[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen master] xen: Modify domain_crash() to take a print string



commit d7aaecd3e172eb30c79eba7049efd3c44ba4f213
Author:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
AuthorDate: Thu Jan 20 15:45:02 2022 +0000
Commit:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CommitDate: Fri Mar 24 12:16:31 2023 +0000

    xen: Modify domain_crash() to take a print string
    
    There are two problems with domain_crash().
    
    First, that it is frequently not preceded by a printk() at all, or only by a
    dprintk().  Either way, critical diagnostic information is missing for an
    event which is fatal to the guest.
    
    Second, the embedded __LINE__ is an issue for livepatching, creating 
unwanted
    churn in the binary diff.  This is the final __LINE__ remaining in
    livepatching-relevant contexts.
    
    The end goal is to have domain_crash() require a print string which gets fed
    to printk(), making it far less easy to omit relevant diagnostic 
information.
    
    However, modifying all callers at once is far too big and complicated, so 
use
    some macro magic to tolerate the old API (no print string) in the short 
term.
    
    Adjust two callers in load_segments() to demonstrate the new API.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
    Reviewed-by: Julien Grall <jgrall@xxxxxxxxxx>
    Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
---
 xen/arch/x86/domain.c   | 14 ++++----------
 xen/include/xen/sched.h | 13 +++++++++----
 2 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
index 6b2e32d244..d5847f70f8 100644
--- a/xen/arch/x86/domain.c
+++ b/xen/arch/x86/domain.c
@@ -1704,11 +1704,8 @@ static void load_segments(struct vcpu *n)
                  put_guest(uregs->fs,   esp - 5) |
                  put_guest(uregs->es,   esp - 6) |
                  put_guest(uregs->ds,   esp - 7) )
-            {
-                gprintk(XENLOG_ERR,
-                        "error while creating compat failsafe callback 
frame\n");
-                domain_crash(n->domain);
-            }
+                domain_crash(n->domain,
+                             "Error creating compat failsafe callback 
frame\n");
 
             if ( n->arch.pv.vgc_flags & VGCF_failsafe_disables_events )
                 vcpu_info(n, evtchn_upcall_mask) = 1;
@@ -1743,11 +1740,8 @@ static void load_segments(struct vcpu *n)
              put_guest(uregs->ds,   rsp -  9) |
              put_guest(regs->r11,   rsp - 10) |
              put_guest(regs->rcx,   rsp - 11) )
-        {
-            gprintk(XENLOG_ERR,
-                    "error while creating failsafe callback frame\n");
-            domain_crash(n->domain);
-        }
+            domain_crash(n->domain,
+                         "Error creating failsafe callback frame\n");
 
         if ( n->arch.pv.vgc_flags & VGCF_failsafe_disables_events )
             vcpu_info(n, evtchn_upcall_mask) = 1;
diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h
index 12be794002..85242a73d3 100644
--- a/xen/include/xen/sched.h
+++ b/xen/include/xen/sched.h
@@ -766,10 +766,15 @@ void vcpu_end_shutdown_deferral(struct vcpu *v);
  * from any processor.
  */
 void __domain_crash(struct domain *d);
-#define domain_crash(d) do {                                              \
-    printk("domain_crash called from %s:%d\n", __FILE__, __LINE__);       \
-    __domain_crash(d);                                                    \
-} while (0)
+#define domain_crash(d, ...)                                        \
+    do {                                                            \
+        if ( count_args(__VA_ARGS__) == 0 )                         \
+            printk(XENLOG_ERR "domain_crash called from %s:%d\n",   \
+                   __FILE__, __LINE__);                             \
+        else                                                        \
+            printk(XENLOG_ERR __VA_ARGS__);                         \
+        __domain_crash(d);                                          \
+    } while ( 0 )
 
 /*
  * Called from assembly code, with an optional address to help indicate why
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.