]> git.itanic.dy.fi Git - linux-stable/commitdiff
KVM: x86/xen: Remove unneeded xen context from kvm_arch when !CONFIG_KVM_XEN
authorVitaly Kuznetsov <vkuznets@redhat.com>
Tue, 5 Dec 2023 10:36:15 +0000 (11:36 +0100)
committerSean Christopherson <seanjc@google.com>
Thu, 7 Dec 2023 17:33:42 +0000 (09:33 -0800)
Saving a few bytes of memory per KVM VM is certainly great but what's more
important is the ability to see where the code accesses Xen emulation
context while CONFIG_KVM_XEN is not enabled. Currently, kvm_cpu_get_extint()
is the only such place and it is harmless: kvm_xen_has_interrupt() always
returns '0' when !CONFIG_KVM_XEN.

No functional change intended.

Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
Tested-by: Jeremi Piotrowski <jpiotrowski@linux.microsoft.com>
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Link: https://lore.kernel.org/r/20231205103630.1391318-2-vkuznets@redhat.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/include/asm/kvm_host.h
arch/x86/kvm/irq.c

index 5e5e9e0abd4a06104fd1b815bacd3a036bfa511c..b0ca65632f2cea66b57ea09da9cd8307bbbdaac6 100644 (file)
@@ -1136,6 +1136,7 @@ struct msr_bitmap_range {
        unsigned long *bitmap;
 };
 
+#ifdef CONFIG_KVM_XEN
 /* Xen emulation context */
 struct kvm_xen {
        struct mutex xen_lock;
@@ -1147,6 +1148,7 @@ struct kvm_xen {
        struct idr evtchn_ports;
        unsigned long poll_mask[BITS_TO_LONGS(KVM_MAX_VCPUS)];
 };
+#endif
 
 enum kvm_irqchip_mode {
        KVM_IRQCHIP_NONE,
@@ -1349,7 +1351,10 @@ struct kvm_arch {
        struct hlist_head mask_notifier_list;
 
        struct kvm_hv hyperv;
+
+#ifdef CONFIG_KVM_XEN
        struct kvm_xen xen;
+#endif
 
        bool backwards_tsc_observed;
        bool boot_vcpu_runs_old_kvmclock;
index b2c397dd2bc6620c54f045e7d503a326fedf81b4..ad9ca8a60144c773dd2ab7de10af67a436f790cb 100644 (file)
@@ -118,8 +118,10 @@ static int kvm_cpu_get_extint(struct kvm_vcpu *v)
        if (!lapic_in_kernel(v))
                return v->arch.interrupt.nr;
 
+#ifdef CONFIG_KVM_XEN
        if (kvm_xen_has_interrupt(v))
                return v->kvm->arch.xen.upcall_vector;
+#endif
 
        if (irqchip_split(v->kvm)) {
                int vector = v->arch.pending_external_vector;