diff --git a/OvmfPkg/Include/Library/PlatformInitLib.h b/OvmfPkg/Include/Library/PlatformInitLib.h index b91771d282..2d9c662e37 100644 --- a/OvmfPkg/Include/Library/PlatformInitLib.h +++ b/OvmfPkg/Include/Library/PlatformInitLib.h @@ -18,57 +18,57 @@ The work area is used to support reading from cache in QemuFwCfgLib. It is also used as global variable in Dxe phase. */ typedef struct { + BOOLEAN QemuFwCfgSupported; + BOOLEAN QemuFwCfgDmaSupported; UINT16 FwCfgItem; UINT32 Offset; BOOLEAN Reading; -} QEMU_FW_CFG_CACHE_WORK_AREA; +} QEMU_FW_CFG_WORK_AREA; typedef struct { - EFI_HOB_GUID_TYPE GuidHeader; - UINT16 HostBridgeDevId; + EFI_HOB_GUID_TYPE GuidHeader; + UINT16 HostBridgeDevId; - UINT64 PcdConfidentialComputingGuestAttr; - BOOLEAN SevEsIsEnabled; + UINT64 PcdConfidentialComputingGuestAttr; + BOOLEAN SevEsIsEnabled; - UINT32 BootMode; - BOOLEAN S3Supported; + UINT32 BootMode; + BOOLEAN S3Supported; - BOOLEAN SmmSmramRequire; - BOOLEAN Q35SmramAtDefaultSmbase; - UINT16 Q35TsegMbytes; + BOOLEAN SmmSmramRequire; + BOOLEAN Q35SmramAtDefaultSmbase; + UINT16 Q35TsegMbytes; - UINT32 LowMemory; - UINT64 FirstNonAddress; - UINT8 PhysMemAddressWidth; - UINT32 Uc32Base; - UINT32 Uc32Size; + UINT32 LowMemory; + UINT64 FirstNonAddress; + UINT8 PhysMemAddressWidth; + UINT32 Uc32Base; + UINT32 Uc32Size; - BOOLEAN PcdSetNxForStack; - UINT64 PcdTdxSharedBitMask; + BOOLEAN PcdSetNxForStack; + UINT64 PcdTdxSharedBitMask; - UINT64 PcdPciMmio64Base; - UINT64 PcdPciMmio64Size; - BOOLEAN PcdPciMmio64Override; - UINT32 PcdPciMmio32Base; - UINT32 PcdPciMmio32Size; - UINT64 PcdPciIoBase; - UINT64 PcdPciIoSize; + UINT64 PcdPciMmio64Base; + UINT64 PcdPciMmio64Size; + BOOLEAN PcdPciMmio64Override; + UINT32 PcdPciMmio32Base; + UINT32 PcdPciMmio32Size; + UINT64 PcdPciIoBase; + UINT64 PcdPciIoSize; - UINT64 PcdEmuVariableNvStoreReserved; - UINT32 PcdCpuBootLogicalProcessorNumber; - UINT32 PcdCpuMaxLogicalProcessorNumber; - UINT32 DefaultMaxCpuNumber; + UINT64 PcdEmuVariableNvStoreReserved; + UINT32 PcdCpuBootLogicalProcessorNumber; + UINT32 PcdCpuMaxLogicalProcessorNumber; + UINT32 DefaultMaxCpuNumber; - UINT32 S3AcpiReservedMemoryBase; - UINT32 S3AcpiReservedMemorySize; + UINT32 S3AcpiReservedMemoryBase; + UINT32 S3AcpiReservedMemorySize; - UINT64 FeatureControlValue; + UINT64 FeatureControlValue; - BOOLEAN QemuFwCfgChecked; - BOOLEAN QemuFwCfgSupported; - BOOLEAN QemuFwCfgDmaSupported; + BOOLEAN QemuFwCfgChecked; - QEMU_FW_CFG_CACHE_WORK_AREA QemuFwCfgCacheWorkArea; + QEMU_FW_CFG_WORK_AREA QemuFwCfgWorkArea; } EFI_HOB_PLATFORM_INFO; #pragma pack() diff --git a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgCache.c b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgCache.c index f15ae7a6ec..6cb302a1ed 100644 --- a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgCache.c +++ b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgCache.c @@ -57,20 +57,20 @@ InternalQemuFwCfgItemCached ( } /** - Clear the QEMU_FW_CFG_CACHE_WORK_AREA. + Clear the QEMU_FW_CFG_WORK_AREA. **/ VOID InternalQemuFwCfgCacheResetWorkArea ( VOID ) { - QEMU_FW_CFG_CACHE_WORK_AREA *QemuFwCfgCacheWorkArea; + QEMU_FW_CFG_WORK_AREA *QemuFwCfgWorkArea; - QemuFwCfgCacheWorkArea = InternalQemuFwCfgCacheGetWorkArea (); - if (QemuFwCfgCacheWorkArea != NULL) { - QemuFwCfgCacheWorkArea->FwCfgItem = 0; - QemuFwCfgCacheWorkArea->Offset = 0; - QemuFwCfgCacheWorkArea->Reading = FALSE; + QemuFwCfgWorkArea = InternalQemuFwCfgCacheGetWorkArea (); + if (QemuFwCfgWorkArea != NULL) { + QemuFwCfgWorkArea->FwCfgItem = 0; + QemuFwCfgWorkArea->Offset = 0; + QemuFwCfgWorkArea->Reading = FALSE; } } @@ -84,13 +84,13 @@ InternalQemuFwCfgCacheReading ( VOID ) { - BOOLEAN Reading; - QEMU_FW_CFG_CACHE_WORK_AREA *QemuFwCfgCacheWorkArea; + BOOLEAN Reading; + QEMU_FW_CFG_WORK_AREA *QemuFwCfgWorkArea; - Reading = FALSE; - QemuFwCfgCacheWorkArea = InternalQemuFwCfgCacheGetWorkArea (); - if (QemuFwCfgCacheWorkArea != NULL) { - Reading = QemuFwCfgCacheWorkArea->Reading; + Reading = FALSE; + QemuFwCfgWorkArea = InternalQemuFwCfgCacheGetWorkArea (); + if (QemuFwCfgWorkArea != NULL) { + Reading = QemuFwCfgWorkArea->Reading; } return Reading; @@ -101,22 +101,22 @@ InternalQemuFwCfgCacheSelectItem ( IN FIRMWARE_CONFIG_ITEM Item ) { - QEMU_FW_CFG_CACHE_WORK_AREA *QemuFwCfgCacheWorkArea; + QEMU_FW_CFG_WORK_AREA *QemuFwCfgWorkArea; // Walk thru cached fw_items to see if Item is cached. if (InternalQemuFwCfgItemCached (Item) == NULL) { return FALSE; } - QemuFwCfgCacheWorkArea = InternalQemuFwCfgCacheGetWorkArea (); - if (QemuFwCfgCacheWorkArea == NULL) { + QemuFwCfgWorkArea = InternalQemuFwCfgCacheGetWorkArea (); + if (QemuFwCfgWorkArea == NULL) { DEBUG ((DEBUG_ERROR, "%a: Invalid FwCfg Cache Work Area\n", __func__)); return FALSE; } - QemuFwCfgCacheWorkArea->FwCfgItem = (UINT16)Item; - QemuFwCfgCacheWorkArea->Offset = 0; - QemuFwCfgCacheWorkArea->Reading = TRUE; + QemuFwCfgWorkArea->FwCfgItem = (UINT16)Item; + QemuFwCfgWorkArea->Offset = 0; + QemuFwCfgWorkArea->Reading = TRUE; return TRUE; } @@ -134,43 +134,43 @@ InternalQemuFwCfgCacheReadBytes ( IN OUT VOID *Buffer ) { - QEMU_FW_CFG_CACHE_WORK_AREA *QemuFwCfgCacheWorkArea; - FW_CFG_CACHED_ITEM *CachedItem; - UINTN ReadSize; + QEMU_FW_CFG_WORK_AREA *QemuFwCfgWorkArea; + FW_CFG_CACHED_ITEM *CachedItem; + UINTN ReadSize; if (Buffer == NULL) { return EFI_INVALID_PARAMETER; } - QemuFwCfgCacheWorkArea = InternalQemuFwCfgCacheGetWorkArea (); - if (QemuFwCfgCacheWorkArea == NULL) { + QemuFwCfgWorkArea = InternalQemuFwCfgCacheGetWorkArea (); + if (QemuFwCfgWorkArea == NULL) { return RETURN_NOT_FOUND; } - if (!QemuFwCfgCacheWorkArea->Reading) { + if (!QemuFwCfgWorkArea->Reading) { return RETURN_NOT_READY; } - CachedItem = InternalQemuFwCfgItemCached (QemuFwCfgCacheWorkArea->FwCfgItem); + CachedItem = InternalQemuFwCfgItemCached (QemuFwCfgWorkArea->FwCfgItem); if (CachedItem == NULL) { return RETURN_NOT_FOUND; } - if (QemuFwCfgCacheWorkArea->Offset >= CachedItem->DataSize) { - DEBUG ((DEBUG_ERROR, "%a: Invalid Item Offset(0x%x) in FwCfg Cache\n", __func__, QemuFwCfgCacheWorkArea->Offset)); + if (QemuFwCfgWorkArea->Offset >= CachedItem->DataSize) { + DEBUG ((DEBUG_ERROR, "%a: Invalid Item Offset(0x%x) in FwCfg Cache\n", __func__, QemuFwCfgWorkArea->Offset)); ASSERT (FALSE); return RETURN_ABORTED; } - if (CachedItem->DataSize - QemuFwCfgCacheWorkArea->Offset > Size) { + if (CachedItem->DataSize - QemuFwCfgWorkArea->Offset > Size) { ReadSize = Size; } else { - ReadSize = CachedItem->DataSize - QemuFwCfgCacheWorkArea->Offset; + ReadSize = CachedItem->DataSize - QemuFwCfgWorkArea->Offset; } - CopyMem (Buffer, (UINT8 *)CachedItem + sizeof (FW_CFG_CACHED_ITEM) + QemuFwCfgCacheWorkArea->Offset, ReadSize); - QemuFwCfgCacheWorkArea->Offset += (UINT32)ReadSize; + CopyMem (Buffer, (UINT8 *)CachedItem + sizeof (FW_CFG_CACHED_ITEM) + QemuFwCfgWorkArea->Offset, ReadSize); + QemuFwCfgWorkArea->Offset += (UINT32)ReadSize; - DEBUG ((DEBUG_VERBOSE, "%a: found Item 0x%x in FwCfg Cache\n", __func__, QemuFwCfgCacheWorkArea->FwCfgItem)); + DEBUG ((DEBUG_VERBOSE, "%a: found Item 0x%x in FwCfg Cache\n", __func__, QemuFwCfgWorkArea->FwCfgItem)); return RETURN_SUCCESS; } diff --git a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgCacheInit.c b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgCacheInit.c index 25fd1f10d7..d3220c8f03 100644 --- a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgCacheInit.c +++ b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgCacheInit.c @@ -240,9 +240,9 @@ InternalQemuFwCfgInitCache ( return EFI_INVALID_PARAMETER; } - PlatformInfoHob->QemuFwCfgCacheWorkArea.FwCfgItem = INVALID_FW_CFG_ITEM; - PlatformInfoHob->QemuFwCfgCacheWorkArea.Offset = 0; - PlatformInfoHob->QemuFwCfgCacheWorkArea.Reading = FALSE; + PlatformInfoHob->QemuFwCfgWorkArea.FwCfgItem = INVALID_FW_CFG_ITEM; + PlatformInfoHob->QemuFwCfgWorkArea.Offset = 0; + PlatformInfoHob->QemuFwCfgWorkArea.Reading = FALSE; if (!QemuFwCfgIsAvailable ()) { return EFI_UNSUPPORTED; diff --git a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgDxe.c b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgDxe.c index d68928fe8a..e8b2caf416 100644 --- a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgDxe.c +++ b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgDxe.c @@ -24,12 +24,9 @@ #include "QemuFwCfgLibInternal.h" -STATIC BOOLEAN mQemuFwCfgSupported = FALSE; -STATIC BOOLEAN mQemuFwCfgDmaSupported; - STATIC EDKII_IOMMU_PROTOCOL *mIoMmuProtocol; -STATIC QEMU_FW_CFG_CACHE_WORK_AREA mFwCfgCacheWorkArea = { 0 }; +STATIC QEMU_FW_CFG_WORK_AREA mQemuFwCfgWorkArea = { 0 }; /** Returns a boolean indicating if the firmware configuration interface @@ -64,8 +61,8 @@ QemuFwCfgInitialize ( // Enable the access routines while probing to see if it is supported. // For probing we always use the IO Port (IoReadFifo8()) access method. // - mQemuFwCfgSupported = TRUE; - mQemuFwCfgDmaSupported = FALSE; + mQemuFwCfgWorkArea.QemuFwCfgSupported = TRUE; + mQemuFwCfgWorkArea.QemuFwCfgDmaSupported = FALSE; QemuFwCfgSelectItem (QemuFwCfgItemSignature); Signature = QemuFwCfgRead32 (); @@ -78,20 +75,20 @@ QemuFwCfgInitialize ( ) { DEBUG ((DEBUG_INFO, "QemuFwCfg interface not supported.\n")); - mQemuFwCfgSupported = FALSE; + mQemuFwCfgWorkArea.QemuFwCfgSupported = FALSE; return RETURN_SUCCESS; } if ((Revision & FW_CFG_F_DMA) == 0) { DEBUG ((DEBUG_INFO, "QemuFwCfg interface (IO Port) is supported.\n")); } else { - mQemuFwCfgDmaSupported = TRUE; + mQemuFwCfgWorkArea.QemuFwCfgDmaSupported = TRUE; DEBUG ((DEBUG_INFO, "QemuFwCfg interface (DMA) is supported.\n")); } CcGuestAttr = PcdGet64 (PcdConfidentialComputingGuestAttr); - if (mQemuFwCfgDmaSupported && (CC_GUEST_IS_SEV (CcGuestAttr) || - CC_GUEST_IS_TDX (CcGuestAttr))) + if (mQemuFwCfgWorkArea.QemuFwCfgDmaSupported && (CC_GUEST_IS_SEV (CcGuestAttr) || + CC_GUEST_IS_TDX (CcGuestAttr))) { EFI_STATUS Status; @@ -133,7 +130,7 @@ InternalQemuFwCfgIsAvailable ( VOID ) { - return mQemuFwCfgSupported; + return mQemuFwCfgWorkArea.QemuFwCfgSupported; } /** @@ -148,7 +145,7 @@ InternalQemuFwCfgDmaIsAvailable ( VOID ) { - return mQemuFwCfgDmaSupported; + return mQemuFwCfgWorkArea.QemuFwCfgDmaSupported; } /** @@ -514,17 +511,17 @@ InternalQemuFwCfgCheckOvmfWorkArea ( } /** - Get the pointer to the QEMU_FW_CFG_CACHE_WORK_AREA. This data is used as the + Get the pointer to the QEMU_FW_CFG_WORK_AREA. This data is used as the workarea to record the ongoing fw_cfg item and offset. - @retval QEMU_FW_CFG_CACHE_WORK_AREA Pointer to the QEMU_FW_CFG_CACHE_WORK_AREA - @retval NULL QEMU_FW_CFG_CACHE_WORK_AREA doesn't exist + @retval QEMU_FW_CFG_WORK_AREA Pointer to the QEMU_FW_CFG_WORK_AREA + @retval NULL QEMU_FW_CFG_WORK_AREA doesn't exist **/ -QEMU_FW_CFG_CACHE_WORK_AREA * +QEMU_FW_CFG_WORK_AREA * InternalQemuFwCfgCacheGetWorkArea ( VOID ) { - return &mFwCfgCacheWorkArea; + return &mQemuFwCfgWorkArea; } RETURN_STATUS diff --git a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c index 1863a81ee6..9e896fb6b5 100644 --- a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c +++ b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c @@ -135,19 +135,19 @@ InternalQemuFwCfgCacheSkipBytes ( IN UINT32 Size ) { - QEMU_FW_CFG_CACHE_WORK_AREA *QemuFwCfgCacheWorkArea; + QEMU_FW_CFG_WORK_AREA *QemuFwCfgWorkArea; if (Size == 0) { return; } - QemuFwCfgCacheWorkArea = InternalQemuFwCfgCacheGetWorkArea (); - if ((QemuFwCfgCacheWorkArea->Offset + Size) > MAX_UINT32) { + QemuFwCfgWorkArea = InternalQemuFwCfgCacheGetWorkArea (); + if ((QemuFwCfgWorkArea->Offset + Size) > MAX_UINT32) { DEBUG ((DEBUG_ERROR, "%a: Integer overflow with invalid offset size\n", __func__)); ASSERT (FALSE); - QemuFwCfgCacheWorkArea->Offset = MAX_UINT32; + QemuFwCfgWorkArea->Offset = MAX_UINT32; } else { - QemuFwCfgCacheWorkArea->Offset += Size; + QemuFwCfgWorkArea->Offset += Size; } } diff --git a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLibInternal.h b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLibInternal.h index acbaf0017d..a33caff83a 100644 --- a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLibInternal.h +++ b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLibInternal.h @@ -130,18 +130,18 @@ InternalQemuFwCfgCacheSelectItem ( ); /** - Get the pointer to the QEMU_FW_CFG_CACHE_WORK_AREA. This data is used as the + Get the pointer to the QEMU_FW_CFG_WORK_AREA. This data is used as the workarea to record the ongoing fw_cfg item and offset. - @retval QEMU_FW_CFG_CACHE_WORK_AREA Pointer to the QEMU_FW_CFG_CACHE_WORK_AREA - @retval NULL QEMU_FW_CFG_CACHE_WORK_AREA doesn't exist + @retval QEMU_FW_CFG_WORK_AREA Pointer to the QEMU_FW_CFG_WORK_AREA + @retval NULL QEMU_FW_CFG_WORK_AREA doesn't exist **/ -QEMU_FW_CFG_CACHE_WORK_AREA * +QEMU_FW_CFG_WORK_AREA * InternalQemuFwCfgCacheGetWorkArea ( VOID ); /** - Clear the QEMU_FW_CFG_CACHE_WORK_AREA. + Clear the QEMU_FW_CFG_WORK_AREA. **/ VOID InternalQemuFwCfgCacheResetWorkArea ( diff --git a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPei.c b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPei.c index 6df36d2155..9c69f522d6 100644 --- a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPei.c +++ b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPei.c @@ -120,8 +120,8 @@ QemuFwCfgGetPlatformInfo ( if (!PlatformInfoHob->QemuFwCfgChecked) { QemuFwCfgProbe ( - &PlatformInfoHob->QemuFwCfgSupported, - &PlatformInfoHob->QemuFwCfgDmaSupported + &PlatformInfoHob->QemuFwCfgWorkArea.QemuFwCfgSupported, + &PlatformInfoHob->QemuFwCfgWorkArea.QemuFwCfgDmaSupported ); PlatformInfoHob->QemuFwCfgChecked = TRUE; } @@ -154,7 +154,7 @@ InternalQemuFwCfgIsAvailable ( { EFI_HOB_PLATFORM_INFO *PlatformInfoHob = QemuFwCfgGetPlatformInfo (); - return PlatformInfoHob->QemuFwCfgSupported; + return PlatformInfoHob->QemuFwCfgWorkArea.QemuFwCfgSupported; } /** @@ -171,7 +171,7 @@ InternalQemuFwCfgDmaIsAvailable ( { EFI_HOB_PLATFORM_INFO *PlatformInfoHob = QemuFwCfgGetPlatformInfo (); - return PlatformInfoHob->QemuFwCfgDmaSupported; + return PlatformInfoHob->QemuFwCfgWorkArea.QemuFwCfgDmaSupported; } /** @@ -253,12 +253,12 @@ InternalQemuFwCfgDmaBytes ( } /** - Get the pointer to the QEMU_FW_CFG_CACHE_WORK_AREA. This data is used as the + Get the pointer to the QEMU_FW_CFG_WORK_AREA. This data is used as the workarea to record the onging fw_cfg item and offset. - @retval QEMU_FW_CFG_CACHE_WORK_AREA Pointer to the QEMU_FW_CFG_CACHE_WORK_AREA - @retval NULL QEMU_FW_CFG_CACHE_WORK_AREA doesn't exist + @retval QEMU_FW_CFG_WORK_AREA Pointer to the QEMU_FW_CFG_WORK_AREA + @retval NULL QEMU_FW_CFG_WORK_AREA doesn't exist **/ -QEMU_FW_CFG_CACHE_WORK_AREA * +QEMU_FW_CFG_WORK_AREA * InternalQemuFwCfgCacheGetWorkArea ( VOID ) @@ -272,7 +272,7 @@ InternalQemuFwCfgCacheGetWorkArea ( } PlatformHobinfo = (EFI_HOB_PLATFORM_INFO *)(VOID *)GET_GUID_HOB_DATA (GuidHob); - return &(PlatformHobinfo->QemuFwCfgCacheWorkArea); + return &(PlatformHobinfo->QemuFwCfgWorkArea); } /** diff --git a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgSec.c b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgSec.c index 207f322d0e..31bafa9195 100644 --- a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgSec.c +++ b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgSec.c @@ -150,12 +150,12 @@ InternalQemuFwCfgCheckOvmfWorkArea ( } /** - Get the pointer to the QEMU_FW_CFG_CACHE_WORK_AREA. This data is used as the + Get the pointer to the QEMU_FW_CFG_WORK_AREA. This data is used as the workarea to record the ongoing fw_cfg item and offset. - @retval QEMU_FW_CFG_CACHE_WORK_AREA Pointer to the QEMU_FW_CFG_CACHE_WORK_AREA - @retval NULL QEMU_FW_CFG_CACHE_WORK_AREA doesn't exist + @retval QEMU_FW_CFG_WORK_AREA Pointer to the QEMU_FW_CFG_WORK_AREA + @retval NULL QEMU_FW_CFG_WORK_AREA doesn't exist **/ -QEMU_FW_CFG_CACHE_WORK_AREA * +QEMU_FW_CFG_WORK_AREA * InternalQemuFwCfgCacheGetWorkArea ( VOID ) @@ -173,7 +173,7 @@ InternalQemuFwCfgCacheGetWorkArea ( } PlatformHobinfo = (EFI_HOB_PLATFORM_INFO *)(VOID *)GET_GUID_HOB_DATA (GuidHob); - return &(PlatformHobinfo->QemuFwCfgCacheWorkArea); + return &(PlatformHobinfo->QemuFwCfgWorkArea); } /**