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 511AD941920 for ; Thu, 22 Feb 2024 17:32:40 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=X3Ky54b4GB4RUV90ktIADdeo0LJc7zVapPgOzTq2tUk=; c=relaxed/simple; d=groups.io; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:Received-SPF:From:To:CC:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding:Content-Type; s=20140610; t=1708623159; v=1; b=m0DPmUzrgMATu6CFPu24lqAriv7kXMKS4/xq5Tt/s4gzr291wO94Pw6vCkf99IHneUYTkuLD xRFQBecljJzjnq96cGV4bflt8BQbSZUNE6V/EAzI5pzSQs0L1jlIVVoJzpy8LCSYy9nTMmP8az3 GhMJRHGcGphorli3mGJdVHTQ= X-Received: by 127.0.0.2 with SMTP id otVeYY7687511xb7rDVAFqnW; Thu, 22 Feb 2024 09:32:39 -0800 X-Received: from NAM11-BN8-obe.outbound.protection.outlook.com (NAM11-BN8-obe.outbound.protection.outlook.com [40.107.236.41]) by mx.groups.io with SMTP id smtpd.web10.19155.1708623158265007512 for ; Thu, 22 Feb 2024 09:32:38 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JzkXDUS2Fh2NjrWA8GwXUBI8x7juyduQIwol67jKA/e+zwYtU6FNtJdKDhucp7r7r70inqNnT7bJ8LUaSxLT4RAeBYJelOVmsOFHZYbthKRPw8tYgx7tDjXSIuRnp+5WFJ9ij7PwTx0BXfBSLocaTsLMLeEs1Xs3D5vy56HedvAmbKUtht6b3zfhrgbYsyocu9updpgrE/vZFDC2NbM/K0bxhu6YU9wWsIE+6irs4uoetTGJaTdEvB5AV4wsaLyHT7cJwfkqOwaALOWW6fKhrfyHqx+J5gc/GlZDG3suD6MATZPg4NG46RVlSWdaplodAk+0RatitgWhfoFa065Djg== 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=0ppOi82A79hRVQ2VrfH4ksMh8nRf6HjvPq9gHM82FIg=; b=cvMq/EwDK08oNBi0K5sDiSqUZ+2EQoLP+zc/f4vdm4bM1bpzpzJ2+Hb21XN/8U2dAGSblPLgFqqfr49lteRYRVJ2SxUfOGrfasIRkp0v1atyr2CC4ZKaFrx8Yy7THh6v8hxBdPhcLztedFSkq3qsShiClcIKR6muEN/1USbU7RVOvWOf/qbBuFSXAJkhTyb1W+WuBTzPzOziuhiSCaerZSeYj4w5aESVhVtTncWLsjrDfDFTSfXei4pCtx9Rsldb9BpQNV0A27po3zuVyVraxLl2DdGIBvyquC7huL+H9l0hk4lWAm5RWoXKNBzt3+9XBEoI+ptG5jvSxzUr4LxQmg== 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 (0) X-Received: from BN9PR03CA0039.namprd03.prod.outlook.com (2603:10b6:408:fb::14) by PH7PR12MB6836.namprd12.prod.outlook.com (2603:10b6:510:1b6::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.21; Thu, 22 Feb 2024 17:32:35 +0000 X-Received: from BN2PEPF000044AC.namprd04.prod.outlook.com (2603:10b6:408:fb:cafe::58) by BN9PR03CA0039.outlook.office365.com (2603:10b6:408:fb::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.43 via Frontend Transport; Thu, 22 Feb 2024 17:32:35 +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 X-Received: from SATLEXMB04.amd.com (165.204.84.17) by BN2PEPF000044AC.mail.protection.outlook.com (10.167.243.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7292.25 via Frontend Transport; Thu, 22 Feb 2024 17:32:35 +0000 X-Received: from tlendack-t1.amdoffice.net (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.2507.35; Thu, 22 Feb 2024 11:32:34 -0600 From: "Lendacky, Thomas via groups.io" To: CC: Ard Biesheuvel , Erdem Aktas , Gerd Hoffmann , Jiewen Yao , Laszlo Ersek , Liming Gao , Michael D Kinney , Min Xu , Zhiguang Liu , "Rahul Kumar" , Ray Ni , Michael Roth Subject: [edk2-devel] [PATCH v2 20/23] OvmfPkg/CcSvsmLib: Add support for the SVSM create/delete vCPU calls Date: Thu, 22 Feb 2024 11:29:59 -0600 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF000044AC:EE_|PH7PR12MB6836:EE_ X-MS-Office365-Filtering-Correlation-Id: 9e0774be-4cc1-4875-5001-08dc33cc423c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: w6dhJB/Vq6BQeL7QTj4FzKyFKBl5qi/u4N+LpzaTxrzp6/x5kcSfAAXEo9MbmHBHPyAmApjH9Gr4JIT9KksTNn2ftcJKCUQOtTpkX5jUFckD1gxZR4Q7eVUMyP2J+S+hbXvoM8lZw7Y946Drm68nclvdCYNT28CU3u65/0u4aZX/tzgshrUyAEFnx50dc2MgQ1lnlIlaB3MsYVbjhfiSBu+mvexUkdmmzkQ/ENr89Y42h5qa5aRzi10MsAPSWax2VmXvsO4Jao7qIfEgng12tb//Ff53J7axbPs2koABHQgEmDFKT0dIroSho9COYXzkqdpl7ngM4U3KE1ZcPFG+3QUqNvofOrKjPkqc7eBRxbiWlk1BWD0CAWyBovTgI4IdDB1bN7MrTXKzFIbfTk787EDrkUGaPwFLh+2E9ALbm1/YiwutHRubj0HcyXI9vXVKD1xFh5xkqnf+16dj4mjM3QEWlfbWi0RWtvHWmLL5D2m8Gr+aEjgIht0lRjztL+6mb1VcBWWDQWWfQiombpf1opKdtbT7S3MbdLu1an6ad5Wy2XvmQx5qcwEtmIutJvYAyARPyxrc2A2RKCeFiclUEzbTRsvJ9BS6N+E8YHVUlP1kN51kN3zMOPO9acmhbcgcWvt2pkvPgbVP6xlD8f9nWw== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Feb 2024 17:32:35.6892 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9e0774be-4cc1-4875-5001-08dc33cc423c 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: BN2PEPF000044AC.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6836 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,thomas.lendacky@amd.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: XBVsSDmIxBENYAjB01jPdHaYx7686176AA= Content-Transfer-Encoding: quoted-printable Content-Type: text/plain X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=m0DPmUzr; dmarc=pass (policy=none) header.from=groups.io; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4654 The RMPADJUST instruction is used to alter the VMSA attribute of a page, but the VMSA attribute can only be changed when running at VMPL0. When an SVSM is present, use the SVSM_CORE_CREATE_VCPU and SVSM_CORE_DELTE_VCPU calls to add or remove the VMSA attribute on a page instead of issuing the RMPADJUST instruction directly. Implement the CcSvsmSnpVmsaRmpAdjust() API to perform the proper operation to update the VMSA attribute. Signed-off-by: Tom Lendacky --- OvmfPkg/Library/CcSvsmLib/CcSvsmLib.c | 54 +++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/OvmfPkg/Library/CcSvsmLib/CcSvsmLib.c b/OvmfPkg/Library/CcSvsm= Lib/CcSvsmLib.c index 017ca715cee5..97fe09aa7329 100644 --- a/OvmfPkg/Library/CcSvsmLib/CcSvsmLib.c +++ b/OvmfPkg/Library/CcSvsmLib/CcSvsmLib.c @@ -377,6 +377,57 @@ CcSvsmSnpPvalidate ( CcSvsmIsSvsmPresent () ? SvsmPvalidate (Info) : BasePvalidate (Info); } =20 +/** + Perform an RMPADJUST operation to alter the VMSA setting of a page. + + Add or remove the VMSA attribute for a page. + + @param[in] Vmsa Pointer to an SEV-ES save area page + @param[in] ApicId APIC ID associated with the VMSA + @param[in] SetVmsa Boolean indicator as to whether to set o= r + or clear the VMSA setting for the page + + @retval EFI_SUCCESS RMPADJUST operation successful + @retval EFI_UNSUPPORTED Operation is not supported + @retval EFI_INVALID_PARAMETER RMPADJUST operation failed, an invalid + parameter was supplied + +**/ +STATIC +EFI_STATUS +SvsmVmsaRmpAdjust ( + IN SEV_ES_SAVE_AREA *Vmsa, + IN UINT32 ApicId, + IN BOOLEAN SetVmsa + ) +{ + SVSM_CALL_DATA SvsmCallData; + SVSM_FUNCTION Function; + UINTN Ret; + + SvsmCallData.Caa =3D (SVSM_CAA *)CcSvsmSnpGetCaa (); + + Function.Id.Protocol =3D 0; + + if (SetVmsa) { + Function.Id.CallId =3D 2; + + SvsmCallData.RaxIn =3D Function.Uint64; + SvsmCallData.RcxIn =3D (UINT64)(UINTN)Vmsa; + SvsmCallData.RdxIn =3D (UINT64)(UINTN)Vmsa + SIZE_4KB; + SvsmCallData.R8In =3D ApicId; + } else { + Function.Id.CallId =3D 3; + + SvsmCallData.RaxIn =3D Function.Uint64; + SvsmCallData.RcxIn =3D (UINT64)(UINTN)Vmsa; + } + + Ret =3D SvsmMsrProtocol (&SvsmCallData); + + return (Ret =3D=3D 0) ? EFI_SUCCESS : EFI_INVALID_PARAMETER; +} + /** Perform a native RMPADJUST operation to alter the VMSA setting of a page= . =20 @@ -444,5 +495,6 @@ CcSvsmSnpVmsaRmpAdjust ( IN BOOLEAN SetVmsa ) { - return BaseVmsaRmpAdjust (Vmsa, SetVmsa); + return CcSvsmIsSvsmPresent () ? SvsmVmsaRmpAdjust (Vmsa, ApicId, SetVmsa= ) + : BaseVmsaRmpAdjust (Vmsa, SetVmsa); } --=20 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 (#115855): https://edk2.groups.io/g/devel/message/115855 Mute This Topic: https://groups.io/mt/104512977/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-