xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: "Jan Beulich" <JBeulich@suse.com>
To: Tiejun Chen <tiejun.chen@intel.com>
Cc: Yang Zhang <yang.z.zhang@intel.com>,
	Kevin Tian <kevin.tian@intel.com>,
	xen-devel@lists.xen.org
Subject: Re: [v11][PATCH 01/16] xen: introduce XENMEM_reserved_device_memory_map
Date: Wed, 22 Jul 2015 03:32:50 -0600	[thread overview]
Message-ID: <55AF7F620200007800093E57@prv-mh.provo.novell.com> (raw)
In-Reply-To: <1437528607-19315-2-git-send-email-tiejun.chen@intel.com>

>>> On 22.07.15 at 03:29, <tiejun.chen@intel.com> wrote:
> From: Jan Beulich <jbeulich@suse.com>
> 
> This is a prerequisite for punching holes into HVM and PVH guests' P2M
> to allow passing through devices that are associated with (on VT-d)
> RMRRs.
> 
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> Signed-off-by: Tiejun Chen <tiejun.chen@intel.com>

You not stating what you did to the patch made me always assume
that you didn't do more than some cosmetic adjustments, if any.
Now that I'm preparing to get the initial part of this series in I find
that you altered it quite a bit, so I'm afraid I'm going to need to
undo some of the adjustments you did.

> @@ -303,6 +342,33 @@ int compat_memory_op(unsigned int cmd, XEN_GUEST_HANDLE_PARAM(void) compat)
>              break;
>          }
>  
> +#ifdef HAS_PASSTHROUGH
> +        case XENMEM_reserved_device_memory_map:
> +        {
> +            struct get_reserved_device_memory grdm;
> +
> +            if ( copy_from_guest(&grdm.map, compat, 1) ||
> +                 !compat_handle_okay(grdm.map.buffer, grdm.map.nr_entries) )
> +                return -EFAULT;
> +
> +            grdm.used_entries = 0;
> +            rc = iommu_get_reserved_device_memory(get_reserved_device_memory,
> +                                                  &grdm);
> +
> +            if ( !rc && grdm.map.nr_entries < grdm.used_entries )
> +                rc = -ENOBUFS;
> +
> +            grdm.map.nr_entries = grdm.used_entries;
> +            if ( grdm.map.nr_entries )

This conditional appears to be a bug: How would the caller know,
upon successful return, that there are no reserved regions?

> @@ -1162,6 +1199,33 @@ long do_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
>          break;
>      }
>  
> +#ifdef HAS_PASSTHROUGH
> +    case XENMEM_reserved_device_memory_map:
> +    {
> +        struct get_reserved_device_memory grdm;
> +

+        if ( unlikely(start_extent) )
+            return -ENOSYS;
+

> --- a/xen/include/public/memory.h
> +++ b/xen/include/public/memory.h
> @@ -573,7 +573,42 @@ struct xen_vnuma_topology_info {
>  typedef struct xen_vnuma_topology_info xen_vnuma_topology_info_t;
>  DEFINE_XEN_GUEST_HANDLE(xen_vnuma_topology_info_t);
>  
> -/* Next available subop number is 27 */
> +/*
> + * With some legacy devices, certain guest-physical addresses cannot safely
> + * be used for other purposes, e.g. to map guest RAM.  This hypercall
> + * enumerates those regions so the toolstack can avoid using them.
> + */
> +#define XENMEM_reserved_device_memory_map   27
> +struct xen_reserved_device_memory {
> +    xen_pfn_t start_pfn;
> +    xen_ulong_t nr_pages;
> +};
> +typedef struct xen_reserved_device_memory xen_reserved_device_memory_t;
> +DEFINE_XEN_GUEST_HANDLE(xen_reserved_device_memory_t);
> +
> +struct xen_reserved_device_memory_map {
> +    /* IN */
> +    /* Currently just one bit to indicate checkng all Reserved Device Memory. */
> +#define PCI_DEV_RDM_ALL   0x1
> +    uint32_t        flag;
> +    /* IN */
> +    uint16_t        seg;
> +    uint8_t         bus;
> +    uint8_t         devfn;

This makes a mem-op PCI specific. For one, this should therefore be
put in a union, so that non-PCI uses remain possible in the future
without breaking by then existing users of the interface. And with
that I wonder whether this shouldn't use struct physdev_pci_device.

> --- a/xen/include/xen/pci.h
> +++ b/xen/include/xen/pci.h
> @@ -33,6 +33,8 @@
>  #define PCI_DEVFN2(bdf) ((bdf) & 0xff)
>  #define PCI_BDF(b,d,f)  ((((b) & 0xff) << 8) | PCI_DEVFN(d,f))
>  #define PCI_BDF2(b,df)  ((((b) & 0xff) << 8) | ((df) & 0xff))
> +#define PCI_SBDF(s,bdf) (((s & 0xffff) << 16) | (bdf & 0xffff))
> +#define PCI_SBDF2(s,b,df) (((s & 0xffff) << 16) | PCI_BDF2(b,df))

The natural thing for PCI_SBDF() would be

#define PCI_SBDF(s,b,d,f) ...

See for instance
http://lists.xenproject.org/archives/html/xen-devel/2015-07/msg02554.html

I'm going to produce an updated patch, to be sent out later today.

Jan

  reply	other threads:[~2015-07-22  9:32 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-22  1:29 [v11][PATCH 00/16] Fix RMRR Tiejun Chen
2015-07-22  1:29 ` [v11][PATCH 01/16] xen: introduce XENMEM_reserved_device_memory_map Tiejun Chen
2015-07-22  9:32   ` Jan Beulich [this message]
2015-07-22 10:42   ` [PATCH v12] " Jan Beulich
2015-07-22 12:17     ` Julien Grall
2015-07-22 12:28       ` Jan Beulich
2015-07-22 12:52     ` Ian Campbell
2015-07-22 13:14       ` Jan Beulich
2015-07-22 13:19         ` Ian Campbell
2015-07-22 12:55     ` Chen, Tiejun
2015-07-22 13:03       ` Jan Beulich
2015-07-22 13:20         ` Chen, Tiejun
2015-07-22 13:28           ` Jan Beulich
2015-07-22 13:46     ` Ian Campbell
2015-07-22 14:22     ` [PATCH v12a] " Jan Beulich
2015-07-22  1:29 ` [v11][PATCH 02/16] xen/vtd: create RMRR mapping Tiejun Chen
2015-07-22  1:29 ` [v11][PATCH 03/16] xen/passthrough: extend hypercall to support rdm reservation policy Tiejun Chen
2015-07-22  1:29 ` [v11][PATCH 04/16] xen: enable XENMEM_memory_map in hvm Tiejun Chen
2015-07-22  1:29 ` [v11][PATCH 05/16] hvmloader: get guest memory map into memory_map[] Tiejun Chen
2015-07-22  1:29 ` [v11][PATCH 06/16] hvmloader/pci: Try to avoid placing BARs in RMRRs Tiejun Chen
2015-07-22  8:43   ` Jan Beulich
2015-07-22 13:00   ` Jan Beulich
2015-07-22  1:29 ` [v11][PATCH 07/16] hvmloader/e820: construct guest e820 table Tiejun Chen
2015-07-22  1:29 ` [v11][PATCH 08/16] tools/libxc: Expose new hypercall xc_reserved_device_memory_map Tiejun Chen
2015-07-22  1:30 ` [v11][PATCH 09/16] tools: extend xc_assign_device() to support rdm reservation policy Tiejun Chen
2015-07-22 13:06   ` Ian Jackson
2015-07-22 15:01     ` Wei Liu
2015-07-22  1:30 ` [v11][PATCH 10/16] tools: introduce some new parameters to set rdm policy Tiejun Chen
2015-07-22  1:30 ` [v11][PATCH 11/16] tools/libxl: detect and avoid conflicts with RDM Tiejun Chen
2015-07-22  8:28   ` Jan Beulich
2015-07-22  8:52     ` Chen, Tiejun
2015-07-22 10:12       ` Jan Beulich
2015-07-22 10:54       ` George Dunlap
2015-07-22 10:04   ` Ian Jackson
2015-07-22 16:05     ` Jan Beulich
2015-07-22 13:24   ` Ian Jackson
2015-07-22 13:33     ` Chen, Tiejun
2015-07-22 14:04       ` Ian Jackson
2015-07-22 15:00         ` Chen, Tiejun
2015-07-22 15:09           ` Chen, Tiejun
2015-07-22 15:09           ` Ian Jackson
2015-07-22 15:21             ` Chen, Tiejun
2015-07-22  1:30 ` [v11][PATCH 12/16] tools: introduce a new parameter to set a predefined rdm boundary Tiejun Chen
2015-07-22  1:30 ` [v11][PATCH 13/16] libxl: construct e820 map with RDM information for HVM guest Tiejun Chen
2015-07-22  1:30 ` [v11][PATCH 14/16] xen/vtd: enable USB device assignment Tiejun Chen
2015-07-22  1:30 ` [v11][PATCH 15/16] xen/vtd: prevent from assign the device with shared rmrr Tiejun Chen
2015-07-22  1:30 ` [v11][PATCH 16/16] tools: parse to enable new rdm policy parameters Tiejun Chen
2015-07-22 14:09   ` Ian Jackson
2015-07-22 14:40     ` Wei Liu
2015-07-22 12:38 ` [v11][PATCH 00/16] Fix RMRR 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=55AF7F620200007800093E57@prv-mh.provo.novell.com \
    --to=jbeulich@suse.com \
    --cc=kevin.tian@intel.com \
    --cc=tiejun.chen@intel.com \
    --cc=xen-devel@lists.xen.org \
    --cc=yang.z.zhang@intel.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).