All of lore.kernel.org
 help / color / mirror / Atom feed
From: "H. Peter Anvin" <hpa@zytor.com>
To: Borislav Petkov <bp@alien8.de>
Cc: Maciej Wieczor-Retman <m.wieczorretman@pm.me>,
	tglx@kernel.org, peterz@infradead.org, xin@zytor.com,
	maciej.wieczor-retman@intel.com, babu.moger@amd.com,
	chang.seok.bae@intel.com, sohil.mehta@intel.com,
	dave.hansen@linux.intel.com, jpoimboe@kernel.org,
	elena.reshetova@intel.com, pawan.kumar.gupta@linux.intel.com,
	ak@linux.intel.com, darwi@linutronix.de, mingo@redhat.com,
	x86@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v11 3/4] x86/cpu: Do a sanity check on required feature bits
Date: Mon, 23 Mar 2026 13:24:25 -0700	[thread overview]
Message-ID: <e59fc661-6e27-49ca-9582-cf8dd99585e8@zytor.com> (raw)
In-Reply-To: <20260323191905.GDacGSKaG4rEU8O4NA@fat_crate.local>

On 2026-03-23 12:19, Borislav Petkov wrote:
> On Mon, Mar 23, 2026 at 11:43:08AM -0700, H. Peter Anvin wrote:
>> That is not necessarily true at all.
> 
> What does that even mean?! :)
> 
>> As such, this may be a really cheap way to get a message out in case we get
>> that far without problems.
> 
> Meh.
> 
>> For one thing, this runs -- at least on the BSP -- before either alternatives
>> patching or running user space, so there is plenty of features that may not
>> have been used yet.
> 
> We're talking about required features here. What's wrong with verify_cpu()
> testing required features and stopping if some of them are not present?
> 
> It is already checking some of them.
> 

Well, there is the bits which need to be in assembly because they

>> For another thing, there are some features -- such as PAE to mention one --
>> that are present in some CPUs but disabled in CPUID because for some reason or
>> another the manufacturer found during testing that it doesn't always work
>> right. However, it is likely that a PAE kernel will successfully boot, and it
>> might even work on any one particular CPU. This is *exactly* what
>> TAINT_CPU_OUT_OF_SPEC is supposed to represent.
> 
> And?
> 
> We're supposed to support such a CPU or somewhat wobbly only?
>
> You want to be able to boot up to the point of checking required features in
> C code, find out that PAE is not supported, taint the CPU but still run?
> 
> What for?
> 
> How do you explain the user that her machine is actually fine but we'll taint
> the kernel and that it maybe works but maybe not and there are no guarantees?

That is EXACTLY what TAINT_CPU_OUT_OF_SPEC means.


>> Finally, as Maciej reported, the user might have tried to explicitly override
>> a required feature.
> 
> You can still catch it in verify_cpu. Catch it such that you simply stop
> there.
> 
> If the luser is overriding required features, then she gets to keep both
> pieces.

It doesn't mean we can't at least TRY to warn things.

>> verify_cpu.S serves a different purpose: is to enable features that are
>> required to even set up the kernel execution environment and that may be
>> switched off through various mechanisms.
> 
> And because we run it at so many places, then it can do those checks for us
> too.
> 
>> verify_cpu.S is unfortunately not able to issue messages (not to mention that
>> it is written in assembly,
> 
> We can convert it to C. We've done this before with other crap. :)

No, you can't, because YOU CAN'T GET FAR ENOUGH ALONG TO RUN C CODE WITHOUT
IT. That is what is unique about verify_cpu.S. It should probably really be
called "enable_cpu.S".

It doesn't mean you can't do an earlier check, but at that point you pretty
much need the entire machinery of arch/x86/kernel/cpu.

We COULD push a lot of that code much earlier, and make it sharable with the
boot/compressed prekernel, but that is a cleanup on a whole different scale.

> Yes, I have seen the error message about this CPU not being supported very
> early.
> 
> But I don't see the point for adding another function to verify required
> features which is somewhere else where we're pretty much doing that checking
> early.

Well, for one thing: it lets us avoid more ad hoc messages in central code.

> And what's the point of booting up to C code and kernel proper and say that
> some of the required features are off?
> 
> I think we should extend verify_cpu or convert it to C or have it call
> a C function or whatever and do the checking once and for all and not boot
> into a wobbly and tainted kernel.
> 
> As to showing a proper error message, what is the real use case we're chasing
> here?
> 
> The CPU has all the required features - which is probably 99.999% of the cases
> out there or it doesn't and then it deserves to blow up.
> 
> So what are we really "fixing" here...?
You can make the same argument about #MC for example: why bother trying to get
a message out when the CPU is literally telling you that your system just broke?

The answer is because it helps the user understand what is wrong. Certainly,
you have no guarantee that you will actually get there, but in practice, in
many (but definitely not all) cases you WILL be able to get far enough along
to get the message out so that when the user wonders why their machine crashed
they have a clue.

	-hpa


  reply	other threads:[~2026-03-23 20:25 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-20 12:50 [PATCH v11 0/4] x86: Capability bits fix and required bits sanity check Maciej Wieczor-Retman
2026-03-20 12:50 ` [PATCH v11 1/4] x86/cpu: Clear feature bits disabled at compile-time Maciej Wieczor-Retman
2026-03-20 12:50 ` [PATCH v11 2/4] x86/cpu: Check if feature string is non-zero Maciej Wieczor-Retman
2026-03-23 14:24   ` Borislav Petkov
2026-03-23 15:52     ` Maciej Wieczor-Retman
2026-03-23 16:23       ` Borislav Petkov
2026-03-23 16:58         ` Maciej Wieczor-Retman
2026-03-23 17:51           ` Borislav Petkov
2026-03-23 18:11             ` Maciej Wieczor-Retman
2026-03-23 18:15               ` H. Peter Anvin
2026-03-20 12:50 ` [PATCH v11 3/4] x86/cpu: Do a sanity check on required feature bits Maciej Wieczor-Retman
2026-03-21  0:31   ` Pawan Gupta
2026-03-21  5:58     ` Maciej Wieczór-Retman
2026-03-23 18:16       ` Pawan Gupta
2026-03-23 18:33         ` Maciej Wieczor-Retman
2026-03-26 18:36     ` Maciej Wieczor-Retman
2026-03-26 19:04       ` Pawan Gupta
2026-03-26 19:11         ` Maciej Wieczor-Retman
2026-03-28  1:52           ` H. Peter Anvin
2026-03-28  2:01             ` H. Peter Anvin
2026-03-30  9:47               ` Maciej Wieczor-Retman
2026-03-30 10:09             ` Maciej Wieczor-Retman
2026-03-30 16:01               ` Pawan Gupta
2026-03-30 21:24               ` David Laight
2026-03-31  8:12                 ` Maciej Wieczor-Retman
2026-03-31 13:29             ` Maciej Wieczor-Retman
2026-03-23 16:31   ` Borislav Petkov
2026-03-23 17:05     ` Maciej Wieczor-Retman
2026-03-23 17:55       ` Borislav Petkov
2026-03-23 18:43         ` H. Peter Anvin
2026-03-23 18:43     ` H. Peter Anvin
2026-03-23 19:19       ` Borislav Petkov
2026-03-23 20:24         ` H. Peter Anvin [this message]
2026-03-23 20:58           ` Borislav Petkov
2026-03-23 21:40             ` H. Peter Anvin
2026-03-23 21:50               ` Borislav Petkov
2026-03-23 21:56                 ` Borislav Petkov
2026-03-23 22:03                 ` H. Peter Anvin
2026-03-23 22:09                   ` Borislav Petkov
2026-03-24  1:16                     ` H. Peter Anvin
2026-03-20 12:50 ` [PATCH v11 4/4] x86/cpu: Clear feature bits whose dependencies were cleared Maciej Wieczor-Retman
2026-03-23 16:35   ` Borislav Petkov
2026-03-23 17:23     ` Maciej Wieczor-Retman
2026-03-23 17:59       ` Borislav Petkov
2026-03-23 18:18         ` Maciej Wieczor-Retman
2026-03-23 18:57         ` H. Peter Anvin
2026-03-23 19:30           ` Borislav Petkov
2026-03-25  9:33             ` Maciej Wieczor-Retman
2026-03-23 19:33           ` Ahmed S. Darwish

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=e59fc661-6e27-49ca-9582-cf8dd99585e8@zytor.com \
    --to=hpa@zytor.com \
    --cc=ak@linux.intel.com \
    --cc=babu.moger@amd.com \
    --cc=bp@alien8.de \
    --cc=chang.seok.bae@intel.com \
    --cc=darwi@linutronix.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=elena.reshetova@intel.com \
    --cc=jpoimboe@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m.wieczorretman@pm.me \
    --cc=maciej.wieczor-retman@intel.com \
    --cc=mingo@redhat.com \
    --cc=pawan.kumar.gupta@linux.intel.com \
    --cc=peterz@infradead.org \
    --cc=sohil.mehta@intel.com \
    --cc=tglx@kernel.org \
    --cc=x86@kernel.org \
    --cc=xin@zytor.com \
    /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.