Improvements for domain_crash_synchronous
cover Improvements for domain_crash_synchronous
This patch series is RFC because the second patch would benifit greatly from following Jan's patch introducing UNLIKELY_DONE(), my GLOBAL() patch, backed onto that series, and a further improvement to unconditionally provide a label to the entry of an UNLIKELY section.
If there are no strong objections to the change in the meantime, I do intend to rebase this series when the other patches are committed.
~Andrew
Signature · 1 line
1.7.10.4
PATCH 1/2 x86/traps: Record last extable faulting address
... so the following patch can identify the location of faults leading to a decision to crash a domain.
--- xen/arch/x86/traps.c | 5 +++++ 1 file changed, 5 insertions(+)
xen/arch/x86/traps.c +5 -0
@@ -89,6 +89,7 @@ static char __read_mostly opt_nmi[10] = "fatal";string_param ("nmi" , opt_nmi);DEFINE_PER_CPU (u64, efer); +static DEFINE_PER_CPU(unsigned long, last_extable_addr);DEFINE_PER_CPU_READ_MOSTLY (u32, ler_msr);
@@ -550,6 +551,7 @@ static inline void do_trap( {dprintk (XENLOG_ERR ,"Trap %d: %p -> %p\n" , trapnr,_p (regs->eip),_p (fixup)); +this_cpu (last_extable_addr) = regs->eip; regs->eip = fixup;return ; }
@@ -1038,6 +1040,7 @@ void do_invalid_op(struct cpu_user_regs *regs) die:if ( (fixup =search_exception_table (regs->eip)) !=0 ) { +this_cpu (last_extable_addr) = regs->eip; regs->eip = fixup;return ; }
@@ -1370,6 +1373,7 @@ void do_page_fault(struct cpu_user_regs *regs)perfc_incr (copy_user_faults);if (unlikely (regs->error_code & PFEC_reserved_bit) )reserved_bit_page_fault (addr, regs); +this_cpu (last_extable_addr) = regs->eip; regs->eip = fixup;return ; }
@@ -3062,6 +3066,7 @@ void do_general_protection(struct cpu_user_regs *regs) {dprintk (XENLOG_INFO ,"GPF (%04x): %p -> %p\n" , regs->error_code,_p (regs->eip),_p (fixup)); +this_cpu (last_extable_addr) = regs->eip; regs->eip = fixup;return ; }
Signature · 1 line
1.7.10.4
PATCH 2/2 Xen/x86: Improve information from domain_crash_synchronous
In reply to Andrew CooperAs it currently stands, the string "domain_crash_sync called from entry.S" is not helpful at identifying why the domain was crashed, and a debug build of Xen doesn't help the matter
This patch improves the information printed, by pointing to where the crash decision was made.
Specific improvements include:
* Moving the ascii string "domain_crash_sync called from entry.S\n" away from some semi-hot code cache lines.
* Moving the printk into C code (especially as this_cpu() is miserable to use in assembly code)
* Undo the previous confusing situation of having the domain_crash_synchronous() as a macro in C code, yet a global symbol in assembly code.
---
There were 4 jmps to the old domain_crash_synchronous which have been replaced by unlikely sections, due to now providing an address in %rdi. None of them appear to need the recovery back to a sensible stack which is possibly required through an extable redirection.
--- xen/arch/x86/traps.c | 12 ++++++++ xen/arch/x86/x86_64/compat/entry.S | 16 ++++++++--- xen/arch/x86/x86_64/entry.S | 53 ++++++++++++++++++++---------------- xen/include/xen/sched.h | 7 +++++ 4 files changed, 60 insertions(+), 28 deletions(-)
xen/arch/x86/traps.c +12 -0
@@ -3748,6 +3748,18 @@ unsigned long do_get_debugreg(int reg)return -EINVAL ; } +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\n" +" fault at %p" ,_p (addr)); +print_symbol (" %s\n" , addr); + +__domain_crash_synchronous (); +} +/* * Local variables: * mode: C
xen/arch/x86/x86_64/compat/entry.S +12 -4
@@ -263,6 +263,7 @@ ENTRY(compat_int80_direct_trap) /* {[ERRCODE,] EIP, CS, EFLAGS, [ESP, SS]} */ /* %rdx: trap_bounce, %rbx: struct vcpu */ /* On return only %rbx and %rdx are guaranteed non-clobbered. */ +.globl compat_create_bounce_frame compat_create_bounce_frame: ASSERT_INTERRUPTS_ENABLED mov %fs,%edi
@@ -329,7 +330,12 @@ UNLIKELY_END(compat_bounce_failsafe) movzwl TRAPBOUNCE_cs(%rdx),%eax /* Null selectors (0-3) are not allowed. */ testl $~3,%eax - jz domain_crash_synchronous +.Lcompat_bounce_null_selector: +UNLIKELY_START(z, compat_bounce_null_selector) + lea .Lcompat_bounce_null_selector(%rip), %rdi + jmp asm_domain_crash_synchronous + ud2a +UNLIKELY_END(compat_bounce_null_selector) movl %eax,UREGS_cs+8(%rsp) movl TRAPBOUNCE_eip(%rdx),%eax movl %eax,UREGS_rip+8(%rsp)
@@ -339,10 +345,10 @@ UNLIKELY_END(compat_bounce_failsafe) xorl %edi,%edi jmp .Lft13 .previous - _ASM_EXTABLE(.Lft1, domain_crash_synchronous) + _ASM_EXTABLE(.Lft1, dom_crash_sync_extable) _ASM_EXTABLE(.Lft2, compat_crash_page_fault) _ASM_EXTABLE(.Lft3, compat_crash_page_fault_4) - _ASM_EXTABLE(.Lft4, domain_crash_synchronous) + _ASM_EXTABLE(.Lft4, dom_crash_sync_extable) _ASM_EXTABLE(.Lft5, compat_crash_page_fault_4) _ASM_EXTABLE(.Lft6, compat_crash_page_fault_8) _ASM_EXTABLE(.Lft7, compat_crash_page_fault)
@@ -363,7 +369,9 @@ compat_crash_page_fault: .Lft14: mov %edi,%fs movl %esi,%edi call show_page_walk - jmp domain_crash_synchronous + xorl %edi,%edi + jmp asm_domain_crash_synchronous + ud2a .section .fixup,"ax" .Lfx14: xorl %edi,%edi
xen/arch/x86/x86_64/entry.S +29 -24
79 lines not on this page · raw message
xen/include/xen/sched.h +7 -0
@@ -541,6 +541,13 @@ void __domain_crash_synchronous(void) __attribute__((noreturn));__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. +*/ +void asm_domain_crash_synchronous(unsigned long addr) __attribute__((noreturn)); +#define set_current_state (_s) do { current->state = (_s); } while (0)void scheduler_init (void );int sched_init_vcpu (struct vcpu *v,unsigned int processor);
Signature · 1 line
1.7.10.4
Re: [PATCH 2/2] Xen/x86: Improve information from domain_crash_synchronous
Quoted 7 lines
Quoted 1 line
Quoted 1 line · Andrew Cooper
As it currently stands, the string "
domain_crash_synccalled fromentry.S" is not helpful at identifying why the domain was crashed, and a debug build of Xen doesn't help the matterThis patch improves the information printed, by pointing to where the crash decision was made.
Looks quite useful.
xen/arch/x86/x86_64/compat/entry.S ENTRY(compat_int80_direct_trap) · line 267
Quoted 8 lines
xen/arch/x86/x86_64/compat/entry.S +1
-0@@ -263,6 +263,7 @@ ENTRY(compat_int80_direct_trap) /* {[ERRCODE,] EIP, CS, EFLAGS, [ESP, SS]} */ /* %rdx: trap_bounce, %rbx: struct vcpu */ /* On return only %rbx and %rdx are guaranteed non-clobbered. */ +.globl compat_create_bounce_frame compat_create_bounce_frame:
Is the addition above a left-over? I don't see any use of the label outside of this file.
xen/arch/x86/x86_64/compat/entry.S UNLIKELY_END(compat_bounce_failsafe) · line 338
Quoted 11 lines
xen/arch/x86/x86_64/compat/entry.S +6
-1@@ -329,7 +330,12 @@ UNLIKELY_END(compat_bounce_failsafe) movzwl TRAPBOUNCE_cs(%rdx),%eax /* Null selectors (0-3) are not allowed. */ testl $~3,%eax - jz domain_crash_synchronous +.Lcompat_bounce_null_selector: +UNLIKELY_START(z, compat_bounce_null_selector) + lea .Lcompat_bounce_null_selector(%rip), %rdi + jmp asm_domain_crash_synchronous + ud2a +UNLIKELY_END(compat_bounce_null_selector)
Here and further down you don't really need the label at the start of the unlikely section - the place can as well be identified by using
lea (%rip), %rdi
inside that section (the place is still unique, just outside the original code stream, i.e. just slightly more difficult to re-associate).
Jan
Re: [PATCH 2/2] Xen/x86: Improve information from domain_crash_synchronous
Quoted 9 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · Andrew Cooper
As it currently stands, the string "
domain_crash_synccalled fromentry.S" is not helpful at identifying why the domain was crashed, and a debug build of Xen doesn't help the matterThis patch improves the information printed, by pointing to where the crash decision was made.
Looks quite useful.
Quoted 10 lines
xen/arch/x86/x86_64/compat/entry.S ENTRY(compat_int80_direct_trap) · line 267
Quoted 8 lines
xen/arch/x86/x86_64/compat/entry.S +1
-0@@ -263,6 +263,7 @@ ENTRY(compat_int80_direct_trap) /* {[ERRCODE,] EIP, CS, EFLAGS, [ESP, SS]} */ /* %rdx: trap_bounce, %rbx: struct vcpu */ /* On return only %rbx and %rdx are guaranteed non-clobbered. */ +.globl compat_create_bounce_frame compat_create_bounce_frame:Is the addition above a left-over? I don't see any use of the label outside of this file.
This is for the benifit of print_symbol(), which will now give create_bounce_frame()+some rather than trap_nop()+loads.
Quoted 16 lines
xen/arch/x86/x86_64/compat/entry.S UNLIKELY_END(compat_bounce_failsafe) · line 338
Quoted 12 lines
xen/arch/x86/x86_64/compat/entry.S +6
-1@@ -329,7 +330,12 @@ UNLIKELY_END(compat_bounce_failsafe) movzwl TRAPBOUNCE_cs(%rdx),%eax /* Null selectors (0-3) are not allowed. */ testl $~3,%eax - jz domain_crash_synchronous +.Lcompat_bounce_null_selector: +UNLIKELY_START(z, compat_bounce_null_selector) + lea .Lcompat_bounce_null_selector(%rip), %rdi + jmp asm_domain_crash_synchronous + ud2a +UNLIKELY_END(compat_bounce_null_selector)Here and further down you don't really need the label at the start of the unlikely section - the place can as well be identified by using
Quoted 8 lines
lea (%rip), %rdiinside that section (the place is still unique, just outside the original code stream, i.e. just slightly more difficult to re-associate).
Jan
But in an unlikely section, %rip is shifted quite a lot from %rip of the code immediately before. This is also for the benefit of print_symbol() which will pick up the {compat_,}create_bounce_frame rather than the global symbol surrounding the unlikely section.
~Andrew
Re: [PATCH 2/2] Xen/x86: Improve information from domain_crash_synchronous
Quoted 23 lines
Quoted 1 line
Quoted 1 line · Andrew Cooper
Quoted 2 lines · Jan Beulich
Quoted 2 lines
Quoted 1 line
Quoted 1 line · Andrew Cooper
As it currently stands, the string "
domain_crash_synccalled fromentry.S"is
Quoted 7 lines
Quoted 5 lines
not helpful at identifying why the domain was crashed, and a debug build of Xen doesn't help the matter
This patch improves the information printed, by pointing to where the crash decision was made.
Looks quite useful.
Quoted 10 lines
xen/arch/x86/x86_64/compat/entry.S ENTRY(compat_int80_direct_trap) · line 267
Quoted 8 lines
xen/arch/x86/x86_64/compat/entry.S +1
-0@@ -263,6 +263,7 @@ ENTRY(compat_int80_direct_trap) /* {[ERRCODE,] EIP, CS, EFLAGS, [ESP, SS]} */ /* %rdx: trap_bounce, %rbx: struct vcpu */ /* On return only %rbx and %rdx are guaranteed non-clobbered. */ +.globl compat_create_bounce_frame compat_create_bounce_frame:Is the addition above a left-over? I don't see any use of the label outside of this file.
Quoted 2 lines
This is for the benifit of
print_symbol(), which will now give create_bounce_frame()+some rather than trap_nop()+loads.
That shouldn't be happening - whether a symbol is local or global should not matter to symbol table generation and consumption. The matter would be different is the label started with .L...
Quoted 17 lines
Quoted 17 lines
xen/arch/x86/x86_64/compat/entry.S UNLIKELY_END(compat_bounce_failsafe) · line 338
Quoted 11 lines
xen/arch/x86/x86_64/compat/entry.S +6
-1@@ -329,7 +330,12 @@ UNLIKELY_END(compat_bounce_failsafe) movzwl TRAPBOUNCE_cs(%rdx),%eax /* Null selectors (0-3) are not allowed. */ testl $~3,%eax - jz domain_crash_synchronous +.Lcompat_bounce_null_selector: +UNLIKELY_START(z, compat_bounce_null_selector) + lea .Lcompat_bounce_null_selector(%rip), %rdi + jmp asm_domain_crash_synchronous + ud2a +UNLIKELY_END(compat_bounce_null_selector)Here and further down you don't really need the label at the start of the unlikely section - the place can as well be identified by using
lea (%rip), %rdi
Quoted 8 lines
Quoted 3 lines
inside that section (the place is still unique, just outside the original code stream, i.e. just slightly more difficult to re-associate).
But in an unlikely section, %rip is shifted quite a lot from %rip of the code immediately before. This is also for the benefit of
print_symbol()which will pick up the {compat_,}create_bounce_frame rather than the global symbol surrounding the unlikely section.
I understand that, but stray labels are at clear risk of getting deleted by a subsequent cleanup patch anyway. Hence either we need a solution without stray labels, or live with the need to re-associate the address pointed to be the crash log messages to the original function.
Jan
Re: [PATCH 2/2] Xen/x86: Improve information from domain_crash_synchronous
Quoted 22 lines · Jan Beulich
Quoted 22 lines
Quoted 1 line
Quoted 1 line · Andrew Cooper
Quoted 2 lines · Jan Beulich
Quoted 2 lines
Quoted 1 line
Quoted 1 line · Andrew Cooper
As it currently stands, the string "
domain_crash_synccalled fromentry.S"is
Quoted 17 lines
Quoted 5 lines
not helpful at identifying why the domain was crashed, and a debug build of Xen doesn't help the matter
This patch improves the information printed, by pointing to where the crash decision was made.
Looks quite useful.
xen/arch/x86/x86_64/compat/entry.S ENTRY(compat_int80_direct_trap) · line 267
Quoted 8 lines
xen/arch/x86/x86_64/compat/entry.S +1
-0@@ -263,6 +263,7 @@ ENTRY(compat_int80_direct_trap) /* {[ERRCODE,] EIP, CS, EFLAGS, [ESP, SS]} */ /* %rdx: trap_bounce, %rbx: struct vcpu */ /* On return only %rbx and %rdx are guaranteed non-clobbered. */ +.globl compat_create_bounce_frame compat_create_bounce_frame:Is the addition above a left-over? I don't see any use of the label outside of this file.
Quoted 5 lines
Quoted 2 lines
This is for the benifit of
print_symbol(), which will now give create_bounce_frame()+some rather than trap_nop()+loads.That shouldn't be happening - whether a symbol is local or global should not matter to symbol table generation and consumption. The matter would be different is the label started with .L...
Hmm - this was caught by my testing. I had initially assumed that print_symbol() would DTRT, but it didn't. Perhaps it is been fed off the global symbol table rather than the debug symbol table.
Quoted 25 lines
Quoted 18 lines
Quoted 18 lines
xen/arch/x86/x86_64/compat/entry.S UNLIKELY_END(compat_bounce_failsafe) · line 338
Quoted 12 lines
xen/arch/x86/x86_64/compat/entry.S +6
-1@@ -329,7 +330,12 @@ UNLIKELY_END(compat_bounce_failsafe) movzwl TRAPBOUNCE_cs(%rdx),%eax /* Null selectors (0-3) are not allowed. */ testl $~3,%eax - jz domain_crash_synchronous +.Lcompat_bounce_null_selector: +UNLIKELY_START(z, compat_bounce_null_selector) + lea .Lcompat_bounce_null_selector(%rip), %rdi + jmp asm_domain_crash_synchronous + ud2a +UNLIKELY_END(compat_bounce_null_selector)Here and further down you don't really need the label at the start of the unlikely section - the place can as well be identified by using
lea (%rip), %rdiQuoted 7 lines
Quoted 3 lines
inside that section (the place is still unique, just outside the original code stream, i.e. just slightly more difficult to re-associate).
But in an unlikely section, %rip is shifted quite a lot from %rip of the code immediately before. This is also for the benefit of
print_symbol()which will pick up the {compat_,}create_bounce_frame rather than the global symbol surrounding the unlikely section.
Quoted 8 lines
I understand that, but stray labels are at clear risk of getting deleted by a subsequent cleanup patch anyway. Hence either we need a solution without stray labels, or live with the need to re-associate the address pointed to be the crash log messages to the original function.
Jan
That was eluded to in my patch 0 (perhaps not well enough), where I intend to augment UNLIKELY_START() to automatically generate this symbol, and provide an __UNLIKLEY_ENTRY_SYM() accessor. The code for that was rather tangled with your UNLIKELY_DONE() patch, which is why I left it and was going to fix up after your series is committed.
Re: [PATCH 2/2] Xen/x86: Improve information from domain_crash_synchronous
Quoted 17 lines
Quoted 1 line
Quoted 1 line · Andrew Cooper
Quoted 15 lines · Jan Beulich
Quoted 15 lines
Quoted 1 line
Quoted 1 line · Andrew Cooper
Quoted 11 lines · Jan Beulich
xen/arch/x86/x86_64/compat/entry.S ENTRY(compat_int80_direct_trap) · line 267
Quoted 9 lines
Quoted 1 line
Quoted 1 line · Andrew Cooper
xen/arch/x86/x86_64/compat/entry.S +1
-0@@ -263,6 +263,7 @@ ENTRY(compat_int80_direct_trap) /* {[ERRCODE,] EIP, CS, EFLAGS, [ESP, SS]} */ /* %rdx: trap_bounce, %rbx: struct vcpu */ /* On return only %rbx and %rdx are guaranteed non-clobbered. */ +.globl compat_create_bounce_frame compat_create_bounce_frame:Is the addition above a left-over? I don't see any use of the label outside of this file.
This is for the benifit of
print_symbol(), which will now give create_bounce_frame()+some rather than trap_nop()+loads.
Quoted 7 lines
Quoted 3 lines
That shouldn't be happening - whether a symbol is local or global should not matter to symbol table generation and consumption. The matter would be different is the label started with .L...
Hmm - this was caught by my testing. I had initially assumed that
print_symbol()would DTRT, but it didn't. Perhaps it is been fed off the global symbol table rather than the debug symbol table.
The debug symbol table never gets used, but local symbols should always end up in the normal ELF symbol table. I just checked - they do here.
Quoted 30 lines
Quoted 24 lines
Quoted 17 lines
Quoted 17 lines
xen/arch/x86/x86_64/compat/entry.S UNLIKELY_END(compat_bounce_failsafe) · line 338
Quoted 11 lines
xen/arch/x86/x86_64/compat/entry.S +6
-1@@ -329,7 +330,12 @@ UNLIKELY_END(compat_bounce_failsafe) movzwl TRAPBOUNCE_cs(%rdx),%eax /* Null selectors (0-3) are not allowed. */ testl $~3,%eax - jz domain_crash_synchronous +.Lcompat_bounce_null_selector: +UNLIKELY_START(z, compat_bounce_null_selector) + lea .Lcompat_bounce_null_selector(%rip), %rdi + jmp asm_domain_crash_synchronous + ud2a +UNLIKELY_END(compat_bounce_null_selector)Here and further down you don't really need the label at the start of the unlikely section - the place can as well be identified by using
lea (%rip), %rdiQuoted 7 lines
Quoted 3 lines
inside that section (the place is still unique, just outside the original code stream, i.e. just slightly more difficult to re-associate).
But in an unlikely section, %rip is shifted quite a lot from %rip of the code immediately before. This is also for the benefit of
print_symbol()which will pick up the {compat_,}create_bounce_frame rather than the global symbol surrounding the unlikely section.Quoted 5 lines
I understand that, but stray labels are at clear risk of getting deleted by a subsequent cleanup patch anyway. Hence either we need a solution without stray labels, or live with the need to re-associate the address pointed to be the crash log messages to the original function.
Quoted 5 lines
That was eluded to in my patch 0 (perhaps not well enough), where I intend to augment
UNLIKELY_START()to automatically generate this symbol, and provide an__UNLIKLEY_ENTRY_SYM()accessor. The code for that was rather tangled with yourUNLIKELY_DONE()patch, which is why I left it and was going to fix up after your series is committed.
I did realize those intentions, but whether an orphan label gets added here or in the macro doesn't matter - the label remains orphaned, and hence would be a likely subject to janitorial work.
Jan
Re: [PATCH 2/2] Xen/x86: Improve information from domain_crash_synchronous
Quoted 9 lines · Jan Beulich
Quoted 6 lines
Quoted 3 lines
That shouldn't be happening - whether a symbol is local or global should not matter to symbol table generation and consumption. The matter would be different is the label started with .L...
Hmm - this was caught by my testing. I had initially assumed that
print_symbol()would DTRT, but it didn't. Perhaps it is been fed off the global symbol table rather than the debug symbol table.The debug symbol table never gets used, but local symbols should always end up in the normal ELF symbol table. I just checked - they do here.
So they are. I have just double checked my debugging, and I was getting mixed up with the issue from below, which would leave these .globl as failed debugging. I shall remove them.
Quoted 35 lines
Quoted 30 lines
Quoted 25 lines
Quoted 18 lines
Quoted 18 lines
xen/arch/x86/x86_64/compat/entry.S UNLIKELY_END(compat_bounce_failsafe) · line 338
Quoted 12 lines
xen/arch/x86/x86_64/compat/entry.S +6
-1@@ -329,7 +330,12 @@ UNLIKELY_END(compat_bounce_failsafe) movzwl TRAPBOUNCE_cs(%rdx),%eax /* Null selectors (0-3) are not allowed. */ testl $~3,%eax - jz domain_crash_synchronous +.Lcompat_bounce_null_selector: +UNLIKELY_START(z, compat_bounce_null_selector) + lea .Lcompat_bounce_null_selector(%rip), %rdi + jmp asm_domain_crash_synchronous + ud2a +UNLIKELY_END(compat_bounce_null_selector)Here and further down you don't really need the label at the start of the unlikely section - the place can as well be identified by using
lea (%rip), %rdiQuoted 7 lines
Quoted 3 lines
inside that section (the place is still unique, just outside the original code stream, i.e. just slightly more difficult to re-associate).
But in an unlikely section, %rip is shifted quite a lot from %rip of the code immediately before. This is also for the benefit of
print_symbol()which will pick up the {compat_,}create_bounce_frame rather than the global symbol surrounding the unlikely section.Quoted 5 lines
I understand that, but stray labels are at clear risk of getting deleted by a subsequent cleanup patch anyway. Hence either we need a solution without stray labels, or live with the need to re-associate the address pointed to be the crash log messages to the original function.
Quoted 5 lines
That was eluded to in my patch 0 (perhaps not well enough), where I intend to augment
UNLIKELY_START()to automatically generate this symbol, and provide an__UNLIKLEY_ENTRY_SYM()accessor. The code for that was rather tangled with yourUNLIKELY_DONE()patch, which is why I left it and was going to fix up after your series is committed.
Quoted 6 lines
I did realize those intentions, but whether an orphan label gets added here or in the macro doesn't matter - the label remains orphaned, and hence would be a likely subject to janitorial work.
Jan
But any janitorial work which removes the proposed new label from UNLIKELY_START() will cause a subsequent assemble error when __UNLIKELY_ENTRY_SYM() references a non-existant label.
~Andrew