Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

KVM: x86/xen: Remove unneeded xen context from kvm_arch when !CONFIG_KVM_XEN

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>

authored by

Vitaly Kuznetsov and committed by
Sean Christopherson
87562052 0277022a

+7
+5
arch/x86/include/asm/kvm_host.h
··· 1136 1136 unsigned long *bitmap; 1137 1137 }; 1138 1138 1139 + #ifdef CONFIG_KVM_XEN 1139 1140 /* Xen emulation context */ 1140 1141 struct kvm_xen { 1141 1142 struct mutex xen_lock; ··· 1148 1147 struct idr evtchn_ports; 1149 1148 unsigned long poll_mask[BITS_TO_LONGS(KVM_MAX_VCPUS)]; 1150 1149 }; 1150 + #endif 1151 1151 1152 1152 enum kvm_irqchip_mode { 1153 1153 KVM_IRQCHIP_NONE, ··· 1351 1349 struct hlist_head mask_notifier_list; 1352 1350 1353 1351 struct kvm_hv hyperv; 1352 + 1353 + #ifdef CONFIG_KVM_XEN 1354 1354 struct kvm_xen xen; 1355 + #endif 1355 1356 1356 1357 bool backwards_tsc_observed; 1357 1358 bool boot_vcpu_runs_old_kvmclock;
+2
arch/x86/kvm/irq.c
··· 118 118 if (!lapic_in_kernel(v)) 119 119 return v->arch.interrupt.nr; 120 120 121 + #ifdef CONFIG_KVM_XEN 121 122 if (kvm_xen_has_interrupt(v)) 122 123 return v->kvm->arch.xen.upcall_vector; 124 + #endif 123 125 124 126 if (irqchip_split(v->kvm)) { 125 127 int vector = v->arch.pending_external_vector;