From: Avi Kivity <avi@redhat.com>
To: Christoffer Dall <cdall@cs.columbia.edu>
Cc: kvm@vger.kernel.org, catalin.marinas@arm.com,
tech@virtualopensystems.com, android-virt@lists.cs.columbia.edu
Subject: Re: [PATCH v4 05/10] ARM: KVM: Inject IRQs and FIQs from userspace
Date: Tue, 09 Aug 2011 13:07:20 +0300 [thread overview]
Message-ID: <4E4106D8.3070305@redhat.com> (raw)
In-Reply-To: <20110806103933.27198.91264.stgit@localhost6.localdomain6>
On 08/06/2011 01:39 PM, Christoffer Dall wrote:
> Userspace can inject IRQs and FIQs through the KVM_IRQ_LINE VM ioctl.
> This ioctl is used since the sematics are in fact two lines that can be
> either raised or lowered on the VCPU - the IRQ and FIQ lines.
>
> KVM needs to know which VCPU it must operate on and whether the FIQ or
> IRQ line is raised/lowered. Hence both pieces of information is packed
> in the kvm_irq_level->irq field. The irq fild value will be:
> IRQ: vcpu_index * 2
> FIQ: (vcpu_index * 2) + 1
>
> This is documented in Documentation/kvm/api.txt.
>
> The effect of the ioctl is simply to simply raise/lower the
> corresponding virt_irq field on the VCPU struct, which will cause the
> world-switch code to raise/lower virtual interrupts when running the
> guest on next switch. The wait_for_interrupt flag is also cleared for
> raised IRQs causing an idle VCPU to become active again.
Note x86 starts out with a default configuration and allows updating it
via KVM_SET_GSI_ROUTING. You may need this in the future if you decide
to implement an irq controller in the kernel.
> +static int kvm_arch_vm_ioctl_irq_line(struct kvm *kvm,
> + struct kvm_irq_level *irq_level)
> +{
> + u32 mask;
> + unsigned int vcpu_idx;
> + struct kvm_vcpu *vcpu;
> +
> + vcpu_idx = irq_level->irq / 2;
> + if (vcpu_idx>= KVM_MAX_VCPUS)
> + return -EINVAL;
> +
> + vcpu = kvm_get_vcpu(kvm, vcpu_idx);
> + if (!vcpu)
> + return -EINVAL;
> +
> + switch (irq_level->irq % 2) {
> + case KVM_ARM_IRQ_LINE:
> + mask = HCR_VI;
> + break;
> + case KVM_ARM_FIQ_LINE:
> + mask = HCR_VF;
> + break;
> + default:
> + return -EINVAL;
> + }
> +
> + trace_kvm_irq_line(irq_level->irq % 2, irq_level->level, vcpu_idx);
Please reuse trace_kvm_set_irq(). You can decode vcpu/type in a
trace-cmd plugin.
> +
> + if (irq_level->level) {
> + vcpu->arch.virt_irq |= mask;
> + vcpu->arch.wait_for_interrupts = 0;
> + } else
> + vcpu->arch.virt_irq&= ~mask;
> +
This seems to be non-smp-safe? Do you need atomic ops and barriers
here? And a wakeup?
Unlike KVM_INTERRUPT, KVM_IRQ_LINE is designed to be used asynchronously
wrt the vcpu.
> + return 0;
> +}
> +
> long kvm_arch_vcpu_ioctl(struct file *filp,
> unsigned int ioctl, unsigned long arg)
> {
> @@ -312,8 +349,21 @@ int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm, struct kvm_dirty_log *log)
> long kvm_arch_vm_ioctl(struct file *filp,
> unsigned int ioctl, unsigned long arg)
> {
> - printk(KERN_ERR "kvm_arch_vm_ioctl: Unsupported ioctl (%d)\n", ioctl);
> - return -EINVAL;
> + struct kvm *kvm = filp->private_data;
> + void __user *argp = (void __user *)arg;
> +
> + switch (ioctl) {
> + case KVM_IRQ_LINE: {
> + struct kvm_irq_level irq_event;
> +
> + if (copy_from_user(&irq_event, argp, sizeof irq_event))
> + return -EFAULT;
> + return kvm_arch_vm_ioctl_irq_line(kvm,&irq_event);
> + }
> + default:
> + kvm_err(-EINVAL, "Unsupported ioctl (%d)", ioctl);
Please remove for the final code, we don't want a user spamming the
kernel log.
> + return -EINVAL;
> + }
> }
>
>
--
error compiling committee.c: too many arguments to function
next prev parent reply other threads:[~2011-08-09 10:08 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-06 10:38 [PATCH v4 00/10] KVM/ARM Implementation Christoffer Dall
2011-08-06 10:39 ` [PATCH v4 01/10] ARM: KVM: Initial skeleton to compile KVM support Christoffer Dall
2011-08-06 10:39 ` [PATCH v4 02/10] ARM: KVM: Hypervisor identity mapping Christoffer Dall
2011-08-09 9:20 ` Avi Kivity
2011-08-09 9:29 ` Catalin Marinas
2011-08-09 9:29 ` Christoffer Dall
2011-08-09 10:23 ` [Android-virt] " Alexey Smirnov
2011-08-09 11:23 ` Christoffer Dall
2011-08-06 10:39 ` [PATCH v4 03/10] ARM: KVM: Add hypervisor inititalization Christoffer Dall
2011-08-06 10:39 ` [PATCH v4 04/10] ARM: KVM: Memory virtualization setup Christoffer Dall
2011-08-09 9:57 ` Avi Kivity
2011-08-09 11:24 ` [Android-virt] " Christoffer Dall
2011-08-06 10:39 ` [PATCH v4 05/10] ARM: KVM: Inject IRQs and FIQs from userspace Christoffer Dall
2011-08-09 10:07 ` Avi Kivity [this message]
2011-08-09 11:27 ` [Android-virt] " Christoffer Dall
2011-08-09 11:37 ` Avi Kivity
2011-08-09 11:40 ` Christoffer Dall
2011-08-06 10:39 ` [PATCH v4 06/10] ARM: KVM: World-switch implementation Christoffer Dall
2011-08-09 11:09 ` Avi Kivity
2011-08-09 11:29 ` Christoffer Dall
2011-08-06 10:39 ` [PATCH v4 07/10] ARM: KVM: Emulation framework and CP15 emulation Christoffer Dall
2011-08-09 11:17 ` Avi Kivity
2011-08-09 11:34 ` Christoffer Dall
2011-08-09 11:39 ` Avi Kivity
2011-08-09 11:40 ` Christoffer Dall
2011-08-06 10:39 ` [PATCH v4 08/10] ARM: KVM: Handle guest faults in KVM Christoffer Dall
2011-08-09 11:24 ` Avi Kivity
2011-08-09 11:35 ` Christoffer Dall
2011-08-06 10:40 ` [PATCH v4 09/10] ARM: KVM: Handle I/O aborts Christoffer Dall
2011-08-09 11:34 ` Avi Kivity
2011-08-09 11:39 ` Christoffer Dall
2011-08-09 11:46 ` Avi Kivity
2011-08-06 10:40 ` [PATCH v4 10/10] ARM: KVM: Guest wait-for-interrupts (WFI) support Christoffer Dall
2011-08-09 11:43 ` [PATCH v4 00/10] KVM/ARM Implementation Avi Kivity
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=4E4106D8.3070305@redhat.com \
--to=avi@redhat.com \
--cc=android-virt@lists.cs.columbia.edu \
--cc=catalin.marinas@arm.com \
--cc=cdall@cs.columbia.edu \
--cc=kvm@vger.kernel.org \
--cc=tech@virtualopensystems.com \
/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).