From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xenproject.org>
Cc: "Andrew Cooper" <andrew.cooper3@citrix.com>,
"Jan Beulich" <jbeulich@suse.com>,
"Roger Pau Monné" <roger@xenproject.org>,
"Teddy Astie" <teddy.astie@vates.tech>
Subject: [PATCH] x86/amd: Expand comment about NullSelectorClearsBase
Date: Thu, 20 Aug 2026 18:26:40 +0100 [thread overview]
Message-ID: <20260820172640.2072049-1-andrew.cooper3@citrix.com> (raw)
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@citrix.com>
---
CC: Jan Beulich <jbeulich@suse.com>
CC: Roger Pau Monné <roger@xenproject.org>
CC: Teddy Astie <teddy.astie@vates.tech>
Naming Zen2/3 in init_hygon() isn't ideal, but the early hygons really were
not far removed from the AMD microarchitectures.
---
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 70783c9a0af0..ddd73f64c2d5 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 7a9fc25d3157..ef19c2b36783 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();
--
2.39.5
next reply other threads:[~2026-08-20 17:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-20 17:26 Andrew Cooper [this message]
2026-08-21 8:51 ` [PATCH] x86/amd: Expand comment about NullSelectorClearsBase Jan Beulich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260820172640.2072049-1-andrew.cooper3@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=jbeulich@suse.com \
--cc=roger@xenproject.org \
--cc=teddy.astie@vates.tech \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.