From: Paul Mackerras <paulus@ozlabs.org>
To: "Cédric Le Goater" <clg@kaod.org>
Cc: kvm-ppc@vger.kernel.org,
David Gibson <david@gibson.dropbear.id.au>,
kvm@vger.kernel.org
Subject: Re: [PATCH v6 14/17] KVM: PPC: Book3S HV: XIVE: add passthrough support
Date: Thu, 25 Apr 2019 17:07:05 +1000 [thread overview]
Message-ID: <20190425070705.GA12768@blackberry> (raw)
In-Reply-To: <20190418103942.2883-15-clg@kaod.org>
On Thu, Apr 18, 2019 at 12:39:39PM +0200, Cédric Le Goater wrote:
> The KVM XICS-over-XIVE device and the proposed KVM XIVE native device
> implement an IRQ space for the guest using the generic IPI interrupts
> of the XIVE IC controller. These interrupts are allocated at the OPAL
> level and "mapped" into the guest IRQ number space in the range 0-0x1FFF.
> Interrupt management is performed in the XIVE way: using loads and
> stores on the addresses of the XIVE IPI interrupt ESB pages.
>
> Both KVM devices share the same internal structure caching information
> on the interrupts, among which the xive_irq_data struct containing the
> addresses of the IPI ESB pages and an extra one in case of pass-through.
> The later contains the addresses of the ESB pages of the underlying HW
> controller interrupts, PHB4 in all cases for now.
>
> A guest, when running in the XICS legacy interrupt mode, lets the KVM
> XICS-over-XIVE device "handle" interrupt management, that is to
> perform the loads and stores on the addresses of the ESB pages of the
> guest interrupts. However, when running in XIVE native exploitation
> mode, the KVM XIVE native device exposes the interrupt ESB pages to
> the guest and lets the guest perform directly the loads and stores.
>
> The VMA exposing the ESB pages make use of a custom VM fault handler
> which role is to populate the VMA with appropriate pages. When a fault
> occurs, the guest IRQ number is deduced from the offset, and the ESB
> pages of associated XIVE IPI interrupt are inserted in the VMA (using
> the internal structure caching information on the interrupts).
>
> Supporting device passthrough in the guest running in XIVE native
> exploitation mode adds some extra refinements because the ESB pages
> of a different HW controller (PHB4) need to be exposed to the guest
> along with the initial IPI ESB pages of the XIVE IC controller. But
> the overall mechanic is the same.
>
> When the device HW irqs are mapped into or unmapped from the guest
> IRQ number space, the passthru_irq helpers, kvmppc_xive_set_mapped()
> and kvmppc_xive_clr_mapped(), are called to record or clear the
> passthrough interrupt information and to perform the switch.
>
> The approach taken by this patch is to clear the ESB pages of the
> guest IRQ number being mapped and let the VM fault handler repopulate.
> The handler will insert the ESB page corresponding to the HW interrupt
> of the device being passed-through or the initial IPI ESB page if the
> device is being removed.
One comment below:
> @@ -257,6 +289,13 @@ static int kvmppc_xive_native_mmap(struct kvm_device *dev,
>
> vma->vm_flags |= VM_IO | VM_PFNMAP;
> vma->vm_page_prot = pgprot_noncached_wc(vma->vm_page_prot);
> +
> + /*
> + * Grab the KVM device file address_space to be able to clear
> + * the ESB pages mapping when a device is passed-through into
> + * the guest.
> + */
> + xive->mapping = vma->vm_file->f_mapping;
I'm worried about the lifetime of this pointer. At the least you
should clear it in the release function for the device, when you get
one. It looks like you should hold the xive->mapping_lock around the
clearing. I think that should be OK then since the release function
won't get called until all of the mmaps of the fd have been destroyed,
as I understand things.
Paul.
next prev parent reply other threads:[~2019-04-25 22:03 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-18 10:39 [PATCH v6 00/17] KVM: PPC: Book3S HV: add XIVE native exploitation mode Cédric Le Goater
2019-04-18 10:39 ` [PATCH v6 01/17] powerpc/xive: add OPAL extensions for the XIVE native exploitation support Cédric Le Goater
2019-04-18 10:39 ` [PATCH v6 02/17] KVM: PPC: Book3S HV: add a new KVM device for the XIVE native exploitation mode Cédric Le Goater
2019-04-18 10:39 ` [PATCH v6 03/17] KVM: PPC: Book3S HV: XIVE: introduce a new capability KVM_CAP_PPC_IRQ_XIVE Cédric Le Goater
2019-04-18 10:39 ` [PATCH v6 04/17] KVM: PPC: Book3S HV: XIVE: add a control to initialize a source Cédric Le Goater
2019-04-18 10:39 ` [PATCH v6 05/17] KVM: PPC: Book3S HV: XIVE: add a control to configure " Cédric Le Goater
2019-04-18 10:39 ` [PATCH v6 06/17] KVM: PPC: Book3S HV: XIVE: add controls for the EQ configuration Cédric Le Goater
2019-04-18 10:39 ` [PATCH v6 07/17] KVM: PPC: Book3S HV: XIVE: add a global reset control Cédric Le Goater
2019-04-18 10:39 ` [PATCH v6 08/17] KVM: PPC: Book3S HV: XIVE: add a control to sync the sources Cédric Le Goater
2019-04-18 10:39 ` [PATCH v6 09/17] KVM: PPC: Book3S HV: XIVE: add a control to dirty the XIVE EQ pages Cédric Le Goater
2019-04-18 10:39 ` [PATCH v6 10/17] KVM: PPC: Book3S HV: XIVE: add get/set accessors for the VP XIVE state Cédric Le Goater
2019-04-18 10:39 ` [PATCH v6 11/17] KVM: introduce a 'mmap' method for KVM devices Cédric Le Goater
2019-04-18 10:39 ` [PATCH v6 12/17] KVM: PPC: Book3S HV: XIVE: add a TIMA mapping Cédric Le Goater
2019-04-18 10:39 ` [PATCH v6 13/17] KVM: PPC: Book3S HV: XIVE: add a mapping for the source ESB pages Cédric Le Goater
2019-04-18 10:39 ` [PATCH v6 14/17] KVM: PPC: Book3S HV: XIVE: add passthrough support Cédric Le Goater
2019-04-25 7:07 ` Paul Mackerras [this message]
2019-05-06 15:16 ` Cédric Le Goater
2019-04-18 10:39 ` [PATCH v6 15/17] KVM: PPC: Book3S HV: XIVE: activate XIVE exploitation mode Cédric Le Goater
2019-04-18 10:39 ` [PATCH v6 16/17] KVM: introduce a 'release' method for KVM devices Cédric Le Goater
2019-04-18 10:39 ` [PATCH v6 17/17] KVM: PPC: Book3S HV: XIVE: replace the 'destroy' method by a 'release' method Cédric Le Goater
2019-04-23 6:04 ` David Gibson
2019-04-26 6:10 ` [PATCH] KVM: PPC: Book3S HV: XIVE: Prevent races when releasing device Paul Mackerras
2019-04-29 1:24 ` [PATCH v2] " Paul Mackerras
2019-05-06 16:05 ` Cédric Le Goater
2019-04-30 10:11 ` [PATCH v6 00/17] KVM: PPC: Book3S HV: add XIVE native exploitation mode Paul Mackerras
2019-05-06 16:10 ` Cédric Le Goater
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=20190425070705.GA12768@blackberry \
--to=paulus@ozlabs.org \
--cc=clg@kaod.org \
--cc=david@gibson.dropbear.id.au \
--cc=kvm-ppc@vger.kernel.org \
--cc=kvm@vger.kernel.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