]> xenbits.xensource.com Git - ovmf.git/commitdiff
OvmfPkg/CcExitLib: Fix SEV-SNP XSave area size calculation
authorRoth, Michael via groups.io <Michael.Roth=amd.com@groups.io>
Tue, 25 Apr 2023 20:32:57 +0000 (04:32 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Wed, 26 Apr 2023 13:39:01 +0000 (13:39 +0000)
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 <papaluri@amd.com>
Cc: Pavan Kumar Paluri <papaluri@amd.com>
Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
Acked-by: Jiewen Yao <jiewen.yao@intel.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Michael Roth <michael.roth@amd.com>
OvmfPkg/Library/CcExitLib/CcExitVcHandler.c

index 7fe11c53249ed648cd61bb26752621e7074cfd3c..94f0c4872c24db0a0de23f68189a69d4c1930216 100644 (file)
@@ -1145,9 +1145,7 @@ GetCpuidXSaveSize (
   for (Idx = 0; Idx < CpuidInfo->Count; Idx++) {\r
     SEV_SNP_CPUID_FUNCTION  *CpuidFn = &CpuidInfo->function[Idx];\r
 \r
-    if (!((CpuidFn->EaxIn == 0xD) &&\r
-          ((CpuidFn->EcxIn == 0) || (CpuidFn->EcxIn == 1))))\r
-    {\r
+    if (!((CpuidFn->EaxIn == 0xD) && (CpuidFn->EcxIn > 1))) {\r
       continue;\r
     }\r
 \r