Re: [PATCH] KVM: x86: Allow XSAVES on CPUs where host doesn't use it due to an errata

From: Maciej S. Szmigiero
Date: Fri Dec 01 2023 - 11:05:13 EST


On 1.12.2023 00:57, Jim Mattson wrote:
On Thu, Nov 30, 2023 at 2:00 PM Maciej S. Szmigiero
<mail@xxxxxxxxxxxxxxxxxxxxx> wrote:
I think that if particular guest would work on bare metal it should
work on "-cpu host" too - no tinkering should be required for such
basic functionality as being able to successfully finish booting.

I disagree. Let's not focus on one particular erratum. If, for
whatever reason, the host kernel is booted with "noxsaves," I don't
think KVM should allow a guest to bypass that directive.

Good point, I agree that if user explicitly disabled XSAVES on
the host via this parameter then it should remain disabled for
the whole host kernel, including KVM.

This could be achieved by either adding special "noxsaves" flag
or by setting X86_BUG_XSAVES_AVOID instead of clearing
X86_FEATURE_XSAVES on these CPUs.

Then the core kernel XSAVES code would check for lack of
X86_BUG_XSAVES_AVOID (in addition to checking for
presence of X86_FEATURE_XSAVES) while KVM would keep using
only X86_FEATURE_XSAVES.

Thanks,
Maciej