Changeset 9978


Ignore:
Timestamp:
Jul 10, 2008, 9:46:09 AM (11 years ago)
Author:
gb
Message:

Trunk changes: new traps for thread ops, handle writes to readonly
area by unprotecting the page.
Use traditional register names on Darwin.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/working-0711/ccl/lisp-kernel/ppc-exceptions.c

    r7668 r9978  
    442442        /*        nrs_GC_EVENT_STATUS_BITS.vcell |= gc_integrity_check_bit; */
    443443        gc_from_xp(xp, 0L);
     444        release_readonly_area();
    444445      }
    445446      if (selector & GC_TRAP_FUNCTION_PURIFY) {
     
    691692{
    692693  TCR *tcr = TCR_FROM_TSD(xpGPR(xp, rcontext)), *other_tcr;
    693   ExceptionInformation* other_xp;
    694694  int result;
    695695  signed_natural inhibit;
     
    806806   do_hard_stack_overflow,   
    807807   do_hard_stack_overflow,
    808    do_hard_stack_overflow,
     808   do_hard_stack_overflow
    809809   };
    810810
     
    905905      handler = protection_handlers[area->why];
    906906      return handler(xp, area, addr);
     907    } else {
     908      if ((addr >= readonly_area->low) &&
     909          (addr < readonly_area->active)) {
     910        UnProtectMemory((LogicalAddress)(truncate_to_power_of_2(addr,log2_page_size)),
     911                        page_size);
     912        return 0;
     913      }
    907914    }
    908915  }
     
    10881095  return -1;
    10891096}
     1097
    10901098
    10911099/*
     
    12171225                       int old_valence)
    12181226{
    1219   unsigned oldMQ;
    12201227  OSStatus status = -1;
    12211228  pc program_counter;
     
    12711278{
    12721279  OSStatus err;
    1273   opcode *there = (opcode *) where, instr, errnum;
     1280  opcode *there = (opcode *) where, instr, errnum = 0;
    12741281  int i = TRAP_LOOKUP_TRIES, delta = 0;
    12751282 
     
    13091316  unsigned
    13101317    minor = UUO_MINOR(the_uuo),
    1311     rt = 0x1f & (the_uuo >> 21),
    1312     ra = 0x1f & (the_uuo >> 16),
    13131318    rb = 0x1f & (the_uuo >> 11),
    13141319    errnum = 0x3ff & (the_uuo >> 16);
     
    13271332
    13281333  case UUO_INTERR:
    1329     if (errnum == error_propagate_suspend) {
     1334    {
     1335      TCR * target = (TCR *)xpGPR(xp,arg_z);
    13301336      status = 0;
    1331     } else {
    1332       status = handle_error(xp, errnum, rb, 0,  where);
     1337      switch (errnum) {
     1338      case error_propagate_suspend:
     1339        break;
     1340      case error_interrupt:
     1341        xpGPR(xp,imm0) = (LispObj) raise_thread_interrupt(target);
     1342        break;
     1343      case error_suspend:
     1344        xpGPR(xp,imm0) = (LispObj) lisp_suspend_tcr(target);
     1345        break;
     1346      case error_suspend_all:
     1347        lisp_suspend_other_threads();
     1348        break;
     1349      case error_resume:
     1350        xpGPR(xp,imm0) = (LispObj) lisp_resume_tcr(target);
     1351        break;
     1352      case error_resume_all:
     1353        lisp_resume_other_threads();
     1354        break;
     1355      default:
     1356        status = handle_error(xp, errnum, rb, 0,  where);
     1357        break;
     1358      }
    13331359    }
    13341360    break;
     
    14071433                  natural arg1, natural arg2, natural arg3, natural arg4, natural arg5)
    14081434{
    1409   sigset_t mask;
    1410   natural  callback_ptr, i;
     1435  natural  callback_ptr;
    14111436  area *a;
    14121437
     
    14681493handle_trap(ExceptionInformation *xp, opcode the_trap, pc where, siginfo_t *info)
    14691494{
    1470   unsigned  instr, err_arg1 = 0, err_arg2 = 0, err_arg3 = 0;
    1471   int       ra, rs, fn_reg = 0;
    1472   char *    error_msg = NULL;
    1473   char      name[kNameBufLen];
    14741495  LispObj   cmain = nrs_CMAIN.vcell;
    1475   Boolean   event_poll_p = false;
    1476   int old_interrupt_level = 0;
    14771496  TCR *tcr = TCR_FROM_TSD(xpGPR(xp, rcontext));
    14781497
     
    16551674handle_error(ExceptionInformation *xp, unsigned errnum, unsigned rb, unsigned continuable, pc where)
    16561675{
    1657   LispObj   pname;
    16581676  LispObj   errdisp = nrs_ERRDISP.vcell;
    16591677
     
    18351853  if ((program_counter < &egc_write_barrier_end) &&
    18361854      (program_counter >= &egc_write_barrier_start)) {
    1837     LispObj *ea = 0, val, root;
     1855    LispObj *ea = 0, val = 0, root = 0;
    18381856    bitvector refbits = (bitvector)(lisp_global(REFBITS));
    18391857    Boolean need_store = true, need_check_memo = true, need_memoize_root = false;
     
    20952113  sigfillset(&sa.sa_mask);
    20962114  sa.sa_flags =
    2097     SA_RESTART
     2115    0 /* SA_RESTART */
    20982116    | SA_SIGINFO
    20992117#ifdef DARWIN
     
    21702188{
    21712189  thread_suspend_signal = SIG_SUSPEND_THREAD;
    2172   thread_resume_signal = SIG_RESUME_THREAD;
    21732190
    21742191  install_signal_handler(thread_suspend_signal, (void *) suspend_resume_handler);
    2175   install_signal_handler(thread_resume_signal,  (void *) suspend_resume_handler);
    21762192  install_signal_handler(SIGQUIT, (void *)quit_handler);
    21772193}
     
    23532369restore_mach_thread_state(mach_port_t thread, ExceptionInformation *pseudosigcontext)
    23542370{
    2355   int i, j;
    23562371  kern_return_t kret;
    23572372  MCONTEXT_T mc = UC_MCONTEXT(pseudosigcontext);
     
    23602375  kret = thread_set_state(thread,
    23612376                          PPC_FLOAT_STATE,
    2362                           (thread_state_t)&(mc->__fs),
     2377                          (thread_state_t)&(mc->fs),
    23632378                          PPC_FLOAT_STATE_COUNT);
    23642379
     
    23692384  kret = thread_set_state(thread,
    23702385                          PPC_THREAD_STATE64,
    2371                           (thread_state_t)&(mc->__ss),
     2386                          (thread_state_t)&(mc->ss),
    23722387                          PPC_THREAD_STATE64_COUNT);
    23732388#else
    23742389  kret = thread_set_state(thread,
    23752390                          MACHINE_THREAD_STATE,
    2376                           (thread_state_t)&(mc->__ss),
     2391                          (thread_state_t)&(mc->ss),
    23772392                          MACHINE_THREAD_STATE_COUNT);
    23782393#endif
     
    24242439  mach_msg_type_number_t thread_state_count;
    24252440  kern_return_t result;
    2426   int i,j;
    24272441  ExceptionInformation *pseudosigcontext;
    24282442  MCONTEXT_T mc;
     
    24472461    Bug(NULL, "Exception thread can't obtain thread state, Mach result = %d", result);
    24482462  }
    2449   stackp = ts.__r1;
     2463  stackp = ts.r1;
    24502464  backlink = stackp;
    24512465  stackp = TRUNC_DOWN(stackp, C_REDZONE_LEN, C_STK_ALIGN);
     
    24552469  stackp = TRUNC_DOWN(stackp, sizeof(*mc), C_STK_ALIGN);
    24562470  mc = (MCONTEXT_T) ptr_from_lispobj(stackp);
    2457   memmove(&(mc->__ss),&ts,sizeof(ts));
     2471  memmove(&(mc->ss),&ts,sizeof(ts));
    24582472
    24592473  thread_state_count = PPC_FLOAT_STATE_COUNT;
    24602474  thread_get_state(thread,
    24612475                   PPC_FLOAT_STATE,
    2462                    (thread_state_t)&(mc->__fs),
     2476                   (thread_state_t)&(mc->fs),
    24632477                   &thread_state_count);
    24642478
     
    24752489                   PPC_EXCEPTION_STATE,
    24762490#endif
    2477                    (thread_state_t)&(mc->__es),
     2491                   (thread_state_t)&(mc->es),
    24782492                   &thread_state_count);
    24792493
     
    25182532  ppc_thread_state_t ts;
    25192533#endif
    2520   mach_msg_type_number_t thread_state_count;
    25212534  ExceptionInformation *pseudosigcontext;
    2522   int i, j, old_valence = tcr->valence;
    2523   kern_return_t result;
     2535  int old_valence = tcr->valence;
    25242536  natural stackp;
    25252537
     
    25402552  */
    25412553
    2542   ts.__srr0 = (natural) handler_address;
    2543   ts.__srr1 = (int) xpMSR(pseudosigcontext) & ~MSR_FE0_FE1_MASK;
    2544   ts.__r1 = stackp;
    2545   ts.__r3 = signum;
    2546   ts.__r4 = (natural)pseudosigcontext;
    2547   ts.__r5 = (natural)tcr;
    2548   ts.__r6 = (natural)old_valence;
    2549   ts.__lr = (natural)pseudo_sigreturn;
     2554  ts.srr0 = (natural) handler_address;
     2555  ts.srr1 = (int) xpMSR(pseudosigcontext) & ~MSR_FE0_FE1_MASK;
     2556  ts.r1 = stackp;
     2557  ts.r3 = signum;
     2558  ts.r4 = (natural)pseudosigcontext;
     2559  ts.r5 = (natural)tcr;
     2560  ts.r6 = (natural)old_valence;
     2561  ts.lr = (natural)pseudo_sigreturn;
    25502562
    25512563
    25522564#ifdef PPC64
    2553   ts.__r13 = xpGPR(pseudosigcontext,13);
     2565  ts.r13 = xpGPR(pseudosigcontext,13);
    25542566  thread_set_state(thread,
    25552567                   PPC_THREAD_STATE64,
     
    26002612                   &thread_state_count);
    26012613  if (enabled) {
    2602     ts.__srr1 |= MSR_FE0_FE1_MASK;
     2614    ts.srr1 |= MSR_FE0_FE1_MASK;
    26032615  } else {
    2604     ts.__srr1 &= ~MSR_FE0_FE1_MASK;
     2616    ts.srr1 &= ~MSR_FE0_FE1_MASK;
    26052617  }
    26062618  /*
     
    26202632  */
    26212633  {
    2622     lisp_frame *tos = (lisp_frame *)ts.__r1,
     2634    lisp_frame *tos = (lisp_frame *)ts.r1,
    26232635      *next_frame = tos->backlink;
    26242636   
    26252637    if (tos == (next_frame -1)) {
    2626       ts.__srr0 = tos->savelr;
    2627       ts.__r1 = (LispObj) next_frame;
     2638      ts.srr0 = tos->savelr;
     2639      ts.r1 = (LispObj) next_frame;
    26282640    } else {
    2629       ts.__srr0 += 4;
     2641      ts.srr0 += 4;
    26302642    }
    26312643  }
     
    29602972  mach_port_t
    29612973    thread_exception_port = TCR_TO_EXCEPTION_PORT(tcr),
    2962     target_thread = pthread_mach_thread_np((pthread_t)ptr_from_lispobj(tcr->osid)),
    29632974    task_self = mach_task_self();
    29642975  kern_return_t kret;
Note: See TracChangeset for help on using the changeset viewer.