Re: [edk2-devel] [PATCH 3/3] UefiCpuPkg: Simplify the code to set smm page table as RO
> + PageTableBase = AsmReadCr3 () & PAGING_4K_ADDRESS_MASK_64; > + > + // > + // ConvertMemoryPageAttributes might update mPageTablePool. It's safer to > + // remember original one in advance. > + // > + HeadPool = mPageTablePool; > + Pool = HeadPool; > + do { > +Address = (EFI_PHYSICAL_ADDRESS)(UINTN)Pool & > PAGE_TABLE_POOL_ALIGN_MASK; 1. When is the Pool not aligned on 128KB boundary? If it's guaranteed, can we remove the "& PAGE_TABLE_POOL_ALIGN_MASK"? > +PoolSize = Pool->Offset + EFI_PAGES_TO_SIZE (Pool->FreePages); > + > +ConvertMemoryPageAttributes (PageTableBase, m5LevelPagingNeeded, > Address, PoolSize, EFI_MEMORY_RO, TRUE, > NULL, NULL); 2. Can you please explain in comments that above call is to make the entire pool including header, used-memory, free-memory as read-only? 3. It's better to use LinkedList library APIs from BaseLib. The comments apply to the first patch as well. But I am fine if you decide not to do it in this patch. > + { > +if (sizeof (UINTN) == sizeof (UINT64)) { > + // > + // Restriction on access to non-SMRAM memory and heap guard could not > be enabled at the same time. > + // > + ASSERT ( > +!(IsRestrictedMemoryAccess () && > + (PcdGet8 (PcdHeapGuardPropertyMask) & (BIT3 | BIT2)) != 0) > +); > + > + // > + // Restriction on access to non-SMRAM memory and SMM profile could not > be enabled at the same time. > + // > + ASSERT (!(IsRestrictedMemoryAccess () && FeaturePcdGet > (PcdCpuSmmProfileEnable))); > +} 4. I don't think we still need the above two assertions. But let's not clean up the code in your patch. @Wang, Jian J -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#97553): https://edk2.groups.io/g/devel/message/97553 Mute This Topic: https://groups.io/mt/95703349/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH] ShellPkg: Multiple Coverity issues were found from EDK2 ShellPkg
Few Coverity changes were done in the following files ShellProtocol.c and UefiShellLib.c. so, will include those changes and send as V3 patch. -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#97552): https://edk2.groups.io/g/devel/message/97552 Mute This Topic: https://groups.io/mt/95329853/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH 3/3] MdeModulePkg/Bus/Pci/XhciDxe: Check port is compatible before getting PSIV
Reviewed-by: Hao A Wu I will make minor modification to: * Function description comment * Input parameter name of XhcCheckUsbPortSpeedUsedPsic() to make the declaration (in .H) and the definition (in .C) match. Best Regards, Hao Wu > -Original Message- > From: devel@edk2.groups.io On Behalf Of Sean > Rhodes > Sent: Friday, December 16, 2022 4:58 PM > To: devel@edk2.groups.io > Cc: Rhodes, Sean > Subject: [edk2-devel] [PATCH 3/3] MdeModulePkg/Bus/Pci/XhciDxe: Check > port is compatible before getting PSIV > > On some platforms, including Sky Lake and Kaby Lake, the PSIV (Protocol > Speed ID Value) indices are shared between Protocol Speed ID DWORD' in > the extended capabilities registers for both USB2 (Full Speed) and USB3 > (Super Speed). > > An example can be found below: > > XhcCheckUsbPortSpeedUsedPsic: checking for USB2 ext caps > XhciPsivGetPsid: found 3 PSID entries > XhciPsivGetPsid: looking for port speed 1 > XhciPsivGetPsid: PSIV 1 PSIE 2 PLT 0 PSIM 12 > XhciPsivGetPsid: PSIV 2 PSIE 1 PLT 0 PSIM 1500 > XhciPsivGetPsid: PSIV 3 PSIE 2 PLT 0 PSIM 480 > XhcCheckUsbPortSpeedUsedPsic: checking for USB3 ext caps > XhciPsivGetPsid: found 3 PSID entries > XhciPsivGetPsid: looking for port speed 1 > XhciPsivGetPsid: PSIV 1 PSIE 3 PLT 0 PSIM 5 > XhciPsivGetPsid: PSIV 2 PSIE 3 PLT 0 PSIM 10 > XhciPsivGetPsid: PSIV 34 PSIE 2 PLT 0 PSIM 1248 > > The result is edk2 detecting USB2 devices as USB3 devices, which > consequently causes enumeration to fail. > > To avoid incorrect detection, check the Compatible Port Offset to find > the starting Port of Root Hubs that support the protocol. > > Signed-off-by: Sean Rhodes > --- > MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c| 2 +- > MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.c | 35 +-- > --- > MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.h | 8 +++--- > 3 files changed, 35 insertions(+), 10 deletions(-) > > diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c > b/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c > index 8dd7a8fbb7..461b2cd9b5 100644 > --- a/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c > +++ b/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c > @@ -405,7 +405,7 @@ XhcGetRootHubPortStatus ( >// Section 7.2 xHCI Support Protocol Capability > >// > >if (PortSpeed > 0) { > > -PortStatus->PortStatus = XhcCheckUsbPortSpeedUsedPsic (Xhc, > PortSpeed); > > +PortStatus->PortStatus = XhcCheckUsbPortSpeedUsedPsic (Xhc, > PortSpeed, PortNumber); > > // If no match found in ext cap reg, fall back to PORTSC > > if (PortStatus->PortStatus == 0) { > >// > > diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.c > b/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.c > index 2b4a4b2444..5700fc5fb8 100644 > --- a/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.c > +++ b/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.c > @@ -636,6 +636,7 @@ XhcGetSupportedProtocolCapabilityAddr ( >@param XhcThe XHCI Instance. > >@param ExtCapOffset The USB Major Version in xHCI Support Protocol > Capability Field > >@param PortSpeed The Port Speed Field in USB PortSc register > > + @param PortNumber The Port Number (0-indexed) > > > >@return The Protocol Speed ID (PSI) from xHCI Supported Protocol > capability register. > > > > @@ -644,12 +645,15 @@ UINT32 > XhciPsivGetPsid ( > >IN USB_XHCI_INSTANCE *Xhc, > >IN UINT32 ExtCapOffset, > > - IN UINT8 PortSpeed > > + IN UINT8 PortSpeed, > > + IN UINT8 PortNumber > >) > > { > >XHC_SUPPORTED_PROTOCOL_DW2PortId; > >XHC_SUPPORTED_PROTOCOL_PROTOCOL_SPEED_ID Reg; > >UINT32Count; > > + UINT32MinPortIndex; > > + UINT32MaxPortIndex; > > > >if ((Xhc == NULL) || (ExtCapOffset == 0x)) { > > return 0; > > @@ -663,6 +667,23 @@ XhciPsivGetPsid ( >// > >PortId.Dword = XhcReadExtCapReg (Xhc, ExtCapOffset + > XHC_SUPPORTED_PROTOCOL_DW2_OFFSET); > > > > + // > > + // According to XHCI 1.1 spec November 2017, valid values > > + // for CompPortOffset are 1 to CompPortCount - 1. > > + // > > + // PortNumber is zero-indexed, so subtract 1. > > + // > > + if ((PortId.Data.CompPortOffset == 0) || (PortId.Data.CompPortCount == > 0)) { > > +return 0; > > + } > > + > > + MinPortIndex = PortId.Data.CompPortOffset - 1; > > + MaxPortIndex = MinPortIndex + PortId.Data.CompPortCount - 1; > > + > > + if ((PortNumber < MinPortIndex) || (PortNumber > MaxPortIndex)) { > > +return 0; > > + } > > + > >for (Count = 0; Count < PortId.Data.Psic; Count++) { > > Reg.Dword = XhcReadExtCapReg (Xhc, ExtCapOffset + > XHC_SUPPORTED_PROTOCOL_PSI_OFFSET + (Count << 2)); > > if (Reg.Data.Psiv == PortSpeed) { > > @@ -676,8 +697,9 @@ XhciPsivGetPsid ( > /** > >Find PortSpeed value match case
Re: [edk2-devel] [PATCH v2] PcAtChipsetPkg: Move RTC PCD to dynamic PCD
The initial goal was to remove dynamic PCD dependency from bootloader. Is that still the goal? If yes, maybe depending on dynamic PCD is not a good idea. Thanks, Ray > -Original Message- > From: Liu, KasimX > Sent: Monday, December 19, 2022 3:40 PM > To: devel@edk2.groups.io > Cc: Liu, KasimX ; Dong, Guo ; Ni, > Ray ; Lu, James > ; Guo, Gua > Subject: [PATCH v2] PcAtChipsetPkg: Move RTC PCD to dynamic PCD > > From: KasimX Liu > > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4193 > > In order to remove RTC_INDEX/RTC_TARGET from > the UplBuild macro list,change the RTC_INDEX > /RTC_TARGET type from PcdsFixedAtBuild to PcdsDynamicEx > > Cc: Guo Dong > Cc: Ray Ni > Cc: James Lu > Cc: Gua Guo > Signed-off-by: KasimX Liu > --- > PcAtChipsetPkg/PcAtChipsetPkg.dec | 16 > 1 file changed, 8 insertions(+), 8 deletions(-) > > diff --git a/PcAtChipsetPkg/PcAtChipsetPkg.dec > b/PcAtChipsetPkg/PcAtChipsetPkg.dec > index ed2d95550b..a53ca777e8 100644 > --- a/PcAtChipsetPkg/PcAtChipsetPkg.dec > +++ b/PcAtChipsetPkg/PcAtChipsetPkg.dec > @@ -84,6 +84,14 @@ ># @Prompt RTC Target Register address > >gPcAtChipsetPkgTokenSpaceGuid.PcdRtcTargetRegister64|0x0|UINT64|0x0023 > > > > + ## Specifies RTC Index Register address in I/O space. > > + # @Prompt RTC Index Register address > > + gPcAtChipsetPkgTokenSpaceGuid.PcdRtcIndexRegister|0x70|UINT8|0x001E > > + > > + ## Specifies RTC Target Register address in I/O space. > > + # @Prompt RTC Target Register address > > + gPcAtChipsetPkgTokenSpaceGuid.PcdRtcTargetRegister|0x71|UINT8|0x001F > > + > > [PcdsFixedAtBuild, PcdsPatchableInModule] > >## Defines the ACPI register set base address. > ># The invalid 0x is as its default value. It must be configured to > the real value. > > @@ -146,14 +154,6 @@ ># @Prompt Initial value for Register_D in RTC. > > > gPcAtChipsetPkgTokenSpaceGuid.PcdInitialValueRtcRegisterD|0x00|UINT8|0x001D > > > > - ## Specifies RTC Index Register address in I/O space. > > - # @Prompt RTC Index Register address > > - gPcAtChipsetPkgTokenSpaceGuid.PcdRtcIndexRegister|0x70|UINT8|0x001E > > - > > - ## Specifies RTC Target Register address in I/O space. > > - # @Prompt RTC Target Register address > > - gPcAtChipsetPkgTokenSpaceGuid.PcdRtcTargetRegister|0x71|UINT8|0x001F > > - > >## RTC Update Timeout Value(microsecond). > ># @Prompt RTC Update Timeout Value. > > > gPcAtChipsetPkgTokenSpaceGuid.PcdRealTimeClockUpdateTimeout|10|UINT32|0x0020 > > -- > 2.32.0.windows.2 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#97550): https://edk2.groups.io/g/devel/message/97550 Mute This Topic: https://groups.io/mt/95760949/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH V2] MdeModulePkg/XhciPei: Unlinked XhciPei memory block
Hello, My take is that unlike in DXE, the UsbHcFreeMemBlock() implementation in PEI phase does not perform freeing the memory. So I think both the solution: * Provided at https://edk2.groups.io/g/devel/topic/92833071#92165, which aligns with EhciPei * Mentioned at the end of your previous reply, which aligns with XhciDxe should work fine. I will leave it to you for the final decision. Best Regards, Hao Wu > -Original Message- > From: He, Jiangang > Sent: Friday, December 16, 2022 12:48 AM > To: Chang, Abner ; Wu, Hao A > ; devel@edk2.groups.io > Cc: Lin, Kuei-Hung (Timothy) ; Ni, Ray > ; Zeng, Star ; Sun, Zhikai > ; Kirkendall, Garrett > Subject: RE: [PATCH V2] MdeModulePkg/XhciPei: Unlinked XhciPei memory > block > > [AMD Official Use Only - General] > > Yes, it is the same issue discussed in > https://edk2.groups.io/g/devel/topic/92833071#92165 > > MdeModulePkg\Bus\Pci\XhciPei\UsbHcMem.c > > for (Block = Pool->Head->Next; Block != NULL; Block = Pool->Head->Next) { > // UsbHcUnlinkMemBlock (Pool->Head, Block); > UsbHcFreeMemBlock (Pool, Block); > } > Block = Pool->Head->Next never change without calling > UsbHcUnlinkMemBlock (Pool->Head, Block), therefore dead loop. > > Our proposed fix came from dxe version of the equivalent file > MdeModulePkg\Bus\Pci\XhciDxe\UsbHcMem.c but swapped two routine call > order (Now I think it is incorrect as clarified below). > for (Block = Pool->Head->Next; Block != NULL; Block = Pool->Head->Next) { > UsbHcFreeMemBlock (Pool, Block); > UsbHcUnlinkMemBlock (Pool->Head, Block); > } > > https://edk2.groups.io/g/devel/topic/92833071#92165 proposed fix: > > for (Block = Pool->Head->Next; Block != NULL; Block = Block ->Next) { > // UsbHcUnlinkMemBlock (Pool->Head, Block); > UsbHcFreeMemBlock (Pool, Block); > } > > I think it again, both proposals have problem of reading memory content in > the buffer that has just been freed. > > for (Block = Pool->Head->Next; Block != NULL; Block = Pool->Head->Next) { > UsbHcUnlinkMemBlock (Pool->Head, Block); > UsbHcFreeMemBlock (Pool, Block); > } > is right solution and matches dxe version of UsbHcMem.c. > > Thanks, > Jiangang > > -Original Message- > From: Chang, Abner > Sent: Wednesday, December 14, 2022 8:12 PM > To: Wu, Hao A ; devel@edk2.groups.io > Cc: Lin, Kuei-Hung (Timothy) ; Ni, Ray > ; Zeng, Star ; Sun, Zhikai > ; Kirkendall, Garrett ; > He, Jiangang > Subject: RE: [PATCH V2] MdeModulePkg/XhciPei: Unlinked XhciPei memory > block > > [AMD Official Use Only - General] > > Hi Jiangang, > Could you please provide the context of this patch? > > Thanks > Abner > > > -Original Message- > > From: Wu, Hao A > > Sent: Monday, December 12, 2022 11:27 AM > > To: Chang, Abner ; devel@edk2.groups.io > > Cc: Lin, Kuei-Hung (Timothy) ; Ni, Ray > > ; Zeng, Star ; Sun, Zhikai > > ; Kirkendall, Garrett > > > > Subject: RE: [PATCH V2] MdeModulePkg/XhciPei: Unlinked XhciPei memory > > block > > > > Caution: This message originated from an External Source. Use proper > > caution when opening attachments, clicking links, or responding. > > > > > > Sorry for a question, may I know what issue was met that leads to the > > proposed patch? > > Could you help to check if it is related with the topic discussed in > > > https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fedk2 > > .gr > > > oups.io%2Fg%2Fdevel%2Ftopic%2F92833071%2392165&data=05%7C0 > 1%7 > > > Cabner.chang%40amd.com%7Ccac49c2820e741b8c48a08dadbf0cc24%7C3d > d8 > > > 961fe4884e608e11a82d994e183d%7C0%7C0%7C638064124512265992%7C > Unk > > > nown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6I > k1h > > > aWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=z1Q7NRxN4GMA > %2 > > FBxYd2D7Gnkc3aTD23mRnwNF3H5wE0k%3D&reserved=0? Thanks in > advance. > > > > Best Regards, > > Hao Wu > > > > > -Original Message- > > > From: abner.ch...@amd.com > > > Sent: Saturday, December 10, 2022 11:13 PM > > > To: devel@edk2.groups.io > > > Cc: kuei-hung@amd.com; Wu, Hao A ; Ni, Ray > > > ; Garrett Kirkendall ; > > > Abner Chang > > > Subject: [PATCH V2] MdeModulePkg/XhciPei: Unlinked XhciPei memory > > > block > > > > > > From: Abner Chang > > > > > > In V2: Add AMD copyright. > > > > > > Unlink the XhciPei memory block when it has been freed. > > > > > > Signed-off-by: Kuei-Hung Lin > > > Cc: Hao A Wu > > > Cc: Ray Ni > > > Cc: Garrett Kirkendall > > > Cc: Abner Chang > > > --- > > > MdeModulePkg/Bus/Pci/XhciPei/UsbHcMem.c | 29 > > > - > > > 1 file changed, 28 insertions(+), 1 deletion(-) > > > > > > diff --git a/MdeModulePkg/Bus/Pci/XhciPei/UsbHcMem.c > > > b/MdeModulePkg/Bus/Pci/XhciPei/UsbHcMem.c > > > index c64b38fcfc8..39ba31b0913 100644 > > > --- a/MdeModulePkg/Bus/Pci/XhciPei/UsbHcMem.c > > > +++ b/MdeModulePkg/Bus/Pci/XhciPei/UsbHcMem.c > > > @@ -3,6 +3,7 @@ PEIM to produce gPeiUsb2HostControllerPpiGuid > based > > > on gPeiUsbControllerPpiGuid whic
Re: [edk2-devel] [PATCH 2/3] UefiCpuPkg: Remove unused API in SmmCpuFeaturesLib.h
Reviewed-by: Ray Ni > -Original Message- > From: Tan, Dun > Sent: Friday, December 16, 2022 11:01 AM > To: devel@edk2.groups.io > Cc: Dong, Eric ; Ni, Ray ; Kumar, > Rahul R > Subject: [PATCH 2/3] UefiCpuPkg: Remove unused API in SmmCpuFeaturesLib.h > > Remove SmmCpuFeaturesAllocatePageTableMemory in this headfile. > This API is not used by PiSmmCpuDxeSmm driver any more. Also > no other files use this API. > > Signed-off-by: Dun Tan > Cc: Eric Dong > Cc: Ray Ni > Cc: Rahul Kumar > --- > UefiCpuPkg/Include/Library/SmmCpuFeaturesLib.h | 25 - > 1 file changed, 25 deletions(-) > > diff --git a/UefiCpuPkg/Include/Library/SmmCpuFeaturesLib.h > b/UefiCpuPkg/Include/Library/SmmCpuFeaturesLib.h > index 54cae865a2..52160c7145 100644 > --- a/UefiCpuPkg/Include/Library/SmmCpuFeaturesLib.h > +++ b/UefiCpuPkg/Include/Library/SmmCpuFeaturesLib.h > @@ -386,29 +386,4 @@ SmmCpuFeaturesCompleteSmmReadyToLock ( >VOID >); > > -/** > - This API provides a method for a CPU to allocate a specific region for > storing page tables. > - > - This API can be called more once to allocate memory for page tables. > - > - Allocates the number of 4KB pages of type EfiRuntimeServicesData and > returns a pointer to the > - allocated buffer. The buffer returned is aligned on a 4KB boundary. If > Pages is 0, then NULL > - is returned. If there is not enough memory remaining to satisfy the > request, then NULL is > - returned. > - > - This function can also return NULL if there is no preference on where the > page tables are allocated in SMRAM. > - > - @param Pages The number of 4 KB pages to allocate. > - > - @return A pointer to the allocated buffer for page tables. > - @retval NULL Fail to allocate a specific region for storing page > tables, > -Or there is no preference on where the page tables are > allocated in SMRAM. > - > -**/ > -VOID * > -EFIAPI > -SmmCpuFeaturesAllocatePageTableMemory ( > - IN UINTN Pages > - ); > - > #endif > -- > 2.31.1.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#97548): https://edk2.groups.io/g/devel/message/97548 Mute This Topic: https://groups.io/mt/95703348/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH 1/3] UefiCpuPkg/PiSmmCpuDxeSmm: Introduce page table pool mechanism
> + // > + // If page table memory has been marked as RO, mark the new pool pages as > read-only. > + // > + if (mIsReadOnlyPageTable) { > +AsmWriteCr0 (AsmReadCr0 () & ~CR0_WP); > +SmmSetMemoryAttributes ((EFI_PHYSICAL_ADDRESS)(UINTN)Buffer, > EFI_PAGES_TO_SIZE (PoolPages), > EFI_MEMORY_RO); > +AsmWriteCr0 (AsmReadCr0 () | CR0_WP); > + } > + If you check other logic that clears WP bit in CR0, CET is disabled before clearing WP. You need to follow the same pattern here. Other looks good to me. -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#97547): https://edk2.groups.io/g/devel/message/97547 Mute This Topic: https://groups.io/mt/95703346/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
[edk2-devel] [PATCH 1/1] CryptoPkg: Make Protocol Service API backward compatible
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4197 Using older Crypto protocol will be allowed. Each function wrapper will be annotated to require a minimum required version of the crypto protocol and assert if called when the version is not compatible. Ths minimum version difined as the version when the API was introduced. Details: ///Parallel hash: MinVersion 8 ParallelHash256HashAll, /// HMAC SHA256 (continued): MinVersion 9 HmacSha256All, /// HMAC SHA384: MinVersion 9 HmacSha384New, ... HmacSha384All, /// HKDF (continued): MinVersion 10 HkdfSha256Extract, ... HkdfSha384Expand, /// Aead Aes GCM: MinVersion 11 AeadAesGcmEncrypt, AeadAesGcmDecrypt, /// Big Numbers: MinVersion 12 BigNumInit, ... BigNumAddMod, /// EC: MinVersion 13 EcGroupInit, ... EcDhComputeKey, /// TLS (continued): MinVersion 14 TlsShutdown, ... TlsGetExportKey, /// Ec (Continued): MinVersion 15 EcGetPublicKeyFromX509, ... EcDsaVerify, /// X509 (Continued): MinVersion 16 X509GetVersion, ... X509GetExtendedBasicConstraints /// Others: MinVersion 7 Cc: Jiewen Yao Cc: Jian J Wang Cc: Xiaoyu Lu Cc: Guomin Jiang Signed-off-by: Yi Li --- .../BaseCryptLibOnProtocolPpi/CryptLib.c | 449 +- .../BaseCryptLibOnProtocolPpi/DxeCryptLib.c | 9 - .../BaseCryptLibOnProtocolPpi/PeiCryptLib.c | 8 - .../BaseCryptLibOnProtocolPpi/SmmCryptLib.c | 9 - 4 files changed, 227 insertions(+), 248 deletions(-) diff --git a/CryptoPkg/Library/BaseCryptLibOnProtocolPpi/CryptLib.c b/CryptoPkg/Library/BaseCryptLibOnProtocolPpi/CryptLib.c index 4e31bc278e..e470a0f0d4 100644 --- a/CryptoPkg/Library/BaseCryptLibOnProtocolPpi/CryptLib.c +++ b/CryptoPkg/Library/BaseCryptLibOnProtocolPpi/CryptLib.c @@ -24,18 +24,20 @@ @param Args The argument list to pass to Function. @param ErrorReturnValue The value to return if the protocol is NULL or the service in the protocol is NULL. - -**/ -#define CALL_CRYPTO_SERVICE(Function, Args, ErrorReturnValue) \ - do { \ -EDKII_CRYPTO_PROTOCOL *CryptoServices;\ - \ -CryptoServices = (EDKII_CRYPTO_PROTOCOL *)GetCryptoServices ();\ -if (CryptoServices != NULL && CryptoServices->Function != NULL) { \ - return (CryptoServices->Function) Args; \ -} \ -CryptoServiceNotAvailable (#Function); \ -return ErrorReturnValue; \ + @param MinVersionThe minimum protocol version that supports the API. + +**/ +#define CALL_CRYPTO_SERVICE(Function, Args, ErrorReturnValue, MinVersion) \ + do {\ +EDKII_CRYPTO_PROTOCOL *CryptoServices; \ + \ +CryptoServices = (EDKII_CRYPTO_PROTOCOL *)GetCryptoServices (); \ +if (CryptoServices != NULL && CryptoServices->Function != NULL && \ +CryptoServices->GetVersion () >= MinVersion) {\ + return (CryptoServices->Function) Args; \ +} \ +CryptoServiceNotAvailable (#Function);\ +return ErrorReturnValue; \ } while (FALSE); /** @@ -45,14 +47,16 @@ @param Function Name of the EDK II Crypto Protocol service to call. @param Args The argument list to pass to Function. + @param MinVersionThe minimum protocol version that supports the API. **/ -#define CALL_VOID_CRYPTO_SERVICE(Function, Args) \ +#define CALL_VOID_CRYPTO_SERVICE(Function, Args, MinVersion) \ do { \ EDKII_CRYPTO_PROTOCOL *CryptoServices;\ \ CryptoServices = (EDKII_CRYPTO_PROTOCOL *)GetCryptoServices ();\ -if (CryptoServices != NULL && CryptoServices->Function != NULL) { \ +if (CryptoServices != NULL && CryptoServices->Function != NULL && \ +CryptoServices->GetVersion () >= MinVersion) { \ (CryptoServices->Function) Args; \ return; \ } \ @@ -116,7 +120,7 @@ Md5GetContextSize ( VOID ) { - CALL_CRYPTO_SERVICE (Md5GetContextSize, (), 0); + CALL_CRYPTO_SERVICE (Md5GetContextSize, (), 0,
Re: [edk2-devel] [PATCH 2/3] MdeModulePkg/XhciDxe/Xhci: Don't check for invalid PSIV
Reviewed-by: Hao A Wu Best Regards, Hao Wu > -Original Message- > From: Sean Rhodes > Sent: Friday, December 16, 2022 4:58 PM > To: devel@edk2.groups.io > Cc: Matt DeVillier ; Wu, Hao A > ; Ni, Ray ; Rhodes, Sean > > Subject: [PATCH 2/3] MdeModulePkg/XhciDxe/Xhci: Don't check for invalid > PSIV > > From: Matt DeVillier > > PSID matching relies on comparing the PSIV against the PortSpeed > value. This patch stops edk2 from checking for a PSIV of 0, as it > is not valid; this reduces the number of register access by > approximately 6 per second. > > Cc: Hao A Wu > Cc: Ray Ni > Reviewed-by: Sean Rhodes > Signed-off-by: Matt DeVillier > Change-Id: If15c55ab66d2e7faa832ce8576d2e5b47157cc9a > --- > MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c | 44 - > 1 file changed, 25 insertions(+), 19 deletions(-) > > diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c > b/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c > index 15fb49f28f..8dd7a8fbb7 100644 > --- a/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c > +++ b/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c > @@ -371,6 +371,7 @@ XhcGetRootHubPortStatus ( >UINT32 TotalPort; > >UINTN Index; > >UINTN MapSize; > > + UINT8 PortSpeed; > >EFI_STATUS Status; > >USB_DEV_ROUTE ParentRouteChart; > >EFI_TPLOldTpl; > > @@ -397,32 +398,37 @@ XhcGetRootHubPortStatus ( > > >State = XhcReadOpReg (Xhc, Offset); > > > > + PortSpeed = (State & XHC_PORTSC_PS) >> 10; > > + > >// > >// According to XHCI 1.1 spec November 2017, > >// Section 7.2 xHCI Support Protocol Capability > >// > > - PortStatus->PortStatus = XhcCheckUsbPortSpeedUsedPsic (Xhc, ((State & > XHC_PORTSC_PS) >> 10)); > > - if (PortStatus->PortStatus == 0) { > > -// > > -// According to XHCI 1.1 spec November 2017, > > -// bit 10~13 of the root port status register identifies the speed of the > attached device. > > -// > > -switch ((State & XHC_PORTSC_PS) >> 10) { > > - case 2: > > -PortStatus->PortStatus |= USB_PORT_STAT_LOW_SPEED; > > -break; > > + if (PortSpeed > 0) { > > +PortStatus->PortStatus = XhcCheckUsbPortSpeedUsedPsic (Xhc, > PortSpeed); > > +// If no match found in ext cap reg, fall back to PORTSC > > +if (PortStatus->PortStatus == 0) { > > + // > > + // According to XHCI 1.1 spec November 2017, > > + // bit 10~13 of the root port status register identifies the speed of > the > attached device. > > + // > > + switch (PortSpeed) { > > +case 2: > > + PortStatus->PortStatus |= USB_PORT_STAT_LOW_SPEED; > > + break; > > > > - case 3: > > -PortStatus->PortStatus |= USB_PORT_STAT_HIGH_SPEED; > > -break; > > +case 3: > > + PortStatus->PortStatus |= USB_PORT_STAT_HIGH_SPEED; > > + break; > > > > - case 4: > > - case 5: > > -PortStatus->PortStatus |= USB_PORT_STAT_SUPER_SPEED; > > -break; > > +case 4: > > +case 5: > > + PortStatus->PortStatus |= USB_PORT_STAT_SUPER_SPEED; > > + break; > > > > - default: > > -break; > > +default: > > + break; > > + } > > } > >} > > > > -- > 2.37.2 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#97545): https://edk2.groups.io/g/devel/message/97545 Mute This Topic: https://groups.io/mt/95569298/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH 3/4] OvmfPkg: Add CpuPageTableLib required by MpInitLib.
Acked-by: Jiewen Yao > -Original Message- > From: devel@edk2.groups.io On Behalf Of Ni, Ray > Sent: Monday, December 19, 2022 11:23 AM > To: devel@edk2.groups.io; Xie, Yuanhao > Subject: Re: [edk2-devel] [PATCH 3/4] OvmfPkg: Add CpuPageTableLib > required by MpInitLib. > > Reviewed-by: Ray Ni > > > -Original Message- > > From: devel@edk2.groups.io On Behalf Of > Yuanhao Xie > > Sent: Monday, December 19, 2022 5:43 AM > > To: devel@edk2.groups.io > > Subject: [edk2-devel] [PATCH 3/4] OvmfPkg: Add CpuPageTableLib required > by MpInitLib. > > > > Add CpuPageTableLib required by MpInitLib in OvmfPkg. > > > > Signed-off-by: Yuanhao Xie > > --- > > OvmfPkg/AmdSev/AmdSevX64.dsc | 3 ++- > > OvmfPkg/CloudHv/CloudHvX64.dsc | 1 + > > OvmfPkg/IntelTdx/IntelTdxX64.dsc | 4 +++- > > OvmfPkg/Microvm/MicrovmX64.dsc | 3 ++- > > OvmfPkg/OvmfPkgIa32X64.dsc | 1 + > > OvmfPkg/OvmfPkgX64.dsc | 2 ++ > > OvmfPkg/OvmfXen.dsc | 3 ++- > > 7 files changed, 13 insertions(+), 4 deletions(-) > > > > diff --git a/OvmfPkg/AmdSev/AmdSevX64.dsc > b/OvmfPkg/AmdSev/AmdSevX64.dsc > > index e0b04d6734..b92c6154b2 100644 > > --- a/OvmfPkg/AmdSev/AmdSevX64.dsc > > +++ b/OvmfPkg/AmdSev/AmdSevX64.dsc > > @@ -3,7 +3,7 @@ > > # virtual machine remote attestation and secret injection > > # > > # Copyright (c) 2020 James Bottomley, IBM Corporation. > > -# Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved. > > +# Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved. > > # (C) Copyright 2016 Hewlett Packard Enterprise Development LP > > # > > # SPDX-License-Identifier: BSD-2-Clause-Patent > > @@ -352,6 +352,7 @@ > > > DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgentL > ib.inf > > !endif > >PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf > > + > CpuPageTableLib|UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableLib.inf > >MpInitLib|UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf > > > QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/DxeQemuFwCfgS3LibF > wCfg.inf > > > QemuLoadImageLib|OvmfPkg/Library/GenericQemuLoadImageLib/GenericQ > emuLoadImageLib.inf > > diff --git a/OvmfPkg/CloudHv/CloudHvX64.dsc > b/OvmfPkg/CloudHv/CloudHvX64.dsc > > index 4fe7cb5f1b..4d7107fd19 100644 > > --- a/OvmfPkg/CloudHv/CloudHvX64.dsc > > +++ b/OvmfPkg/CloudHv/CloudHvX64.dsc > > @@ -403,6 +403,7 @@ > > > DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgentL > ib.inf > > !endif > >PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf > > + > CpuPageTableLib|UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableLib.inf > >MpInitLib|UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf > > > QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/DxeQemuFwCfgS3LibF > wCfg.inf > > > QemuLoadImageLib|OvmfPkg/Library/X86QemuLoadImageLib/X86QemuLoa > dImageLib.inf > > diff --git a/OvmfPkg/IntelTdx/IntelTdxX64.dsc > b/OvmfPkg/IntelTdx/IntelTdxX64.dsc > > index 3458926515..ea538fd783 100644 > > --- a/OvmfPkg/IntelTdx/IntelTdxX64.dsc > > +++ b/OvmfPkg/IntelTdx/IntelTdxX64.dsc > > @@ -1,7 +1,7 @@ > > ## @file > > # EFI/Framework Open Virtual Machine Firmware (OVMF) platform > > # > > -# Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved. > > +# Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved. > > # (C) Copyright 2016 Hewlett Packard Enterprise Development LP > > # Copyright (c) Microsoft Corporation. > > # > > @@ -313,6 +313,7 @@ > > > CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeC > puExceptionHandlerLib.inf > >LockBoxLib|OvmfPkg/Library/LockBoxLib/LockBoxDxeLib.inf > >PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf > > + > CpuPageTableLib|UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableLib.inf > >MpInitLib|UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf > > > QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/DxeQemuFwCfgS3LibF > wCfg.inf > > > QemuLoadImageLib|OvmfPkg/Library/X86QemuLoadImageLib/X86QemuLoa > dImageLib.inf > > @@ -577,6 +578,7 @@ > > > >UefiCpuPkg/CpuDxe/CpuDxe.inf { > > > > + > CpuPageTableLib|UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableLib.inf > ># > ># Directly use DxeMpInitLib. It depends on DxeMpInitLibMpDepLib > which > ># checks the Protocol of gEfiMpInitLibMpDepProtocolGuid. > > diff --git a/OvmfPkg/Microvm/MicrovmX64.dsc > b/OvmfPkg/Microvm/MicrovmX64.dsc > > index 93d4cf3da2..b04c8e6936 100644 > > --- a/OvmfPkg/Microvm/MicrovmX64.dsc > > +++ b/OvmfPkg/Microvm/MicrovmX64.dsc > > @@ -1,7 +1,7 @@ > > ## @file > > # EFI/Framework Open Virtual Machine Firmware (OVMF) platform > > # > > -# Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved. > > +# Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved. > > # (C) Copyright 2016 Hewlett Packard Enterprise Development LP > > # Copyright (c) Microsoft Corporation. > > # > > @@ -402,6 +402,7 @@ > >PciLib
Re: [edk2-devel] [PATCH] UefiPayloadPkg: Move bdsdxe.inf from DXEFV to BDSFV
Reviewed-by: James Lu -Original Message- From: Lin, MarsX Sent: Monday, December 19, 2022 11:07 AM To: devel@edk2.groups.io Cc: Lin, MarsX ; Dong, Guo ; Ni, Ray ; Rhodes, Sean ; Lu, James ; Guo, Gua Subject: [PATCH] UefiPayloadPkg: Move bdsdxe.inf from DXEFV to BDSFV From: MarsX Lin REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4196 Since UefiPayload had supported multiple fv, move bdsdxe.inf to new firmware volume and modify the script of UniversalPayloadPkgBuild.py to support bdsdxe fv in elf file Cc: Guo Dong Cc: Ray Ni Cc: Sean Rhodes Cc: James Lu Cc: Gua Guo Signed-off-by: MarsX Lin --- UefiPayloadPkg/UefiPayloadPkg.fdf | 27 - UefiPayloadPkg/UniversalPayloadBuild.py | 12 ++- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/UefiPayloadPkg/UefiPayloadPkg.fdf b/UefiPayloadPkg/UefiPayloadPkg.fdf index 9c9e2f2741..94ba922244 100644 --- a/UefiPayloadPkg/UefiPayloadPkg.fdf +++ b/UefiPayloadPkg/UefiPayloadPkg.fdf @@ -59,8 +59,33 @@ INF UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf FILE FV_IMAGE = 4E35FD93-9C72-4c15-8C4B-E77F1DB2D793 { SECTION FV_IMAGE = DXEFV }+FILE FV_IMAGE = FBE6C1E3-2F80-4770-88B0-494186E3346F {+SECTION FV_IMAGE = BDSFV+} +[FV.BDSFV]+FvNameGuid = CA5590AF-9558-4822-B5EA-BE2E876CD3EC+BlockSize = $(FD_BLOCK_SIZE)+FvForceRebase = FALSE+FvAlignment= 16+ERASE_POLARITY = 1+MEMORY_MAPPED = TRUE+STICKY_WRITE = TRUE+LOCK_CAP = TRUE+LOCK_STATUS= TRUE+WRITE_DISABLED_CAP = TRUE+WRITE_ENABLED_CAP = TRUE+WRITE_STATUS = TRUE+WRITE_LOCK_CAP = TRUE+WRITE_LOCK_STATUS = TRUE+READ_DISABLED_CAP = TRUE+READ_ENABLED_CAP = TRUE+READ_STATUS= TRUE+READ_LOCK_CAP = TRUE+READ_LOCK_STATUS = TRUE++INF MdeModulePkg/Universal/BdsDxe/BdsDxe.inf [FV.DXEFV] FvNameGuid = 8063C21A-8E58-4576-95CE-089E87975D23@@ -106,7 +131,7 @@ INF CryptoPkg/Driver/CryptoDxe.inf INF MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf !endif INF UefiCpuPkg/CpuDxe/CpuDxe.inf-INF MdeModulePkg/Universal/BdsDxe/BdsDxe.inf+ INF RuleOverride = UI MdeModulePkg/Application/UiApp/UiApp.inf INF MdeModulePkg/Application/BootManagerMenuApp/BootManagerMenuApp.inf INF PcAtChipsetPkg/HpetTimerDxe/HpetTimerDxe.infdiff --git a/UefiPayloadPkg/UniversalPayloadBuild.py b/UefiPayloadPkg/UniversalPayloadBuild.py index 50a5950e7c..f242b039b4 100644 --- a/UefiPayloadPkg/UniversalPayloadBuild.py +++ b/UefiPayloadPkg/UniversalPayloadBuild.py @@ -67,7 +67,8 @@ def BuildUniversalPayload(Args, MacroList): EntryModuleInf = os.path.normpath("UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf") DscPath = os.path.normpath("UefiPayloadPkg/UefiPayloadPkg.dsc")- FvOutputDir = os.path.join(BuildDir, "{}_{}".format (BuildTarget, ToolChain), os.path.normpath("FV/DXEFV.Fv"))+DxeFvOutputDir = os.path.join(BuildDir, "{}_{}".format (BuildTarget, ToolChain), os.path.normpath("FV/DXEFV.Fv"))+ BdsFvOutputDir = os.path.join(BuildDir, "{}_{}".format (BuildTarget, ToolChain), os.path.normpath("FV/BDSFV.Fv")) PayloadReportPath = os.path.join(BuildDir, "UefiUniversalPayload.txt") ModuleReportPath = os.path.join(BuildDir, "UefiUniversalPayloadEntry.txt") UpldInfoFile = os.path.join(BuildDir, "UniversalPayloadInfo.bin")@@ -119,21 +120,22 @@ def BuildUniversalPayload(Args, MacroList): # # Copy the DXEFV as a section in elf format Universal Payload entry. #-remove_section = '"{}" -I {} -O {} --remove-section .upld_info --remove-section .upld.uefi_fv {}'.format (+remove_section = '"{}" -I {} -O {} --remove-section .upld_info --remove-section .upld.uefi_fv --remove-section .upld.bds_fv {}'.format (LlvmObjcopyPath, ObjCopyFlag,ObjCopyFlag, EntryOutputDir)-add_section= '"{}" -I {} -O {} --add-section .upld_info={} --add-section .upld.uefi_fv={} {}'.format (+ add_section= '"{}" -I {} -O {} --add-section .upld_info={} --add-section .upld.uefi_fv={} --add-section .upld.bds_fv={} {}'.format ( LlvmObjcopyPath,ObjCopyFlag, ObjCopyFlag,UpldInfoFile,- FvOutputDir,+ DxeFvOutputDir,+ BdsFvOutputDir,EntryOutputDir)- set_section= '"{}" -I {} -O {} --set-section-alignment .upld_info=4 --set-section-alignment .upld.uefi_fv=16 {}'.format (+set_section= '"{}" -I {} -O {} --set-section-alignment .upld.upld_info=4 --set-section-alignment .upld.uefi_fv=16 --set-section-alignment .upld.bds_fv=16 {}'.format (LlvmObjcopyPath, Obj
Re: [edk2-devel] [PATCH] UefiPayloadPkg: Remove RTC_INDEX/TARGET from UplBuild macro list
Reviewed-by: Gua Guo Please send two commits into one PR. First commit "PcAtChipsetPkg: Move RTC PCD to dynamic PCD" Second commit "UefiPayloadPkg: Move RTC PCD to dynamic PCD" -Original Message- From: Liu, KasimX Sent: Wednesday, December 14, 2022 4:22 PM To: devel@edk2.groups.io Cc: Liu, KasimX ; Dong, Guo ; Ni, Ray ; Lu, James ; Guo, Gua Subject: [PATCH] UefiPayloadPkg: Remove RTC_INDEX/TARGET from UplBuild macro list From: KasimX Liu REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4193 In order to remove RTC_INDEX/RTC_TARGET from the UplBuild macro list,change the RTC_INDEX /RTC_TARGET type from PcdsFixedAtBuild to PcdsDynamicEx Cc: Guo Dong Cc: Ray Ni Cc: James Lu Cc: Gua Guo Signed-off-by: KasimX Liu --- PcAtChipsetPkg/PcAtChipsetPkg.dec | 16 UefiPayloadPkg/UefiPayloadPkg.dsc | 5 +++-- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/PcAtChipsetPkg/PcAtChipsetPkg.dec b/PcAtChipsetPkg/PcAtChipsetPkg.dec index ed2d95550b..a53ca777e8 100644 --- a/PcAtChipsetPkg/PcAtChipsetPkg.dec +++ b/PcAtChipsetPkg/PcAtChipsetPkg.dec @@ -84,6 +84,14 @@ # @Prompt RTC Target Register address gPcAtChipsetPkgTokenSpaceGuid.PcdRtcTargetRegister64|0x0|UINT64|0x0023 + ## Specifies RTC Index Register address in I/O space.+ # @Prompt RTC Index Register address+ gPcAtChipsetPkgTokenSpaceGuid.PcdRtcIndexRegister|0x70|UINT8|0x001E++ ## Specifies RTC Target Register address in I/O space.+ # @Prompt RTC Target Register address+ gPcAtChipsetPkgTokenSpaceGuid.PcdRtcTargetRegister|0x71|UINT8|0x001F+ [PcdsFixedAtBuild, PcdsPatchableInModule] ## Defines the ACPI register set base address. # The invalid 0x is as its default value. It must be configured to the real value.@@ -146,14 +154,6 @@ # @Prompt Initial value for Register_D in RTC. gPcAtChipsetPkgTokenSpaceGuid.PcdInitialValueRtcRegisterD|0x00|UINT8|0x001D - ## Specifies RTC Index Register address in I/O space.- # @Prompt RTC Index Register address- gPcAtChipsetPkgTokenSpaceGuid.PcdRtcIndexRegister|0x70|UINT8|0x001E-- ## Specifies RTC Target Register address in I/O space.- # @Prompt RTC Target Register address- gPcAtChipsetPkgTokenSpaceGuid.PcdRtcTargetRegister|0x71|UINT8|0x001F- ## RTC Update Timeout Value(microsecond). # @Prompt RTC Update Timeout Value. gPcAtChipsetPkgTokenSpaceGuid.PcdRealTimeClockUpdateTimeout|10|UINT32|0x0020diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc b/UefiPayloadPkg/UefiPayloadPkg.dsc index 723a50a422..82cff41780 100644 --- a/UefiPayloadPkg/UefiPayloadPkg.dsc +++ b/UefiPayloadPkg/UefiPayloadPkg.dsc @@ -471,8 +471,6 @@ !endif [PcdsPatchableInModule.X64]- gPcAtChipsetPkgTokenSpaceGuid.PcdRtcIndexRegister|$(RTC_INDEX_REGISTER)- gPcAtChipsetPkgTokenSpaceGuid.PcdRtcTargetRegister|$(RTC_TARGET_REGISTER) !if $(NETWORK_DRIVER_ENABLE) == TRUE gEfiNetworkPkgTokenSpaceGuid.PcdAllowHttpConnections|TRUE !endif@@ -579,6 +577,9 @@ gUefiCpuPkgTokenSpaceGuid.PcdSevEsIsEnabled|0 gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration|TRUE + gPcAtChipsetPkgTokenSpaceGuid.PcdRtcIndexRegister|$(RTC_INDEX_REGISTER)+ gPcAtChipsetPkgTokenSpaceGuid.PcdRtcTargetRegister|$(RTC_TARGET_REGISTER)+ # # Components Section - list of all EDK II Modules needed by this Platform.-- 2.32.0.windows.2 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#97542): https://edk2.groups.io/g/devel/message/97542 Mute This Topic: https://groups.io/mt/95760072/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH v2] UefiPayloadPkg: Move bdsdxe.inf from DXEFV to BDSFV
Reviewed-by: Gua Guo -Original Message- From: Lin, MarsX Sent: Monday, December 19, 2022 11:21 AM To: devel@edk2.groups.io Cc: Lin, MarsX ; Dong, Guo ; Ni, Ray ; Rhodes, Sean ; Lu, James ; Guo, Gua Subject: [PATCH v2] UefiPayloadPkg: Move bdsdxe.inf from DXEFV to BDSFV From: MarsX Lin REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4196 Since UefiPayload had supported multiple fv, move bdsdxe.inf to new firmware volume and modify the script of UniversalPayloadPkgBuild.py to support bdsdxe fv in elf file Cc: Guo Dong Cc: Ray Ni Cc: Sean Rhodes Cc: James Lu Cc: Gua Guo Signed-off-by: MarsX Lin --- UefiPayloadPkg/UefiPayloadPkg.fdf | 27 +++- UefiPayloadPkg/UniversalPayloadBuild.py | 12 + 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/UefiPayloadPkg/UefiPayloadPkg.fdf b/UefiPayloadPkg/UefiPayloadPkg.fdf index 9c9e2f2741..94ba922244 100644 --- a/UefiPayloadPkg/UefiPayloadPkg.fdf +++ b/UefiPayloadPkg/UefiPayloadPkg.fdf @@ -59,8 +59,33 @@ INF UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf FILE FV_IMAGE = 4E35FD93-9C72-4c15-8C4B-E77F1DB2D793 { SECTION FV_IMAGE = DXEFV }+FILE FV_IMAGE = FBE6C1E3-2F80-4770-88B0-494186E3346F {+SECTION FV_IMAGE = BDSFV+} +[FV.BDSFV]+FvNameGuid = CA5590AF-9558-4822-B5EA-BE2E876CD3EC+BlockSize = $(FD_BLOCK_SIZE)+FvForceRebase = FALSE+FvAlignment= 16+ERASE_POLARITY = 1+MEMORY_MAPPED = TRUE+STICKY_WRITE = TRUE+LOCK_CAP = TRUE+LOCK_STATUS= TRUE+WRITE_DISABLED_CAP = TRUE+WRITE_ENABLED_CAP = TRUE+WRITE_STATUS = TRUE+WRITE_LOCK_CAP = TRUE+WRITE_LOCK_STATUS = TRUE+READ_DISABLED_CAP = TRUE+READ_ENABLED_CAP = TRUE+READ_STATUS= TRUE+READ_LOCK_CAP = TRUE+READ_LOCK_STATUS = TRUE++INF MdeModulePkg/Universal/BdsDxe/BdsDxe.inf [FV.DXEFV] FvNameGuid = 8063C21A-8E58-4576-95CE-089E87975D23@@ -106,7 +131,7 @@ INF CryptoPkg/Driver/CryptoDxe.inf INF MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf !endif INF UefiCpuPkg/CpuDxe/CpuDxe.inf-INF MdeModulePkg/Universal/BdsDxe/BdsDxe.inf+ INF RuleOverride = UI MdeModulePkg/Application/UiApp/UiApp.inf INF MdeModulePkg/Application/BootManagerMenuApp/BootManagerMenuApp.inf INF PcAtChipsetPkg/HpetTimerDxe/HpetTimerDxe.infdiff --git a/UefiPayloadPkg/UniversalPayloadBuild.py b/UefiPayloadPkg/UniversalPayloadBuild.py index 50a5950e7c..6d62b8b20f 100644 --- a/UefiPayloadPkg/UniversalPayloadBuild.py +++ b/UefiPayloadPkg/UniversalPayloadBuild.py @@ -67,7 +67,8 @@ def BuildUniversalPayload(Args, MacroList): EntryModuleInf = os.path.normpath("UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf") DscPath = os.path.normpath("UefiPayloadPkg/UefiPayloadPkg.dsc")- FvOutputDir = os.path.join(BuildDir, "{}_{}".format (BuildTarget, ToolChain), os.path.normpath("FV/DXEFV.Fv"))+DxeFvOutputDir = os.path.join(BuildDir, "{}_{}".format (BuildTarget, ToolChain), os.path.normpath("FV/DXEFV.Fv"))+ BdsFvOutputDir = os.path.join(BuildDir, "{}_{}".format (BuildTarget, ToolChain), os.path.normpath("FV/BDSFV.Fv")) PayloadReportPath = os.path.join(BuildDir, "UefiUniversalPayload.txt") ModuleReportPath = os.path.join(BuildDir, "UefiUniversalPayloadEntry.txt") UpldInfoFile = os.path.join(BuildDir, "UniversalPayloadInfo.bin")@@ -119,21 +120,22 @@ def BuildUniversalPayload(Args, MacroList): # # Copy the DXEFV as a section in elf format Universal Payload entry. #-remove_section = '"{}" -I {} -O {} --remove-section .upld_info --remove-section .upld.uefi_fv {}'.format (+remove_section = '"{}" -I {} -O {} --remove-section .upld_info --remove-section .upld.uefi_fv --remove-section .upld.bds_fv {}'.format (LlvmObjcopyPath, ObjCopyFlag,ObjCopyFlag, EntryOutputDir)-add_section= '"{}" -I {} -O {} --add-section .upld_info={} --add-section .upld.uefi_fv={} {}'.format (+ add_section= '"{}" -I {} -O {} --add-section .upld_info={} --add-section .upld.uefi_fv={} --add-section .upld.bds_fv={} {}'.format ( LlvmObjcopyPath,ObjCopyFlag, ObjCopyFlag,UpldInfoFile,- FvOutputDir,+ DxeFvOutputDir,+ BdsFvOutputDir,EntryOutputDir)- set_section= '"{}" -I {} -O {} --set-section-alignment .upld_info=4 --set-section-alignment .upld.uefi_fv=16 {}'.format (+set_section= '"{}" -I {} -O {} --set-section-alignment .upld_info=16 --set-section-alignment .upld.uefi_fv=16 --set-section-alignment .upld.bds_fv=16 {}'.format ( LlvmObjcopyPath,ObjCopyFlag,
Re: [edk2-devel] [PATCH 1/4] UefiCpuPkg: Duplicated AsmRelocateApLoop as AsmRelocateApLoopAmd
> + > +BITS 64 > +AsmRelocateApLoopEndAmd: > \ No newline at end of file Please add a newline at end of file. -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#97540): https://edk2.groups.io/g/devel/message/97540 Mute This Topic: https://groups.io/mt/95754114/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH 4/4] UefiPayloadPkg: Add CpuPageTableLib required by MpInitLib.
Reviewed-by: Ray Ni > -Original Message- > From: devel@edk2.groups.io On Behalf Of Yuanhao Xie > Sent: Monday, December 19, 2022 5:43 AM > To: devel@edk2.groups.io > Subject: [edk2-devel] [PATCH 4/4] UefiPayloadPkg: Add CpuPageTableLib > required by MpInitLib. > > Add CpuPageTableLib required by MpInitLib in UefiPayloadPkg. > > Signed-off-by: Yuanhao Xie > --- > UefiPayloadPkg/UefiPayloadPkg.dsc | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc > b/UefiPayloadPkg/UefiPayloadPkg.dsc > index 723a50a422..05d53a85d0 100644 > --- a/UefiPayloadPkg/UefiPayloadPkg.dsc > +++ b/UefiPayloadPkg/UefiPayloadPkg.dsc > @@ -340,6 +340,7 @@ >DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgentLib.inf > !endif > > CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf > + CpuPageTableLib|UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableLib.inf >MpInitLib|UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf > !if $(PERFORMANCE_MEASUREMENT_ENABLE) >PerformanceLib|MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf > -- > 2.36.1.windows.1 > > > > > -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#97539): https://edk2.groups.io/g/devel/message/97539 Mute This Topic: https://groups.io/mt/95754121/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH 3/4] OvmfPkg: Add CpuPageTableLib required by MpInitLib.
Reviewed-by: Ray Ni > -Original Message- > From: devel@edk2.groups.io On Behalf Of Yuanhao Xie > Sent: Monday, December 19, 2022 5:43 AM > To: devel@edk2.groups.io > Subject: [edk2-devel] [PATCH 3/4] OvmfPkg: Add CpuPageTableLib required by > MpInitLib. > > Add CpuPageTableLib required by MpInitLib in OvmfPkg. > > Signed-off-by: Yuanhao Xie > --- > OvmfPkg/AmdSev/AmdSevX64.dsc | 3 ++- > OvmfPkg/CloudHv/CloudHvX64.dsc | 1 + > OvmfPkg/IntelTdx/IntelTdxX64.dsc | 4 +++- > OvmfPkg/Microvm/MicrovmX64.dsc | 3 ++- > OvmfPkg/OvmfPkgIa32X64.dsc | 1 + > OvmfPkg/OvmfPkgX64.dsc | 2 ++ > OvmfPkg/OvmfXen.dsc | 3 ++- > 7 files changed, 13 insertions(+), 4 deletions(-) > > diff --git a/OvmfPkg/AmdSev/AmdSevX64.dsc b/OvmfPkg/AmdSev/AmdSevX64.dsc > index e0b04d6734..b92c6154b2 100644 > --- a/OvmfPkg/AmdSev/AmdSevX64.dsc > +++ b/OvmfPkg/AmdSev/AmdSevX64.dsc > @@ -3,7 +3,7 @@ > # virtual machine remote attestation and secret injection > # > # Copyright (c) 2020 James Bottomley, IBM Corporation. > -# Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved. > +# Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved. > # (C) Copyright 2016 Hewlett Packard Enterprise Development LP > # > # SPDX-License-Identifier: BSD-2-Clause-Patent > @@ -352,6 +352,7 @@ >DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgentLib.inf > !endif >PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf > + CpuPageTableLib|UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableLib.inf >MpInitLib|UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf >QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/DxeQemuFwCfgS3LibFwCfg.inf > > QemuLoadImageLib|OvmfPkg/Library/GenericQemuLoadImageLib/GenericQemuLoadImageLib.inf > diff --git a/OvmfPkg/CloudHv/CloudHvX64.dsc b/OvmfPkg/CloudHv/CloudHvX64.dsc > index 4fe7cb5f1b..4d7107fd19 100644 > --- a/OvmfPkg/CloudHv/CloudHvX64.dsc > +++ b/OvmfPkg/CloudHv/CloudHvX64.dsc > @@ -403,6 +403,7 @@ >DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgentLib.inf > !endif >PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf > + CpuPageTableLib|UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableLib.inf >MpInitLib|UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf >QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/DxeQemuFwCfgS3LibFwCfg.inf > > QemuLoadImageLib|OvmfPkg/Library/X86QemuLoadImageLib/X86QemuLoadImageLib.inf > diff --git a/OvmfPkg/IntelTdx/IntelTdxX64.dsc > b/OvmfPkg/IntelTdx/IntelTdxX64.dsc > index 3458926515..ea538fd783 100644 > --- a/OvmfPkg/IntelTdx/IntelTdxX64.dsc > +++ b/OvmfPkg/IntelTdx/IntelTdxX64.dsc > @@ -1,7 +1,7 @@ > ## @file > # EFI/Framework Open Virtual Machine Firmware (OVMF) platform > # > -# Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved. > +# Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved. > # (C) Copyright 2016 Hewlett Packard Enterprise Development LP > # Copyright (c) Microsoft Corporation. > # > @@ -313,6 +313,7 @@ > > CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf >LockBoxLib|OvmfPkg/Library/LockBoxLib/LockBoxDxeLib.inf >PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf > + CpuPageTableLib|UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableLib.inf >MpInitLib|UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf >QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/DxeQemuFwCfgS3LibFwCfg.inf > > QemuLoadImageLib|OvmfPkg/Library/X86QemuLoadImageLib/X86QemuLoadImageLib.inf > @@ -577,6 +578,7 @@ > >UefiCpuPkg/CpuDxe/CpuDxe.inf { > > + CpuPageTableLib|UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableLib.inf ># ># Directly use DxeMpInitLib. It depends on DxeMpInitLibMpDepLib which ># checks the Protocol of gEfiMpInitLibMpDepProtocolGuid. > diff --git a/OvmfPkg/Microvm/MicrovmX64.dsc b/OvmfPkg/Microvm/MicrovmX64.dsc > index 93d4cf3da2..b04c8e6936 100644 > --- a/OvmfPkg/Microvm/MicrovmX64.dsc > +++ b/OvmfPkg/Microvm/MicrovmX64.dsc > @@ -1,7 +1,7 @@ > ## @file > # EFI/Framework Open Virtual Machine Firmware (OVMF) platform > # > -# Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved. > +# Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved. > # (C) Copyright 2016 Hewlett Packard Enterprise Development LP > # Copyright (c) Microsoft Corporation. > # > @@ -402,6 +402,7 @@ >PciLib|MdePkg/Library/BasePciLibPciExpress/BasePciLibPciExpress.inf >PciPcdProducerLib|OvmfPkg/Fdt/FdtPciPcdProducerLib/FdtPciPcdProducerLib.inf > > PciExpressLib|OvmfPkg/Library/BaseCachingPciExpressLib/BaseCachingPciExpressLib.inf > + CpuPageTableLib|UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableLib.inf >MpInitLib|UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf >QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/DxeQemuFwCfgS3LibFwCfg.inf > > QemuLoadImageLib|OvmfPkg/Library/
Re: [edk2-devel] [PATCH 2/4] UefiCpuPkg: Has APs in 64 bit long-mode before booting to OS.
> + > +PageTable = CreatePageTable ( > + mReservedTopOfApStack, > + ApSafeBufferSize > + ); > + > +mApPageTable = PageTable; 1. Can you directly assign the CreatePageTable() return value to mApPageTable? So that the local "PageTable" is not needed. > + > +mReservedTopOfApStack += CpuMpData->CpuCount * AP_SAFE_STACK_SIZE; > + } 2. Can you confirm if above change to mReservedTopOfApStack is needed for AMD path? > diff --git a/UefiCpuPkg/Library/MpInitLib/Ia32/CreatePageTable.c > b/UefiCpuPkg/Library/MpInitLib/Ia32/CreatePageTable.c > new file mode 100644 > index 00..54ec42469e > --- /dev/null > +++ b/UefiCpuPkg/Library/MpInitLib/Ia32/CreatePageTable.c > @@ -0,0 +1,28 @@ > +/** @file > + CreatePageTable 3. File header comments are too simple. > + > + Copyright (c) 2016 - 2022, Intel Corporation. All rights reserved. 4. Copyright year can be just "2022". No need to have "2016". > + SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > + > +#include > +#include > +#include 5. Can you try to remove the above two library header inclusion? > + > +/** > + Create or update page table. 6. The function header comments could be: "Create 1:1 mapping page table in reserved memory to map the specified address range." Please update in header file as well. > /** >Initialize global data for MP support. > > diff --git a/UefiCpuPkg/Library/MpInitLib/X64/AmdSev.nasm > b/UefiCpuPkg/Library/MpInitLib/X64/AmdSev.nasm > index 47fc8e9325..b2d95adf6d 100644 > --- a/UefiCpuPkg/Library/MpInitLib/X64/AmdSev.nasm > +++ b/UefiCpuPkg/Library/MpInitLib/X64/AmdSev.nasm > @@ -514,4 +514,4 @@ DoHltAmd: > jmpDoHltAmd > > BITS 64 > -AsmRelocateApLoopEndAmd: > \ No newline at end of file > +AsmRelocateApLoopEndAmd: 7. The change to add newline character should be in the first patch, not in this patch. -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#97537): https://edk2.groups.io/g/devel/message/97537 Mute This Topic: https://groups.io/mt/95754119/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH 1/4] UefiCpuPkg: Duplicated AsmRelocateApLoop as AsmRelocateApLoopAmd
> +movqword [rcx + MP_ASSEMBLY_ADDRESS_MAP.ModeTransitionOffset], > Flat32Start - RendezvousFunnelProcStart I don't think this is needed in your patch. Can you confirm? -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#97536): https://edk2.groups.io/g/devel/message/97536 Mute This Topic: https://groups.io/mt/95754114/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel][PATCH v2 1/2] UefiCpuPkg: Supporting S3 in 64bit PEI
Ted, Can you run uncrustify local? I still see TAB in the patch. > -Original Message- > From: Kuo, Ted > Sent: Friday, December 16, 2022 8:46 PM > To: devel@edk2.groups.io > Cc: Ni, Ray ; Liu, Zhiguang ; Chiu, > Chasel ; Desimone, > Nathaniel L ; Zeng, Star > ; S, Ashraf Ali ; > Duggapu, Chinni B > Subject: [edk2-devel][PATCH v2 1/2] UefiCpuPkg: Supporting S3 in 64bit PEI > > https://bugzilla.tianocore.org/show_bug.cgi?id=4195 > 1.Updated the GDT table in VTF0 to align with the one in S3Resume2Pei. > By doing so can simplify the changes to enable S3 in 64bit PEI. > 2.Use SwitchStack() between PEI and SMM in S3 resume path when both > are in the same execution mode. > 3.Transfer from PEI to OS waking vector by calling SwitchStack() when > both are in the same execution mode. > 4.Removed the debug assertion in S3Resume.c to support 64bit PEI. > > Cc: Ray Ni > Cc: Zhiguang Liu > Cc: Chasel Chiu > Cc: Nate DeSimone > Cc: Star Zeng > Cc: Ashraf Ali S > Cc: Chinni B Duggapu > Signed-off-by: Ted Kuo > --- > UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c | 13 ++- > UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf | 1 + > .../ResetVector/Vtf0/Ia16/Real16ToFlat32.asm | 63 > .../Universal/Acpi/S3Resume2Pei/S3Resume.c| 97 --- > 4 files changed, 117 insertions(+), 57 deletions(-) > > diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c > b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c > index 9b45c442c9..fb4a44eab6 100644 > --- a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c > +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c > @@ -1,7 +1,7 @@ > /** @file > > Code for Processor S3 restoration > > > > -Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved. > > +Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved. > > SPDX-License-Identifier: BSD-2-Clause-Patent > > > > **/ > > @@ -783,7 +783,11 @@ SmmRestoreCpu ( >SmmS3ResumeState = mSmmS3ResumeState; > >ASSERT (SmmS3ResumeState != NULL); > > > > - if (SmmS3ResumeState->Signature == SMM_S3_RESUME_SMM_64) { > > + // > > + // Setup 64bit IDT in 64bit SMM env when called from 32bit PEI. > > + // Note: 64bit PEI and 32bit DXE is not a supported combination. > > + // > > + if ((SmmS3ResumeState->Signature == SMM_S3_RESUME_SMM_64) && (FeaturePcdGet > (PcdDxeIplSwitchToLongMode) == TRUE)) { > > // > > // Save the IA32 IDT Descriptor > > // > > @@ -846,9 +850,10 @@ SmmRestoreCpu ( >DEBUG ((DEBUG_INFO, "SMM S3 Return Stack Pointer = %x\n", > SmmS3ResumeState->ReturnStackPointer)); > > > >// > > - // If SMM is in 32-bit mode, then use SwitchStack() to resume PEI Phase > > + // If SMM is in 32-bit mode or PcdDxeIplSwitchToLongMode is FALSE, then > use SwitchStack() to resume PEI Phase. > > + // Note: 64bit PEI and 32bit DXE is not a supported combination. > >// > > - if (SmmS3ResumeState->Signature == SMM_S3_RESUME_SMM_32) { > > + if ((SmmS3ResumeState->Signature == SMM_S3_RESUME_SMM_32) || > (FeaturePcdGet (PcdDxeIplSwitchToLongMode) > == FALSE)) { > > DEBUG ((DEBUG_INFO, "Call SwitchStack() to return to S3 Resume in PEI > Phase\n")); > > > > SwitchStack ( > > diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf > b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf > index deef00f9c6..b4b327f60c 100644 > --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf > +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf > @@ -124,6 +124,7 @@ >gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmProfileEnable ## > CONSUMES > >gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmProfileRingBuffer ## > CONSUMES > >gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmFeatureControlMsrLock ## > CONSUMES > > + gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode ## > CONSUMES > > > > [Pcd] > >gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber## > SOMETIMES_CONSUMES > > diff --git a/UefiCpuPkg/ResetVector/Vtf0/Ia16/Real16ToFlat32.asm > b/UefiCpuPkg/ResetVector/Vtf0/Ia16/Real16ToFlat32.asm > index 0e79a3984b..f59fc6ead4 100644 > --- a/UefiCpuPkg/ResetVector/Vtf0/Ia16/Real16ToFlat32.asm > +++ b/UefiCpuPkg/ResetVector/Vtf0/Ia16/Real16ToFlat32.asm > @@ -2,7 +2,7 @@ > ; @file > > ; Transition from 16 bit real mode into 32 bit flat protected mode > > ; > > -; Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved. > > +; Copyright (c) 2008 - 2022, Intel Corporation. All rights reserved. > > ; SPDX-License-Identifier: BSD-2-Clause-Patent > > ; > > > ;-- > > @@ -92,7 +92,7 @@ ALIGN 16 > > > GDT_BASE: > > ; null descriptor > > -NULL_SELequ $-GDT_BASE > > +NULL_SELequ $-GDT_BASE; Selector [0x0] > > DW 0; limit 15:0 > > DW 0; base 15:0 > > DB 0; base 23:16 > > @@ -100,42 +100,67 @@ NULL_SELequ $-GDT_
Re: [edk2-devel] [PATCH 4/4] UefiPayloadPkg: Add CpuPageTableLib required by MpInitLib.
Reviewed-by: Gua Guo -Original Message- From: devel@edk2.groups.io On Behalf Of Yuanhao Xie Sent: Monday, December 19, 2022 5:43 AM To: devel@edk2.groups.io Subject: [edk2-devel] [PATCH 4/4] UefiPayloadPkg: Add CpuPageTableLib required by MpInitLib. Add CpuPageTableLib required by MpInitLib in UefiPayloadPkg. Signed-off-by: Yuanhao Xie --- UefiPayloadPkg/UefiPayloadPkg.dsc | 1 + 1 file changed, 1 insertion(+) diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc b/UefiPayloadPkg/UefiPayloadPkg.dsc index 723a50a422..05d53a85d0 100644 --- a/UefiPayloadPkg/UefiPayloadPkg.dsc +++ b/UefiPayloadPkg/UefiPayloadPkg.dsc @@ -340,6 +340,7 @@ DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgentLib.inf !endif CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf + CpuPageTableLib|UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableLib.inf MpInitLib|UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf !if $(PERFORMANCE_MEASUREMENT_ENABLE) PerformanceLib|MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf -- 2.36.1.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#97534): https://edk2.groups.io/g/devel/message/97534 Mute This Topic: https://groups.io/mt/95754121/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
[edk2-devel] Event: Tools, CI, Code base construction meeting series - Monday, December 19, 2022 #cal-reminder
*Reminder: Tools, CI, Code base construction meeting series* *When:* Monday, December 19, 2022 4:30pm to 5:30pm (UTC-08:00) America/Los Angeles *Where:* https://github.com/tianocore/edk2/discussions/2614 View Event ( https://edk2.groups.io/g/devel/viewevent?eventid=1650223 ) *Description:* TianoCore community, Microsoft and Intel will be hosting a series of open meetings to discuss build, CI, tools, and other related topics. If you are interested, have ideas/opinions please join us. These meetings will be Monday 4:30pm Pacific Time on Microsoft Teams. MS Teams Link in following discussion: * https://github.com/tianocore/edk2/discussions/2614 Anyone is welcome to join. * tianocore/edk2: EDK II (github.com) * tianocore/edk2-basetools: EDK II BaseTools Python tools as a PIP module (github.com) https://github.com/tianocore/edk2-basetools * tianocore/edk2-pytool-extensions: Extensions to the edk2 build system allowing for a more robust and plugin based build system and tool execution environment (github.com) https://github.com/tianocore/edk2-pytool-extensions * tianocore/edk2-pytool-library: Python library package that supports UEFI development (github.com) https://github.com/tianocore/edk2-pytool-library MS Teams Browser Clients * https://docs.microsoft.com/en-us/microsoftteams/get-clients?tabs=Windows#browser-client -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#97532): https://edk2.groups.io/g/devel/message/97532 Mute This Topic: https://groups.io/mt/95756379/21656 Mute #cal-reminder:https://edk2.groups.io/g/devel/mutehashtag/cal-reminder Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
[edk2-devel] [PATCH 4/4] UefiPayloadPkg: Add CpuPageTableLib required by MpInitLib.
Add CpuPageTableLib required by MpInitLib in UefiPayloadPkg. Signed-off-by: Yuanhao Xie --- UefiPayloadPkg/UefiPayloadPkg.dsc | 1 + 1 file changed, 1 insertion(+) diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc b/UefiPayloadPkg/UefiPayloadPkg.dsc index 723a50a422..05d53a85d0 100644 --- a/UefiPayloadPkg/UefiPayloadPkg.dsc +++ b/UefiPayloadPkg/UefiPayloadPkg.dsc @@ -340,6 +340,7 @@ DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgentLib.inf !endif CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf + CpuPageTableLib|UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableLib.inf MpInitLib|UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf !if $(PERFORMANCE_MEASUREMENT_ENABLE) PerformanceLib|MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf -- 2.36.1.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#97531): https://edk2.groups.io/g/devel/message/97531 Mute This Topic: https://groups.io/mt/95754121/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
[edk2-devel] [PATCH 3/4] OvmfPkg: Add CpuPageTableLib required by MpInitLib.
Add CpuPageTableLib required by MpInitLib in OvmfPkg. Signed-off-by: Yuanhao Xie --- OvmfPkg/AmdSev/AmdSevX64.dsc | 3 ++- OvmfPkg/CloudHv/CloudHvX64.dsc | 1 + OvmfPkg/IntelTdx/IntelTdxX64.dsc | 4 +++- OvmfPkg/Microvm/MicrovmX64.dsc | 3 ++- OvmfPkg/OvmfPkgIa32X64.dsc | 1 + OvmfPkg/OvmfPkgX64.dsc | 2 ++ OvmfPkg/OvmfXen.dsc | 3 ++- 7 files changed, 13 insertions(+), 4 deletions(-) diff --git a/OvmfPkg/AmdSev/AmdSevX64.dsc b/OvmfPkg/AmdSev/AmdSevX64.dsc index e0b04d6734..b92c6154b2 100644 --- a/OvmfPkg/AmdSev/AmdSevX64.dsc +++ b/OvmfPkg/AmdSev/AmdSevX64.dsc @@ -3,7 +3,7 @@ # virtual machine remote attestation and secret injection # # Copyright (c) 2020 James Bottomley, IBM Corporation. -# Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved. +# Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved. # (C) Copyright 2016 Hewlett Packard Enterprise Development LP # # SPDX-License-Identifier: BSD-2-Clause-Patent @@ -352,6 +352,7 @@ DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgentLib.inf !endif PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf + CpuPageTableLib|UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableLib.inf MpInitLib|UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/DxeQemuFwCfgS3LibFwCfg.inf QemuLoadImageLib|OvmfPkg/Library/GenericQemuLoadImageLib/GenericQemuLoadImageLib.inf diff --git a/OvmfPkg/CloudHv/CloudHvX64.dsc b/OvmfPkg/CloudHv/CloudHvX64.dsc index 4fe7cb5f1b..4d7107fd19 100644 --- a/OvmfPkg/CloudHv/CloudHvX64.dsc +++ b/OvmfPkg/CloudHv/CloudHvX64.dsc @@ -403,6 +403,7 @@ DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgentLib.inf !endif PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf + CpuPageTableLib|UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableLib.inf MpInitLib|UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/DxeQemuFwCfgS3LibFwCfg.inf QemuLoadImageLib|OvmfPkg/Library/X86QemuLoadImageLib/X86QemuLoadImageLib.inf diff --git a/OvmfPkg/IntelTdx/IntelTdxX64.dsc b/OvmfPkg/IntelTdx/IntelTdxX64.dsc index 3458926515..ea538fd783 100644 --- a/OvmfPkg/IntelTdx/IntelTdxX64.dsc +++ b/OvmfPkg/IntelTdx/IntelTdxX64.dsc @@ -1,7 +1,7 @@ ## @file # EFI/Framework Open Virtual Machine Firmware (OVMF) platform # -# Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved. +# Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved. # (C) Copyright 2016 Hewlett Packard Enterprise Development LP # Copyright (c) Microsoft Corporation. # @@ -313,6 +313,7 @@ CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf LockBoxLib|OvmfPkg/Library/LockBoxLib/LockBoxDxeLib.inf PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf + CpuPageTableLib|UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableLib.inf MpInitLib|UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/DxeQemuFwCfgS3LibFwCfg.inf QemuLoadImageLib|OvmfPkg/Library/X86QemuLoadImageLib/X86QemuLoadImageLib.inf @@ -577,6 +578,7 @@ UefiCpuPkg/CpuDxe/CpuDxe.inf { + CpuPageTableLib|UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableLib.inf # # Directly use DxeMpInitLib. It depends on DxeMpInitLibMpDepLib which # checks the Protocol of gEfiMpInitLibMpDepProtocolGuid. diff --git a/OvmfPkg/Microvm/MicrovmX64.dsc b/OvmfPkg/Microvm/MicrovmX64.dsc index 93d4cf3da2..b04c8e6936 100644 --- a/OvmfPkg/Microvm/MicrovmX64.dsc +++ b/OvmfPkg/Microvm/MicrovmX64.dsc @@ -1,7 +1,7 @@ ## @file # EFI/Framework Open Virtual Machine Firmware (OVMF) platform # -# Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved. +# Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved. # (C) Copyright 2016 Hewlett Packard Enterprise Development LP # Copyright (c) Microsoft Corporation. # @@ -402,6 +402,7 @@ PciLib|MdePkg/Library/BasePciLibPciExpress/BasePciLibPciExpress.inf PciPcdProducerLib|OvmfPkg/Fdt/FdtPciPcdProducerLib/FdtPciPcdProducerLib.inf PciExpressLib|OvmfPkg/Library/BaseCachingPciExpressLib/BaseCachingPciExpressLib.inf + CpuPageTableLib|UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableLib.inf MpInitLib|UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/DxeQemuFwCfgS3LibFwCfg.inf QemuLoadImageLib|OvmfPkg/Library/X86QemuLoadImageLib/X86QemuLoadImageLib.inf diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc index aca292ce83..894ce1867d 100644 --- a/OvmfPkg/OvmfPkgIa32X64.dsc +++ b/OvmfPkg/OvmfPkgIa32X64.dsc @@ -414,6 +414,7 @@ DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgentLib.inf !endif PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf + CpuPageTableLib|UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableLib.inf MpInitLib|Uef
[edk2-devel] [PATCH 2/4] UefiCpuPkg: Has APs in 64 bit long-mode before booting to OS.
During the finalization of Mp initialization before booting into the OS, depending on whether Mwait is supported or not, AsmRelocateApLoop places Aps in MWAIT-loop or HLT-loop. Since paging is necessary for long mode, the original implementation of moving APs to 32-bit was to disable paging to ensure that the booting does not crash. The current modification creates a page table in reserved memory, avoiding switching modes and reclaiming memory by OS. This modification is only for 64 bit mode. More specifically, we keep the AMD logic as the original code flow, extract and update the Intel-related code, where the APs would stay in 64-bit, and run in a Mwait or Hlt loop until the OS wake them up. Signed-off-by: Ray Ni Signed-off-by: Yuanhao Xie --- UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf | 7 +- UefiCpuPkg/Library/MpInitLib/DxeMpLib.c | 88 - .../Library/MpInitLib/Ia32/CreatePageTable.c | 28 +++ UefiCpuPkg/Library/MpInitLib/MpLib.h | 19 +- UefiCpuPkg/Library/MpInitLib/X64/AmdSev.nasm | 2 +- .../Library/MpInitLib/X64/CreatePageTable.c | 74 UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm | 171 +++--- UefiCpuPkg/UefiCpuPkg.dsc | 1 + 8 files changed, 189 insertions(+), 201 deletions(-) create mode 100644 UefiCpuPkg/Library/MpInitLib/Ia32/CreatePageTable.c create mode 100644 UefiCpuPkg/Library/MpInitLib/X64/CreatePageTable.c diff --git a/UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf b/UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf index cd07de3a3c..8c8b81d933 100644 --- a/UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf +++ b/UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf @@ -1,7 +1,7 @@ ## @file # MP Initialize Library instance for DXE driver. # -# Copyright (c) 2016 - 2021, Intel Corporation. All rights reserved. +# Copyright (c) 2016 - 2022, Intel Corporation. All rights reserved. # SPDX-License-Identifier: BSD-2-Clause-Patent # ## @@ -24,9 +24,11 @@ [Sources.IA32] Ia32/AmdSev.c Ia32/MpFuncs.nasm + Ia32/CreatePageTable.c [Sources.X64] X64/AmdSev.c + X64/CreatePageTable.c X64/MpFuncs.nasm [Sources.common] @@ -57,6 +59,9 @@ CcExitLib MicrocodeLib +[LibraryClasses.X64] + CpuPageTableLib + [Protocols] gEfiTimerArchProtocolGuid ## SOMETIMES_CONSUMES diff --git a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c index 445e0853d2..aff646c3ce 100644 --- a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c +++ b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c @@ -16,6 +16,7 @@ #include #include +#include #include #define AP_SAFE_STACK_SIZE 128 @@ -28,6 +29,7 @@ volatile BOOLEAN mStopCheckAllApsStatus = TRUE; VOID *mReservedApLoopFunc = NULL; UINTN mReservedTopOfApStack; volatile UINT32 mNumberToFinish = 0; +UINTN mApPageTable; // // Begin wakeup buffer allocation below 0x88000 @@ -407,12 +409,9 @@ RelocateApLoop ( AsmRelocateApLoopFunc ( MwaitSupport, CpuMpData->ApTargetCState, - CpuMpData->PmCodeSegment, StackStart - ProcessorNumber * AP_SAFE_STACK_SIZE, (UINTN)&mNumberToFinish, - CpuMpData->Pm16CodeSegment, - CpuMpData->SevEsAPBuffer, - CpuMpData->WakeupBuffer + mApPageTable ); } @@ -477,12 +476,12 @@ InitMpGlobalData ( ) { EFI_STATUS Status; - EFI_PHYSICAL_ADDRESS Address; UINTNApSafeBufferSize; UINTNIndex; EFI_GCD_MEMORY_SPACE_DESCRIPTOR MemDesc; UINTNStackBase; CPU_INFO_IN_HOB *CpuInfoInHob; + UINTNPageTable; SaveCpuMpData (CpuMpData); @@ -545,60 +544,47 @@ InitMpGlobalData ( // Allocating it in advance since memory services are not available in // Exit Boot Services callback function. // - ApSafeBufferSize = EFI_PAGES_TO_SIZE ( - EFI_SIZE_TO_PAGES ( - CpuMpData->AddressMap.RelocateApLoopFuncSize - ) - ); - Address = BASE_4GB - 1; - Status = gBS->AllocatePages ( - AllocateMaxAddress, - EfiReservedMemoryType, - EFI_SIZE_TO_PAGES (ApSafeBufferSize), - &Address - ); - ASSERT_EFI_ERROR (Status); - - mReservedApLoopFunc = (VOID *)(UINTN)Address; - ASSERT (mReservedApLoopFunc != NULL); - - // - // Make sure that the buffer memory is executable if NX protection is enabled - // for EfiReservedMemoryType. - // - // TODO: Check EFI_MEMORY_XP bit set or not once it's available in DXE GCD - // service. + // ++ + // | Ap Loop| + // ++ + // | Stack * N | + // ++ (low address) // - Status = gDS->GetMemorySpaceDescriptor (Address, &MemDesc); - if (!EFI_ERROR (Status))
[edk2-devel] [PATCH 1/4] UefiCpuPkg: Duplicated AsmRelocateApLoop as AsmRelocateApLoopAmd
AsmRelocateApLoop is replicated for future Intel Logic Extraction, further brings AP into 64-bit, and enables paging. Signed-off-by: Yuanhao Xie --- UefiCpuPkg/Library/MpInitLib/DxeMpLib.c | 52 +++--- UefiCpuPkg/Library/MpInitLib/MpEqu.inc| 2 + UefiCpuPkg/Library/MpInitLib/MpLib.h | 27 +++ UefiCpuPkg/Library/MpInitLib/X64/AmdSev.nasm | 169 ++ UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm | 6 + 5 files changed, 236 insertions(+), 20 deletions(-) diff --git a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c index a84e9e33ba..445e0853d2 100644 --- a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c +++ b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c @@ -1,7 +1,7 @@ /** @file MP initialize support functions for DXE phase. - Copyright (c) 2016 - 2020, Intel Corporation. All rights reserved. + Copyright (c) 2016 - 2022, Intel Corporation. All rights reserved. SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -378,32 +378,44 @@ RelocateApLoop ( IN OUT VOID *Buffer ) { - CPU_MP_DATA *CpuMpData; - BOOLEAN MwaitSupport; - ASM_RELOCATE_AP_LOOP AsmRelocateApLoopFunc; - UINTN ProcessorNumber; - UINTN StackStart; + CPU_MP_DATA *CpuMpData; + BOOLEAN MwaitSupport; + ASM_RELOCATE_AP_LOOP AsmRelocateApLoopFunc; + ASM_RELOCATE_AP_LOOP_AMD AsmRelocateApLoopFuncAmd; + UINTN ProcessorNumber; + UINTN StackStart; MpInitLibWhoAmI (&ProcessorNumber); CpuMpData= GetCpuMpData (); MwaitSupport = IsMwaitSupport (); - if (CpuMpData->UseSevEsAPMethod) { -StackStart = CpuMpData->SevEsAPResetStackStart; + if (StandardSignatureIsAuthenticAMD ()) { +StackStart = CpuMpData->UseSevEsAPMethod ? CpuMpData->SevEsAPResetStackStart : mReservedTopOfApStack; +AsmRelocateApLoopFuncAmd = (ASM_RELOCATE_AP_LOOP_AMD)(UINTN)mReservedApLoopFunc; +AsmRelocateApLoopFuncAmd ( + MwaitSupport, + CpuMpData->ApTargetCState, + CpuMpData->PmCodeSegment, + StackStart - ProcessorNumber * AP_SAFE_STACK_SIZE, + (UINTN)&mNumberToFinish, + CpuMpData->Pm16CodeSegment, + CpuMpData->SevEsAPBuffer, + CpuMpData->WakeupBuffer + ); } else { -StackStart = mReservedTopOfApStack; +StackStart= mReservedTopOfApStack; +AsmRelocateApLoopFunc = (ASM_RELOCATE_AP_LOOP)(UINTN)mReservedApLoopFunc; +AsmRelocateApLoopFunc ( + MwaitSupport, + CpuMpData->ApTargetCState, + CpuMpData->PmCodeSegment, + StackStart - ProcessorNumber * AP_SAFE_STACK_SIZE, + (UINTN)&mNumberToFinish, + CpuMpData->Pm16CodeSegment, + CpuMpData->SevEsAPBuffer, + CpuMpData->WakeupBuffer + ); } - AsmRelocateApLoopFunc = (ASM_RELOCATE_AP_LOOP)(UINTN)mReservedApLoopFunc; - AsmRelocateApLoopFunc ( -MwaitSupport, -CpuMpData->ApTargetCState, -CpuMpData->PmCodeSegment, -StackStart - ProcessorNumber * AP_SAFE_STACK_SIZE, -(UINTN)&mNumberToFinish, -CpuMpData->Pm16CodeSegment, -CpuMpData->SevEsAPBuffer, -CpuMpData->WakeupBuffer -); // // It should never reach here // diff --git a/UefiCpuPkg/Library/MpInitLib/MpEqu.inc b/UefiCpuPkg/Library/MpInitLib/MpEqu.inc index ebadcc6fb3..ea202d4aef 100644 --- a/UefiCpuPkg/Library/MpInitLib/MpEqu.inc +++ b/UefiCpuPkg/Library/MpInitLib/MpEqu.inc @@ -26,6 +26,8 @@ struc MP_ASSEMBLY_ADDRESS_MAP .RendezvousFunnelSize CTYPE_UINTN 1 .RelocateApLoopFuncAddress CTYPE_UINTN 1 .RelocateApLoopFuncSizeCTYPE_UINTN 1 + .RelocateApLoopFuncAddressAmd CTYPE_UINTN 1 + .RelocateApLoopFuncSizeAmd CTYPE_UINTN 1 .ModeTransitionOffset CTYPE_UINTN 1 .SwitchToRealNoNxOffsetCTYPE_UINTN 1 .SwitchToRealPM16ModeOffsetCTYPE_UINTN 1 diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.h b/UefiCpuPkg/Library/MpInitLib/MpLib.h index f5086e497e..1102003a93 100644 --- a/UefiCpuPkg/Library/MpInitLib/MpLib.h +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.h @@ -179,6 +179,8 @@ typedef struct { UINTNRendezvousFunnelSize; UINT8*RelocateApLoopFuncAddress; UINTNRelocateApLoopFuncSize; + UINT8*RelocateApLoopFuncAddressAmd; + UINTNRelocateApLoopFuncSizeAmd; UINTNModeTransitionOffset; UINTNSwitchToRealNoNxOffset; UINTNSwitchToRealPM16ModeOffset; @@ -346,6 +348,31 @@ typedef extern EFI_GUID mCpuInitMpLibHobGuid; +/** + Assembly code to place AP into safe loop mode for Amd. + Place AP into targeted C-State if MONITOR is supported, otherwise + place AP into hlt state. + Place AP in protected mode if the current is long mode. Due to AP maybe + wakeup by some hardware event. It could avoid accessing page table that + may not available during booting to OS. + @param[in] MwaitSupportTRUE indicates MONITOR is supported. + FALSE indicates M
[edk2-devel] [PATCH 0/4] Put APs in 64 bit long-mode before booting to OS.
Yuanhao Xie (4): UefiCpuPkg: Duplicated AsmRelocateApLoop as AsmRelocateApLoopAmd UefiCpuPkg: Has APs in 64 bit long-mode before booting to OS. OvmfPkg: Add CpuPageTableLib required by MpInitLib. UefiPayloadPkg: Add CpuPageTableLib required by MpInitLib. OvmfPkg/AmdSev/AmdSevX64.dsc | 3 +- OvmfPkg/CloudHv/CloudHvX64.dsc| 1 + OvmfPkg/IntelTdx/IntelTdxX64.dsc | 4 +- OvmfPkg/Microvm/MicrovmX64.dsc| 3 +- OvmfPkg/OvmfPkgIa32X64.dsc| 1 + OvmfPkg/OvmfPkgX64.dsc| 2 + OvmfPkg/OvmfXen.dsc | 3 +- UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf | 7 +- UefiCpuPkg/Library/MpInitLib/DxeMpLib.c | 132 +++-- .../Library/MpInitLib/Ia32/CreatePageTable.c | 28 +++ UefiCpuPkg/Library/MpInitLib/MpEqu.inc| 2 + UefiCpuPkg/Library/MpInitLib/MpLib.h | 46 - UefiCpuPkg/Library/MpInitLib/X64/AmdSev.nasm | 169 + .../Library/MpInitLib/X64/CreatePageTable.c | 74 UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm | 177 -- UefiCpuPkg/UefiCpuPkg.dsc | 1 + UefiPayloadPkg/UefiPayloadPkg.dsc | 1 + 17 files changed, 434 insertions(+), 220 deletions(-) create mode 100644 UefiCpuPkg/Library/MpInitLib/Ia32/CreatePageTable.c create mode 100644 UefiCpuPkg/Library/MpInitLib/X64/CreatePageTable.c -- 2.36.1.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#97527): https://edk2.groups.io/g/devel/message/97527 Mute This Topic: https://groups.io/mt/95754112/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-