linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: marc.zyngier@arm.com (Marc Zyngier)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v4 09/13] ARM: KVM: VGIC interrupt injection
Date: Mon, 03 Dec 2012 19:22:45 +0000	[thread overview]
Message-ID: <50BCFC05.107@arm.com> (raw)
In-Reply-To: <CANM98qJbU=Nfs86nmwRBtw8m-sL-j3NVXJ1-+pZGQ3_Ax8ZoVQ@mail.gmail.com>

On 03/12/12 19:13, Christoffer Dall wrote:
> On Mon, Dec 3, 2012 at 9:21 AM, Marc Zyngier <marc.zyngier@arm.com> wrote:
>> On 03/12/12 13:25, Will Deacon wrote:
>>> On Sat, Nov 10, 2012 at 03:45:18PM +0000, Christoffer Dall wrote:
>>>> From: Marc Zyngier <marc.zyngier@arm.com>
>>>>
>>>> Plug the interrupt injection code. Interrupts can now be generated
>>>> from user space.
>>>>
>>>> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
>>>> Signed-off-by: Christoffer Dall <c.dall@virtualopensystems.com>
>>>> ---
>>>>  arch/arm/include/asm/kvm_vgic.h |    8 +++
>>>>  arch/arm/kvm/arm.c              |   29 +++++++++++++
>>>>  arch/arm/kvm/vgic.c             |   90 +++++++++++++++++++++++++++++++++++++++
>>>>  3 files changed, 127 insertions(+)
>>>>
>>>> diff --git a/arch/arm/include/asm/kvm_vgic.h b/arch/arm/include/asm/kvm_vgic.h
>>>> index 7229324..6e3d303 100644
>>>> --- a/arch/arm/include/asm/kvm_vgic.h
>>>> +++ b/arch/arm/include/asm/kvm_vgic.h
>>>> @@ -241,6 +241,8 @@ struct kvm_exit_mmio;
>>>>  int kvm_vgic_set_addr(struct kvm *kvm, unsigned long type, u64 addr);
>>>>  void kvm_vgic_sync_to_cpu(struct kvm_vcpu *vcpu);
>>>>  void kvm_vgic_sync_from_cpu(struct kvm_vcpu *vcpu);
>>>> +int kvm_vgic_inject_irq(struct kvm *kvm, int cpuid, unsigned int irq_num,
>>>> +                    bool level);
>>>>  int kvm_vgic_vcpu_pending_irq(struct kvm_vcpu *vcpu);
>>>>  bool vgic_handle_mmio(struct kvm_vcpu *vcpu, struct kvm_run *run,
>>>>                    struct kvm_exit_mmio *mmio);
>>>> @@ -271,6 +273,12 @@ static inline void kvm_vgic_vcpu_init(struct kvm_vcpu *vcpu) {}
>>>>  static inline void kvm_vgic_sync_to_cpu(struct kvm_vcpu *vcpu) {}
>>>>  static inline void kvm_vgic_sync_from_cpu(struct kvm_vcpu *vcpu) {}
>>>>
>>>> +static inline int kvm_vgic_inject_irq(struct kvm *kvm, int cpuid,
>>>> +                                  const struct kvm_irq_level *irq)
>>>> +{
>>>> +    return 0;
>>>> +}
>>>> +
>>>>  static inline int kvm_vgic_vcpu_pending_irq(struct kvm_vcpu *vcpu)
>>>>  {
>>>>      return 0;
>>>> diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
>>>> index 3ac1aab..f43da01 100644
>>>> --- a/arch/arm/kvm/arm.c
>>>> +++ b/arch/arm/kvm/arm.c
>>>> @@ -764,10 +764,31 @@ int kvm_vm_ioctl_irq_line(struct kvm *kvm, struct kvm_irq_level *irq_level)
>>>>
>>>>      switch (irq_type) {
>>>>      case KVM_ARM_IRQ_TYPE_CPU:
>>>> +            if (irqchip_in_kernel(kvm))
>>>> +                    return -ENXIO;
>>>> +
>>>>              if (irq_num > KVM_ARM_IRQ_CPU_FIQ)
>>>>                      return -EINVAL;
>>>>
>>>>              return vcpu_interrupt_line(vcpu, irq_num, level);
>>>> +#ifdef CONFIG_KVM_ARM_VGIC
>>>> +    case KVM_ARM_IRQ_TYPE_PPI:
>>>> +            if (!irqchip_in_kernel(kvm))
>>>> +                    return -ENXIO;
>>>> +
>>>> +            if (irq_num < 16 || irq_num > 31)
>>>> +                    return -EINVAL;
>>>
>>> It's our favourite two numbers again! :)
>>
>> I already fixed a number of them. Probably missed this one though.
>>
>>>> +
>>>> +            return kvm_vgic_inject_irq(kvm, vcpu->vcpu_id, irq_num, level);
>>>> +    case KVM_ARM_IRQ_TYPE_SPI:
>>>> +            if (!irqchip_in_kernel(kvm))
>>>> +                    return -ENXIO;
>>>> +
>>>> +            if (irq_num < 32 || irq_num > KVM_ARM_IRQ_GIC_MAX)
>>>> +                    return -EINVAL;
>>>> +
>>>> +            return kvm_vgic_inject_irq(kvm, 0, irq_num, level);
>>>> +#endif
>>>>      }
>>>>
>>>>      return -EINVAL;
>>>> @@ -849,6 +870,14 @@ long kvm_arch_vm_ioctl(struct file *filp,
>>>>      void __user *argp = (void __user *)arg;
>>>>
>>>>      switch (ioctl) {
>>>> +#ifdef CONFIG_KVM_ARM_VGIC
>>>> +    case KVM_CREATE_IRQCHIP: {
>>>> +            if (vgic_present)
>>>> +                    return kvm_vgic_create(kvm);
>>>> +            else
>>>> +                    return -EINVAL;
>>>
>>> ENXIO? At least, that's what you use when setting the GIC addresses.
>>
>> -EINVAL seems to be one of the values other archs are using. -ENXIO is
>> not one of them for KVM_CREATE_IRQCHIP. Doesn't mean they are right, but
>> for the sake of keeping userspace happy, I'm not really inclined to
>> change this.
>>
> 
> We don't have user space code relying on this, and EINVAL is
> misleading, so let's use ENXIO to be consistent with
> SET_DEVICE_ADDRESS. No error values are specified in the API docs, so
> we should use the most appropriate one.
> 
> You fix?

Yes, I'll fix it as part the whole vgic series.

	M.
-- 
Jazz is not dead. It just smells funny...

  reply	other threads:[~2012-12-03 19:22 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-10 15:44 [PATCH v4 00/13] KVM/ARM vGIC support Christoffer Dall
2012-11-10 15:44 ` [PATCH v4 01/13] KVM: ARM: Introduce KVM_SET_DEVICE_ADDRESS ioctl Christoffer Dall
2012-11-10 15:44 ` [PATCH v4 02/13] ARM: KVM: Keep track of currently running vcpus Christoffer Dall
2012-11-28 12:47   ` Will Deacon
2012-11-28 13:15     ` Marc Zyngier
2012-11-30 22:39     ` Christoffer Dall
2012-11-10 15:44 ` [PATCH v4 03/13] ARM: KVM: Initial VGIC infrastructure support Christoffer Dall
2012-11-28 12:49   ` Will Deacon
2012-11-28 13:09     ` Marc Zyngier
2012-11-28 14:13       ` Will Deacon
2012-12-01  2:19     ` Christoffer Dall
2012-11-10 15:44 ` [PATCH v4 04/13] ARM: KVM: Initial VGIC MMIO support code Christoffer Dall
2012-11-12  8:54   ` Dong Aisheng
2012-11-13 13:32     ` Christoffer Dall
2012-11-28 13:09   ` Will Deacon
2012-11-28 13:44     ` Marc Zyngier
2012-11-10 15:44 ` [PATCH v4 05/13] ARM: KVM: VGIC accept vcpu and dist base addresses from user space Christoffer Dall
2012-11-12  8:56   ` Dong Aisheng
2012-11-13 13:35     ` Christoffer Dall
2012-11-28 13:11   ` Will Deacon
2012-11-28 13:22     ` [kvmarm] " Marc Zyngier
2012-12-01  2:52     ` Christoffer Dall
2012-12-01 15:57       ` Christoffer Dall
2012-12-03 10:40       ` Will Deacon
2012-11-10 15:44 ` [PATCH v4 06/13] ARM: KVM: VGIC distributor handling Christoffer Dall
2012-11-12  9:29   ` Dong Aisheng
2012-11-13 13:38     ` Christoffer Dall
2012-11-28 13:21   ` Will Deacon
2012-11-28 14:35     ` Marc Zyngier
2012-11-10 15:45 ` [PATCH v4 07/13] ARM: KVM: VGIC virtual CPU interface management Christoffer Dall
2012-12-03 13:23   ` Will Deacon
2012-12-03 14:11     ` Marc Zyngier
2012-12-03 14:34       ` Will Deacon
2012-12-03 15:24         ` Marc Zyngier
2012-12-03 14:54       ` Christoffer Dall
2012-11-10 15:45 ` [PATCH v4 08/13] ARM: KVM: vgic: retire queued, disabled interrupts Christoffer Dall
2012-12-03 13:24   ` Will Deacon
2012-11-10 15:45 ` [PATCH v4 09/13] ARM: KVM: VGIC interrupt injection Christoffer Dall
2012-12-03 13:25   ` Will Deacon
2012-12-03 14:21     ` Marc Zyngier
2012-12-03 14:58       ` Christoffer Dall
2012-12-03 19:13       ` Christoffer Dall
2012-12-03 19:22         ` Marc Zyngier [this message]
2012-11-10 15:45 ` [PATCH v4 10/13] ARM: KVM: VGIC control interface world switch Christoffer Dall
2012-12-03 13:31   ` Will Deacon
2012-12-03 14:26     ` Marc Zyngier
2012-11-10 15:45 ` [PATCH v4 11/13] ARM: KVM: VGIC initialisation code Christoffer Dall
2012-12-05 10:43   ` Will Deacon
2012-11-10 15:45 ` [PATCH v4 12/13] ARM: KVM: vgic: reduce the number of vcpu kick Christoffer Dall
2012-12-05 10:43   ` Will Deacon
2012-12-05 10:58     ` Russell King - ARM Linux
2012-12-05 12:17       ` Marc Zyngier
2012-12-05 12:29         ` Russell King - ARM Linux
2012-12-05 13:40           ` Marc Zyngier
2012-12-05 15:55             ` Russell King - ARM Linux
2012-12-05 11:16   ` Russell King - ARM Linux
2012-11-10 15:45 ` [PATCH v4 13/13] ARM: KVM: Add VGIC configuration option Christoffer Dall
2012-11-10 19:52   ` Sergei Shtylyov

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=50BCFC05.107@arm.com \
    --to=marc.zyngier@arm.com \
    --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).