Skip to content

Commit ee11ab6

Browse files
flying-122sean-jc
authored andcommitted
KVM: X86: Reduce size of kvm_vcpu_arch structure when CONFIG_KVM_XEN=n
When CONFIG_KVM_XEN=n, the size of kvm_vcpu_arch can be reduced from 5100+ to 4400+ by adding macro control. Signed-off-by: Peng Hao <flyingpeng@tencent.com> Link: https://lore.kernel.org/all/CAPm50aKwbZGeXPK5uig18Br8CF1hOS71CE2j_dLX+ub7oJdpGg@mail.gmail.com [sean: fix whitespace damage] Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent 5804c19 commit ee11ab6

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

arch/x86/include/asm/kvm_host.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,7 @@ struct kvm_hypervisor_cpuid {
680680
u32 limit;
681681
};
682682

683+
#ifdef CONFIG_KVM_XEN
683684
/* Xen HVM per vcpu emulation context */
684685
struct kvm_vcpu_xen {
685686
u64 hypercall_rip;
@@ -702,6 +703,7 @@ struct kvm_vcpu_xen {
702703
struct timer_list poll_timer;
703704
struct kvm_hypervisor_cpuid cpuid;
704705
};
706+
#endif
705707

706708
struct kvm_queued_exception {
707709
bool pending;
@@ -930,8 +932,9 @@ struct kvm_vcpu_arch {
930932

931933
bool hyperv_enabled;
932934
struct kvm_vcpu_hv *hyperv;
935+
#ifdef CONFIG_KVM_XEN
933936
struct kvm_vcpu_xen xen;
934-
937+
#endif
935938
cpumask_var_t wbinvd_dirty_mask;
936939

937940
unsigned long last_retry_eip;

arch/x86/kvm/cpuid.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,9 @@ static int kvm_set_cpuid(struct kvm_vcpu *vcpu, struct kvm_cpuid_entry2 *e2,
456456
vcpu->arch.cpuid_nent = nent;
457457

458458
vcpu->arch.kvm_cpuid = kvm_get_hypervisor_cpuid(vcpu, KVM_SIGNATURE);
459+
#ifdef CONFIG_KVM_XEN
459460
vcpu->arch.xen.cpuid = kvm_get_hypervisor_cpuid(vcpu, XEN_SIGNATURE);
461+
#endif
460462
kvm_vcpu_after_set_cpuid(vcpu);
461463

462464
return 0;

arch/x86/kvm/x86.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3232,11 +3232,13 @@ static int kvm_guest_time_update(struct kvm_vcpu *v)
32323232

32333233
if (vcpu->pv_time.active)
32343234
kvm_setup_guest_pvclock(v, &vcpu->pv_time, 0);
3235+
#ifdef CONFIG_KVM_XEN
32353236
if (vcpu->xen.vcpu_info_cache.active)
32363237
kvm_setup_guest_pvclock(v, &vcpu->xen.vcpu_info_cache,
32373238
offsetof(struct compat_vcpu_info, time));
32383239
if (vcpu->xen.vcpu_time_info_cache.active)
32393240
kvm_setup_guest_pvclock(v, &vcpu->xen.vcpu_time_info_cache, 0);
3241+
#endif
32403242
kvm_hv_setup_tsc_page(v->kvm, &vcpu->hv_clock);
32413243
return 0;
32423244
}

0 commit comments

Comments
 (0)