From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (NAM04-MW2-obe.outbound.protection.outlook.com [40.107.101.55]) by mx.groups.io with SMTP id smtpd.web08.14882.1624902235036224717 for ; Mon, 28 Jun 2021 10:43:55 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@amd.com header.s=selector1 header.b=MBWu9LNc; 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.101.55, mailfrom: brijesh.singh@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EC9SFDNRPPJ5EV2DxY/lNm5STaPIC/1Y3MgphrDpUAhpmwGxq+77LJyJ9L2XVB2eC7A/HJNx+aYZTE3JsMqsmRlrq6sXVSyxK5d3fdSjm4nLpW3sQe69z6TMllz9xd/Bs8BXrVfeH/iOkky7fR1TgHxpboVAsomr9ewL6b9ZA1h7sl8LjDfHdnfR+576UICRpjjWjVpi9Cyb0qFRfE382aAVSKr5ZIcVxB67NVHnwpJ1QBqz4T/zzgPXlu6A/mMectxygu8n4QTe13ge3cbiTXEmHX5OFDp5hGM9P+6EIJT29O+n/FAxWZcidBE+ZjH0ArJoBwv5N8I3XX/qv6JkBQ== 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:X-MS-Exchange-SenderADCheck; bh=sDn0435vUWKMQxJbw0YukzI00tb18Vtbz+3wBEbKwS0=; b=InGgcgyGScz+wdxq0B9OH+1pFjSkXYCtj4CyfJZdQLIKD8gdOs8B/JaXA7yhVYLAWyy2CuZyHnnVIzU03MfFVOwU/cl5z1lN+qeEPiCKZ3o3HYRuI6SiUNlnDEEz0UvPBDUVCFuulfjMvljQBNcB9x2o4U64gk/ckFQmRw0MyK6NOjy4WIWabxbX7MFGrkWsnYWEELr2zTy8zuitvwPt4KKzHqwniWP0xJk+Vr2k4Hn61HPp0spzPWLaLO0dH9vDpA10MpQUbXj/oAwdlADknprwoEj3a1wDxp3egFCQtY7JKDKpYe105UsK9nlhauM1mj/gwvGVITu4HYfQIznouQ== 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=sDn0435vUWKMQxJbw0YukzI00tb18Vtbz+3wBEbKwS0=; b=MBWu9LNcY4EigpGyUCE1iJCWxUgr53wrtIYN5mx95V4CMkR8JBe/9FCxmaftOBnbF5RPzQ82LHrOPgCesjFNrBTWsMyIRnPmIqBW6jWqdReEHym4BLnNNSuXhJAbPx+Lla0JLalKtuAxYo3ALF6rI0HGGmWNFLeY2eaRduSOMZU= 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 DM6PR12MB2714.namprd12.prod.outlook.com (2603:10b6:5:42::18) by DM6PR12MB4761.namprd12.prod.outlook.com (2603:10b6:5:75::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.19; Mon, 28 Jun 2021 17:43:53 +0000 Received: from DM6PR12MB2714.namprd12.prod.outlook.com ([fe80::7df8:b0cd:fe1b:ae7b]) by DM6PR12MB2714.namprd12.prod.outlook.com ([fe80::7df8:b0cd:fe1b:ae7b%5]) with mapi id 15.20.4264.026; Mon, 28 Jun 2021 17:43:53 +0000 From: "Brijesh Singh" To: devel@edk2.groups.io CC: James Bottomley , Min Xu , Jiewen Yao , Tom Lendacky , Jordan Justen , Ard Biesheuvel , Laszlo Ersek , Erdem Aktas , Eric Dong , Ray Ni , Rahul Kumar , Michael D Kinney , Liming Gao , Zhiguang Liu , Michael Roth , Brijesh Singh Subject: [RFC PATCH v4 27/27] OvmfPkg/AmdSev: expose the SNP reserved pages through configuration table Date: Mon, 28 Jun 2021 12:42:23 -0500 Message-ID: <20210628174223.1302-28-brijesh.singh@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210628174223.1302-1-brijesh.singh@amd.com> References: <20210628174223.1302-1-brijesh.singh@amd.com> X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: SN4PR0601CA0020.namprd06.prod.outlook.com (2603:10b6:803:2f::30) To DM6PR12MB2714.namprd12.prod.outlook.com (2603:10b6:5:42::18) Return-Path: brijesh.singh@amd.com MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sbrijesh-desktop.amd.com (165.204.77.1) by SN4PR0601CA0020.namprd06.prod.outlook.com (2603:10b6:803:2f::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.19 via Frontend Transport; Mon, 28 Jun 2021 17:43:52 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cb3a662d-e3fb-468d-aba7-08d93a5c4ba1 X-MS-TrafficTypeDiagnostic: DM6PR12MB4761: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5516; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: k7TvsXGGe/daxwRWFf9sw4Jz1pyVEJZ516Dsw0cRsNcL3bWq3kbqzjlxFTkRyTmZhETRlY+403xiJs9ANJ0Jfg15TgqahFKoZ93OzdtF+g9Xt0TIdKMXXdN32PIBahE85tnjmdQu2O5EXbAD/QwJ4LBjMDrJbDCSNNs6uVV9hC03mvTDulT8wVQli3ShMT+EIHVQO/4xyc/lBfdzrw1ZU6U0JBmFh54QarmEWZE8IJr2QFp7xIRoVpGoetfNnKNd4OMfwqVprWPkzNv86+g3qnlAGopG99ZnmJ7E6AM7IQ316k8yD/RcRROJ7/49LCc+1WPFUuybMOmrYDBWhIP50pfl1nwnQ8rFsSWZe57xGZwP3QNfxtvAWLg3GtUuDUqX2G9hKJdYOdNhSkLfsvndq+jwOeR0a49Aea3NTTdiGctPNNO5ykqBFtnvUDnQJp7f7AOCf3pCj+a+/yZ4a6tRo7OiPMEO+1oJHBtaZWnO2jgcfkf0DxeGKRnHAU9P9bzsWnNEivcPqQiRZDcQy0f3oF2m4y/wzV34Lk0gpA+N+tTvnWym4QKcZRz9IXTgyeoX7Rss0R8u4lAD+3EMzypLxl73iYDo9dZVGKlNQ7pkU7a3zppJdHU213mHbEs7X2IY76sbC6C+Vbkxd9fL5drSleg9k8FctaaeLqkf/l25OmtFVlrNFdcTlB3dlqd4vF2A3rV7cpBeU57K5DUM3Ws7YKU979SBPov8cjLhCBbs1f6DXos0yiVSRtQO4vq/0nYs0s9Hv7SDaqQC2UD0GkdI9OUrVNBYT5/K69qVccyhcF1z0U0j5ZU28GrUylAoxT8l X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR12MB2714.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(136003)(376002)(39860400002)(396003)(366004)(346002)(52116002)(36756003)(26005)(7696005)(1076003)(2616005)(8676002)(186003)(16526019)(8936002)(86362001)(66556008)(5660300002)(316002)(54906003)(66946007)(66476007)(6666004)(44832011)(38100700002)(4326008)(2906002)(6486002)(6916009)(956004)(966005)(7416002)(478600001)(38350700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?e1sNsa8iADjbZcLPA0cIffvDX0g8xf8aN7uTFw8hhCz1fsQMk1lIdCOR3Gyw?= =?us-ascii?Q?h3bfGUdulHj+zDW5iajq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ascii?Q?WrmzlBxIjQTfVXYrPXaNMgl2StEe6HVGNAd1wRXIzYPi7XUwRo8aYgnTeRJL?= =?us-ascii?Q?GnojyemWREauFfsJCqn6ICqhu+6M5tuGLCHapDA2oTwAu+nyZfvsqzerK459?= =?us-ascii?Q?kPlEUa8MxRGgvHYvRVyBPN69ctVd5AGWCY5LjqqwATkU5dc6I5MtYHB61NIJ?= =?us-ascii?Q?r3V2P42rBZLz6m3hWuo6vzQ/DLW1yVheE30OgSBYUSN7Fs2MH24dFvnx41P3?= =?us-ascii?Q?VswQ+zWenS/BmZtlex1QN4VYHrwCT+XVnBle5L7fbfB6/3H/EFC3qQkOCvmf?= =?us-ascii?Q?uUscj5DlMP2GX8336snvJk2UGS6m94NrVhyJ/qYjJ825LL1S7Jo76MeA4Lqq?= =?us-ascii?Q?2ol49XEEuw7D9LoH5dDqot8s?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: cb3a662d-e3fb-468d-aba7-08d93a5c4ba1 X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB2714.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jun 2021 17:43:53.1523 (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: 6vK0rWIQS8oX/WL2CrXyWVwK+H2AZrfbi6a+/AjYPgzCn44QeCrxPf2XE77iqI9H4B3XvRDeTb3WdmUer3dRlQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4761 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: James Bottomley Cc: Min Xu Cc: Jiewen Yao Cc: Tom Lendacky Cc: Jordan Justen Cc: Ard Biesheuvel Cc: Laszlo Ersek Cc: Erdem Aktas Signed-off-by: Brijesh Singh --- OvmfPkg/OvmfPkg.dec | 1 + OvmfPkg/AmdSevDxe/AmdSevDxe.inf | 7 ++++++ .../Guid/ConfidentialComputingSecret.h | 18 +++++++++++++++ OvmfPkg/AmdSevDxe/AmdSevDxe.c | 23 +++++++++++++++++++ 4 files changed, 49 insertions(+) diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec index afc559d74335..42ad88fc5622 100644 --- a/OvmfPkg/OvmfPkg.dec +++ b/OvmfPkg/OvmfPkg.dec @@ -122,6 +122,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}} + gConfidentialComputingBlobGuid =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..ee1f8e4ff09a 100644 --- a/OvmfPkg/AmdSevDxe/AmdSevDxe.inf +++ b/OvmfPkg/AmdSevDxe/AmdSevDxe.inf @@ -42,6 +42,13 @@ [FeaturePcd] =20 [FixedPcd] gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSnpCpuidBase + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSnpCpuidSize + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSnpSecretsBase + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSnpSecretsSize + +[Guids] + gConfidentialComputingBlobGuid =20 [Pcd] gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId diff --git a/OvmfPkg/Include/Guid/ConfidentialComputingSecret.h b/OvmfPkg/I= nclude/Guid/ConfidentialComputingSecret.h index 7026fc5b089f..aa1a3b015437 100644 --- a/OvmfPkg/Include/Guid/ConfidentialComputingSecret.h +++ b/OvmfPkg/Include/Guid/ConfidentialComputingSecret.h @@ -18,11 +18,29 @@ { 0xae, 0x11, 0xb5, 0x1c, 0x7d, 0x33, 0x64, 0x47 }, \ } =20 +#define CONFIDENTIAL_COMPUTING_BLOB_GUID \ + { 0x067b1f5f, \ + 0xcf26, \ + 0x44c5, \ + { 0x85, 0x54, 0x93, 0xd7, 0x77, 0x91, 0x2d, 0x42 }, \ + } + typedef struct { UINT64 Base; UINT64 Size; } CONFIDENTIAL_COMPUTING_SECRET_LOCATION; =20 +typedef struct { + UINT32 Header; + UINT16 Version; + UINT16 Reserved1; + UINT64 SecretsPhysicalAddress; + UINT32 SecretsSize; + UINT64 CpuidPhysicalAddress; + UINT32 CpuidLSize; +} CONFIDENTIAL_COMPUTING_BLOB_LOCATION; + extern EFI_GUID gConfidentialComputingSecretGuid; +extern EFI_GUID gConfidentialComputingBlobGuid; =20 #endif // SEV_LAUNCH_SECRET_H_ diff --git a/OvmfPkg/AmdSevDxe/AmdSevDxe.c b/OvmfPkg/AmdSevDxe/AmdSevDxe.c index c66c4e9b9272..c59cc28cf6f5 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_BLOB_LOCATION mSnpBootDxeTable =3D { + SIGNATURE_32('A','M','D','E'), + 1, + 0, + (UINT64)(UINTN) FixedPcdGet32 (PcdOvmfSnpSecretsBase), + FixedPcdGet32 (PcdOvmfSnpSecretsSize), + (UINT64)(UINTN) FixedPcdGet32 (PcdOvmfSnpCpuidBase), + FixedPcdGet32 (PcdOvmfSnpCpuidSize), +}; + EFI_STATUS EFIAPI AmdSevDxeEntryPoint ( @@ -130,5 +142,16 @@ AmdSevDxeEntryPoint ( } } =20 + // + // If its SEV-SNP active guest then install the CONFIDENTIAL_COMPUTING_B= LOB. + // It contains the location for both the Secrets and CPUID page. + // + if (MemEncryptSevSnpIsEnabled ()) { + return gBS->InstallConfigurationTable ( + &gConfidentialComputingBlobGuid, + &mSnpBootDxeTable + ); + } + return EFI_SUCCESS; } --=20 2.17.1