This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
Home Products Support Community News


Re: [Xen-devel] [PATCH 0/3] xen: msi support for Xen dom0

To: Jeremy Fitzhardinge <jeremy@xxxxxxxx>
Subject: Re: [Xen-devel] [PATCH 0/3] xen: msi support for Xen dom0
From: Qing He <qing.he@xxxxxxxxx>
Date: Tue, 1 Sep 2009 09:54:20 +0800
Cc: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>, "Jiang, Yunhong" <yunhong.jiang@xxxxxxxxx>
Delivery-date: Mon, 31 Aug 2009 18:49:37 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <4A8C50E4.8070006@xxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <1250574314-19600-1-git-send-email-qing.he@xxxxxxxxx> <4A8B0DFA.1020002@xxxxxxxx> <20090819014552.GA21318@ub-qhe2> <4A8C50E4.8070006@xxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.5.17+20080114 (2008-01-14)
On Thu, 2009-08-20 at 03:22 +0800, Jeremy Fitzhardinge wrote:
> >> I'm not actually sure this approach is going to work; so far it just
> >> locks up the machine shortly after ACPI initialization.  Trapping an
> >> emulating (IO-)APIC accesses may well turn out to be simpler (on the
> >> Linux side, at least) and more robust in the end...
> >>     
> > MSI by nature is vector based, but xen uses pirq as the interface to
> > communicate with dom0, 2/3 is actually used to handle the pirq thing
> > instead of solely vectors.
> >   
> Yes, that's awkward.  The new-interrupt-routing branch moves towards
> eliminating vectors from the kernel<->xen, replacing them entirely with
> pirqs.  Part of the motivation for this is to insulate the kernel from
> Xen's decisions on how to allocate and route vectors (ie, the number of
> vectors and whether they're percpu or not).
> Extending this to MSI would presumably require Xen to do the actual PCI
> (config space?) programming given a pirq for the device interrupt. 
> Perhaps this could be best achieved by making the x86
> arch_setup_msi_irqs call through a function pointer so we can direct it
> to a Xen-specific version.  Would that be clean?

I finished reading the new-interrupt-routing branch and had some revisit
on MSI. Basically, I think this branch is OK, exposing Xen vectors to
guest is quite weird (also includes `index' field of map_pirq call),
this `vector' is now even renamed to `irq' because of per-cpu vector.

And my MSI patches don't conflict significantly with the
new-interrupt-routing branch. We can consider the setting up of MSI as
two aspects: one is programming the interrupt source (by writing to
config space and MSIX mmio), the other is software: creating new irqs,
and starting them.  The method I use now is to add a branching
in arch_setup_msi_irqs, to (1) set the irq_chip of these new irqs to
pirq; (2) avoid programming the config space. This can be changed to
funciton pointers with no additional pain.

> > So trapping and emulating for msi will first need a decoupling of that,
> > allowing dom0 to use only vector to index its msi. This requires changing
> > of the current pirq based xen irq, which seems quite annoying at Xen side,
> > especially if per-cpu vector is in.
> >   
> What about making pirq == vector, so the "vector" seen by the kernel
> isn't a real vector at all, and Xen remaps from the pirq/vector to the
> real vector when emulating the write?

But the vector is allocated by the kernel, right? How can Xen know which
vector (and its CPU affinity) is related to a pirq?

For suspend/resume of MSI devices support, what the kernel does on bare
metal is simply to reprogram the interrupt source, including writing vectors
and set enable bit. On Xen, the reprogramming is done in the hypervisor,
so we just need to bypass kernel the kernel reprogramming: If using T&E,
just ignore address/data writing and if not, an arch specific hook is

And what do you mean by I/O APIC T&E? Since dom0 is eventually notified
by evtchn, a relation between vector and evtchn has to be established,
which doesn't exist yet. I ever think of mapping evtchns for (vcpu,
vector) pairs at vector allocation time, so that everything else can be
keep untouched. But that seems to involve to much change.


>     J

Xen-devel mailing list