aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorChristoffer Dall <cdall@cs.columbia.edu>2012-09-02 15:45:31 +0100
committerPeter Maydell <peter.maydell@linaro.org>2012-09-02 15:45:31 +0100
commit8ed1e91fdb509f6a8527e1879b1ca73bd3055f15 (patch)
treedf61021479ad5e5cb929c66f46da63ac69381b81 /hw
parenta0104fd05ea4c3fe4fc8a3d506b26d55456922e7 (diff)
ARM: KVM: Add support for KVM on ARM architecture
Add basic support for KVM on ARM architecture. Signed-off-by: Christoffer Dall <cdall@cs.columbia.edu> [Rusty: updates to use KVM_ARM_VCPU_INIT, KVM_GET/SET_MSRS] Signed-off-by: Rusty Russell <rusty.russell@linaro.org> [PMM: Minor tweaks and code cleanup] Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'hw')
-rw-r--r--hw/arm_pic.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/hw/arm_pic.c b/hw/arm_pic.c
index ffb4d4171a..950e6c4c49 100644
--- a/hw/arm_pic.c
+++ b/hw/arm_pic.c
@@ -9,6 +9,7 @@
#include "hw.h"
#include "arm-misc.h"
+#include "kvm.h"
/* Input 0 is IRQ and input 1 is FIQ. */
static void arm_pic_cpu_handler(void *opaque, int irq, int level)
@@ -34,7 +35,34 @@ static void arm_pic_cpu_handler(void *opaque, int irq, int level)
}
}
+#ifdef CONFIG_KVM
+static void kvm_arm_pic_cpu_handler(void *opaque, int irq, int level)
+{
+ ARMCPU *cpu = opaque;
+ CPUARMState *env = &cpu->env;
+ int kvm_irq;
+
+ switch (irq) {
+ case ARM_PIC_CPU_IRQ:
+ kvm_irq = KVM_ARM_IRQ_LINE;
+ break;
+ case ARM_PIC_CPU_FIQ:
+ kvm_irq = KVM_ARM_FIQ_LINE;
+ break;
+ default:
+ hw_error("kvm_arm_pic_cpu_handler: Bad interrupt line %d\n", irq);
+ }
+ kvm_irq |= (env->cpu_index << 1);
+ kvm_set_irq(kvm_state, kvm_irq, level ? 1 : 0);
+}
+#endif
+
qemu_irq *arm_pic_init_cpu(ARMCPU *cpu)
{
+#ifdef CONFIG_KVM
+ if (kvm_enabled()) {
+ return qemu_allocate_irqs(kvm_arm_pic_cpu_handler, cpu, 2);
+ }
+#endif
return qemu_allocate_irqs(arm_pic_cpu_handler, cpu, 2);
}