Skip to contentSkip to conversation

xen: Remove domain_crash_synchronous() completely

PATCH In review Andrew Cooper 4 participants 5 messages Aug 1, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen: Remove domain_crash_synchronous() completely

domain_crash_synchronous() is unsafe to use in general as it may leave spinlocks held, temporary memory allocated, etc.

With domain_crash_synchronous() removed from the ARM code in 4.11, take the opportunity to remove the infrastructure completely by opencoding the softirq loop in the remaining callsites, all of which are destined for deletion.

None of these sites are at risk of having a pending ioreq to qemu, which means that the vcpu_end_shutdown_deferral() isn't necessary.

---
CC: Jan Beulich <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Wei Liu <[email protected]>
CC: Roger Pau Monné <[email protected]>

asm_domain_crash_synchronous() will be removed by my "lift exception frame logic up into C" series, while the waitqueue callers will be removed when the vm_event ring mapping infrastructure is complete.

---
 xen/arch/x86/traps.c    |  5 ++++-
 xen/common/domain.c     | 11 -----------
 xen/common/wait.c       | 13 ++++++++++---
 xen/include/xen/sched.h | 10 ----------
 4 files changed, 14 insertions(+), 25 deletions(-)
xen/arch/x86/traps.c +4 -1
index 789d7ff..ddff346 100644
@@ -2215,7 +2215,10 @@ void asm_domain_crash_synchronous(unsigned long addr)
     printk("domain_crash_sync called from entry.S: fault at %p %pS\n",
            _p(addr), _p(addr));
 
-    __domain_crash_synchronous();
+    __domain_crash(current->domain);
+
+    for ( ; ; )
+        do_softirq();
 }
 
 /*
xen/common/domain.c +0 -11
index 08ca4b1..749722b 100644
@@ -700,17 +700,6 @@ void __domain_crash(struct domain *d)
 }
 
 
-void __domain_crash_synchronous(void)
-{
-    __domain_crash(current->domain);
-
-    vcpu_end_shutdown_deferral(current);
-
-    for ( ; ; )
-        do_softirq();
-}
-
-
 int domain_shutdown(struct domain *d, u8 reason)
 {
     struct vcpu *v;
xen/common/wait.c +10 -3
index a57bc10..4f830a1 100644
@@ -20,6 +20,7 @@
  */
 
 #include <xen/sched.h>
+#include <xen/softirq.h>
 #include <xen/wait.h>
 #include <xen/errno.h>
 
@@ -135,7 +136,10 @@ static void __prepare_to_wait(struct waitqueue_vcpu *wqv)
     if ( vcpu_set_hard_affinity(curr, cpumask_of(wqv->wakeup_cpu)) )
     {
         gdprintk(XENLOG_ERR, "Unable to set vcpu affinity\n");
-        domain_crash_synchronous();
+        domain_crash(current->domain);
+
+        for ( ; ; )
+            do_softirq();
     }
 
     /* Hand-rolled setjmp(). */
@@ -166,7 +170,10 @@ static void __prepare_to_wait(struct waitqueue_vcpu *wqv)
     if ( unlikely(wqv->esp == 0) )
     {
         gdprintk(XENLOG_ERR, "Stack too large in %s\n", __func__);
-        domain_crash_synchronous();
+        domain_crash(current->domain);
+
+        for ( ; ; )
+            do_softirq();
     }
 
     cpu_info->guest_cpu_user_regs.entry_vector = entry_vector;
@@ -196,7 +203,7 @@ void check_wakeup_from_wait(void)
         if ( vcpu_set_hard_affinity(curr, cpumask_of(wqv->wakeup_cpu)) )
         {
             gdprintk(XENLOG_ERR, "Unable to set vcpu affinity\n");
-            domain_crash_synchronous();
+            domain_crash(current->domain);
         }
         wait(); /* takes us back into the scheduler */
     }
xen/include/xen/sched.h +0 -10
index 851f11e..3c35473 100644
@@ -617,16 +617,6 @@ void __domain_crash(struct domain *d);
 } while (0)
 
 /*
- * Mark current domain as crashed and synchronously deschedule from the local
- * processor. This function never returns.
- */
-void noreturn __domain_crash_synchronous(void);
-#define domain_crash_synchronous() do {                                   \
-    printk("domain_crash_sync called from %s:%d\n", __FILE__, __LINE__);  \
-    __domain_crash_synchronous();                                         \
-} while (0)
-
-/*
  * Called from assembly code, with an optional address to help indicate why
  * the crash occured.  If addr is 0, look up address from last extable
  * redirection.
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 01.08.18 at 15:29, <[email protected]> wrote:

domain_crash_synchronous() is unsafe to use in general as it may leave spinlocks held, temporary memory allocated, etc.

Quoted 8 lines

With domain_crash_synchronous() removed from the ARM code in 4.11, take the opportunity to remove the infrastructure completely by opencoding the softirq loop in the remaining callsites, all of which are destined for deletion.

None of these sites are at risk of having a pending ioreq to qemu, which means that the vcpu_end_shutdown_deferral() isn't necessary.

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

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

domain_crash_synchronous() is unsafe to use in general as it may leave spinlocks held, temporary memory allocated, etc.

With domain_crash_synchronous() removed from the ARM code in 4.11, take the opportunity to remove the infrastructure completely by opencoding the softirq loop in the remaining callsites, all of which are destined for deletion.

None of these sites are at risk of having a pending ioreq to qemu, which means that the vcpu_end_shutdown_deferral() isn't necessary.

This however removes the printk with the file an line number from where the domain_crash was called. I don't think it's a big issue because each call site already has a message.

Roger.

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

#3 lore raw
Quoted 11 lines · Roger Pau Monné
Quoted 10 lines · Andrew Cooper

domain_crash_synchronous() is unsafe to use in general as it may leave spinlocks held, temporary memory allocated, etc.

With domain_crash_synchronous() removed from the ARM code in 4.11, take the opportunity to remove the infrastructure completely by opencoding the softirq loop in the remaining callsites, all of which are destined for deletion.

None of these sites are at risk of having a pending ioreq to qemu, which means that the vcpu_end_shutdown_deferral() isn't necessary.

Quoted 6 lines
Quoted 1 line

This however removes the printk with the file an line number from where the domain_crash was called. I don't think it's a big issue because each call site already has a message.

Removing the line number was the basis of this work originally.  It is a problem for livepatching, as it causes excessively large binary deltas.

A followup which I've yet to refresh from its previous posting changes domain_crash() to take a string to force all users to provide an intelligent error, and swaps __LINE__ for __file__

~Andrew

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

#4 lore raw
In reply to Roger Pau Monné
Quoted 25 lines

-----Original Message-----
From: Xen-devel [mailto:[email protected]] On Behalf Of Roger Pau Monné
Sent: 01 August 2018 14:50
To: Andrew Cooper <[email protected]>
Cc: Julien Grall <[email protected]>; Stefano Stabellini <[email protected]>; Wei Liu <[email protected]>; Jan Beulich <[email protected]>; Xen-devel <[email protected]>
Subject: Re: [Xen-devel] [PATCH] xen: Remove domain_crash_synchronous() completely

Quoted 4 lines · Andrew Cooper

domain_crash_synchronous() is unsafe to use in general as it may leave spinlocks held, temporary memory allocated, etc.

With domain_crash_synchronous() removed from the ARM code in 4.11,

take the

Quoted 1 line

opportunity to remove the infrastructure completely by opencoding the

softirq

Quoted 3 lines

loop in the remaining callsites, all of which are destined for deletion.

None of these sites are at risk of having a pending ioreq to qemu, which

means

Quoted 2 lines

that the vcpu_end_shutdown_deferral() isn't necessary.

Quoted 7 lines
Quoted 1 line

This however removes the printk with the file an line number from where the domain_crash was called. I don't think it's a big issue because each call site already has a message.

There are many places which call domain_crash() without any other logging so such crashes will certainly get harder to diagnose.

Paul

Quoted 7 lines

Roger.

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

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