handle more errors and remove race condition in native_isr_entry

This commit is contained in:
Ludwig Ortmann 2014-01-29 10:57:17 +01:00
parent a55e85f8d0
commit 2c80f68d62

View File

@ -297,11 +297,12 @@ void native_isr_entry(int sig, siginfo_t *info, void *context)
_native_sigpend++; _native_sigpend++;
//real_write(STDOUT_FILENO, "sigpend\n", 8); //real_write(STDOUT_FILENO, "sigpend\n", 8);
native_isr_context.uc_stack.ss_sp = __isr_stack; if (context == NULL) {
native_isr_context.uc_stack.ss_size = SIGSTKSZ; errx(EXIT_FAILURE, "native_isr_entry: context is null - unhandled");
native_isr_context.uc_stack.ss_flags = 0; }
makecontext(&native_isr_context, native_irq_handler, 0); if (active_thread == NULL) {
_native_cur_ctx = (ucontext_t *)active_thread->sp; errx(EXIT_FAILURE, "native_isr_entry: active_thread is null - unhandled");
}
/* XXX: Workaround safety check - whenever this happens it really /* XXX: Workaround safety check - whenever this happens it really
* indicates a bug in disableIRQ */ * indicates a bug in disableIRQ */
@ -314,7 +315,17 @@ void native_isr_entry(int sig, siginfo_t *info, void *context)
return; return;
} }
if (_native_in_syscall == 0) { if (_native_in_syscall != 0) {
DEBUG("\n\n\t\treturn to syscall\n\n");
return;
}
native_isr_context.uc_stack.ss_sp = __isr_stack;
native_isr_context.uc_stack.ss_size = SIGSTKSZ;
native_isr_context.uc_stack.ss_flags = 0;
makecontext(&native_isr_context, native_irq_handler, 0);
_native_cur_ctx = (ucontext_t *)active_thread->sp;
DEBUG("\n\n\t\treturn to _native_sig_leave_tramp\n\n"); DEBUG("\n\n\t\treturn to _native_sig_leave_tramp\n\n");
/* disable interrupts in context */ /* disable interrupts in context */
isr_set_sigmask((ucontext_t *)context); isr_set_sigmask((ucontext_t *)context);
@ -330,10 +341,6 @@ void native_isr_entry(int sig, siginfo_t *info, void *context)
_native_saved_eip = ((ucontext_t *)context)->uc_mcontext.gregs[REG_EIP]; _native_saved_eip = ((ucontext_t *)context)->uc_mcontext.gregs[REG_EIP];
((ucontext_t *)context)->uc_mcontext.gregs[REG_EIP] = (unsigned int)&_native_sig_leave_tramp; ((ucontext_t *)context)->uc_mcontext.gregs[REG_EIP] = (unsigned int)&_native_sig_leave_tramp;
#endif #endif
}
else {
DEBUG("\n\n\t\treturn to syscall\n\n");
}
} }
/** /**