public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Borislav Petkov <bp@alien8.de>
Cc: kernel test robot <oliver.sang@intel.com>,
	oe-lkp@lists.linux.dev, lkp@intel.com,
	 linux-kernel@vger.kernel.org, x86@kernel.org,
	Ingo Molnar <mingo@kernel.org>,
	 Srikanth Aithal <sraithal@amd.com>
Subject: Re: [tip:x86/alternatives] [x86/alternatives] ee8962082a: WARNING:at_arch/x86/kernel/cpu/cpuid-deps.c:#do_clear_cpu_cap
Date: Tue, 30 Apr 2024 12:51:02 -0700	[thread overview]
Message-ID: <ZjFLpkgI3Zl4dsXs@google.com> (raw)
In-Reply-To: <20240430193211.GEZjFHO0ayDXtgvbE7@fat_crate.local>

On Tue, Apr 30, 2024, Borislav Petkov wrote:
> On Tue, Apr 30, 2024 at 11:40:14AM -0700, Sean Christopherson wrote:
> > Hmm, I don't think the problem is that init_ia32_feat_ctl() is called too late.
> > It too is called from the BSP prior to alternative_instructions():
> > 
> >   arch_cpu_finalize_init()
> >   |
> >   -> identify_boot_cpu()
> >      |
> >      -> identify_cpu()
> >         |
> >         -> .c_init() => init_intel()
> 
> Yeah, but look at the his stacktrace:
> 
> [ 0.055225][ T0] init_intel (arch/x86/include/asm/msr.h:146 arch/x86/include/asm/msr.h:300 arch/x86/kernel/cpu/intel.c:583
> +arch/x86/kernel/cpu/intel.c:687)
> [ 0.055225][ T0] identify_cpu (arch/x86/kernel/cpu/common.c:1824)
> [ 0.055225][ T0] identify_secondary_cpu (arch/x86/kernel/cpu/common.c:1949)
> [ 0.055225][ T0] smp_store_cpu_info (arch/x86/kernel/smpboot.c:333)
> 
> That's after alternatives.
>
> > Ah, and the WARN even specifically checks for the case where there's divergence
> > from the boot CPU:
> > 
> > 	if (boot_cpu_has(feature))
> > 		WARN_ON(alternatives_patched);
> 
> Funny you should mention that - I have this check in
> setup_force_cpu_cap() too which works on boot_cpu_data *BUT*, actually,
> the test in do_clear_cpu_cap() should be:
> 
>         if (c && cpu_has(c, feature))
>                 WARN_ON(alternatives_patched);
> 
> because setting a feature flag in *any* CPU's cap field is wrong after
> alternatives because as explained earlier.
> 
> I know, our feature flags handling is a major mess.

...

> my guess would be no and that init_ia32_feat_ctl() really needs to go
> before alternatives have been patched because it clears flags.

But that would just mask the underlying problem, it wouldn't actually fix anything
other than making the WARN go away.  Unless I'm misreading the splat+code, the
issue isn't that init_ia32_feat_ctl() clears VMX late, it's that the BSP sees
VMX as fully enabled, but at least one AP sees VMX as disabled.

I don't see how the kernel can expect to function correctly with divergent feature
support across CPUs, i.e. the WARN is a _good_ thing in this case, because it
alerts the user that their system is messed up, e.g. has a bad BIOS or something.

  reply	other threads:[~2024-04-30 19:51 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-30 15:00 [tip:x86/alternatives] [x86/alternatives] ee8962082a: WARNING:at_arch/x86/kernel/cpu/cpuid-deps.c:#do_clear_cpu_cap kernel test robot
2024-04-30 17:23 ` Borislav Petkov
2024-04-30 18:40   ` Sean Christopherson
2024-04-30 19:32     ` Borislav Petkov
2024-04-30 19:51       ` Sean Christopherson [this message]
2024-04-30 22:33         ` Borislav Petkov
2024-05-04 12:48           ` Borislav Petkov
2024-05-04 12:49             ` [PATCH 1/2] x86/alternatives: Check the correct cpu_data's caps Borislav Petkov
2024-05-04 12:50             ` [PATCH 2/2] x86/CPU/Intel: Do the MSR_IA32_FEAT_CTL setup before alternatives Borislav Petkov
2024-05-06  7:09             ` [tip:x86/alternatives] [x86/alternatives] ee8962082a: WARNING:at_arch/x86/kernel/cpu/cpuid-deps.c:#do_clear_cpu_cap Oliver Sang
2024-05-06  7:39               ` Borislav Petkov
2024-05-06  8:01                 ` Borislav Petkov
2024-05-06  8:12                   ` Borislav Petkov
2024-05-07  2:29                     ` Oliver Sang
2024-05-06 15:28               ` Sean Christopherson
2024-05-06 15:57                 ` Borislav Petkov
2024-05-07  7:08                   ` Oliver Sang
2024-05-07 11:48                     ` Borislav Petkov
2024-05-07 17:09                       ` Sean Christopherson
2024-05-08  8:08                       ` Oliver Sang
2024-05-08  8:24                         ` Borislav Petkov
2024-05-08  8:37                           ` Oliver Sang

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=ZjFLpkgI3Zl4dsXs@google.com \
    --to=seanjc@google.com \
    --cc=bp@alien8.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=mingo@kernel.org \
    --cc=oe-lkp@lists.linux.dev \
    --cc=oliver.sang@intel.com \
    --cc=sraithal@amd.com \
    --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