Skip to contentSkip to conversation

common/multicall: Increase debugability for bad hypercalls

PATCH In review Andrew Cooper 4 participants 4 messages Oct 31, 2017 – Nov 2, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 common/multicall: Increase debugability for bad hypercalls

While investigating an issue (in a new codepath I'd introduced, as it turns out), leaving interrupts disabled manifested as a subsequent op in the multicall failing a check_lock() test.

The codepath would have hit the ASSERT_NOT_IN_ATOMIC on the return-to-guest path, had it not hit the check_lock() first.

Call ASSERT_NOT_IN_ATOMIC() after each operation in the multicall, to make failures more obvious.

---
CC: George Dunlap <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Konrad Rzeszutek Wilk <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Tim Deegan <[email protected]>
CC: Wei Liu <[email protected]>
CC: Julien Grall <[email protected]>

As with the related check_lock() patch, this only affects debug builds, so is a very low risk change for 4.10

---
 xen/common/multicall.c | 7 +++++++
 1 file changed, 7 insertions(+)
xen/common/multicall.c +7 -0
index c7af4e0..d98e59d 100644
@@ -66,6 +66,13 @@ do_multicall(
 
         disp = arch_do_multicall_call(mcs);
 
+        /*
+         * In the unlikley event that a hypercall has left interrupts,
+         * spinlocks, or other things in a bad way, continuting the multicall
+         * will typically lead to far more subtle issues to debug.
+         */
+        ASSERT_NOT_IN_ATOMIC();
+
 #ifndef NDEBUG
         {
             /*
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Andrew Cooper

While investigating an issue (in a new codepath I'd introduced, as it turns out), leaving interrupts disabled manifested as a subsequent op in the multicall failing a check_lock() test.

The codepath would have hit the ASSERT_NOT_IN_ATOMIC on the return-to-guest path, had it not hit the check_lock() first.

Call ASSERT_NOT_IN_ATOMIC() after each operation in the multicall, to make failures more obvious.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

Reviewed-by on v1 1/1
#2 lore raw
In reply to Andrew Cooper
Quoted 11 lines · Andrew Cooper

While investigating an issue (in a new codepath I'd introduced, as it turns out), leaving interrupts disabled manifested as a subsequent op in the multicall failing a check_lock() test.

The codepath would have hit the ASSERT_NOT_IN_ATOMIC on the return-to-guest path, had it not hit the check_lock() first.

Call ASSERT_NOT_IN_ATOMIC() after each operation in the multicall, to make failures more obvious.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#3 lore raw
In reply to Andrew Cooper

Hi Andrew,

Quoted 20 lines · Andrew Cooper

While investigating an issue (in a new codepath I'd introduced, as it turns out), leaving interrupts disabled manifested as a subsequent op in the multicall failing a check_lock() test.

The codepath would have hit the ASSERT_NOT_IN_ATOMIC on the return-to-guest path, had it not hit the check_lock() first.

Call ASSERT_NOT_IN_ATOMIC() after each operation in the multicall, to make failures more obvious.

---
CC: George Dunlap <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Konrad Rzeszutek Wilk <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Tim Deegan <[email protected]>
CC: Wei Liu <[email protected]>
CC: Julien Grall <[email protected]>

Quoted 2 lines

As with the related check_lock() patch, this only affects debug builds, so is a very low risk change for 4.10

With a couple of typos below.

Quoted 9 lines
---
  xen/common/multicall.c | 7 +++++++
  1 file changed, 7 insertions(+)
xen/common/multicall.c +0 -0
index c7af4e0..d98e59d 100644

xen/common/multicall.c do_multicall( · line 70

Quoted 5 lines
xen/common/multicall.c +2 -0
@@ -66,6 +66,13 @@ do_multicall(
 
          disp = arch_do_multicall_call(mcs);
 
+        /*
+         * In the unlikley event that a hypercall has left interrupts,

s/unlikley/unlikely/

xen/common/multicall.c do_multicall( · line 71

Quoted 1 line
xen/common/multicall.c +1 -0
+         * spinlocks, or other things in a bad way, continuting the multicall

s/continuting/continuing/

xen/common/multicall.c do_multicall( · line 78

Quoted 8 lines
xen/common/multicall.c +4 -0
+         * will typically lead to far more subtle issues to debug.
+         */
+        ASSERT_NOT_IN_ATOMIC();
+
  #ifndef NDEBUG
          {
              /*

Cheers,

Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel