|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 2/2] Xen/x86: Improve information from domain_crash_synchronous
As 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.
Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CC: Keir Fraser <keir@xxxxxxx>
CC: Jan Beulich <JBeulich@xxxxxxxx>
---
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(-)
diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c
index 50fb6ba..225dda9 100644
--- a/xen/arch/x86/traps.c
+++ b/xen/arch/x86/traps.c
@@ -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
diff --git a/xen/arch/x86/x86_64/compat/entry.S
b/xen/arch/x86/x86_64/compat/entry.S
index c0afe2c..2a6f1cf 100644
--- a/xen/arch/x86/x86_64/compat/entry.S
+++ b/xen/arch/x86/x86_64/compat/entry.S
@@ -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
diff --git a/xen/arch/x86/x86_64/entry.S b/xen/arch/x86/x86_64/entry.S
index 5beeccb..fdd2d3c 100644
--- a/xen/arch/x86/x86_64/entry.S
+++ b/xen/arch/x86/x86_64/entry.S
@@ -350,6 +350,7 @@ int80_slow_path:
/* { RCX, R11, [DS-GS,] [CR2,] [ERRCODE,] RIP, CS, RFLAGS, RSP, SS } */
/* %rdx: trap_bounce, %rbx: struct vcpu */
/* On return only %rbx and %rdx are guaranteed non-clobbered. */
+.globl create_bounce_frame
create_bounce_frame:
ASSERT_INTERRUPTS_ENABLED
testb $TF_kernel_mode,VCPU_thread_flags(%rbx)
@@ -371,7 +372,12 @@ create_bounce_frame:
sbb %ecx,%ecx # In +ve address space? Then okay.
cmpq %rax,%rsi
adc %ecx,%ecx # Above Xen private area? Then okay.
- jg domain_crash_synchronous
+.Lbad_sp:
+UNLIKELY_START(g, create_bounce_frame_bad_sp)
+ lea .Lbad_sp(%rip), %rdi
+ jmp asm_domain_crash_synchronous
+ ud2a
+UNLIKELY_END(create_bounce_frame_bad_sp)
movb TRAPBOUNCE_flags(%rdx),%cl
subq $40,%rsi
movq UREGS_ss+8(%rsp),%rax
@@ -430,26 +436,28 @@ UNLIKELY_END(bounce_failsafe)
movq $FLAT_KERNEL_CS,UREGS_cs+8(%rsp)
movq TRAPBOUNCE_eip(%rdx),%rax
testq %rax,%rax
- jz domain_crash_synchronous
+.Lbad_ip:
+UNLIKELY_START(z, create_bounce_frame_bad_ip)
+ lea .Lbad_ip(%rip), %rdi
+ jmp asm_domain_crash_synchronous
+ ud2a
+UNLIKELY_END(create_bounce_frame_bad_ip)
movq %rax,UREGS_rip+8(%rsp)
ret
- _ASM_EXTABLE(.Lft2, domain_crash_synchronous)
- _ASM_EXTABLE(.Lft3, domain_crash_synchronous)
- _ASM_EXTABLE(.Lft4, domain_crash_synchronous)
- _ASM_EXTABLE(.Lft5, domain_crash_synchronous)
- _ASM_EXTABLE(.Lft6, domain_crash_synchronous)
- _ASM_EXTABLE(.Lft7, domain_crash_synchronous)
- _ASM_EXTABLE(.Lft8, domain_crash_synchronous)
- _ASM_EXTABLE(.Lft9, domain_crash_synchronous)
- _ASM_EXTABLE(.Lft10, domain_crash_synchronous)
- _ASM_EXTABLE(.Lft11, domain_crash_synchronous)
- _ASM_EXTABLE(.Lft12, domain_crash_synchronous)
- _ASM_EXTABLE(.Lft13, domain_crash_synchronous)
-
-domain_crash_synchronous_string:
- .asciz "domain_crash_sync called from entry.S\n"
-
-ENTRY(domain_crash_synchronous)
+ _ASM_EXTABLE(.Lft2, dom_crash_sync_extable)
+ _ASM_EXTABLE(.Lft3, dom_crash_sync_extable)
+ _ASM_EXTABLE(.Lft4, dom_crash_sync_extable)
+ _ASM_EXTABLE(.Lft5, dom_crash_sync_extable)
+ _ASM_EXTABLE(.Lft6, dom_crash_sync_extable)
+ _ASM_EXTABLE(.Lft7, dom_crash_sync_extable)
+ _ASM_EXTABLE(.Lft8, dom_crash_sync_extable)
+ _ASM_EXTABLE(.Lft9, dom_crash_sync_extable)
+ _ASM_EXTABLE(.Lft10, dom_crash_sync_extable)
+ _ASM_EXTABLE(.Lft11, dom_crash_sync_extable)
+ _ASM_EXTABLE(.Lft12, dom_crash_sync_extable)
+ _ASM_EXTABLE(.Lft13, dom_crash_sync_extable)
+
+ENTRY(dom_crash_sync_extable)
# Get out of the guest-save area of the stack.
GET_STACK_BASE(%rax)
leaq STACK_CPUINFO_FIELD(guest_cpu_user_regs)(%rax),%rsp
@@ -460,11 +468,8 @@ ENTRY(domain_crash_synchronous)
setz %al
leal (%rax,%rax,2),%eax
orb %al,UREGS_cs(%rsp)
- # printk(domain_crash_synchronous_string)
- leaq domain_crash_synchronous_string(%rip),%rdi
- xorl %eax,%eax
- call printk
- jmp __domain_crash_synchronous
+ xorl %edi,%edi
+ jmp asm_domain_crash_synchronous
/* No special register assumptions. */
ENTRY(ret_from_intr)
diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h
index ae6a3b8..8e66d6b 100644
--- a/xen/include/xen/sched.h
+++ b/xen/include/xen/sched.h
@@ -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);
--
1.7.10.4
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |