BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3275
The OvmfPkgX86 build reserves memory regions in MEMFD. The memory regions get accessed in the SEC phase. Both Intel TDX and AMD SEV-SNP require that the guest's private memory be accepted or validated before access. Introduce a Guided metadata structure that describes the reserved memory regions. The VMM can locate the metadata structure by iterating through the reset vector guid and process the areas based on the platform specific requirements. Min Xu introduced the metadata structure conceptin the TDX patch series [1]. [1] https://www.mail-archive.com/devel@edk2.groups.io/msg33605.html Cc: Michael Roth <michael.r...@amd.com> Cc: James Bottomley <j...@linux.ibm.com> Cc: Min Xu <min.m...@intel.com> Cc: Jiewen Yao <jiewen....@intel.com> Cc: Tom Lendacky <thomas.lenda...@amd.com> Cc: Jordan Justen <jordan.l.jus...@intel.com> Cc: Ard Biesheuvel <ardb+tianoc...@kernel.org> Cc: Erdem Aktas <erdemak...@google.com> Cc: Gerd Hoffmann <kra...@redhat.com> Suggested-by: Gerd Hoffmann <kra...@redhat.com> Signed-off-by: Brijesh Singh <brijesh.si...@amd.com> --- OvmfPkg/ResetVector/Ia16/ResetVectorVtf0.asm | 17 ++++++++ OvmfPkg/ResetVector/ResetVector.nasmb | 1 + OvmfPkg/ResetVector/X64/OvmfMetadata.asm | 45 ++++++++++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 OvmfPkg/ResetVector/X64/OvmfMetadata.asm diff --git a/OvmfPkg/ResetVector/Ia16/ResetVectorVtf0.asm b/OvmfPkg/ResetVector/Ia16/ResetVectorVtf0.asm index 7ec3c6e980c3..f0e509d0672e 100644 --- a/OvmfPkg/ResetVector/Ia16/ResetVectorVtf0.asm +++ b/OvmfPkg/ResetVector/Ia16/ResetVectorVtf0.asm @@ -47,6 +47,23 @@ TIMES (15 - ((guidedStructureEnd - guidedStructureStart + 15) % 16)) DB 0 ; guidedStructureStart: +%ifdef ARCH_X64 +; +; OVMF metadata descriptor for the TDX and SEV-SNP +; +; Provide the start offset of the metadata blob within the OVMF binary. + +; GUID : e47a6535-984a-4798-865e-4685a7bf8ec2 +; +OvmfMetadataOffsetStart: + DD (fourGigabytes - OvmfMetadataGuid - 16) + DW OvmfMetadataOffsetEnd - OvmfMetadataOffsetStart + DB 0x35, 0x65, 0x7a, 0xe4, 0x4a, 0x98, 0x98, 0x47 + DB 0x86, 0x5e, 0x46, 0x85, 0xa7, 0xbf, 0x8e, 0xc2 +OvmfMetadataOffsetEnd: + +%endif + ; SEV Hash Table Block ; ; This describes the guest ram area where the hypervisor should diff --git a/OvmfPkg/ResetVector/ResetVector.nasmb b/OvmfPkg/ResetVector/ResetVector.nasmb index d1d800c56745..bc61b1d05a24 100644 --- a/OvmfPkg/ResetVector/ResetVector.nasmb +++ b/OvmfPkg/ResetVector/ResetVector.nasmb @@ -80,6 +80,7 @@ %include "Ia32/Flat32ToFlat64.asm" %include "Ia32/AmdSev.asm" %include "Ia32/PageTables64.asm" +%include "X64/OvmfMetadata.asm" %endif %include "Ia16/Real16ToFlat32.asm" diff --git a/OvmfPkg/ResetVector/X64/OvmfMetadata.asm b/OvmfPkg/ResetVector/X64/OvmfMetadata.asm new file mode 100644 index 000000000000..a1260a1ed029 --- /dev/null +++ b/OvmfPkg/ResetVector/X64/OvmfMetadata.asm @@ -0,0 +1,45 @@ +;----------------------------------------------------------------------------- +; @file +; OVMF metadata for the confidential computing guests (TDX and SEV-SNP) +; +; Copyright (c) 2021, Intel Corporation. All rights reserved.<BR> +; Copyright (c) 2021, AMD Inc. All rights reserved.<BR> +; +; SPDX-License-Identifier: BSD-2-Clause-Patent +;----------------------------------------------------------------------------- + +BITS 64 + +%define OVMF_METADATA_VERSION 1 + +%define OVMF_SECTION_TYPE_UNDEFINED 0 + +;The section contains the code +%define OVMF_SECTION_TYPE_CODE 0x100 + +; The section contains the varaibles +%define OVMF_SECTION_TYPE_VARS 0x101 + +; The section must be accepted or validated by the VMM before the boot +%define OVMF_SECTION_TYPE_SEC_MEM 0x102 + +ALIGN 16 + +TIMES (15 - ((OvmfGuidedStructureEnd - OvmfGuidedStructureStart + 15) % 16)) DB 0 + +OvmfGuidedStructureStart: +; +; Ovmf metadata descriptor +; +OvmfMetadataGuid: + DB 0xf3, 0xf9, 0xea, 0xe9, 0x8e, 0x16, 0xd5, 0x44 + DB 0xa8, 0xeb, 0x7f, 0x4d, 0x87, 0x38, 0xf6, 0xae + +_Descriptor: + DB 'O','V','M','F' ; Signature + DD OvmfGuidedStructureEnd - _Descriptor ; Length + DD OVMF_METADATA_VERSION ; Version + DD (OvmfGuidedStructureEnd - _Descriptor - 16) / 12 ; Number of sections + +OvmfGuidedStructureEnd: + ALIGN 16 -- 2.25.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#80888): https://edk2.groups.io/g/devel/message/80888 Mute This Topic: https://groups.io/mt/85749017/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-