Re: [PATCH v3 26/40] KVM: x86: Move the bulk of MSR specific code from x86.c to msrs.{c,h}
From: Huang, Kai
Date: Thu Jun 04 2026 - 08:05:07 EST
On Fri, 2026-05-29 at 15:22 -0700, Sean Christopherson wrote:
> Introduce msrs.{c,h}, and move the vast majority of MSR specific code out
> of x86.{c,h}. Use a plural "msrs" instead of just "msr" to be consistent
> with regs.{c,h}, and to make it easier to differentiate KVM's code from the
> other 5+ msr.c files in the kernel.
>
> No functional change intended.
>
> Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx>
Tried best to review, seems fine:
Reviewed-by: Kai Huang <kai.huang@xxxxxxxxx>
[...]
> +static inline bool kvm_is_valid_u_s_cet(struct kvm_vcpu *vcpu, u64 data)
> +{
> + if (data & CET_US_RESERVED_BITS)
> + return false;
> + if (!guest_cpu_cap_has(vcpu, X86_FEATURE_SHSTK) &&
> + (data & CET_US_SHSTK_MASK_BITS))
> + return false;
> + if (!guest_cpu_cap_has(vcpu, X86_FEATURE_IBT) &&
> + (data & CET_US_IBT_MASK_BITS))
> + return false;
> + if (!IS_ALIGNED(CET_US_LEGACY_BITMAP_BASE(data), 4))
> + return false;
> + /* IBT can be suppressed iff the TRACKER isn't WAIT_ENDBR. */
> + if ((data & CET_SUPPRESS) && (data & CET_WAIT_ENDBR))
> + return false;
> +
> + return true;
> +}
Nit: AFAICT the purpose of this being in msrs.h is it is also used by
vmx/nested.c. Not sure whether you want to explicitly include "msrs.h" in
vmx/nested.c
> +
> +#endif
> \ No newline at end of file
No newline at end of file
> diff --git a/arch/x86/kvm/mtrr.c b/arch/x86/kvm/mtrr.c
> index 6f74e2b27c1e..4f3b7b0f6565 100644
> --- a/arch/x86/kvm/mtrr.c
> +++ b/arch/x86/kvm/mtrr.c
> @@ -19,6 +19,7 @@
> #include <asm/mtrr.h>
>
> #include "cpuid.h"
> +#include "msrs.h"
> #include "x86.h"
Seems "x86.h" is not needed anymore.
[...]
>
> static DEFINE_MUTEX(vendor_module_lock);
> -
> struct kvm_x86_ops kvm_x86_ops __read_mostly;
Nit of nit: seems unintended change.