All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86: fix return value checks of set_guest_{machinecheck, nmi}_trapbounce
@ 2018-05-02  9:02 Jan Beulich
  2018-05-02  9:37 ` Andrew Cooper
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Beulich @ 2018-05-02  9:02 UTC (permalink / raw)
  To: xen-devel; +Cc: Juergen Gross, Andrew Cooper

Commit 0142064421 ("x86/traps: move set_guest_{machine,nmi}_trapbounce")
converted the functions' return types from int to bool without also
correcting the checks in assembly code: The ABI does not guarantee sub-
32-bit return values to be promoted to 32 bits.

Take the liberty and also adjust the number of spaces used in the compat
code, such that both code sequences end up similar (they already are in
the non-compat case).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
This wants backporting to 4.10.

--- a/xen/arch/x86/x86_64/compat/entry.S
+++ b/xen/arch/x86/x86_64/compat/entry.S
@@ -74,9 +74,9 @@ compat_process_mce:
         testb $1 << VCPU_TRAP_MCE,VCPU_async_exception_mask(%rbx)
         jnz   .Lcompat_test_guest_nmi
         sti
-        movb $0,VCPU_mce_pending(%rbx)
-        call set_guest_machinecheck_trapbounce
-        testl %eax,%eax
+        movb  $0, VCPU_mce_pending(%rbx)
+        call  set_guest_machinecheck_trapbounce
+        test  %al, %al
         jz    compat_test_all_events
         movzbl VCPU_async_exception_mask(%rbx),%edx # save mask for the
         movb %dl,VCPU_mce_old_mask(%rbx)            # iret hypercall
@@ -88,11 +88,11 @@ compat_process_mce:
 /* %rbx: struct vcpu */
 compat_process_nmi:
         testb $1 << VCPU_TRAP_NMI,VCPU_async_exception_mask(%rbx)
-        jnz  compat_test_guest_events
+        jnz   compat_test_guest_events
         sti
-        movb  $0,VCPU_nmi_pending(%rbx)
+        movb  $0, VCPU_nmi_pending(%rbx)
         call  set_guest_nmi_trapbounce
-        testl %eax,%eax
+        test  %al, %al
         jz    compat_test_all_events
         movzbl VCPU_async_exception_mask(%rbx),%edx # save mask for the
         movb %dl,VCPU_nmi_old_mask(%rbx)            # iret hypercall
--- a/xen/arch/x86/x86_64/entry.S
+++ b/xen/arch/x86/x86_64/entry.S
@@ -77,7 +77,7 @@ process_mce:
         sti
         movb $0, VCPU_mce_pending(%rbx)
         call set_guest_machinecheck_trapbounce
-        test %eax, %eax
+        test %al, %al
         jz   test_all_events
         movzbl VCPU_async_exception_mask(%rbx), %edx # save mask for the
         movb %dl, VCPU_mce_old_mask(%rbx)            # iret hypercall
@@ -93,7 +93,7 @@ process_nmi:
         sti
         movb $0, VCPU_nmi_pending(%rbx)
         call set_guest_nmi_trapbounce
-        test %eax, %eax
+        test %al, %al
         jz   test_all_events
         movzbl VCPU_async_exception_mask(%rbx), %edx # save mask for the
         movb %dl, VCPU_nmi_old_mask(%rbx)            # iret hypercall




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

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

* Re: [PATCH] x86: fix return value checks of set_guest_{machinecheck, nmi}_trapbounce
  2018-05-02  9:02 [PATCH] x86: fix return value checks of set_guest_{machinecheck, nmi}_trapbounce Jan Beulich
@ 2018-05-02  9:37 ` Andrew Cooper
  0 siblings, 0 replies; 3+ messages in thread
From: Andrew Cooper @ 2018-05-02  9:37 UTC (permalink / raw)
  To: Jan Beulich, xen-devel; +Cc: Juergen Gross

On 02/05/18 10:02, Jan Beulich wrote:
> Commit 0142064421 ("x86/traps: move set_guest_{machine,nmi}_trapbounce")
> converted the functions' return types from int to bool without also
> correcting the checks in assembly code: The ABI does not guarantee sub-
> 32-bit return values to be promoted to 32 bits.
>
> Take the liberty and also adjust the number of spaces used in the compat
> code, such that both code sequences end up similar (they already are in
> the non-compat case).
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

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

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

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

* Re: [PATCH] x86: fix return value checks of set_guest_{machinecheck, nmi}_trapbounce
       [not found] <5AE97E9C02000078001C00D5@suse.com>
@ 2018-05-02 10:25 ` Juergen Gross
  0 siblings, 0 replies; 3+ messages in thread
From: Juergen Gross @ 2018-05-02 10:25 UTC (permalink / raw)
  To: Jan Beulich, xen-devel; +Cc: Andrew Cooper

On 02/05/18 11:02, Jan Beulich wrote:
> Commit 0142064421 ("x86/traps: move set_guest_{machine,nmi}_trapbounce")
> converted the functions' return types from int to bool without also
> correcting the checks in assembly code: The ABI does not guarantee sub-
> 32-bit return values to be promoted to 32 bits.
> 
> Take the liberty and also adjust the number of spaces used in the compat
> code, such that both code sequences end up similar (they already are in
> the non-compat case).
> 
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Release-acked-by: Juergen Gross <jgross@suse.com>


Juergen

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

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

end of thread, other threads:[~2018-05-02 10:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-02  9:02 [PATCH] x86: fix return value checks of set_guest_{machinecheck, nmi}_trapbounce Jan Beulich
2018-05-02  9:37 ` Andrew Cooper
     [not found] <5AE97E9C02000078001C00D5@suse.com>
2018-05-02 10:25 ` Juergen Gross

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.