From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id EFA15AC0B44 for ; Fri, 2 Feb 2024 06:48:25 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=jSqbHV8VGp3SgOb/wHepOx0iV3YQYLniG5H4BQTPnSA=; c=relaxed/simple; d=groups.io; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:From:To:CC:Subject:Thread-Topic:Thread-Index:Date:Message-ID:References:In-Reply-To:Accept-Language:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1706856504; v=1; b=FkfL4+plpP+5WKoVJnXy8kPbRN4FRijgmHwUj5aiUGAx3W/YaTTBM3wqHa8qkcuNUQrJt/fM ulBaSfZDn36UVdT8PASFX48ho2EzINLsNLfnjPj/iqxHVuHyF9QWUKGuQQl9nImhFOwt508pxm/ ZAGYMabICCZmfRF0SEH9lCwc= X-Received: by 127.0.0.2 with SMTP id 6MOmYY7687511xzADCmho3Zb; Thu, 01 Feb 2024 22:48:24 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) by mx.groups.io with SMTP id smtpd.web10.17789.1706856503778980219 for ; Thu, 01 Feb 2024 22:48:23 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10971"; a="10834209" X-IronPort-AV: E=Sophos;i="6.05,237,1701158400"; d="scan'208";a="10834209" X-Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Feb 2024 22:48:23 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10971"; a="932394063" X-IronPort-AV: E=Sophos;i="6.05,237,1701158400"; d="scan'208";a="932394063" X-Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by fmsmga001.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 01 Feb 2024 22:48:22 -0800 X-Received: from fmsmsx612.amr.corp.intel.com (10.18.126.92) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 1 Feb 2024 22:48:22 -0800 X-Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) 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.35; Thu, 1 Feb 2024 22:48:22 -0800 X-Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35 via Frontend Transport; Thu, 1 Feb 2024 22:48:22 -0800 X-Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.101) by edgegateway.intel.com (192.55.55.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Thu, 1 Feb 2024 22:48:21 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Mf9Teg8zLi/iazK7Yj3UNGi3ZJv4oCdvE4jeW9PeEnVP/WX4yA2AOPuo+ynbUNGoQgA+ZTIQZQVM3bVcZq0DzGkL/sM9WX8EEg4UygokLMdItmccu/XsZwY9ozn0FDj2F+zgHY3k/kFYAFIIXmOkGV5vt9W/4Ne0m+OvvdEZdSuYb5nsz3b0GSKA0bu+07ksrtxYda+zpYqBTreJSi15f8a7/SaMGv5KTyo2fC7fG5Gz3AswVOVCDrXFFzBKvlGyXGbVK7S7UC14wq6CMfzzgRH3Ofekh8OfvJ57a7kPcLzTznWB7RHndJoWv/pNyG2eokQwMM2+ObRp8LXinRX5Ug== 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=4Z/4Fn9Tm9Ynf+JJSxHgy08dXbRAAaK2fqP3VaQH5Ok=; b=jSxw14DARPqbPP1IkuPmmxH7xs6L1zV4gXIfigNDm8XUHbPTy/Q8RIj2y80R6BeYyQehUwHJvlUD075IpFdSVPxzkOuvjvKiuS+wdL/KPy4N8rXoiYJg8kbVs6UCrl8ymDJJ1MPce16faLLM1tQMfDTADLLfV5bxiPxF6DjVOba953CbISUwH728/M3LoNxhO2KM+y/H2ZgsJvkXMPO1ZRwJigGLM0w7CbSd57zldriMnzFqIg9RI+cFIc9XKMYgF72O0FfRltYopo2oGZ8CbqJmoUWkixB6VJpHJEfsNnH3IlMP++OQ8tq5YhBl2NOFl4X7zqvRKcqcDANlEM+5/Q== 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 X-Received: from MN6PR11MB8244.namprd11.prod.outlook.com (2603:10b6:208:470::14) by SA2PR11MB5163.namprd11.prod.outlook.com (2603:10b6:806:113::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.30; Fri, 2 Feb 2024 06:48:19 +0000 X-Received: from MN6PR11MB8244.namprd11.prod.outlook.com ([fe80::fdd3:11d7:1c15:6c2d]) by MN6PR11MB8244.namprd11.prod.outlook.com ([fe80::fdd3:11d7:1c15:6c2d%7]) with mapi id 15.20.7228.029; Fri, 2 Feb 2024 06:48:19 +0000 From: "Ni, Ray" To: Tom Lendacky , "devel@edk2.groups.io" CC: Ard Biesheuvel , "Aktas, Erdem" , Gerd Hoffmann , "Yao, Jiewen" , Laszlo Ersek , Liming Gao , "Kinney, Michael D" , "Xu, Min M" , "Liu, Zhiguang" , "Kumar, Rahul R" , Michael Roth Subject: Re: [edk2-devel] [PATCH 14/16] UefiCpuPkg/MpInitLib: AP creation support under an SVSM Thread-Topic: [PATCH 14/16] UefiCpuPkg/MpInitLib: AP creation support under an SVSM Thread-Index: AQHaUKUtop24LunXxkObrEojBRFGsLD2pkMg Date: Fri, 2 Feb 2024 06:48:19 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MN6PR11MB8244:EE_|SA2PR11MB5163:EE_ x-ms-office365-filtering-correlation-id: 10cb50ea-d62c-4e37-f554-08dc23baf0f3 x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: 8gZ0qFO38OZHCLHvibCwdtQSLgGVBJV7/ddG1qRFgh1ud1g83vhxbaemZ0jf/1bEfqNjYAEWnR9W7E+A6bkm+fzLB04Rl8Ti8gZfuZvOS9Y2FCYRuNKg8f5HwLlRS52Ng+iBZNtksj2Y+/jBCvt+VD/FbgasNBExODln1sXmSeKLII7rISBSY0jaAEKEMOvevKvbsqJjctg4LtPoYgzPcLt3r04SF3g+vwD5A+Cg3joaWCR1kstfonemrsuAd0aYcREkHNOBBTnNnqHKO6jJG3hMJbkDGcqMwhaKy8plCj9vqSMDb2siYv+aPmAvO2Z6JvQ4bFei8qKJEnoomcxh3wrIHfdHiIO6cH8DsGVsIY3PiAdsdf7nkhDvfVZLpFBWZNaos+qF4MWZ1s1eZ1ojDhJNcoykqO7oR8yzJ6VkaaNIW6PcyugQdfuYWq/Ka5gonjMsLQ18fB/49YG6hNgIqlVi4QqTrHagQZAmZf1nj9hBTpycrGBPiUbZzIknZSoYe8khn7Yso1Hehyq0Lym6MsoWES20QVc6u8cFySJYQxCf5mzE5gKJPCtHDgq8turkp6l953Xw/zeUAy1KP6zjPQhQ916bU1MGq0565akcxyA= x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?T/CPpCdPtdR5FEYZSrO34lsSBoFCNue8EB8lpvDIhUqYUO8mBUdTxgaILX92?= =?us-ascii?Q?sQmPuCZgLrVrnXbTYpezmcAB86ECedDbIEL5hpXM8gcwdRA36CoLgKOJ4PAM?= =?us-ascii?Q?wlLI+z34ePT9Frh0Y22lsB6va3rAJkF2HAMFOHk4nE+fORMAwCc/IDR59w8N?= =?us-ascii?Q?28/Zzz4hidjTIMsHAuxNUSNg2A8A9SogzbhlplS1ISBLV8lUZRBPu7PHQvLh?= =?us-ascii?Q?E/4gCnlxIffdffDowJG611AIBtC1RLowEebmhOhIIxzKpNvH2pDMoJFW3F75?= =?us-ascii?Q?s9i5QVwW1/LYUC9gRy9Bz3/NcY8oEfrRnkki2hsmI76vHxvPL/4n3PA4fPVq?= =?us-ascii?Q?G10A19mfCC9Jdtjwa/sjIPoheJ62lNB+23YIAz98BqvtNTVaheuRbun67Q38?= =?us-ascii?Q?9FxktbJTQ8hm8M3Tx6B4bY5MEYF1ATEuNBxAYf5AWiJZ8XMmIJaUI3uuXXvC?= =?us-ascii?Q?HXKkPQBf7ekknCBb4ap73frqhAn4XcL0Eg1rkUIdb+YzByFKSWXeTBT/NMGf?= =?us-ascii?Q?4YWEMqBD0N5fC10zDsjdmIR/DL4j9TmazCc1HmYO1elQ20OnsfYNUd/AKlc0?= =?us-ascii?Q?+9VdIQKKHtw6o9ukLi66aSk7ZQmOoy8RoKFjsFBDiQ00Cq+0fZa9hbKQD0fO?= =?us-ascii?Q?mLJvGBO342BtyWBC2zqQUtityf0i4DtXRsn6B4t9n6pmqSVX2VaNgF64W7gV?= =?us-ascii?Q?2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-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MN6PR11MB8244.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 10cb50ea-d62c-4e37-f554-08dc23baf0f3 X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Feb 2024 06:48:19.2670 (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: /EG9RzsJ2K3WzrfElIbmsP+eF5nl/3v4fla4hjQcPSe4CW4m786JCMgZsSj1GEjcNppRc3Wwu/49fW79hoVy+w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR11MB5163 X-OriginatorOrg: intel.com Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,ray.ni@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: 9DHfczlybzwqzzDtZQUVByA2x7686176AA= Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=FkfL4+pl; arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}"); dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io Acked-by: Ray Ni Thanks, Ray > -----Original Message----- > From: Tom Lendacky > Sent: Saturday, January 27, 2024 6:13 AM > To: devel@edk2.groups.io > Cc: Ard Biesheuvel ; Aktas, Erdem > ; Gerd Hoffmann ; Yao, > Jiewen ; Laszlo Ersek ; Liming > Gao ; Kinney, Michael D > ; Xu, Min M ; Liu, > Zhiguang ; Kumar, Rahul R > ; Ni, Ray ; Michael Roth > > Subject: [PATCH 14/16] UefiCpuPkg/MpInitLib: AP creation support under an > SVSM >=20 > BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4654 >=20 > When running under an SVSM, the VMPL level of the APs that are started > must match the VMPL level provided by the SVSM. Additionally, each AP > must have a Calling Area for use with the SVSM protocol. Update the AP > creation to properly support running under an SVSM. >=20 > Signed-off-by: Tom Lendacky > --- > UefiCpuPkg/Library/MpInitLib/X64/AmdSev.c | 19 +++++++++++++------ > 1 file changed, 13 insertions(+), 6 deletions(-) >=20 > diff --git a/UefiCpuPkg/Library/MpInitLib/X64/AmdSev.c > b/UefiCpuPkg/Library/MpInitLib/X64/AmdSev.c > index 6186a8d71521..9b00c945e13d 100644 > --- a/UefiCpuPkg/Library/MpInitLib/X64/AmdSev.c > +++ b/UefiCpuPkg/Library/MpInitLib/X64/AmdSev.c > @@ -55,6 +55,7 @@ SevSnpPerformApAction ( > } >=20 > ExitInfo1 =3D (UINT64)ApicId << 32; > + ExitInfo1 |=3D (UINT64)SaveArea->Vmpl << 16; > ExitInfo1 |=3D Action; > ExitInfo2 =3D (UINT64)(UINTN)SaveArea; >=20 > @@ -115,6 +116,7 @@ SevSnpCreateSaveArea ( > UINT32 ApicId > ) > { > + UINTN PageCount; > UINT8 *Pages; > SEV_ES_SAVE_AREA *SaveArea; > IA32_CR0 ApCr0; > @@ -124,13 +126,18 @@ SevSnpCreateSaveArea ( > UINTN StartIp; > UINT8 SipiVector; >=20 > + // > + // When running under an SVSM, a Calling Area page is also needed > + // > + PageCount =3D CcExitSnpSvsmPresent () ? 2 : 1; > + > if (CpuData->SevEsSaveArea =3D=3D NULL) { > // > // Allocate a page for the SEV-ES Save Area and initialize it. Due t= o AMD > // erratum #1467 (VMSA cannot be on a 2MB boundary), allocate an ext= ra > page > // to choose from to work around the issue. > // > - Pages =3D AllocateReservedPages (2); > + Pages =3D AllocateReservedPages (PageCount + 1); > if (!Pages) { > return; > } > @@ -139,12 +146,12 @@ SevSnpCreateSaveArea ( > // Since page allocation works by allocating downward in the address= space, > // try to always free the first (lower address) page to limit possib= le holes > // in the memory map. So, if the address of the second page is 2MB a= ligned, > - // then use the first page and free the second page. Otherwise, free= the > + // then use the first page and free the last page. Otherwise, free t= he > // first page and use the second page. > // > if (_IS_ALIGNED (Pages + EFI_PAGE_SIZE, SIZE_2MB)) { > SaveArea =3D (SEV_ES_SAVE_AREA *)Pages; > - FreePages (Pages + EFI_PAGE_SIZE, 1); > + FreePages (Pages + (EFI_PAGE_SIZE * PageCount), 1); > } else { > SaveArea =3D (SEV_ES_SAVE_AREA *)(Pages + EFI_PAGE_SIZE); > FreePages (Pages, 1); > @@ -162,7 +169,7 @@ SevSnpCreateSaveArea ( > } > } >=20 > - ZeroMem (SaveArea, EFI_PAGE_SIZE); > + ZeroMem (SaveArea, EFI_PAGE_SIZE * PageCount); >=20 > // > // Propogate the CR0.NW and CR0.CD setting to the AP > @@ -238,10 +245,10 @@ SevSnpCreateSaveArea ( >=20 > // > // Set the SEV-SNP specific fields for the save area: > - // VMPL - always VMPL0 > + // VMPL - based on current mode > // SEV_FEATURES - equivalent to the SEV_STATUS MSR right shifted 2 b= its > // > - SaveArea->Vmpl =3D 0; > + SaveArea->Vmpl =3D CcExitSnpGetVmpl (); > SaveArea->SevFeatures =3D AsmReadMsr64 (MSR_SEV_STATUS) >> 2; >=20 > SevSnpPerformApAction (SaveArea, ApicId, > SVM_VMGEXIT_SNP_AP_CREATE); > -- > 2.42.0 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#115025): https://edk2.groups.io/g/devel/message/115025 Mute This Topic: https://groups.io/mt/103986475/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-