Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 116145
b: refs/heads/master
c: 3d58695
h: refs/heads/master
i:
  116143: 87b722a
v: v3
  • Loading branch information
Paul Mundt committed Sep 21, 2008
1 parent b0a16d0 commit 86b5b4f
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 29 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: 8f2baee28093ea77c7cc8da45049fd94cc76998e
refs/heads/master: 3d58695edbfac785161bf282dc11fd42a483d6c9
9 changes: 7 additions & 2 deletions trunk/arch/sh/kernel/process_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ __asm__(".align 5\n"
int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
{
struct pt_regs regs;
int pid;

memset(&regs, 0, sizeof(regs));
regs.regs[4] = (unsigned long)arg;
Expand All @@ -178,8 +179,12 @@ int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
regs.sr = (1 << 30);

/* Ok, create the new process.. */
return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0,
&regs, 0, NULL, NULL);
pid = do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0,
&regs, 0, NULL, NULL);

trace_mark(kernel_arch_kthread_create, "pid %d fn %p", pid, fn);

return pid;
}

/*
Expand Down
10 changes: 8 additions & 2 deletions trunk/arch/sh/kernel/process_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ ATTRIB_NORET void kernel_thread_helper(void *arg, int (*fn)(void *))
int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
{
struct pt_regs regs;
int pid;

memset(&regs, 0, sizeof(regs));
regs.regs[2] = (unsigned long)arg;
Expand All @@ -404,8 +405,13 @@ int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
regs.pc = (unsigned long)kernel_thread_helper;
regs.sr = (1 << 30);

return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0,
&regs, 0, NULL, NULL);
/* Ok, create the new process.. */
pid = do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0,
&regs, 0, NULL, NULL);

trace_mark(kernel_arch_kthread_create, "pid %d fn %p", pid, fn);

return pid;
}

/*
Expand Down
2 changes: 2 additions & 0 deletions trunk/arch/sh/kernel/sys_sh.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ asmlinkage int sys_ipc(uint call, int first, int second,
version = call >> 16; /* hack for backward compatibility */
call &= 0xffff;

trace_mark(kernel_arch_ipc_call, "call %u first %d", call, first);

if (call <= SEMTIMEDOP)
switch (call) {
case SEMOP:
Expand Down
57 changes: 33 additions & 24 deletions trunk/arch/sh/mm/fault_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,13 @@
#include <linux/mm.h>
#include <linux/hardirq.h>
#include <linux/kprobes.h>
#include <linux/marker.h>
#include <asm/io_trapped.h>
#include <asm/system.h>
#include <asm/mmu_context.h>
#include <asm/tlbflush.h>
#include <asm/kgdb.h>

static inline int notify_page_fault(struct pt_regs *regs, int trap)
{
int ret = 0;

#ifdef CONFIG_KPROBES
if (!user_mode(regs)) {
preempt_disable();
if (kprobe_running() && kprobe_fault_handler(regs, trap))
ret = 1;
preempt_enable();
}
#endif

return ret;
}

/*
* This routine handles page faults. It determines the address,
* and the problem, and then passes it off to one of the appropriate
Expand Down Expand Up @@ -261,6 +246,25 @@ asmlinkage void __kprobes do_page_fault(struct pt_regs *regs,
goto no_context;
}

static inline int notify_page_fault(struct pt_regs *regs, int trap)
{
int ret = 0;

trace_mark(kernel_arch_trap_entry, "trap_id %d ip #p%ld",
trap >> 5, instruction_pointer(regs));

#ifdef CONFIG_KPROBES
if (!user_mode(regs)) {
preempt_disable();
if (kprobe_running() && kprobe_fault_handler(regs, trap))
ret = 1;
preempt_enable();
}
#endif

return ret;
}

#ifdef CONFIG_SH_STORE_QUEUES
/*
* This is a special case for the SH-4 store queues, as pages for this
Expand All @@ -284,15 +288,18 @@ asmlinkage int __kprobes __do_page_fault(struct pt_regs *regs,
pmd_t *pmd;
pte_t *pte;
pte_t entry;
int ret = 0;

if (notify_page_fault(regs, lookup_exception_vector()))
return 0;
goto out;

#ifdef CONFIG_SH_KGDB
if (kgdb_nofault && kgdb_bus_err_hook)
kgdb_bus_err_hook();
#endif

ret = 1;

/*
* We don't take page faults for P1, P2, and parts of P4, these
* are always mapped, whether it be due to legacy behaviour in
Expand All @@ -302,24 +309,23 @@ asmlinkage int __kprobes __do_page_fault(struct pt_regs *regs,
pgd = pgd_offset_k(address);
} else {
if (unlikely(address >= TASK_SIZE || !current->mm))
return 1;
goto out;

pgd = pgd_offset(current->mm, address);
}

pud = pud_offset(pgd, address);
if (pud_none_or_clear_bad(pud))
return 1;
goto out;
pmd = pmd_offset(pud, address);
if (pmd_none_or_clear_bad(pmd))
return 1;

goto out;
pte = pte_offset_kernel(pmd, address);
entry = *pte;
if (unlikely(pte_none(entry) || pte_not_present(entry)))
return 1;
goto out;
if (unlikely(writeaccess && !pte_write(entry)))
return 1;
goto out;

if (writeaccess)
entry = pte_mkdirty(entry);
Expand All @@ -336,5 +342,8 @@ asmlinkage int __kprobes __do_page_fault(struct pt_regs *regs,
set_pte(pte, entry);
update_mmu_cache(NULL, address, entry);

return 0;
ret = 0;
out:
trace_mark(kernel_arch_trap_exit, MARK_NOARGS);
return ret;
}

0 comments on commit 86b5b4f

Please sign in to comment.