ia64/xen-unstable

changeset 16947:33d0cf9474f9

[IA64] Fix infinite loop in fault handler if debugger is not connected

If xen is compiled with crash_debug=y and the debugger is not
connected, the fault handler enters infinite loop. regs may
be on stack, so split the incrementing out of vcpu_increment_iip().

Signed-off-by: Kazuhiro Suzuki <kaz@jp.fujitsu.com>
author Alex Williamson <alex.williamson@hp.com>
date Wed Jan 30 11:13:29 2008 -0700 (2008-01-30)
parents 13eb21985d3d
children 0695363214c3
files xen/arch/ia64/vmx/vmx_fault.c xen/arch/ia64/xen/faults.c xen/arch/ia64/xen/vcpu.c xen/include/asm-ia64/linux-xen/asm/ptrace.h
line diff
     1.1 --- a/xen/arch/ia64/vmx/vmx_fault.c	Wed Jan 30 10:50:24 2008 -0700
     1.2 +++ b/xen/arch/ia64/vmx/vmx_fault.c	Wed Jan 30 11:13:29 2008 -0700
     1.3 @@ -181,6 +181,7 @@ vmx_ia64_handle_break (unsigned long ifa
     1.4          if (iim == 0)
     1.5              show_registers(regs);
     1.6          debugger_trap_fatal(0 /* don't care */, regs);
     1.7 +        regs_increment_iip(regs);
     1.8      } else
     1.9  #endif
    1.10      {
     2.1 --- a/xen/arch/ia64/xen/faults.c	Wed Jan 30 10:50:24 2008 -0700
     2.2 +++ b/xen/arch/ia64/xen/faults.c	Wed Jan 30 11:13:29 2008 -0700
     2.3 @@ -515,6 +515,7 @@ ia64_handle_break(unsigned long ifa, str
     2.4  		if (iim == 0)
     2.5  			show_registers(regs);
     2.6  		debugger_trap_fatal(0 /* don't care */ , regs);
     2.7 +		regs_increment_iip(regs);
     2.8  	}
     2.9  #endif
    2.10  	else if (iim == d->arch.breakimm &&
     3.1 --- a/xen/arch/ia64/xen/vcpu.c	Wed Jan 30 10:50:24 2008 -0700
     3.2 +++ b/xen/arch/ia64/xen/vcpu.c	Wed Jan 30 11:13:29 2008 -0700
     3.3 @@ -804,12 +804,7 @@ IA64FAULT vcpu_set_iip(VCPU * vcpu, u64 
     3.4  IA64FAULT vcpu_increment_iip(VCPU * vcpu)
     3.5  {
     3.6  	REGS *regs = vcpu_regs(vcpu);
     3.7 -	struct ia64_psr *ipsr = (struct ia64_psr *)&regs->cr_ipsr;
     3.8 -	if (ipsr->ri == 2) {
     3.9 -		ipsr->ri = 0;
    3.10 -		regs->cr_iip += 16;
    3.11 -	} else
    3.12 -		ipsr->ri++;
    3.13 +	regs_increment_iip(regs);
    3.14  	return IA64_NO_FAULT;
    3.15  }
    3.16  
     4.1 --- a/xen/include/asm-ia64/linux-xen/asm/ptrace.h	Wed Jan 30 10:50:24 2008 -0700
     4.2 +++ b/xen/include/asm-ia64/linux-xen/asm/ptrace.h	Wed Jan 30 11:13:29 2008 -0700
     4.3 @@ -281,6 +281,15 @@ struct switch_stack {
     4.4  # define guest_mode(regs)		(ia64_psr(regs)->cpl != 0)
     4.5  # define guest_kernel_mode(regs)	(ia64_psr(regs)->cpl == CONFIG_CPL0_EMUL)
     4.6  # define vmx_guest_kernel_mode(regs)	(ia64_psr(regs)->cpl == 0)
     4.7 +# define regs_increment_iip(regs)					\
     4.8 +do {									\
     4.9 +	struct ia64_psr *ipsr = ia64_psr(regs);				\
    4.10 +	if (ipsr->ri == 2) {						\
    4.11 +		ipsr->ri = 0;						\
    4.12 +		regs->cr_iip += 16;					\
    4.13 +	} else								\
    4.14 +		ipsr->ri++;						\
    4.15 +} while (0)
    4.16  #else
    4.17  # define user_mode(regs)		(((struct ia64_psr *) &(regs)->cr_ipsr)->cpl != 0)
    4.18  #endif