[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen staging-4.17] x86/cpu-policy: Fix handling of leaf 0x80000021



commit bdca9c89adeb5d6813fabe75fd11df1a4b6e2e76
Author:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
AuthorDate: Tue Jul 1 11:33:41 2025 +0100
Commit:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CommitDate: Mon Jul 7 22:52:06 2025 +0100

    x86/cpu-policy: Fix handling of leaf 0x80000021
    
    When support was originally introduced, ebx, ecx and edx were reserved and
    should have been zeroed in recalculate_misc() to avoid leaking into guests.
    
    Since then, fields have been added into ebx.  Guests can't load microcode, 
so
    shouldn't see ucode_size, and while in principle we do want to support 
larger
    RAP sizes in guests, virtualising this for guests depends on AMD procuding 
any
    official documentation for ERAPS, which is long overdue and with no ETA.
    
    This patch will cause a difference in guests on Zen5 CPUs, but as the main
    ERAPS feature is hidden, guests should be ignoring the rap_size field too.
    
    Fixes: e9b4fe263649 ("x86/cpuid: support LFENCE always serialising CPUID 
bit")
    Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
    Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
    (cherry picked from commit 10dc35c516f7b9224590a7a4e2722bbfd70fa87a)
---
 xen/arch/x86/cpu-policy.c            | 3 +++
 xen/include/xen/lib/x86/cpu-policy.h | 5 ++++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/cpu-policy.c b/xen/arch/x86/cpu-policy.c
index 42bd039e7c..8f006fe08a 100644
--- a/xen/arch/x86/cpu-policy.c
+++ b/xen/arch/x86/cpu-policy.c
@@ -340,6 +340,9 @@ static void recalculate_misc(struct cpu_policy *p)
         p->extd.raw[0x1e] = EMPTY_LEAF; /* TopoExt APIC ID/Core/Node */
         p->extd.raw[0x1f] = EMPTY_LEAF; /* SEV */
         p->extd.raw[0x20] = EMPTY_LEAF; /* Platform QoS */
+        p->extd.raw[0x21].b = 0;
+        p->extd.raw[0x21].c = 0;
+        p->extd.raw[0x21].d = 0;
         break;
     }
 }
diff --git a/xen/include/xen/lib/x86/cpu-policy.h 
b/xen/include/xen/lib/x86/cpu-policy.h
index 6d5e9edd26..ba29bfe9b4 100644
--- a/xen/include/xen/lib/x86/cpu-policy.h
+++ b/xen/include/xen/lib/x86/cpu-policy.h
@@ -324,7 +324,10 @@ struct cpu_policy
                 uint32_t e21a;
                 struct { DECL_BITFIELD(e21a); };
             };
-            uint32_t /* b */:32, /* c */:32, /* d */:32;
+            uint16_t ucode_size; /* Units of 16 bytes */
+            uint8_t  rap_size;   /* Units of 8 entries */
+            uint8_t  :8;
+            uint32_t /* c */:32, /* d */:32;
         };
     } extd;
 
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.17



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.