Re: [PATCH] x86: Clear LAM and FRED feature bits

From: Xin Li
Date: Tue Jul 22 2025 - 13:22:34 EST


On 7/22/2025 9:46 AM, H. Peter Anvin wrote:
The following code will work as a generic fix:

c->x86_capability[i] &= ~DISABLED_MASK(i);

And DISABLED_MASK(x) needs to be defined like DISABLED_MASK_BIT_SET(x).

Thanks!
Xin
The easiest thing would be to initialize the setup disabled mask with the DISABLED bitmask instead of zero. This can be done statically; if it isn't already the awk script can produce the disabled bitmask in array form.

Yes, something like:

void __init init_cpu_cap(void)
{
for (i = 0; i < NCAPINTS; i++) {
cpu_caps_set[i] = REQUIRED_MASK(i);
cpu_caps_cleared[i] = DISABLED_MASK(i);
}
}

And it would be better if it could be done at build time (to avoid
changing Xen which has a dedicated startup code path):

__u32 cpu_caps_{set,cleared}[NCAPINTS + NBUGINTS] = {
{REQUIRED,DISABLED}_MASK(i),
};

And then apply_forced_caps() will do the rest automatically :)