kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	Jan Kiszka <jan.kiszka@siemens.com>,
	Paul Mackerras <paulus@samba.org>,
	Christoffer Dall <c.dall@virtualopensystems.com>,
	Alexander Graf <agraf@suse.de>,
	"kvmarm@lists.cs.columbia.edu" <kvmarm@lists.cs.columbia.edu>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	kvm-ppc <kvm-ppc@vger.kernel.org>
Subject: Re: [kvmarm] [RFC PATCH 0/3] KVM: ARM: Get rid of hardcoded VGIC addresses
Date: Fri, 26 Oct 2012 22:39:55 +1100	[thread overview]
Message-ID: <1351251595.12271.46.camel@pasglop> (raw)
In-Reply-To: <CAFEAcA_+brjafLeXMmWbk3_vCz1UZtqCjdr4byR8Ve8iKhzF=Q@mail.gmail.com>

On Fri, 2012-10-26 at 12:17 +0100, Peter Maydell wrote:
> > Well, that's the thing, I haven't managed to figure that out so far,
> it
> > looks very x86-specific to me. To begin with there's no such thing
> as a
> > "GSI" in our world.
> 
> This was roughly the feeling I had looking at these APIs. There
> might be some underlying generic concept but there is a definite
> tendency for the surface representation to use x86 specific
> terminology to the extent that you can't tell whether an API
> is x86 specific or merely apparently so...

Right. Which is why I'm sure I'm actually missing something there :-)
And I'm hoping Paolo and Jan will help shed some light.

It might help if somebody could explain a bit more what a GSI is in x86
land and how it relates to the various APICs, along with what exactly
they mean by "routing" , ie. what are the different elements that get
associated. Basically, if somebody could describe how the x86 stuff
works, that might help.

>From my view of things, we have various "sources" of interrupts. On my
list are emulated device LSIs, emulated device MSIs, both in qemu, then
vhost and finally pass-through, I suppose on some platforms IPIs come in
as well though. Those "sources" need, one way or another, to hit a
source controller which will then itself, in a platform specific way,
shoot the interrupt to a presentation controller.

The routing between source and presentation controllers is fairly
platform specific as far as I can tell even within a given CPU family.
Ie the way an OpenPIC (aka MPIC, used on macs) does it is different than
the way the XICS system does it on pseries, and is different from most
embedded stuff (which typically doesn't have that source/presentation
distinction but just cascaded dumber PICs). The amount of
configurability, the type of configuration information etc... that
governs such a layout is also very specific to the platform and the type
of interrupt controller system used on it.

Remains the "routing" between source of "events" and actual "inputs" to
a source controller.

This too doesn't seem totally obvious to generalize. For example an
embedded platform with a bunch of cascaded dumb interrupt controllers
doesn't have a concept of a flat number space in HW, an interrupt
"input" to be identified properly, needs to identify the controller and
the interrupt within that controller. However, within KVM/qemu, it's
pretty easy to assign to each controller a number and by collating the
two, get some kind of flat space, though it's not arbitrary and the
routing is thus fairly constrained if not totally fixed.

In the pseries case, the global number is split in two bit fields, the
BUID identifying the specific source controller and the source within
that controller. Here too it's fairly fixed though. So the ioctl we use
to create a source controller in the kernel takes the BUID as an
argument, and from there the kernel will "find" the right source
controller based solely on the interrupt number.

So basically on one side we have a global interrupt number that
identifies an "input", I assume that's what x86 calls a GSI ?

Remains how to associate the various sources of interrupts to that
'global number'... and that is fairly specific to each source type isn't
it ?

In our current powerpc code, the emulated devices toggle the qirq which
ends up shooting an ioctl to set/reset or "message" (for MSIs) the
corresponding global interrupt. The mapping is established entirely
within qemu, we just tell the kernel to trigger a given interrupt.

We haven't really sorted vhost out yet so I'm not sure how that will
work out but the idea would be to have an ioctl to associate an eventfd
or whatever vhost uses as interrupt "outputs" with a global interrupt
number.

For pass-through, currently our VFIO is dumb, interrupts get to qemu
which then shoots them back to the kernel using the standard qirq stuff
used by emulated devices. Here I suppose we would want something similar
to vhost to associate the VFIO irq fd with a "global number".

Is that what the existing ioctl's provide ? Their semantics aren't
totally obvious to me.

Note that for pass-through at least, and possibly for vhost, we'd like
to actually totally bypass the irqfd & eventfd stuff for performance
reasons. At least for VFIO, if we are going to get the max performance
out of it, we need to take all generic code out of the picture. IE. If
the interrupts are routed to the physical CPU where the guest is
running, we want to be able to catch and distribute the interrupts to
the guest entirely within guest context, ie, with KVM arch specific low
level code that runs in "real mode" (ie MMU off) without context
switching the MMU back to the host, which on POWER is fairly costly.

That means that at least the association between a guest global
interrupt number and a host global interrupt number for pass-through
will be something that goes entirely through arch specific code path. We
might still be able to use generic APIs to establish it if they are
suitable though.

Cheers,
Ben.

  reply	other threads:[~2012-10-26 11:39 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-14  0:04 [RFC PATCH 0/3] KVM: ARM: Get rid of hardcoded VGIC addresses Christoffer Dall
2012-10-14  0:04 ` [RFC PATCH 1/3] KVM: ARM: Introduce KVM_INIT_IRQCHIP ioctl Christoffer Dall
2012-10-17 20:21   ` Peter Maydell
2012-10-17 20:23     ` Christoffer Dall
2012-10-17 20:31       ` Peter Maydell
2012-10-17 20:39         ` Christoffer Dall
2012-10-18 12:20   ` Avi Kivity
2012-10-19 18:42     ` Christoffer Dall
2012-10-14  0:04 ` [RFC PATCH 2/3] KVM: ARM: Introduce KVM_SET_DEVICE_ADDRESS ioctl Christoffer Dall
2012-10-17 20:29   ` Peter Maydell
2012-10-19 18:46     ` Christoffer Dall
2012-10-19 20:24       ` Peter Maydell
2012-10-19 20:27         ` Christoffer Dall
2012-10-19 20:33           ` Christoffer Dall
2012-10-14  0:04 ` [RFC PATCH 3/3] KVM: ARM: Split KVM_CREATE_IRQCHIP and KVM_INIT_IRQCHIP Christoffer Dall
2012-10-18 11:15   ` Peter Maydell
2012-10-17 20:38 ` [kvmarm] [RFC PATCH 0/3] KVM: ARM: Get rid of hardcoded VGIC addresses Alexander Graf
2012-10-17 20:39   ` Christoffer Dall
2012-10-17 21:19     ` Benjamin Herrenschmidt
2012-10-17 22:10     ` Paul Mackerras
2012-10-17 23:58       ` Benjamin Herrenschmidt
2012-10-18 13:48         ` Christoffer Dall
2012-10-18 13:49           ` Alexander Graf
2012-10-18 15:25             ` Avi Kivity
2012-10-23 10:48           ` Jan Kiszka
2012-10-23 10:52             ` Peter Maydell
2012-10-23 11:00               ` Jan Kiszka
2012-10-23 11:04                 ` Peter Maydell
2012-10-23 11:08                   ` Jan Kiszka
2012-10-24  0:50             ` Paul Mackerras
2012-10-25 11:57               ` Jan Kiszka
2012-10-25 16:14               ` Paolo Bonzini
2012-10-25 16:32                 ` Jan Kiszka
2012-10-25 18:27                   ` Paolo Bonzini
2012-10-25 19:40                     ` Benjamin Herrenschmidt
2012-10-26  9:58                       ` Paolo Bonzini
2012-10-26 10:09                         ` Peter Maydell
2012-10-26 10:15                           ` Paolo Bonzini
2012-10-26 10:22                             ` Jan Kiszka
2012-10-26 10:44                             ` Benjamin Herrenschmidt
2012-10-26 11:00                               ` Jan Kiszka
2012-10-26 11:09                                 ` Benjamin Herrenschmidt
2012-10-26 11:57                                   ` Paolo Bonzini
2012-10-26 12:08                                     ` Peter Maydell
2012-10-26 12:41                                       ` Jan Kiszka
2012-10-26 20:21                                     ` Benjamin Herrenschmidt
2012-10-26 11:17                               ` Peter Maydell
2012-10-26 11:39                                 ` Benjamin Herrenschmidt [this message]
2012-10-26 12:39                                   ` Jan Kiszka
2012-10-26 20:45                                     ` Benjamin Herrenschmidt
2012-10-26 22:03                                       ` Benjamin Herrenschmidt
2012-10-27  8:06                                         ` Jan Kiszka
2012-10-27 10:01                                         ` Peter Maydell
2012-10-28 22:19                                           ` Benjamin Herrenschmidt
2012-10-26 10:37                         ` Benjamin Herrenschmidt
2012-10-26 10:40                           ` Paolo Bonzini
2012-10-26 10:47                             ` Benjamin Herrenschmidt
2012-10-26 11:47                               ` Paolo Bonzini
2012-10-25 19:39                 ` Benjamin Herrenschmidt

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=1351251595.12271.46.camel@pasglop \
    --to=benh@kernel.crashing.org \
    --cc=agraf@suse.de \
    --cc=c.dall@virtualopensystems.com \
    --cc=jan.kiszka@siemens.com \
    --cc=kvm-ppc@vger.kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=paulus@samba.org \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.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).