Re: [PATCH v3 30/40] KVM: x86: Move MSR helper declarations from kvm_host.h => msrs.h
From: Huang, Kai
Date: Fri Jun 05 2026 - 02:55:19 EST
On Fri, 2026-05-29 at 15:22 -0700, Sean Christopherson wrote:
> Relocate declarations of MSR helpers (and kvm_nr_uret_msrs) from x86's
> x86's kvm_host.h to msrs, to continue trimming down kvm_host.h.
Double x86's
>
> Deliberately leave the funky read_msr() where it is, as it will hopefully
> be removed entirely as part of a broader kernel-API cleanup.
>
> No functional change intended.
>
> Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx>
Reviewed-by: Kai Huang <kai.huang@xxxxxxxxx>
Btw, not sure whether you like:
We can also move the body of 'struct msr_bitmap_range' and 'struct
kvm_x86_msr_filter' to "msrs.h" too, if we put one
struct kvm_x86_msr_filter;
to <asm/kvm_host.h> before 'struct kvm_arch'.
The below diff passed build at my side:
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index 1143140592df..f87b839fd3a4 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -1291,13 +1291,6 @@ struct kvm_hv {
};
#endif
-struct msr_bitmap_range {
- u32 flags;
- u32 nmsrs;
- u32 base;
- unsigned long *bitmap;
-};
-
#ifdef CONFIG_KVM_XEN
/* Xen emulation context */
struct kvm_xen {
@@ -1328,12 +1321,6 @@ enum kvm_suppress_eoi_broadcast_mode {
KVM_SUPPRESS_EOI_BROADCAST_DISABLED /* Disable Suppress EOI broadcast */
};
-struct kvm_x86_msr_filter {
- u8 count;
- bool default_allow:1;
- struct msr_bitmap_range ranges[16];
-};
-
struct kvm_x86_pmu_event_filter {
__u32 action;
__u32 nevents;
@@ -1478,6 +1465,8 @@ enum kvm_mmu_type {
KVM_NR_MMU_TYPES,
};
+struct kvm_x86_msr_filter;
+
struct kvm_arch {
unsigned long n_used_mmu_pages;
unsigned long n_requested_mmu_pages;
diff --git a/arch/x86/kvm/msrs.h b/arch/x86/kvm/msrs.h
index 5c8362a8fd97..7a690a515947 100644
--- a/arch/x86/kvm/msrs.h
+++ b/arch/x86/kvm/msrs.h
@@ -13,6 +13,19 @@ extern bool ignore_msrs;
extern u32 __read_mostly kvm_nr_uret_msrs;
+struct msr_bitmap_range {
+ u32 flags;
+ u32 nmsrs;
+ u32 base;
+ unsigned long *bitmap;
+};
+
+struct kvm_x86_msr_filter {
+ u8 count;
+ bool default_allow:1;
+ struct msr_bitmap_range ranges[16];
+};
+
static inline void kvm_pr_unimpl_wrmsr(struct kvm_vcpu *vcpu, u32 msr, u64
data)
{
if (report_ignored_msrs)
@@ -153,4 +166,4 @@ static inline bool kvm_is_valid_u_s_cet(struct kvm_vcpu
*vcpu, u64 data)
return true;
}
-#endif
\ No newline at end of file
+#endif