From: eric.auger@linaro.org (Eric Auger)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 4/7] KVM: arm/arm64: enable irqchip routing
Date: Tue, 30 Jun 2015 16:02:30 +0200 [thread overview]
Message-ID: <5592A176.1090502@linaro.org> (raw)
In-Reply-To: <55929C0A.9020107@arm.com>
On 06/30/2015 03:39 PM, Andre Przywara wrote:
> Hi Eric,
>
> On 29/06/15 16:37, Eric Auger wrote:
>> This patch adds compilation and link against irqchip.
>>
>> On ARM, irqchip routing is not really useful since there is
>> a single irqchip. However main motivation behind using irqchip
>> code is to enable MSI routing code. With the support of in-kernel
>> GICv3 ITS emulation, it now seems to be a MUST HAVE requirement.
>>
>> Functions previously implemented in vgic.c and substitute
>> to more complex irqchip implementation are removed:
>>
>> - kvm_send_userspace_msi
>> - kvm_irq_map_chip_pin
>> - kvm_set_irq
>> - kvm_irq_map_gsi.
>>
>> They implemented a kernel default identity GSI routing. This is now
>> replaced by user-side provided routing.
>>
>> Routing standard hooks are now implemented in vgic:
>> - kvm_set_routing_entry
>> - kvm_set_irq
>> - kvm_set_msi
>>
>> Both HAVE_KVM_IRQCHIP and HAVE_KVM_IRQ_ROUTING are defined.
>> KVM_CAP_IRQ_ROUTING is advertised and KVM_SET_GSI_ROUTING is allowed.
>>
>> MSI routing is not yet allowed.
>>
>> Signed-off-by: Eric Auger <eric.auger@linaro.org>
>>
> ...
>
>> diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c
>> index 09b1f46..212a5ff 100644
>> --- a/virt/kvm/arm/vgic.c
>> +++ b/virt/kvm/arm/vgic.c
>> @@ -2220,47 +2220,67 @@ out_free_irq:
>> return ret;
>> }
>>
>> -int kvm_irq_map_gsi(struct kvm *kvm,
>> - struct kvm_kernel_irq_routing_entry *entries,
>> - int gsi)
>> +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;
>> -}
>> -
>> -int kvm_irq_map_chip_pin(struct kvm *kvm, unsigned irqchip, unsigned pin)
>> -{
>> - return pin;
>> -}
>> -
>> -int kvm_set_irq(struct kvm *kvm, int irq_source_id,
>> - u32 irq, int level, bool line_status)
>> -{
>> - unsigned int spi = irq + VGIC_NR_PRIVATE_IRQS;
>> + unsigned int spi_id = e->irqchip.pin + VGIC_NR_PRIVATE_IRQS;
>>
>> - trace_kvm_set_irq(irq, level, irq_source_id);
>> + trace_kvm_set_irq(spi_id, level, irq_source_id);
>>
>> BUG_ON(!vgic_initialized(kvm));
>>
>> - if (spi > kvm->arch.vgic.nr_irqs)
>> + if (spi_id > kvm->arch.vgic.nr_irqs)
>> return -EINVAL;
>> - return kvm_vgic_inject_irq(kvm, 0, spi, level);
>> + return kvm_vgic_inject_irq(kvm, 0, spi_id, level);
>>
>> }
>>
>> -/* MSI not implemented yet */
>> +/**
>> + * Populates a kvm routing entry from a user routing entry
>> + * @e: kvm internal formatted entry
>> + * @ue: user api formatted entry
>> + * return 0 on success, -EINVAL on errors.
>> + */
>> +int kvm_set_routing_entry(struct kvm_kernel_irq_routing_entry *e,
>> + const struct kvm_irq_routing_entry *ue)
>> +{
>> + int r = -EINVAL;
>> +
>> + switch (ue->type) {
>> + case KVM_IRQ_ROUTING_IRQCHIP:
>> + e->set = vgic_irqfd_set_irq;
>> + e->irqchip.irqchip = ue->u.irqchip.irqchip;
>> + e->irqchip.pin = ue->u.irqchip.pin;
>> + if ((e->irqchip.pin >= KVM_IRQCHIP_NUM_PINS) ||
>> + (e->irqchip.irqchip >= KVM_NR_IRQCHIPS))
>> + goto out;
>> + break;
>> + default:
>> + goto out;
>> + }
>> + r = 0;
>> +out:
>> + return r;
>> +}
>> +
>> int kvm_set_msi(struct kvm_kernel_irq_routing_entry *e,
>> struct kvm *kvm, int irq_source_id,
>> int level, bool line_status)
>> {
>> - return 0;
>> -}
>> + struct kvm_msi msi;
>>
>> -#ifdef CONFIG_HAVE_KVM_MSI
>> -int kvm_send_userspace_msi(struct kvm *kvm, struct kvm_msi *msi)
>> -{
>> - if (kvm->arch.vgic.vm_ops.inject_msi)
>> - return kvm->arch.vgic.vm_ops.inject_msi(kvm, msi);
>> - else
>> - return -ENODEV;
>> + switch (e->type) {
>> + case KVM_IRQ_ROUTING_EXTENDED_MSI:
>> + msi.address_lo = e->ext_msi.address_lo;
>> + msi.address_hi = e->ext_msi.address_hi;
>> + msi.data = e->ext_msi.data;
>> + msi.flags = e->ext_msi.devid;
>
> You probably meant to write:
> + msi.flags = KVM_MSI_VALID_DEVID;
> + msi.devid = e->ext_msi.devid;
>
> With this change I could get it (your patches on top of my v1.5) to work
> with my hacked kvmtool - at least with vhost=0. On to fixing irqfd now ...
Yes sure. Thanks for the catch!
I will correct in next respin
Thanks
Eric
>
> Cheers,
> Andre.
>
>> + if (kvm->arch.vgic.vm_ops.inject_msi)
>> + return kvm->arch.vgic.vm_ops.inject_msi(kvm, &msi);
>> + else
>> + return -ENODEV;
>> + default:
>> + return -EINVAL;
>> + }
>> }
>> -#endif
next prev parent reply other threads:[~2015-06-30 14:02 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-29 15:37 [PATCH 0/7] KVM: arm/arm64: gsi routing support Eric Auger
2015-06-29 15:37 ` [PATCH 1/7] KVM: api: add kvm_irq_routing_extended_msi Eric Auger
2015-07-02 7:26 ` Pavel Fedin
2015-07-02 8:41 ` Pavel Fedin
2015-07-02 14:50 ` Eric Auger
2015-07-02 14:49 ` Eric Auger
2015-07-02 15:14 ` Andre Przywara
2015-07-02 15:22 ` Eric Auger
2015-07-02 15:39 ` Pavel Fedin
2015-07-02 15:41 ` Eric Auger
2015-07-03 15:29 ` Pavel Fedin
2015-07-03 15:42 ` Eric Auger
2015-07-03 9:05 ` Andre Przywara
2015-07-03 15:53 ` Andre Przywara
2015-07-06 6:42 ` Pavel Fedin
2015-07-06 8:30 ` Andre Przywara
2015-07-06 9:30 ` Christoffer Dall
2015-07-06 10:05 ` Andre Przywara
2015-07-06 10:37 ` Christoffer Dall
2015-07-06 11:07 ` Paolo Bonzini
2015-07-06 11:23 ` Andre Przywara
2015-07-06 11:51 ` Paolo Bonzini
2015-07-06 13:32 ` Pavel Fedin
2015-07-06 15:01 ` Eric Auger
2015-07-06 15:52 ` Andre Przywara
2015-07-06 17:02 ` Eric Auger
2015-07-07 7:23 ` Pavel Fedin
2015-07-07 7:43 ` Eric Auger
2015-07-06 15:37 ` Andre Przywara
2015-07-06 15:54 ` Paolo Bonzini
2015-07-06 16:08 ` Andre Przywara
2015-07-07 7:16 ` Pavel Fedin
2015-07-07 10:02 ` Andre Przywara
2015-07-07 10:57 ` Pavel Fedin
2015-07-06 12:08 ` Christoffer Dall
2015-07-06 13:33 ` Pavel Fedin
2015-07-06 15:09 ` Andre Przywara
2015-06-29 15:37 ` [PATCH 2/7] KVM: kvm_host: add kvm_extended_msi Eric Auger
2015-07-02 17:03 ` Andre Przywara
2015-06-29 15:37 ` [PATCH 3/7] KVM: irqchip: convey devid to kvm_set_msi Eric Auger
2015-06-29 15:37 ` [PATCH 4/7] KVM: arm/arm64: enable irqchip routing Eric Auger
2015-06-30 13:39 ` Andre Przywara
2015-06-30 14:02 ` Eric Auger [this message]
2015-06-29 15:37 ` [PATCH 5/7] KVM: arm/arm64: build a default routing table Eric Auger
2015-06-29 15:37 ` [PATCH 6/7] KVM: arm/arm64: enable MSI routing Eric Auger
2015-06-29 15:37 ` [PATCH 7/7] KVM: arm: implement kvm_set_msi by gsi direct mapping Eric Auger
2015-07-02 7:53 ` Pavel Fedin
2015-07-02 15:02 ` Eric Auger
2015-07-02 15:37 ` Pavel Fedin
2015-07-02 17:10 ` Andre Przywara
2015-07-03 5:34 ` Eric Auger
2015-07-05 19:40 ` [PATCH 0/7] KVM: arm/arm64: gsi routing support Christoffer Dall
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5592A176.1090502@linaro.org \
--to=eric.auger@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).