aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/kvm/irq.h
diff options
context:
space:
mode:
authorEddie Dong <eddie.dong@intel.com>2007-07-18 05:03:39 -0400
committerAvi Kivity <avi@qumranet.com>2007-10-13 04:18:25 -0400
commit1fd4f2a5ed8f80cf6e23d2bdf78554f6a1ac7997 (patch)
treeeb7d79c7f39788547a5dd9844295814085fcccc6 /drivers/kvm/irq.h
parent97222cc8316328965851ed28d23f6b64b4c912d2 (diff)
KVM: In-kernel I/O APIC model
This allows in-kernel host-side device drivers to raise guest interrupts without going to userspace. [avi: fix level-triggered interrupt redelivery on eoi] [avi: add missing #include] [avi: avoid redelivery of edge-triggered interrupt] [avi: implement polarity] [avi: don't deliver edge-triggered interrupts when unmasking] [avi: fix host oops on invalid guest access] Signed-off-by: Yaozu (Eddie) Dong <eddie.dong@intel.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'drivers/kvm/irq.h')
-rw-r--r--drivers/kvm/irq.h51
1 files changed, 51 insertions, 0 deletions
diff --git a/drivers/kvm/irq.h b/drivers/kvm/irq.h
index 57e23bdac530..6ed856a41e23 100644
--- a/drivers/kvm/irq.h
+++ b/drivers/kvm/irq.h
@@ -60,6 +60,50 @@ int kvm_pic_read_irq(struct kvm_pic *s);
60int kvm_cpu_get_interrupt(struct kvm_vcpu *v); 60int kvm_cpu_get_interrupt(struct kvm_vcpu *v);
61int kvm_cpu_has_interrupt(struct kvm_vcpu *v); 61int kvm_cpu_has_interrupt(struct kvm_vcpu *v);
62 62
63#define IOAPIC_NUM_PINS 24
64#define IOAPIC_VERSION_ID 0x11 /* IOAPIC version */
65#define IOAPIC_EDGE_TRIG 0
66#define IOAPIC_LEVEL_TRIG 1
67
68#define IOAPIC_DEFAULT_BASE_ADDRESS 0xfec00000
69#define IOAPIC_MEM_LENGTH 0x100
70
71/* Direct registers. */
72#define IOAPIC_REG_SELECT 0x00
73#define IOAPIC_REG_WINDOW 0x10
74#define IOAPIC_REG_EOI 0x40 /* IA64 IOSAPIC only */
75
76/* Indirect registers. */
77#define IOAPIC_REG_APIC_ID 0x00 /* x86 IOAPIC only */
78#define IOAPIC_REG_VERSION 0x01
79#define IOAPIC_REG_ARB_ID 0x02 /* x86 IOAPIC only */
80
81struct kvm_ioapic {
82 u64 base_address;
83 u32 ioregsel;
84 u32 id;
85 u32 irr;
86 u32 pad;
87 union ioapic_redir_entry {
88 u64 bits;
89 struct {
90 u8 vector;
91 u8 delivery_mode:3;
92 u8 dest_mode:1;
93 u8 delivery_status:1;
94 u8 polarity:1;
95 u8 remote_irr:1;
96 u8 trig_mode:1;
97 u8 mask:1;
98 u8 reserve:7;
99 u8 reserved[4];
100 u8 dest_id;
101 } fields;
102 } redirtbl[IOAPIC_NUM_PINS];
103 struct kvm_io_device dev;
104 struct kvm *kvm;
105};
106
63struct kvm_lapic { 107struct kvm_lapic {
64 unsigned long base_address; 108 unsigned long base_address;
65 struct kvm_io_device dev; 109 struct kvm_io_device dev;
@@ -96,8 +140,15 @@ void kvm_free_apic(struct kvm_lapic *apic);
96u64 kvm_lapic_get_cr8(struct kvm_vcpu *vcpu); 140u64 kvm_lapic_get_cr8(struct kvm_vcpu *vcpu);
97void kvm_lapic_set_tpr(struct kvm_vcpu *vcpu, unsigned long cr8); 141void kvm_lapic_set_tpr(struct kvm_vcpu *vcpu, unsigned long cr8);
98void kvm_lapic_set_base(struct kvm_vcpu *vcpu, u64 value); 142void kvm_lapic_set_base(struct kvm_vcpu *vcpu, u64 value);
143struct kvm_lapic *kvm_apic_round_robin(struct kvm *kvm, u8 vector,
144 unsigned long bitmap);
99u64 kvm_get_apic_base(struct kvm_vcpu *vcpu); 145u64 kvm_get_apic_base(struct kvm_vcpu *vcpu);
100void kvm_set_apic_base(struct kvm_vcpu *vcpu, u64 data); 146void kvm_set_apic_base(struct kvm_vcpu *vcpu, u64 data);
147int kvm_apic_match_physical_addr(struct kvm_lapic *apic, u16 dest);
101void kvm_ioapic_update_eoi(struct kvm *kvm, int vector); 148void kvm_ioapic_update_eoi(struct kvm *kvm, int vector);
149int kvm_apic_match_logical_addr(struct kvm_lapic *apic, u8 mda);
150int kvm_apic_set_irq(struct kvm_lapic *apic, u8 vec, u8 trig);
151int kvm_ioapic_init(struct kvm *kvm);
152void kvm_ioapic_set_irq(struct kvm_ioapic *ioapic, int irq, int level);
102 153
103#endif 154#endif