From nobody Thu May 9 12:31:21 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+94681+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+94681+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1664823243; cv=none; d=zohomail.com; s=zohoarc; b=ND9z/NYuE9iXuQPN+zJBczYk8ibgZ2k2m/HJyqqeip0ffONiZFJ0/kHxAXe8xdoUq+euNZ9JYMQFVLog2BRdDoqcmlNwcOOmWQinWPrGReATDE5OV4VNvt56PEBWtBN5iaabG6UKwutpyUpKRcaDkyVadl0iwIqaZwiLNV+V9OY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664823243; 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=I+/1bgp9uT//E3vaEDJxspyODujILlcZFEVwJcupTS8=; b=OKbzsOyZO6dH9BLx8PVHremEFQGU2BjYdqYmoNa/1VtTCZ5TvLx4vgP2uy2yzic4xL+lJeyWpqLdK5PPYswOXtltAfolKhvNHThtOFrKpkAE0VyyLTVo0FFwmoDu70KQoooMfZO5uflGoboUyWbwCT3Ls3b+yMdqbU7D7jPF818= 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+94681+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1664823243088656.8094895614229; Mon, 3 Oct 2022 11:54:03 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id A6O7YY1788612x992rdfn4kC; Mon, 03 Oct 2022 11:54:02 -0700 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.web11.1504.1664823241651350967 for ; Mon, 03 Oct 2022 11:54:01 -0700 X-Received: by mail-pl1-f202.google.com with SMTP id l2-20020a170902f68200b00177ee7e673eso8683629plg.2 for ; Mon, 03 Oct 2022 11:54:01 -0700 (PDT) X-Gm-Message-State: XVsDloHoayS3rTXndadLr6B2x1787277AA= X-Google-Smtp-Source: AMsMyM4w2jej9lsQV+InotlcsRncatxAaXoXwOMxuiU/MMWUApjYkFIArc83PLOwgZdkl3LLj9F6FV/cO7gYkO0nhg== X-Received: from dionnaglaze.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:2ee6]) (user=dionnaglaze job=sendgmr) by 2002:a17:90b:3ec2:b0:202:b123:29cc with SMTP id rm2-20020a17090b3ec200b00202b12329ccmr13739344pjb.167.1664823241120; Mon, 03 Oct 2022 11:54:01 -0700 (PDT) Date: Mon, 3 Oct 2022 18:53:46 +0000 In-Reply-To: <20221003185352.3969999-1-dionnaglaze@google.com> Mime-Version: 1.0 References: <20221003185352.3969999-1-dionnaglaze@google.com> Message-ID: <20221003185352.3969999-2-dionnaglaze@google.com> Subject: [edk2-devel] [PATCH v6 1/7] 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=1664823242; bh=WAwkEKPSsifBwIWF2pbJV8o0X88+QLhlRkvWlBBgu3k=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=Hcc7IMSJoQ7hqr44KMq3M92BV3y9MJPCiaLUYE2uhQMQ70nfKedVW1J0pdq4zxb9zsX jmy/TzN7X6DQGDiEv/L5aeWl5Pt4b86xAdmlBiiphnvR+LZA2IdYV2hiH5gDrcY24R1yd ucwalko/zw8b1/pNraFVUD4gLKBJapTxA6M= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1664823244855100003 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 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..13fb58cc02 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 EFI_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 EFI_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, + &gEfiMemoryAcceptProtocolGuid, + 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..5ddddabc32 100644 --- a/OvmfPkg/AmdSevDxe/AmdSevDxe.inf +++ b/OvmfPkg/AmdSevDxe/AmdSevDxe.inf @@ -47,6 +47,9 @@ gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSnpSecretsBase gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSnpSecretsSize =20 +[Protocols] + gEfiMemoryAcceptProtocolGuid + [Guids] gConfidentialComputingSevSnpBlobGuid =20 diff --git a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/DxeSnpSystemRamValida= te.c b/OvmfPkg/Library/BaseMemEncryptSevLib/X64/DxeSnpSystemRamValidate.c index d3a95e4913..ee3710f7b3 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.0.rc1.362.ged0d419d3c-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 (#94681): https://edk2.groups.io/g/devel/message/94681 Mute This Topic: https://groups.io/mt/94098167/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 Thu May 9 12:31:21 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+94682+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+94682+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1664823244; cv=none; d=zohomail.com; s=zohoarc; b=acaQaauP0kiIA5TCKKMQXWsSikhNmmap1l3I4XnsKooRxtga3QtDUAmyHSvNvSdJ0e8EyFeEGNBiIkJ3AkTymweIbs3qU3ZwMRozhx0TMNBpt/+fAmEt+w/5i1SmNYjZYgCcL5YYmXYzE1Sah4jth1veE0h4VJXmxVJ96pHSsg0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664823244; h=Content-Type:Content-Transfer-Encoding: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=ZF99pjla47xR+NtG+CYLJJRTN30WiAzIIGBehaGiqcE=; b=kEQatlzlx2mELTGSc16vziI1X3E58sFnkobBbulfuTTa1MzgXU1a2K4ItEwHvAxYUwhAiMRLOf31zqDhoY7EI1YJgqRXOIK4cBULhNQRWJZvFqGqapWUSPAvFgr8TYy81Y4aTTBWPNX1rLeE40EhV/wp0iIGeAiR9AGJTC8RfB0= 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+94682+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1664823244636712.7761085493748; Mon, 3 Oct 2022 11:54:04 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 23Y7YY1788612xhUFWXQh4Uo; Mon, 03 Oct 2022 11:54:04 -0700 X-Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) by mx.groups.io with SMTP id smtpd.web12.1561.1664823243571460287 for ; Mon, 03 Oct 2022 11:54:03 -0700 X-Received: by mail-yb1-f202.google.com with SMTP id d8-20020a25bc48000000b00680651cf051so11094010ybk.23 for ; Mon, 03 Oct 2022 11:54:03 -0700 (PDT) X-Gm-Message-State: jGcmmDgLCNSxuK7mTpfP8P2Qx1787277AA= X-Google-Smtp-Source: AMsMyM7cXo1GTjzqGigueFlkVuO99fK8jbW8DWQP3/Pa9n7pY7K5IymMb5YwslLDxg4BZI3GgV+CnMwrG+AIMQ0f+A== X-Received: from dionnaglaze.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:2ee6]) (user=dionnaglaze job=sendgmr) by 2002:a25:bbcc:0:b0:6a8:e269:5eec with SMTP id c12-20020a25bbcc000000b006a8e2695eecmr22255868ybk.219.1664823242747; Mon, 03 Oct 2022 11:54:02 -0700 (PDT) Date: Mon, 3 Oct 2022 18:53:47 +0000 In-Reply-To: <20221003185352.3969999-1-dionnaglaze@google.com> Mime-Version: 1.0 References: <20221003185352.3969999-1-dionnaglaze@google.com> Message-ID: <20221003185352.3969999-3-dionnaglaze@google.com> Subject: [edk2-devel] [PATCH v6 2/7] MdeModulePkg: Introduce ExitBootServicesCallbackProtocol From: "Dionna Glaze via groups.io" To: devel@edk2.groups.io Cc: Dionna Glaze , Gerd Hoffmann , "Min M. Xu" , James Bottomley , Jiewen Yao , Tom Lendacky , Ard Biesheuvel , Andrew Fish , "Michael D. Kinney" 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 Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1664823244; bh=0uAoyWL4+4W02BtU5GdJigRVPqCDruNjFJqghtgXA9w=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=qsDzto+AsyzP29Mtjxmm8Q3fN2CoYnFKp7t7yEZgMukmfe40jkvfbWh4/cmzjk5DH55 GqijCJmFuFtjp69yvkUe466XgV7OJxZUYAQQpBFQVhiFGwjTp3rQWjIb1gP4Z6KKSI99I riTl1bP7z1mI18jf8rYcVkmJbEF62FxTWwo= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1664823246752100007 Content-Type: text/plain; charset="utf-8" This introduces a callback after the time that the timer is disabled and be= fore the MemoryMap is finalized. This callback is useful to make final changes to the memory map due to prot= ocols initiated (or not initiated) by the OS loader. Cc: Gerd Hoffmann Cc: "Min M. Xu" Cc: James Bottomley Cc: Jiewen Yao Cc: Tom Lendacky Cc: Ard Biesheuvel Cc: Andrew Fish Cc: "Michael D. Kinney" Signed-off-by: Dionna Glaze --- MdeModulePkg/Include/Protocol/ExitBootServicesCallback.h | 40 ++++++++++++= ++++++++ MdeModulePkg/MdeModulePkg.dec | 3 ++ 2 files changed, 43 insertions(+) diff --git a/MdeModulePkg/Include/Protocol/ExitBootServicesCallback.h b/Mde= ModulePkg/Include/Protocol/ExitBootServicesCallback.h new file mode 100644 index 0000000000..5c9f973b79 --- /dev/null +++ b/MdeModulePkg/Include/Protocol/ExitBootServicesCallback.h @@ -0,0 +1,40 @@ +/** @file + The file provides the protocol that allows callbacks in ExitBootServices + immediately before TerminateMemoryMap. + + Copyright (c) 2022, Google LLC. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent +**/ +#ifndef EXIT_BOOT_SERVICES_CALLBACK_H_ +#define EXIT_BOOT_SERVICES_CALLBACK_H_ + +/* This protocol is internal to EDK2 only */ + +#define EDKII_EXIT_BOOT_SERVICES_CALLBACK_PROTOCOL_GUID {0xf5684799, = 0x9a33, = 0x40f7, = {0xa1, 0x5c, 0x10, 0x8e, 0x0e, 0x6b, 0x45, 0x25}} + +typedef struct _EDKII_EXIT_BOOT_SERVICES_CALLBACK_PROTOCOL + EDKII_EXIT_BOOT_SERVICES_CALLBACK_PROTOCOL; + +/** + @param This A pointer to a EDKII_EXIT_BOOT_SERVICES_CALLBACK_PROTOCOL. + + The returned status may only be EFI_SUCCESS or EFI_INVALID_PARAMETER. +**/ +typedef +EFI_STATUS +(EFIAPI *EDKII_TERMINATE_MEMORY_MAP_PREHOOK)( + IN EDKII_EXIT_BOOT_SERVICES_CALLBACK_PROTOCOL *This + ); + +/// +/// The EDKII_EXIT_BOOT_SERVICES_CALLBACK_PROTOCOL allows callbacks in +/// ExitBootServices immediately before TerminateMemoryMap. +/// +struct _EDKII_EXIT_BOOT_SERVICES_CALLBACK_PROTOCOL { + EDKII_TERMINATE_MEMORY_MAP_PREHOOK TerminateMemoryMapPrehook; + BOOLEAN Disabled; +}; + +extern EFI_GUID gEdkiiExitBootServicesCallbackProtocolGuid; + +#endif diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index 58e6ab0048..add4e304ca 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -677,6 +677,9 @@ ## Include/Protocol/VariablePolicy.h gEdkiiVariablePolicyProtocolGuid =3D { 0x81D1675C, 0x86F6, 0x48DF, { 0xB= D, 0x95, 0x9A, 0x6E, 0x4F, 0x09, 0x25, 0xC3 } } =20 + ## Include/Protocol/ExitBootServicesCallback.h + gEdkiiExitBootServicesCallbackProtocolGuid =3D { 0xf5684799, 0x9a33, 0x4= 0f7, {0xa1, 0x5c, 0x10, 0x8e, 0x0e, 0x6b, 0x45, 0x25 }} + [PcdsFeatureFlag] ## Indicates if the platform can support update capsule across a system = reset.

# TRUE - Supports update capsule across a system reset.
--=20 2.38.0.rc1.362.ged0d419d3c-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 (#94682): https://edk2.groups.io/g/devel/message/94682 Mute This Topic: https://groups.io/mt/94098169/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 Thu May 9 12:31:21 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+94683+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+94683+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1664823247; cv=none; d=zohomail.com; s=zohoarc; b=ZJ3RmmAYuog2k2IxkG0fEUpbErgiv/vPxugzm/Al+hk+tWXGQLmefwHUt6SUw+D6O5cgaauQ4S6iloNZkGl0KIZ8J0quzJX/orYsdVoFTA3CozLJpp06wmwR0SvCEFw3qmAJLsDrAiKapjXVYj2cFWO0ESTUy5YXb3G8dX0E7XI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664823247; 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=vnz9PYjv5vUpEKKq+l43qqx2zfNzRlrE+QZCmJXESqk=; b=PuhdIcRGyFqbHBIUyXKSPfA7WA2f4Lgmg8JS2ibfVbftpMLLxZqo/0EYe85S1krSKtjJLakA46w3CPs3bY3tWmWaTCNnAUnnKLOTAtji7f8NFmH2quMwJJHQYKSuzzhBFIWUQXXHdplHrUirYq3qFPc6gRaqKR5lHbA30oypsg0= 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+94683+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 166482324744025.281612381005175; Mon, 3 Oct 2022 11:54:07 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id Wi3OYY1788612xR2A24uuzSv; Mon, 03 Oct 2022 11:54:06 -0700 X-Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) by mx.groups.io with SMTP id smtpd.web08.1482.1664823245330759376 for ; Mon, 03 Oct 2022 11:54:05 -0700 X-Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-3562f0fb5a7so93895027b3.1 for ; Mon, 03 Oct 2022 11:54:05 -0700 (PDT) X-Gm-Message-State: 30IZafTPAgmblO96ZgbCeVSpx1787277AA= X-Google-Smtp-Source: AMsMyM6VDlt1Fk1VDTbz3lpBc2wNMXVJSmq24I8W0FlWCAvFa4nDVjwMfkkzUZV3FvuaqMjrmndO+EZwaMV+xvKPYQ== X-Received: from dionnaglaze.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:2ee6]) (user=dionnaglaze job=sendgmr) by 2002:a25:3bcd:0:b0:6b3:bb2d:8497 with SMTP id i196-20020a253bcd000000b006b3bb2d8497mr21460102yba.598.1664823244418; Mon, 03 Oct 2022 11:54:04 -0700 (PDT) Date: Mon, 3 Oct 2022 18:53:48 +0000 In-Reply-To: <20221003185352.3969999-1-dionnaglaze@google.com> Mime-Version: 1.0 References: <20221003185352.3969999-1-dionnaglaze@google.com> Message-ID: <20221003185352.3969999-4-dionnaglaze@google.com> Subject: [edk2-devel] [PATCH v6 3/7] MdeModulePkg: Invoke all ExitBootServicesCallback instances at ExitBootServices 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 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=1664823246; bh=G2GkZiHJvjlkU/3jA/YXoJXPMvcaYJXJ9uHwYsik4Uk=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=EINxR5Zotm28lBTb8qnEVmn2jhjcvc8u3EgPCiQnePYHxtkI8ln9G8GvCnW+Zb4B1Dw zz8LxlNDufIwBQNypaTQl8J39nYcGMJz/m4Jj7umi4O5dXOD+9VaXDrFL07T+9fUSY6Zp YTb3YQQ3PPrkn487Qj7VTbYPpFzmWM0cW8w= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1664823248809100013 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The protocol's intent is to allow drivers to install callbacks that can modify the memory map at ExitBootServices time, so that any changes will lead to the EFI_INVALID_PARAMETER error. This error is specified to require the EBS caller to call GetMemoryMap again if it already had. 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 Signed-off-by: Dionna Glaze --- MdeModulePkg/Core/Dxe/DxeMain.h | 1 + MdeModulePkg/Core/Dxe/DxeMain.inf | 1 + MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c | 41 ++++++++++++++++++++ 3 files changed, 43 insertions(+) diff --git a/MdeModulePkg/Core/Dxe/DxeMain.h b/MdeModulePkg/Core/Dxe/DxeMai= n.h index 815a6b4bd8..185b9dc3d6 100644 --- a/MdeModulePkg/Core/Dxe/DxeMain.h +++ b/MdeModulePkg/Core/Dxe/DxeMain.h @@ -45,6 +45,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include #include +#include #include #include #include diff --git a/MdeModulePkg/Core/Dxe/DxeMain.inf b/MdeModulePkg/Core/Dxe/DxeM= ain.inf index e4bca89577..bdd9cf8222 100644 --- a/MdeModulePkg/Core/Dxe/DxeMain.inf +++ b/MdeModulePkg/Core/Dxe/DxeMain.inf @@ -153,6 +153,7 @@ gEfiHiiPackageListProtocolGuid ## SOMETIMES_PRODUCES gEfiSmmBase2ProtocolGuid ## SOMETIMES_CONSUMES gEdkiiPeCoffImageEmulatorProtocolGuid ## SOMETIMES_CONSUMES + gEdkiiExitBootServicesCallbackProtocolGuid ## CONSUMES =20 # Arch Protocols gEfiBdsArchProtocolGuid ## CONSUMES diff --git a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c b/MdeModulePkg/Core/Dx= e/DxeMain/DxeMain.c index 5733f0c8ec..3270f9858d 100644 --- a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c +++ b/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c @@ -744,6 +744,34 @@ CalculateEfiHdrCrc ( Hdr->CRC32 =3D Crc; } =20 +/** + Invokes TerminateMemoryMapPrehook from the first located instance of + EdkiiExitBootServicesProtocol. +**/ +STATIC +EFI_STATUS +InvokeTerminateMemoryMapPrehooks ( + VOID + ) +{ + EFI_STATUS Status; + EDKII_EXIT_BOOT_SERVICES_CALLBACK_PROTOCOL *Callback; + + Status =3D gBS->LocateHandle ( + &gEdkiiExitBootServicesCallbackProtocolGuid, + NULL, + (VOID**)Callback + ); + if (Status =3D=3D EFI_NOT_FOUND) { + return EFI_SUCCESS; + } + if (EFI_ERROR (Status)) { + return Status; + } + + return Callback->TerminateMemoryMapPrehook(Callback); +} + /** Terminates all boot services. =20 @@ -768,6 +796,19 @@ CoreExitBootServices ( // gTimer->SetTimerPeriod (gTimer, 0); =20 + // + // Invoke all protocols installed for ExitBootServices prior to + // CoreTerminateMemoryMap. + // + Status =3D InvokeTerminateMemoryMapPrehooks(); + if (EFI_ERROR (Status)) { + // + // Notify other drivers that ExitBootServices failed + // + CoreNotifySignalList (&gEventExitBootServicesFailedGuid); + return Status; + } + // // Terminate memory services if the MapKey matches // --=20 2.38.0.rc1.362.ged0d419d3c-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 (#94683): https://edk2.groups.io/g/devel/message/94683 Mute This Topic: https://groups.io/mt/94098170/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 Thu May 9 12:31:22 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+94684+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+94684+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1664823248; cv=none; d=zohomail.com; s=zohoarc; b=RcEJu40IqzGkj/tGWhjQO8jEwaSeCySFyLO9kxDYvLmOkjWb+Xf/U8+9dDmErJZAK8c05KOhuVL0oZAkC72O8u+jo3rfxd140wn2EqvbOfzbfRr51eqmFeO6FVKuhQjPS3snC7WF6UGTT4wnNEQANzHfh5EMf55x8OHl6X9qgik= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664823248; 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=gmWvdOru6WMKvZVt0H6BlmQudumiVGHg/rnMjsTzWGA=; b=ECX+FAZxr6hhwj+CP3I55I1Z4kUgzSqz0SsmF+g8tC7oU+wP5wk4qpHCMgr0BGiVXqFjTHitAGsNe8CZJci+QpF8uKyXFOvScZrip2YGvE8DI7e8L3IjNBLq3w9QrDceaDVLPASItes9CPNgkbAmgddwtzyf1vVUkfgiu/K06yg= 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+94684+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1664823248941752.9273542970727; Mon, 3 Oct 2022 11:54:08 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id FjyFYY1788612xd4oEbVr3OT; Mon, 03 Oct 2022 11:54:07 -0700 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.web10.1457.1664823246815585133 for ; Mon, 03 Oct 2022 11:54:06 -0700 X-Received: by mail-pj1-f73.google.com with SMTP id v6-20020a17090a898600b0020a6fa41b32so5052621pjn.5 for ; Mon, 03 Oct 2022 11:54:06 -0700 (PDT) X-Gm-Message-State: BvgW3o7pwVlM8se6Dsss5xsQx1787277AA= X-Google-Smtp-Source: AMsMyM729hcFeVHuk+qlHcCrz5/eh2lNxXCix1vFYV+lcqJep9qbFIrJFlVI7+NhqzBvOE7yYiYDLCl0dtgSPsDhvA== X-Received: from dionnaglaze.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:2ee6]) (user=dionnaglaze job=sendgmr) by 2002:a17:902:7888:b0:17f:637b:953f with SMTP id q8-20020a170902788800b0017f637b953fmr4303175pll.171.1664823246269; Mon, 03 Oct 2022 11:54:06 -0700 (PDT) Date: Mon, 3 Oct 2022 18:53:49 +0000 In-Reply-To: <20221003185352.3969999-1-dionnaglaze@google.com> Mime-Version: 1.0 References: <20221003185352.3969999-1-dionnaglaze@google.com> Message-ID: <20221003185352.3969999-5-dionnaglaze@google.com> Subject: [edk2-devel] [PATCH v6 4/7] OvmfPkg: Introduce CocoDxe driver 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" 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=1664823247; bh=4a5/LCSytpKtdOJqB4Z15INJiePZFK5cUpZWu7nBZw4=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=VUavqzIFFdKNkktaW78Za+zvAwX5qMEvcVFOQEogqzoL2yTFDccgZhzR6RcNjMqP7MF UsW/tFc+gcy2alOCsjK2EKERj2WxJnd+u55eRCqoAjNC7fuIInCCYbYz7Zn/65IroPQQZ +WkxJyWHMvhtBdxoDesW7xzhMBAO1OrZjvg= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1664823250871100018 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This driver is meant as a join point for all Confidential Compute technologies to put shared behavior that doesn't belong anywhere else. The first behavior added here is to accept all unaccepted memory at ExitBootServices if the protocol is not disabled. This allows safe upgrades for OS loaders to affirm their support for the unaccepted memory type. 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" Signed-off-by: Dionna Glaze --- OvmfPkg/AmdSev/AmdSevX64.dsc | 1 + OvmfPkg/AmdSev/AmdSevX64.fdf | 1 + OvmfPkg/CocoDxe/CocoDxe.c | 144 ++++++++++++++++++++ OvmfPkg/CocoDxe/CocoDxe.inf | 43 ++++++ OvmfPkg/IntelTdx/IntelTdxX64.dsc | 1 + OvmfPkg/IntelTdx/IntelTdxX64.fdf | 1 + OvmfPkg/OvmfPkgIa32X64.dsc | 1 + OvmfPkg/OvmfPkgIa32X64.fdf | 1 + OvmfPkg/OvmfPkgX64.dsc | 1 + OvmfPkg/OvmfPkgX64.fdf | 1 + 10 files changed, 195 insertions(+) diff --git a/OvmfPkg/AmdSev/AmdSevX64.dsc b/OvmfPkg/AmdSev/AmdSevX64.dsc index 90e8a213ef..ad6b73ca4a 100644 --- a/OvmfPkg/AmdSev/AmdSevX64.dsc +++ b/OvmfPkg/AmdSev/AmdSevX64.dsc @@ -747,6 +747,7 @@ PciLib|MdePkg/Library/BasePciLibCf8/BasePciLibCf8.inf } + OvmfPkg/CocoDxe/CocoDxe.inf OvmfPkg/IoMmuDxe/IoMmuDxe.inf =20 # diff --git a/OvmfPkg/AmdSev/AmdSevX64.fdf b/OvmfPkg/AmdSev/AmdSevX64.fdf index 4658e1d30e..3717ec9094 100644 --- a/OvmfPkg/AmdSev/AmdSevX64.fdf +++ b/OvmfPkg/AmdSev/AmdSevX64.fdf @@ -302,6 +302,7 @@ INF OvmfPkg/QemuRamfbDxe/QemuRamfbDxe.inf INF OvmfPkg/VirtioGpuDxe/VirtioGpu.inf INF OvmfPkg/PlatformDxe/Platform.inf INF OvmfPkg/AmdSevDxe/AmdSevDxe.inf +INF OvmfPkg/CocoDxe/CocoDxe.inf INF OvmfPkg/IoMmuDxe/IoMmuDxe.inf =20 =20 diff --git a/OvmfPkg/CocoDxe/CocoDxe.c b/OvmfPkg/CocoDxe/CocoDxe.c new file mode 100644 index 0000000000..9e9a405af1 --- /dev/null +++ b/OvmfPkg/CocoDxe/CocoDxe.c @@ -0,0 +1,144 @@ +/** @file + + Confidential Compute Dxe driver. This driver installs protocols that are + generic over confidential compute techonology. + + Copyright (c) 2022, Google LLC. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +STATIC EFI_HANDLE mCocoDxeHandle =3D NULL; + +STATIC +EFI_STATUS +AcceptAllUnacceptedMemory ( + IN EFI_MEMORY_ACCEPT_PROTOCOL *AcceptMemory + ) +{ + EFI_GCD_MEMORY_SPACE_DESCRIPTOR *AllDescMap; + UINTN NumEntries; + UINTN Index; + EFI_STATUS Status; + BOOLEAN AcceptedAny; + + DEBUG ((DEBUG_INFO, "Accepting all memory\n")); + AcceptedAny =3D FALSE; + Status =3D EFI_SUCCESS; + /* + * Get a copy of the memory space map to iterate over while + * changing the map. + */ + Status =3D gDS->GetMemorySpaceMap (&NumEntries, &AllDescMap); + if (EFI_ERROR (Status)) { + return Status; + } + for (Index =3D 0; Index < NumEntries; Index++) { + CONST EFI_GCD_MEMORY_SPACE_DESCRIPTOR *Desc; + + Desc =3D &AllDescMap[Index]; + if (Desc->GcdMemoryType !=3D EfiGcdMemoryTypeUnaccepted) { + continue; + } + + Status =3D AcceptMemory->AcceptMemory ( + AcceptMemory, + Desc->BaseAddress, + Desc->Length + ); + ASSERT_EFI_ERROR (Status); + + Status =3D gDS->RemoveMemorySpace(Desc->BaseAddress, Desc->Length); + ASSERT_EFI_ERROR (Status); + + Status =3D gDS->AddMemorySpace ( + EfiGcdMemoryTypeSystemMemory, + Desc->BaseAddress, + Desc->Length, + EFI_MEMORY_CPU_CRYPTO | EFI_MEMORY_XP | EFI_MEMORY_RO | EFI_MEMORY_RP + ); + ASSERT_EFI_ERROR (Status); + + AcceptedAny =3D TRUE; + } + + // If any memory is accepted, cause ExitBootServices to fail with + // EFI_INVALID_PARAMETER in order to force the caller to refresh + // their view of the MemoryMap. + if (AcceptedAny) { + Status =3D EFI_INVALID_PARAMETER; + } + +done: + gBS->FreePool (AllDescMap); + return Status; +} + +EFI_STATUS +EFIAPI +ResolveUnacceptedMemory ( + IN EDKII_EXIT_BOOT_SERVICES_CALLBACK_PROTOCOL *This + ) +{ + EFI_MEMORY_ACCEPT_PROTOCOL *AcceptMemory; + EFI_STATUS Status; + + if (This->Disabled) { + return EFI_SUCCESS; + } + + Status =3D gBS->LocateProtocol (&gEfiMemoryAcceptProtocolGuid, NULL, + (VOID **)&AcceptMemory); + if (Status =3D=3D EFI_NOT_FOUND) { + return EFI_SUCCESS; + } + ASSERT_EFI_ERROR (Status); + + return AcceptAllUnacceptedMemory(AcceptMemory); +} + +STATIC EDKII_EXIT_BOOT_SERVICES_CALLBACK_PROTOCOL mExitBootServicesCallbac= kProcotol =3D { + ResolveUnacceptedMemory, + FALSE, +}; + +EFI_STATUS +EFIAPI +CocoDxeEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + // + // Do nothing when confidential compute technologies that require memory + // acceptance are not enabled. + // + if (!MemEncryptSevSnpIsEnabled () && + !MemEncryptTdxIsEnabled ()) { + return EFI_UNSUPPORTED; + } + + Status =3D gBS->InstallProtocolInterface (&mCocoDxeHandle, + &gEdkiiExitBootServicesCallbackProtocolGuid, + EFI_NATIVE_INTERFACE, + &mExitBootServicesCallbackProcotol + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Install EdkiiExitBootServicesCallbackProtocol fa= iled.\n")); + } + + return EFI_SUCCESS; +} diff --git a/OvmfPkg/CocoDxe/CocoDxe.inf b/OvmfPkg/CocoDxe/CocoDxe.inf new file mode 100644 index 0000000000..3ff2a6fade --- /dev/null +++ b/OvmfPkg/CocoDxe/CocoDxe.inf @@ -0,0 +1,43 @@ +#/** @file +# +# Driver installs shared protocols needed for confidential compute +# technologies. +# +# Copyright (c) 2022, Google LLC. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +#**/ + +[Defines] + INF_VERSION =3D 1.25 + BASE_NAME =3D CocoDxe + FILE_GUID =3D 08162f1e-5147-4d3e-b5a9-fa48c9808419 + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + ENTRY_POINT =3D CocoDxeEntryPoint + +[Sources] + CocoDxe.c + +[Packages] + MdeModulePkg/MdeModulePkg.dec + MdePkg/MdePkg.dec + OvmfPkg/OvmfPkg.dec + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + DxeServicesTableLib + MemEncryptSevLib + MemEncryptTdxLib + MemoryAllocationLib + UefiDriverEntryPoint + +[Depex] + TRUE + +[Protocols] + gEdkiiExitBootServicesCallbackProtocolGuid + gEfiMemoryAcceptProtocolGuid diff --git a/OvmfPkg/IntelTdx/IntelTdxX64.dsc b/OvmfPkg/IntelTdx/IntelTdxX6= 4.dsc index c0c1a15b09..8136d50eb2 100644 --- a/OvmfPkg/IntelTdx/IntelTdxX64.dsc +++ b/OvmfPkg/IntelTdx/IntelTdxX64.dsc @@ -753,6 +753,7 @@ OvmfPkg/IoMmuDxe/IoMmuDxe.inf =20 OvmfPkg/TdxDxe/TdxDxe.inf + OvmfPkg/CocoDxe/CocoDxe.inf =20 # # Variable driver stack (non-SMM) diff --git a/OvmfPkg/IntelTdx/IntelTdxX64.fdf b/OvmfPkg/IntelTdx/IntelTdxX6= 4.fdf index 6923eb8831..e612608c0c 100644 --- a/OvmfPkg/IntelTdx/IntelTdxX64.fdf +++ b/OvmfPkg/IntelTdx/IntelTdxX64.fdf @@ -269,6 +269,7 @@ INF ShellPkg/Application/Shell/Shell.inf INF MdeModulePkg/Logo/LogoDxe.inf =20 INF OvmfPkg/TdxDxe/TdxDxe.inf +INF OvmfPkg/CocoDxe/CocoDxe.inf =20 # # Usb Support diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc index af566b953f..2cfb3fbc6b 100644 --- a/OvmfPkg/OvmfPkgIa32X64.dsc +++ b/OvmfPkg/OvmfPkgIa32X64.dsc @@ -965,6 +965,7 @@ PciLib|MdePkg/Library/BasePciLibCf8/BasePciLibCf8.inf } + OvmfPkg/CocoDxe/CocoDxe.inf OvmfPkg/IoMmuDxe/IoMmuDxe.inf =20 !if $(SMM_REQUIRE) =3D=3D TRUE diff --git a/OvmfPkg/OvmfPkgIa32X64.fdf b/OvmfPkg/OvmfPkgIa32X64.fdf index 80de4fa2c0..2ab7f3b95b 100644 --- a/OvmfPkg/OvmfPkgIa32X64.fdf +++ b/OvmfPkg/OvmfPkgIa32X64.fdf @@ -343,6 +343,7 @@ INF OvmfPkg/QemuRamfbDxe/QemuRamfbDxe.inf INF OvmfPkg/VirtioGpuDxe/VirtioGpu.inf INF OvmfPkg/PlatformDxe/Platform.inf INF OvmfPkg/AmdSevDxe/AmdSevDxe.inf +INF OvmfPkg/CocoDxe/CocoDxe.inf INF OvmfPkg/IoMmuDxe/IoMmuDxe.inf =20 !if $(SMM_REQUIRE) =3D=3D TRUE diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc index f39d9cd117..3ead476b61 100644 --- a/OvmfPkg/OvmfPkgX64.dsc +++ b/OvmfPkg/OvmfPkgX64.dsc @@ -1036,6 +1036,7 @@ OvmfPkg/IoMmuDxe/IoMmuDxe.inf =20 OvmfPkg/TdxDxe/TdxDxe.inf + OvmfPkg/CocoDxe/CocoDxe.inf =20 !if $(SMM_REQUIRE) =3D=3D TRUE OvmfPkg/SmmAccess/SmmAccess2Dxe.inf diff --git a/OvmfPkg/OvmfPkgX64.fdf b/OvmfPkg/OvmfPkgX64.fdf index c0f5a1ef3c..5dd452f42b 100644 --- a/OvmfPkg/OvmfPkgX64.fdf +++ b/OvmfPkg/OvmfPkgX64.fdf @@ -370,6 +370,7 @@ INF OvmfPkg/QemuRamfbDxe/QemuRamfbDxe.inf INF OvmfPkg/VirtioGpuDxe/VirtioGpu.inf INF OvmfPkg/PlatformDxe/Platform.inf INF OvmfPkg/AmdSevDxe/AmdSevDxe.inf +INF OvmfPkg/CocoDxe/CocoDxe.inf INF OvmfPkg/IoMmuDxe/IoMmuDxe.inf =20 !if $(SMM_REQUIRE) =3D=3D TRUE --=20 2.38.0.rc1.362.ged0d419d3c-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 (#94684): https://edk2.groups.io/g/devel/message/94684 Mute This Topic: https://groups.io/mt/94098172/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 Thu May 9 12:31:22 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+94685+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+94685+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1664823250; cv=none; d=zohomail.com; s=zohoarc; b=dwpDtbk4ads+0P1KrAD6Si1HMkNvVJogMxMoyAilSrrtmcMdOLKocy2RSYQn0i7yvhJsWLFJ/PkHWCl/B375Mh2R5HpzTMsH/Svz/CKGWfZj5mdgcr5Des7+Z42sS9lNJPs5oU2WQxYnnccgM42lHMtSZweaa549AIlOvloEgTQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664823250; 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=HyMYKNU75zjQaigRiB6wkCZapmCf8NxfKxmWlXICz8U=; b=CSPjhS8dNrRUJFgnRlJoeC2wkO0oD3ArHWOv1RW6lQc38sbK2g6v7rhAT4RyEtVJudtw/NfBg2snaU9eUfMVpueazeCnxRRvKFofqRxkcr0PkEcpKvVz7qPyjoDdzUzKCMmdabBsjjASyYDofWWO7lOCyHUvjM+HP6Tj+txsBFo= 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+94685+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 16648232506061016.4078499191386; Mon, 3 Oct 2022 11:54:10 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 69xuYY1788612xO0NtfCZzSd; Mon, 03 Oct 2022 11:54:09 -0700 X-Received: from mail-pg1-f201.google.com (mail-pg1-f201.google.com [209.85.215.201]) by mx.groups.io with SMTP id smtpd.web10.1458.1664823248375447311 for ; Mon, 03 Oct 2022 11:54:08 -0700 X-Received: by mail-pg1-f201.google.com with SMTP id r126-20020a632b84000000b004393806c06eso7450067pgr.4 for ; Mon, 03 Oct 2022 11:54:08 -0700 (PDT) X-Gm-Message-State: mz1a7o3WeYwh0oDcMRJEv3tix1787277AA= X-Google-Smtp-Source: AMsMyM4/NofS+psLkaVWuXgQrz7vZfcRiYrcDj5WeLdpEcCBrPBZeKPVp43rG3IXX4lNQLlcVcH3zFOLl1vTFrThdg== X-Received: from dionnaglaze.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:2ee6]) (user=dionnaglaze job=sendgmr) by 2002:a17:90b:1c12:b0:200:b623:455d with SMTP id oc18-20020a17090b1c1200b00200b623455dmr13384081pjb.88.1664823247821; Mon, 03 Oct 2022 11:54:07 -0700 (PDT) Date: Mon, 3 Oct 2022 18:53:50 +0000 In-Reply-To: <20221003185352.3969999-1-dionnaglaze@google.com> Mime-Version: 1.0 References: <20221003185352.3969999-1-dionnaglaze@google.com> Message-ID: <20221003185352.3969999-6-dionnaglaze@google.com> Subject: [edk2-devel] [PATCH v6 5/7] MdePkg: Introduce the AcceptAllUnacceptedMemory protocol 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" 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=1664823249; bh=Q2jDAPn0YDDGMr8gJ0VwN7iZnkeCb0R2U7Va1psBllw=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=IBgAk2UyyViENr0uaFLC59FI2JXZfauXj6GL89JLpRMOxRcbydEPPe8URlp9JWuFSkB SSeODY0uQs5Z/k1+42P2YFpEhSoNZXpx7QDPZxcAHreWlLYme5YS056vSw53gtDfNf1ch nnbhzC9lb1BAqeD16VWUVSiFw52YsDXg3B8= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1664823250833100017 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The default behavior for unaccepted memory is to accept all memory when ExitBootServices is called. An OS loader can use this protocol to Disable this behavior to assume responsibility for memory acceptance and to affirm that the OS can handle the unaccepted memory type. This is a candidate for standardization. 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" Signed-off-by: Dionna Glaze --- MdePkg/Include/Protocol/Bz3987AcceptAllUnacceptedMemory.h | 40 +++++++++++= +++++++++ MdePkg/MdePkg.dec | 3 ++ 2 files changed, 43 insertions(+) diff --git a/MdePkg/Include/Protocol/Bz3987AcceptAllUnacceptedMemory.h b/Md= ePkg/Include/Protocol/Bz3987AcceptAllUnacceptedMemory.h new file mode 100644 index 0000000000..e50831836c --- /dev/null +++ b/MdePkg/Include/Protocol/Bz3987AcceptAllUnacceptedMemory.h @@ -0,0 +1,40 @@ +/** @file + The file provides the protocol that disables the behavior that all memory + gets accepted at ExitBootServices(). This protocol is only meant to be c= alled + by the OS loader, and not EDK2 itself. + + Copyright (c) 2022, Google LLC. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent +**/ +#ifndef _ACCEPT_ALL_UNACCEPTED_MEMORY_H_ +#define _ACCEPT_ALL_UNACCEPTED_MEMORY_H_ + +#define BZ3987_ACCEPT_ALL_UNACCEPTED_MEMORY_PROTOCOL_GUID \ + {0xc5a010fe, \ + 0x38a7, \ + 0x4531, \ + {0x8a, 0x4a, 0x05, 0x00, 0xd2, 0xfd, 0x16, 0x49}} + +typedef struct _BZ3987_ACCEPT_ALL_UNACCEPTED_MEMORY_PROTOCOL + BZ3987_ACCEPT_ALL_UNACCEPTED_MEMORY_PROTOCOL; + +/** + @param This A pointer to a BZ3987_ACCEPT_ALL_UNACCEPTED_MEMORY_PROTOCOL. +**/ +typedef +EFI_STATUS +(EFIAPI *BZ3987_DISABLE_ACCEPT_ALL_UNACCEPTED_MEMORY)( + IN BZ3987_ACCEPT_ALL_UNACCEPTED_MEMORY_PROTOCOL *This + ); + +/// +/// The BZ3987_ACCEPT_ALL_UNACCEPTED_MEMORY_PROTOCOL allows the OS loader = to +/// indicate to EDK2 that ExitBootServices should not accept all memory. +/// +struct _BZ3987_ACCEPT_ALL_UNACCEPTED_MEMORY_PROTOCOL { + BZ3987_DISABLE_ACCEPT_ALL_UNACCEPTED_MEMORY Disable; +}; + +extern EFI_GUID gBz3987AcceptAllUnacceptedMemoryProtocolGuid; + +#endif diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec index de3c56758b..b6b108586e 100644 --- a/MdePkg/MdePkg.dec +++ b/MdePkg/MdePkg.dec @@ -1019,6 +1019,9 @@ gEfiPeiDelayedDispatchPpiGuid =3D { 0x869c711d, 0x649c, 0x44fe, { 0x8b,= 0x9e, 0x2c, 0xbb, 0x29, 0x11, 0xc3, 0xe6 }} =20 [Protocols] + ## Include/Protocol/Bz3987AcceptAllUnacceptedMemory.h + gBz3987AcceptAllUnacceptedMemoryProtocolGuid =3D { 0xc5a010fe, 0x38a7, 0= x4531, {0x8a, 0x4a, 0x05, 0x00, 0xd2, 0xfd, 0x16, 0x49 }} + ## Include/Protocol/MemoryAccept.h gEfiMemoryAcceptProtocolGuid =3D { 0x38c74800, 0x5590, 0x4db4, { 0xa0,= 0xf3, 0x67, 0x5d, 0x9b, 0x8e, 0x80, 0x26 }} =20 --=20 2.38.0.rc1.362.ged0d419d3c-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 (#94685): https://edk2.groups.io/g/devel/message/94685 Mute This Topic: https://groups.io/mt/94098173/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 Thu May 9 12:31:22 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+94686+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+94686+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1664823250; cv=none; d=zohomail.com; s=zohoarc; b=VkWOxPnPbTYajw1+PZqLrM78B0VzP6064jnQ2A8A8El/27TqpqVJGt3lrNc+a8BvGXV8rP3E96aDDf2Mr7x5QHnvuxvSTtFoaSelcThMhgt90iR3jj/o7xxxeUV4sEhNC9nClPI+XLvyHGpUezA6XZYSndvmmn14LQrKvb7SQL4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664823250; 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=5BD1HFDE+nGxSp3YaItbQ1XyF9UXdnGEHPbvydiv/vY=; b=UnLuT41QSfxJBMpy6pkB7u/wl3qjsfUSzGqdBKSxtpkJk7up8J1Rmop629Ilz2NcXC115qjlOYPcpzAvnsouCTvPFQIghprGDoBnEDTyowGsXV6JpA0lYOCJLjZ808+9zPChVRxjqgZtDTSsfwry2HTrW1QNp0ctzBSCAJUgl7E= 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+94686+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1664823250942943.8340306032491; Mon, 3 Oct 2022 11:54:10 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id x1v7YY1788612xI6uk4rZ4hL; Mon, 03 Oct 2022 11:54:10 -0700 X-Received: from mail-pl1-f201.google.com (mail-pl1-f201.google.com [209.85.214.201]) by mx.groups.io with SMTP id smtpd.web09.1512.1664823249905982015 for ; Mon, 03 Oct 2022 11:54:10 -0700 X-Received: by mail-pl1-f201.google.com with SMTP id a5-20020a170902ecc500b0017eea4a394fso3094941plh.20 for ; Mon, 03 Oct 2022 11:54:09 -0700 (PDT) X-Gm-Message-State: 7cAJnSBmUE5zEDgIt84tLhWVx1787277AA= X-Google-Smtp-Source: AMsMyM7GWJv+6owLZyB87neXlUhuu7BeUN/RPG8Z2qz1mfHUvT1sd7i+YOYj+Z3FDd/XNUnZgEMb3sdAAZU4RiFeDg== X-Received: from dionnaglaze.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:2ee6]) (user=dionnaglaze job=sendgmr) by 2002:a17:90a:aa96:b0:205:bb67:a85f with SMTP id l22-20020a17090aaa9600b00205bb67a85fmr13365383pjq.202.1664823249388; Mon, 03 Oct 2022 11:54:09 -0700 (PDT) Date: Mon, 3 Oct 2022 18:53:51 +0000 In-Reply-To: <20221003185352.3969999-1-dionnaglaze@google.com> Mime-Version: 1.0 References: <20221003185352.3969999-1-dionnaglaze@google.com> Message-ID: <20221003185352.3969999-7-dionnaglaze@google.com> Subject: [edk2-devel] [PATCH v6 6/7] OvmfPkg: Implement AcceptAllUnacceptedMemory in CocoDxe 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" 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=1664823250; bh=1qFr/edhNOIbJmLlf0/Y4v8h/0DqErju8NmsQdSOmSE=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=IqrePddrBI+973SeOFerfP3RDyynshnnvqI2ZL09vwWcunM/cc1Br2jMsvs4dmuXJLc 8ZmCriMOUBnH3nG0Md4HvhpRtfKSpgraH5nUG1IEL7B+s1Y9IvF30OyRc/8SM+R4Afvfz Siwh/h0TR29+XgKwAju5sPsARmywOMEkwn8= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1664823252805100021 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This protocol implementation disables the accept-all-memory behavior of the ExitBootServicesCallback instance thise driver adds. 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" Signed-off-by: Dionna Glaze --- OvmfPkg/CocoDxe/CocoDxe.c | 25 ++++++++++++++++++++ OvmfPkg/CocoDxe/CocoDxe.inf | 1 + 2 files changed, 26 insertions(+) diff --git a/OvmfPkg/CocoDxe/CocoDxe.c b/OvmfPkg/CocoDxe/CocoDxe.c index 9e9a405af1..abf2d2b055 100644 --- a/OvmfPkg/CocoDxe/CocoDxe.c +++ b/OvmfPkg/CocoDxe/CocoDxe.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include =20 @@ -113,6 +114,21 @@ STATIC EDKII_EXIT_BOOT_SERVICES_CALLBACK_PROTOCOL mExi= tBootServicesCallbackProco FALSE, }; =20 +STATIC +EFI_STATUS +EFIAPI +DisableAcceptAllUnacceptedMemory ( + IN BZ3987_ACCEPT_ALL_UNACCEPTED_MEMORY_PROTOCOL *This + ) +{ + mExitBootServicesCallbackProcotol.Disabled =3D TRUE; + return EFI_SUCCESS; +} + +STATIC +BZ3987_ACCEPT_ALL_UNACCEPTED_MEMORY_PROTOCOL +mAcceptAllUnacceptedMemoryProtocol =3D {DisableAcceptAllUnacceptedMemory}; + EFI_STATUS EFIAPI CocoDxeEntryPoint ( @@ -140,5 +156,14 @@ CocoDxeEntryPoint ( DEBUG ((DEBUG_ERROR, "Install EdkiiExitBootServicesCallbackProtocol fa= iled.\n")); } =20 + Status =3D gBS->InstallProtocolInterface (&mCocoDxeHandle, + &gBz3987AcceptAllUnacceptedMemoryProtocolGuid, + EFI_NATIVE_INTERFACE, + &mAcceptAllUnacceptedMemoryProtocol + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Install Bz3987AcceptAllUnacceptedMemoryProtocol = failed.\n")); + } + return EFI_SUCCESS; } diff --git a/OvmfPkg/CocoDxe/CocoDxe.inf b/OvmfPkg/CocoDxe/CocoDxe.inf index 3ff2a6fade..96ab3e1c68 100644 --- a/OvmfPkg/CocoDxe/CocoDxe.inf +++ b/OvmfPkg/CocoDxe/CocoDxe.inf @@ -39,5 +39,6 @@ TRUE =20 [Protocols] + gBz3987AcceptAllUnacceptedMemoryProtocolGuid gEdkiiExitBootServicesCallbackProtocolGuid gEfiMemoryAcceptProtocolGuid --=20 2.38.0.rc1.362.ged0d419d3c-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 (#94686): https://edk2.groups.io/g/devel/message/94686 Mute This Topic: https://groups.io/mt/94098176/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 Thu May 9 12:31:22 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+94687+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+94687+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1664823253; cv=none; d=zohomail.com; s=zohoarc; b=SFWO6Db9Depq+Am4ARXaFfaAzR2R+KQGyeS+1iJ26eFdsnRdtSnRl5dZ8NRkvsFND7nl8cnrb2EcSuuNVvX7z8EWdV0q1f5AyCz0YOZKaWPZunsdStpPz6rLRwyw74YqsWdKpQIpWGU3CpKZSgs7UGVrRP1VxjNjdmjr7Qnzox8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664823253; 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=fYXHmx0OqlMzzAciEGPCv4/r1Cb0l4DfND0shyvpnPU=; b=I1UCW+hjo7Q/kyAquEEbWlvamCQBcIS6lz/jaKaH23/HK3OVVKXX7INLBA1GWi6VP2mEx7BNF97xajKaYnraqkKJHMDQXcguuRJwVIV4AxYbVI/yQWheNsl/mTsJc9qsaNMkuNmBB6JJLJek8uUhqYmqjX6gWaLMgknNdBaB8AE= 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+94687+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1664823253512647.8633197695128; Mon, 3 Oct 2022 11:54:13 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 9ugAYY1788612xCfDPPEbpxy; Mon, 03 Oct 2022 11:54:12 -0700 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.1459.1664823251590268754 for ; Mon, 03 Oct 2022 11:54:11 -0700 X-Received: by mail-pj1-f74.google.com with SMTP id v5-20020a17090abb8500b0020a76ded27eso4546553pjr.3 for ; Mon, 03 Oct 2022 11:54:11 -0700 (PDT) X-Gm-Message-State: rbwNaA1sFhqyP5ty4vE9GPcjx1787277AA= X-Google-Smtp-Source: AMsMyM7oiScnd6k1b1T2fAt2n5+7dilJMjJTabDA48lKy0gTbv/RnglBa5WU+uDI52tbS9V9MlTjuNZ/FrGUR0SAlQ== X-Received: from dionnaglaze.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:2ee6]) (user=dionnaglaze job=sendgmr) by 2002:a17:90b:350b:b0:202:8495:6275 with SMTP id ls11-20020a17090b350b00b0020284956275mr13779254pjb.216.1664823250931; Mon, 03 Oct 2022 11:54:10 -0700 (PDT) Date: Mon, 3 Oct 2022 18:53:52 +0000 In-Reply-To: <20221003185352.3969999-1-dionnaglaze@google.com> Mime-Version: 1.0 References: <20221003185352.3969999-1-dionnaglaze@google.com> Message-ID: <20221003185352.3969999-8-dionnaglaze@google.com> Subject: [edk2-devel] [PATCH v6 7/7] OvmfPkg/PlatformPei: SEV-SNP make >=4GB unaccepted 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=1664823252; bh=mUVkTPUqRy5JU1ZhiXxJxYnz/kNnoT/o7VOPULec6+8=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=nktUCdI4pW8B5UQLBTUoXOCz2Wg80NEIjRu0aKvrGnIOQ7Cmfwe2p9cMbc5BIJLFQN5 htY52OrbzSERHBc00MNYTw+SOYTGRpVKItboJxdrR7YWcs+s53fQDTuDCKRLN943UGeSk xxcPI4kSFWhSEFrHUiKWRQwAeMsheXXKpOo= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1664823254822100029 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Instead of eagerly accepting all memory in PEI, only accept memory under the 4GB address. This allows a loaded image to use the ACCEPT_ALL_UNACCEPTED_MEMORY_PROTOCOL to disable the accept behavior and indicate that it can interpret the memory type accordingly. This classification is safe since ExitBootServices will accept and reclassify the memory as conventional if the disable protocol is not used. 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 --- OvmfPkg/PlatformPei/AmdSev.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/OvmfPkg/PlatformPei/AmdSev.c b/OvmfPkg/PlatformPei/AmdSev.c index 385562b44c..2a52d6f491 100644 --- a/OvmfPkg/PlatformPei/AmdSev.c +++ b/OvmfPkg/PlatformPei/AmdSev.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -63,6 +64,10 @@ AmdSevSnpInitialize ( for (Hob.Raw =3D GetHobList (); !END_OF_HOB_LIST (Hob); Hob.Raw =3D GET_= NEXT_HOB (Hob)) { if ((Hob.Raw !=3D NULL) && (GET_HOB_TYPE (Hob) =3D=3D EFI_HOB_TYPE_RES= OURCE_DESCRIPTOR)) { ResourceHob =3D Hob.ResourceDescriptor; + if (ResourceHob->PhysicalStart >=3D SIZE_4GB) { + ResourceHob->ResourceType =3D EFI_RESOURCE_MEMORY_UNACCEPTED; + continue; + } =20 if (ResourceHob->ResourceType =3D=3D EFI_RESOURCE_SYSTEM_MEMORY) { MemEncryptSevSnpPreValidateSystemRam ( --=20 2.38.0.rc1.362.ged0d419d3c-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 (#94687): https://edk2.groups.io/g/devel/message/94687 Mute This Topic: https://groups.io/mt/94098177/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-