xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Paul Durrant <Paul.Durrant@citrix.com>
To: 'Yu Zhang' <yu.c.zhang@linux.intel.com>,
	"xen-devel@lists.xen.org" <xen-devel@lists.xen.org>
Cc: Ian Jackson <Ian.Jackson@citrix.com>,
	Wei Liu <wei.liu2@citrix.com>,
	"zhiyuan.lv@intel.com" <zhiyuan.lv@intel.com>
Subject: Re: [PATCH v10 3/6] x86/ioreq server: Add device model wrappers for new DMOP
Date: Mon, 3 Apr 2017 08:13:20 +0000	[thread overview]
Message-ID: <b2362a5e904c48b9bb510a9933295445@AMSPEX02CL03.citrite.net> (raw)
In-Reply-To: <1491135867-623-4-git-send-email-yu.c.zhang@linux.intel.com>

> -----Original Message-----
> From: Yu Zhang [mailto:yu.c.zhang@linux.intel.com]
> Sent: 02 April 2017 13:24
> To: xen-devel@lists.xen.org
> Cc: zhiyuan.lv@intel.com; Paul Durrant <Paul.Durrant@citrix.com>; Ian
> Jackson <Ian.Jackson@citrix.com>; Wei Liu <wei.liu2@citrix.com>
> Subject: [PATCH v10 3/6] x86/ioreq server: Add device model wrappers for
> new DMOP
> 
> A new device model wrapper is added for the newly introduced
> DMOP - XEN_DMOP_map_mem_type_to_ioreq_server.
> 
> Since currently this DMOP only supports the emulation of write
> operations, attempts to trigger the DMOP with values other than
> XEN_DMOP_IOREQ_MEM_ACCESS_WRITE or 0(to unmap the ioreq server)
> shall fail. The wrapper shall be updated once read operations
> are also to be emulated in the future.
> 
> Also note currently this DMOP only supports one memory type,
> and can be extended in the future to map multiple memory types
> to multiple ioreq servers, e.g. mapping HVMMEM_ioreq_serverX to
> ioreq server X, This wrapper shall be updated when such change
> is made.
> 
> Signed-off-by: Yu Zhang <yu.c.zhang@linux.intel.com>

Reviewed-by: Paul Durrant <paul.durrant@citrix.com>

...with one observation...

> ---
> Cc: Paul Durrant <paul.durrant@citrix.com>
> Cc: Ian Jackson <ian.jackson@eu.citrix.com>
> Cc: Wei Liu <wei.liu2@citrix.com>
> ---
>  tools/libs/devicemodel/core.c                   | 25
> +++++++++++++++++++++++++
>  tools/libs/devicemodel/include/xendevicemodel.h | 18
> ++++++++++++++++++
>  tools/libs/devicemodel/libxendevicemodel.map    |  1 +
>  tools/libxc/include/xenctrl_compat.h            |  5 +++++
>  tools/libxc/xc_devicemodel_compat.c             | 17 +++++++++++++++++

This is new code so I don't think you really want compat code for this, do you?

>  5 files changed, 66 insertions(+)
> 
> diff --git a/tools/libs/devicemodel/core.c b/tools/libs/devicemodel/core.c
> index a85cb49..ff09819 100644
> --- a/tools/libs/devicemodel/core.c
> +++ b/tools/libs/devicemodel/core.c
> @@ -244,6 +244,31 @@ int
> xendevicemodel_unmap_io_range_from_ioreq_server(
>      return xendevicemodel_op(dmod, domid, 1, &op, sizeof(op));
>  }
> 
> +int xendevicemodel_map_mem_type_to_ioreq_server(
> +    xendevicemodel_handle *dmod, domid_t domid, ioservid_t id, uint16_t
> type,
> +    uint32_t flags)
> +{
> +    struct xen_dm_op op;
> +    struct xen_dm_op_map_mem_type_to_ioreq_server *data;
> +
> +    if (type != HVMMEM_ioreq_server ||
> +        flags & ~XEN_DMOP_IOREQ_MEM_ACCESS_WRITE) {
> +        errno = EINVAL;
> +        return -1;
> +    }
> +
> +    memset(&op, 0, sizeof(op));
> +
> +    op.op = XEN_DMOP_map_mem_type_to_ioreq_server;
> +    data = &op.u.map_mem_type_to_ioreq_server;
> +
> +    data->id = id;
> +    data->type = type;
> +    data->flags = flags;
> +
> +    return xendevicemodel_op(dmod, domid, 1, &op, sizeof(op));
> +}
> +
>  int xendevicemodel_map_pcidev_to_ioreq_server(
>      xendevicemodel_handle *dmod, domid_t domid, ioservid_t id,
>      uint16_t segment, uint8_t bus, uint8_t device, uint8_t function)
> diff --git a/tools/libs/devicemodel/include/xendevicemodel.h
> b/tools/libs/devicemodel/include/xendevicemodel.h
> index b3f600e..1da216f 100644
> --- a/tools/libs/devicemodel/include/xendevicemodel.h
> +++ b/tools/libs/devicemodel/include/xendevicemodel.h
> @@ -104,6 +104,24 @@ int
> xendevicemodel_unmap_io_range_from_ioreq_server(
>      uint64_t start, uint64_t end);
> 
>  /**
> + * This function registers/deregisters a memory type for emulation.
> + *
> + * @parm dmod a handle to an open devicemodel interface.
> + * @parm domid the domain id to be serviced.
> + * @parm id the IOREQ Server id.
> + * @parm type the memory type to be emulated. For now, only
> HVMMEM_ioreq_server
> + *            is supported, and in the future new types can be introduced, e.g.
> + *            HVMMEM_ioreq_serverX mapped to ioreq server X.
> + * @parm flags operations to be emulated; 0 for unmap. For now, only write
> + *             operations will be emulated and can be extended to emulate
> + *             read ones in the future.
> + * @return 0 on success, -1 on failure.
> + */
> +int xendevicemodel_map_mem_type_to_ioreq_server(
> +    xendevicemodel_handle *dmod, domid_t domid, ioservid_t id, uint16_t
> type,
> +    uint32_t flags);
> +
> +/**
>   * This function registers a PCI device for config space emulation.
>   *
>   * @parm dmod a handle to an open devicemodel interface.
> diff --git a/tools/libs/devicemodel/libxendevicemodel.map
> b/tools/libs/devicemodel/libxendevicemodel.map
> index 45c773e..130222c 100644
> --- a/tools/libs/devicemodel/libxendevicemodel.map
> +++ b/tools/libs/devicemodel/libxendevicemodel.map
> @@ -5,6 +5,7 @@ VERS_1.0 {
>  		xendevicemodel_get_ioreq_server_info;
>  		xendevicemodel_map_io_range_to_ioreq_server;
>  		xendevicemodel_unmap_io_range_from_ioreq_server;
> +		xendevicemodel_map_mem_type_to_ioreq_server;
>  		xendevicemodel_map_pcidev_to_ioreq_server;
>  		xendevicemodel_unmap_pcidev_from_ioreq_server;
>  		xendevicemodel_destroy_ioreq_server;
> diff --git a/tools/libxc/include/xenctrl_compat.h
> b/tools/libxc/include/xenctrl_compat.h
> index 040e7b2..173c08c 100644
> --- a/tools/libxc/include/xenctrl_compat.h
> +++ b/tools/libxc/include/xenctrl_compat.h
> @@ -134,6 +134,11 @@ int xc_hvm_map_io_range_to_ioreq_server(
>  int xc_hvm_unmap_io_range_from_ioreq_server(
>      xc_interface *xch, domid_t domid, ioservid_t id, int is_mmio,
>      uint64_t start, uint64_t end);
> +int xc_hvm_map_mem_type_to_ioreq_server(
> +    xc_interface * xch, domid_t domid, ioservid_t id,
> +    uint16_t type, uint32_t flags);
> +int xc_hvm_unmap_mem_type_from_ioreq_server(
> +    xc_interface * xch, domid_t domid, ioservid_t id, uint16_t type);
>  int xc_hvm_map_pcidev_to_ioreq_server(
>      xc_interface *xch, domid_t domid, ioservid_t id, uint16_t segment,
>      uint8_t bus, uint8_t device, uint8_t function);
> diff --git a/tools/libxc/xc_devicemodel_compat.c
> b/tools/libxc/xc_devicemodel_compat.c
> index e4edeea..ea2496b 100644
> --- a/tools/libxc/xc_devicemodel_compat.c
> +++ b/tools/libxc/xc_devicemodel_compat.c
> @@ -41,6 +41,23 @@ int xc_hvm_unmap_io_range_from_ioreq_server(
>                                                             start, end);
>  }
> 
> +int xc_hvm_map_mem_type_to_ioreq_server(
> +    xc_interface *xch, domid_t domid, ioservid_t id, uint16_t type,
> +    uint32_t flags)
> +{
> +    return xendevicemodel_map_mem_type_to_ioreq_server(xch->dmod,
> domid,
> +                                                           id, type,
> +                                                           flags);
> +}
> +
> +int xc_hvm_unmap_mem_type_from_ioreq_server(
> +    xc_interface *xch, domid_t domid, ioservid_t id, uint16_t type)
> +{
> +    return xendevicemodel_map_mem_type_to_ioreq_server(xch->dmod,
> domid,
> +                                                           id, type,
> +                                                           0);
> +}
> +
>  int xc_hvm_map_pcidev_to_ioreq_server(
>      xc_interface *xch, domid_t domid, ioservid_t id, uint16_t segment,
>      uint8_t bus, uint8_t device, uint8_t function)
> --
> 1.9.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  reply	other threads:[~2017-04-03  8:13 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-02 12:24 [PATCH v10 0/6] x86/ioreq server: Introduce HVMMEM_ioreq_server mem type Yu Zhang
2017-04-02 12:24 ` [PATCH v10 1/6] x86/ioreq server: Release the p2m lock after mmio is handled Yu Zhang
2017-04-02 12:24 ` [PATCH v10 2/6] x86/ioreq server: Add DMOP to map guest ram with p2m_ioreq_server to an ioreq server Yu Zhang
2017-04-03 14:21   ` Jan Beulich
2017-04-05 13:48   ` George Dunlap
2017-04-02 12:24 ` [PATCH v10 3/6] x86/ioreq server: Add device model wrappers for new DMOP Yu Zhang
2017-04-03  8:13   ` Paul Durrant [this message]
2017-04-03  9:28     ` Wei Liu
2017-04-05  6:53       ` Yu Zhang
2017-04-05  9:21         ` Jan Beulich
2017-04-05  9:22           ` Yu Zhang
2017-04-05  9:38             ` Jan Beulich
2017-04-05 10:08         ` Wei Liu
2017-04-05 10:20           ` Wei Liu
2017-04-05 10:21             ` Yu Zhang
2017-04-05 10:21           ` Yu Zhang
2017-04-05 10:33             ` Wei Liu
2017-04-05 10:26               ` Yu Zhang
2017-04-05 10:46                 ` Jan Beulich
2017-04-05 10:50                   ` Yu Zhang
2017-04-02 12:24 ` [PATCH v10 4/6] x86/ioreq server: Handle read-modify-write cases for p2m_ioreq_server pages Yu Zhang
2017-04-02 12:24 ` [PATCH v10 5/6] x86/ioreq server: Asynchronously reset outstanding p2m_ioreq_server entries Yu Zhang
2017-04-03 14:36   ` Jan Beulich
2017-04-03 14:38     ` Jan Beulich
2017-04-05  7:18     ` Yu Zhang
2017-04-05  8:11       ` Jan Beulich
2017-04-05 14:41   ` George Dunlap
2017-04-05 16:22     ` Yu Zhang
2017-04-05 16:35       ` George Dunlap
2017-04-05 16:32         ` Yu Zhang
2017-04-05 17:01           ` George Dunlap
2017-04-05 17:18             ` Yu Zhang
2017-04-05 17:28               ` Yu Zhang
2017-04-05 18:02                 ` Yu Zhang
2017-04-05 18:04                   ` Yu Zhang
2017-04-06  7:48                     ` Jan Beulich
2017-04-06  8:27                       ` Yu Zhang
2017-04-06  8:44                         ` Jan Beulich
2017-04-06  7:43                 ` Jan Beulich
2017-04-05 17:29               ` George Dunlap
2017-04-02 12:24 ` [PATCH v10 6/6] x86/ioreq server: Synchronously reset outstanding p2m_ioreq_server entries when an ioreq server unmaps Yu Zhang
2017-04-03  8:16   ` Paul Durrant
2017-04-03 15:23   ` Jan Beulich
2017-04-05  9:11     ` Yu Zhang
2017-04-05  9:41       ` Jan Beulich
2017-04-05 14:46   ` George Dunlap

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=b2362a5e904c48b9bb510a9933295445@AMSPEX02CL03.citrite.net \
    --to=paul.durrant@citrix.com \
    --cc=Ian.Jackson@citrix.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xen.org \
    --cc=yu.c.zhang@linux.intel.com \
    --cc=zhiyuan.lv@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).