From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (NAM10-MW2-obe.outbound.protection.outlook.com [40.107.94.79]) by mx.groups.io with SMTP id smtpd.web10.874.1631557202199811456 for ; Mon, 13 Sep 2021 11:20:03 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@amd.com header.s=selector1 header.b=5s0hKxst; spf=permerror, err=parse error for token &{10 18 %{i}._ip.%{h}._ehlo.%{d}._spf.vali.email}: invalid domain name (domain: amd.com, ip: 40.107.94.79, mailfrom: brijesh.singh@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dvfKHZtYlXafjzjZXi20LwaO5lz1FxjlwZEZ/qt8W7420vb9/pxIC1PqmE+ynfyYGzoB7DrJXSsJ+qerKdg4CBxXUhuLTmDYC+V0t6TRu/IxdRqhiUYCVIzzf3IQGwCk3HsiCC7ld6tSlDE8iQdQBB3ZyUaL0XC29WXvF0ry16mIEPOiSnfkOBZn+T83KZtfijRzlwVQVI6YFsJ6RhHSVfK64+wLB4p2Sq8Jey45EO1P6o+tL5PkBsd2DrWyhUKUbvrocpAtwt8OodUQ0hXlWYG7TYrt71ZgIR2pdZU9bxt4y72K0VAgJX6FOVx/+4lG+wOX20u2WFar5owxdbpCgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=1jq5l7G88SN2JAF+bE5aAmWyCMze1id5BI4sMXQRvfs=; b=SNNofd5Qr8me68sdCJVCsLjgVzDgofKv14YdRZHcw8lm91b3WpWIPQPhvXTaATLyGQ9Iy6DcVqLUrW0sLLQt0XYr/2+UUO9wqUdTBqoqLrlTAsbrNDcanwinxQGdsc+yEOWoF0yYPsZpRTZO1mG3O1MeeKSbXituNVAURFwm5PKB7+IPo/VhuT7rI2pxRZFiWhpzpcSjR8OCjdoJe3xGORkFRKHKrLKAwwwcfWvwQHDCYTpMaCU6eWF90IstWXfGxe9YPemSy6rMbe1vs1PMzQSTZEW8MmslrKAwx7CFup+MIeNLkyTSFqiTedymy+G4emVv8gl6G5ecsG0S8ipmPw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1jq5l7G88SN2JAF+bE5aAmWyCMze1id5BI4sMXQRvfs=; b=5s0hKxstr2hFf/15a9XZ/H49rz4is1q4Agqbi/Un24XguM1Z3mnEOqmGCJ1+PPpaHJpsF/yxSecJ5iJ1ohxhHsb3FAxpwBe4lhATN5Gl7Wq5QEXnO5EZeA0cU5tFz2LNWB0x0CqgCy/W/zoYpvYIcvO5zib3zA8Fa/kBO3UWBmU= Authentication-Results: edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=none action=none header.from=amd.com; Received: from SN6PR12MB2718.namprd12.prod.outlook.com (2603:10b6:805:6f::22) by SN1PR12MB2512.namprd12.prod.outlook.com (2603:10b6:802:31::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14; Mon, 13 Sep 2021 18:20:00 +0000 Received: from SN6PR12MB2718.namprd12.prod.outlook.com ([fe80::78b7:7336:d363:9be3]) by SN6PR12MB2718.namprd12.prod.outlook.com ([fe80::78b7:7336:d363:9be3%6]) with mapi id 15.20.4500.019; Mon, 13 Sep 2021 18:20:00 +0000 From: "Brijesh Singh" To: devel@edk2.groups.io CC: James Bottomley , Min Xu , Jiewen Yao , Tom Lendacky , Jordan Justen , Ard Biesheuvel , Erdem Aktas , Michael Roth , Gerd Hoffmann , Brijesh Singh , Michael Roth Subject: [PATCH v7 03/31] OvmfPkg/ResetVector: introduce metadata descriptor for VMM use Date: Mon, 13 Sep 2021 13:19:13 -0500 Message-ID: <20210913181941.23405-4-brijesh.singh@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210913181941.23405-1-brijesh.singh@amd.com> References: <20210913181941.23405-1-brijesh.singh@amd.com> X-ClientProxiedBy: SA9P221CA0012.NAMP221.PROD.OUTLOOK.COM (2603:10b6:806:25::17) To SN6PR12MB2718.namprd12.prod.outlook.com (2603:10b6:805:6f::22) Return-Path: brijesh.singh@amd.com MIME-Version: 1.0 Received: from sbrijesh-desktop.amd.com (165.204.77.1) by SA9P221CA0012.NAMP221.PROD.OUTLOOK.COM (2603:10b6:806:25::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14 via Frontend Transport; Mon, 13 Sep 2021 18:20:00 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cd75280c-0a6a-4e91-a1e7-08d976e31967 X-MS-TrafficTypeDiagnostic: SN1PR12MB2512: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HtcIjtz+cGbLbg4O8/6CHxpLBvtSvOpb6CMTxfkiQkWilOPk3PJFH6U/GvUYoMfhSX2tL+78qwm9XwAgyWjTjv4zEoeRnsgyh9LwL4XZ7OrscWpOJTRb1cCN2t/zl4xPn7zeC4kvSHyTA15/ZQgDwapwbrnLnziiBEFF0YwryXNFuWVfGyPI32L5Efj/rV+EuW8HnVXc+LbR+byNDItv6JW9CYs8N06dwgHBC6arX6SqibMutfL7dU5VsbIi0s1afX+Ks4vfyDiRbdXTxtBi91xxhFBrj6c55BLfoSnhE5Dmw/KL4QEKuaNgCzNtY5dTZFrsHBvT3/hwm2c+Fde31C+k8s82WP8xDn+xtgqGfnD6cwSCWxaJfqSZFk7IXPWGsKFnWjLo6UbG/m+ZYjNSu2ZYVkx/wzYDbMkcJGFD4cS9uDRr3jyvadXZhX428Ed6/ELOyIGhcNfDJQ5SuotJypSBdvSu8UKgxga4CIuFJWLocyERBpUVYdooPxcsSqraBWgJI6SIYitmHxhjybTU5VELLVf2uU6smiQfnrp4MMV4rfdXhVuqJMguYvcMg+iKNuzlS9JCzy4NI8U8rrxttHHFiv4Z03hzKMhzw2uiTtn5VomUHHfr4nMwrfxodKpAOpFcbcNxeqCSQhUqfoc9ZHriM9ti3B/eROUVkBW0SalMs0TooWSSZ3qIOUAisGKlS9ecBFYq5I7zPgeDcp4ZvbR55oVDp0XXtBMEGZOWn6+77nPMC7gIbfU2BDN3pPinObBNiY3/6LICD7TyirfVKg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR12MB2718.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(396003)(346002)(39860400002)(366004)(376002)(136003)(83380400001)(478600001)(86362001)(8936002)(966005)(6486002)(8676002)(186003)(6916009)(2906002)(38350700002)(38100700002)(26005)(36756003)(19627235002)(956004)(2616005)(66946007)(6666004)(66556008)(54906003)(5660300002)(52116002)(44832011)(66476007)(316002)(4326008)(1076003)(7696005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?heYzyCQ2N/XouYQIN1Bed0MGX9o6S/2qqgQnoA4dcvWSGiuYQTQitJl07yrC?= =?us-ascii?Q?hEPkpSmURtDFIgI3fOUuJnI3bQZRQSWOTJF40C78KU2FjTUyE+PCBkSsKmsg?= =?us-ascii?Q?i+D+0+od72nwds2yb2oNjqykZcOmFGl3f5jnwa2zNXiTPgb7KSGsGnC7oRUS?= =?us-ascii?Q?s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Y5n+SPB9zQR71v?= =?us-ascii?Q?wRsszcyl0FSLWwhl41MyZbB/anRNpNvyHIgA+i9L+jdDSiPw1hF+1kwskqqj?= =?us-ascii?Q?Frh/FWniCW4HN093NikBleEV3grdgBWTixCY1Q/tMeEuvY5xNuhDgtyath5D?= =?us-ascii?Q?YENmpCgOObbd3ch836lgw6Do2OGz7sgsN7bJh4dBUUzTIxzp3nwsFGY8wPMS?= =?us-ascii?Q?RMlUareGPrN9JtUKu1ru2YS/VxVeRePkfv6r3NIsOHGEHWx1WatB/7bAYPCk?= =?us-ascii?Q?4zn23mXEw5D0b6lzP/sATLiT?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: cd75280c-0a6a-4e91-a1e7-08d976e31967 X-MS-Exchange-CrossTenant-AuthSource: SN6PR12MB2718.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Sep 2021 18:20:00.6910 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 31YqgyJNj5OVSNN9a3gGQSfThFgVaNRwE0Bi82dhtfjieym8780WgxWpUAO6PNg9C7K0wA7iSsqwrZUMHT8/UA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB2512 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3275 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 Cc: James Bottomley Cc: Min Xu Cc: Jiewen Yao Cc: Tom Lendacky Cc: Jordan Justen Cc: Ard Biesheuvel Cc: Erdem Aktas Cc: Gerd Hoffmann Suggested-by: Gerd Hoffmann Signed-off-by: Brijesh Singh --- 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/ResetVe= ctor/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: =20 +%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/Re= setVector.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 =20 %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.
+; Copyright (c) 2021, AMD Inc. All rights reserved.
+; +; 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 --=20 2.17.1