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

I discovered two issues while trying to figure out what went wrong with
Windows.

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         | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

-- 
2.11.0


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

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

* [PATCH 1/2] x86/hvm/dmop: fix EFAULT condition
  2017-09-28 10:24 [PATCH 0/2] Fix bugs in dmop code Wei Liu
@ 2017-09-28 10:24 ` Wei Liu
  2017-09-28 10:28   ` Paul Durrant
  2017-09-28 10:24 ` [PATCH 2/2] libxendevicemodel: initialise extent to zero Wei Liu
  1 sibling, 1 reply; 5+ messages in thread
From: Wei Liu @ 2017-09-28 10:24 UTC (permalink / raw)
  To: Xen-devel; +Cc: 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 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/arch/x86/hvm/dm.c b/xen/arch/x86/hvm/dm.c
index 87ef4b6ca9..b1cf0d54a2 100644
--- a/xen/arch/x86/hvm/dm.c
+++ b/xen/arch/x86/hvm/dm.c
@@ -182,7 +182,7 @@ static int modified_memory(struct domain *d,
 
         rc = COPY_FROM_GUEST_BUF_OFFSET(extent,
             bufs, EXTENTS_BUFFER, (*rem_extents - 1) * sizeof(extent));
-        if ( rc )
+        if ( !rc )
             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] 5+ messages in thread

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

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

Instead of setting the pad separately, memset extent to zero.

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, 2 insertions(+)

diff --git a/tools/libs/devicemodel/core.c b/tools/libs/devicemodel/core.c
index fcb260d29b..af06936262 100644
--- a/tools/libs/devicemodel/core.c
+++ b/tools/libs/devicemodel/core.c
@@ -485,6 +485,8 @@ int xendevicemodel_modified_memory(
 {
     struct xen_dm_op_modified_memory_extent extent;
 
+    memset(&extent, 0, sizeof(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] 5+ messages in thread

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

> -----Original Message-----
> From: Wei Liu [mailto:wei.liu2@citrix.com]
> Sent: 28 September 2017 11:24
> To: Xen-devel <xen-devel@lists.xenproject.org>
> Cc: 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 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>
> ---
> 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 | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/xen/arch/x86/hvm/dm.c b/xen/arch/x86/hvm/dm.c
> index 87ef4b6ca9..b1cf0d54a2 100644
> --- a/xen/arch/x86/hvm/dm.c
> +++ b/xen/arch/x86/hvm/dm.c
> @@ -182,7 +182,7 @@ static int modified_memory(struct domain *d,
> 
>          rc = COPY_FROM_GUEST_BUF_OFFSET(extent,
>              bufs, EXTENTS_BUFFER, (*rem_extents - 1) * sizeof(extent));
> -        if ( rc )
> +        if ( !rc )
>              return -EFAULT;

For clarity and consistency I think it would be better to avoid use of rc in this case and simply put the call to COPY_FROM_GUEST_BUF_OFFSET() inside the if clause.

  Paul

> 
>          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] 5+ messages in thread

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

> -----Original Message-----
> From: Wei Liu [mailto:wei.liu2@citrix.com]
> Sent: 28 September 2017 11:24
> To: Xen-devel <xen-devel@lists.xenproject.org>
> Cc: Wei Liu <wei.liu2@citrix.com>; Ian Jackson <Ian.Jackson@citrix.com>;
> Paul Durrant <Paul.Durrant@citrix.com>
> Subject: [PATCH 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, memset extent to zero.
> 
> 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, 2 insertions(+)
> 
> diff --git a/tools/libs/devicemodel/core.c b/tools/libs/devicemodel/core.c
> index fcb260d29b..af06936262 100644
> --- a/tools/libs/devicemodel/core.c
> +++ b/tools/libs/devicemodel/core.c
> @@ -485,6 +485,8 @@ int xendevicemodel_modified_memory(
>  {
>      struct xen_dm_op_modified_memory_extent extent;
> 
> +    memset(&extent, 0, sizeof(extent));
> +

Probably better to just use a C99 initializer instead so the compiler deals with the pad.

  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] 5+ messages in thread

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

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

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