aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/kvm/irq.h2
-rw-r--r--drivers/kvm/kvm_main.c10
-rw-r--r--include/linux/kvm.h29
3 files changed, 39 insertions, 2 deletions
diff --git a/drivers/kvm/irq.h b/drivers/kvm/irq.h
index 4034f6576cd9..30adddcb182d 100644
--- a/drivers/kvm/irq.h
+++ b/drivers/kvm/irq.h
@@ -61,7 +61,7 @@ int 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);
62void kvm_pic_update_irq(struct kvm_pic *s); 62void kvm_pic_update_irq(struct kvm_pic *s);
63 63
64#define IOAPIC_NUM_PINS 24 64#define IOAPIC_NUM_PINS KVM_IOAPIC_NUM_PINS
65#define IOAPIC_VERSION_ID 0x11 /* IOAPIC version */ 65#define IOAPIC_VERSION_ID 0x11 /* IOAPIC version */
66#define IOAPIC_EDGE_TRIG 0 66#define IOAPIC_EDGE_TRIG 0
67#define IOAPIC_LEVEL_TRIG 1 67#define IOAPIC_LEVEL_TRIG 1
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index c270e4afd3fd..61dff55f137e 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -913,6 +913,11 @@ static int kvm_vm_ioctl_get_irqchip(struct kvm *kvm, struct kvm_irqchip *chip)
913 &pic_irqchip(kvm)->pics[1], 913 &pic_irqchip(kvm)->pics[1],
914 sizeof(struct kvm_pic_state)); 914 sizeof(struct kvm_pic_state));
915 break; 915 break;
916 case KVM_IRQCHIP_IOAPIC:
917 memcpy (&chip->chip.ioapic,
918 ioapic_irqchip(kvm),
919 sizeof(struct kvm_ioapic_state));
920 break;
916 default: 921 default:
917 r = -EINVAL; 922 r = -EINVAL;
918 break; 923 break;
@@ -936,6 +941,11 @@ static int kvm_vm_ioctl_set_irqchip(struct kvm *kvm, struct kvm_irqchip *chip)
936 &chip->chip.pic, 941 &chip->chip.pic,
937 sizeof(struct kvm_pic_state)); 942 sizeof(struct kvm_pic_state));
938 break; 943 break;
944 case KVM_IRQCHIP_IOAPIC:
945 memcpy (ioapic_irqchip(kvm),
946 &chip->chip.ioapic,
947 sizeof(struct kvm_ioapic_state));
948 break;
939 default: 949 default:
940 r = -EINVAL; 950 r = -EINVAL;
941 break; 951 break;
diff --git a/include/linux/kvm.h b/include/linux/kvm.h
index 6560f11870fd..42d15150d7a3 100644
--- a/include/linux/kvm.h
+++ b/include/linux/kvm.h
@@ -45,7 +45,7 @@ struct kvm_irq_level {
45 __u32 level; 45 __u32 level;
46}; 46};
47 47
48/* for KVM_GET_IRQCHIP / KVM_SET_IRQCHIP */ 48/* for KVM_GET_IRQCHIP and KVM_SET_IRQCHIP */
49struct kvm_pic_state { 49struct kvm_pic_state {
50 __u8 last_irr; /* edge detection */ 50 __u8 last_irr; /* edge detection */
51 __u8 irr; /* interrupt request register */ 51 __u8 irr; /* interrupt request register */
@@ -65,9 +65,35 @@ struct kvm_pic_state {
65 __u8 elcr_mask; 65 __u8 elcr_mask;
66}; 66};
67 67
68#define KVM_IOAPIC_NUM_PINS 24
69struct kvm_ioapic_state {
70 __u64 base_address;
71 __u32 ioregsel;
72 __u32 id;
73 __u32 irr;
74 __u32 pad;
75 union {
76 __u64 bits;
77 struct {
78 __u8 vector;
79 __u8 delivery_mode:3;
80 __u8 dest_mode:1;
81 __u8 delivery_status:1;
82 __u8 polarity:1;
83 __u8 remote_irr:1;
84 __u8 trig_mode:1;
85 __u8 mask:1;
86 __u8 reserve:7;
87 __u8 reserved[4];
88 __u8 dest_id;
89 } fields;
90 } redirtbl[KVM_IOAPIC_NUM_PINS];
91};
92
68enum kvm_irqchip_id { 93enum kvm_irqchip_id {
69 KVM_IRQCHIP_PIC_MASTER = 0, 94 KVM_IRQCHIP_PIC_MASTER = 0,
70 KVM_IRQCHIP_PIC_SLAVE = 1, 95 KVM_IRQCHIP_PIC_SLAVE = 1,
96 KVM_IRQCHIP_IOAPIC = 2,
71}; 97};
72 98
73struct kvm_irqchip { 99struct kvm_irqchip {
@@ -76,6 +102,7 @@ struct kvm_irqchip {
76 union { 102 union {
77 char dummy[512]; /* reserving space */ 103 char dummy[512]; /* reserving space */
78 struct kvm_pic_state pic; 104 struct kvm_pic_state pic;
105 struct kvm_ioapic_state ioapic;
79 } chip; 106 } chip;
80}; 107};
81 108