qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kurz <groug@kaod.org>
To: David Gibson <david@gibson.dropbear.id.au>
Cc: abologna@redhat.com, thuth@redhat.com, lvivier@redhat.com,
	benh@kernel.crashing.org, marcel@redhat.com, aik@ozlabs.ru,
	ehabkost@redhat.com, mdroth@linux.vnet.ibm.com,
	libvir-list@redhat.com, qemu-devel@nongnu.org,
	qemu-ppc@nongnu.org
Subject: Re: [Qemu-devel] Proposal PCI/PCIe device placement on PAPR guests
Date: Fri, 6 Jan 2017 13:01:01 +0100	[thread overview]
Message-ID: <20170106130101.5b88cfec@bahia.lan> (raw)
In-Reply-To: <20170105054618.GA12106@umbus.fritz.box>

[-- Attachment #1: Type: text/plain, Size: 6050 bytes --]

Resending because of bad qemu-devel address...

On Thu, 5 Jan 2017 16:46:18 +1100
David Gibson <david@gibson.dropbear.id.au> wrote:

> There was a discussion back in November on the qemu list which spilled
> onto the libvirt list about how to add support for PCIe devices to
> POWER VMs, specifically 'pseries' machine type PAPR guests.
> 
> Here's a more concrete proposal for how to handle part of this in
> future from the libvirt side.  Strictly speaking what I'm suggesting
> here isn't intrinsically linked to PCIe: it will make adding PCIe
> support sanely easier, as well as having a number of advantages for
> both PCIe and plain-PCI devices on PAPR guests.
> 
> Background:
> 
>  * Currently the pseries machine type only supports vanilla PCI
>    buses.
>     * This is a qemu limitation, not something inherent - PAPR guests
>       running under PowerVM (the IBM hypervisor) can use passthrough
>       PCIe devices (PowerVM doesn't emulate devices though).
>     * In fact the way PCI access is para-virtalized in PAPR makes the
>       usual distinctions between PCI and PCIe largely disappear
>  * Presentation of PCIe devices to PAPR guests is unusual
>     * Unlike x86 - and other "bare metal" platforms, root ports are
>       not made visible to the guest. i.e. all devices (typically)
>       appear as though they were integrated devices on x86
>     * In terms of topology all devices will appear in a way similar to
>       a vanilla PCI bus, even PCIe devices
>        * However PCIe extended config space is accessible
>     * This means libvirt's usual placement of PCIe devices is not
>       suitable for PAPR guests
>  * PAPR has its own hotplug mechanism
>     * This is used instead of standard PCIe hotplug
>     * This mechanism works for both PCIe and vanilla-PCI devices
>     * This can hotplug/unplug devices even without a root port P2P
>       bridge between it and the root "bus
>  * Multiple independent host bridges are routine on PAPR
>     * Unlike PC (where all host bridges have multiplexed access to
>       configuration space) PCI host bridges (PHBs) are truly
>       independent for PAPR guests (disjoint MMIO regions in system
>       address space)
>     * PowerVM typically presents a separate PHB to the guest for each
>       host slot passed through
> 
> The Proposal:
> 
> I suggest that libvirt implement a new default algorithm for placing
> (i.e. assigning addresses to) both PCI and PCIe devices for (only)
> PAPR guests.
> 
> The short summary is that by default it should assign each device to a
> separate vPHB, creating vPHBs as necessary.
> 
>   * For passthrough sometimes a group of host devices can't be safely
>     isolated from each other - this is known as a (host) Partitionable
>     Endpoint (PE).  In this case, if any device in the PE is passed
>     through to a guest, the whole PE must be passed through to the
>     same vPHB in the guest.  From the guest POV, each vPHB has exactly
>     one (guest) PE.
>   * To allow for hotplugged devices, libvirt should also add a number
>     of additional, empty vPHBs (the PAPR spec allows for hotplug of
>     PHBs, but this is not yet implemented in qemu).  When hotplugging
>     a new device (or PE) libvirt should locate a vPHB which doesn't
>     currently contain anything.
>   * libvirt should only (automatically) add PHBs - never root ports or
>     other PCI to PCI bridges
> 
> In order to handle migration, the vPHBs will need to be represented in
> the domain XML, which will also allow the user to override this
> topology if they want.
> 
> Advantages:
> 
> There are still some details I need to figure out w.r.t. handling PCIe
> devices (on both the qemu and libvirt sides).  However the fact that

One such detail may be that PCIe devices should have the
"ibm,pci-config-space-type" property set to 1 in the DT,
for the driver to be able to access the extended config
space.

> PAPR guests don't typically see PCIe root ports means that the normal
> libvirt PCIe allocation scheme won't work.  This scheme has several
> advantages with or without support for PCIe devices:
> 
>  * Better performance for 32-bit devices
> 
> With multiple devices on a single vPHB they all must share a (fairly
> small) 32-bit DMA/IOMMU window.  With separate PHBs they each have a
> separate window.  PAPR guests have an always-on guest visible IOMMU.
> 
>  * Better EEH handling for passthrough devices
> 
> EEH is an IBM hardware-assisted mechanism for isolating and safely
> resetting devices experiencing hardware faults so they don't bring
> down other devices or the system at large.  It's roughly similar to
> PCIe AER in concept, but has a different IBM specific interface, and
> works on both PCI and PCIe devices.
> 
> Currently the kernel interfaces for handling EEH events on passthrough
> devices will only work if there is a single (host) iommu group in the
> vfio container.  While lifting that restriction would be nice, it's
> quite difficult to do so (it requires keeping state synchronized
> between multiple host groups).  That also means that an EEH error on
> one device could stop another device where that isn't required by the
> actual hardware.
> 
> The unit of EEH isolation is a PE (Partitionable Endpoint) and
> currently there is only one guest PE per vPHB.  Changing this might
> also be possible, but is again quite complex and may result in
> confusing and/or broken distinctions between groups for EEH isolation
> and IOMMU isolation purposes.
> 
> Placing separate host groups in separate vPHBs sidesteps these
> problems.
> 
>  * Guest NUMA node assignment of devices
> 
> PAPR does not (and can't reasonably) use the pxb device.  Instead to
> allocate devices to different guest NUMA nodes they should be placed
> on different vPHBs.  Placing them on different PHBs by default allows
> NUMA node to be assigned to those PHBs in a straightforward manner.
> 


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

       reply	other threads:[~2017-01-06 12:01 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20170105054618.GA12106@umbus.fritz.box>
2017-01-06 12:01 ` Greg Kurz [this message]
2017-01-06 17:34 ` [Qemu-devel] Proposal PCI/PCIe device placement on PAPR guests Andrea Bolognani
2017-01-08 23:46   ` David Gibson
2017-01-12 10:31     ` Andrea Bolognani
2017-01-12 14:52       ` Laine Stump
2017-01-12 16:35         ` Michael Roth
2017-01-12 17:53           ` Laine Stump
2017-01-12 22:56             ` David Gibson
2017-01-18 12:21             ` Marcel Apfelbaum
2017-01-12 22:57       ` David Gibson
2017-01-13 16:29         ` Greg Kurz
     [not found] ` <20170106125758.4643fb35@bahia.lan>
     [not found]   ` <20170112035219.GK14026@umbus.fritz.box>
     [not found]     ` <0bfaa82a-d5f5-eb0f-14a9-f7d13239cee5@ozlabs.ru>
     [not found]       ` <20170112100823.2a906117@bahia.lan>
     [not found]         ` <20170113044831.GP13656@umbus.fritz.box>
     [not found]           ` <20170113095828.302b77f2@bahia.lan>
     [not found]             ` <20170222120825.0253f2d6@bahia.lan>
     [not found]               ` <20170223021152.GR12577@umbus.fritz.box>
2017-02-23  7:23                 ` [Qemu-devel] [Qemu-ppc] " Greg Kurz
2017-02-23 22:57                   ` David Gibson

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=20170106130101.5b88cfec@bahia.lan \
    --to=groug@kaod.org \
    --cc=abologna@redhat.com \
    --cc=aik@ozlabs.ru \
    --cc=benh@kernel.crashing.org \
    --cc=david@gibson.dropbear.id.au \
    --cc=ehabkost@redhat.com \
    --cc=libvir-list@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=marcel@redhat.com \
    --cc=mdroth@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=thuth@redhat.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).