From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (NAM11-DM6-obe.outbound.protection.outlook.com [40.107.223.62]) by mx.groups.io with SMTP id smtpd.web11.6822.1678917565627619330 for ; Wed, 15 Mar 2023 14:59:25 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@amd.com header.s=selector1 header.b=WhZ8ulyZ; 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.223.62, mailfrom: michael.roth@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IjQ3EsCpMz1k2ENZBX+JFMSr+7/jp0g2GclpDQbvHoRJ8JIXDqHZgQAwJuu/zVcDUVIcbuW7g9YytLBzsrPLTch6fkV1038cZGIF6N71zWUI0fHw0UT1/keMYCrdUtrRMiMtAblPQ6dKOI5P9XuCPMWdlMWVuuhsM+JcWDbN/5e/8sH+DzJiOmyaTr/q9wW2DO6YOcArLm5et02qg852ofUduzs3/ED52GUmA3R0OeeAPUbNvqb1G1y+EzZ+jFnT15QIw768ANZR6NipanXhIlB/fztZieivG7nHJXOTOeFK/XuuGwtRaFisvo+ljEc3a38jBmtTs9Vs8Jg25xhdaA== 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=b4ep7E86IGY5rBBOyiT/2dfBLHR2bhaof4monbShjXI=; b=E28xA8l75x2vyDRg+BRFhmxQzdjyygt/s9QgtrsyEdCWIBKlqDwavOKR8HwhOSOu891LVkbvz31u0wgWYwkKScwhICFo/kLaJ0mBpSA/VlXqLzXhM4Ff56Ilp0p3zE46vJhgGQAAmWUY1BARTkncrsaSi1y8W9YD+o7dWduDBhCUvleVs8bu3w1mmVfjFj3d/4Im9wtIdgZ3rzRlS54D5D1dkvSyMFxPNWx/vQ1lS013HCcyxdLjhAJ8nOXqNpV7gQ2w4xooA+sERXBcs8GSfebEuH4wlJ7NeEhpCW4ZjPo5e3pf16MaRqXS2Ti75rNJGZET4ERdGkr14OKR7DPBpg== 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=b4ep7E86IGY5rBBOyiT/2dfBLHR2bhaof4monbShjXI=; b=WhZ8ulyZm14hM9dkD7NiTFHzwtB4ZxDtog6IvLliQrYn8VruPci0H/73O5c35TeMtK0pndaqWg71WLs6OxxD1Iz0guoDO3ggHGufFigV1hqlRbEazvhW18TOToTnxC2MRKZg5Wixc8rCczuVf4oYn3t66guYTvJyvv9YvMG3tG8= Received: from MW4PR04CA0216.namprd04.prod.outlook.com (2603:10b6:303:87::11) by DM4PR12MB6640.namprd12.prod.outlook.com (2603:10b6:8:8f::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.24; Wed, 15 Mar 2023 21:59:22 +0000 Received: from CO1NAM11FT110.eop-nam11.prod.protection.outlook.com (2603:10b6:303:87:cafe::f7) by MW4PR04CA0216.outlook.office365.com (2603:10b6:303:87::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.30 via Frontend Transport; Wed, 15 Mar 2023 21:59: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 CO1NAM11FT110.mail.protection.outlook.com (10.13.175.125) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6199.17 via Frontend Transport; Wed, 15 Mar 2023 21:59:21 +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, 15 Mar 2023 16:59:20 -0500 From: "Roth, Michael" To: CC: Tom Lendacky , Jiewen Yao , , Gerd Hoffmann , Erdem Aktas , James Bottomley , Min Xu , Pavan Kumar Paluri Subject: [PATCH RESEND 3/4] OvmfPkg/CcExitLib: Fix SEV-SNP XSave area size calculation Date: Wed, 15 Mar 2023 16:57:46 -0500 Message-ID: <20230315215747.1543837-4-michael.roth@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230315215747.1543837-1-michael.roth@amd.com> References: <20230315215747.1543837-1-michael.roth@amd.com> MIME-Version: 1.0 Return-Path: Michael.Roth@amd.com 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: CO1NAM11FT110:EE_|DM4PR12MB6640:EE_ X-MS-Office365-Filtering-Correlation-Id: fd4a4c56-5ff5-4795-aa73-08db25a088a1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jJOiwyGV7lI2DB/isKxZ/bFSujFTJs1ctGgh3NZLFkKZiPTV84YLKiT+57W5ct+SLTxYSXsow+7jKiIPk747HJ7YrZwAW7PlEPcMsPhYWTs8Od7EpoKjTnJOa2pLnhx6rWdaYbbiMicEolm0dz/pKlE8R+K15ineJRZMmsxKEFbun8aS+0P3iOreJuYiwHnLJ++gYoCrLrOyLVDrpRUgm8gokNHKUqgKeLUL7Am+Byp89INQsMBQyckW8gVlOO9oQBSxiYJvW7zJoispk9uwYB4TM4Bkp8YtX4KAw0GCsQSThc4DluOBTszujmsW8nqZHraRgt2fgwLQ3zFsHupyjSeVTSxSouBrriMN2iSgh7FTWmL0wwdy+SBqNmLWaf9gWAdqYK/QYMV5hQWVx6URq44tfxObasc78Ycd7hTN9/Jcx3VNT8gh+toSOn1YHL2+WPd7EZolvjynGGGVQtPLGHtEYt3C2bA4+2ti1GA+9C+l906qz1OR3Kd7sXfkYldsLDqIsQwVZbLNZkAR8xvAdZQBKKTVfK6paX+kh2XdtMqYsOJK5NeARnkrPrYZS3wOK0X8cvMG458T5tgcffAT9MYh5gx3vBoABax9SBb27g1pg5huAX3ZKd/nWub45B5W/K+31S88JzCc2vJXEfonaXpiCHz8boT9J1Y7VnZCzXOHOOwSVvQtB3qtZDLfKhGdc3btuBBB9s3hJyZ2GwvLYimB5oXT5y5+WuPjff2LjyY= 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:(13230025)(6029001)(4636009)(136003)(39860400002)(396003)(346002)(376002)(451199018)(36840700001)(46966006)(40470700004)(336012)(36860700001)(316002)(41300700001)(4326008)(40480700001)(8676002)(6666004)(54906003)(186003)(1076003)(2616005)(26005)(70206006)(16526019)(6916009)(70586007)(47076005)(83380400001)(478600001)(40460700003)(426003)(356005)(36756003)(2906002)(82310400005)(82740400003)(81166007)(86362001)(5660300002)(44832011)(8936002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Mar 2023 21:59:21.7379 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fd4a4c56-5ff5-4795-aa73-08db25a088a1 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: CO1NAM11FT110.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6640 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 Reviewed-by: Tom Lendacky Acked-by: Jiewen Yao 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 7fe11c5324..94f0c4872c 100644 --- a/OvmfPkg/Library/CcExitLib/CcExitVcHandler.c +++ b/OvmfPkg/Library/CcExitLib/CcExitVcHandler.c @@ -1145,9 +1145,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