xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] Fix bugs in dmop code
@ 2017-09-28 10:36 Wei Liu
  2017-09-28 10:36 ` [PATCH v2 1/2] x86/hvm/dmop: fix EFAULT condition Wei Liu
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Wei Liu @ 2017-09-28 10:36 UTC (permalink / raw)
  To: Xen-devel; +Cc: Anthony PERARD, Wei Liu

Wei Liu (2):
  x86/hvm/dmop: fix EFAULT condition
  libxendevicemodel: initialise extent to zero

 tools/libs/devicemodel/core.c | 2 +-
 xen/arch/x86/hvm/dm.c         | 6 ++----
 2 files changed, 3 insertions(+), 5 deletions(-)

-- 
2.11.0


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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2 1/2] x86/hvm/dmop: fix EFAULT condition
  2017-09-28 10:36 [PATCH v2 0/2] Fix bugs in dmop code Wei Liu
@ 2017-09-28 10:36 ` Wei Liu
  2017-09-28 10:39   ` Paul Durrant
  2017-09-28 10:36 ` [PATCH v2 2/2] libxendevicemodel: initialise extent to zero Wei Liu
  2017-09-28 10:40 ` [PATCH v2 0/2] Fix bugs in dmop code Andrew Cooper
  2 siblings, 1 reply; 8+ messages in thread
From: Wei Liu @ 2017-09-28 10:36 UTC (permalink / raw)
  To: Xen-devel
  Cc: Anthony PERARD, Andrew Cooper, Paul Durrant, Wei Liu, Jan Beulich

The copy macro returns false when the copy fails.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Paul Durrant <paul.durrant@citrix.com>

Backport to 4.9
---
 xen/arch/x86/hvm/dm.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/xen/arch/x86/hvm/dm.c b/xen/arch/x86/hvm/dm.c
index 87ef4b6ca9..9cf53b551c 100644
--- a/xen/arch/x86/hvm/dm.c
+++ b/xen/arch/x86/hvm/dm.c
@@ -178,11 +178,9 @@ static int modified_memory(struct domain *d,
         struct xen_dm_op_modified_memory_extent extent;
         unsigned int batch_nr;
         xen_pfn_t pfn, end_pfn;
-        int rc;
 
-        rc = COPY_FROM_GUEST_BUF_OFFSET(extent,
-            bufs, EXTENTS_BUFFER, (*rem_extents - 1) * sizeof(extent));
-        if ( rc )
+        if ( !COPY_FROM_GUEST_BUF_OFFSET(extent, bufs, EXTENTS_BUFFER,
+                                         (*rem_extents - 1) * sizeof(extent)) )
             return -EFAULT;
 
         if ( extent.pad )
-- 
2.11.0


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

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 2/2] libxendevicemodel: initialise extent to zero
  2017-09-28 10:36 [PATCH v2 0/2] Fix bugs in dmop code Wei Liu
  2017-09-28 10:36 ` [PATCH v2 1/2] x86/hvm/dmop: fix EFAULT condition Wei Liu
@ 2017-09-28 10:36 ` Wei Liu
  2017-09-28 10:40   ` Paul Durrant
  2017-09-28 10:40 ` [PATCH v2 0/2] Fix bugs in dmop code Andrew Cooper
  2 siblings, 1 reply; 8+ messages in thread
From: Wei Liu @ 2017-09-28 10:36 UTC (permalink / raw)
  To: Xen-devel; +Cc: Anthony PERARD, Ian Jackson, Paul Durrant, Wei Liu

The pad field needs to be zero as required by the hypervisor.

Instead of setting the pad separately, use C99 initialiser to clear
extent.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Paul Durrant <paul.durrant@citrix.com>

Backport to 4.9
---
 tools/libs/devicemodel/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/libs/devicemodel/core.c b/tools/libs/devicemodel/core.c
index fcb260d29b..986f147658 100644
--- a/tools/libs/devicemodel/core.c
+++ b/tools/libs/devicemodel/core.c
@@ -483,7 +483,7 @@ int xendevicemodel_modified_memory(
     xendevicemodel_handle *dmod, domid_t domid, uint64_t first_pfn,
     uint32_t nr)
 {
-    struct xen_dm_op_modified_memory_extent extent;
+    struct xen_dm_op_modified_memory_extent extent = { };
 
     extent.first_pfn = first_pfn;
     extent.nr = nr;
-- 
2.11.0


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

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 1/2] x86/hvm/dmop: fix EFAULT condition
  2017-09-28 10:36 ` [PATCH v2 1/2] x86/hvm/dmop: fix EFAULT condition Wei Liu
@ 2017-09-28 10:39   ` Paul Durrant
  0 siblings, 0 replies; 8+ messages in thread
From: Paul Durrant @ 2017-09-28 10:39 UTC (permalink / raw)
  To: Xen-devel; +Cc: Anthony Perard, Andrew Cooper, Wei Liu, Jan Beulich

> -----Original Message-----
> From: Wei Liu [mailto:wei.liu2@citrix.com]
> Sent: 28 September 2017 11:36
> To: Xen-devel <xen-devel@lists.xenproject.org>
> Cc: Anthony Perard <anthony.perard@citrix.com>; Wei Liu
> <wei.liu2@citrix.com>; Jan Beulich <jbeulich@suse.com>; Andrew Cooper
> <Andrew.Cooper3@citrix.com>; Paul Durrant <Paul.Durrant@citrix.com>
> Subject: [PATCH v2 1/2] x86/hvm/dmop: fix EFAULT condition
> 
> The copy macro returns false when the copy fails.
> 
> Signed-off-by: Wei Liu <wei.liu2@citrix.com>

Better diff stats too now :-)

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

> ---
> Cc: Jan Beulich <jbeulich@suse.com>
> Cc: Andrew Cooper <andrew.cooper3@citrix.com>
> Cc: Paul Durrant <paul.durrant@citrix.com>
> 
> Backport to 4.9
> ---
>  xen/arch/x86/hvm/dm.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/xen/arch/x86/hvm/dm.c b/xen/arch/x86/hvm/dm.c
> index 87ef4b6ca9..9cf53b551c 100644
> --- a/xen/arch/x86/hvm/dm.c
> +++ b/xen/arch/x86/hvm/dm.c
> @@ -178,11 +178,9 @@ static int modified_memory(struct domain *d,
>          struct xen_dm_op_modified_memory_extent extent;
>          unsigned int batch_nr;
>          xen_pfn_t pfn, end_pfn;
> -        int rc;
> 
> -        rc = COPY_FROM_GUEST_BUF_OFFSET(extent,
> -            bufs, EXTENTS_BUFFER, (*rem_extents - 1) * sizeof(extent));
> -        if ( rc )
> +        if ( !COPY_FROM_GUEST_BUF_OFFSET(extent, bufs, EXTENTS_BUFFER,
> +                                         (*rem_extents - 1) * sizeof(extent)) )
>              return -EFAULT;
> 
>          if ( extent.pad )
> --
> 2.11.0


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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 0/2] Fix bugs in dmop code
  2017-09-28 10:36 [PATCH v2 0/2] Fix bugs in dmop code Wei Liu
  2017-09-28 10:36 ` [PATCH v2 1/2] x86/hvm/dmop: fix EFAULT condition Wei Liu
  2017-09-28 10:36 ` [PATCH v2 2/2] libxendevicemodel: initialise extent to zero Wei Liu
@ 2017-09-28 10:40 ` Andrew Cooper
  2 siblings, 0 replies; 8+ messages in thread
From: Andrew Cooper @ 2017-09-28 10:40 UTC (permalink / raw)
  To: Wei Liu, Xen-devel; +Cc: Anthony PERARD

On 28/09/17 11:36, Wei Liu wrote:
> Wei Liu (2):
>   x86/hvm/dmop: fix EFAULT condition
>   libxendevicemodel: initialise extent to zero

Both Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 2/2] libxendevicemodel: initialise extent to zero
  2017-09-28 10:36 ` [PATCH v2 2/2] libxendevicemodel: initialise extent to zero Wei Liu
@ 2017-09-28 10:40   ` Paul Durrant
  2017-09-28 10:46     ` Wei Liu
  0 siblings, 1 reply; 8+ messages in thread
From: Paul Durrant @ 2017-09-28 10:40 UTC (permalink / raw)
  To: Xen-devel; +Cc: Anthony Perard, Ian Jackson, Wei Liu

> -----Original Message-----
> From: Wei Liu [mailto:wei.liu2@citrix.com]
> Sent: 28 September 2017 11:36
> To: Xen-devel <xen-devel@lists.xenproject.org>
> Cc: Anthony Perard <anthony.perard@citrix.com>; Wei Liu
> <wei.liu2@citrix.com>; Ian Jackson <Ian.Jackson@citrix.com>; Paul Durrant
> <Paul.Durrant@citrix.com>
> Subject: [PATCH v2 2/2] libxendevicemodel: initialise extent to zero
> 
> The pad field needs to be zero as required by the hypervisor.
> 
> Instead of setting the pad separately, use C99 initialiser to clear
> extent.
> 
> Signed-off-by: Wei Liu <wei.liu2@citrix.com>
> ---
> Cc: Ian Jackson <ian.jackson@eu.citrix.com>
> Cc: Paul Durrant <paul.durrant@citrix.com>
> 
> Backport to 4.9
> ---
>  tools/libs/devicemodel/core.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/libs/devicemodel/core.c b/tools/libs/devicemodel/core.c
> index fcb260d29b..986f147658 100644
> --- a/tools/libs/devicemodel/core.c
> +++ b/tools/libs/devicemodel/core.c
> @@ -483,7 +483,7 @@ int xendevicemodel_modified_memory(
>      xendevicemodel_handle *dmod, domid_t domid, uint64_t first_pfn,
>      uint32_t nr)
>  {
> -    struct xen_dm_op_modified_memory_extent extent;
> +    struct xen_dm_op_modified_memory_extent extent = { };

Not quite. I meant:

struct xen_dm_op_modified_memory_extent extent = { 
    .first_pfn = first_pfn,
    .nr = nr,
};

then you can drop the lines below.

  Paul

> 
>      extent.first_pfn = first_pfn;
>      extent.nr = nr;
> --
> 2.11.0


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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 2/2] libxendevicemodel: initialise extent to zero
  2017-09-28 10:40   ` Paul Durrant
@ 2017-09-28 10:46     ` Wei Liu
  2017-09-28 10:48       ` Paul Durrant
  0 siblings, 1 reply; 8+ messages in thread
From: Wei Liu @ 2017-09-28 10:46 UTC (permalink / raw)
  To: Paul Durrant; +Cc: Anthony Perard, Xen-devel, Wei Liu, Ian Jackson

On Thu, Sep 28, 2017 at 11:40:45AM +0100, Paul Durrant wrote:
> > -----Original Message-----
> > From: Wei Liu [mailto:wei.liu2@citrix.com]
> > Sent: 28 September 2017 11:36
> > To: Xen-devel <xen-devel@lists.xenproject.org>
> > Cc: Anthony Perard <anthony.perard@citrix.com>; Wei Liu
> > <wei.liu2@citrix.com>; Ian Jackson <Ian.Jackson@citrix.com>; Paul Durrant
> > <Paul.Durrant@citrix.com>
> > Subject: [PATCH v2 2/2] libxendevicemodel: initialise extent to zero
> > 
> > The pad field needs to be zero as required by the hypervisor.
> > 
> > Instead of setting the pad separately, use C99 initialiser to clear
> > extent.
> > 
> > Signed-off-by: Wei Liu <wei.liu2@citrix.com>
> > ---
> > Cc: Ian Jackson <ian.jackson@eu.citrix.com>
> > Cc: Paul Durrant <paul.durrant@citrix.com>
> > 
> > Backport to 4.9
> > ---
> >  tools/libs/devicemodel/core.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/tools/libs/devicemodel/core.c b/tools/libs/devicemodel/core.c
> > index fcb260d29b..986f147658 100644
> > --- a/tools/libs/devicemodel/core.c
> > +++ b/tools/libs/devicemodel/core.c
> > @@ -483,7 +483,7 @@ int xendevicemodel_modified_memory(
> >      xendevicemodel_handle *dmod, domid_t domid, uint64_t first_pfn,
> >      uint32_t nr)
> >  {
> > -    struct xen_dm_op_modified_memory_extent extent;
> > +    struct xen_dm_op_modified_memory_extent extent = { };
> 
> Not quite. I meant:
> 
> struct xen_dm_op_modified_memory_extent extent = { 
>     .first_pfn = first_pfn,
>     .nr = nr,
> };
> 
> then you can drop the lines below.

Here you go.

---8<---
From 75c955c2d2c7077fe59b5e3b14e3deff613025e8 Mon Sep 17 00:00:00 2001
From: Wei Liu <wei.liu2@citrix.com>
Date: Thu, 28 Sep 2017 11:00:00 +0100
Subject: [PATCH] libxendevicemodel: initialise extent.pad to zero

The pad field needs to be zero as required by the hypervisor.

Instead of setting the pad separately, use C99 initialiser.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Paul Durrant <paul.durrant@citrix.com>

Backport to 4.9
---
 tools/libs/devicemodel/core.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/libs/devicemodel/core.c b/tools/libs/devicemodel/core.c
index fcb260d29b..0f2c1a791f 100644
--- a/tools/libs/devicemodel/core.c
+++ b/tools/libs/devicemodel/core.c
@@ -483,10 +483,10 @@ int xendevicemodel_modified_memory(
     xendevicemodel_handle *dmod, domid_t domid, uint64_t first_pfn,
     uint32_t nr)
 {
-    struct xen_dm_op_modified_memory_extent extent;
-
-    extent.first_pfn = first_pfn;
-    extent.nr = nr;
+    struct xen_dm_op_modified_memory_extent extent = {
+        .first_pfn = first_pfn,
+        .nr = nr,
+    };
 
     return xendevicemodel_modified_memory_bulk(dmod, domid, &extent, 1);
 }
-- 
2.11.0


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

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 2/2] libxendevicemodel: initialise extent to zero
  2017-09-28 10:46     ` Wei Liu
@ 2017-09-28 10:48       ` Paul Durrant
  0 siblings, 0 replies; 8+ messages in thread
From: Paul Durrant @ 2017-09-28 10:48 UTC (permalink / raw)
  Cc: Anthony Perard, Xen-devel, Wei Liu, Ian Jackson

> -----Original Message-----
> From: Wei Liu [mailto:wei.liu2@citrix.com]
> Sent: 28 September 2017 11:46
> To: Paul Durrant <Paul.Durrant@citrix.com>
> Cc: Wei Liu <wei.liu2@citrix.com>; Xen-devel <xen-
> devel@lists.xenproject.org>; Anthony Perard <anthony.perard@citrix.com>;
> Ian Jackson <Ian.Jackson@citrix.com>
> Subject: Re: [PATCH v2 2/2] libxendevicemodel: initialise extent to zero
> 
> On Thu, Sep 28, 2017 at 11:40:45AM +0100, Paul Durrant wrote:
> > > -----Original Message-----
> > > From: Wei Liu [mailto:wei.liu2@citrix.com]
> > > Sent: 28 September 2017 11:36
> > > To: Xen-devel <xen-devel@lists.xenproject.org>
> > > Cc: Anthony Perard <anthony.perard@citrix.com>; Wei Liu
> > > <wei.liu2@citrix.com>; Ian Jackson <Ian.Jackson@citrix.com>; Paul
> Durrant
> > > <Paul.Durrant@citrix.com>
> > > Subject: [PATCH v2 2/2] libxendevicemodel: initialise extent to zero
> > >
> > > The pad field needs to be zero as required by the hypervisor.
> > >
> > > Instead of setting the pad separately, use C99 initialiser to clear
> > > extent.
> > >
> > > Signed-off-by: Wei Liu <wei.liu2@citrix.com>
> > > ---
> > > Cc: Ian Jackson <ian.jackson@eu.citrix.com>
> > > Cc: Paul Durrant <paul.durrant@citrix.com>
> > >
> > > Backport to 4.9
> > > ---
> > >  tools/libs/devicemodel/core.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/tools/libs/devicemodel/core.c
> b/tools/libs/devicemodel/core.c
> > > index fcb260d29b..986f147658 100644
> > > --- a/tools/libs/devicemodel/core.c
> > > +++ b/tools/libs/devicemodel/core.c
> > > @@ -483,7 +483,7 @@ int xendevicemodel_modified_memory(
> > >      xendevicemodel_handle *dmod, domid_t domid, uint64_t first_pfn,
> > >      uint32_t nr)
> > >  {
> > > -    struct xen_dm_op_modified_memory_extent extent;
> > > +    struct xen_dm_op_modified_memory_extent extent = { };
> >
> > Not quite. I meant:
> >
> > struct xen_dm_op_modified_memory_extent extent = {
> >     .first_pfn = first_pfn,
> >     .nr = nr,
> > };
> >
> > then you can drop the lines below.
> 
> Here you go.
> 
> ---8<---
> From 75c955c2d2c7077fe59b5e3b14e3deff613025e8 Mon Sep 17 00:00:00
> 2001
> From: Wei Liu <wei.liu2@citrix.com>
> Date: Thu, 28 Sep 2017 11:00:00 +0100
> Subject: [PATCH] libxendevicemodel: initialise extent.pad to zero
> 
> The pad field needs to be zero as required by the hypervisor.
> 
> Instead of setting the pad separately, use C99 initialiser.
> 
> Signed-off-by: Wei Liu <wei.liu2@citrix.com>
> ---
> Cc: Ian Jackson <ian.jackson@eu.citrix.com>
> Cc: Paul Durrant <paul.durrant@citrix.com>
> 
> Backport to 4.9
> ---
>  tools/libs/devicemodel/core.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/tools/libs/devicemodel/core.c b/tools/libs/devicemodel/core.c
> index fcb260d29b..0f2c1a791f 100644
> --- a/tools/libs/devicemodel/core.c
> +++ b/tools/libs/devicemodel/core.c
> @@ -483,10 +483,10 @@ int xendevicemodel_modified_memory(
>      xendevicemodel_handle *dmod, domid_t domid, uint64_t first_pfn,
>      uint32_t nr)
>  {
> -    struct xen_dm_op_modified_memory_extent extent;
> -
> -    extent.first_pfn = first_pfn;
> -    extent.nr = nr;
> +    struct xen_dm_op_modified_memory_extent extent = {
> +        .first_pfn = first_pfn,
> +        .nr = nr,
> +    };

Yep, LGTM.

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

> 
>      return xendevicemodel_modified_memory_bulk(dmod, domid, &extent,
> 1);
>  }
> --
> 2.11.0


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

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2017-09-28 10:48 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-28 10:36 [PATCH v2 0/2] Fix bugs in dmop code Wei Liu
2017-09-28 10:36 ` [PATCH v2 1/2] x86/hvm/dmop: fix EFAULT condition Wei Liu
2017-09-28 10:39   ` Paul Durrant
2017-09-28 10:36 ` [PATCH v2 2/2] libxendevicemodel: initialise extent to zero Wei Liu
2017-09-28 10:40   ` Paul Durrant
2017-09-28 10:46     ` Wei Liu
2017-09-28 10:48       ` Paul Durrant
2017-09-28 10:40 ` [PATCH v2 0/2] Fix bugs in dmop code Andrew Cooper

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).