Re: [PATCH v2 1/2] x86/cpu, kvm: Use CPU capabilities for CPUID[0x80000021].EAX

From: Borislav Petkov
Date: Tue Nov 29 2022 - 10:50:49 EST


On Mon, Nov 28, 2022 at 05:00:43PM -0600, Kim Phillips wrote:
> > verify_tags: WARNING: Co-developed-by Babu Moger <Babu.Moger@xxxxxxx> hasn't signed off on the patch!
>
> OK, I'll add his signed-off-by.

You can't just add his SOB - he needs to give it himself.

"Certificate of Origin" in Documentation/process/submitting-patches.rst
needs brushing up on, it seems.

> Not sure I follow. That code (originally from commit f144c49e8c39
> ("KVM: x86: synthesize CPUID leaf 0x80000021h if useful") doesn't
> negate that: the code is saying that if we don't have the bug, then
> set the feature bit that says we don't have the bug.

I was thinking of the case described here:

415de4407664 ("x86/cpu: Fix migration safety with X86_BUG_NULL_SEL")

but I guess we can do that on the host.

> > Which means, you'd have to update check_null_seg_clears_base() too.
>
> Like this?:
>
> diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
> index 73cc546e024d..bbe96d71ff5e 100644
> --- a/arch/x86/kernel/cpu/common.c
> +++ b/arch/x86/kernel/cpu/common.c
> @@ -1682,11 +1682,6 @@ void check_null_seg_clears_base(struct cpuinfo_x86 *c)
> if (!IS_ENABLED(CONFIG_X86_64))
> return;
>
> - /* Zen3 CPUs advertise Null Selector Clears Base in CPUID. */
> - if (c->extended_cpuid_level >= 0x80000021 &&
> - cpuid_eax(0x80000021) & BIT(6))
> - return;
> -

No, not like this. The above you've removed needs to be

if (cpu_has(c, X86_FEATURE_NULL_SEL_CLR_BASE))
return;

so that you exit early.

Thx.

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette