Hi Radim

On 22/07/2016 16:24, Radim Krčmář wrote:
> 2016-07-22 13:46+0000, Eric Auger:
>> This patch adds compilation and link against irqchip.
>>
>> Main motivation behind using irqchip code is to enable MSI
>> routing code. In the future irqchip routing may also be useful
>> when targeting multiple irqchips.
>>
>> Routing standard callbacks now are implemented in vgic-irqfd:
>> - kvm_set_routing_entry
>> - kvm_set_irq
>> - kvm_set_msi
>>
>> They only are supported with new_vgic code.
>>
>> Both HAVE_KVM_IRQCHIP and HAVE_KVM_IRQ_ROUTING are defined.
>> KVM_CAP_IRQ_ROUTING is advertised and KVM_SET_GSI_ROUTING is allowed.
>>
>> So from now on IRQCHIP routing is enabled and a routing table entry
>> must exist for irqfd injection to succeed for a given SPI. This patch
>> builds a default flat irqchip routing table (gsi=irqchip.pin) covering
>> all the VGIC SPI indexes. This routing table is overwritten by the
>> first first user-space call to KVM_SET_GSI_ROUTING ioctl.
>>
>> MSI routing setup is not yet allowed.
>>
>> Signed-off-by: Eric Auger <eric.au...@redhat.com>
>>
>> ---
>> diff --git a/virt/kvm/arm/vgic/vgic-irqfd.c b/virt/kvm/arm/vgic/vgic-irqfd.c
>> @@ -17,36 +17,101 @@
>>  #include <linux/kvm.h>
>>  #include <linux/kvm_host.h>
>>  #include <trace/events/kvm.h>
>> +#include <kvm/arm_vgic.h>
>> +#include "vgic.h"
>>  
>> -int kvm_irq_map_gsi(struct kvm *kvm,
>> -                struct kvm_kernel_irq_routing_entry *entries,
>> -                int gsi)
>> +/**
>> + * vgic_irqfd_set_irq: inject the IRQ corresponding to the
>> + * irqchip routing entry
>> + *
>> + * This is the entry point for irqfd IRQ injection
>> + */
>> +static int vgic_irqfd_set_irq(struct kvm_kernel_irq_routing_entry *e,
>> +                    struct kvm *kvm, int irq_source_id,
>> +                    int level, bool line_status)
>>  {
>> -    return 0;
>> +    unsigned int spi_id = e->irqchip.pin + VGIC_NR_PRIVATE_IRQS;
>> +    struct vgic_dist *dist = &kvm->arch.vgic;
>> +
>> +    if (spi_id > min(dist->nr_spis, VGIC_MAX_SPI))
> 
> This is more strict that vgic_valid_spi(), because spi_id between
> "dist->nr_spis" and "dist->nr_spis + VGIC_NR_PRIVATE_IRQS" is not
> allowed, which probably wasn't intended.
Hum yes you're right. This is wrong.
> 
> And shouldn't nr_spis always be less that VGIC_MAX_SPI?
Correct. I will use vgic_valid_spi which was introduced to avoid such mixup.

Thanks for noticing

Eric
> 
> Thanks.
> 
>> +            return -EINVAL;
>> +    return kvm_vgic_inject_irq(kvm, 0, spi_id, level);
>>  }
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

Reply via email to