aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRadim Krčmář <rkrcmar@redhat.com>2014-10-30 10:06:47 -0400
committerPaolo Bonzini <pbonzini@redhat.com>2014-11-03 06:07:32 -0500
commitf30ebc312ca9def25650b4e1d01cdb425c310dca (patch)
treebc3bda35500fdd10e6d2dced919633fde0c322c3
parenta323b409820c8afd33fbd841f5534eb84b406e8d (diff)
KVM: x86: optimize some accesses to LVTT and SPIV
We mirror a subset of these registers in separate variables. Using them directly should be faster. Signed-off-by: Radim Krčmář <rkrcmar@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r--arch/x86/kvm/lapic.c10
-rw-r--r--arch/x86/kvm/lapic.h6
2 files changed, 6 insertions, 10 deletions
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index fa3c6f7fdca4..5f574b4add90 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -244,21 +244,17 @@ static inline int apic_lvt_vector(struct kvm_lapic *apic, int lvt_type)
244 244
245static inline int apic_lvtt_oneshot(struct kvm_lapic *apic) 245static inline int apic_lvtt_oneshot(struct kvm_lapic *apic)
246{ 246{
247 return ((kvm_apic_get_reg(apic, APIC_LVTT) & 247 return apic->lapic_timer.timer_mode == APIC_LVT_TIMER_ONESHOT;
248 apic->lapic_timer.timer_mode_mask) == APIC_LVT_TIMER_ONESHOT);
249} 248}
250 249
251static inline int apic_lvtt_period(struct kvm_lapic *apic) 250static inline int apic_lvtt_period(struct kvm_lapic *apic)
252{ 251{
253 return ((kvm_apic_get_reg(apic, APIC_LVTT) & 252 return apic->lapic_timer.timer_mode == APIC_LVT_TIMER_PERIODIC;
254 apic->lapic_timer.timer_mode_mask) == APIC_LVT_TIMER_PERIODIC);
255} 253}
256 254
257static inline int apic_lvtt_tscdeadline(struct kvm_lapic *apic) 255static inline int apic_lvtt_tscdeadline(struct kvm_lapic *apic)
258{ 256{
259 return ((kvm_apic_get_reg(apic, APIC_LVTT) & 257 return apic->lapic_timer.timer_mode == APIC_LVT_TIMER_TSCDEADLINE;
260 apic->lapic_timer.timer_mode_mask) ==
261 APIC_LVT_TIMER_TSCDEADLINE);
262} 258}
263 259
264static inline int apic_lvt_nmi_mode(u32 lvt_val) 260static inline int apic_lvt_nmi_mode(u32 lvt_val)
diff --git a/arch/x86/kvm/lapic.h b/arch/x86/kvm/lapic.h
index 35d83dcae8f9..d4365f21ea2e 100644
--- a/arch/x86/kvm/lapic.h
+++ b/arch/x86/kvm/lapic.h
@@ -121,11 +121,11 @@ static inline int kvm_apic_hw_enabled(struct kvm_lapic *apic)
121 121
122extern struct static_key_deferred apic_sw_disabled; 122extern struct static_key_deferred apic_sw_disabled;
123 123
124static inline int kvm_apic_sw_enabled(struct kvm_lapic *apic) 124static inline bool kvm_apic_sw_enabled(struct kvm_lapic *apic)
125{ 125{
126 if (static_key_false(&apic_sw_disabled.key)) 126 if (static_key_false(&apic_sw_disabled.key))
127 return kvm_apic_get_reg(apic, APIC_SPIV) & APIC_SPIV_APIC_ENABLED; 127 return apic->sw_enabled;
128 return APIC_SPIV_APIC_ENABLED; 128 return true;
129} 129}
130 130
131static inline bool kvm_apic_present(struct kvm_vcpu *vcpu) 131static inline bool kvm_apic_present(struct kvm_vcpu *vcpu)