Changeset 14117 for branches


Ignore:
Timestamp:
Aug 5, 2010, 12:41:04 AM (9 years ago)
Author:
gb
Message:

Scheme for stack-overflow recovery (e.g., for re-protecting guard pages
after the stack is unwound past the point of overflow.)

A new TCR field, a new UUO, use of that UUO in nthrow subprims, handler
for the UUO.

Location:
branches/arm/lisp-kernel
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/arm/lisp-kernel/arm-constants.h

    r14018 r14117  
    281281  struct tcr *prev;
    282282  unsigned lisp_fpscr;
    283   unsigned pad;
     283  unsigned stack_overflowed;    /* non-zero when a stack has overflowed */
    284284  special_binding *db_link;     /* special binding chain head */
    285285  LispObj catch_top;            /* top catch frame */
     
    345345#define FPSCR_UFE_BIT 11                    /* underflow enable */
    346346#define FPSCR_IXE_BIT 12                    /* inexact enable */
     347
     348#define STACK_OVERFLOW_CSTACK fixnum_bitmask(0)
     349#define STACK_OVERFLOW_VSTACK fixnum_bitmask(1)
     350#define STACK_RECOVERY_MARGIN (8192)
  • branches/arm/lisp-kernel/arm-constants.s

    r14065 r14117  
    588588         _node(next)            /* in doubly-linked list */
    589589         _node(lisp_fpscr)      /* lisp thread's fpscr (in low word) */
    590          _node(pad)
     590         _node(stack_overflowed) /* Some stack has overflowed ;  maybe fix */
    591591         _node(db_link)         /* special binding chain head */
    592592         _node(catch_top)       /* top catch frame */
  • branches/arm/lisp-kernel/arm-exceptions.c

    r14074 r14117  
    507507signal_stack_soft_overflow(ExceptionInformation *xp, unsigned reg)
    508508{
    509   /* The cstack just overflowed.  Force the current thread's
    510      control stack to do so until all stacks are well under their overflow
    511      limits.
    512   */
    513 
    514 #if 0
    515   lisp_global(CS_OVERFLOW_LIMIT) = CS_OVERFLOW_FORCE_LIMIT; /* force unsigned traps to fail */
    516 #endif
     509 
    517510  handle_error(xp, error_stack_overflow, reg, NULL);
    518511}
     
    928921  protected_area_ptr vsp_soft = a->softprot;
    929922  unprotect_area(vsp_soft);
     923  tcr->stack_overflowed |= STACK_OVERFLOW_VSTACK;
    930924  signal_stack_soft_overflow(xp,vsp);
    931925  return 0;
     
    937931do_soft_stack_overflow(ExceptionInformation *xp, protected_area_ptr prot_area, BytePtr addr)
    938932{
     933  TCR *tcr = get_tcr(true);
     934
    939935  /* Trying to write into a guard page on the vstack or tstack.
    940936     Allocate a new stack segment, emulate stwu and stwux for the TSP, and
     
    945941  }
    946942  unprotect_area(prot_area);
     943  tcr->stack_overflowed |= STACK_OVERFLOW_CSTACK;
    947944  signal_stack_soft_overflow(xp,Rsp);
    948945  return 0;
     
    10451042  opcode *there = (opcode *) where, instr, errnum = 0;
    10461043  return err;
     1044}
     1045
     1046Boolean
     1047try_stack_overflow_recovery(ExceptionInformation *xp, TCR *tcr)
     1048{
     1049  area *a;
     1050  protected_area_ptr soft;
     1051
     1052  if ((tcr->stack_overflowed) & STACK_OVERFLOW_CSTACK) {
     1053    a = tcr->cs_area;
     1054    soft = a->softprot;
     1055    if (((BytePtr)xpGPR(xp,Rsp)-STACK_RECOVERY_MARGIN) >
     1056        (soft->end)) {
     1057      protect_area(soft);
     1058      tcr->stack_overflowed &= ~STACK_OVERFLOW_CSTACK;
     1059    }
     1060  }
     1061
     1062  if ((tcr->stack_overflowed) & STACK_OVERFLOW_VSTACK) {
     1063    a = tcr->vs_area;
     1064    soft = a->softprot;
     1065    if (((BytePtr)xpGPR(xp,vsp)-STACK_RECOVERY_MARGIN) >
     1066        (soft->end)) {
     1067      protect_area(soft);
     1068      tcr->stack_overflowed &= ~STACK_OVERFLOW_VSTACK;
     1069    }
     1070  }
    10471071}
    10481072
     
    11311155      handled = true;
    11321156      break;
     1157    case 6:
     1158      try_stack_overflow_recovery(xp,tcr);
     1159      handled = true;
     1160      break;
    11331161    default:
    11341162      handled = false;
  • branches/arm/lisp-kernel/arm-macros.s

    r14101 r14117  
    498498        ')               
    499499
     500/* Check to see if we've unprotected a stack region in response to an overflow ;
     501   if so, trap into the kernel to see if that region can be protected again. */
     502define(`check_stack_overflow_recovery',`
     503        __(ldr $1,[rcontext,#tcr.stack_overflowed])
     504        __(cmp $1,#0)
     505        __(uuo_stack_overflow_recovery(ne))
     506        ')
     507       
  • branches/arm/lisp-kernel/arm-spentry.s

    r14092 r14117  
    39213921        __(ldr lr,[sp,#catch_frame.size+lisp_frame.savelr])
    39223922        __(add sp,sp,#catch_frame.size+lisp_frame.size)
     3923        __(check_stack_overflow_recovery(imm0))
    39233924        __(bx lr)
    39243925_endfn(C(_throw_found))       
     
    39493950        __(ldreq vsp,[sp,#catch_frame.size+lisp_frame.savevsp])
    39503951        __(add sp,sp,#catch_frame.size+lisp_frame.size)
     3952        __(check_stack_overflow_recovery(arg_y))
    39513953        __(b local_label(_nthrow1v_nextframe))
    39523954local_label(_nthrow1v_do_unwind):
     
    39693971        __(ldr vsp,[temp0,#lisp_frame.savevsp])
    39703972        __(mov fn,nfn)
     3973        __(check_stack_overflow_recovery(arg_y))       
    39713974        __(str imm1,[rcontext,#tcr.unwinding])
    39723975        __(blx lr)
     
    40234026local_label(nthrownv_skip):     
    40244027        __(add sp,sp,#catch_frame.size+lisp_frame.size)
     4028        __(check_stack_overflow_recovery(arg_y))       
    40254029        __(b local_label(nthrownv_nextframe))               
    40264030local_label(nthrownv_do_unwind):
     
    40564060        __(str fn,[arg_z,#lisp_frame.savefn])
    40574061        __(ldr vsp,[arg_z,#lisp_frame.savevsp])
     4062        __(check_stack_overflow_recovery(arg_y))       
    40584063        __(str imm1,[rcontext,#tcr.unwinding])
    40594064        __(mov fn,nfn)
  • branches/arm/lisp-kernel/arm-uuo.s

    r14024 r14117  
    8383define(`uuo_interrupt_now',`nullaryUUO($1,4)')
    8484define(`uuo_suspend_now',`nullaryUUO($1,5)')
    85 
     85define(`uuo_stack_overflow_recovery',`nullaryUUO($1,6)')
     86       
    8687/* Unary UUOs */
    8788define(`uuo_error_unbound',`unary_errorUUO($1,$2,0)')
Note: See TracChangeset for help on using the changeset viewer.