Commit 248b74c7 authored by Al Viro's avatar Al Viro Committed by Richard Weinberger

um: start switching the references to host mcontext_t to its userland type

Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
parent 05c46db4
...@@ -6,9 +6,4 @@ ...@@ -6,9 +6,4 @@
#ifndef __PROCESS_H__ #ifndef __PROCESS_H__
#define __PROCESS_H__ #define __PROCESS_H__
#include <signal.h>
extern void sig_handler(int sig, struct sigcontext *sc);
extern void alarm_handler(int sig, struct sigcontext *sc);
#endif #endif
void alarm_handler(int, mcontext_t *);
...@@ -26,7 +26,7 @@ void (*sig_info[NSIG])(int, struct uml_pt_regs *) = { ...@@ -26,7 +26,7 @@ void (*sig_info[NSIG])(int, struct uml_pt_regs *) = {
[SIGIO] = sigio_handler, [SIGIO] = sigio_handler,
[SIGVTALRM] = timer_handler }; [SIGVTALRM] = timer_handler };
static void sig_handler_common(int sig, struct sigcontext *sc) static void sig_handler_common(int sig, mcontext_t *mc)
{ {
struct uml_pt_regs r; struct uml_pt_regs r;
int save_errno = errno; int save_errno = errno;
...@@ -34,8 +34,8 @@ static void sig_handler_common(int sig, struct sigcontext *sc) ...@@ -34,8 +34,8 @@ static void sig_handler_common(int sig, struct sigcontext *sc)
r.is_user = 0; r.is_user = 0;
if (sig == SIGSEGV) { if (sig == SIGSEGV) {
/* For segfaults, we want the data from the sigcontext. */ /* For segfaults, we want the data from the sigcontext. */
copy_sc(&r, sc); copy_sc(&r, (struct sigcontext *)mc);
GET_FAULTINFO_FROM_SC(r.faultinfo, sc); GET_FAULTINFO_FROM_MC(r.faultinfo, mc);
} }
/* enable signals if sig isn't IRQ signal */ /* enable signals if sig isn't IRQ signal */
...@@ -62,7 +62,7 @@ static void sig_handler_common(int sig, struct sigcontext *sc) ...@@ -62,7 +62,7 @@ static void sig_handler_common(int sig, struct sigcontext *sc)
static int signals_enabled; static int signals_enabled;
static unsigned int signals_pending; static unsigned int signals_pending;
void sig_handler(int sig, struct sigcontext *sc) void sig_handler(int sig, mcontext_t *mc)
{ {
int enabled; int enabled;
...@@ -74,23 +74,23 @@ void sig_handler(int sig, struct sigcontext *sc) ...@@ -74,23 +74,23 @@ void sig_handler(int sig, struct sigcontext *sc)
block_signals(); block_signals();
sig_handler_common(sig, sc); sig_handler_common(sig, mc);
set_signals(enabled); set_signals(enabled);
} }
static void real_alarm_handler(struct sigcontext *sc) static void real_alarm_handler(mcontext_t *mc)
{ {
struct uml_pt_regs regs; struct uml_pt_regs regs;
if (sc != NULL) if (mc != NULL)
copy_sc(&regs, sc); copy_sc(&regs, (struct sigcontext *)mc);
regs.is_user = 0; regs.is_user = 0;
unblock_signals(); unblock_signals();
timer_handler(SIGVTALRM, &regs); timer_handler(SIGVTALRM, &regs);
} }
void alarm_handler(int sig, struct sigcontext *sc) void alarm_handler(int sig, mcontext_t *mc)
{ {
int enabled; int enabled;
...@@ -102,7 +102,7 @@ void alarm_handler(int sig, struct sigcontext *sc) ...@@ -102,7 +102,7 @@ void alarm_handler(int sig, struct sigcontext *sc)
block_signals(); block_signals();
real_alarm_handler(sc); real_alarm_handler(mc);
set_signals(enabled); set_signals(enabled);
} }
...@@ -121,7 +121,7 @@ void set_sigstack(void *sig_stack, int size) ...@@ -121,7 +121,7 @@ void set_sigstack(void *sig_stack, int size)
panic("enabling signal stack failed, errno = %d\n", errno); panic("enabling signal stack failed, errno = %d\n", errno);
} }
static void (*handlers[_NSIG])(int sig, struct sigcontext *sc) = { static void (*handlers[_NSIG])(int sig, mcontext_t *mc) = {
[SIGSEGV] = sig_handler, [SIGSEGV] = sig_handler,
[SIGBUS] = sig_handler, [SIGBUS] = sig_handler,
[SIGILL] = sig_handler, [SIGILL] = sig_handler,
...@@ -133,8 +133,11 @@ static void (*handlers[_NSIG])(int sig, struct sigcontext *sc) = { ...@@ -133,8 +133,11 @@ static void (*handlers[_NSIG])(int sig, struct sigcontext *sc) = {
[SIGVTALRM] = alarm_handler [SIGVTALRM] = alarm_handler
}; };
static void handle_signal(int sig, struct sigcontext *sc)
static void hard_handler(int sig, siginfo_t *info, void *p)
{ {
struct ucontext *uc = p;
mcontext_t *mc = &uc->uc_mcontext;
unsigned long pending = 1UL << sig; unsigned long pending = 1UL << sig;
do { do {
...@@ -160,7 +163,7 @@ static void handle_signal(int sig, struct sigcontext *sc) ...@@ -160,7 +163,7 @@ static void handle_signal(int sig, struct sigcontext *sc)
while ((sig = ffs(pending)) != 0){ while ((sig = ffs(pending)) != 0){
sig--; sig--;
pending &= ~(1 << sig); pending &= ~(1 << sig);
(*handlers[sig])(sig, sc); (*handlers[sig])(sig, mc);
} }
/* /*
...@@ -174,12 +177,6 @@ static void handle_signal(int sig, struct sigcontext *sc) ...@@ -174,12 +177,6 @@ static void handle_signal(int sig, struct sigcontext *sc)
} while (pending); } while (pending);
} }
static void hard_handler(int sig, siginfo_t *info, void *p)
{
struct ucontext *uc = p;
handle_signal(sig, (struct sigcontext *) &uc->uc_mcontext);
}
void set_handler(int sig) void set_handler(int sig)
{ {
struct sigaction action; struct sigaction action;
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include <sys/time.h> #include <sys/time.h>
#include "kern_util.h" #include "kern_util.h"
#include "os.h" #include "os.h"
#include "process.h" #include "internal.h"
int set_interval(void) int set_interval(void)
{ {
......
...@@ -22,4 +22,11 @@ ...@@ -22,4 +22,11 @@
(fi).trap_no = SC_TRAPNO(sc); \ (fi).trap_no = SC_TRAPNO(sc); \
} }
#define GET_FAULTINFO_FROM_MC(fi, mc) \
{ \
(fi).cr2 = (mc)->cr2; \
(fi).error_code = (mc)->gregs[REG_ERR]; \
(fi).trap_no = (mc)->gregs[REG_TRAPNO]; \
}
#endif #endif
...@@ -22,4 +22,11 @@ ...@@ -22,4 +22,11 @@
(fi).trap_no = SC_TRAPNO(sc); \ (fi).trap_no = SC_TRAPNO(sc); \
} }
#define GET_FAULTINFO_FROM_MC(fi, mc) \
{ \
(fi).cr2 = (mc)->gregs[REG_CR2]; \
(fi).error_code = (mc)->gregs[REG_ERR]; \
(fi).trap_no = (mc)->gregs[REG_TRAPNO]; \
}
#endif #endif
...@@ -12,7 +12,7 @@ stub_segv_handler(int sig, siginfo_t *info, void *p) ...@@ -12,7 +12,7 @@ stub_segv_handler(int sig, siginfo_t *info, void *p)
{ {
struct ucontext *uc = p; struct ucontext *uc = p;
GET_FAULTINFO_FROM_SC(*((struct faultinfo *) STUB_DATA), GET_FAULTINFO_FROM_MC(*((struct faultinfo *) STUB_DATA),
&uc->uc_mcontext); &uc->uc_mcontext);
trap_myself(); trap_myself();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment