From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (NAM11-DM6-obe.outbound.protection.outlook.com [40.107.223.75]) by mx.groups.io with SMTP id smtpd.web10.22539.1671638864871917866 for ; Wed, 21 Dec 2022 08:07:45 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@amd.com header.s=selector1 header.b=wuhElLEx; 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.223.75, mailfrom: michael.roth@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kJo1norBbJaTEIgCDY+bly01Q4UCXBHYbAZRKHbdfWb0vdmwmFpYj5+uY2JcALNt26rHSmKOU8tPv6h6ZuzIvD8RYtcKtmdrCevGMJZYWh3f+LU/QZakNGzJEyyp9TrJHAj9z/qS52L2z9czMSgGLtrFJ7c291GYwTsR85jUc0QW/aXWZNErFdZCxb+YzqLvozIvxmuTY1nlA7tL6FwxstF285hStBBYb5/GGjVgLX3MvN5DDLnBEAlVQQZwp/b5SFOrWM5ydGhjQZf0c3v/zZf/TcXs1V3522z9h+1MTSdriEJcgJhRkaO69xCslfTUdEpdzSzkyJCRFwMAVaJy4Q== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=f59gmXconZyZ9v923Eu9Ly+ke1bCER+fRmCbUMqoSj8=; b=UmahguErSSKnQIlbR7jciNZew5zP0WrMrx9o7PY33T597Egmt8KHlvmEj8XhuYAvHYgTamGdLxuhUs6zOezvWhW1yM7sw/pL1gTRHBqJ/6eIvw9GcJ7EZ510DP1C6wgUtF4sJCC5dHcwRV8GIL2sUzQV2uQ5P4mzlmeQxMk7U5REpPeZ+0mtco5ohduxKUYrAv98asXfpwN5cVJVo3kOts7+wNU+oTTCkiNYp9BRn+WIqEkHGc773VohXpbGAyTjEWcwUAKQf4CJNHTHVOV6GoXrL3oN+TzVAx0S83YfmRNBUiyb78OpMR8IUfrjkPHthL5tZ7/LE9/8dySwmprhUA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); 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=f59gmXconZyZ9v923Eu9Ly+ke1bCER+fRmCbUMqoSj8=; b=wuhElLExOp+XOJck45frEXuaFI87ZdtLSqtlEP1UKeOHRk38xDQ2juSRS2dqlV+nyFCSQehmtW2JJshngCuRK5dxKhzKD9G3ledYyO3TpichoMqP+L4KFqPY4uPu5E5Yw1kyp05mnJGrvuqrhx1wp8ECVBYFDKhhRhrnhE9EsIY= Received: from BN9P220CA0024.NAMP220.PROD.OUTLOOK.COM (2603:10b6:408:13e::29) by SJ0PR12MB6853.namprd12.prod.outlook.com (2603:10b6:a03:47b::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.16; Wed, 21 Dec 2022 16:07:43 +0000 Received: from BN8NAM11FT078.eop-nam11.prod.protection.outlook.com (2603:10b6:408:13e:cafe::76) by BN9P220CA0024.outlook.office365.com (2603:10b6:408:13e::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.21 via Frontend Transport; Wed, 21 Dec 2022 16:07:43 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT078.mail.protection.outlook.com (10.13.176.251) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5944.10 via Frontend Transport; Wed, 21 Dec 2022 16:07:42 +0000 Received: from localhost (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Wed, 21 Dec 2022 10:07:39 -0600 From: "Roth, Michael" To: CC: Tom Lendacky , , Dov Murik Subject: [PATCH 1/4] OvmfPkg/AmdSevDxe: Allocate SEV-SNP CC blob as EfiACPIReclaimMemory Date: Wed, 21 Dec 2022 10:06:48 -0600 Message-ID: <20221221160651.182143-2-michael.roth@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221221160651.182143-1-michael.roth@amd.com> References: <20221221160651.182143-1-michael.roth@amd.com> MIME-Version: 1.0 Return-Path: Michael.Roth@amd.com X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT078:EE_|SJ0PR12MB6853:EE_ X-MS-Office365-Filtering-Correlation-Id: adfa5bb6-a608-4ebd-d40b-08dae36d7df1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2gwdE2dmSleW10nDkdvz/S7hOo7Vg2y1PuUOGtZ5SXPxMGO/gsMqthGx+GOKRdBDKOWxywmi+sPlEzF4tuiA/nWu9eiWOoXqofEz4yb4JpxD6Gr9+wwWorWzLMpT0JTHzp1TN4mGkThJb5Eo3IMd77BPtx8g3xqfh3lnUcu+jf32JKOTxQLmK8Q7B69ZfL9hxeimShJU3CafQG8l7M5KO4jebsW/WQKmE2/t+DiPolzyaKkJ2dvcLYjir/WkDo8nWxdeLR1fCWZ19FI2Ud+AH6YA4LsbWy2+Ts/0PyeXsRDhsGe5AF4PazayBCSQPkdRHgVZvD6TeX6ZaDsThKFAzzjorB5Bi6RqAWtPOUWzyeQlTlZ5zZzC6OWKEvoTenTsuyEFGq+NyTO0SivarSh4md9jOaaOctGFpix4fx/E7lx2vhAkVDl0SwGYS5HzwXKrVgStBtOEaAFkDwgf8snh8PqKUbKnKprBsjc02gDPLE9JjjuS3bnWBS/hO9rBZAuIJ6JJ470wqwQUzeJp3oSI2kFyfNIIyCEuCH9v2UiDYDj3zNkSgRfDc9DYTFlGsLVOHr4pQ1rGQXnHFbTfiXzOoT4C8vWJefXocpCHSFKQ7ygODqre75zfVBKCZdwXe6pPaMBfg6/tvOlCJR4hWi3nSOsekWm8shaebFFMwnAWJHhzjf0OarZT2x+lAzsg9qb0vqbmNqtJqcfgJya8lRw0c5FhtdIixHvRnRqn1xiBVkxMqgd8VW+KeYpvOmqBAk3bW7+YWVDEkrsnLq1STlF15g== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(136003)(376002)(39860400002)(396003)(346002)(451199015)(36840700001)(40470700004)(46966006)(2906002)(36860700001)(41300700001)(86362001)(40460700003)(336012)(426003)(40480700001)(36756003)(4326008)(186003)(81166007)(82740400003)(316002)(356005)(82310400005)(26005)(8936002)(8676002)(1076003)(2616005)(83380400001)(70206006)(47076005)(16526019)(70586007)(5660300002)(6916009)(54906003)(478600001)(6666004)(44832011)(145603002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Dec 2022 16:07:42.9818 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: adfa5bb6-a608-4ebd-d40b-08dae36d7df1 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT078.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB6853 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain The SEV-SNP Confidential Computing blob contains metadata that should remain accessible for the life of the guest. Allocate it as EfiACPIReclaimMemory to ensure the memory isn't overwritten by the guest operating system later. Reported-by: Dov Murik Suggested-by: Dov Murik Signed-off-by: Michael Roth --- OvmfPkg/AmdSevDxe/AmdSevDxe.c | 62 +++++++++++++++++++++++++++-------- 1 file changed, 48 insertions(+), 14 deletions(-) diff --git a/OvmfPkg/AmdSevDxe/AmdSevDxe.c b/OvmfPkg/AmdSevDxe/AmdSevDxe.c index 662d3c4ccb..8dfda961d7 100644 --- a/OvmfPkg/AmdSevDxe/AmdSevDxe.c +++ b/OvmfPkg/AmdSevDxe/AmdSevDxe.c @@ -21,15 +21,36 @@ #include =0D #include =0D =0D -STATIC CONFIDENTIAL_COMPUTING_SNP_BLOB_LOCATION mSnpBootDxeTable =3D {=0D - SIGNATURE_32 ('A', 'M', 'D', 'E'),=0D - 1,=0D - 0,=0D - (UINT64)(UINTN)FixedPcdGet32 (PcdOvmfSnpSecretsBase),=0D - FixedPcdGet32 (PcdOvmfSnpSecretsSize),=0D - (UINT64)(UINTN)FixedPcdGet32 (PcdOvmfCpuidBase),=0D - FixedPcdGet32 (PcdOvmfCpuidSize),=0D -};=0D +STATIC=0D +EFI_STATUS=0D +AllocateConfidentialComputingBlob (=0D + OUT CONFIDENTIAL_COMPUTING_SNP_BLOB_LOCATION **CcBlobPtr=0D + )=0D +{=0D + EFI_STATUS Status;=0D + CONFIDENTIAL_COMPUTING_SNP_BLOB_LOCATION *CcBlob;=0D +=0D + Status =3D gBS->AllocatePool (=0D + EfiACPIReclaimMemory,=0D + sizeof (CONFIDENTIAL_COMPUTING_SNP_BLOB_LOCATION),=0D + (VOID **)&CcBlob=0D + );=0D + if (EFI_ERROR (Status)) {=0D + return Status;=0D + }=0D +=0D + CcBlob->Header =3D SIGNATURE_32 ('A', 'M', 'D', 'E');=0D + CcBlob->Version =3D 1;=0D + CcBlob->Reserved1 =3D 0;=0D + CcBlob->SecretsPhysicalAddress =3D (UINT64)(UINTN)FixedPcdGet32 (PcdOvmf= SnpSecretsBase);=0D + CcBlob->SecretsSize =3D FixedPcdGet32 (PcdOvmfSnpSecretsSize)= ;=0D + CcBlob->CpuidPhysicalAddress =3D (UINT64)(UINTN)FixedPcdGet32 (PcdOvmf= CpuidBase);=0D + CcBlob->CpuidLSize =3D FixedPcdGet32 (PcdOvmfCpuidSize);=0D +=0D + *CcBlobPtr =3D CcBlob;=0D +=0D + return EFI_SUCCESS;=0D +}=0D =0D EFI_STATUS=0D EFIAPI=0D @@ -38,10 +59,11 @@ AmdSevDxeEntryPoint ( IN EFI_SYSTEM_TABLE *SystemTable=0D )=0D {=0D - EFI_STATUS Status;=0D - EFI_GCD_MEMORY_SPACE_DESCRIPTOR *AllDescMap;=0D - UINTN NumEntries;=0D - UINTN Index;=0D + EFI_STATUS Status;=0D + EFI_GCD_MEMORY_SPACE_DESCRIPTOR *AllDescMap;=0D + UINTN NumEntries;=0D + UINTN Index;=0D + CONFIDENTIAL_COMPUTING_SNP_BLOB_LOCATION *SnpBootDxeTable;=0D =0D //=0D // Do nothing when SEV is not enabled=0D @@ -147,6 +169,18 @@ AmdSevDxeEntryPoint ( }=0D }=0D =0D + Status =3D AllocateConfidentialComputingBlob (&SnpBootDxeTable);=0D + if (EFI_ERROR (Status)) {=0D + DEBUG ((=0D + DEBUG_ERROR,=0D + "%a: AllocateConfidentialComputingBlob(): %r\n",=0D + __FUNCTION__,=0D + Status=0D + ));=0D + ASSERT (FALSE);=0D + CpuDeadLoop ();=0D + }=0D +=0D //=0D // If its SEV-SNP active guest then install the CONFIDENTIAL_COMPUTING_S= EV_SNP_BLOB.=0D // It contains the location for both the Secrets and CPUID page.=0D @@ -154,7 +188,7 @@ AmdSevDxeEntryPoint ( if (MemEncryptSevSnpIsEnabled ()) {=0D return gBS->InstallConfigurationTable (=0D &gConfidentialComputingSevSnpBlobGuid,=0D - &mSnpBootDxeTable=0D + SnpBootDxeTable=0D );=0D }=0D =0D --=20 2.25.1