Commit ee11ab6b authored by Peng Hao's avatar Peng Hao Committed by Sean Christopherson
Browse files

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: default avatarPeng Hao <flyingpeng@tencent.com>
Link: https://lore.kernel.org/all/CAPm50aKwbZGeXPK5uig18Br8CF1hOS71CE2j_dLX+ub7oJdpGg@mail.gmail.com


[sean: fix whitespace damage]
Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
parent 5804c19b
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -680,6 +680,7 @@ struct kvm_hypervisor_cpuid {
	u32 limit;
};

#ifdef CONFIG_KVM_XEN
/* Xen HVM per vcpu emulation context */
struct kvm_vcpu_xen {
	u64 hypercall_rip;
@@ -702,6 +703,7 @@ struct kvm_vcpu_xen {
	struct timer_list poll_timer;
	struct kvm_hypervisor_cpuid cpuid;
};
#endif

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

	bool hyperv_enabled;
	struct kvm_vcpu_hv *hyperv;
#ifdef CONFIG_KVM_XEN
	struct kvm_vcpu_xen xen;

#endif
	cpumask_var_t wbinvd_dirty_mask;

	unsigned long last_retry_eip;
+2 −0
Original line number Diff line number Diff line
@@ -456,7 +456,9 @@ static int kvm_set_cpuid(struct kvm_vcpu *vcpu, struct kvm_cpuid_entry2 *e2,
	vcpu->arch.cpuid_nent = nent;

	vcpu->arch.kvm_cpuid = kvm_get_hypervisor_cpuid(vcpu, KVM_SIGNATURE);
#ifdef CONFIG_KVM_XEN
	vcpu->arch.xen.cpuid = kvm_get_hypervisor_cpuid(vcpu, XEN_SIGNATURE);
#endif
	kvm_vcpu_after_set_cpuid(vcpu);

	return 0;
+2 −0
Original line number Diff line number Diff line
@@ -3232,11 +3232,13 @@ static int kvm_guest_time_update(struct kvm_vcpu *v)

	if (vcpu->pv_time.active)
		kvm_setup_guest_pvclock(v, &vcpu->pv_time, 0);
#ifdef CONFIG_KVM_XEN
	if (vcpu->xen.vcpu_info_cache.active)
		kvm_setup_guest_pvclock(v, &vcpu->xen.vcpu_info_cache,
					offsetof(struct compat_vcpu_info, time));
	if (vcpu->xen.vcpu_time_info_cache.active)
		kvm_setup_guest_pvclock(v, &vcpu->xen.vcpu_time_info_cache, 0);
#endif
	kvm_hv_setup_tsc_page(v->kvm, &vcpu->hv_clock);
	return 0;
}