xen: Improvements to domain_crash_sync()
RFC PATCH 1/1 xen: Improvements to domain_crash_sync()
The use of __LINE__ in a printk() is problematic for livepatching, as it causes unnecessary binary differences.
Furthermore, diagnostic information around calls is inconsistent and occasionally unhelpful. (e.g. diagnosing logs from the field which might be release builds, or likely without exact source code).
Take the opportunity to improve things. Shorten the name to domain_crash_sync() and require the user to pass a print message in.
Internally, the current vcpu and calling function are identified, and the message is emitted as a non-debug guest error.
---
CC: Jan Beulich <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
This is RFC for now as it only does the x86 side of things.
If it is considered generally acceptable, I'll do the ARM side of things, and a similar patch for domain_crash()
--- xen/arch/x86/hvm/vmx/vmcs.c | 2 +- xen/arch/x86/traps.c | 5 +---- xen/common/domain.c | 2 +- xen/common/wait.c | 16 ++++------------ xen/include/xen/sched.h | 11 ++++++----- 5 files changed, 13 insertions(+), 23 deletions(-)
xen/arch/x86/hvm/vmx/vmcs.c +1 -1
@@ -1669,7 +1669,7 @@ void vmx_vmentry_failure(void) error == VMX_INSN_INVALID_HOST_STATE )vmcs_dump_vcpu (curr); -domain_crash_synchronous (); +domain_crash_sync ("\n" );/* Info available from earlier gprintk(). */ }void vmx_do_resume (struct vcpu *v)
xen/arch/x86/traps.c +1 -4
@@ -2083,10 +2083,7 @@ void asm_domain_crash_synchronous(unsigned long addr)if ( addr ==0 ) addr =this_cpu (last_extable_addr); -printk ("domain_crash_sync called from entry.S: fault at %p %pS\n" , -_p (addr),_p (addr)); - -__domain_crash_synchronous (); +domain_crash_sync ("entry.S fault at %p %pS\n" ,_p (addr),_p (addr)); }/*
xen/common/domain.c +1 -1
@@ -686,7 +686,7 @@ void __domain_crash(struct domain *d) } -void __domain_crash_synchronous (void ) +void __domain_crash_sync (void ) {__domain_crash (current->domain);
xen/common/wait.c +4 -12
@@ -133,10 +133,7 @@ static void __prepare_to_wait(struct waitqueue_vcpu *wqv) wqv->wakeup_cpu =smp_processor_id ();cpumask_copy (&wqv->saved_affinity, curr->cpu_hard_affinity);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_sync ("Unable to set vcpu affinity\n" );/* Hand-rolled setjmp(). */ asm volatile (
@@ -164,10 +161,7 @@ static void __prepare_to_wait(struct waitqueue_vcpu *wqv) : "memory" );if (unlikely (wqv->esp ==0 ) ) - { -gdprintk (XENLOG_ERR ,"Stack too large in %s\n" , __func__); -domain_crash_synchronous (); - } +domain_crash_sync ("Stack too large\n" ); cpu_info->guest_cpu_user_regs.entry_vector = entry_vector; }
@@ -194,10 +188,8 @@ void check_wakeup_from_wait(void)struct vcpu *curr = current;cpumask_copy (&wqv->saved_affinity, curr->cpu_hard_affinity);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_sync ("Unable to set vcpu affinity\n" ); +wait ();/* takes us back into the scheduler */ }
xen/include/xen/sched.h +6 -5
@@ -627,11 +627,12 @@ void __domain_crash(struct domain *d);* 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) +void noreturn__domain_crash_sync (void ); +#define domain_crash_sync (fmt, ...) do { \ + printk(XENLOG_G_ERR "domain_crash_sync(%pv) from %s: " fmt, \ + current, __func__, ## __VA_ARGS__); \ + __domain_crash_sync(); \ + } while (0)/* * Called from assembly code, with an optional address to help indicate why
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 20 lines
Quoted 1 line
Quoted 1 line · On 24.01.18 at 16:49, <[email protected]> wrote:
The use of
__LINE__in aprintk()is problematic for livepatching, as it causes unnecessary binary differences.Furthermore, diagnostic information around calls is inconsistent and occasionally unhelpful. (e.g. diagnosing logs from the field which might be release builds, or likely without exact source code).
Take the opportunity to improve things. Shorten the name to
domain_crash_sync()and require the user to pass a print message in.Internally, the current vcpu and calling function are identified, and the message is emitted as a non-debug guest error.
Signed-off-by Andrew Cooper <[email protected]>---
CC: Jan Beulich <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
Quoted 4 lines
This is RFC for now as it only does the x86 side of things.
If it is considered generally acceptable, I'll do the ARM side of things, and a similar patch for
domain_crash()
I'm fine with this, just two remarks:
xen/arch/x86/traps.c void asm_domain_crash_synchronous(unsigned long addr) · line 2086
Quoted 11 lines
xen/arch/x86/traps.c +1
-4@@ -2083,10 +2083,7 @@ void asm_domain_crash_synchronous(unsigned long addr)if ( addr ==0 ) addr =this_cpu (last_extable_addr); -printk ("domain_crash_sync called from entry.S: fault at %p %pS\n" , -_p (addr),_p (addr)); - -__domain_crash_synchronous (); +domain_crash_sync ("entry.S fault at %p %pS\n" ,_p (addr),_p (addr));
Could we try to aim for some consistency here going forward? Either make %pS always _also_ print the raw number, or (if that's undesirable in some use cases) re-arrange the above to achieve the same effect, which I's in particular like to be the deciphered value first, and the raw one in e.g. square brackets (like iirc Linux does):
domain_crash_sync("entry.S fault at %pS [%p]\n", _p(addr), _p(addr));Quoted 5 lines
xen/include/xen/sched.h +0
-0@@ -627,11 +627,12 @@ void __domain_crash(struct domain *d);* Mark current domain as crashed and synchronously deschedule from the local * processor. This function never returns.
xen/include/xen/sched.h void __domain_crash(struct domain *d); · line 633
Quoted 10 lines
xen/include/xen/sched.h +4
-5*/ -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) +void noreturn__domain_crash_sync (void ); +#define domain_crash_sync (fmt, ...) do { \ + printk(XENLOG_G_ERR "domain_crash_sync(%pv) from %s: " fmt, \ + current, __func__, ## __VA_ARGS__); \
This isn't C standard mandated usage of __VA_ARGS__; I generally think it is better to use the older GCC extension when the number of actuals may validly be zero (which the C standard doesn't allow).
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 44 lines · Jan Beulich
Quoted 20 lines
Quoted 1 line
Quoted 1 line · On 24.01.18 at 16:49, <[email protected]> wrote:
The use of
__LINE__in aprintk()is problematic for livepatching, as it causes unnecessary binary differences.Furthermore, diagnostic information around calls is inconsistent and occasionally unhelpful. (e.g. diagnosing logs from the field which might be release builds, or likely without exact source code).
Take the opportunity to improve things. Shorten the name to
domain_crash_sync()and require the user to pass a print message in.Internally, the current vcpu and calling function are identified, and the message is emitted as a non-debug guest error.
Signed-off-by Andrew Cooper <[email protected]>---
CC: Jan Beulich <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>Quoted 4 lines
This is RFC for now as it only does the x86 side of things.
If it is considered generally acceptable, I'll do the ARM side of things, and a similar patch for
domain_crash()I'm fine with this, just two remarks:
xen/arch/x86/traps.c void asm_domain_crash_synchronous(unsigned long addr) · line 2086
Quoted 11 lines
xen/arch/x86/traps.c +1
-4@@ -2083,10 +2083,7 @@ void asm_domain_crash_synchronous(unsigned long addr)if ( addr ==0 ) addr =this_cpu (last_extable_addr); -printk ("domain_crash_sync called from entry.S: fault at %p %pS\n" , -_p (addr),_p (addr)); - -__domain_crash_synchronous (); +domain_crash_sync ("entry.S fault at %p %pS\n" ,_p (addr),_p (addr));Could we try to aim for some consistency here going forward? Either make %pS always _also_ print the raw number, or (if that's undesirable in some use cases) re-arrange the above to achieve the same effect, which I's in particular like to be the deciphered value first, and the raw one in e.g. square brackets (like iirc Linux does):
Quoted 1 line
domain_crash_sync("entry.S fault at %pS [%p]\n", _p(addr), _p(addr));Can do (although the reason I didn't shorten this function name is because it isn't long for the world, once I dust off my create_bounce_frame in C series).
Quoted 11 lines
Quoted 11 lines
xen/include/xen/sched.h +0
-4@@ -627,11 +627,12 @@ void __domain_crash(struct domain *d);* 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(); \
Quoted 8 lines
xen/include/xen/sched.h void __domain_crash(struct domain *d); · line 633
Quoted 5 lines
xen/include/xen/sched.h +4
-1-}while (0 ) +void noreturn__domain_crash_sync (void ); +#define domain_crash_sync (fmt, ...) do { \ + printk(XENLOG_G_ERR "domain_crash_sync(%pv) from %s: " fmt, \ + current, __func__, ## __VA_ARGS__); \This isn't C standard mandated usage of
__VA_ARGS__; I generally think it is better to use the older GCC extension when the number of actuals may validly be zero (which the C standard doesn't allow).
Do you mean go with the (fmt, args...) version ?
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 68 lines · Andrew Cooper
Quoted 44 lines · Jan Beulich
Quoted 20 lines
Quoted 1 line
Quoted 1 line · On 24.01.18 at 16:49, <[email protected]> wrote:
The use of
__LINE__in aprintk()is problematic for livepatching, as it causes unnecessary binary differences.Furthermore, diagnostic information around calls is inconsistent and occasionally unhelpful. (e.g. diagnosing logs from the field which might be release builds, or likely without exact source code).
Take the opportunity to improve things. Shorten the name to
domain_crash_sync()and require the user to pass a print message in.Internally, the current vcpu and calling function are identified, and the message is emitted as a non-debug guest error.
Signed-off-by Andrew Cooper <[email protected]>---
CC: Jan Beulich <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>Quoted 4 lines
This is RFC for now as it only does the x86 side of things.
If it is considered generally acceptable, I'll do the ARM side of things, and a similar patch for
domain_crash()I'm fine with this, just two remarks:
xen/arch/x86/traps.c void asm_domain_crash_synchronous(unsigned long addr) · line 2086
Quoted 11 lines
xen/arch/x86/traps.c +1
-4@@ -2083,10 +2083,7 @@ void asm_domain_crash_synchronous(unsigned long addr)if ( addr ==0 ) addr =this_cpu (last_extable_addr); -printk ("domain_crash_sync called from entry.S: fault at %p %pS\n" , -_p (addr),_p (addr)); - -__domain_crash_synchronous (); +domain_crash_sync ("entry.S fault at %p %pS\n" ,_p (addr),_p (addr));Could we try to aim for some consistency here going forward? Either make %pS always _also_ print the raw number, or (if that's undesirable in some use cases) re-arrange the above to achieve the same effect, which I's in particular like to be the deciphered value first, and the raw one in e.g. square brackets (like iirc Linux does):
Quoted 1 line
domain_crash_sync("entry.S fault at %pS [%p]\n", _p(addr), _p(addr));Can do (although the reason I didn't shorten this function name is because it isn't long for the world, once I dust off my
create_bounce_framein C series).Quoted 10 lines
Quoted 10 lines
xen/include/xen/sched.h +0
-4@@ -627,11 +627,12 @@ void __domain_crash(struct domain *d);* 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(); \Quoted 8 lines
xen/include/xen/sched.h void __domain_crash(struct domain *d); · line 633
Quoted 5 lines
xen/include/xen/sched.h +4
-1-}while (0 ) +void noreturn__domain_crash_sync (void ); +#define domain_crash_sync (fmt, ...) do { \ + printk(XENLOG_G_ERR "domain_crash_sync(%pv) from %s: " fmt, \ + current, __func__, ## __VA_ARGS__); \This isn't C standard mandated usage of
__VA_ARGS__; I generally think it is better to use the older GCC extension when the number of actuals may validly be zero (which the C standard doesn't allow).
Quoted 1 line
Do you mean go with the (fmt, args...) version ?
I don't see any other GNU extensions which work here. Unless you can point out exactly which one you mean, I'll stay with the ## __VA_ARGS__ version, because that is consistent with other examples in our codebase.
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 22 lines
Quoted 1 line
Quoted 1 line · On 24.01.18 at 17:31, <[email protected]> wrote:
Quoted 20 lines · Andrew Cooper
Quoted 19 lines · Jan Beulich
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 24.01.18 at 16:49, <[email protected]> wrote:
xen/include/xen/sched.h +0
-0@@ -627,11 +627,12 @@ void __domain_crash(struct domain *d);* Mark current domain as crashed and synchronously deschedule from the local * processor. This function never returns. xen/include/xen/sched.h void __domain_crash(struct domain *d); · line 633
Quoted 10 lines
xen/include/xen/sched.h +4
-5*/ -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) +void noreturn__domain_crash_sync (void ); +#define domain_crash_sync (fmt, ...) do { \ + printk(XENLOG_G_ERR "domain_crash_sync(%pv) from %s: " fmt, \ + current, __func__, ## __VA_ARGS__); \This isn't C standard mandated usage of
__VA_ARGS__; I generally think it is better to use the older GCC extension when the number of actuals may validly be zero (which the C standard doesn't allow).
Quoted 5 lines
Quoted 1 line
Do you mean go with the (fmt, args...) version ?
I don't see any other GNU extensions which work here. Unless you can point out exactly which one you mean, I'll stay with the ##
__VA_ARGS__version, because that is consistent with other examples in our codebase.
Isn't gprintk() a good enough example we have in our code base?
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 22 lines · Jan Beulich
Quoted 22 lines
Quoted 1 line
Quoted 1 line · On 24.01.18 at 17:31, <[email protected]> wrote:
Quoted 20 lines · Andrew Cooper
Quoted 19 lines · Jan Beulich
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 24.01.18 at 16:49, <[email protected]> wrote:
xen/include/xen/sched.h +0
-0@@ -627,11 +627,12 @@ void __domain_crash(struct domain *d);* Mark current domain as crashed and synchronously deschedule from the local * processor. This function never returns. xen/include/xen/sched.h void __domain_crash(struct domain *d); · line 633
Quoted 10 lines
xen/include/xen/sched.h +4
-5*/ -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) +void noreturn__domain_crash_sync (void ); +#define domain_crash_sync (fmt, ...) do { \ + printk(XENLOG_G_ERR "domain_crash_sync(%pv) from %s: " fmt, \ + current, __func__, ## __VA_ARGS__); \This isn't C standard mandated usage of
__VA_ARGS__; I generally think it is better to use the older GCC extension when the number of actuals may validly be zero (which the C standard doesn't allow).
Quoted 5 lines
Quoted 4 lines
Quoted 1 line
Do you mean go with the (fmt, args...) version ?
I don't see any other GNU extensions which work here. Unless you can point out exactly which one you mean, I'll stay with the ##
__VA_ARGS__version, because that is consistent with other examples in our codebase.Isn't
gprintk()a good enough example we have in our code base?
I'm clearly going blind. Sorry for the noise.
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 47 lines
Quoted 1 line
Quoted 1 line · On 24.01.18 at 17:15, <[email protected]> wrote:
Quoted 20 lines · Jan Beulich
Quoted 20 lines
Quoted 1 line
Quoted 1 line · On 24.01.18 at 16:49, <[email protected]> wrote:
The use of
__LINE__in aprintk()is problematic for livepatching, as it causes unnecessary binary differences.Furthermore, diagnostic information around calls is inconsistent and occasionally unhelpful. (e.g. diagnosing logs from the field which might be release builds, or likely without exact source code).
Take the opportunity to improve things. Shorten the name to
domain_crash_sync()and require the user to pass a print message in.Internally, the current vcpu and calling function are identified, and the message is emitted as a non-debug guest error.
Signed-off-by Andrew Cooper <[email protected]>---
CC: Jan Beulich <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>Quoted 3 lines
Quoted 3 lines
This is RFC for now as it only does the x86 side of things.
If it is considered generally acceptable, I'll do the ARM side of things,
and
Quoted 21 lines
Quoted 1 line
a similar patch for
domain_crash()I'm fine with this, just two remarks:
xen/arch/x86/traps.c void asm_domain_crash_synchronous(unsigned long addr) · line 2086
Quoted 11 lines
xen/arch/x86/traps.c +1
-4@@ -2083,10 +2083,7 @@ void asm_domain_crash_synchronous(unsigned long addr)if ( addr ==0 ) addr =this_cpu (last_extable_addr); -printk ("domain_crash_sync called from entry.S: fault at %p %pS\n" , -_p (addr),_p (addr)); - -__domain_crash_synchronous (); +domain_crash_sync ("entry.S fault at %p %pS\n" ,_p (addr),_p (addr));Could we try to aim for some consistency here going forward? Either make %pS always _also_ print the raw number, or (if that's undesirable in some use cases) re-arrange the above to achieve the same effect, which I's in particular like to be the deciphered value first, and the raw one in e.g. square brackets (like iirc Linux does):
Quoted 5 lines
Quoted 1 line
domain_crash_sync("entry.S fault at %pS [%p]\n", _p(addr), _p(addr));Can do (although the reason I didn't shorten this function name is because it isn't long for the world, once I dust off my
create_bounce_framein C series).
"I didn't shorten this function name"? I'm confused - you did shorten it from is original __domain_crash_synchronous().
Quoted 19 lines
Quoted 10 lines
Quoted 10 lines
xen/include/xen/sched.h +0
-4@@ -627,11 +627,12 @@ void __domain_crash(struct domain *d);* 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(); \Quoted 8 lines
xen/include/xen/sched.h void __domain_crash(struct domain *d); · line 633
Quoted 5 lines
xen/include/xen/sched.h +4
-1-}while (0 ) +void noreturn__domain_crash_sync (void ); +#define domain_crash_sync (fmt, ...) do { \ + printk(XENLOG_G_ERR "domain_crash_sync(%pv) from %s: " fmt, \ + current, __func__, ## __VA_ARGS__); \This isn't C standard mandated usage of
__VA_ARGS__; I generally think it is better to use the older GCC extension when the number of actuals may validly be zero (which the C standard doesn't allow).
Quoted 1 line
Do you mean go with the (fmt, args...) version ?
Yes.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 7 lines · Andrew Cooper
The use of
__LINE__in aprintk()is problematic for livepatching, as it causes unnecessary binary differences.Furthermore, diagnostic information around calls is inconsistent and occasionally unhelpful. (e.g. diagnosing logs from the field which might be release builds, or likely without exact source code).
Quoted 7 lines
Take the opportunity to improve things. Shorten the name to
domain_crash_sync()and require the user to pass a print message in.Internally, the current vcpu and calling function are identified, and the message is emitted as a non-debug guest error.
Signed-off-by Andrew Cooper <[email protected]>
I think I saw this at some point, from Ross like a year ago?
Anyhow: Reviewed-by: Konrad Rzeszutek Wilk <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel