linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: gleb@redhat.com (Gleb Natapov)
To: linux-arm-kernel@lists.infradead.org
Subject: [kvmarm] [PATCH v5 06/14] KVM: ARM: Inject IRQs and FIQs from userspace
Date: Wed, 16 Jan 2013 12:40:55 +0200	[thread overview]
Message-ID: <20130116104055.GQ11529@redhat.com> (raw)
In-Reply-To: <50F582E9.40402@suse.de>

On Tue, Jan 15, 2013 at 05:25:13PM +0100, Alexander Graf wrote:
> On 01/15/2013 04:17 PM, Gleb Natapov wrote:
> >On Tue, Jan 15, 2013 at 02:04:47PM +0000, Peter Maydell wrote:
> >>On 15 January 2013 12:52, Gleb Natapov<gleb@redhat.com>  wrote:
> >>>On Tue, Jan 15, 2013 at 12:15:01PM +0000, Peter Maydell wrote:
> >>>>On 15 January 2013 09:56, Gleb Natapov<gleb@redhat.com>  wrote:
> >>>>>>ARM can signal an interrupt either at the CPU level, or at the in-kernel irqchip
> >>>>>CPU level interrupt should use KVM_INTERRUPT instead.
> >>>>No, that would be wrong. KVM_INTERRUPT is for interrupts which must be
> >>>>delivered synchronously to the CPU. KVM_IRQ_LINE is for interrupts which
> >>>>can be fed to the kernel asynchronously. It happens that on x86 "must be
> >>>>delivered synchronously" and "not going to in kernel irqchip" are the same, but
> >>>>this isn't true for other archs. For ARM all our interrupts can be fed
> >>>>to the kernel asynchronously, and so we use KVM_IRQ_LINE in all
> >>>>cases.
> >>>I do no quite understand what you mean by synchronously and
> >>>asynchronously.
> >>Synchronously: the vcpu has to be stopped and userspace then
> >>feeds in the interrupt to be taken when the guest is resumed.
> >>Asynchronously: any old thread can tell the kernel there's an
> >>interrupt, and the guest vcpu then deals with it when needed
> >>(the vcpu thread may leave the guest but doesn't come out of
> >>the host kernel to qemu).
> >>
> >>>The difference between KVM_INTERRUPT and KVM_IRQ_LINE line
> >>>is that former is used when destination cpu is known to userspace later
> >>>is used when kernel code is involved in figuring out the destination.
> >>This doesn't match up with Avi's explanation at all.
> >>
> >>>The
> >>>injections themselves are currently synchronous for both of them on x86
> >>>and ARM. i.e vcpu is kicked out from guest mode when interrupt need to
> >>>be injected into a guest and vcpu state is changed to inject interrupt
> >>>during next guest entry. In the near feature x86 will be able to inject
> >>>interrupt without kicking vcpu out from the guest mode does ARM plan to
> >>>do the same? For GIC interrupts or for IRQ/FIQ or for both?
> >>>
> >>>>There was a big discussion thread about this on kvm and qemu-devel last
> >>>>July (and we cleaned up some of the QEMU code to not smoosh together
> >>>>all these different concepts under "do I have an irqchip or not?").
> >>>Do you have a pointer?
> >>   http://lists.gnu.org/archive/html/qemu-devel/2012-07/msg02460.html
> >>and there was a later longer (but less clear) thread which included
> >>this mail from Avi:
> >>   http://lists.gnu.org/archive/html/qemu-devel/2012-07/msg02872.html
> >>basically explaining that the reason for the weird synchronous
> >>KVM_INTERRUPT API is that it's emulating a weird synchronous
> >>hardware interface which is specific to x86. ARM doesn't have
> >>a synchronous interface in the same way, so it's much more
> >>straightforward to use KVM_IRQ_LINE.
> >>
> >OK. I see. So basically Avi saw KVM_INTERRUPT as an oddball interface
> >required only for APIC emulation in userspace. It is used for PIC also,
> >where this is not strictly needed, but this is for historical reasons
> >(KVM_IRQ_LINE was introduces late and it is GSI centric on x86).
> >
> >Thank you for the pointer.
> 
> Yeah, please keep in mind that KVM_INTERRUPT is not a unified
> interface either. In fact, it is asynchronous on PPC :). And it's
> called KVM_S390_INTERRUPT on s390 and also asynchronous. X86 is the
> oddball here.
> 
KVM_INTERRUPT needs vcpu fd to be issues. Usually such ioctls are
issued only by vcpu thread which makes them synchronous and vcpu_load()
synchronise them anyway if the rule is not met. And sure enough those
KVM_S390_INTERRUPT/KVM_INTERRUPT are special cased in kvm_vcpu_ioctl()
to not call vcpu_load(), sigh :(

There was an idea to change vcpu ioctls to kvm syscall which would have
made it impossible to use KVM_INTERRUPT asynchronously.


> But I don't care whether we call the ioctl to steer CPU interrupt
> pins KVM_INTERRUPT, KVM_S390_INTERRUPT or KVM_IRQ_LINE, as long as
> the code makes it obvious what is happening.
> 
Some consistency would be nice though. You do not always look at the
kernel code when you read userspace code and iothread calling KVM_INTERRUPT
would have made me suspicious.

--
			Gleb.

  reply	other threads:[~2013-01-16 10:40 UTC|newest]

Thread overview: 80+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-08 18:38 [PATCH v5 00/14] KVM/ARM Implementation Christoffer Dall
2013-01-08 18:38 ` [PATCH v5 01/14] ARM: Add page table and page defines needed by KVM Christoffer Dall
2013-01-08 18:38 ` [PATCH v5 02/14] ARM: Section based HYP idmap Christoffer Dall
2013-01-14 10:27   ` Gleb Natapov
2013-01-14 10:49     ` Will Deacon
2013-01-14 11:07       ` Gleb Natapov
2013-01-14 13:07         ` Russell King - ARM Linux
2013-01-14 16:13   ` Russell King - ARM Linux
2013-01-14 17:09     ` Christoffer Dall
2013-01-08 18:38 ` [PATCH v5 03/14] KVM: ARM: Initial skeleton to compile KVM support Christoffer Dall
2013-01-14 15:09   ` Will Deacon
2013-01-14 15:40     ` Christoffer Dall
2013-01-14 16:24   ` Russell King - ARM Linux
2013-01-14 17:33     ` Christoffer Dall
2013-01-16  2:56       ` Rusty Russell
2013-01-16  9:44         ` Russell King - ARM Linux
2013-01-17  2:11           ` Rusty Russell
2013-01-14 18:49   ` Gleb Natapov
2013-01-14 22:17     ` Christoffer Dall
2013-01-15 13:32       ` Gleb Natapov
2013-01-15 13:43         ` [kvmarm] " Alexander Graf
2013-01-15 15:35           ` Gleb Natapov
2013-01-15 16:21             ` Alexander Graf
2013-01-08 18:39 ` [PATCH v5 04/14] KVM: ARM: Hypervisor initialization Christoffer Dall
2013-01-14 15:11   ` Will Deacon
2013-01-14 16:35     ` Christoffer Dall
2013-01-08 18:39 ` [PATCH v5 05/14] KVM: ARM: Memory virtualization setup Christoffer Dall
2013-01-08 18:39 ` [PATCH v5 06/14] KVM: ARM: Inject IRQs and FIQs from userspace Christoffer Dall
2013-01-15  9:56   ` Gleb Natapov
2013-01-15 12:15     ` [kvmarm] " Peter Maydell
2013-01-15 12:52       ` Gleb Natapov
2013-01-15 14:04         ` Peter Maydell
2013-01-15 14:40           ` Christoffer Dall
2013-01-15 15:17           ` Gleb Natapov
2013-01-15 16:25             ` Alexander Graf
2013-01-16 10:40               ` Gleb Natapov [this message]
2013-01-08 18:39 ` [PATCH v5 07/14] KVM: ARM: World-switch implementation Christoffer Dall
2013-01-15  9:43   ` Gleb Natapov
2013-01-16  2:08     ` Christoffer Dall
2013-01-16  4:08       ` Christoffer Dall
2013-01-16 12:57         ` Gleb Natapov
2013-01-16 15:40           ` Christoffer Dall
2013-01-16 16:17             ` Gleb Natapov
2013-01-16 12:12       ` Gleb Natapov
2013-01-16 13:14         ` Russell King - ARM Linux
2013-01-16 15:42         ` Christoffer Dall
2013-01-16 15:52           ` Gleb Natapov
2013-01-16 16:17             ` Christoffer Dall
2013-01-16 16:21               ` Gleb Natapov
2013-01-08 18:39 ` [PATCH v5 08/14] KVM: ARM: Emulation framework and CP15 emulation Christoffer Dall
2013-01-14 16:36   ` Russell King - ARM Linux
2013-01-14 17:38     ` Christoffer Dall
2013-01-14 18:33       ` Russell King - ARM Linux
2013-01-08 18:39 ` [PATCH v5 09/14] KVM: ARM: User space API for getting/setting co-proc registers Christoffer Dall
2013-01-08 18:39 ` [PATCH v5 10/14] KVM: ARM: Demux CCSIDR in the userspace API Christoffer Dall
2013-01-08 18:39 ` [PATCH v5 11/14] KVM: ARM: VFP userspace interface Christoffer Dall
2013-01-08 18:39 ` [PATCH v5 12/14] KVM: ARM: Handle guest faults in KVM Christoffer Dall
2013-01-08 18:40 ` [PATCH v5 13/14] KVM: ARM: Handle I/O aborts Christoffer Dall
2013-01-14 16:43   ` Russell King - ARM Linux
2013-01-14 18:25     ` Christoffer Dall
2013-01-14 18:43       ` Russell King - ARM Linux
2013-01-14 18:50         ` Will Deacon
2013-01-14 18:53           ` [kvmarm] " Alexander Graf
2013-01-14 18:56             ` Christoffer Dall
2013-01-14 19:00             ` Will Deacon
2013-01-14 19:12               ` Christoffer Dall
2013-01-14 22:36                 ` Will Deacon
2013-01-14 22:51                   ` Christoffer Dall
2013-01-15  7:00                   ` Gleb Natapov
2013-01-15 13:18   ` Gleb Natapov
2013-01-15 13:29     ` Marc Zyngier
2013-01-15 13:34       ` Gleb Natapov
2013-01-15 13:46         ` Marc Zyngier
2013-01-15 14:27           ` Gleb Natapov
2013-01-15 14:42             ` Christoffer Dall
2013-01-15 14:48             ` Marc Zyngier
2013-01-15 15:31               ` Gleb Natapov
2013-01-08 18:40 ` [PATCH v5 14/14] KVM: ARM: Add maintainer entry for KVM/ARM Christoffer Dall
2013-01-14 16:00 ` [PATCH v5 00/14] KVM/ARM Implementation Will Deacon
2013-01-14 22:31   ` 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=20130116104055.GQ11529@redhat.com \
    --to=gleb@redhat.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).