From nobody Sun Feb 8 11:21:28 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+97705+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1671657793230467.1770004572239; Wed, 21 Dec 2022 13:23:13 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id co4eYY1788612xKZOsANosCi; Wed, 21 Dec 2022 13:23:12 -0800 X-Received: from NAM12-BN8-obe.outbound.protection.outlook.com (NAM12-BN8-obe.outbound.protection.outlook.com [40.107.237.56]) by mx.groups.io with SMTP id smtpd.web11.22419.1671638927163955884 for ; Wed, 21 Dec 2022 08:08:47 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ipApf3uZstrnFxSjCycGlbFCrD26D9lVEtrIcKbU603uU7yzivLNVdzqu9hCVUwqITuVKq45axHB8ufN0i3Q8a+kNUtcLaPK/+eJ3jah/C1Fq0U45n2R/iAbc4sgOSSVFzp/irz/PjUOKmbFScZwY5oHzrNYoS3tSqFGm0PuupeHrbsXuZsXI+SuB47nyNJ+xS3PnFqTysOcGcJw5C7hr7jECHMU6sA95RZaaXbI5qWbe7dZ8ypIKP8i7wpiqg4Cmmn0gm86oW2TzFQOxtn+fwQZg8IJMHErvnNM8RZz1F5aj6wBI3PJjSxHPZm2AA7c4O07np/CVEf19INsQ7vFTQ== 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=zfLZ1JJvwUGX30osJb4HaE3fh7416kByisWk4zm1Tos=; b=fTW8UR2Wq5B7VdQrVp4PiMq7s27b/VeoFUzoa3OSXnqBP3zqQDA7fAWXZYv3pUBhuT1EBb2zEJJZuJY0LqWk/vgzZ/baDE8Rj8y060ExsI+bQkfqN1o2m5ltrXcIBifvpEghd1lkIY0bx1BTqvDrajHMtFWPuxZYqBNHBmrOVbl+nvwBLU9T2cr2wPd406NZ2h3sgfhY5zjfG3yZAM3KsvuhFrgw4EeE9MdRFoMGmOMr1latG7LNI8g25Tf5LWJatfWW66HkZvvkULTLwvqtOoLY80AAebIU9Yl72/y2sgTRXOvYbi2CC0ZFbf4GxcdnbDtu1LglgvAWvYEyuf2M/g== 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 X-Received: from BN9PR03CA0233.namprd03.prod.outlook.com (2603:10b6:408:f8::28) by CY5PR12MB6550.namprd12.prod.outlook.com (2603:10b6:930:42::6) 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:08:44 +0000 X-Received: from BN8NAM11FT007.eop-nam11.prod.protection.outlook.com (2603:10b6:408:f8:cafe::2b) by BN9PR03CA0233.outlook.office365.com (2603:10b6:408:f8::28) 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:08:44 +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 (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+97705+1787277+3901457@groups.io; helo=mail02.groups.io; 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 BN8NAM11FT007.mail.protection.outlook.com (10.13.177.109) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5944.6 via Frontend Transport; Wed, 21 Dec 2022 16:08:44 +0000 X-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:08:42 -0600 From: "Roth, Michael via groups.io" To: CC: Tom Lendacky , Subject: [edk2-devel] [PATCH 4/4] OvmfPkg/CcExitLib: Use documented XSave area base size for SEV-SNP Date: Wed, 21 Dec 2022 10:06:51 -0600 Message-ID: <20221221160651.182143-5-michael.roth@amd.com> In-Reply-To: <20221221160651.182143-1-michael.roth@amd.com> References: <20221221160651.182143-1-michael.roth@amd.com> MIME-Version: 1.0 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: BN8NAM11FT007:EE_|CY5PR12MB6550:EE_ X-MS-Office365-Filtering-Correlation-Id: f4f3475e-75f5-4baf-a5b5-08dae36da2b8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: qed7C4ndM4aTEgp+NdFgjohyMqmod/iNMN3WLLc20eR9Xii7++MFxvH49yblBzBTvyOYVNjdaNCdoj+GPEOtfLzVdkozDdUdLvQNRLUgAPSL8tfmdNm63u2KcOj+IzDJ2Xuzg2T8UTi1adZ6YWLFD70bfMJMSaubYCnaWrC8K/BHmdUJkvX3uPUfTxEzsDq34/8fU51sNLf9BUtp6GqggcPsV+7IUog6PC+8Pw7vYSNqIGy0B5mHUBKhHHJB2y39vcMM0PQGngHHBNTb3NvcAz6GzH1Zad3eTdnOPZB7aDYnDYKJ6h+96ilhFHG87O9fqo0CytpS9KJGN0DKJ5NqTk/c/Q4fSrXAYkCIC6M8E5eYgoxPgPo2NeiSGIid9CZAzsWrR9yFzTbtGGbYPd7SpLpeGbiDadtrSLq2HkC2ZT9Tz+Gx3uerr2fhUJhPFQhDNSigu9fg9OskFb6v+tkLkrilmsjgvdWWkV4g5ao6v3hb3Wc1sBsG/rqid4tVrzCczqJUQ9KK4j+pSXrRWFqc8RF9j8DmAzMd87Hu417XPew/i2CcGqsz3nC29qJwTqmz1bKpeKKzK76qWaEHFArVSBqnUyKaHVgtJ9TMVsaMp4IPFw+PE1rD/LctI1jO+TsovavqT2VA9zG4PJ76+YII5OvbdVAAsj2rDXImwGA1RdpxNSZiI0BM6wulevJRH7fAyzYz9wanRSG8Yr8U+bGQDOuEvM8k5TmCT+93AULPZoE= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Dec 2022 16:08:44.6828 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f4f3475e-75f5-4baf-a5b5-08dae36da2b8 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: BN8NAM11FT007.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6550 Precedence: Bulk List-Unsubscribe: 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,Michael.Roth@amd.com X-Gm-Message-State: N2vz86jIgOgvKDysRfnEtJUCx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1671657792; bh=Y6MIdqBoMVk9n4sSeurXL03yUrnKdPCvXGb3pI/HSYA=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=T6JoahDoB+U2EkVP17Ug+ka6sgjGrluqhq8h6x1voJn3TkKPBgXsYn8EecOkWoV3EXR 6Lh1jZRbtMIRBbUV7ZArOtgME77bSsK6tKU61J5+TrK7jHOpE72luTTm8MZ2jeORiLRan GWFnzhnJp74gknGE3rW8sAAzht2x8QmAK/s= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1671657793636100035 Content-Type: text/plain; charset="utf-8" Currently OVMF tries to rely on the base size advertised via the CPUID table entries corresponding to leaf 0xD, sub-leafs 0x0/0x1. This will generally work for KVM guests, but might not for other SEV-SNP hypervisor implementations. Make the handling more robust by simply using the base area size documented by the APM. Signed-off-by: Michael Roth Acked-by: Jiewen Yao Reviewed-by: Tom Lendacky --- OvmfPkg/Library/CcExitLib/CcExitVcHandler.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/OvmfPkg/Library/CcExitLib/CcExitVcHandler.c b/OvmfPkg/Library/= CcExitLib/CcExitVcHandler.c index cd117d5a31..f985dcff8d 100644 --- a/OvmfPkg/Library/CcExitLib/CcExitVcHandler.c +++ b/OvmfPkg/Library/CcExitLib/CcExitVcHandler.c @@ -1647,8 +1647,6 @@ SnpEnabled ( =20 @param[in] XFeaturesEnabled Bit-mask of enabled XSAVE features/are= as as indicated by XCR0/MSR_IA32_XSS bits - @param[in] XSaveBaseSize Base/legacy XSAVE area size (e.g. when - XCR0 is 1) @param[in, out] XSaveSize Pointer to storage for calculated XSAV= E area size @param[in] Compacted Whether or not the calculation is for = the @@ -1663,7 +1661,6 @@ STATIC BOOLEAN GetCpuidXSaveSize ( IN UINT64 XFeaturesEnabled, - IN UINT32 XSaveBaseSize, IN OUT UINT32 *XSaveSize, IN BOOLEAN Compacted ) @@ -1672,7 +1669,10 @@ GetCpuidXSaveSize ( UINT64 XFeaturesFound =3D 0; UINT32 Idx; =20 - *XSaveSize =3D XSaveBaseSize; + // + // The base/legacy XSave size is documented to be 0x240 in the APM. + // + *XSaveSize =3D 0x240; CpuidInfo =3D (SEV_SNP_CPUID_INFO *)(UINT64)PcdGet32 (PcdOvmfCpuidBase); =20 for (Idx =3D 0; Idx < CpuidInfo->Count; Idx++) { @@ -1888,7 +1888,6 @@ GetCpuidFw ( =20 if (!GetCpuidXSaveSize ( XCr0 | XssMsr.Uint64, - *Ebx, &XSaveSize, Compacted )) --=20 2.25.1 -=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 (#97705): https://edk2.groups.io/g/devel/message/97705 Mute This Topic: https://groups.io/mt/95815543/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-