From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (NAM02-DM3-obe.outbound.protection.outlook.com [40.107.95.79]) by mx.groups.io with SMTP id smtpd.web10.46.1622070718013463087 for ; Wed, 26 May 2021 16:11:58 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@amd.com header.s=selector1 header.b=QataXpDT; 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.95.79, mailfrom: brijesh.singh@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ju+GqgBo6bsVtMoAmpOLOs+XB/2Gh6nD+obzgohVA0pDPaXY03WVhAQseMwJEEkp6pTRkhXkK+h99L9WGlkSh0pkMyQlztFrr1BbFIasDMG1370mJbR3UN/dyFLRkAX54xy8cpIXntOdVluZgJ63IvTHvIdvQSTL4r0UxarhcB6lmGWMtzgD/rDVbog+NEZLKEVHg33s0IS7mjzgPAPv55XVkX7souUHr4IGkzzkD3ANi5rS4aKbhSq05a1JpGgzs1Tfcp07zeVVaUGFoAW9wBg4jUi4MvBSWtwYhb9iDDcPTmPuuopTJ5LVyarBTonEG2gYbF9EoMm89oDknm7ZVg== 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=uW7PdDpTfjUcWQlqxiCR/N9BaHq1oPUa3FWHu/iVvnE=; b=jK8juueIY3bfFx8M8dVZYeW8Po6EQUw9QKNp3t52rRRqYthS+8+tR1UZN9POvizLYPfBicdvsPc48oLajUE6bodpVmYTsGp5RvbYp8rG0LhD++oybiCJatwQINx7EPms+ep5BYc+YdH5V8Cw6MMdwwBTt5yTIeyqyxM6uzgRS98iNwQbcwFww/btj2rNcvICgExTyQs/6v3yfvwxbsEEWaew4FiSp1pkHJN0pAGGVHXSIKdeb0hpSLo6zseTpgeYExPh7/sHwvxs4XYpz0VL121PQvO+3exD4cMmM9L+XuzdL7BUnjR4uDUQO5ts49VmdHMmWTkS9xxA8njBh7GKTA== 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=uW7PdDpTfjUcWQlqxiCR/N9BaHq1oPUa3FWHu/iVvnE=; b=QataXpDTBNf3BxuhF5jL2kUGaPeOo2v70Y2e4U4XqkshcNOlg/cGW/oPg4k3YjRVkl2lOfq+6w4wr0ecufkwM23ouw/QsoGPULHNg+4h0eYpg7NcKFsENRt4AB0aeZ+E7yRUXH0bbvgT0Yvrx7PAz0V2QsV579yJ0X5x7/yw4Ww= Authentication-Results: linux.ibm.com; dkim=none (message not signed) header.d=none;linux.ibm.com; dmarc=none action=none header.from=amd.com; Received: from SN6PR12MB2718.namprd12.prod.outlook.com (2603:10b6:805:6f::22) by SN6PR12MB2782.namprd12.prod.outlook.com (2603:10b6:805:73::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.28; Wed, 26 May 2021 23:11:54 +0000 Received: from SN6PR12MB2718.namprd12.prod.outlook.com ([fe80::9898:5b48:a062:db94]) by SN6PR12MB2718.namprd12.prod.outlook.com ([fe80::9898:5b48:a062:db94%6]) with mapi id 15.20.4150.023; Wed, 26 May 2021 23:11:54 +0000 From: "Brijesh Singh" To: James Bottomley , Min Xu , Jiewen Yao , Tom Lendacky , Jordan Justen , Laszlo Ersek , Erdem Aktas , Eric Dong , Ray Ni , Rahul Kumar , devel@edk2.groups.io CC: Brijesh Singh , Ard Biesheuvel Subject: [PATCH RFC v3 20/22] OvmfPkg/AmdSev: expose the SNP reserved pages through configuration table Date: Wed, 26 May 2021 18:11:16 -0500 Message-ID: <20210526231118.12946-21-brijesh.singh@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210526231118.12946-1-brijesh.singh@amd.com> References: <20210526231118.12946-1-brijesh.singh@amd.com> X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: SA0PR11CA0202.namprd11.prod.outlook.com (2603:10b6:806:1bc::27) To SN6PR12MB2718.namprd12.prod.outlook.com (2603:10b6:805:6f::22) 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 SA0PR11CA0202.namprd11.prod.outlook.com (2603:10b6:806:1bc::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.21 via Frontend Transport; Wed, 26 May 2021 23:11:53 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3aa30ec1-c964-40ed-6436-08d9209ba6eb X-MS-TrafficTypeDiagnostic: SN6PR12MB2782: 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: zmLpGN/bLXkQ4tK5CNxdCHyCpB0SVvYkfLGQAMrUdbV0Hf+Y/SA3snJBS3NzOSk0Nldd0F2OjUIO3Nt/sQ9SXTCZUGoVDGJ6CG6YY1v6Hjhli/1Az8yx6Q+InrhqCQK071YtavzNOyxzJWynWSRoXuBXJfqZUry6XzMq1FIZA71P9NALfQpg37+cX6O/B0weooNtwzDY809LIQ05uOzgJ4Z9+JOshOV/+8lQBSBXZFM2+nFsUNipTMRaWsL5zjORzqySMijX4wMGNr+gZQUwLe/lE2tscX04ekj3ZZ7MWAgN1gQtFPNgJqThHyjalYkjHpTrSqRzH4sjRNd6YAr+QzE8IFq+G+8v5wBsgPhi5Z5RKidvBgQtnqy+quOiNLwpthTkJMQX++Nai0LkOJzczX+w7pgb5bol413cXnQCXVD+EanggmBtqJci33tIKv0ZP4IsFnwY1p9CeGlN38/19f+6eCOTghNun3TlJNbuByXKy5vNuOzToBCZw3LpxqxHHwkNt0dkijIAS6FWWLSxjVMoDCl9uO1q2mVR5A6Vxq//5jncKyuhJQDMVXb0jODFyTesBOjSN3XROGJPaaAsKNFzsb1jcEEV3wXONF0UUZRhGJXCirr6LePZXolyObfxexD39JDXzhYfIjrqJDbYuQfn+u033BBGMKbwp0aO6DN0oxnaFOv4wQ7FIhmfVV+sixbE/q+jvYc/XplXsF69g3Jv9gZiHoeweT1y6ElHGzcAFv3Oflp+CwrbgaqaKsk1CEYEJJtDRYQHTR1usmLB58UPCmYMiM4jJmezBYoNCmA= 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)(39860400002)(346002)(396003)(376002)(136003)(26005)(316002)(5660300002)(8676002)(186003)(38350700002)(16526019)(478600001)(54906003)(36756003)(4326008)(86362001)(6666004)(7416002)(2616005)(110136005)(44832011)(2906002)(52116002)(66476007)(66556008)(7696005)(921005)(6486002)(8936002)(38100700002)(66946007)(1076003)(956004)(966005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?yUXMs1mSPFBJ58MVU4/xET88BTQHzOd1vwZywaKcyZrzgJS6HXpAd2tZMGya?= =?us-ascii?Q?WGTwK7BChdVsUnIyDBprTUoBox+EDU7pjvs2SPZ6UZ1RmDG+r+B7z6HwuJwI?= =?us-ascii?Q?T1fdCxqmI/g5ZSXHKru+9gYAJ1OJ4VX607tYeqsidREe5ezU6F4ctIXqKNRi?= =?us-ascii?Q?Ni4T5P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yaLZnIjg3?= =?us-ascii?Q?w5n1ZSebP+N4L34zPC3zU1MuX0ZcwoYUS4a50a4o7/ARj1feN5L6XnHb7sfV?= =?us-ascii?Q?TiGpPhIkYtoNUKTUmEEbS+pMJZHCdDibSgUbPqt6OU7uVhDKzxxuiDgjhpU2?= =?us-ascii?Q?VGVd+SnCVrQN3UvtxP3SaW92oEkK64Czf5TmPO1fNB/tHm2ooK2WkQcjnb5X?= =?us-ascii?Q?nklCvjP9048siIUErha3GVuv4blUyD8NAQAdb7FS8MJKCLd5qOhMFCXCKnun?= =?us-ascii?Q?DDZm+AtMjDOEw9sbm+RqbpiQ?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3aa30ec1-c964-40ed-6436-08d9209ba6eb X-MS-Exchange-CrossTenant-AuthSource: SN6PR12MB2718.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 May 2021 23:11:54.3099 (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: cCOPR6Guq7Eb52SxuKXtWExD2iPB2IvPvR/JmjvTbF6jlDwM3HLwvE/A5QHSam3g9suiMIr9JyT1TjaUh/E51Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB2782 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/AmdSev/SecretDxe/SecretDxe.inf | 4 ++++ .../Guid/ConfidentialComputingSecret.h | 18 +++++++++++++++ OvmfPkg/AmdSev/SecretDxe/SecretDxe.c | 22 +++++++++++++++++++ 4 files changed, 45 insertions(+) diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec index 4da2d2de9df0..89476c6a68d2 100644 --- a/OvmfPkg/OvmfPkg.dec +++ b/OvmfPkg/OvmfPkg.dec @@ -126,6 +126,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/AmdSev/SecretDxe/SecretDxe.inf b/OvmfPkg/AmdSev/Secret= Dxe/SecretDxe.inf index 40bda7ff846c..d15194b368f5 100644 --- a/OvmfPkg/AmdSev/SecretDxe/SecretDxe.inf +++ b/OvmfPkg/AmdSev/SecretDxe/SecretDxe.inf @@ -23,13 +23,17 @@ [Packages] MdePkg/MdePkg.dec =20 [LibraryClasses] + MemEncryptSevLib UefiBootServicesTableLib UefiDriverEntryPoint =20 [Guids] gConfidentialComputingSecretGuid + gConfidentialComputingBlobGuid =20 [FixedPcd] + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSnpCpuidBase + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSnpCpuidSize gUefiOvmfPkgTokenSpaceGuid.PcdSevLaunchSecretBase gUefiOvmfPkgTokenSpaceGuid.PcdSevLaunchSecretSize =20 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/AmdSev/SecretDxe/SecretDxe.c b/OvmfPkg/AmdSev/SecretDx= e/SecretDxe.c index 308022b5b25e..0c0f511d4ca0 100644 --- a/OvmfPkg/AmdSev/SecretDxe/SecretDxe.c +++ b/OvmfPkg/AmdSev/SecretDxe/SecretDxe.c @@ -6,6 +6,7 @@ **/ #include #include +#include #include =20 STATIC CONFIDENTIAL_COMPUTING_SECRET_LOCATION mSecretDxeTable =3D { @@ -13,6 +14,16 @@ STATIC CONFIDENTIAL_COMPUTING_SECRET_LOCATION mSecretDxe= Table =3D { FixedPcdGet32 (PcdSevLaunchSecretSize), }; =20 +STATIC CONFIDENTIAL_COMPUTING_BLOB_LOCATION mSnpBootDxeTable =3D { + SIGNATURE_32('A','M','D','E'), + 1, + 0, + (UINT64)(UINTN) FixedPcdGet32 (PcdSevLaunchSecretBase), + FixedPcdGet32 (PcdSevLaunchSecretSize), + (UINT64)(UINTN) FixedPcdGet32 (PcdOvmfSnpCpuidBase), + FixedPcdGet32 (PcdOvmfSnpCpuidSize), +}; + EFI_STATUS EFIAPI InitializeSecretDxe( @@ -20,6 +31,17 @@ InitializeSecretDxe( IN EFI_SYSTEM_TABLE *SystemTable ) { + // + // 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 gBS->InstallConfigurationTable ( &gConfidentialComputingSecretGuid, &mSecretDxeTable --=20 2.17.1