From: Sean Christopherson <seanjc@google.com>
To: Borislav Petkov <bp@alien8.de>
Cc: Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>,
Dave Hansen <dave.hansen@linux.intel.com>,
x86@kernel.org, Paolo Bonzini <pbonzini@redhat.com>,
"H. Peter Anvin" <hpa@zytor.com>,
linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Subject: Re: [PATCH 1/3] x86/cpu: Process all CPUID dependencies after identifying CPU info
Date: Thu, 8 Dec 2022 16:26:29 +0000 [thread overview]
Message-ID: <Y5IQNY/fZw2JFA0B@google.com> (raw)
In-Reply-To: <Y5INU3o+SFReGkLz@zn.tnic>
On Thu, Dec 08, 2022, Borislav Petkov wrote:
> On Sat, Dec 03, 2022 at 12:37:43AM +0000, Sean Christopherson wrote:
> > Process all CPUID dependencies to ensure that a dependent is disabled if
> > one or more of its parent features is unsupported.
>
> Just out of curiosity: this is some weird guest configuration, right?
No, it's also relevant for bare metal.
> Not addressing a real hw issue...
But it's not really a hardware issue either. More like an admin/user issue.
The problem is that if a kernel is built for subset of CPU types, e.g. just Intel
or just Centaur, and then booted on an "unsupported" CPU type, init_ia32_feat_ctl()
will never be invoked because ->c_init() will point a default_init(), and so the
kernel never checks MSR_IA32_FEAT_CTL to see if VMX and/or SGX are fully enabled.
E.g. if someone booted an "unsupported" kernel and also disabled VMX in BIOS, then
the CPU will enumerate support for VMX in CPUID, but attempting to actually enable
VMX will fail due to VMX being disabled in MSR_IA32_FEAT_CTL.
> > diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
> > index bf4ac1cb93d7..094fc69dba63 100644
> > --- a/arch/x86/kernel/cpu/common.c
> > +++ b/arch/x86/kernel/cpu/common.c
> > @@ -1887,6 +1887,12 @@ static void identify_cpu(struct cpuinfo_x86 *c)
> >
> > ppin_init(c);
> >
> > + /*
> > + * Apply CPUID dependencies to ensure dependent features are disabled
> > + * if a parent feature is unsupported but wasn't explicitly disabled.
> > + */
> > + apply_cpuid_deps(c);
>
> I'd probably call that resolve_cpuid_deps()...
"resolve" works for me.
next prev parent reply other threads:[~2022-12-08 16:26 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-03 0:37 [PATCH 0/3] x86/cpu: KVM: Make SGX and VMX depend on FEAT_CTL Sean Christopherson
2022-12-03 0:37 ` [PATCH 1/3] x86/cpu: Process all CPUID dependencies after identifying CPU info Sean Christopherson
2022-12-08 16:14 ` Borislav Petkov
2022-12-08 16:26 ` Sean Christopherson [this message]
2022-12-08 16:45 ` Borislav Petkov
2023-01-04 21:02 ` Sean Christopherson
2023-01-04 22:55 ` Borislav Petkov
2023-01-04 23:18 ` Sean Christopherson
2023-01-05 10:15 ` Borislav Petkov
2022-12-03 0:37 ` [PATCH 2/3] x86/cpu: Mark SGX and VMX as being dependent on MSR_IA32_FEAT_CTL Sean Christopherson
2022-12-03 0:37 ` [PATCH 3/3] KVM: VMX: Drop manual checks on X86_FEATURE_MSR_IA32_FEAT_CTL Sean Christopherson
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=Y5IQNY/fZw2JFA0B@google.com \
--to=seanjc@google.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=tglx@linutronix.de \
--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