diff mbox

[v1,4/5] tools: libxendevicemodel: Provide xendevicemodel_add_to_physmap

Message ID 20171018140339.13888-5-ross.lagerwall@citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Ross Lagerwall Oct. 18, 2017, 2:03 p.m. UTC
Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
---
 tools/libs/devicemodel/Makefile                 |  2 +-
 tools/libs/devicemodel/core.c                   | 17 +++++++++++++++++
 tools/libs/devicemodel/include/xendevicemodel.h | 13 +++++++++++++
 tools/libs/devicemodel/libxendevicemodel.map    |  5 +++++
 4 files changed, 36 insertions(+), 1 deletion(-)

Comments

Ian Jackson Oct. 19, 2017, 3 p.m. UTC | #1
Ross Lagerwall writes ("[PATCH v1 4/5] tools: libxendevicemodel: Provide xendevicemodel_add_to_physmap"):
> Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>

Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>

I have looked at the hypervisor patches but I am not qualified to
assess the security properties of the new DMOPs.

Ian.
Paul Durrant Oct. 20, 2017, 9:22 a.m. UTC | #2
> -----Original Message-----

> From: Xen-devel [mailto:xen-devel-bounces@lists.xen.org] On Behalf Of

> Ross Lagerwall

> Sent: 18 October 2017 15:04

> To: Xen-devel <xen-devel@lists.xen.org>

> Cc: Ross Lagerwall <ross.lagerwall@citrix.com>; Ian Jackson

> <Ian.Jackson@citrix.com>; Wei Liu <wei.liu2@citrix.com>

> Subject: [Xen-devel] [PATCH v1 4/5] tools: libxendevicemodel: Provide

> xendevicemodel_add_to_physmap

> 

> Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>

> ---

>  tools/libs/devicemodel/Makefile                 |  2 +-

>  tools/libs/devicemodel/core.c                   | 17 +++++++++++++++++

>  tools/libs/devicemodel/include/xendevicemodel.h | 13 +++++++++++++

>  tools/libs/devicemodel/libxendevicemodel.map    |  5 +++++

>  4 files changed, 36 insertions(+), 1 deletion(-)

> 

> diff --git a/tools/libs/devicemodel/Makefile

> b/tools/libs/devicemodel/Makefile

> index 342371a..5b2df7a 100644

> --- a/tools/libs/devicemodel/Makefile

> +++ b/tools/libs/devicemodel/Makefile

> @@ -2,7 +2,7 @@ XEN_ROOT = $(CURDIR)/../../..

>  include $(XEN_ROOT)/tools/Rules.mk

> 

>  MAJOR    = 1

> -MINOR    = 1

> +MINOR    = 2

>  SHLIB_LDFLAGS += -Wl,--version-script=libxendevicemodel.map

> 

>  CFLAGS   += -Werror -Wmissing-prototypes

> diff --git a/tools/libs/devicemodel/core.c b/tools/libs/devicemodel/core.c

> index b66d4f9..2a23077 100644

> --- a/tools/libs/devicemodel/core.c

> +++ b/tools/libs/devicemodel/core.c

> @@ -564,6 +564,23 @@ int xendevicemodel_shutdown(

>      return xendevicemodel_op(dmod, domid, 1, &op, sizeof(op));

>  }

> 

> +int xendevicemodel_add_to_physmap(

> +    xendevicemodel_handle *dmod, domid_t domid, uint64_t idx, uint64_t

> gpfn)


Do you really want this to be single page? Populating VRAM is not going to be fast if you need to make 16MB / 4K hypercalls to do it.

  Paul

> +{

> +    struct xen_dm_op op;

> +    struct xen_dm_op_add_to_physmap *data;

> +

> +    memset(&op, 0, sizeof(op));

> +

> +    op.op = XEN_DMOP_add_to_physmap;

> +    data = &op.u.add_to_physmap;

> +

> +    data->idx = idx;

> +    data->gpfn = gpfn;

> +

> +    return xendevicemodel_op(dmod, domid, 1, &op, sizeof(op));

> +}

> +

>  int xendevicemodel_restrict(xendevicemodel_handle *dmod, domid_t

> domid)

>  {

>      return osdep_xendevicemodel_restrict(dmod, domid);

> diff --git a/tools/libs/devicemodel/include/xendevicemodel.h

> b/tools/libs/devicemodel/include/xendevicemodel.h

> index dda0bc7..2c4e392 100644

> --- a/tools/libs/devicemodel/include/xendevicemodel.h

> +++ b/tools/libs/devicemodel/include/xendevicemodel.h

> @@ -326,6 +326,19 @@ int xendevicemodel_shutdown(

>      xendevicemodel_handle *dmod, domid_t domid, unsigned int reason);

> 

>  /**

> + * Sets the GPFN at which a particular page appears in the domain's

> + * pseudophysical address space.

> + *

> + * @parm dmod a handle to an open devicemodel interface.

> + * @parm domid the domain id to be serviced

> + * @parm idx Index into GMFN space

> + * @parm gpfn GPFN in domid where the GMFN should appear

> + * @return 0 on success, -1 on failure.

> + */

> +int xendevicemodel_add_to_physmap(

> +    xendevicemodel_handle *dmod, domid_t domid, uint64_t idx, uint64_t

> gpfn);

> +

> +/**

>   * This function restricts the use of this handle to the specified

>   * domain.

>   *

> diff --git a/tools/libs/devicemodel/libxendevicemodel.map

> b/tools/libs/devicemodel/libxendevicemodel.map

> index cefd32b..4a19ecb 100644

> --- a/tools/libs/devicemodel/libxendevicemodel.map

> +++ b/tools/libs/devicemodel/libxendevicemodel.map

> @@ -27,3 +27,8 @@ VERS_1.1 {

>  	global:

>  		xendevicemodel_shutdown;

>  } VERS_1.0;

> +

> +VERS_1.2 {

> +	global:

> +		xendevicemodel_add_to_physmap;

> +} VERS_1.1;

> --

> 2.9.5

> 

> 

> _______________________________________________

> Xen-devel mailing list

> Xen-devel@lists.xen.org

> https://lists.xen.org/xen-devel
Wei Liu Oct. 27, 2017, 11:45 a.m. UTC | #3
On Fri, Oct 20, 2017 at 10:22:55AM +0100, Paul Durrant wrote:
> > -----Original Message-----
> > From: Xen-devel [mailto:xen-devel-bounces@lists.xen.org] On Behalf Of
> > Ross Lagerwall
> > Sent: 18 October 2017 15:04
> > To: Xen-devel <xen-devel@lists.xen.org>
> > Cc: Ross Lagerwall <ross.lagerwall@citrix.com>; Ian Jackson
> > <Ian.Jackson@citrix.com>; Wei Liu <wei.liu2@citrix.com>
> > Subject: [Xen-devel] [PATCH v1 4/5] tools: libxendevicemodel: Provide
> > xendevicemodel_add_to_physmap
> > 
> > Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
> > ---
> >  tools/libs/devicemodel/Makefile                 |  2 +-
> >  tools/libs/devicemodel/core.c                   | 17 +++++++++++++++++
> >  tools/libs/devicemodel/include/xendevicemodel.h | 13 +++++++++++++
> >  tools/libs/devicemodel/libxendevicemodel.map    |  5 +++++
> >  4 files changed, 36 insertions(+), 1 deletion(-)
> > 
> > diff --git a/tools/libs/devicemodel/Makefile
> > b/tools/libs/devicemodel/Makefile
> > index 342371a..5b2df7a 100644
> > --- a/tools/libs/devicemodel/Makefile
> > +++ b/tools/libs/devicemodel/Makefile
> > @@ -2,7 +2,7 @@ XEN_ROOT = $(CURDIR)/../../..
> >  include $(XEN_ROOT)/tools/Rules.mk
> > 
> >  MAJOR    = 1
> > -MINOR    = 1
> > +MINOR    = 2
> >  SHLIB_LDFLAGS += -Wl,--version-script=libxendevicemodel.map
> > 
> >  CFLAGS   += -Werror -Wmissing-prototypes
> > diff --git a/tools/libs/devicemodel/core.c b/tools/libs/devicemodel/core.c
> > index b66d4f9..2a23077 100644
> > --- a/tools/libs/devicemodel/core.c
> > +++ b/tools/libs/devicemodel/core.c
> > @@ -564,6 +564,23 @@ int xendevicemodel_shutdown(
> >      return xendevicemodel_op(dmod, domid, 1, &op, sizeof(op));
> >  }
> > 
> > +int xendevicemodel_add_to_physmap(
> > +    xendevicemodel_handle *dmod, domid_t domid, uint64_t idx, uint64_t
> > gpfn)
> 
> Do you really want this to be single page? Populating VRAM is not going to be fast if you need to make 16MB / 4K hypercalls to do it.

This. Since we're introducing a new interface please consider giving it
the ability to batch.
Ross Lagerwall Oct. 27, 2017, 12:06 p.m. UTC | #4
On 10/27/2017 12:45 PM, Wei Liu wrote:
> On Fri, Oct 20, 2017 at 10:22:55AM +0100, Paul Durrant wrote:
...
>>>  CFLAGS   += -Werror -Wmissing-prototypes
>>> diff --git a/tools/libs/devicemodel/core.c b/tools/libs/devicemodel/core.c
>>> index b66d4f9..2a23077 100644
>>> --- a/tools/libs/devicemodel/core.c
>>> +++ b/tools/libs/devicemodel/core.c
>>> @@ -564,6 +564,23 @@ int xendevicemodel_shutdown(
>>>      return xendevicemodel_op(dmod, domid, 1, &op, sizeof(op));
>>>  }
>>>
>>> +int xendevicemodel_add_to_physmap(
>>> +    xendevicemodel_handle *dmod, domid_t domid, uint64_t idx, uint64_t
>>> gpfn)
>>
>> Do you really want this to be single page? Populating VRAM is not going to be fast if you need to make 16MB / 4K hypercalls to do it.
>
> This. Since we're introducing a new interface please consider giving it
> the ability to batch.
>

Yes indeed. I sent a v2 of this patch series a few days ago which 
changes it to operate on a range.
diff mbox

Patch

diff --git a/tools/libs/devicemodel/Makefile b/tools/libs/devicemodel/Makefile
index 342371a..5b2df7a 100644
--- a/tools/libs/devicemodel/Makefile
+++ b/tools/libs/devicemodel/Makefile
@@ -2,7 +2,7 @@  XEN_ROOT = $(CURDIR)/../../..
 include $(XEN_ROOT)/tools/Rules.mk
 
 MAJOR    = 1
-MINOR    = 1
+MINOR    = 2
 SHLIB_LDFLAGS += -Wl,--version-script=libxendevicemodel.map
 
 CFLAGS   += -Werror -Wmissing-prototypes
diff --git a/tools/libs/devicemodel/core.c b/tools/libs/devicemodel/core.c
index b66d4f9..2a23077 100644
--- a/tools/libs/devicemodel/core.c
+++ b/tools/libs/devicemodel/core.c
@@ -564,6 +564,23 @@  int xendevicemodel_shutdown(
     return xendevicemodel_op(dmod, domid, 1, &op, sizeof(op));
 }
 
+int xendevicemodel_add_to_physmap(
+    xendevicemodel_handle *dmod, domid_t domid, uint64_t idx, uint64_t gpfn)
+{
+    struct xen_dm_op op;
+    struct xen_dm_op_add_to_physmap *data;
+
+    memset(&op, 0, sizeof(op));
+
+    op.op = XEN_DMOP_add_to_physmap;
+    data = &op.u.add_to_physmap;
+
+    data->idx = idx;
+    data->gpfn = gpfn;
+
+    return xendevicemodel_op(dmod, domid, 1, &op, sizeof(op));
+}
+
 int xendevicemodel_restrict(xendevicemodel_handle *dmod, domid_t domid)
 {
     return osdep_xendevicemodel_restrict(dmod, domid);
diff --git a/tools/libs/devicemodel/include/xendevicemodel.h b/tools/libs/devicemodel/include/xendevicemodel.h
index dda0bc7..2c4e392 100644
--- a/tools/libs/devicemodel/include/xendevicemodel.h
+++ b/tools/libs/devicemodel/include/xendevicemodel.h
@@ -326,6 +326,19 @@  int xendevicemodel_shutdown(
     xendevicemodel_handle *dmod, domid_t domid, unsigned int reason);
 
 /**
+ * Sets the GPFN at which a particular page appears in the domain's
+ * pseudophysical address space.
+ *
+ * @parm dmod a handle to an open devicemodel interface.
+ * @parm domid the domain id to be serviced
+ * @parm idx Index into GMFN space
+ * @parm gpfn GPFN in domid where the GMFN should appear
+ * @return 0 on success, -1 on failure.
+ */
+int xendevicemodel_add_to_physmap(
+    xendevicemodel_handle *dmod, domid_t domid, uint64_t idx, uint64_t gpfn);
+
+/**
  * This function restricts the use of this handle to the specified
  * domain.
  *
diff --git a/tools/libs/devicemodel/libxendevicemodel.map b/tools/libs/devicemodel/libxendevicemodel.map
index cefd32b..4a19ecb 100644
--- a/tools/libs/devicemodel/libxendevicemodel.map
+++ b/tools/libs/devicemodel/libxendevicemodel.map
@@ -27,3 +27,8 @@  VERS_1.1 {
 	global:
 		xendevicemodel_shutdown;
 } VERS_1.0;
+
+VERS_1.2 {
+	global:
+		xendevicemodel_add_to_physmap;
+} VERS_1.1;