[PATCH v2 1/8] x86/fpu: Check for missing AVX and AVX-512 xstate bits

Borislav Petkov bp at alien8.de
Tue Jul 28 15:59:36 PDT 2026


On Tue, Jul 28, 2026 at 06:34:47PM +0000, Eric Biggers wrote:
> The argument is the bitmask of xfeatures that are present.  0 is an
> empty bitmask, i.e. no xfeatures are present.

Ok, so what does that mean when you see it in the code:

	clear_cpu_caps_with_missing_xfeatures(0)

clear the CPU caps with missing xfeatures bitmask 0?

> I can rename it to xfeatures_present and/or document the argument
> explicitly in the function comment, if that would help.

I guess. I like the documentation aspect.

> I'm not sure what this question is asking, but UML indeed doesn't
> implement cpu_has_xfeatures().  Currently most of the AVX optimized code
> isn't enabled on UML, which avoids this limitation.  The RAID code is
> different though, as it's enabled on UML.

You brought up the UML example upthread. I'm trying to figure out why we care
about the UML case. I'm also assuming that case will be fixed with whatever we
end up doing here.

> First, the code being added *is* to fpu__init_system_xstate().  Do you
> think it needs to be moved later in the function, and if so why?

Lemme try again:

there where we sanity check the xfeatures mask, at that same place we can
sanity check the X86_FEATURE flags we have set in our internal representation
of CPUID flags. At exactly the same place. And we warn and clear the ones are
wrong.

> Second, clearing xfeatures is the opposite of what's needed.

I meant clearing X86_FEATURE flags. Basically what you started doing.

All I'm proposing is having the *whole* X86_FEATURE clearing concentrated in
a single function so that it is called once per CPU and then we're done.

That's it.

Thx.

-- 
Regards/Gruss,
    Boris.

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



More information about the linux-um mailing list