From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (NAM10-DM6-obe.outbound.protection.outlook.com [40.107.93.80]) by mx.groups.io with SMTP id smtpd.web11.1354.1632163640606502808 for ; Mon, 20 Sep 2021 11:47:20 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@amd.com header.s=selector1 header.b=rxkv/NdM; 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.93.80, mailfrom: brijesh.singh@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lw/1fZ/wDaOk2qTxs62mwMpJL/5ufm/NIZFzh2JymcC3VG9tiMZD4jDU/G7cv75evLPmNl7U4FsLaZnel14nAjjstUyJ7n1bW1Iq1tkzMF4QW3dfaXNaYTMilL/2blsCZw0Z70BL1i71eB8sj0InMiZOBTkCo/KuyrNl6OK73i7MV8UVbwcIr5ddjegQAK2NEDGir2cQvrPaTNAwbiWHQ2nhx5mRsznIYc+KQ49W69pcZzwInFcKZlhiOteZUTZ0LIM5qu2PGhhj3scRLHEFaZGaHOHxa8hYsjlM08VD0mQA3gp7LlJ2nkRq2MP7080UntkXVcSQPrttc/zte7XojQ== 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=zQAfFr5SED33vqXYnVZZF1oDPgGDJXikOazCPYGUem0=; b=k8bHtmLY9GlzFhREZXe8qGMjrITep1uz6U/2mGvqWG4JwmgIckXdWuxoifTJ9XHNm/03rnNuRib3xbcw/x1SPf5f3u3iEg0YTWsjF+XSliJsJmcGnUYr8rLmlTG1LxhI6z0Ie+6TAjSgX86qP8BZgTM4vnfbOwgXqNa9unDo4IVECm53t1U/quYas+2tolU8cajP2jHHa0W2mMWBAb4kEaFPsRfQT+4+KaA6czFTsH4vdr56NldUP/ugkSi8Fi/37u1BD36bEZzocuvaVvbMKx19jcjd7zvAMMIiO0HKHOGW0uLwChkvHHSTYsAI6yeZmGiXVS4lDGAyo/0M9c1ZRQ== 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=zQAfFr5SED33vqXYnVZZF1oDPgGDJXikOazCPYGUem0=; b=rxkv/NdM1KkrnUd5rUvIU79LVUndo2ZFbjmpPR7pU6AcIREScbWqFYwt3oGEzQDGi5ITSR1XXpA4Pm82KOyk1I5OEw8FpAEXs8mJNfKxSuGKsyj4CXtGP9gy1c1HQyolZg/gchhoY1GVv8Aiz9f1ZNiaRvDzUGTmpJsrOvyxaIs= 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 SA0PR12MB4384.namprd12.prod.outlook.com (2603:10b6:806:9f::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14; Mon, 20 Sep 2021 18:47:16 +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.4523.018; Mon, 20 Sep 2021 18:47:16 +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 v8 31/32] OvmfPkg/AmdSev: expose the SNP reserved pages through configuration table Date: Mon, 20 Sep 2021 13:46:03 -0500 Message-ID: <20210920184604.31590-32-brijesh.singh@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210920184604.31590-1-brijesh.singh@amd.com> References: <20210920184604.31590-1-brijesh.singh@amd.com> X-ClientProxiedBy: SN4PR0201CA0034.namprd02.prod.outlook.com (2603:10b6:803:2e::20) 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 SN4PR0201CA0034.namprd02.prod.outlook.com (2603:10b6:803:2e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14 via Frontend Transport; Mon, 20 Sep 2021 18:46:45 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8ec7dcd2-4418-4d91-9290-08d97c66ff0c X-MS-TrafficTypeDiagnostic: SA0PR12MB4384: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5516; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lf1qGBoF2Zg/eh0eoL3fS+SHw0ptZmvVQObEWRA8k4iE1rXw+dkGc2rZDkXFdTF9tOQI0t7uZm5wYlepBz3b24QdxKo/1wyQ1pmUqWjYPNZ0Ux2/hRCdIIROfmU5K6fYwQHMu88GdjFZUZPmMtEfiZ+9cfJxeVqUniqp5uqjwiuFYD9bQIlINRI8KeEKpPUJBYAsz/ZLafh+tiKqge9NXaCGOq9eYLkSmd81wemNCLvu/Tvv9mTkSK3YpTz6vQWGdruU3qfGr0zv/urywLs/+9qmL1Jy1JDC3pz1GIFpeQJzCuoCLB3Vup4SPTtwhauMJj1VRBCp7M1mM3t3GAmcB1+TjhFGngsLE+rGgWZz4XobKv8aNB2eiNfJZwYCaXemXI/PECEzeM+aWbrPYqNCamwNU21jtSUT7WIsgtuCDyiOZPzF96kaPNgxv7XeUnASI/yh7pYjjYYs0pxAHfu4qBPgSqh3Pfu2godBInUyugXP5bGyVNruiNHFRC25UMUX+3/Ax14vaWbOXP3gkBgtCguj7mYoqGLCDcutjuAb3qoBb8P6Xiu0LS4wnSJoztv2olwWHVtjLbxud00IHBwqlc4MrjXiRfW7bTa1NZwk92vee4tyhcrvszz5aUWkOzca/e2VU9FTBaqpAT6lg2slQFKF6eDuZeuoVv/cADJIzWhjo72+qma8tpLJZNb150PGnfFVM3v0g+1ai86Fafx1LAhItODeAZoQwZIopHdnNCGEp1VUvd0vz/QyBH1nqTuYa3eodflgOdY9mw8C0KufJA== 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)(366004)(346002)(396003)(376002)(136003)(39860400002)(26005)(44832011)(6916009)(8936002)(86362001)(5660300002)(52116002)(66946007)(38100700002)(2906002)(4326008)(54906003)(8676002)(186003)(956004)(966005)(36756003)(2616005)(66556008)(478600001)(6666004)(6486002)(316002)(38350700002)(66476007)(1076003)(7696005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?zMK2FzQjC+qlLhCnel13A8lKJF4HYf1eZgIHRqMO30EhJuLj3bdT1F9Lh0H2?= =?us-ascii?Q?ElFsh24cNheJDvZTnDDPVBXwSVrd0FkYU2bh2CEK8y0uqIzwxOp22dbwTqzw?= =?us-ascii?Q?uP5/096d7N+x8+uPlDSEr5Wv69sUgaEtW6VcUil5kbsOmq+i4uuZMhPO+Jlx?= =?us-ascii?Q?d7BV3FH0Gpj31SSA356wp+tgt6Ps7fzJ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a89SKma/+wBIfqfDDY5RhupZSEZugJy3lmzQ6wCZe5gAx4dpy?= =?us-ascii?Q?qtS4O9fkM/TVyxqW+46kHFB8rtY2Dvf3Sleu+db1Seprj2CrMYPk/A8oTfd0?= =?us-ascii?Q?IZwDXnokNfur02RMViBA8efEaUrz+5AeVjYvS+tubcc+hpEArIYYNQyO2SVM?= =?us-ascii?Q?DIWe85mT7o0PpzgywZMXWRj6iV5qYsheWPozFquAfGiMutb82ENiSUdTOW7g?= =?us-ascii?Q?BlPpz36ro8f9DNjIxUogIj3f?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8ec7dcd2-4418-4d91-9290-08d97c66ff0c X-MS-Exchange-CrossTenant-AuthSource: SN6PR12MB2718.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Sep 2021 18:46:45.8717 (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: Lh5/ZIgNkFoPI3BBlElhYKTmkpNrkiHPew9MrrbulybaJZpMkcx7Gx1FbdISOOQT0kECnvxNr+/GZ+uCGX8PQQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4384 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3275 Now that both the secrets and cpuid pages are reserved in the HOB, extract the location details through fixed PCD and make it available to the guest OS through the configuration table. 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 Signed-off-by: Brijesh Singh --- OvmfPkg/OvmfPkg.dec | 1 + OvmfPkg/AmdSevDxe/AmdSevDxe.inf | 7 ++++ .../Guid/ConfidentialComputingSevSnpBlob.h | 33 +++++++++++++++++++ OvmfPkg/AmdSevDxe/AmdSevDxe.c | 23 +++++++++++++ 4 files changed, 64 insertions(+) create mode 100644 OvmfPkg/Include/Guid/ConfidentialComputingSevSnpBlob.h diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec index 052784c18864..aabe81d5c63e 100644 --- a/OvmfPkg/OvmfPkg.dec +++ b/OvmfPkg/OvmfPkg.dec @@ -124,6 +124,7 @@ [Guids] gQemuKernelLoaderFsMediaGuid =3D {0x1428f772, 0xb64a, 0x441e, {= 0xb8, 0xc3, 0x9e, 0xbd, 0xd7, 0xf8, 0x93, 0xc7}} gGrubFileGuid =3D {0xb5ae312c, 0xbc8a, 0x43b1, {= 0x9c, 0x62, 0xeb, 0xb8, 0x26, 0xdd, 0x5d, 0x07}} gConfidentialComputingSecretGuid =3D {0xadf956ad, 0xe98c, 0x484c, {= 0xae, 0x11, 0xb5, 0x1c, 0x7d, 0x33, 0x64, 0x47}} + gConfidentialComputingSevSnpBlobGuid =3D {0x067b1f5f, 0xcf26, 0x44c5, {= 0x85, 0x54, 0x93, 0xd7, 0x77, 0x91, 0x2d, 0x42}} =20 [Ppis] # PPI whose presence in the PPI database signals that the TPM base addre= ss diff --git a/OvmfPkg/AmdSevDxe/AmdSevDxe.inf b/OvmfPkg/AmdSevDxe/AmdSevDxe.= inf index 0676fcc5b6a4..9acf860cf25e 100644 --- a/OvmfPkg/AmdSevDxe/AmdSevDxe.inf +++ b/OvmfPkg/AmdSevDxe/AmdSevDxe.inf @@ -42,6 +42,13 @@ [FeaturePcd] =20 [FixedPcd] gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfCpuidBase + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfCpuidSize + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSnpSecretsBase + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSnpSecretsSize + +[Guids] + gConfidentialComputingSevSnpBlobGuid =20 [Pcd] gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId diff --git a/OvmfPkg/Include/Guid/ConfidentialComputingSevSnpBlob.h b/OvmfP= kg/Include/Guid/ConfidentialComputingSevSnpBlob.h new file mode 100644 index 000000000000..c98e7a1dcccd --- /dev/null +++ b/OvmfPkg/Include/Guid/ConfidentialComputingSevSnpBlob.h @@ -0,0 +1,33 @@ + /** @file + UEFI Configuration Table for exposing the SEV-SNP launch blob. + + Copyright (c) 2021, Advanced Micro Devices Inc. All right reserved. + + SPDX-License-Identifier: BSD-2-Clause-Patent + **/ + +#ifndef CONFIDENTIAL_COMPUTING_SEV_SNP_BLOB_H_ +#define CONFIDENTIAL_COMPUTING_SEV_SNP_BLOB_H_ + +#include + +#define CONFIDENTIAL_COMPUTING_SNP_BLOB_GUID \ + { 0x067b1f5f, \ + 0xcf26, \ + 0x44c5, \ + { 0x85, 0x54, 0x93, 0xd7, 0x77, 0x91, 0x2d, 0x42 }, \ + } + +typedef struct { + UINT32 Header; + UINT16 Version; + UINT16 Reserved1; + UINT64 SecretsPhysicalAddress; + UINT32 SecretsSize; + UINT64 CpuidPhysicalAddress; + UINT32 CpuidLSize; +} CONFIDENTIAL_COMPUTING_SNP_BLOB_LOCATION; + +extern EFI_GUID gConfidentialComputingSevSnpBlobGuid; + +#endif diff --git a/OvmfPkg/AmdSevDxe/AmdSevDxe.c b/OvmfPkg/AmdSevDxe/AmdSevDxe.c index c66c4e9b9272..6e1ba35e02b8 100644 --- a/OvmfPkg/AmdSevDxe/AmdSevDxe.c +++ b/OvmfPkg/AmdSevDxe/AmdSevDxe.c @@ -17,8 +17,20 @@ #include #include #include +#include +#include #include =20 +STATIC CONFIDENTIAL_COMPUTING_SNP_BLOB_LOCATION mSnpBootDxeTable =3D { + SIGNATURE_32('A','M','D','E'), + 1, + 0, + (UINT64)(UINTN) FixedPcdGet32 (PcdOvmfSnpSecretsBase), + FixedPcdGet32 (PcdOvmfSnpSecretsSize), + (UINT64)(UINTN) FixedPcdGet32 (PcdOvmfCpuidBase), + FixedPcdGet32 (PcdOvmfCpuidSize), +}; + EFI_STATUS EFIAPI AmdSevDxeEntryPoint ( @@ -130,5 +142,16 @@ 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 ()) { + return gBS->InstallConfigurationTable ( + &gConfidentialComputingSevSnpBlobGuid, + &mSnpBootDxeTable + ); + } + return EFI_SUCCESS; } --=20 2.25.1