2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-27 14:43:58 +08:00

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>
This commit is contained in:
Radim Krčmář 2014-10-30 15:06:47 +01:00 committed by Paolo Bonzini
parent a323b40982
commit f30ebc312c
2 changed files with 6 additions and 10 deletions

View File

@ -244,21 +244,17 @@ static inline int apic_lvt_vector(struct kvm_lapic *apic, int lvt_type)
static inline int apic_lvtt_oneshot(struct kvm_lapic *apic) static inline int apic_lvtt_oneshot(struct kvm_lapic *apic)
{ {
return ((kvm_apic_get_reg(apic, APIC_LVTT) & return apic->lapic_timer.timer_mode == APIC_LVT_TIMER_ONESHOT;
apic->lapic_timer.timer_mode_mask) == APIC_LVT_TIMER_ONESHOT);
} }
static inline int apic_lvtt_period(struct kvm_lapic *apic) static inline int apic_lvtt_period(struct kvm_lapic *apic)
{ {
return ((kvm_apic_get_reg(apic, APIC_LVTT) & return apic->lapic_timer.timer_mode == APIC_LVT_TIMER_PERIODIC;
apic->lapic_timer.timer_mode_mask) == APIC_LVT_TIMER_PERIODIC);
} }
static inline int apic_lvtt_tscdeadline(struct kvm_lapic *apic) static inline int apic_lvtt_tscdeadline(struct kvm_lapic *apic)
{ {
return ((kvm_apic_get_reg(apic, APIC_LVTT) & return apic->lapic_timer.timer_mode == APIC_LVT_TIMER_TSCDEADLINE;
apic->lapic_timer.timer_mode_mask) ==
APIC_LVT_TIMER_TSCDEADLINE);
} }
static inline int apic_lvt_nmi_mode(u32 lvt_val) static inline int apic_lvt_nmi_mode(u32 lvt_val)

View File

@ -121,11 +121,11 @@ static inline int kvm_apic_hw_enabled(struct kvm_lapic *apic)
extern struct static_key_deferred apic_sw_disabled; extern struct static_key_deferred apic_sw_disabled;
static inline int kvm_apic_sw_enabled(struct kvm_lapic *apic) static inline bool kvm_apic_sw_enabled(struct kvm_lapic *apic)
{ {
if (static_key_false(&apic_sw_disabled.key)) if (static_key_false(&apic_sw_disabled.key))
return kvm_apic_get_reg(apic, APIC_SPIV) & APIC_SPIV_APIC_ENABLED; return apic->sw_enabled;
return APIC_SPIV_APIC_ENABLED; return true;
} }
static inline bool kvm_apic_present(struct kvm_vcpu *vcpu) static inline bool kvm_apic_present(struct kvm_vcpu *vcpu)