diff options
author | Eddie Dong <eddie.dong@intel.com> | 2007-09-12 03:58:04 -0400 |
---|---|---|
committer | Avi Kivity <avi@qumranet.com> | 2007-10-13 04:18:25 -0400 |
commit | 97222cc8316328965851ed28d23f6b64b4c912d2 (patch) | |
tree | 469b2f72e74046a7aec5061df194c3f68812a224 /drivers/kvm/irq.h | |
parent | 7017fc3d1a12e30ea7df4992152978a188433457 (diff) |
KVM: Emulate local APIC in kernel
Because lightweight exits (exits which don't involve userspace) are many
times faster than heavyweight exits, it makes sense to emulate high usage
devices in the kernel. The local APIC is one such device, especially for
Windows and for SMP, so we add an APIC model to kvm.
It also allows in-kernel host-side drivers to inject interrupts without
going through userspace.
[compile fix on i386 from Jindrich Makovicka]
Signed-off-by: Yaozu (Eddie) Dong <Eddie.Dong@intel.com>
Signed-off-by: Qing He <qing.he@intel.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'drivers/kvm/irq.h')
-rw-r--r-- | drivers/kvm/irq.h | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/drivers/kvm/irq.h b/drivers/kvm/irq.h index bdb2fc34804b..57e23bdac530 100644 --- a/drivers/kvm/irq.h +++ b/drivers/kvm/irq.h | |||
@@ -26,7 +26,6 @@ | |||
26 | 26 | ||
27 | typedef void irq_request_func(void *opaque, int level); | 27 | typedef void irq_request_func(void *opaque, int level); |
28 | 28 | ||
29 | struct kvm_pic; | ||
30 | struct kvm_kpic_state { | 29 | struct kvm_kpic_state { |
31 | u8 last_irr; /* edge detection */ | 30 | u8 last_irr; /* edge detection */ |
32 | u8 irr; /* interrupt request register */ | 31 | u8 irr; /* interrupt request register */ |
@@ -61,4 +60,44 @@ int kvm_pic_read_irq(struct kvm_pic *s); | |||
61 | int kvm_cpu_get_interrupt(struct kvm_vcpu *v); | 60 | int kvm_cpu_get_interrupt(struct kvm_vcpu *v); |
62 | int kvm_cpu_has_interrupt(struct kvm_vcpu *v); | 61 | int kvm_cpu_has_interrupt(struct kvm_vcpu *v); |
63 | 62 | ||
63 | struct kvm_lapic { | ||
64 | unsigned long base_address; | ||
65 | struct kvm_io_device dev; | ||
66 | struct { | ||
67 | atomic_t pending; | ||
68 | s64 period; /* unit: ns */ | ||
69 | u32 divide_count; | ||
70 | ktime_t last_update; | ||
71 | struct hrtimer dev; | ||
72 | } timer; | ||
73 | struct kvm_vcpu *vcpu; | ||
74 | struct page *regs_page; | ||
75 | void *regs; | ||
76 | }; | ||
77 | |||
78 | #ifdef DEBUG | ||
79 | #define ASSERT(x) \ | ||
80 | do { \ | ||
81 | if (!(x)) { \ | ||
82 | printk(KERN_EMERG "assertion failed %s: %d: %s\n", \ | ||
83 | __FILE__, __LINE__, #x); \ | ||
84 | BUG(); \ | ||
85 | } \ | ||
86 | } while (0) | ||
87 | #else | ||
88 | #define ASSERT(x) do { } while (0) | ||
89 | #endif | ||
90 | |||
91 | void kvm_vcpu_kick(struct kvm_vcpu *vcpu); | ||
92 | int kvm_apic_has_interrupt(struct kvm_vcpu *vcpu); | ||
93 | int kvm_get_apic_interrupt(struct kvm_vcpu *vcpu); | ||
94 | int kvm_create_lapic(struct kvm_vcpu *vcpu); | ||
95 | void kvm_free_apic(struct kvm_lapic *apic); | ||
96 | u64 kvm_lapic_get_cr8(struct kvm_vcpu *vcpu); | ||
97 | void kvm_lapic_set_tpr(struct kvm_vcpu *vcpu, unsigned long cr8); | ||
98 | void kvm_lapic_set_base(struct kvm_vcpu *vcpu, u64 value); | ||
99 | u64 kvm_get_apic_base(struct kvm_vcpu *vcpu); | ||
100 | void kvm_set_apic_base(struct kvm_vcpu *vcpu, u64 data); | ||
101 | void kvm_ioapic_update_eoi(struct kvm *kvm, int vector); | ||
102 | |||
64 | #endif | 103 | #endif |