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

[xen master] x86/amd: Expand comment about NullSelectorClearsBase



commit 228c881efc3e867233772548676f5fa863aec67d
Author:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
AuthorDate: Mon Mar 2 19:30:39 2026 +0000
Commit:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CommitDate: Thu Sep 24 20:54:37 2026 +0100

    x86/amd: Expand comment about NullSelectorClearsBase
    
    Rework detect_zen2_null_seg_behaviour() to use the new MSR infrastructure.
    
    Zen2 doesn't have WRMSRNS so don't bother relaxing the write.  All it will 
do
    is insert a useless alternative.
    
    No functional change.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
    Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
---
 xen/arch/x86/cpu/amd.c   | 17 ++++++++---------
 xen/arch/x86/cpu/hygon.c |  5 ++++-
 2 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/xen/arch/x86/cpu/amd.c b/xen/arch/x86/cpu/amd.c
index 70783c9a0a..ddd73f64c2 100644
--- a/xen/arch/x86/cpu/amd.c
+++ b/xen/arch/x86/cpu/amd.c
@@ -828,15 +828,11 @@ void amd_init_spectral_chicken(void)
 
 void __init detect_zen2_null_seg_behaviour(void)
 {
-       uint64_t base;
-
-       wrmsrl(MSR_FS_BASE, 1);
-       asm volatile ( "mov %0, %%fs" :: "r" (0) );
-       rdmsrl(MSR_FS_BASE, base);
-
-       if (base == 0)
-               setup_force_cpu_cap(X86_FEATURE_NSCB);
+    wrmsr(MSR_FS_BASE, 1);
+    asm volatile ( "mov %0, %%fs" :: "r" (0) );
 
+    if ( rdmsr(MSR_FS_BASE) == 0 )
+        setup_force_cpu_cap(X86_FEATURE_NSCB);
 }
 
 static void cf_check fam17_disable_c6(void *arg)
@@ -1110,7 +1106,10 @@ static void cf_check init_amd(struct cpuinfo_x86 *c)
        if (c->family == 0x17)
                amd_init_spectral_chicken();
 
-       /* Probe for NSCB on Zen2 CPUs when not virtualised */
+       /*
+        * Zen3 and later enumerate NullSelectorClearsBase.  Zen2 has this
+        * behaviour but doesn't enumerate it.  Probe when not virtualised.
+        */
        if (!cpu_has_hypervisor && !cpu_has_nscb && c == &boot_cpu_data &&
            c->family == 0x17)
                detect_zen2_null_seg_behaviour();
diff --git a/xen/arch/x86/cpu/hygon.c b/xen/arch/x86/cpu/hygon.c
index 7a9fc25d31..ef19c2b367 100644
--- a/xen/arch/x86/cpu/hygon.c
+++ b/xen/arch/x86/cpu/hygon.c
@@ -39,7 +39,10 @@ static void cf_check init_hygon(struct cpuinfo_x86 *c)
 
        amd_init_ssbd(c);
 
-       /* Probe for NSCB on Zen2 CPUs when not virtualised */
+       /*
+        * Zen3 and later enumerate NullSelectorClearsBase.  Zen2 has this
+        * behaviour but doesn't enumerate it.  Probe when not virtualised.
+        */
        if (!cpu_has_hypervisor && !cpu_has_nscb && c == &boot_cpu_data &&
            c->family == 0x18)
                detect_zen2_null_seg_behaviour();
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

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