Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 54306
b: refs/heads/master
c: 377fad3
h: refs/heads/master
v: v3
  • Loading branch information
Jeff Dike authored and Linus Torvalds committed May 7, 2007
1 parent 682e7e9 commit 7de23aa
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 23 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 5d86456d3852cb95a38d2b23fe01cede54984ba5
refs/heads/master: 377fad3acbb7e94ab9942a74e0d9ede8eeb2f039
2 changes: 2 additions & 0 deletions trunk/arch/um/include/common-offsets.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,7 @@ DEFINE(UM_ELF_CLASS, ELF_CLASS);
DEFINE(UM_ELFCLASS32, ELFCLASS32);
DEFINE(UM_ELFCLASS64, ELFCLASS64);

DEFINE(UM_NR_CPUS, NR_CPUS);

/* For crypto assembler code. */
DEFINE(crypto_tfm_ctx_offset, offsetof(struct crypto_tfm, __crt_ctx));
2 changes: 2 additions & 0 deletions trunk/arch/um/include/kern_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,6 @@ extern void time_init_kern(void);
extern int __cant_sleep(void);
extern void sigio_handler(int sig, union uml_pt_regs *regs);

extern void copy_sc(union uml_pt_regs *regs, void *from);

#endif
10 changes: 7 additions & 3 deletions trunk/arch/um/kernel/trap.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,10 @@ unsigned long segv(struct faultinfo fi, unsigned long ip, int is_user,
flush_tlb_kernel_vm();
return 0;
}
else if(current->mm == NULL)
panic("Segfault with no mm");
else if(current->mm == NULL) {
show_regs(container_of(regs, struct pt_regs, regs));
panic("Segfault with no mm");
}

if (SEGV_IS_FIXABLE(&fi) || SEGV_MAYBE_FIXABLE(&fi))
err = handle_page_fault(address, ip, is_write, is_user, &si.si_code);
Expand All @@ -194,9 +196,11 @@ unsigned long segv(struct faultinfo fi, unsigned long ip, int is_user,
else if(!is_user && arch_fixup(ip, regs))
return 0;

if(!is_user)
if(!is_user) {
show_regs(container_of(regs, struct pt_regs, regs));
panic("Kernel mode fault at addr 0x%lx, ip 0x%lx",
address, ip);
}

if (err == -EACCES) {
si.si_signo = SIGBUS;
Expand Down
15 changes: 13 additions & 2 deletions trunk/arch/um/os-Linux/skas/trap.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include "sysdep/ptrace_user.h"
#include "os.h"

static union uml_pt_regs ksig_regs[UM_NR_CPUS];

void sig_handler_common_skas(int sig, void *sc_ptr)
{
struct sigcontext *sc = sc_ptr;
Expand All @@ -27,10 +29,19 @@ void sig_handler_common_skas(int sig, void *sc_ptr)
* the process will die.
* XXX Figure out why this is better than SA_NODEFER
*/
if(sig == SIGSEGV)
if(sig == SIGSEGV) {
change_sig(SIGSEGV, 1);
/* For segfaults, we want the data from the
* sigcontext. In this case, we don't want to mangle
* the process registers, so use a static set of
* registers. For other signals, the process
* registers are OK.
*/
r = &ksig_regs[cpu()];
copy_sc(r, sc_ptr);
}
else r = TASK_REGS(get_current());

r = TASK_REGS(get_current());
save_user = r->skas.is_user;
r->skas.is_user = 0;
if ( sig == SIGFPE || sig == SIGSEGV ||
Expand Down
41 changes: 24 additions & 17 deletions trunk/arch/um/sys-i386/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,28 @@

#include "skas.h"

void copy_sc(union uml_pt_regs *regs, void *from)
{
struct sigcontext *sc = from;

REGS_GS(regs->skas.regs) = sc->gs;
REGS_FS(regs->skas.regs) = sc->fs;
REGS_ES(regs->skas.regs) = sc->es;
REGS_DS(regs->skas.regs) = sc->ds;
REGS_EDI(regs->skas.regs) = sc->edi;
REGS_ESI(regs->skas.regs) = sc->esi;
REGS_EBP(regs->skas.regs) = sc->ebp;
REGS_SP(regs->skas.regs) = sc->esp;
REGS_EBX(regs->skas.regs) = sc->ebx;
REGS_EDX(regs->skas.regs) = sc->edx;
REGS_ECX(regs->skas.regs) = sc->ecx;
REGS_EAX(regs->skas.regs) = sc->eax;
REGS_IP(regs->skas.regs) = sc->eip;
REGS_CS(regs->skas.regs) = sc->cs;
REGS_EFLAGS(regs->skas.regs) = sc->eflags;
REGS_SS(regs->skas.regs) = sc->ss;
}

static int copy_sc_from_user_skas(struct pt_regs *regs,
struct sigcontext __user *from)
{
Expand All @@ -30,25 +52,10 @@ static int copy_sc_from_user_skas(struct pt_regs *regs,
if(err)
return err;

REGS_GS(regs->regs.skas.regs) = sc.gs;
REGS_FS(regs->regs.skas.regs) = sc.fs;
REGS_ES(regs->regs.skas.regs) = sc.es;
REGS_DS(regs->regs.skas.regs) = sc.ds;
REGS_EDI(regs->regs.skas.regs) = sc.edi;
REGS_ESI(regs->regs.skas.regs) = sc.esi;
REGS_EBP(regs->regs.skas.regs) = sc.ebp;
REGS_SP(regs->regs.skas.regs) = sc.esp;
REGS_EBX(regs->regs.skas.regs) = sc.ebx;
REGS_EDX(regs->regs.skas.regs) = sc.edx;
REGS_ECX(regs->regs.skas.regs) = sc.ecx;
REGS_EAX(regs->regs.skas.regs) = sc.eax;
REGS_IP(regs->regs.skas.regs) = sc.eip;
REGS_CS(regs->regs.skas.regs) = sc.cs;
REGS_EFLAGS(regs->regs.skas.regs) = sc.eflags;
REGS_SS(regs->regs.skas.regs) = sc.ss;
copy_sc(&regs->regs, &sc);

err = restore_fp_registers(userspace_pid[0], fpregs);
if(err < 0){
if(err < 0) {
printk("copy_sc_from_user_skas - PTRACE_SETFPREGS failed, "
"errno = %d\n", -err);
return err;
Expand Down
30 changes: 30 additions & 0 deletions trunk/arch/um/sys-x86_64/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,36 @@

#include "skas.h"

void copy_sc(union uml_pt_regs *regs, void *from)
{
struct sigcontext *sc = from;

#define GETREG(regs, regno, sc, regname) \
(regs)->skas.regs[(regno) / sizeof(unsigned long)] = (sc)->regname

GETREG(regs, R8, sc, r8);
GETREG(regs, R9, sc, r9);
GETREG(regs, R10, sc, r10);
GETREG(regs, R11, sc, r11);
GETREG(regs, R12, sc, r12);
GETREG(regs, R13, sc, r13);
GETREG(regs, R14, sc, r14);
GETREG(regs, R15, sc, r15);
GETREG(regs, RDI, sc, rdi);
GETREG(regs, RSI, sc, rsi);
GETREG(regs, RBP, sc, rbp);
GETREG(regs, RBX, sc, rbx);
GETREG(regs, RDX, sc, rdx);
GETREG(regs, RAX, sc, rax);
GETREG(regs, RCX, sc, rcx);
GETREG(regs, RSP, sc, rsp);
GETREG(regs, RIP, sc, rip);
GETREG(regs, EFLAGS, sc, eflags);
GETREG(regs, CS, sc, cs);

#undef GETREG
}

static int copy_sc_from_user_skas(struct pt_regs *regs,
struct sigcontext __user *from)
{
Expand Down

0 comments on commit 7de23aa

Please sign in to comment.