Re: [RFC v2 2/6] ARM: KVM: Add support for KVM on ARM architecture

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2012-10-10 17:07, Peter Maydell wrote:
> From: Christoffer Dall <cdall@xxxxxxxxxxxxxxx>
> 
> Add basic support for KVM on ARM architecture.
> 
> Signed-off-by: Christoffer Dall <cdall@xxxxxxxxxxxxxxx>
> [PMM: Minor tweaks and code cleanup, switch to ONE_REG]
> Signed-off-by: Peter Maydell <peter.maydell@xxxxxxxxxx>
> ---
>  hw/arm_pic.c             |   28 ++++
>  target-arm/Makefile.objs |    1 +
>  target-arm/cpu.h         |    1 +
>  target-arm/helper.c      |    2 +-
>  target-arm/kvm.c         |  328 ++++++++++++++++++++++++++++++++++++++++++++++
>  5 files changed, 359 insertions(+), 1 deletion(-)
>  create mode 100644 target-arm/kvm.c
> 
> diff --git a/hw/arm_pic.c b/hw/arm_pic.c
> index ffb4d41..72272dc 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 = KVM_ARM_IRQ_TYPE_CPU << KVM_ARM_IRQ_TYPE_SHIFT;
> +
> +    switch (irq) {
> +    case ARM_PIC_CPU_IRQ:
> +        kvm_irq |= KVM_ARM_IRQ_CPU_IRQ;
> +        break;
> +    case ARM_PIC_CPU_FIQ:
> +        kvm_irq |= KVM_ARM_IRQ_CPU_FIQ;
> +        break;
> +    default:
> +        hw_error("kvm_arm_pic_cpu_handler: Bad interrupt line %d\n", irq);
> +    }
> +    kvm_irq |= env->cpu_index << KVM_ARM_IRQ_VCPU_SHIFT;
> +    kvm_set_irq(kvm_state, kvm_irq, level ? 1 : 0);
> +}
> +#endif

Minor: If you do

function()
{
#ifdef CONFIG_KVM
...
#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

...you can avoid the ifdef'ery here.

Jan

-- 
Siemens AG, Corporate Technology, CT RTC ITP SDP-DE
Corporate Competence Center Embedded Linux
_______________________________________________
kvmarm mailing list
kvmarm@xxxxxxxxxxxxxxxxxxxxx
https://lists.cs.columbia.edu/cucslists/listinfo/kvmarm


[Index of Archives]     [Linux KVM]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux