]>
Commit | Line | Data |
---|---|---|
1 | From 100943c54e0947a07d2c0185368fc2fd848f7f28 Mon Sep 17 00:00:00 2001 | |
2 | From: "Gabriel L. Somlo" <gsomlo@gmail.com> | |
3 | Date: Thu, 27 Feb 2014 23:06:17 -0500 | |
4 | Subject: kvm: x86: ignore ioapic polarity | |
5 | ||
6 | Both QEMU and KVM have already accumulated a significant number of | |
7 | optimizations based on the hard-coded assumption that ioapic polarity | |
8 | will always use the ActiveHigh convention, where the logical and | |
9 | physical states of level-triggered irq lines always match (i.e., | |
10 | active(asserted) == high == 1, inactive == low == 0). QEMU guests | |
11 | are expected to follow directions given via ACPI and configure the | |
12 | ioapic with polarity 0 (ActiveHigh). However, even when misbehaving | |
13 | guests (e.g. OS X <= 10.9) set the ioapic polarity to 1 (ActiveLow), | |
14 | QEMU will still use the ActiveHigh signaling convention when | |
15 | interfacing with KVM. | |
16 | ||
17 | This patch modifies KVM to completely ignore ioapic polarity as set by | |
18 | the guest OS, enabling misbehaving guests to work alongside those which | |
19 | comply with the ActiveHigh polarity specified by QEMU's ACPI tables. | |
20 | ||
21 | Signed-off-by: Michael S. Tsirkin <mst@redhat.com> | |
22 | Signed-off-by: Gabriel L. Somlo <somlo@cmu.edu> | |
23 | [Move documentation to KVM_IRQ_LINE, add ia64. - Paolo] | |
24 | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> | |
25 | ||
26 | diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c | |
27 | index 53f44be..6a4309b 100644 | |
28 | --- a/arch/ia64/kvm/kvm-ia64.c | |
29 | +++ b/arch/ia64/kvm/kvm-ia64.c | |
30 | @@ -197,6 +197,7 @@ int kvm_dev_ioctl_check_extension(long ext) | |
31 | case KVM_CAP_IRQCHIP: | |
32 | case KVM_CAP_MP_STATE: | |
33 | case KVM_CAP_IRQ_INJECT_STATUS: | |
34 | + case KVM_CAP_IOAPIC_POLARITY_IGNORED: | |
35 | r = 1; | |
36 | break; | |
37 | case KVM_CAP_COALESCED_MMIO: | |
38 | diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c | |
39 | index d906391..a37da6b 100644 | |
40 | --- a/arch/x86/kvm/x86.c | |
41 | +++ b/arch/x86/kvm/x86.c | |
42 | @@ -1971,6 +1971,7 @@ int kvm_dev_ioctl_check_extension(long ext) | |
43 | case KVM_CAP_XSAVE: | |
44 | case KVM_CAP_GET_TSC_KHZ: | |
45 | case KVM_CAP_KVMCLOCK_CTRL: | |
46 | + case KVM_CAP_IOAPIC_POLARITY_IGNORED: | |
47 | r = 1; | |
48 | break; | |
49 | case KVM_CAP_COALESCED_MMIO: | |
50 | diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h | |
51 | index 7d76401..a7518be 100644 | |
52 | --- a/include/linux/kvm.h | |
53 | +++ b/include/linux/kvm.h | |
54 | @@ -459,6 +459,7 @@ struct kvm_ppc_smmu_info { | |
55 | #define KVM_CAP_GET_TSC_KHZ 61 | |
56 | #define KVM_CAP_TSC_DEADLINE_TIMER 72 | |
57 | #define KVM_CAP_KVMCLOCK_CTRL 76 | |
58 | +#define KVM_CAP_IOAPIC_POLARITY_IGNORED 97 | |
59 | ||
60 | #ifdef KVM_CAP_IRQ_ROUTING | |
61 | ||
62 | diff --git a/virt/kvm/ioapic.c b/virt/kvm/ioapic.c | |
63 | index ce9ed99..1539d37 100644 | |
64 | --- a/virt/kvm/ioapic.c | |
65 | +++ b/virt/kvm/ioapic.c | |
66 | @@ -206,7 +206,6 @@ int kvm_ioapic_set_irq(struct kvm_ioapic *ioapic, int irq, int irq_source_id, | |
67 | int irq_level = __kvm_irq_line_state(&ioapic->irq_states[irq], | |
68 | irq_source_id, level); | |
69 | entry = ioapic->redirtbl[irq]; | |
70 | - irq_level ^= entry.fields.polarity; | |
71 | if (!irq_level) | |
72 | ioapic->irr &= ~mask; | |
73 | else { | |
74 | -- | |
75 | cgit v0.10.1 | |
76 |