From nobody Fri May 17 09:01:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+96105+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+96105+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1667942170; cv=none; d=zohomail.com; s=zohoarc; b=McgQe1MxlOctAflhdRQHg+82VFyI9v/HsyFkTVTSz69pIcgvJJU2I6I/z6RyFFxgmRnxtMGeRR/4M+Z/dr/fzRP0U71nkqJx/lKoqhDO2Vbd0vayHATTmhxVXcsKRin3WOnPgAZnYJ3Ve9Md4g0J3UWTeBevYPAXvPVIQxkBYkg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1667942170; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=x0IPHo667gkhcIT2x2dMQJfgFUTdyVR7BLRHFH5kh/w=; b=FA+L2Ri2v7qdl8G1csWwB4dXqGrP7xKeWOZjGtpy3nvMsE0NeiTmayOYNavHpBFdB/mNJ0dlplMX0E/HuB2dWQL8u0h9Qk1ZAkZxoiRC/9nLnmLBWRd5/vUY5t8XshPBMqsiiL7WRVWiLEtOISuCbbUiWrnEBwUdYpnjbNjH3MY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+96105+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1667942170566279.52270202866714; Tue, 8 Nov 2022 13:16:10 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 6wPFYY1788612xbSICHbSl8f; Tue, 08 Nov 2022 13:16:10 -0800 X-Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) by mx.groups.io with SMTP id smtpd.web11.2826.1667942169449201697 for ; Tue, 08 Nov 2022 13:16:09 -0800 X-Received: by mail-pj1-f73.google.com with SMTP id nl16-20020a17090b385000b002138288fd51so1623pjb.6 for ; Tue, 08 Nov 2022 13:16:09 -0800 (PST) X-Gm-Message-State: 7LZeBeMljE2cSepPUVCplghbx1787277AA= X-Google-Smtp-Source: AMsMyM62dBB++5fnH/QKQCrzpOwHdF4TdfXW4G09c/V4GoV6ZL+iUo9bVOV2zRzRarli7uixYS0ECmNtLvdwREm04w== X-Received: from dionnaglaze.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:2ee6]) (user=dionnaglaze job=sendgmr) by 2002:aa7:82d8:0:b0:561:5d08:761 with SMTP id f24-20020aa782d8000000b005615d080761mr1068266pfn.14.1667942168358; Tue, 08 Nov 2022 13:16:08 -0800 (PST) Date: Tue, 8 Nov 2022 21:15:54 +0000 In-Reply-To: <20221108211557.3306520-1-dionnaglaze@google.com> Mime-Version: 1.0 References: <20221108211557.3306520-1-dionnaglaze@google.com> Message-ID: <20221108211557.3306520-2-dionnaglaze@google.com> Subject: [edk2-devel] [PATCH v2 1/4] OvmfPkg: Realize EfiMemoryAcceptProtocol in AmdSevDxe From: "Dionna Glaze via groups.io" To: devel@edk2.groups.io Cc: Dionna Glaze , Gerd Hoffmann , James Bottomley , Jiewen Yao , Tom Lendacky Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,dionnaglaze@google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1667942170; bh=AuIWhykj62QC1Mok0BIERW4qJPY/Cg493gmjFut/92M=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=h7bTdwXYp8ITM/ZXCUANqL00Z314C3E6/uTwi1TS116zuSkLngYqOXRizpB0pF3ty+o +sycKJsXjKKbS4fsCnKpuTO3ueWtghUgv/0c/2CADl3CPWoOtIed9YT0/NnXKbMDmj9cf w4CZqybmeFEEUS45fCbnVMLQ44sV6V4NVsA= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1667942172507100006 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Sophia Wolf When a guest OS does not support unaccepted memory, the unaccepted memory must be accepted before returning a memory map to the caller. EfiMemoryAcceptProtocol is defined in MdePkg and is implemented / Installed in AmdSevDxe for AMD SEV-SNP memory acceptance. Cc: Gerd Hoffmann Cc: James Bottomley Cc: Jiewen Yao Cc: Tom Lendacky Reviewed-by: Tom Lendacky Signed-off-by: Dionna Glaze --- OvmfPkg/AmdSevDxe/AmdSevDxe.c | 55 ++= ++++++++++++++++-- OvmfPkg/AmdSevDxe/AmdSevDxe.inf | 3 ++ OvmfPkg/Library/BaseMemEncryptSevLib/X64/DxeSnpSystemRamValidate.c | 24 ++= +++++-- 3 files changed, 74 insertions(+), 8 deletions(-) diff --git a/OvmfPkg/AmdSevDxe/AmdSevDxe.c b/OvmfPkg/AmdSevDxe/AmdSevDxe.c index 662d3c4ccb..f7600c3c81 100644 --- a/OvmfPkg/AmdSevDxe/AmdSevDxe.c +++ b/OvmfPkg/AmdSevDxe/AmdSevDxe.c @@ -20,6 +20,7 @@ #include #include #include +#include =20 STATIC CONFIDENTIAL_COMPUTING_SNP_BLOB_LOCATION mSnpBootDxeTable =3D { SIGNATURE_32 ('A', 'M', 'D', 'E'), @@ -31,6 +32,40 @@ STATIC CONFIDENTIAL_COMPUTING_SNP_BLOB_LOCATION mSnpBoo= tDxeTable =3D { FixedPcdGet32 (PcdOvmfCpuidSize), }; =20 +STATIC EFI_HANDLE mAmdSevDxeHandle =3D NULL; + +#define IS_ALIGNED(x, y) ((((x) & ((y) - 1)) =3D=3D 0)) + +STATIC +EFI_STATUS +EFIAPI +AmdSevMemoryAccept ( + IN EDKII_MEMORY_ACCEPT_PROTOCOL *This, + IN EFI_PHYSICAL_ADDRESS StartAddress, + IN UINTN Size + ) +{ + // + // The StartAddress must be page-aligned, and the Size must be a positive + // multiple of SIZE_4KB. Use an assert instead of returning an erros sin= ce + // this is an EDK2-internal protocol. + // + ASSERT (IS_ALIGNED (StartAddress, SIZE_4KB)); + ASSERT (IS_ALIGNED (Size, SIZE_4KB)); + ASSERT (Size !=3D 0); + + MemEncryptSevSnpPreValidateSystemRam ( + StartAddress, + EFI_SIZE_TO_PAGES (Size) + ); + + return EFI_SUCCESS; +} + +STATIC EDKII_MEMORY_ACCEPT_PROTOCOL mMemoryAcceptProtocol =3D { + AmdSevMemoryAccept +}; + EFI_STATUS EFIAPI AmdSevDxeEntryPoint ( @@ -147,11 +182,23 @@ AmdSevDxeEntryPoint ( } } =20 - // - // If its SEV-SNP active guest then install the CONFIDENTIAL_COMPUTING_S= EV_SNP_BLOB. - // It contains the location for both the Secrets and CPUID page. - // if (MemEncryptSevSnpIsEnabled ()) { + // + // Memory acceptance began being required in SEV-SNP, so install the + // memory accept protocol implementation for a SEV-SNP active guest. + // + Status =3D gBS->InstallProtocolInterface ( + &mAmdSevDxeHandle, + &gEdkiiMemoryAcceptProtocolGuid, + EFI_NATIVE_INTERFACE, + &mMemoryAcceptProtocol + ); + ASSERT_EFI_ERROR (Status); + + // + // If its SEV-SNP active guest then install the CONFIDENTIAL_COMPUTING= _SEV_SNP_BLOB. + // It contains the location for both the Secrets and CPUID page. + // return gBS->InstallConfigurationTable ( &gConfidentialComputingSevSnpBlobGuid, &mSnpBootDxeTable diff --git a/OvmfPkg/AmdSevDxe/AmdSevDxe.inf b/OvmfPkg/AmdSevDxe/AmdSevDxe.= inf index 9acf860cf2..cd1b686c53 100644 --- a/OvmfPkg/AmdSevDxe/AmdSevDxe.inf +++ b/OvmfPkg/AmdSevDxe/AmdSevDxe.inf @@ -47,6 +47,9 @@ gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSnpSecretsBase gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSnpSecretsSize =20 +[Protocols] + gEdkiiMemoryAcceptProtocolGuid + [Guids] gConfidentialComputingSevSnpBlobGuid =20 diff --git a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/DxeSnpSystemRamValida= te.c b/OvmfPkg/Library/BaseMemEncryptSevLib/X64/DxeSnpSystemRamValidate.c index d3a95e4913..cbcdd46f52 100644 --- a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/DxeSnpSystemRamValidate.c +++ b/OvmfPkg/Library/BaseMemEncryptSevLib/X64/DxeSnpSystemRamValidate.c @@ -14,6 +14,7 @@ #include =20 #include "SnpPageStateChange.h" +#include "VirtualMemory.h" =20 /** Pre-validate the system RAM when SEV-SNP is enabled in the guest VM. @@ -29,12 +30,27 @@ MemEncryptSevSnpPreValidateSystemRam ( IN UINTN NumPages ) { + EFI_STATUS Status; + if (!MemEncryptSevSnpIsEnabled ()) { return; } =20 - // - // All the pre-validation must be completed in the PEI phase. - // - ASSERT (FALSE); + // DXE pre-validation may happen with the memory accept protocol. + // The protocol should only be called outside the prevalidated ranges + // that the PEI stage code explicitly skips. Specifically, only memory + // ranges that are classified as unaccepted. + if (BaseAddress >=3D SIZE_4GB) { + Status =3D InternalMemEncryptSevCreateIdentityMap1G ( + 0, + BaseAddress, + EFI_PAGES_TO_SIZE (NumPages) + ); + if (EFI_ERROR (Status)) { + ASSERT (FALSE); + CpuDeadLoop (); + } + } + + InternalSetPageState (BaseAddress, NumPages, SevSnpPagePrivate, TRUE); } --=20 2.38.1.431.g37b22c650d-goog -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#96105): https://edk2.groups.io/g/devel/message/96105 Mute This Topic: https://groups.io/mt/94900164/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri May 17 09:01:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+96106+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+96106+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1667942173; cv=none; d=zohomail.com; s=zohoarc; b=Kkog7YK0MujlkKVU6y/omDa45jCcRwXviHnnDFMNHFJ300tTY6tUHb3t+lT/x0V07NaIuWO775lhsm03NXE1ThUG5gch8eeS8359Xgve7YhL3JrZg9RTQttmHs+7hsDBPOnyCkGIFwYVokQ/pKThU75AtTtx6iGJqPw30PaA6aY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1667942173; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=NeJcwas6Dod9pq6mucfy+SvTQZVtq9w4tOzlGNGxK3g=; b=WrhFtjGrAYfM4sRLloZkpsubCR2I/aui1k3kewff6H6/ybHKCaUn2Qesgn70FUx5ZswFeJOzu5bSFCZ7Gzwdn6SM4sRyQTv1NMxgYBWc//ecHljcEtL+iA5q7Ve3KS/mE60aphNvrIqByIO11WZ6TVZNH7F7SGrWX0bxW+U7DQs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+96106+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1667942173219595.0556528479246; Tue, 8 Nov 2022 13:16:13 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id bYb4YY1788612xY8gpYr5J5x; Tue, 08 Nov 2022 13:16:12 -0800 X-Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) by mx.groups.io with SMTP id smtpd.web12.2817.1667942171823417451 for ; Tue, 08 Nov 2022 13:16:11 -0800 X-Received: by mail-pj1-f73.google.com with SMTP id ci1-20020a17090afc8100b00212e5b4c3afso6700101pjb.3 for ; Tue, 08 Nov 2022 13:16:11 -0800 (PST) X-Gm-Message-State: bCEsMkIcbQoUMKXQYLzZdOcPx1787277AA= X-Google-Smtp-Source: AMsMyM4qIIZfD4ZwVXBD7wx/BebJPy1p5RToZhY4XxpiCtvlfktQ2l09Bz9uzM195taGVqCak5DZOzoMipdLDJAdSA== X-Received: from dionnaglaze.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:2ee6]) (user=dionnaglaze job=sendgmr) by 2002:a17:90a:cb95:b0:215:f80c:18e6 with SMTP id a21-20020a17090acb9500b00215f80c18e6mr859377pju.45.1667942170443; Tue, 08 Nov 2022 13:16:10 -0800 (PST) Date: Tue, 8 Nov 2022 21:15:55 +0000 In-Reply-To: <20221108211557.3306520-1-dionnaglaze@google.com> Mime-Version: 1.0 References: <20221108211557.3306520-1-dionnaglaze@google.com> Message-ID: <20221108211557.3306520-3-dionnaglaze@google.com> Subject: [edk2-devel] [PATCH v2 2/4] MdePkg: Add event groups for boot events From: "Dionna Glaze via groups.io" To: devel@edk2.groups.io Cc: Dionna Glaze , Ard Biescheuvel , "Min M. Xu" , Gerd Hoffmann , James Bottomley , Tom Lendacky , Jiewen Yao , Erdem Aktas Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,dionnaglaze@google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1667942172; bh=TR7y4Zm3nyoqZ/MJVFVUeh+3fN9+SDdSKS7NlR3HgXg=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=h8BzUXxbbqFzHw9eQWBogwpxMeiappDMxKaPAG1pH8R2U6WTHu5m6+UNNAL6GReHW6q 91THvdqTsWKt/lysKMVp9/LA24WbtffZAGidolPUwmDKonaIQ7V99Ds+6YrDOAyubMgKq wcQGDE6tn78XVRfSA13BxqlXiclVsP68DCg= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1667942174317100009 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add EFI_EVENT_BEFORE_EXIT_BOOT_SERVICES_GUID Add EFI_EVENT_GROUP_AFTER_READY_TO_BOOT Both defined in UEFI standard v2.9. Cc: Ard Biescheuvel Cc: "Min M. Xu" Cc: Gerd Hoffmann Cc: James Bottomley Cc: Tom Lendacky Cc: Jiewen Yao Cc: Erdem Aktas Signed-off-by: Dionna Glaze --- MdePkg/Include/Guid/EventGroup.h | 10 ++++++++++ MdePkg/MdePkg.dec | 8 +++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/MdePkg/Include/Guid/EventGroup.h b/MdePkg/Include/Guid/EventGr= oup.h index 063d1f7157..821b728e59 100644 --- a/MdePkg/Include/Guid/EventGroup.h +++ b/MdePkg/Include/Guid/EventGroup.h @@ -14,6 +14,11 @@ SPDX-License-Identifier: BSD-2-Clause-Patent =20 extern EFI_GUID gEfiEventExitBootServicesGuid; =20 +#define EFI_EVENT_GROUP_BEFORE_EXIT_BOOT_SERVICES \ + { 0x8be0e274, 0x3970, 0x4b44, { 0x80, 0xc5, 0x1a, 0xb9, 0x50, 0x2f, 0x3b= , 0xfc } } + +extern EFI_GUID gEfiEventBeforeExitBootServicesGuid; + #define EFI_EVENT_GROUP_VIRTUAL_ADDRESS_CHANGE \ { 0x13fa7698, 0xc831, 0x49c7, { 0x87, 0xea, 0x8f, 0x43, 0xfc, 0xc2, 0x51= , 0x96 } } =20 @@ -29,6 +34,11 @@ extern EFI_GUID gEfiEventMemoryMapChangeGuid; =20 extern EFI_GUID gEfiEventReadyToBootGuid; =20 +#define EFI_EVENT_GROUP_AFTER_READY_TO_BOOT \ + { 0x3a2a00ad, 0x98b9, 0x4cdf, { 0xa4, 0x78, 0x70, 0x27, 0x77, 0xf1, 0xc1,= 0xb } } + +extern EFI_GUID gEfiEventAfterReadyToBootGuid; + #define EFI_EVENT_GROUP_DXE_DISPATCH_GUID \ { 0x7081e22f, 0xcac6, 0x4053, { 0x94, 0x68, 0x67, 0x57, 0x82, 0xcf, 0x88= , 0xe5 }} =20 diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec index 6b6bfbec29..c4ccec935a 100644 --- a/MdePkg/MdePkg.dec +++ b/MdePkg/MdePkg.dec @@ -408,11 +408,17 @@ gEfiEventMemoryMapChangeGuid =3D { 0x78BEE926, 0x692F, 0x48FD, { 0x9E,= 0xDB, 0x01, 0x42, 0x2E, 0xF0, 0xD7, 0xAB }} =20 ## Include/Guid/EventGroup.h - gEfiEventVirtualAddressChangeGuid =3D { 0x13FA7698, 0xC831, 0x49C7, { 0x= 87, 0xEA, 0x8F, 0x43, 0xFC, 0xC2, 0x51, 0x96 }} + gEfiEventVirtualAddressChangeGuid =3D { 0x13FA7698, 0xC831, 0x49C7, { = 0x87, 0xEA, 0x8F, 0x43, 0xFC, 0xC2, 0x51, 0x96 }} + + ## Include/Guid/EventGroup.h + gEfiEventBeforeExitBootServicesGuid =3D { 0x8BE0E274, 0x3970, 0x4B44, { = 0x80, 0xC5, 0x1A, 0xB9, 0x50, 0x2F, 0x3B, 0xFC }} =20 ## Include/Guid/EventGroup.h gEfiEventExitBootServicesGuid =3D { 0x27ABF055, 0xB1B8, 0x4C26, { 0x80,= 0x48, 0x74, 0x8F, 0x37, 0xBA, 0xA2, 0xDF }} =20 + ## Include/Guid/EventGroup.h + gEfiEventAfterReadyToBootGuid =3D { 0x3A2A00AD, 0x98B9, 0x4CDF, { 0xA4, = 0x78, 0x70, 0x27, 0x77, 0xF1, 0xC1, 0xB }} + ## Include/Protocol/DebugPort.h gEfiDebugPortVariableGuid =3D { 0xEBA4E8D2, 0x3858, 0x41EC, { 0xA2,= 0x81, 0x26, 0x47, 0xBA, 0x96, 0x60, 0xD0 }} =20 --=20 2.38.1.431.g37b22c650d-goog -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#96106): https://edk2.groups.io/g/devel/message/96106 Mute This Topic: https://groups.io/mt/94900166/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri May 17 09:01:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+96107+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+96107+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1667942174; cv=none; d=zohomail.com; s=zohoarc; b=MOA5GoRax/I2cozgrqWP7jT+/K8NbrmlcRiJVwadZuzYCcTZnEu6suk/jl/tDU3Pc/qd7YDnMTr25hqBUMne/x0As+LccsnN5tUm1ZlMY+ULeskZRTFDaj4c2oaCw87aMAEFsJ9oiTpq4/+cSM3l1MAHyg+Uwq6FU+zI11VrdeI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1667942174; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=TE2SBJXMjFBE3RFhQAqK+QfSocKwLuCMngEOcXhj4qo=; b=CEEUOxZVk4jo3PQZNEPePrrPbJ5gSZXlGjttAUeLwv0RXtCiqY9ZItjgm81xcyzJeOQSaHyXP05B3PXgN+AlHV+0v0UXOPwXNvhKPLlPZX4s8iNe/o+MzZVxiSB47IvoqXZYe5ET6K0GZecCZe2LmtCx8ejxHP921agtGkAfrCk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+96107+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1667942174140320.97878533494077; Tue, 8 Nov 2022 13:16:14 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id IOiqYY1788612xDDE1q5mMQU; Tue, 08 Nov 2022 13:16:13 -0800 X-Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) by mx.groups.io with SMTP id smtpd.web10.2770.1667942172863703658 for ; Tue, 08 Nov 2022 13:16:12 -0800 X-Received: by mail-pj1-f74.google.com with SMTP id b1-20020a17090a10c100b0020da29fa5e5so12740pje.2 for ; Tue, 08 Nov 2022 13:16:12 -0800 (PST) X-Gm-Message-State: atXOJ04VK2aOG8qYCuJts520x1787277AA= X-Google-Smtp-Source: AMsMyM52b43j0lsJZTaTz7SNH6ttj2WF/idc81ohFeTzGOi9KSuBRmOzfrY1+ZSkoPLYz0Dg+O0QKxrViA5+d8C51A== X-Received: from dionnaglaze.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:2ee6]) (user=dionnaglaze job=sendgmr) by 2002:a05:6a00:1d25:b0:56b:add7:fe2f with SMTP id a37-20020a056a001d2500b0056badd7fe2fmr1063063pfx.51.1667942172214; Tue, 08 Nov 2022 13:16:12 -0800 (PST) Date: Tue, 8 Nov 2022 21:15:56 +0000 In-Reply-To: <20221108211557.3306520-1-dionnaglaze@google.com> Mime-Version: 1.0 References: <20221108211557.3306520-1-dionnaglaze@google.com> Message-ID: <20221108211557.3306520-4-dionnaglaze@google.com> Subject: [edk2-devel] [PATCH v2 3/4] MdeModulePkg: Notify BeforeExitBootServices in CoreExitBootServices From: "Dionna Glaze via groups.io" To: devel@edk2.groups.io Cc: Dionna Glaze , Gerd Hoffmann , James Bottomley , Jiewen Yao , Tom Lendacky , Ard Biesheuvel , "Min M. Xu" , Andrew Fish , "Michael D. Kinney" , Ray Ni , Jiewen Yao Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,dionnaglaze@google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1667942173; bh=VZvdivtMz+LbazJZmg9wyf9+MoBNz0cc+uRunQpxpDE=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=HRZ3YZjI+PvkRVQKWAvOtzUqGNfUeR0FauXSmAl4wDutjYcES57Imxvl3+rFH8iwT0p tVIlQ+O/kbHj+qRxxFKNLz7MrMiY60+cIcRYUu8eYnuxHyhLh5zwHA6L3Qcv/J1ksuJ99 RPje0X9UEmRu3cEiKbmfAqRnbrfSprWUikY= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1667942174325100010 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Location of notification is has been specified in UEFI v2.9. Cc: Gerd Hoffmann Cc: James Bottomley Cc: Jiewen Yao Cc: Tom Lendacky Cc: Ard Biesheuvel Cc: "Min M. Xu" Cc: Andrew Fish Cc: "Michael D. Kinney" Cc: Ray Ni Acked-by: Jiewen Yao Signed-off-by: Dionna Glaze --- MdeModulePkg/Core/Dxe/DxeMain.inf | 1 + MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/MdeModulePkg/Core/Dxe/DxeMain.inf b/MdeModulePkg/Core/Dxe/DxeM= ain.inf index e4bca89577..35d5bf0dee 100644 --- a/MdeModulePkg/Core/Dxe/DxeMain.inf +++ b/MdeModulePkg/Core/Dxe/DxeMain.inf @@ -100,6 +100,7 @@ gEfiEventVirtualAddressChangeGuid ## CONSUMES ##= Event ## CONSUMES ## Event ## PRODUCES ## Event + gEfiEventBeforeExitBootServicesGuid gEfiEventExitBootServicesGuid gEfiHobMemoryAllocModuleGuid ## SOMETIMES_CONSUMES ##= HOB gEfiFirmwareFileSystem2Guid ## CONSUMES ##= GUID # Used to compare with FV's file system guid and get the FV's file sy= stem format diff --git a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c b/MdeModulePkg/Core/Dx= e/DxeMain/DxeMain.c index 5733f0c8ec..4683016ed7 100644 --- a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c +++ b/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c @@ -763,6 +763,12 @@ CoreExitBootServices ( { EFI_STATUS Status; =20 + // + // Notify other drivers of their last chance to use boot services + // before the memory map is terminated. + // + CoreNotifySignalList (&gEfiEventBeforeExitBootServicesGuid); + // // Disable Timer // --=20 2.38.1.431.g37b22c650d-goog -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#96107): https://edk2.groups.io/g/devel/message/96107 Mute This Topic: https://groups.io/mt/94900167/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri May 17 09:01:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+96108+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+96108+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1667942176; cv=none; d=zohomail.com; s=zohoarc; b=dhp3S4CGB/w4ZWFSdAtUDWQXiiWML9MlBtVCIQx0SyLbeJUFnngEegJCetcgcMp4ijXcjCPmuaapLOmL2KTvtF4sQ6qgg5iS4g6u74ATSjsgEEtIKpCTvyHXOsU6HHiBtJ7mTf9ZgGnLjN8+bwmwCFgqI8xpeXGkdk3uYPLMCm0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1667942176; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=bRit/T0d1SZOLXMnTLmkf+B4OLji/7oUI/ngqRJGvDI=; b=HR3iOifP5+GLfa3tbNA8guoSsb8HQrO13347dPw1h7nYNJn7wu2CdAaDgYI3OybfUkIccPYDyX8TLxt349i0p9/f9lRBYjNXhW2hVdhKEDR/lUQSeztNfoo7BJliJJ0c3PH/0QVFFSWJ+0zZ2UbRvLLLESlWvtKmu8RdCGbzyQ0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+96108+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1667942176153313.438013223893; Tue, 8 Nov 2022 13:16:16 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id HlHqYY1788612xmXQVWSt03d; Tue, 08 Nov 2022 13:16:15 -0800 X-Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) by mx.groups.io with SMTP id smtpd.web12.2818.1667942174687646811 for ; Tue, 08 Nov 2022 13:16:14 -0800 X-Received: by mail-pl1-f202.google.com with SMTP id t3-20020a170902e84300b00186ab03043dso12074164plg.20 for ; Tue, 08 Nov 2022 13:16:14 -0800 (PST) X-Gm-Message-State: bSSMTfQjjKSYSlgGF5EOAcVJx1787277AA= X-Google-Smtp-Source: AMsMyM6xJ6E64LQkB80nNFaU9Gv4HrfT/sTbTkbFsICTuEKGyZJHq6+2jW8m85Us32igD97ne93gIaR1h1sBCFCIMQ== X-Received: from dionnaglaze.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:2ee6]) (user=dionnaglaze job=sendgmr) by 2002:a62:1c85:0:b0:563:3c15:f891 with SMTP id c127-20020a621c85000000b005633c15f891mr1066043pfc.76.1667942174028; Tue, 08 Nov 2022 13:16:14 -0800 (PST) Date: Tue, 8 Nov 2022 21:15:57 +0000 In-Reply-To: <20221108211557.3306520-1-dionnaglaze@google.com> Mime-Version: 1.0 References: <20221108211557.3306520-1-dionnaglaze@google.com> Message-ID: <20221108211557.3306520-5-dionnaglaze@google.com> Subject: [edk2-devel] [PATCH v2 4/4] MdePkg: Signal AfterReadyToBoot after ReadyToBoot From: "Dionna Glaze via groups.io" To: devel@edk2.groups.io Cc: Dionna Glaze , Michael D Kinney , Ard Biesheuvel , Gerd Hoffman , Jiewen Yao Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,dionnaglaze@google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1667942175; bh=8WMAw9wniDtEzsptrSll+I/dOYAQyPthTMhY3gcNb88=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=xTxwISlLlUe/hdWsDgDWHwFe5W9E/zoj4OqUGRGvZeoNm2U/LR0AI33cAXp+mDdOecL KN1XZrZXP72hm0Q/9F+L7tVi8DXjxkNU3Z6l+XXOXeMRIaOgksDN4bnhjG4OHWNaBxmrq vEr41zlI9TYoqrmaJW7BZ3utWIKhOkn0mzc= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1667942176417100002 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The Uefi v2.9 specification adds this event group in section 3.1.7, with its GUID defined in the Related Definitions section of EFI_BOOT_SERVICES.CreateEventEx() in chapter 7. Cc: "Michael D Kinney" Cc: Ard Biesheuvel Cc: Gerd Hoffman Cc: Jiewen Yao Signed-off-by: Dionna Glaze --- MdePkg/Include/Library/UefiLib.h | 2 ++ MdePkg/Library/UefiLib/UefiLib.inf | 1 + MdePkg/Library/UefiLib/UefiNotTiano.c | 18 ++++++++++++++++++ 3 files changed, 21 insertions(+) diff --git a/MdePkg/Include/Library/UefiLib.h b/MdePkg/Include/Library/Uefi= Lib.h index be7da7fdf7..2c3342351e 100644 --- a/MdePkg/Include/Library/UefiLib.h +++ b/MdePkg/Include/Library/UefiLib.h @@ -890,6 +890,8 @@ UnicodeStringDisplayLength ( /** Create, Signal, and Close the Ready to Boot event using EfiSignalEventRe= adyToBoot(). =20 + If successful, then create, signal and close the After Ready to Boot eve= nt. + This function abstracts the signaling of the Ready to Boot Event. The Fr= amework moved from a proprietary to UEFI 2.0 based mechanism. This library abstracts t= he caller from how this event is created to prevent to code form having to change = with the diff --git a/MdePkg/Library/UefiLib/UefiLib.inf b/MdePkg/Library/UefiLib/Ue= fiLib.inf index 01ed92092d..5c4064eafa 100644 --- a/MdePkg/Library/UefiLib/UefiLib.inf +++ b/MdePkg/Library/UefiLib/UefiLib.inf @@ -60,6 +60,7 @@ gEfiGlobalVariableGuid ## SOMETIMES_CONSUMES ## = Variable gEfiAcpi20TableGuid ## SOMETIMES_CONSUMES ## = SystemTable gEfiAcpi10TableGuid ## SOMETIMES_CONSUMES ## = SystemTable + gEfiEventAfterReadyToBootGuid ## SOMETIMES_CONSUMES ## = Event =20 [Protocols] gEfiDriverBindingProtocolGuid ## SOMETIMES_PRODUCES diff --git a/MdePkg/Library/UefiLib/UefiNotTiano.c b/MdePkg/Library/UefiLib= /UefiNotTiano.c index d84e91fd01..04fe42f9f7 100644 --- a/MdePkg/Library/UefiLib/UefiNotTiano.c +++ b/MdePkg/Library/UefiLib/UefiNotTiano.c @@ -208,6 +208,8 @@ EfiCreateEventReadyToBootEx ( /** Create, Signal, and Close the Ready to Boot event using EfiSignalEventRe= adyToBoot(). =20 + If successful, then create, signal and close the After Ready to Boot eve= nt. + =20 This function abstracts the signaling of the Ready to Boot Event. The Fr= amework moved from a proprietary to UEFI 2.0 based mechanism. This library abstracts t= he caller from how this event is created to prevent to code form having to change = with the @@ -222,11 +224,27 @@ EfiSignalEventReadyToBoot ( { EFI_STATUS Status; EFI_EVENT ReadyToBootEvent; + EFI_EVENT AfterReadyToBootEvent; =20 Status =3D EfiCreateEventReadyToBoot (&ReadyToBootEvent); if (!EFI_ERROR (Status)) { gBS->SignalEvent (ReadyToBootEvent); gBS->CloseEvent (ReadyToBootEvent); + return; + } + + /* Then immediately signal the after ready to boot event group */ + Status =3D gBS->CreateEventEx ( + EVT_NOTIFY_SIGNAL, + TPL_CALLBACK, + EfiEventEmptyFunction, + NULL, + &gEfiEventAfterReadyToBootGuid, + AfterReadyToBootEvent + ); + if (!EFI_ERROR(Status)) { + gBS->SignalEvent (AfterReadyToBootEvent); + gBS->CloseEvent (AfterReadyToBootEvent); } } =20 --=20 2.38.1.431.g37b22c650d-goog -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#96108): https://edk2.groups.io/g/devel/message/96108 Mute This Topic: https://groups.io/mt/94900168/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-