All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Hao, Xudong" <xudong.hao@intel.com>
To: Ian Jackson <Ian.Jackson@eu.citrix.com>
Cc: "xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>
Subject: Re: [PATCH] libxl: passthrough: avoid passing through devices not owned by pciback
Date: Tue, 17 Apr 2012 01:28:04 +0000	[thread overview]
Message-ID: <403610A45A2B5242BD291EDAE8B37D300FD12DE8@SHSMSX102.ccr.corp.intel.com> (raw)
In-Reply-To: 20349.44836.366233.162318@mariner.uk.xensource.com

Hi, Ian

Any other comments for this patch?

Thanks,
-Xudong


> -----Original Message-----
> From: Hao, Xudong
> Sent: Thursday, April 05, 2012 11:37 PM
> To: 'Ian Jackson'
> Cc: xen-devel@lists.xensource.com; Kay, Allen M
> Subject: RE: [Xen-devel] [PATCH] libxl: passthrough: avoid passing through
> devices not owned by pciback
> 
> <Porting from xen 4.1, patch on Xen unstable 25138>
> 
> libxl: passthrough: avoid passing through devices not owned by pciback
> 
> This patch makes sure the passthrough device belongs to pciback before allow
> them passthrough to the guest.  There are still many other checks missing.
> 
> xm terminates the guest startup process when this type of condition is found.
> This patch just allows the guest to continue to boot but with no device
> passthrough.
> 
> Signed-off-by: Allen Kay <allen.m.kay@intel.com>
> Signed-off-by: Xudong Hao <xudong.hao@intel.com>
> 
> diff -r 4e1d091d10d8 tools/libxl/libxl_pci.c
> --- a/tools/libxl/libxl_pci.c	Fri Mar 16 15:24:25 2012 +0000
> +++ b/tools/libxl/libxl_pci.c	Thu Mar 22 00:43:14 2012 +0800
> @@ -779,6 +779,24 @@ int libxl_device_pci_add(libxl_ctx *ctx,
>      return rc;
>  }
> 
> +static int libxl_pcidev_assignable(libxl_ctx *ctx, libxl_device_pci
> +*pcidev) {
> +    libxl_device_pci *pcidevs;
> +    int num, i;
> +
> +    pcidevs = libxl_device_pci_list_assignable(ctx, &num);
> +    for (i = 0; i < num; i++) {
> +        if (pcidevs[i].domain == pcidev->domain &&
> +            pcidevs[i].bus == pcidev->bus &&
> +            pcidevs[i].dev == pcidev->dev &&
> +            pcidevs[i].func == pcidev->func)
> +        {
> +            return 1;
> +        }
> +    }
> +    return 0;
> +}
> +
>  int libxl__device_pci_add(libxl__gc *gc, uint32_t domid, libxl_device_pci
> *pcidev, int starting)  {
>      libxl_ctx *ctx = libxl__gc_owner(gc); @@ -789,6 +807,13 @@ int
> libxl__device_pci_add(libxl__gc *gc,
> 
>      rc = libxl__device_pci_setdefault(gc, pcidev);
>      if (rc) goto out;
> +
> +    if (!libxl_pcidev_assignable(ctx, pcidev)) {
> +        LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "PCI device %x:%x:%x.%x is
> not assignable",
> +                   pcidev->domain, pcidev->bus, pcidev->dev,
> pcidev->func);
> +        rc = ERROR_FAIL;
> +        goto out;
> +    }
> 
>      rc = get_all_assigned_devices(gc, &assigned, &num_assigned);
>      if ( rc ) {
> 
> Thanks,
> -Xudong
> 
> > -----Original Message-----
> > From: Ian Jackson [mailto:Ian.Jackson@eu.citrix.com]
> > Sent: Thursday, April 05, 2012 10:42 PM
> > To: Hao, Xudong
> > Cc: xen-devel@lists.xensource.com; Kay, Allen M
> > Subject: RE: [Xen-devel] [PATCH] libxl: passthrough: avoid passing through
> > devices not owned by pciback
> >
> > Hao, Xudong writes ("RE: [Xen-devel] [PATCH] libxl: passthrough: avoid
> passing
> > through devices not owned by pciback"):
> > >
> > > > -----Original Message-----
> > > > From: Ian Jackson [mailto:Ian.Jackson@eu.citrix.com]
> > > > Sent: Tuesday, April 03, 2012 1:01 AM
> > > > To: Hao, Xudong
> > > > Cc: xen-devel@lists.xensource.com; Kay, Allen M
> > > > Subject: Re: [Xen-devel] [PATCH] libxl: passthrough: avoid passing
> > > > through devices not owned by pciback
> > > >
> > > > Hao, Xudong writes ("[Xen-devel] [PATCH] libxl: passthrough: avoid
> > > > passing through devices not owned by pciback"):
> > > > > <Porting from Xen 4.1 tree.>
> > > > >
> > > > > libxl: passthrough: avoid passing through devices not owned by
> > > > > pciback
> > > >
> > > > I'm afraid this no longer applies to xen-unstable.hg tip.
> > > >
> > > Reason?
> > >
> > > If no pciback checking, one device could be assigned to guest even it's being
> > used by dom0, is there security issue?
> >
> > I mean that it has conflicts when I try to apply it.  You need to refresh it.
> >
> > Thanks,
> > Ian.

      parent reply	other threads:[~2012-04-17  1:28 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-22  1:20 [PATCH] libxl: passthrough: avoid passing through devices not owned by pciback Hao, Xudong
2012-03-22 10:15 ` George Dunlap
2012-03-23  2:47   ` Hao, Xudong
2012-03-27 14:00     ` Ian Jackson
2012-03-31  2:12       ` Hao, Xudong
2012-03-27 14:41     ` George Dunlap
2012-03-31  2:10       ` Hao, Xudong
2012-04-02 17:00 ` Ian Jackson
2012-04-05  1:13   ` Hao, Xudong
2012-04-05  8:07     ` George Dunlap
2012-04-05 14:41     ` Ian Jackson
2012-04-05 15:37       ` Hao, Xudong
2012-04-24 18:02         ` Ian Jackson
2012-04-25  1:18           ` Hao, Xudong
2012-04-25 10:16             ` Ian Jackson
2012-04-25  2:01           ` Hao, Xudong
2012-04-25 10:18             ` Ian Jackson
2012-04-17  1:28       ` Hao, Xudong [this message]

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=403610A45A2B5242BD291EDAE8B37D300FD12DE8@SHSMSX102.ccr.corp.intel.com \
    --to=xudong.hao@intel.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=xen-devel@lists.xensource.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 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.