From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (NAM11-BN8-obe.outbound.protection.outlook.com [40.107.236.88]) by mx.groups.io with SMTP id smtpd.web11.5562.1625057683480253571 for ; Wed, 30 Jun 2021 05:54:44 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@amd.com header.s=selector1 header.b=TNgKaEtF; 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.236.88, mailfrom: brijesh.singh@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fRDBqaW6BwAHESiriKny4150qytz6pwVOdVI57hsF0weFq8Xmx5zQYSiKsYvzYJuufNOs4oTway/7ODJvwgBTz/agTk+oDZSyFkhQic8cgZpE3wC9Ly50hYXbuaBngDZHUa9AdN5XdVvpYCOd1eJN470w03KSwjYlDWi2ftjbZ/QnSzB15ctIJZY3N5WDbOG4NXfirPiH1E38CjXfLFrfQuedOvOMhJbFMBDMbwjnbju7107YbgjITdSG6G4/i89bYvtkbeeMRisd69gixK2FimSwd6J+JeSC7DCsDx63cDGbA2lFCLEWz6yNWBnmtwuX6zMtNRIQu355V3gvGFb9Q== 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=U+YEdi/UHs5wd3F9ctTTdROdn1n+U82MnLXrb5PCPVU=; b=XXhVa8vW/IvEmeIjssqD6wCQVprQIoHIyrVB1dfV9cb8Hj++eQOeq9vRgWpZySeeOcG4sN/N0WgigejanQVpu4eTgS1jKri6dtzZ4RvyVZp6tONnlFud/wgDhW0J+3hciVXeY9r94if8wSXiypJvvhutWZ97qYggTF2Xu/rnhIu62Pe0Rmz0Li6IcN+iO/RL7V+oKxgszdNl1WUYhmpCBTLS5pIXwVTjr6OG76jcIQobeVZWdK1i8OszDJURlUtb7H4fNCmYqRKvkuvglvGVFPPwVt/m0rEsCLTJQJS2NDMC4uG2E817PKUJu5rxzTobOSbFX92V37LQlCiDPeOO+g== 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=U+YEdi/UHs5wd3F9ctTTdROdn1n+U82MnLXrb5PCPVU=; b=TNgKaEtFQhXl8GrpAjbUgAAGy7yOYWOrJBzbsFz3e0D8AcYvs0aqBbT8rX+3YnNqEZwib35BCHg3aSL2gKPbGn3maVtbzXsZzEkIQDjsjGxlVqDOYR6zqM++4edIGvTZ54gyuDzb1Te4f8/N+K9Hi1W2f9Q9q73r17SrAh76iPk= 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 DM5PR1201MB0172.namprd12.prod.outlook.com (2603:10b6:4:51::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.21; Wed, 30 Jun 2021 12:54:42 +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; Wed, 30 Jun 2021 12:54:42 +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 v5 27/28] OvmfPkg/PlatformPei: mark cpuid and secrets memory reserved in EFI map Date: Wed, 30 Jun 2021 07:53:20 -0500 Message-ID: <20210630125321.30278-28-brijesh.singh@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210630125321.30278-1-brijesh.singh@amd.com> References: <20210630125321.30278-1-brijesh.singh@amd.com> X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: SA9PR13CA0018.namprd13.prod.outlook.com (2603:10b6:806:21::23) 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 SA9PR13CA0018.namprd13.prod.outlook.com (2603:10b6:806:21::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.14 via Frontend Transport; Wed, 30 Jun 2021 12:54:41 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d8c56b69-05f7-41cb-ed49-08d93bc63a75 X-MS-TrafficTypeDiagnostic: DM5PR1201MB0172: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hyTHVgq4KEDeNHtAhm8hrIskASLf/fB5NM4MXcpe5n1kHNdGKoEjkkCnAwUvAXZKSSMgXPQqhC3DsbsB2/S74II+7QroxXmMsroilk7C/LWRg5AfPCD3SjQWptkUh4tpsJur+kBpUcLR6YB1Ufg9KKPqUrLLONwWGeMEVbDp1MkdqVJZ/DLFITVUtWrQ9V4pABmK5RJi/cBTc9aOiRuW8ozI7v3ehENWWVkQt1vCBIDe/jwKytYZq0XRs9rrMlILnPzSJrKepB/hz9LzoL4LZiSflJ0yYlYsRK0Rbl9vF6k52FLITf2vZaYYw7fhip9B7+xOo1ztpapTwaCfN5cDhP1UW5uiEqJkdjGFF3jKmoAjR3xOTHUCua5vrRYbc9pCfg+dJCcA8oQ9WpJ52Ua9qsckPi5iVabSPDY395xrL1mnQeA6nCwufj8wUxoIe7EhIhygotsHcVRqiRnRiRMn27TgDnH0FfwUcLKouXJt282uxIekWdRDaPkbfhTDNC2qJ78sAhmGsFL8x5kDwLpZL71bAJ0VwluYcaAr9bPYJrfqrLUFyqShLd+wr/T0y6nlHC7s1273VdntiWTgl9SZHMmxm1NmJqfLogAxGxKojbkUY5ZKzY/jhGVuCofbvH6RSLyZ2lC8I8hfevl13q+7XoXVjeCwhmegv+HXZ1JE2DXbjpwFacV5B3SUUYVOG//yTobzlmTAmTwSHvXEhts2nA== 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)(376002)(366004)(39860400002)(136003)(346002)(396003)(7416002)(36756003)(5660300002)(8676002)(8936002)(54906003)(38100700002)(44832011)(2906002)(38350700002)(4326008)(83380400001)(7696005)(6486002)(1076003)(2616005)(956004)(66946007)(186003)(26005)(478600001)(52116002)(6666004)(316002)(66476007)(66556008)(16526019)(86362001)(6916009);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?YC2c8aVu2Up4Mvi1Tenmpy3sHs5viqNeh3ya7YxFkxzxkMqplTrR9DQ1jW3Y?= =?us-ascii?Q?nGFXofq+QH5lSu7FtKRyzwXs+FZiytkH7hIwqbcTGmhz1uAz53OlisPgTpYw?= =?us-ascii?Q?zZn6Ec5vrKAYPk5mmf7BOxDJi53IjS9kP23pAOdXgWhSEgcCSiq4xEvsAUsW?= =?us-ascii?Q?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g?= =?us-ascii?Q?g2rsaIHFB+r9tjkCAREh/cuUTZ40NNpdDGO9OunLNPk4H+cON4o8bt6BYawo?= =?us-ascii?Q?heHowdBXUAH5kKk96idunMFhGBhmZnQIiCTvTTvMTxJYIp45rklS2O6IeMpa?= =?us-ascii?Q?VNzKXVIjmPPe1uhQxKCrID9Jdjq0NyNci3KIJe/AEbdMll5/oawD9k8Z0mQc?= =?us-ascii?Q?sMWRsAWccnZ2xcwC1tqqyQszUFixaiI7OUCy0kaQXeW/lDYpqjpgJGAsGCAm?= =?us-ascii?Q?7nNsvOoladMnCBwgkIi7s3PI?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: d8c56b69-05f7-41cb-ed49-08d93bc63a75 X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB2714.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jun 2021 12:54:42.1315 (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: 64B/kSGnhS0gpUoh6TvswtFtj0++bYS1hFRtXGj7PCRCv70vubJ/BfghJVlermlfCbY+GMwg0kXO2oPPeZcPlw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR1201MB0172 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain When SEV-SNP is active, the CPUID and Secrets memory range contains the information that is used during the VM boot. The content need to be persist across the kexec boot. Mark the memory range as Reserved in the EFI map so that guest OS or firmware does not use the range as a system RAM. 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/PlatformPei/PlatformPei.inf | 4 ++++ OvmfPkg/PlatformPei/MemDetect.c | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/OvmfPkg/PlatformPei/PlatformPei.inf b/OvmfPkg/PlatformPei/Plat= formPei.inf index bd0ade9f33d7..f22a60e7db0e 100644 --- a/OvmfPkg/PlatformPei/PlatformPei.inf +++ b/OvmfPkg/PlatformPei/PlatformPei.inf @@ -122,6 +122,10 @@ [FixedPcd] gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecGhcbBackupSize gUefiCpuPkgTokenSpaceGuid.PcdSevEsWorkAreaBase gUefiCpuPkgTokenSpaceGuid.PcdSevEsWorkAreaSize + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSnpSecretsBase + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSnpSecretsSize + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSnpCpuidBase + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSnpCpuidSize =20 [FeaturePcd] gUefiOvmfPkgTokenSpaceGuid.PcdCsmEnable diff --git a/OvmfPkg/PlatformPei/MemDetect.c b/OvmfPkg/PlatformPei/MemDetec= t.c index 2deec128f464..04e0c4e19f97 100644 --- a/OvmfPkg/PlatformPei/MemDetect.c +++ b/OvmfPkg/PlatformPei/MemDetect.c @@ -817,6 +817,27 @@ InitializeRamRegions ( { QemuInitializeRam (); =20 + if (MemEncryptSevSnpIsEnabled ()) { + // + // If SEV-SNP is enabled, reserve the Secrets and CPUID memory area. + // + // This memory range is given to the PSP by the hypervisor to populate + // the information used during the SNP VM boots, and it need to persis= t + // across the kexec boots. Mark it as EfiReservedMemoryType so that + // the guest firmware and OS does not use it as a system memory. + // + BuildMemoryAllocationHob ( + (EFI_PHYSICAL_ADDRESS)(UINTN) PcdGet32 (PcdOvmfSnpSecretsBase), + (UINT64)(UINTN) PcdGet32 (PcdOvmfSnpSecretsSize), + EfiReservedMemoryType + ); + BuildMemoryAllocationHob ( + (EFI_PHYSICAL_ADDRESS)(UINTN) PcdGet32 (PcdOvmfSnpCpuidBase), + (UINT64)(UINTN) PcdGet32 (PcdOvmfSnpCpuidSize), + EfiReservedMemoryType + ); + } + if (mS3Supported && mBootMode !=3D BOOT_ON_S3_RESUME) { // // This is the memory range that will be used for PEI on S3 resume --=20 2.17.1