void __kprobes do_protection_exception(struct pt_regs *regs) { unsigned long trans_exc_code; int fault; trans_exc_code = regs->int_parm_long; /* * Protection exceptions are suppressing, decrement psw address. * The exception to this rule are aborted transactions, for these * the PSW already points to the correct location. */ if (!(regs->int_code & 0x200)) regs->psw.addr = __rewind_psw(regs->psw, regs->int_code >> 16); /* * Check for low-address protection. This needs to be treated * as a special case because the translation exception code * field is not guaranteed to contain valid data in this case. */ if (unlikely(!(trans_exc_code & 4))) { do_low_address(regs); return; } fault = do_exception(regs, VM_WRITE); if (unlikely(fault)) do_fault_error(regs, fault); }
void do_protection_exception(struct pt_regs *regs) { unsigned long trans_exc_code; int access, fault; trans_exc_code = regs->int_parm_long; /* * Protection exceptions are suppressing, decrement psw address. * The exception to this rule are aborted transactions, for these * the PSW already points to the correct location. */ if (!(regs->int_code & 0x200)) regs->psw.addr = __rewind_psw(regs->psw, regs->int_code >> 16); /* * Check for low-address protection. This needs to be treated * as a special case because the translation exception code * field is not guaranteed to contain valid data in this case. */ if (unlikely(!(trans_exc_code & 4))) { do_low_address(regs); return; } if (unlikely(MACHINE_HAS_NX && (trans_exc_code & 0x80))) { regs->int_parm_long = (trans_exc_code & ~PAGE_MASK) | (regs->psw.addr & PAGE_MASK); access = VM_EXEC; fault = VM_FAULT_BADACCESS; } else { access = VM_WRITE; fault = do_exception(regs, access); } if (unlikely(fault)) do_fault_error(regs, access, fault); }
void __kprobes do_dat_exception(struct pt_regs *regs) { int access, fault; access = VM_READ | VM_EXEC | VM_WRITE; fault = do_exception(regs, access); if (unlikely(fault)) do_fault_error(regs, fault); }
static void event_to_exception(Parrot_Interp interpreter, parrot_event* event) { int exit_code = -event->u.signal; switch (event->u.signal) { case SIGINT: /* * SIGINT is silent, if no exception handler is * installed: set severity to EXCEPT_exit */ do_exception(interpreter, EXCEPT_exit, exit_code); break; default: do_exception(interpreter, EXCEPT_error, exit_code); break; } }
void __kprobes do_dat_exception(struct pt_regs *regs, long pgm_int_code, unsigned long trans_exc_code) { int access, fault; access = VM_READ | VM_EXEC | VM_WRITE; fault = do_exception(regs, access, trans_exc_code); if (unlikely(fault)) do_fault_error(regs, pgm_int_code & 255, trans_exc_code, fault); }
void __kprobes do_protection_exception(struct pt_regs *regs) { unsigned long trans_exc_code; int fault; trans_exc_code = regs->int_parm_long; regs->psw.addr = __rewind_psw(regs->psw, regs->int_code >> 16); if (unlikely(!(trans_exc_code & 4))) { do_low_address(regs); return; } fault = do_exception(regs, VM_WRITE); if (unlikely(fault)) do_fault_error(regs, fault); }
void __kprobes do_protection_exception(struct pt_regs *regs, long pgm_int_code, unsigned long trans_exc_code) { int fault; /* Protection exception is suppressing, decrement psw address. */ regs->psw.addr -= (pgm_int_code >> 16); /* * Check for low-address protection. This needs to be treated * as a special case because the translation exception code * field is not guaranteed to contain valid data in this case. */ if (unlikely(!(trans_exc_code & 4))) { do_low_address(regs, pgm_int_code, trans_exc_code); return; } fault = do_exception(regs, VM_WRITE, trans_exc_code); if (unlikely(fault)) do_fault_error(regs, 4, trans_exc_code, fault); }
int __handle_fault(unsigned long uaddr, unsigned long pgm_int_code, int write) { struct pt_regs regs; int access, fault; regs.psw.mask = psw_kernel_bits; if (!irqs_disabled()) regs.psw.mask |= PSW_MASK_IO | PSW_MASK_EXT; regs.psw.addr = (unsigned long) __builtin_return_address(0); regs.psw.addr |= PSW_ADDR_AMODE; uaddr &= PAGE_MASK; access = write ? VM_WRITE : VM_READ; fault = do_exception(®s, access, uaddr | 2); if (unlikely(fault)) { if (fault & VM_FAULT_OOM) return -EFAULT; else if (fault & VM_FAULT_SIGBUS) do_sigbus(®s, pgm_int_code, uaddr); } return fault ? -EFAULT : 0; }
int main (int argc, char **argv) { (void) argc; (void) argv; int exc = 0; do_exception (&exc); if ( ! exc ) { set_alarm (1); //failed (); sleep (10); } else { if ( exc == timeout_ex ) { printf ("timeout!\n"); } else if ( exc ) { printf ("error code: %d\n", exc); } } disable_alarm (); return EXIT_SUCCESS; }
int __handle_fault(unsigned long uaddr, unsigned long pgm_int_code, int write) { struct pt_regs regs; int access, fault; /* Emulate a uaccess fault from kernel mode. */ regs.psw.mask = psw_kernel_bits | PSW_MASK_DAT | PSW_MASK_MCHECK; if (!irqs_disabled()) regs.psw.mask |= PSW_MASK_IO | PSW_MASK_EXT; regs.psw.addr = (unsigned long) __builtin_return_address(0); regs.psw.addr |= PSW_ADDR_AMODE; regs.int_code = pgm_int_code; regs.int_parm_long = (uaddr & PAGE_MASK) | 2; access = write ? VM_WRITE : VM_READ; fault = do_exception(®s, access); /* * Since the fault happened in kernel mode while performing a uaccess * all we need to do now is emulating a fixup in case "fault" is not * zero. * For the calling uaccess functions this results always in -EFAULT. */ return fault ? -EFAULT : 0; }