aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/lapic.h
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86/kvm/lapic.h')
-rw-r--r--arch/x86/kvm/lapic.h45
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);
55u64 kvm_get_apic_base(struct kvm_vcpu *vcpu); 55u64 kvm_get_apic_base(struct kvm_vcpu *vcpu);
56void kvm_set_apic_base(struct kvm_vcpu *vcpu, u64 data); 56void kvm_set_apic_base(struct kvm_vcpu *vcpu, u64 data);
57void kvm_apic_post_state_restore(struct kvm_vcpu *vcpu); 57void kvm_apic_post_state_restore(struct kvm_vcpu *vcpu);
58int kvm_lapic_enabled(struct kvm_vcpu *vcpu);
59bool kvm_apic_present(struct kvm_vcpu *vcpu);
60int kvm_lapic_find_highest_irr(struct kvm_vcpu *vcpu); 58int kvm_lapic_find_highest_irr(struct kvm_vcpu *vcpu);
61 59
62u64 kvm_get_lapic_tscdeadline_msr(struct kvm_vcpu *vcpu); 60u64 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
80int kvm_lapic_enable_pv_eoi(struct kvm_vcpu *vcpu, u64 data); 78int kvm_lapic_enable_pv_eoi(struct kvm_vcpu *vcpu, u64 data);
81void kvm_lapic_init(void); 79void kvm_lapic_init(void);
80
81static inline u32 kvm_apic_get_reg(struct kvm_lapic *apic, int reg_off)
82{
83 return *((u32 *) (apic->regs + reg_off));
84}
85
86extern struct static_key kvm_no_apic_vcpu;
87
88static 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
95extern struct static_key_deferred apic_hw_disabled;
96
97static 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
104extern struct static_key_deferred apic_sw_disabled;
105
106static 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
113static 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
118static 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