xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Paul Durrant <Paul.Durrant@citrix.com>
To: "xen-devel@lists.xen.org" <xen-devel@lists.xen.org>
Cc: Stefano Stabellini <sstabellini@kernel.org>,
	Wei Liu <wei.liu2@citrix.com>,
	Andrew Cooper <Andrew.Cooper3@citrix.com>,
	"Tim (Xen.org)" <tim@xen.org>,
	George Dunlap <George.Dunlap@citrix.com>,
	Ross Lagerwall <ross.lagerwall@citrix.com>,
	Jan Beulich <jbeulich@suse.com>,
	Ian Jackson <Ian.Jackson@citrix.com>
Subject: Re: [PATCH v3 2/6] x86/hvm: Provide XEN_DMOP_add_to_physmap
Date: Mon, 15 Jan 2018 13:33:02 +0000	[thread overview]
Message-ID: <952ef02563994e44a9cfa849fb4d0bf3@AMSPEX02CL03.citrite.net> (raw)
In-Reply-To: <20180112124513.28082-3-ross.lagerwall@citrix.com>

> -----Original Message-----
> From: Ross Lagerwall [mailto:ross.lagerwall@citrix.com]
> Sent: 12 January 2018 12:45
> To: xen-devel@lists.xen.org
> Cc: Ross Lagerwall <ross.lagerwall@citrix.com>; Paul Durrant
> <Paul.Durrant@citrix.com>; Jan Beulich <jbeulich@suse.com>; Andrew
> Cooper <Andrew.Cooper3@citrix.com>; George Dunlap
> <George.Dunlap@citrix.com>; Ian Jackson <Ian.Jackson@citrix.com>; Konrad
> Rzeszutek Wilk <konrad.wilk@oracle.com>; Stefano Stabellini
> <sstabellini@kernel.org>; Tim (Xen.org) <tim@xen.org>; Wei Liu
> <wei.liu2@citrix.com>
> Subject: [PATCH v3 2/6] x86/hvm: Provide XEN_DMOP_add_to_physmap
> 
> Provide XEN_DMOP_add_to_physmap, a limited version of
> XENMEM_add_to_physmap to allow a deprivileged QEMU to move VRAM
> when a
> guest programs its BAR. It is equivalent to XENMEM_add_to_physmap with
> space == XENMAPSPACE_gmfn_range.
> 
> Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>

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

> ---
> 
> Changed in v3:
> * Renamed idx -> src_gfn and gpfn -> dst_gfn.
> * Increase the width of size and add an overflow check.
> * Rework some of the descriptions.
> * Dropped Paul's reviewed-by due to the above changes.
> 
> Changed in v2:
> * Make it operate on a range.
> 
>  xen/arch/x86/hvm/dm.c          | 37
> +++++++++++++++++++++++++++++++++++++
>  xen/include/public/hvm/dm_op.h | 19 +++++++++++++++++++
>  xen/include/xlat.lst           |  1 +
>  3 files changed, 57 insertions(+)
> 
> diff --git a/xen/arch/x86/hvm/dm.c b/xen/arch/x86/hvm/dm.c
> index a787f43..4a2033e 100644
> --- a/xen/arch/x86/hvm/dm.c
> +++ b/xen/arch/x86/hvm/dm.c
> @@ -640,6 +640,42 @@ static int dm_op(const struct dmop_args *op_args)
>          break;
>      }
> 
> +    case XEN_DMOP_add_to_physmap:
> +    {
> +        struct xen_dm_op_add_to_physmap *data =
> +            &op.u.add_to_physmap;
> +        struct xen_add_to_physmap xatp = {
> +            .domid = op_args->domid,
> +            .size = data->size,
> +            .space = XENMAPSPACE_gmfn_range,
> +            .idx = data->src_gfn,
> +            .gpfn = data->dst_gfn,
> +        };
> +
> +        if ( data->pad )
> +        {
> +            rc = -EINVAL;
> +            break;
> +        }
> +
> +        if ( xatp.size != data->size )
> +        {
> +            rc = -EOVERFLOW;
> +            break;
> +        }
> +
> +        rc = xenmem_add_to_physmap(d, &xatp, 0);
> +        if ( rc > 0 )
> +        {
> +            data->size -= rc;
> +            data->src_gfn += rc;
> +            data->dst_gfn += rc;
> +            const_op = false;
> +            rc = -ERESTART;
> +        }
> +        break;
> +    }
> +
>      default:
>          rc = -EOPNOTSUPP;
>          break;
> @@ -669,6 +705,7 @@ CHECK_dm_op_set_mem_type;
>  CHECK_dm_op_inject_event;
>  CHECK_dm_op_inject_msi;
>  CHECK_dm_op_remote_shutdown;
> +CHECK_dm_op_add_to_physmap;
> 
>  int compat_dm_op(domid_t domid,
>                   unsigned int nr_bufs,
> diff --git a/xen/include/public/hvm/dm_op.h
> b/xen/include/public/hvm/dm_op.h
> index e173085..0d7e22f 100644
> --- a/xen/include/public/hvm/dm_op.h
> +++ b/xen/include/public/hvm/dm_op.h
> @@ -368,6 +368,24 @@ struct xen_dm_op_remote_shutdown {
>                             /* (Other reason values are not blocked) */
>  };
> 
> +/*
> + * XEN_DMOP_add_to_physmap : Sets the GFNs at which a page range
> appears in
> + *                           the specified guest's address space. Identical to
> + *                           XENMEM_add_to_physmap with
> + *                           space == XENMAPSPACE_gmfn_range.
> + */
> +#define XEN_DMOP_add_to_physmap 17
> +
> +struct xen_dm_op_add_to_physmap {
> +    /* Number of GFNs to process. */
> +    uint32_t size;
> +    uint32_t pad;
> +    /* Starting GFN of the source mapping page(s). */
> +    uint64_aligned_t src_gfn;
> +    /* Starting GFN where the source mapping page(s) should appear. */
> +    uint64_aligned_t dst_gfn;
> +};
> +
>  struct xen_dm_op {
>      uint32_t op;
>      uint32_t pad;
> @@ -389,6 +407,7 @@ struct xen_dm_op {
>          struct xen_dm_op_map_mem_type_to_ioreq_server
>                  map_mem_type_to_ioreq_server;
>          struct xen_dm_op_remote_shutdown remote_shutdown;
> +        struct xen_dm_op_add_to_physmap add_to_physmap;
>      } u;
>  };
> 
> diff --git a/xen/include/xlat.lst b/xen/include/xlat.lst
> index 4346cbe..d40bac6 100644
> --- a/xen/include/xlat.lst
> +++ b/xen/include/xlat.lst
> @@ -57,6 +57,7 @@
>  ?	grant_entry_v2			grant_table.h
>  ?	gnttab_swap_grant_ref		grant_table.h
>  !	dm_op_buf			hvm/dm_op.h
> +?	dm_op_add_to_physmap		hvm/dm_op.h
>  ?	dm_op_create_ioreq_server	hvm/dm_op.h
>  ?	dm_op_destroy_ioreq_server	hvm/dm_op.h
>  ?	dm_op_get_ioreq_server_info	hvm/dm_op.h
> --
> 2.9.5


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

  reply	other threads:[~2018-01-15 13:33 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-12 12:45 [PATCH v3 0/6] Add dmops to allow use of VGA with restricted QEMU Ross Lagerwall
2018-01-12 12:45 ` [PATCH v3 1/6] xen/mm: Make xenmem_add_to_physmap global Ross Lagerwall
2018-01-12 12:45 ` [PATCH v3 2/6] x86/hvm: Provide XEN_DMOP_add_to_physmap Ross Lagerwall
2018-01-15 13:33   ` Paul Durrant [this message]
2018-01-18  9:24   ` Jan Beulich
2018-01-18  9:32     ` Ross Lagerwall
2018-01-18  9:40       ` Jan Beulich
2018-01-12 12:45 ` [PATCH v3 3/6] x86/hvm: Provide XEN_DMOP_pin_memory_cacheattr Ross Lagerwall
2018-01-12 12:45 ` [PATCH v3 4/6] tools: libxendevicemodel: Provide xendevicemodel_add_to_physmap Ross Lagerwall
2018-01-12 12:45 ` [PATCH v3 5/6] tools: libxendevicemodel: Provide xendevicemodel_pin_memory_cacheattr Ross Lagerwall
2018-01-12 12:45 ` [PATCH v3 6/6] x86/domctl: Remove XEN_DOMCTL_pin_mem_cacheattr Ross Lagerwall
2018-01-15 13:38   ` Paul Durrant
2018-01-17 18:09   ` Daniel De Graaf
2018-01-18  9:29   ` Jan Beulich

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=952ef02563994e44a9cfa849fb4d0bf3@AMSPEX02CL03.citrite.net \
    --to=paul.durrant@citrix.com \
    --cc=Andrew.Cooper3@citrix.com \
    --cc=George.Dunlap@citrix.com \
    --cc=Ian.Jackson@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=ross.lagerwall@citrix.com \
    --cc=sstabellini@kernel.org \
    --cc=tim@xen.org \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xen.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;
as well as URLs for NNTP newsgroup(s).