mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tony W Wang-oc <TonyWWang-oc@zhaoxin.com>
To: Dave Hansen <dave.hansen@intel.com>, me@ziyao.cc
Cc: andrew.cooper3@citrix.com, bp@alien8.de,
	dave.hansen@linux.intel.com, hpa@zytor.com,
	linux-kernel@vger.kernel.org, mingo@redhat.com,
	stable@vger.kernel.org, tglx@kernel.org, x86@kernel.org,
	lukelin@viacpu.com, "TimGuo@zhaoxin.com" <TimGuo@zhaoxin.com>,
	cooperyan@zhaoxin.com, benjaminpan@viatech.com,
	QiyuanWang@zhaoxin.com, HerryYang@zhaoxin.com,
	"CobeChen@zhaoxin.com" <CobeChen@zhaoxin.com>
Subject: Re: [PATCH] x86/cpu/centaur: Disable X86_FEATURE_FSGSBASE on Zhaoxin C4600
Date: Thu, 12 Mar 2026 10:14:27 +0800	[thread overview]
Message-ID: <b16bda4b-c7cb-4e7f-ac71-57c0032c6633@zhaoxin.com> (raw)
In-Reply-To: <7d312ba6-58a0-48cb-92fa-d8094ddef21f@intel.com>

Hi Dave/Andrew/David/Yaozi,

Sorry for the late reply.

First of all, this bug was present in certain early ucode patches for 
ZX-C/ZX-C+ series CPUs; however, it has since been resolved in 
subsequent updates to the ZX-C/ZX-C+ ucode patch.

According to available documentation, the VIA Eden platform supports 
FSGSBASE; however, this CPU is too old, and we haven't been able to 
locate actual hardware to test whether it was affected by this bug.

It is recommended that, in addition to the existing FMS-based detection, 
a supplementary check be implemented to identify the specific ucode 
patch revisions associated with ZX-C/ZX-C+ that are known to exhibit 
this bug.

Due to differences in ucode matching rules on Zhaoxin platforms, 
existing kernel function interfaces cannot be used, so the patch code 
has been placed in a vendor-specific file. The specific patching 
approach can be as follows:

--- a/arch/x86/kernel/cpu/centaur.c
+++ b/arch/x86/kernel/cpu/centaur.c
@@ -8,6 +8,7 @@
  #include <asm/e820/api.h>
  #include <asm/mtrr.h>
  #include <asm/msr.h>
+#include <asm/microcode.h>

  #include "cpu.h"

@@ -110,6 +111,8 @@ static void early_init_centaur(struct cpuinfo_x86 *c)

  static void init_centaur(struct cpuinfo_x86 *c)
  {
+       u32 chip_pf, dummy;
+
  #ifdef CONFIG_X86_32
         char *name;
         u32  fcr_set = 0;
@@ -201,6 +204,18 @@ static void init_centaur(struct cpuinfo_x86 *c)
         set_cpu_cap(c, X86_FEATURE_LFENCE_RDTSC);
  #endif

+       if (c->x86 == 6 && c->x86_model == 15 && c->x86_stepping >= 14) {
+               native_rdmsr(0x1232, dummy, chip_pf);
+               chip_pf = (chip_pf >> 15) & 0x7;
+               c->microcode = intel_get_microcode_revision();
+
+               if ((chip_pf == 0 && c->microcode < 0x20e) ||
+                       (chip_pf == 1 && c->microcode < 0x208)) {
+                       pr_warn_once("CPU has broken FSGSBASE support; 
clear FSGSBASE feature\n");
+                       setup_clear_cpu_cap(X86_FEATURE_FSGSBASE);
+               }
+       }
+
         init_ia32_feat_ctl(c);
  }

diff --git a/arch/x86/kernel/cpu/zhaoxin.c b/arch/x86/kernel/cpu/zhaoxin.c
index 031379b7d4fa..0a0525320502 100644
--- a/arch/x86/kernel/cpu/zhaoxin.c
+++ b/arch/x86/kernel/cpu/zhaoxin.c
@@ -5,6 +5,7 @@
  #include <asm/cpu.h>
  #include <asm/cpufeature.h>
  #include <asm/msr.h>
+#include <asm/microcode.h>

  #include "cpu.h"

@@ -68,6 +69,8 @@ static void early_init_zhaoxin(struct cpuinfo_x86 *c)

  static void init_zhaoxin(struct cpuinfo_x86 *c)
  {
+       u32 chip_pf, dummy;
+
         early_init_zhaoxin(c);
         init_intel_cacheinfo(c);

@@ -89,6 +92,18 @@ static void init_zhaoxin(struct cpuinfo_x86 *c)
         set_cpu_cap(c, X86_FEATURE_LFENCE_RDTSC);
  #endif

+       if (c->x86 == 6 && c->x86_model == 25 && c->x86_stepping <= 3) {
+               native_rdmsr(0x1232, dummy, chip_pf);
+               chip_pf = (chip_pf >> 15) & 0x7;
+               c->microcode = intel_get_microcode_revision();
+
+               if ((chip_pf == 0 && c->microcode < 0x20e) ||
+                       (chip_pf == 1 && c->microcode < 0x208)) {
+                       pr_warn_once("CPU has broken FSGSBASE support; 
clear FSGSBASE feature\n");
+                       setup_clear_cpu_cap(X86_FEATURE_FSGSBASE);
+               }
+       }
+
         init_ia32_feat_ctl(c);
  }


Sincerely!
TonyWWang-oc

On 2026/3/6 00:20, Dave Hansen wrote:
> 
> 
> [这封邮件来自外部发件人 谨防风险]
> 
> On 3/5/26 01:03, Tony W Wang-oc wrote:
>> --- a/arch/x86/kernel/cpu/zhaoxin.c
>> +++ b/arch/x86/kernel/cpu/zhaoxin.c
>> @@ -89,6 +89,11 @@ static void init_zhaoxin(struct cpuinfo_x86 *c)
>>          set_cpu_cap(c, X86_FEATURE_LFENCE_RDTSC);
>>   #endif
>>
>> +       if (c->x86 == 6 && c->x86_model == 25 && c->x86_stepping <= 3) {
>> +               pr_warn_once("CPU has broken FSGSBASE support; clear
>> FSGSBASE feature\n");
>> +               setup_clear_cpu_cap(X86_FEATURE_FSGSBASE);
>> +       }
>> +
> 
> Folks, we have vendor-generic infrastructure to handle these today. You
> don't need to hack copied and pasted code across vendor-specific files.
> You just need some "VFM" defines for the models:
> 
> #define Z_MODEL_HERE    VFM_MAKE(X86_VENDOR_ZHAOXIN, 6, 26)
> #define C_MODEL_HERE    VFM_MAKE(X86_VENDOR_ZHAOXIN, ...)
> 
> a table:
> 
> static const struct x86_cpu_id bum_fsgsbase[] __initconst = {
>          X86_MATCH_VFM_STEPS(Z_MODEL_HERE, X86_STEP_MIN, 0x3, 1),
>          X86_MATCH_VFM_STEPS(C_MODEL_HERE, ..., 1),
> };
> 
> and this code:
> 
>          if (x86_match_cpu(bum_fsgsbase))
>                  setup_clear_cpu_cap(X86_FEATURE_FSGSBASE);
> 
> That code happens _once_. You can even call it from vendor-independent code.
> 
> If you get fixed microcode that can also be extended to store a fixed
> microcode version (although we're moving away from doing this on Intel).
> 
> Just please give the models some semi-sane model name.

  reply	other threads:[~2026-03-12  2:15 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-28 17:37 Yao Zi
2026-02-28 19:06 ` Borislav Petkov
2026-03-01  9:27   ` Yao Zi
2026-03-01 18:37     ` David Laight
2026-03-02  5:09       ` Yao Zi
2026-03-01  0:33 ` Dave Hansen
2026-03-01  9:10   ` Yao Zi
2026-03-01 10:28   ` Borislav Petkov
2026-03-01 16:29 ` Andrew Cooper
2026-03-02  5:08   ` Yao Zi
2026-03-02  9:36     ` Andrew Cooper
2026-03-05  9:03 ` Tony W Wang-oc
2026-03-05 12:40   ` Andrew Cooper
2026-03-05 14:04   ` Yao Zi
2026-03-05 14:10     ` Andrew Cooper
2026-03-05 14:11   ` David Laight
2026-03-05 16:20   ` Dave Hansen
2026-03-12  2:14     ` Tony W Wang-oc [this message]
2026-03-12 15:52       ` Dave Hansen
2026-03-17  7:41         ` Tony W Wang-oc
2026-03-17 15:21           ` Dave Hansen
2026-03-18  3:44             ` Tony W Wang-oc
2026-03-05 20:26 Christian Ludloff
2026-03-12  2:18 ` Tony W Wang-oc
2026-03-12 16:31   ` Christian Ludloff

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=b16bda4b-c7cb-4e7f-ac71-57c0032c6633@zhaoxin.com \
    --to=tonywwang-oc@zhaoxin.com \
    --cc=CobeChen@zhaoxin.com \
    --cc=HerryYang@zhaoxin.com \
    --cc=QiyuanWang@zhaoxin.com \
    --cc=TimGuo@zhaoxin.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=benjaminpan@viatech.com \
    --cc=bp@alien8.de \
    --cc=cooperyan@zhaoxin.com \
    --cc=dave.hansen@intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lukelin@viacpu.com \
    --cc=me@ziyao.cc \
    --cc=mingo@redhat.com \
    --cc=stable@vger.kernel.org \
    --cc=tglx@kernel.org \
    --cc=x86@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®