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

Re: [Xen-ia64-devel] [PATCH]Fix infinite loop in fault handler if debugger is not connected



Hi Alex,

Thank you for your comment.

vcpu_increment_iip() takes a pointer of struct vcpu and calculate regs
from vcpu.
If current->arch._thread.on_ustack == 1 then regs == vcpu_regs(current),
otherwise regs is created in the stack. vcpu_regs(current) indicates
guest's registers.
So we cannot use vcpu_increment_iip() in this part.

How about this patch. 

Thanks.
KAZ

Signed-off-by: Kazuhiro Suzuki <kaz@xxxxxxxxxxxxxx>


From: Alex Williamson <alex.williamson@xxxxxx>
Subject: Re: [Xen-ia64-devel] [PATCH]Fix infinite loop in fault handler if 
debugger is not connected
Date: Mon, 28 Jan 2008 08:35:58 -0700

> 
> On Wed, 2008-01-23 at 17:39 +0900, SUZUKI Kazuhiro wrote:
> > Hi all,
> > 
> > If xen is compiled with crash_debug=y and the debugger is not
> > connected, the fault handler enters infinite loop.
> > 
> > The attached patch increments regs->cr_iip.
> 
>    Wouldn't it make more sense to call vcpu_increment_iip() instead of
> creating a debug version that only slightly shortcuts the code?  Thanks,
> 
>       Alex
> 
> -- 
> Alex Williamson                             HP Open Source & Linux Org.
> 
diff -r b79802517a75 xen/arch/ia64/vmx/vmx_fault.c
--- a/xen/arch/ia64/vmx/vmx_fault.c     Tue Jan 22 09:04:41 2008 -0700
+++ b/xen/arch/ia64/vmx/vmx_fault.c     Wed Jan 30 18:06:35 2008 +0900
@@ -181,6 +181,7 @@ vmx_ia64_handle_break (unsigned long ifa
         if (iim == 0)
             show_registers(regs);
         debugger_trap_fatal(0 /* don't care */, regs);
+        regs_increment_iip(regs);
     } else
 #endif
     {
diff -r b79802517a75 xen/arch/ia64/xen/faults.c
--- a/xen/arch/ia64/xen/faults.c        Tue Jan 22 09:04:41 2008 -0700
+++ b/xen/arch/ia64/xen/faults.c        Wed Jan 30 18:06:52 2008 +0900
@@ -515,6 +515,7 @@ ia64_handle_break(unsigned long ifa, str
                if (iim == 0)
                        show_registers(regs);
                debugger_trap_fatal(0 /* don't care */ , regs);
+               regs_increment_iip(regs);
        }
 #endif
        else if (iim == d->arch.breakimm &&
diff -r b79802517a75 xen/arch/ia64/xen/vcpu.c
--- a/xen/arch/ia64/xen/vcpu.c  Tue Jan 22 09:04:41 2008 -0700
+++ b/xen/arch/ia64/xen/vcpu.c  Wed Jan 30 18:04:34 2008 +0900
@@ -804,12 +804,7 @@ IA64FAULT vcpu_increment_iip(VCPU * vcpu
 IA64FAULT vcpu_increment_iip(VCPU * vcpu)
 {
        REGS *regs = vcpu_regs(vcpu);
-       struct ia64_psr *ipsr = (struct ia64_psr *)&regs->cr_ipsr;
-       if (ipsr->ri == 2) {
-               ipsr->ri = 0;
-               regs->cr_iip += 16;
-       } else
-               ipsr->ri++;
+       regs_increment_iip(regs);
        return IA64_NO_FAULT;
 }
 
diff -r b79802517a75 xen/include/asm-ia64/linux-xen/asm/ptrace.h
--- a/xen/include/asm-ia64/linux-xen/asm/ptrace.h       Tue Jan 22 09:04:41 
2008 -0700
+++ b/xen/include/asm-ia64/linux-xen/asm/ptrace.h       Wed Jan 30 18:04:03 
2008 +0900
@@ -281,6 +281,15 @@ struct switch_stack {
 # define guest_mode(regs)              (ia64_psr(regs)->cpl != 0)
 # define guest_kernel_mode(regs)       (ia64_psr(regs)->cpl == 
CONFIG_CPL0_EMUL)
 # define vmx_guest_kernel_mode(regs)   (ia64_psr(regs)->cpl == 0)
+# define regs_increment_iip(regs)                                      \
+do {                                                                   \
+       struct ia64_psr *ipsr = (struct ia64_psr *)&regs->cr_ipsr;      \
+       if (ipsr->ri == 2) {                                            \
+               ipsr->ri = 0;                                           \
+               regs->cr_iip += 16;                                     \
+       } else                                                          \
+               ipsr->ri++;                                             \
+} while        (0)
 #else
 # define user_mode(regs)               (((struct ia64_psr *) 
&(regs)->cr_ipsr)->cpl != 0)
 #endif
_______________________________________________
Xen-ia64-devel mailing list
Xen-ia64-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-ia64-devel

 


Rackspace

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