diff options
author | Gleb Natapov <gleb@redhat.com> | 2012-08-05 08:58:33 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2012-08-06 12:00:45 -0400 |
commit | c48f14966cc41957d88c66dfe49a439e708ab7b8 (patch) | |
tree | 7b8b728a9401fea096710baf122a608301a68e10 /arch/x86/kvm/lapic.h | |
parent | 54e9818f3903902a4ea3046035739b8770880092 (diff) |
KVM: inline kvm_apic_present() and kvm_lapic_enabled()
Those functions are used during interrupt injection. When inlined they
become nops on the fast path.
Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/x86/kvm/lapic.h')
-rw-r--r-- | arch/x86/kvm/lapic.h | 45 |
1 files changed, 43 insertions, 2 deletions
diff --git a/arch/x86/kvm/lapic.h b/arch/x86/kvm/lapic.h index 73fa299b68e8..2ad9caa06f94 100644 --- a/arch/x86/kvm/lapic.h +++ b/arch/x86/kvm/lapic.h | |||
@@ -55,8 +55,6 @@ int kvm_apic_local_deliver(struct kvm_lapic *apic, int lvt_type); | |||
55 | u64 kvm_get_apic_base(struct kvm_vcpu *vcpu); | 55 | u64 kvm_get_apic_base(struct kvm_vcpu *vcpu); |
56 | void kvm_set_apic_base(struct kvm_vcpu *vcpu, u64 data); | 56 | void kvm_set_apic_base(struct kvm_vcpu *vcpu, u64 data); |
57 | void kvm_apic_post_state_restore(struct kvm_vcpu *vcpu); | 57 | void kvm_apic_post_state_restore(struct kvm_vcpu *vcpu); |
58 | int kvm_lapic_enabled(struct kvm_vcpu *vcpu); | ||
59 | bool kvm_apic_present(struct kvm_vcpu *vcpu); | ||
60 | int kvm_lapic_find_highest_irr(struct kvm_vcpu *vcpu); | 58 | int kvm_lapic_find_highest_irr(struct kvm_vcpu *vcpu); |
61 | 59 | ||
62 | u64 kvm_get_lapic_tscdeadline_msr(struct kvm_vcpu *vcpu); | 60 | u64 kvm_get_lapic_tscdeadline_msr(struct kvm_vcpu *vcpu); |
@@ -79,4 +77,47 @@ static inline bool kvm_hv_vapic_assist_page_enabled(struct kvm_vcpu *vcpu) | |||
79 | 77 | ||
80 | int kvm_lapic_enable_pv_eoi(struct kvm_vcpu *vcpu, u64 data); | 78 | int kvm_lapic_enable_pv_eoi(struct kvm_vcpu *vcpu, u64 data); |
81 | void kvm_lapic_init(void); | 79 | void kvm_lapic_init(void); |
80 | |||
81 | static inline u32 kvm_apic_get_reg(struct kvm_lapic *apic, int reg_off) | ||
82 | { | ||
83 | return *((u32 *) (apic->regs + reg_off)); | ||
84 | } | ||
85 | |||
86 | extern struct static_key kvm_no_apic_vcpu; | ||
87 | |||
88 | static inline bool kvm_vcpu_has_lapic(struct kvm_vcpu *vcpu) | ||
89 | { | ||
90 | if (static_key_false(&kvm_no_apic_vcpu)) | ||
91 | return vcpu->arch.apic; | ||
92 | return true; | ||
93 | } | ||
94 | |||
95 | extern struct static_key_deferred apic_hw_disabled; | ||
96 | |||
97 | static inline int kvm_apic_hw_enabled(struct kvm_lapic *apic) | ||
98 | { | ||
99 | if (static_key_false(&apic_hw_disabled.key)) | ||
100 | return apic->vcpu->arch.apic_base & MSR_IA32_APICBASE_ENABLE; | ||
101 | return MSR_IA32_APICBASE_ENABLE; | ||
102 | } | ||
103 | |||
104 | extern struct static_key_deferred apic_sw_disabled; | ||
105 | |||
106 | static inline int kvm_apic_sw_enabled(struct kvm_lapic *apic) | ||
107 | { | ||
108 | if (static_key_false(&apic_sw_disabled.key)) | ||
109 | return kvm_apic_get_reg(apic, APIC_SPIV) & APIC_SPIV_APIC_ENABLED; | ||
110 | return APIC_SPIV_APIC_ENABLED; | ||
111 | } | ||
112 | |||
113 | static inline bool kvm_apic_present(struct kvm_vcpu *vcpu) | ||
114 | { | ||
115 | return kvm_vcpu_has_lapic(vcpu) && kvm_apic_hw_enabled(vcpu->arch.apic); | ||
116 | } | ||
117 | |||
118 | static inline int kvm_lapic_enabled(struct kvm_vcpu *vcpu) | ||
119 | { | ||
120 | return kvm_apic_present(vcpu) && kvm_apic_sw_enabled(vcpu->arch.apic); | ||
121 | } | ||
122 | |||
82 | #endif | 123 | #endif |