xref: /openbmc/linux/arch/x86/kvm/lapic.h (revision 33e4c68656a2e461b296ce714ec322978de85412)
182470196SZhang Xiantao #ifndef __KVM_X86_LAPIC_H
282470196SZhang Xiantao #define __KVM_X86_LAPIC_H
382470196SZhang Xiantao 
482470196SZhang Xiantao #include "iodev.h"
5d3c7b77dSMarcelo Tosatti #include "kvm_timer.h"
682470196SZhang Xiantao 
782470196SZhang Xiantao #include <linux/kvm_host.h>
882470196SZhang Xiantao 
982470196SZhang Xiantao struct kvm_lapic {
1082470196SZhang Xiantao 	unsigned long base_address;
1182470196SZhang Xiantao 	struct kvm_io_device dev;
12d3c7b77dSMarcelo Tosatti 	struct kvm_timer lapic_timer;
1382470196SZhang Xiantao 	u32 divide_count;
1482470196SZhang Xiantao 	struct kvm_vcpu *vcpu;
15*33e4c686SGleb Natapov 	bool irr_pending;
1682470196SZhang Xiantao 	struct page *regs_page;
1782470196SZhang Xiantao 	void *regs;
18b93463aaSAvi Kivity 	gpa_t vapic_addr;
19b93463aaSAvi Kivity 	struct page *vapic_page;
2082470196SZhang Xiantao };
2182470196SZhang Xiantao int kvm_create_lapic(struct kvm_vcpu *vcpu);
2282470196SZhang Xiantao void kvm_free_lapic(struct kvm_vcpu *vcpu);
2382470196SZhang Xiantao 
2482470196SZhang Xiantao int kvm_apic_has_interrupt(struct kvm_vcpu *vcpu);
2582470196SZhang Xiantao int kvm_apic_accept_pic_intr(struct kvm_vcpu *vcpu);
2682470196SZhang Xiantao int kvm_get_apic_interrupt(struct kvm_vcpu *vcpu);
2782470196SZhang Xiantao void kvm_lapic_reset(struct kvm_vcpu *vcpu);
2882470196SZhang Xiantao u64 kvm_lapic_get_cr8(struct kvm_vcpu *vcpu);
2982470196SZhang Xiantao void kvm_lapic_set_tpr(struct kvm_vcpu *vcpu, unsigned long cr8);
3082470196SZhang Xiantao void kvm_lapic_set_base(struct kvm_vcpu *vcpu, u64 value);
318b2cf73cSHarvey Harrison u64 kvm_lapic_get_base(struct kvm_vcpu *vcpu);
3282470196SZhang Xiantao 
3382470196SZhang Xiantao int kvm_apic_match_physical_addr(struct kvm_lapic *apic, u16 dest);
3482470196SZhang Xiantao int kvm_apic_match_logical_addr(struct kvm_lapic *apic, u8 mda);
3558c2dde1SGleb Natapov int kvm_apic_set_irq(struct kvm_vcpu *vcpu, struct kvm_lapic_irq *irq);
3682470196SZhang Xiantao 
3782470196SZhang Xiantao u64 kvm_get_apic_base(struct kvm_vcpu *vcpu);
3882470196SZhang Xiantao void kvm_set_apic_base(struct kvm_vcpu *vcpu, u64 data);
3982470196SZhang Xiantao void kvm_apic_post_state_restore(struct kvm_vcpu *vcpu);
4082470196SZhang Xiantao int kvm_lapic_enabled(struct kvm_vcpu *vcpu);
41343f94feSGleb Natapov bool kvm_apic_present(struct kvm_vcpu *vcpu);
4282470196SZhang Xiantao int kvm_lapic_find_highest_irr(struct kvm_vcpu *vcpu);
4382470196SZhang Xiantao 
44b93463aaSAvi Kivity void kvm_lapic_set_vapic_addr(struct kvm_vcpu *vcpu, gpa_t vapic_addr);
45b93463aaSAvi Kivity void kvm_lapic_sync_from_vapic(struct kvm_vcpu *vcpu);
46b93463aaSAvi Kivity void kvm_lapic_sync_to_vapic(struct kvm_vcpu *vcpu);
47b93463aaSAvi Kivity 
4882470196SZhang Xiantao #endif
49