From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (NAM04-BN8-obe.outbound.protection.outlook.com [40.107.100.43]) by mx.groups.io with SMTP id smtpd.web11.22408.1671638904699381407 for ; Wed, 21 Dec 2022 08:08:25 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@amd.com header.s=selector1 header.b=CVYrk4FV; 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.100.43, mailfrom: michael.roth@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CYctNDyb+5LTScQo2eEG8b+pWP51Nw9dZSWKjwGye+gfM7YaZ659kM9YsA+v8Fg7Dp0RqZJ81jnQBDL8gQtLawMYPydpEyK38U6RTYrrrdVnuIb49dlq+TnWlAGQjdoKnmb2tIilsfZkdAu8xfxSrx7VzcuiYNX4lUUWwDR8avLTktgZqFGYZ+V75mZlNUHgIxnCWKn18jj10/cAw21yfQG5cXp+JfFwmFiiKTy39dmZgFvas7UNLxSRnSAl2uLg71bSNtdYJUKBIxaY8Uzjs4B+EABZoaqLqElfk7Tr2Q3Pc4r8RK1H5sHKen4plO/4X4HHg4gl3sNPGKBlVT3BHg== 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=H6JWd5zEIETIlw8VR7qHAb4xjeLaZ+e2M1yHtU9t1iA=; b=njFc96opZMI+8QEhKJJJkNNYL5NniHwlMVPGwDC81A0v6jNqPyvaYvGv5JWomq5jZowy3Uk80bZRi7Til52s6iiErT80vrG7a8HsdcnpVAH/XTgKzgoXLLR810MpOAZYGIvUy2nrz+lveuUOkIVAKxlggAOirhNfJqdZOwY2JTPW9NityBA+OSrdpHAoTnTFQAOO+VSBPWkWXFPDzravZqkytSCaVq6ZxHz8Fde2lfkpJdD1McXip3pHZO8HYs5e2JugBtZa1722UAr+vXvRSDtwxQfBgz3YiU/0dlmB/odIONE4veCocZiWYdcxurqvK7cSvb5IUA3IkEaX7rTLpA== 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=H6JWd5zEIETIlw8VR7qHAb4xjeLaZ+e2M1yHtU9t1iA=; b=CVYrk4FVF/PWrBG50qC5dwAp74m+FwTWj8O+sKLfJxKMmMHY7EKkE+ZAmISfVdkxonvXl9lTGKwoMXDq0TgFSKVPb3y4DN4OZOP3DBOEjaZQ2vIvXLkjmtD9K6kMEeULmvak7IRBAarBiW7eg1RfOPbtyPlVMM5c568AjlNCeNQ= Received: from BN8PR12CA0011.namprd12.prod.outlook.com (2603:10b6:408:60::24) by PH7PR12MB6737.namprd12.prod.outlook.com (2603:10b6:510:1a8::13) 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:22 +0000 Received: from BN8NAM11FT089.eop-nam11.prod.protection.outlook.com (2603:10b6:408:60:cafe::e5) by BN8PR12CA0011.outlook.office365.com (2603:10b6:408:60::24) 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:22 +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 BN8NAM11FT089.mail.protection.outlook.com (10.13.176.105) 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:08:22 +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:08:21 -0600 From: "Roth, Michael" To: CC: Tom Lendacky , , "Pavan Kumar Paluri" Subject: [PATCH 3/4] OvmfPkg/CcExitLib: Fix SEV-SNP XSave area size calculation Date: Wed, 21 Dec 2022 10:06:50 -0600 Message-ID: <20221221160651.182143-4-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: BN8NAM11FT089:EE_|PH7PR12MB6737:EE_ X-MS-Office365-Filtering-Correlation-Id: 629136bb-18a0-4dbb-e98e-08dae36d9578 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bZlx2aEpZIB1Gb/5+He9/o4YpIlbA/41EvmWAqTZ80TorGJbyCHD9EjVoiVy7zpcI5KC+cjTDykl/GWgAnsuMYURKAl+Ap2if0iOAPn4MXGlESVa5sjRNPLGecbcETFmGmht7bT4pGcWZIQ0RTpFT1y+HTkVfj7U3qoUcUiegVHrQIevos5Uncp36GGgYOdFbVVFXN3tCcbOqABdCKwC+0t4BzqOx8e6bCcPeF493T/JA23G0AJSYixsUg0wUaz/bemjkReq01m+X7jbMWsqvQPzZz3Tqs6vPlqtngeBxz1wKPkssjIeYgYBPgoWckZhGY7AEPVWZ/L0+OsTMZTakg8HQZGiFniL/4L+VLABCChv6UgnZ2DD73LEq04kte7gsIsOpKlmINl24tFT56bmJywqL7Gl5GDsbXD4AsBo1EwsH8YK/n79aX+AfbwH+f6tBkGrTnNDHbPVvCYcfJtloIZGB5nhJaIJmTGF8JT77yl79jJKWficWfFV77lakrsbWmBuh6mFD7eVHVoVbJLI4aeUsY6OXGAnEtvonwsq+qCTivNVT2ZGJ+FBdwyDeWU5hCX/OaVa9pYfRhy0v4KPyTo8wXEfSkX9/hew+P5zdS2N0QF0N6bnTKa8j4ixuHNQGcYZitCGHtlpxQvgv+th4WULUB7hYYD4gXnQiNaTdBhUFVIXXqmGVcAfsEXiV5dxwGXyL9KzCji7gEiQz/yCRsoGJR9h5sn7QTgkiKr/cdU= 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)(6029001)(4636009)(346002)(39860400002)(376002)(396003)(136003)(451199015)(46966006)(40470700004)(36840700001)(41300700001)(40480700001)(2906002)(8936002)(356005)(70586007)(4326008)(86362001)(81166007)(44832011)(6916009)(8676002)(70206006)(5660300002)(316002)(54906003)(26005)(186003)(40460700003)(82310400005)(82740400003)(6666004)(336012)(83380400001)(36756003)(426003)(1076003)(2616005)(47076005)(16526019)(36860700001)(478600001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Dec 2022 16:08:22.4547 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 629136bb-18a0-4dbb-e98e-08dae36d9578 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: BN8NAM11FT089.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6737 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain CPUID leaf 0xD sub-leafs 0x0 and 0x1 contain cumulative sizes for the enabled XSave areas. Those sizes are calculated by tallying up all the other sub-leafs that contain per-area size information for XSave areas that are currently enabled in XCr0/XSS. The current check has the logic inverted. Fix that. This doesn't seem to cause problems currently, but could in the future if OVMF made more extensive use of XSave areas. It was noticed while implementing SNP-related tests for KVM Unit Tests, which re-uses the OVMF #VC handler in some cases. Reported-by: Pavan Kumar Paluri Cc: Pavan Kumar Paluri Signed-off-by: Michael Roth --- OvmfPkg/Library/CcExitLib/CcExitVcHandler.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/OvmfPkg/Library/CcExitLib/CcExitVcHandler.c b/OvmfPkg/Library/= CcExitLib/CcExitVcHandler.c index 985e547977..cd117d5a31 100644 --- a/OvmfPkg/Library/CcExitLib/CcExitVcHandler.c +++ b/OvmfPkg/Library/CcExitLib/CcExitVcHandler.c @@ -1678,9 +1678,7 @@ GetCpuidXSaveSize ( for (Idx =3D 0; Idx < CpuidInfo->Count; Idx++) {=0D SEV_SNP_CPUID_FUNCTION *CpuidFn =3D &CpuidInfo->function[Idx];=0D =0D - if (!((CpuidFn->EaxIn =3D=3D 0xD) &&=0D - ((CpuidFn->EcxIn =3D=3D 0) || (CpuidFn->EcxIn =3D=3D 1))))=0D - {=0D + if (!((CpuidFn->EaxIn =3D=3D 0xD) && (CpuidFn->EcxIn > 1))) {=0D continue;=0D }=0D =0D --=20 2.25.1