From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mx.groups.io with SMTP id smtpd.web11.9497.1672995231651288112 for ; Fri, 06 Jan 2023 00:53:51 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=OKZc+aVu; spf=pass (domain: intel.com, ip: 192.55.52.151, mailfrom: jiewen.yao@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1672995231; x=1704531231; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=ipq8pogYNEzx+Qsa1ie/1YLnJsiBUfAzUouk9YADph0=; b=OKZc+aVuypm3wCW4RWSHg/kEA4P7wZWjoxCasSovPNq7Mh3NxvS/INTB ZT1H5XPJrDwxbS7YLAJY1mNEdxIisDQihIWkLIzAIEBGV27GtOqsQSs3G W67E5E/ujonuJzOtzUzhyxh5GivEItL78tQMtei/b8v6xKyX6xzTh+KGG +K5ZotgQDQl6HBBBIhhT+NxNOi3/HhJ5NpWDb6oA733S/hGOS5lyBeM5K hcX8J9imqfcr1JBwIun1PmejdneOBDGOznR/Q/zZgrPZhMOVDcYbq1SZi Pcw0XW8ay49mQauG5qLDADXslcIYiVQZqWHrXkgfRZzpWbNg+rfJk9WqL Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10581"; a="302802942" X-IronPort-AV: E=Sophos;i="5.96,304,1665471600"; d="scan'208";a="302802942" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jan 2023 00:53:49 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10581"; a="688250299" X-IronPort-AV: E=Sophos;i="5.96,304,1665471600"; d="scan'208";a="688250299" Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by orsmga001.jf.intel.com with ESMTP; 06 Jan 2023 00:53:48 -0800 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Fri, 6 Jan 2023 00:53:47 -0800 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) 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.16 via Frontend Transport; Fri, 6 Jan 2023 00:53:47 -0800 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (104.47.70.102) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.16; Fri, 6 Jan 2023 00:53:47 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YMW+LvzDzoWzH3yge1dz5i61sxG+atY5hLQU4U1o6c3H7NqfyXo7fJkJn8CvlQTeuww0dLncXeqk1jk8wu6eY2vIUsRow0dL6BuPtl7PWscYzp/obKxB7PlvlTPLxjVZGS5r99zTJLJtnXlKHHgWOcKwJs7XZBjYsNnvRXcknjs752o2Wy58+bdybl4d28r0VpKmm/juXpcWpMWYdb30BoeuE6eXELZGkp65ZPMeU5WStdBEVRGDaju/RrCgqE+/t2+H4mcm0dTUTBDpELbHx7ZloNyWvU0SP06Atf5Rj7ZqacfE45zXVilXHcZgOf3/u1z8CSQWELIYoMy0gJiFQA== 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=cwsDLi/NfcHxx0Rtz0yjAgZEGGV5ymQmg+uvq7Z/T3w=; b=Y9d06d8C/Q3Ytkvk94bzSpXnj1NEnqZ7o/wSjtUFVGig9M9ULuTsMFtjJMfPpgkMOlhTAFGvuIlJM/RzQyMl31qYkLbaCZf3ALPUp5e1LShd57lQOI2m6M6BvQG/tFvGFlTEpKSIBwxwVZy/oiObEqHVbOHj0Ihar9hVQKho9PQWLD8JxZzp776VYeP/aBUot57xdvqmsAJWXqQrEZ2AtDY7zXsPQU/DBihwA4foajl2QayWN8Z/uZ12d+FyK/gmWKgIrDoRFHD8FABWS08e7B/szYucksKLi9l3SZyguHet0CeatG6gwbgVStH662i4xjgj570eZ1c9Gp6o8a8I8w== 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 Received: from MW4PR11MB5872.namprd11.prod.outlook.com (2603:10b6:303:169::14) by CY5PR11MB6236.namprd11.prod.outlook.com (2603:10b6:930:23::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.19; Fri, 6 Jan 2023 08:53:40 +0000 Received: from MW4PR11MB5872.namprd11.prod.outlook.com ([fe80::5f56:1bdc:2eae:c041]) by MW4PR11MB5872.namprd11.prod.outlook.com ([fe80::5f56:1bdc:2eae:c041%9]) with mapi id 15.20.5944.019; Fri, 6 Jan 2023 08:53:40 +0000 From: "Yao, Jiewen" To: "devel@edk2.groups.io" , "Michael.Roth@amd.com" CC: Tom Lendacky , "Ni, Ray" Subject: Re: [edk2-devel] [PATCH 4/4] OvmfPkg/CcExitLib: Use documented XSave area base size for SEV-SNP Thread-Topic: [edk2-devel] [PATCH 4/4] OvmfPkg/CcExitLib: Use documented XSave area base size for SEV-SNP Thread-Index: AQHZFYOG9biMRhULtUOYJCXW3rOBlK6RLbOQ Date: Fri, 6 Jan 2023 08:53:40 +0000 Message-ID: References: <20221221160651.182143-1-michael.roth@amd.com> <20221221160651.182143-5-michael.roth@amd.com> In-Reply-To: <20221221160651.182143-5-michael.roth@amd.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MW4PR11MB5872:EE_|CY5PR11MB6236:EE_ x-ms-office365-filtering-correlation-id: 931e869e-baa0-40e5-104d-08daefc381fa x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: s/dZAhD0uDC8U0O87PsXAfaamXiOnkhmaxiH6vK+QDvSw/24Yt76l2jAn8HJHyqHe/TQjBh4w1XUmGiNpyA7S/CpRNSVwj4H0xxjErMsv7ZE3cvxqO05ldmfF4duUe+s6wYdDL8NRp59wQgeMAHlOLRvb0zi7CHeiS2pgrrzY8nBTL2ADVg0J2Xtvaqvh1/yARLbLRRuKcnt464IxuQEwZYla6wxKftLj8Zs4g7JHhVq1oRqOFAK3yaISDLWo9DXSUUODtUrxsqPKScvUbMMTT0TS66wFmowpZTzIenwR4q0F5lQaiKVajhTXo4IJYsx2sMGevuxUwc7pS/rdU1Inr0f4byb0w9SO8ngWvkhmaZbzpXCc8AVSNPgIf6JyGj01Ib0P56mzwbYdJobbrGzC9nVgqnsyXGXUm7arnHuueGCEcrKkli2Ktd8B3qydwNHpdPI4D5vJ7QsIDtq8R5o+Npg2HHGXbNjaTEBMPL8uDMVtXMJkd/fRca5YpWYL0gd+WIkWPa8rbKXi4lqxixJmaIegtRAAnLjy9e+ldvlLKSkk7CPBkl6WODYMaFONSUFAhfZFDgw+cDKYXLQGWhkbeqPUEXYLah8qDcjyAqEXgxv49sZHI7qEG0hqsWoo4uARaeXdx46d8oVFJidFTgtxkGzMrYm7iKiSsuZWbC7mZMks77WRMYnfau7MM4soSgAwo9qGI2aN1z1TnBevizaCm1IKTDHtV6OQGMjMZrSnOKyOZ6bLqMCUHJiGv+eb+Z+B9GgG2cFalgcGV0j1VQSjQ== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW4PR11MB5872.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(6029001)(366004)(39860400002)(396003)(376002)(346002)(136003)(451199015)(76116006)(66556008)(4326008)(66446008)(66946007)(41300700001)(64756008)(38070700005)(316002)(8676002)(66476007)(54906003)(2906002)(86362001)(110136005)(5660300002)(52536014)(82960400001)(38100700002)(122000001)(55016003)(33656002)(6506007)(9686003)(478600001)(53546011)(966005)(66899015)(8936002)(26005)(186003)(83380400001)(107886003)(71200400001)(7696005);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?JdgjsWjWp32oWzVV8T7Oo7a+r7YRFYG3kJiNW0K9v7Yoamb5DItWGyKNdzSg?= =?us-ascii?Q?QVfkRapKDV+prkFDDFGBiFPfQ8w90eq5I/0lGwiO13moPR1Wi3Sy9pcSxtR9?= =?us-ascii?Q?p2GxeI/8MiG8w0tl3Vc4ZV0nH8wZAC7ybf1hSnPRkAc1mWTEvHxr5XEFLzDL?= =?us-ascii?Q?AThTaHneMKPMzgQCie5IZttkHT9VtIVbas0MYt1KTVf7iZKgPKDkZAaz+XrR?= =?us-ascii?Q?BqHU2AfzI/WFJgG5xHfy9IJNGpK76ZdlHIRGQau+wjWyolbxxJHC4fZ5rVs3?= =?us-ascii?Q?dzOeSzGM9R19laeqri98Exo57m3cB2Y5PvsKzSGnsj8mf2Fx4xmrwmUeTzF1?= =?us-ascii?Q?JjR0NjkplIndq29FFkIlFgSRs9sHUTPeAzlwo9FE+Uuu+2ulWuOzgp0TzoWb?= =?us-ascii?Q?J7VfhGUYL+rxYXd6XdMVQ8L5TVEZv6jrN5vg/HDoa+UctfIDqsfPTdFuJNB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NIUug2BULXiDjTkbWvhCKriAWfrPZnkd?= =?us-ascii?Q?QKSmYBC2S0VCzfX60J66suCw7qwssDQEFtn1FntY2lOhjirqpUhA3PBAvvqF?= =?us-ascii?Q?j5GeCMDrjKmT6ITFVzyfUpLcKaYZJ63sIWLo2hXRX5TcnzanItk+xc8nQlvR?= =?us-ascii?Q?Cj+xpbdSwQNw4hCk2xHMiLeKEIe/4qd/gjH8Deg92hnEWSHcALTohag8NzVc?= =?us-ascii?Q?wvA7xH4m/G3cPhcEucSDfHQZd1Ak+ztDLd6EPcDl?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW4PR11MB5872.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 931e869e-baa0-40e5-104d-08daefc381fa X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Jan 2023 08:53:40.4344 (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: e2PM5J01AQFF45FJ3YYXHstRZ4IItiYCdnxcbccoAv82EVwy0WuaVgtVmFMzGQw12K4nFkaMNki8gWjIJKuu8g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR11MB6236 Return-Path: jiewen.yao@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Acked-by: Jiewen Yao > -----Original Message----- > From: devel@edk2.groups.io On Behalf Of Roth, > Michael via groups.io > Sent: Thursday, December 22, 2022 12:07 AM > To: devel@edk2.groups.io > Cc: Tom Lendacky ; Ni, Ray > Subject: [edk2-devel] [PATCH 4/4] OvmfPkg/CcExitLib: Use documented > XSave area base size for SEV-SNP >=20 > 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. >=20 > Signed-off-by: Michael Roth > --- > OvmfPkg/Library/CcExitLib/CcExitVcHandler.c | 9 ++++----- > 1 file changed, 4 insertions(+), 5 deletions(-) >=20 > 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 >=20 > @param[in] XFeaturesEnabled Bit-mask of enabled XSAVE > features/areas as >=20 > indicated by XCR0/MSR_IA32_XSS bits >=20 > - @param[in] XSaveBaseSize Base/legacy XSAVE area size (e.g. wh= en >=20 > - XCR0 is 1) >=20 > @param[in, out] XSaveSize Pointer to storage for calculated XS= AVE > area >=20 > size >=20 > @param[in] Compacted Whether or not the calculation is fo= r the >=20 > @@ -1663,7 +1661,6 @@ STATIC > BOOLEAN >=20 > GetCpuidXSaveSize ( >=20 > IN UINT64 XFeaturesEnabled, >=20 > - IN UINT32 XSaveBaseSize, >=20 > IN OUT UINT32 *XSaveSize, >=20 > IN BOOLEAN Compacted >=20 > ) >=20 > @@ -1672,7 +1669,10 @@ GetCpuidXSaveSize ( > UINT64 XFeaturesFound =3D 0; >=20 > UINT32 Idx; >=20 >=20 >=20 > - *XSaveSize =3D XSaveBaseSize; >=20 > + // >=20 > + // The base/legacy XSave size is documented to be 0x240 in the APM. >=20 > + // >=20 > + *XSaveSize =3D 0x240; >=20 > CpuidInfo =3D (SEV_SNP_CPUID_INFO *)(UINT64)PcdGet32 > (PcdOvmfCpuidBase); >=20 >=20 >=20 > for (Idx =3D 0; Idx < CpuidInfo->Count; Idx++) { >=20 > @@ -1888,7 +1888,6 @@ GetCpuidFw ( >=20 >=20 > if (!GetCpuidXSaveSize ( >=20 > XCr0 | XssMsr.Uint64, >=20 > - *Ebx, >=20 > &XSaveSize, >=20 > Compacted >=20 > )) >=20 > -- > 2.25.1 >=20 >=20 >=20 >=20 >=20