Re: [PATCH v4 30/30] KVM: x86: Move a pile of stuff from kvm_host.h => x86.h
From: Sean Christopherson
Date: Mon Jun 15 2026 - 10:26:16 EST
On Mon, Jun 15, 2026, Kai Huang wrote:
> On Fri, 2026-06-12 at 17:03 -0700, Sean Christopherson wrote:
> > Move the majority of remaining KVM-internal declarations and defines in
> > kvm_host.h to x86.h, so that kvm_host.h only holds structure and function
> > definitions that need to be visible to arch-neutral KVM.
> >
> > Land the emulator interfaces in x86.h, even though kvm_emulate.h *seems*
> > like a good home, as the interfaces and defines being moved are provided by
> > x86.c. I.e. keep kvm_emulate.h as an interface to the emulator proper.
> >
> > Note, any "misses" are likely unintentional.
> >
> > Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx>
>
> [...]
>
> > -
> > #define TSS_IOPB_BASE_OFFSET 0x66
> > #define TSS_BASE_SIZE 0x68
> > #define TSS_IOPB_SIZE (65536 / 8)
>
> Nit: Seems sashiko was right about TSS_IOPB_BASE and the related macros can be
> moved out of asm/kvm_host.h (ditto for the enum of TASK_SWITCH_*)?
Hmm, agreed. arch/x86/kvm/tss.h seems like the perfect fit. It would be easy
to slot in a patch to move these ahead of the bulk move to x86.h.
> https://lore.kernel.org/kvm/20260530075928.888B61F00893@xxxxxxxxxxxxxxx/
>
> But you said "majority" in the changelog, so we can always do more cleanup
> later. :-)
>
> [...]
>
> > +void __kvm_set_or_clear_apicv_inhibit(struct kvm *kvm,
> > + enum kvm_apicv_inhibit reason, bool set);
> > +void kvm_set_or_clear_apicv_inhibit(struct kvm *kvm,
> > + enum kvm_apicv_inhibit reason, bool set);
> > +
> > +static inline void kvm_set_apicv_inhibit(struct kvm *kvm,
> > + enum kvm_apicv_inhibit reason)
> > +{
> > + kvm_set_or_clear_apicv_inhibit(kvm, reason, true);
> > +}
> > +
> > +static inline void kvm_clear_apicv_inhibit(struct kvm *kvm,
> > + enum kvm_apicv_inhibit reason)
> > +{
> > + kvm_set_or_clear_apicv_inhibit(kvm, reason, false);
> > +}
> > +
>
> The definition of 'enum kvm_apicv_inhibit' remains in asm/kvm_host.h. Is it
> because "trace.h" still uses APICV_INHIBIT_REASONS?
No, pretty sure I just overlooked the enum. I'll do another pass of kvm_host.h
to see what #defines and enums can be moved.