mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dave Hansen <dave.hansen@intel.com>
To: Tony W Wang-oc <TonyWWang-oc@zhaoxin.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 08:52:37 -0700	[thread overview]
Message-ID: <03a03ec8-4309-42ac-a13d-2fcc8396d547@intel.com> (raw)
In-Reply-To: <b16bda4b-c7cb-4e7f-ac71-57c0032c6633@zhaoxin.com>

On 3/11/26 19:14, Tony W Wang-oc wrote:
> 
> 
> +       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);
> +               }
> +       }

So, I'm sorry but that's not really consistent how we're doing things
these days.

The model needs a symbolic name.

The MSR you're reading is completely undocumented and unnamed.

"chip_pf" is nonsensical and unexplained.

Code is duplicated across the centaur and zhaoxin files.

Once you have all of that fixed, you should have a simple:

#define CENTAUR_MODEL_FOO VFM_MAKE(X86_VENDOR_CENTAUR, 6, 15)
#define ZHAOXIN_MODEL_BAR VFM_MAKE(X86_VENDOR_ZHAOXIN, 6, 25)

in a central header, plus:

struct x86_cpu_id *naughty_list[] = {
	X86_MATCH_VFM_STEPS(CENTAUR_MODEL_FOO,       14, MAX_STEP, 0),
	X86_MATCH_VFM_STEPS(ZHAOXIN_MODEL_BAR, MIN_STEP,        3, 0),
	{}
};

void check_fsgsbase_bugs()
{
	u32 fixed_ucode;

	if (!cpu_feature_enabled(X86_FEATURE_FSGSBASE))
		return;

	c = x86_match_cpu(naughty_list);
	if (!c)
		return;

	chip_pf = ...
	if (chip_pf == 0)
		fixed_ucode = 0x20e;
	if (chip_pf == 1)
		fixed_ucode = 0x208;

	if (intel_get_microcode_revision() >= fixed_ucode)
		return;

	pr_warn_once("Broken FSGSBASE support, clearing feature\n");
	setup_clear_cpu_cap(X86_FEATURE_FSGSBASE);
}

Then check_fsgsbase_bugs() can pretty much be called anywhere. It can
even be in generic code.

We are also getting some new matching fields in 'x86_cpu_id'. I suspect
'chip_pf' can be stored in there where Intel has the platform_id right
now. But you don't have to do that now.

Could you please go this route rather than copy-and-pasted chunks of
code sprinkled with a healthy dose of magic numbers?

  reply	other threads:[~2026-03-12 15:52 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
2026-03-12 15:52       ` Dave Hansen [this message]
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=03a03ec8-4309-42ac-a13d-2fcc8396d547@intel.com \
    --to=dave.hansen@intel.com \
    --cc=CobeChen@zhaoxin.com \
    --cc=HerryYang@zhaoxin.com \
    --cc=QiyuanWang@zhaoxin.com \
    --cc=TimGuo@zhaoxin.com \
    --cc=TonyWWang-oc@zhaoxin.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=benjaminpan@viatech.com \
    --cc=bp@alien8.de \
    --cc=cooperyan@zhaoxin.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

Powered by JetHome