From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mx.groups.io with SMTP id smtpd.web11.9906.1672996695438387769 for ; Fri, 06 Jan 2023 01:18:15 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=daGieo9E; spf=pass (domain: intel.com, ip: 134.134.136.31, mailfrom: jiewen.yao@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1672996695; x=1704532695; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=+xf8ruetbpFm96/HlnP3v65wSA0Y0WqU7SvdDgwyw+M=; b=daGieo9ENRqemJoe10Us2hv3zE4xWC/ecRr8xbCydoN8ZidBOqpJA4aW v8DaiYObWkZ3Og+udOzgyCSckczxKcfh3NiQqqKRseEw9DoAEgNTIknxQ tayktm03R0BuWkNnuyFfv/Sr/uwedq11FEMBjG2C14/ZHqEUiz2rRhbx4 Z1eL+bVslosfvukzY92bWTPydatW6foGMEALm6N7dLj5o+HRqk7+/DY/T wT4ODuNF6vvy62hComtf9/7fI9V2bk2ZycJuWsd49URNUi7/gblmHpY20 zmhMhks4lumyKPfIcYV9iA8QkB4eLLJr5qLbB/n0Q0ZE45538MKV3ZlGS g==; X-IronPort-AV: E=McAfee;i="6500,9779,10581"; a="384746594" X-IronPort-AV: E=Sophos;i="5.96,304,1665471600"; d="scan'208";a="384746594" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jan 2023 01:18:14 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10581"; a="829851397" X-IronPort-AV: E=Sophos;i="5.96,304,1665471600"; d="scan'208";a="829851397" Received: from fmsmsx603.amr.corp.intel.com ([10.18.126.83]) by orsmga005.jf.intel.com with ESMTP; 06 Jan 2023 01:18:14 -0800 Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Fri, 6 Jan 2023 01:18:14 -0800 Received: from fmsmsx612.amr.corp.intel.com (10.18.126.92) by fmsmsx611.amr.corp.intel.com (10.18.126.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Fri, 6 Jan 2023 01:18:13 -0800 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx612.amr.corp.intel.com (10.18.126.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16 via Frontend Transport; Fri, 6 Jan 2023 01:18:13 -0800 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (104.47.66.46) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.16; Fri, 6 Jan 2023 01:18:13 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WSh/bk482FlVNS6X50Fbi+XZNt4RC/29jym20K6vMNlmCNbLhfiqNlzO30rc5ABYm7J3JS3uWClIhHGd1CK3N5tnxTgkyKPC2mQCJOitUaW6MykdlN6URBrDqSjpalPINZWeaE9qLMyQ+v1FLKSJ1+7uAfnII1UCGbzkVprM+0eLTabcm1ak5Vg6icHX3Smh+LH+8j8t3xtMQGENviuUGPXUWiF15chtYsk+fYeObFHzySrU8lJxBPa6CccGaYVgnYkg41qMnRmkEppOzAW5R2glUEgHlrk8hFwzce6f7/Qxexkp6U+y29tRyML/bSVZVUs/8pzdgtT2L0QmtQwmIg== 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=t/MiozBROUSQz6kEhkkSCraADMSMMha+NAvND8/pe4w=; b=iE+nyEDsYTaKwZbW6UP0O6Q4p1QTBVa45kNYoHQVs4s/LJBQ1YNtxz2XMkngi9DDB/GXMJgBBVbm1B2TjMglwFpkUembOAKFCCHWkxmBz91WBTvjd1jqsO4E98XZVwv18Wfj+XJrC/P3DV30ejT5BqutkSzwahPP5QmDJF9oY0lPZNKDRxMfnHkWOn9PLH/XqTHgMbqRHlmTFJxATvIoWPbQuie+oFzOKDQiQ6QD5xW8rCa6QPgkgPrYe0mFjhBtjLxda+KVlltMYXXQY3HiLMX3Kf7FqNjSxND16LJkYfF3JNCr9Bs/FC2XwgJXeBaSKPsXh86lqvNaYkZ4dqOJow== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from MW4PR11MB5872.namprd11.prod.outlook.com (2603:10b6:303:169::14) by BN9PR11MB5259.namprd11.prod.outlook.com (2603:10b6:408:134::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.19; Fri, 6 Jan 2023 09:18:10 +0000 Received: from MW4PR11MB5872.namprd11.prod.outlook.com ([fe80::5f56:1bdc:2eae:c041]) by MW4PR11MB5872.namprd11.prod.outlook.com ([fe80::5f56:1bdc:2eae:c041%9]) with mapi id 15.20.5944.019; Fri, 6 Jan 2023 09:18:10 +0000 From: "Yao, Jiewen" To: "devel@edk2.groups.io" , "Michael.Roth@amd.com" CC: Tom Lendacky , "Ni, Ray" , "Dov Murik" Subject: Re: [edk2-devel] [PATCH 1/4] OvmfPkg/AmdSevDxe: Allocate SEV-SNP CC blob as EfiACPIReclaimMemory Thread-Topic: [edk2-devel] [PATCH 1/4] OvmfPkg/AmdSevDxe: Allocate SEV-SNP CC blob as EfiACPIReclaimMemory Thread-Index: AQHZFYLhOGzjXR0cw0OEtgSAfYsF7K6RM7QQ Date: Fri, 6 Jan 2023 09:18:10 +0000 Message-ID: References: <20221221160651.182143-1-michael.roth@amd.com> <20221221160651.182143-2-michael.roth@amd.com> In-Reply-To: <20221221160651.182143-2-michael.roth@amd.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MW4PR11MB5872:EE_|BN9PR11MB5259:EE_ x-ms-office365-filtering-correlation-id: 3f639b0e-0f6b-4a43-0eb8-08daefc6ee00 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: svGhdIjxN8Eo0wS7i5CrDmx6gC7Xjxx0NJpIXyFwfTCJe7SV6Ox1Q7xA1kJq0CcA+Gn/XkvDQ9oujLxNbi8BJnlaSvNRgWdNJyv+SINiHsRz58/ENBMjuhkzSlacUEIW01ZpeEHPLHuB64ZOT9nZm4bwS11vCU5jVIu0f2BXh4+R5zTLl4c1Z30ZYHxmJ8/Xp5oRNlJCRgO3+J74Pzuf3Qf7CNmI6pW2tmhgWiAHAnNEQL4mBMGKajIBRvzxt9EZoQw9M8fjaoF9R64B2BIm7jwrzcX5cnWH/6oM2yPtXoOU+9sQlrE49p2FqltKFTNymFqvNAGSN7HTAhBt32OFnRhnmiDAJc7Vo7PdyFAyDqTzjR9pBR+qLJ9OMtBp213JAhOgZb6Rb1uPkz4CuxFt18HRS02qtjY2B4A78x953ow/VWMO+bvYlp0lZhz4QYfV3ZzUM6L3WkOCebjHCUENKJvaYIQmrbIpkQq23Fj7DBTQP/8+gujoEqKGXi/LGpQoUsXMju7bn20paudBsJ7fja/ejmNj3xfitsAFJdX2zar48N7QN1w4uMUnaKXVE/WxPVZwZ3fSDQe9k6zD5wHZwEfuophEUaHtCr38+fK3ZtBEHgavN/cCgaqt3AioaU31dcAdeeNOAbx7OjZ4+UNXWSogQWghvsQqQ7snrmWahQYkwtfGw20cr+U7hKvwVSHHvwjuDCsg/udDS7JmW0JYR27Jcu5S6JyvE+77sgdZwgin2H99p0792hwgdZwllAqXjMLRix5Vawatzk+MjsvDHfhsF9TzOwKVTv/J4qDqLnk= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW4PR11MB5872.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(39860400002)(136003)(366004)(346002)(396003)(376002)(451199015)(76116006)(5660300002)(4326008)(41300700001)(66946007)(8676002)(64756008)(8936002)(66476007)(66899015)(66556008)(54906003)(316002)(110136005)(52536014)(66446008)(26005)(71200400001)(7696005)(6506007)(966005)(53546011)(478600001)(186003)(9686003)(2906002)(122000001)(86362001)(55016003)(83380400001)(38100700002)(82960400001)(38070700005)(33656002)(145603002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?dwna33jSoqLKXTtsGx/yh6TD+LEQf/VOTkDdNb2ddpYM9CGVaxcuhw2Pl9XC?= =?us-ascii?Q?SaKSILkj6V59XlR6OpRu++Fed47ZWv7efSh/bybOh7Q73y8aeD1Ve9od82fH?= =?us-ascii?Q?36SPhVM2qUcGHZOR7zCsn+08KS+Wv5NS20Gt2d0HLDLoL/yD32xZyEV1DTzp?= =?us-ascii?Q?OAFhQ4LfK/PXEf5Pjd84bOTGCPNmtvvdOBw8rNIQYUk8ExS6NNzkhcQ0FtOf?= =?us-ascii?Q?doODOH9m7seleF77gxWTA84HwD2dVA5JFEl56Sq+LozOhrQ0lsN3tPF6Ukly?= =?us-ascii?Q?Yj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srPFQmNmBBx/UoTseUViyamGaf?= =?us-ascii?Q?tjIBFMdXER9z9w8k67hVnpnozPwNB7R+y9EIkmfrXDzsQZqdZsLnj+cHMcmA?= =?us-ascii?Q?o4AzAdalRh+UvOeBG2Wv+Lm1iIjvGUJDPGflX05ixff196LDBzpSEWnysUuC?= =?us-ascii?Q?60b9nmkcnqVfiNXu9GxdT4fXOxqazIbcdKjrDjizcPZKzbHOmBSVoJ4ksc8k?= =?us-ascii?Q?fjA/56kX4qZoI72etMF9tW8q7qC3D9mgj2VQcaHDoGiJTuGdktDm4IW0co6h?= =?us-ascii?Q?u1wwgZL0FTWhvywKkbN5ECj+3ebywAY689g5Jpt98XrRe1kyYPJGvNxXj+Y7?= =?us-ascii?Q?5EBmfWD8lblx4WXUJOz/5Fy7jxZx/NI6PvXlzbmOYHJopujZ1mjxYmc+6flr?= =?us-ascii?Q?aAAJ371dT/o5ldwSV7OvVbeuj2VHBJmEX/bSBi3V?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW4PR11MB5872.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3f639b0e-0f6b-4a43-0eb8-08daefc6ee00 X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Jan 2023 09:18:10.1265 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: hjY9dpZLtT5XCl9aHnsrhpmDG2JDXpzVV5ggRUGpkDBkn5CMWLXnn6n7AQ8SYA5RSvkkWug5BT8R52xG3pIMgA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR11MB5259 Return-Path: jiewen.yao@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Are you sure you want to use EfiACPIReclaimMemory ? Usually EfiACPIReclaimMemory is only for ACPI table, which can be reclaimed= and used by OS, after copy ACPI table. If you want to claim the memory owned by firmware (not owned by OS), you ne= ed use ACPINvs or reserved. Although I don't fully understand SEV, this seems suspicious. Please double confirm if this is really you want. Thank you Yao, Jiewen > -----Original Message----- > From: devel@edk2.groups.io On Behalf Of Roth, > Michael via groups.io > Sent: Thursday, December 22, 2022 12:07 AM > To: devel@edk2.groups.io > Cc: Tom Lendacky ; Ni, Ray > ; Dov Murik > Subject: [edk2-devel] [PATCH 1/4] OvmfPkg/AmdSevDxe: Allocate SEV-SNP CC > blob as EfiACPIReclaimMemory >=20 > 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. >=20 > 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(-) >=20 > 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 >=20 > #include >=20 >=20 >=20 > -STATIC CONFIDENTIAL_COMPUTING_SNP_BLOB_LOCATION > mSnpBootDxeTable =3D { >=20 > - SIGNATURE_32 ('A', 'M', 'D', 'E'), >=20 > - 1, >=20 > - 0, >=20 > - (UINT64)(UINTN)FixedPcdGet32 (PcdOvmfSnpSecretsBase), >=20 > - FixedPcdGet32 (PcdOvmfSnpSecretsSize), >=20 > - (UINT64)(UINTN)FixedPcdGet32 (PcdOvmfCpuidBase), >=20 > - FixedPcdGet32 (PcdOvmfCpuidSize), >=20 > -}; >=20 > +STATIC >=20 > +EFI_STATUS >=20 > +AllocateConfidentialComputingBlob ( >=20 > + OUT CONFIDENTIAL_COMPUTING_SNP_BLOB_LOCATION **CcBlobPtr >=20 > + ) >=20 > +{ >=20 > + EFI_STATUS Status; >=20 > + CONFIDENTIAL_COMPUTING_SNP_BLOB_LOCATION *CcBlob; >=20 > + >=20 > + Status =3D gBS->AllocatePool ( >=20 > + EfiACPIReclaimMemory, >=20 > + sizeof (CONFIDENTIAL_COMPUTING_SNP_BLOB_LOCATION), >=20 > + (VOID **)&CcBlob >=20 > + ); >=20 > + if (EFI_ERROR (Status)) { >=20 > + return Status; >=20 > + } >=20 > + >=20 > + CcBlob->Header =3D SIGNATURE_32 ('A', 'M', 'D', 'E'); >=20 > + CcBlob->Version =3D 1; >=20 > + CcBlob->Reserved1 =3D 0; >=20 > + CcBlob->SecretsPhysicalAddress =3D (UINT64)(UINTN)FixedPcdGet32 > (PcdOvmfSnpSecretsBase); >=20 > + CcBlob->SecretsSize =3D FixedPcdGet32 (PcdOvmfSnpSecretsSiz= e); >=20 > + CcBlob->CpuidPhysicalAddress =3D (UINT64)(UINTN)FixedPcdGet32 > (PcdOvmfCpuidBase); >=20 > + CcBlob->CpuidLSize =3D FixedPcdGet32 (PcdOvmfCpuidSize); >=20 > + >=20 > + *CcBlobPtr =3D CcBlob; >=20 > + >=20 > + return EFI_SUCCESS; >=20 > +} >=20 >=20 >=20 > EFI_STATUS >=20 > EFIAPI >=20 > @@ -38,10 +59,11 @@ AmdSevDxeEntryPoint ( > IN EFI_SYSTEM_TABLE *SystemTable >=20 > ) >=20 > { >=20 > - EFI_STATUS Status; >=20 > - EFI_GCD_MEMORY_SPACE_DESCRIPTOR *AllDescMap; >=20 > - UINTN NumEntries; >=20 > - UINTN Index; >=20 > + EFI_STATUS Status; >=20 > + EFI_GCD_MEMORY_SPACE_DESCRIPTOR *AllDescMap; >=20 > + UINTN NumEntries; >=20 > + UINTN Index; >=20 > + CONFIDENTIAL_COMPUTING_SNP_BLOB_LOCATION *SnpBootDxeTable; >=20 >=20 >=20 > // >=20 > // Do nothing when SEV is not enabled >=20 > @@ -147,6 +169,18 @@ AmdSevDxeEntryPoint ( > } >=20 > } >=20 >=20 >=20 > + Status =3D AllocateConfidentialComputingBlob (&SnpBootDxeTable); >=20 > + if (EFI_ERROR (Status)) { >=20 > + DEBUG (( >=20 > + DEBUG_ERROR, >=20 > + "%a: AllocateConfidentialComputingBlob(): %r\n", >=20 > + __FUNCTION__, >=20 > + Status >=20 > + )); >=20 > + ASSERT (FALSE); >=20 > + CpuDeadLoop (); >=20 > + } >=20 > + >=20 > // >=20 > // If its SEV-SNP active guest then install the > CONFIDENTIAL_COMPUTING_SEV_SNP_BLOB. >=20 > // It contains the location for both the Secrets and CPUID page. >=20 > @@ -154,7 +188,7 @@ AmdSevDxeEntryPoint ( > if (MemEncryptSevSnpIsEnabled ()) { >=20 > return gBS->InstallConfigurationTable ( >=20 > &gConfidentialComputingSevSnpBlobGuid, >=20 > - &mSnpBootDxeTable >=20 > + SnpBootDxeTable >=20 > ); >=20 > } >=20 >=20 >=20 > -- > 2.25.1 >=20 >=20 >=20 >=20 >=20