From: "Roger Pau Monné" <roger.pau@citrix.com>
To: "Marek Marczykowski-Górecki" <marmarek@invisiblethingslab.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>,
Wei Liu <wei.liu2@citrix.com>,
Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
George Dunlap <George.Dunlap@eu.citrix.com>,
Andrew Cooper <andrew.cooper3@citrix.com>,
Ian Jackson <ian.jackson@eu.citrix.com>, Tim Deegan <tim@xen.org>,
Julien Grall <julien.grall@arm.com>,
Jan Beulich <jbeulich@suse.com>,
xen-devel@lists.xenproject.org,
Daniel De Graaf <dgdegra@tycho.nsa.gov>
Subject: Re: [PATCH v3 5/6] xen/x86: add PHYSDEVOP_msi_msix_set_enable
Date: Wed, 30 Jan 2019 14:51:58 +0100 [thread overview]
Message-ID: <20190130135158.jo5ysmgawta4idzn@mac> (raw)
In-Reply-To: <d0a1089092cfdf2f4027428cc1e754f23128020d.1548469645.git-series.marmarek@invisiblethingslab.com>
On Sat, Jan 26, 2019 at 03:31:16AM +0100, Marek Marczykowski-Górecki wrote:
> Allow device model running in stubdomain to enable/disable MSI(-X),
> bypassing pciback. While pciback is still used to access config space
> from within stubdomain, it refuse to write to
> PCI_MSI_FLAGS_ENABLE/PCI_MSIX_FLAGS_ENABLE in non-permissive mode. Which
> is the right thing to do for PV domain (the main use case for pciback),
> as PV domain should use XEN_PCI_OP_* commands for that. Unfortunately
> those commands are not good for stubdomain use, as they configure MSI in
> dom0's kernel too, which should not happen for HVM domain.
>
> This new physdevop is allowed only for stubdomain controlling the domain
> which own the device.
>
> Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Thanks!
> ---
> Changes in v3:
> - new patch
>
> This is rather RFC. Any suggestions for shorter name? Also, I'm not sure
> if physdev_msi_msix_set_enable.flag is the best name/idea.
I've made some comments below.
> Should it be plugged into XSM? Any suggestions how exactly? New
> function with XSM_DM_PRIV default action? Should it get target domain
> only, or also machine_bdf?
You should Cc the XSM maintainer I think, which I've done now.
> ---
> xen/arch/x86/msi.c | 16 ++++++++++++++++
> xen/arch/x86/physdev.c | 24 ++++++++++++++++++++++++
> xen/include/asm-x86/msi.h | 1 +
> xen/include/public/physdev.h | 13 +++++++++++++
> 4 files changed, 54 insertions(+)
>
> diff --git a/xen/arch/x86/msi.c b/xen/arch/x86/msi.c
> index babc414..9ba934c 100644
> --- a/xen/arch/x86/msi.c
> +++ b/xen/arch/x86/msi.c
> @@ -1474,6 +1474,22 @@ int pci_restore_msi_state(struct pci_dev *pdev)
> return 0;
> }
>
> +int msi_msix_set_enable(struct pci_dev *pdev, int flag, int enable)
> +{
> + if ( !current->domain->target || pdev->domain != current->domain->target )
> + return -EPERM;
> +
> + switch ( flag ) {
> + case PHYSDEVOP_MSI_MSIX_SET_ENABLE_MSI:
> + msi_set_enable(pdev, enable);
> + break;
Please add a newline here.
> + case PHYSDEVOP_MSI_MSIX_SET_ENABLE_MSIX:
> + msix_set_enable(pdev, enable);
> + break;
> + }
> + return 0;
> +}
> +
> void __init early_msi_init(void)
> {
> if ( use_msi < 0 )
> diff --git a/xen/arch/x86/physdev.c b/xen/arch/x86/physdev.c
> index de59e39..822846a 100644
> --- a/xen/arch/x86/physdev.c
> +++ b/xen/arch/x86/physdev.c
> @@ -671,6 +671,30 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
> break;
> }
>
> + case PHYSDEVOP_msi_msix_set_enable: {
> + struct physdev_msi_msix_set_enable op;
> + struct pci_dev *pdev;
> +
> + ret = -EFAULT;
> + if ( copy_from_guest(&op, arg, 1) )
> + break;
> +
> + ret = -EINVAL;
> + if ( op.flag != PHYSDEVOP_MSI_MSIX_SET_ENABLE_MSI &&
> + op.flag != PHYSDEVOP_MSI_MSIX_SET_ENABLE_MSIX )
Align.
> + break;
> +
> + pcidevs_lock();
> + pdev = pci_get_pdev(op.pci.seg, op.pci.bus, op.pci.devfn);
> + if ( pdev )
> + ret = msi_msix_set_enable(pdev, op.flag, !!op.enable);
> + else
> + ret = -ENODEV;
> + pcidevs_unlock();
> + break;
> +
> + }
> +
> default:
> ret = -ENOSYS;
> break;
> diff --git a/xen/include/asm-x86/msi.h b/xen/include/asm-x86/msi.h
> index 10387dc..080bf24 100644
> --- a/xen/include/asm-x86/msi.h
> +++ b/xen/include/asm-x86/msi.h
> @@ -252,5 +252,6 @@ void guest_mask_msi_irq(struct irq_desc *, bool mask);
> void ack_nonmaskable_msi_irq(struct irq_desc *);
> void end_nonmaskable_msi_irq(struct irq_desc *, u8 vector);
> void set_msi_affinity(struct irq_desc *, const cpumask_t *);
> +int msi_msix_set_enable(struct pci_dev *pdev, int flag, int enable);
>
> #endif /* __ASM_MSI_H */
> diff --git a/xen/include/public/physdev.h b/xen/include/public/physdev.h
> index b6faf83..fd797c6 100644
> --- a/xen/include/public/physdev.h
> +++ b/xen/include/public/physdev.h
> @@ -344,6 +344,19 @@ struct physdev_dbgp_op {
> typedef struct physdev_dbgp_op physdev_dbgp_op_t;
> DEFINE_XEN_GUEST_HANDLE(physdev_dbgp_op_t);
>
> +#define PHYSDEVOP_MSI_MSIX_SET_ENABLE_MSI 0
> +#define PHYSDEVOP_MSI_MSIX_SET_ENABLE_MSIX 1
> +
> +#define PHYSDEVOP_msi_msix_set_enable 32
There's no need for the 'msi_msix' name, there are already other
hypercalls that deal with both msi and msix and just have msi in the
name: PHYSDEVOP_msi_set_enable.
> +struct physdev_msi_msix_set_enable {
> + /* IN */
> + struct physdev_pci_device pci;
> + uint8_t flag;
But this is not really a flags field, I would rather rename this
to 'mode' maybe.
> + uint8_t enable;
> +};
> +typedef struct physdev_msi_msix_set_enable physdev_msi_msix_set_enable_t;
> +DEFINE_XEN_GUEST_HANDLE(physdev_msi_msix_set_enable_t);
I think you need to add the new hypercall to include/xlat.lst, AFAICT
it requires no translation, so you should add it as '?'.
Thanks, Roger.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2019-01-30 13:53 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-26 2:31 [PATCH v3 0/6] Fix PCI passthrough for HVM with stubdomain Marek Marczykowski-Górecki
2019-01-26 2:31 ` [PATCH v3 1/6] libxl: do not attach xen-pciback to HVM domain, if stubdomain is in use Marek Marczykowski-Górecki
2019-01-28 14:24 ` Wei Liu
2019-01-26 2:31 ` [PATCH v3 2/6] libxl: attach PCI device to qemu only after setting pciback/pcifront Marek Marczykowski-Górecki
2019-01-28 14:24 ` Wei Liu
2019-01-26 2:31 ` [PATCH v3 3/6] libxl: don't try to manipulate json config for stubdomain Marek Marczykowski-Górecki
2019-01-28 14:41 ` Wei Liu
2019-01-28 21:11 ` Marek Marczykowski-Górecki
2019-01-26 2:31 ` [PATCH v3 4/6] xen/x86: Allow stubdom access to irq created for msi Marek Marczykowski-Górecki
2019-01-28 14:50 ` Wei Liu
2019-01-28 20:30 ` Marek Marczykowski-Górecki
2019-01-26 2:31 ` [PATCH v3 5/6] xen/x86: add PHYSDEVOP_msi_msix_set_enable Marek Marczykowski-Górecki
2019-01-28 14:57 ` Wei Liu
2019-01-30 13:51 ` Roger Pau Monné [this message]
[not found] ` <AE0ECAE80200006E0063616D@prv1-mh.provo.novell.com>
2019-01-30 14:39 ` Jan Beulich
2019-02-01 21:58 ` Daniel De Graaf
2019-01-26 2:31 ` [PATCH v3 6/6] tools/libxc: add wrapper for PHYSDEVOP_msi_msix_set_enable Marek Marczykowski-Górecki
2019-01-28 14:43 ` Wei Liu
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=20190130135158.jo5ysmgawta4idzn@mac \
--to=roger.pau@citrix.com \
--cc=George.Dunlap@eu.citrix.com \
--cc=andrew.cooper3@citrix.com \
--cc=dgdegra@tycho.nsa.gov \
--cc=ian.jackson@eu.citrix.com \
--cc=jbeulich@suse.com \
--cc=julien.grall@arm.com \
--cc=konrad.wilk@oracle.com \
--cc=marmarek@invisiblethingslab.com \
--cc=sstabellini@kernel.org \
--cc=tim@xen.org \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xenproject.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.