mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-07 23:28:55 +00:00
[SPARC64]: Optimize fault kprobe handling just like powerpc.
And eliminate DIE_GPF while we're at it. Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
6c1142602c
commit
127cda1e8c
4 changed files with 28 additions and 43 deletions
|
@ -313,7 +313,7 @@ out:
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __kprobes kprobe_fault_handler(struct pt_regs *regs, int trapnr)
|
int __kprobes kprobe_fault_handler(struct pt_regs *regs, int trapnr)
|
||||||
{
|
{
|
||||||
struct kprobe *cur = kprobe_running();
|
struct kprobe *cur = kprobe_running();
|
||||||
struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
|
struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
|
||||||
|
@ -403,15 +403,6 @@ int __kprobes kprobe_exceptions_notify(struct notifier_block *self,
|
||||||
if (post_kprobe_handler(args->regs))
|
if (post_kprobe_handler(args->regs))
|
||||||
ret = NOTIFY_STOP;
|
ret = NOTIFY_STOP;
|
||||||
break;
|
break;
|
||||||
case DIE_GPF:
|
|
||||||
case DIE_PAGE_FAULT:
|
|
||||||
/* kprobe_running() needs smp_processor_id() */
|
|
||||||
preempt_disable();
|
|
||||||
if (kprobe_running() &&
|
|
||||||
kprobe_fault_handler(args->regs, args->trapnr))
|
|
||||||
ret = NOTIFY_STOP;
|
|
||||||
preempt_enable();
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,36 +32,23 @@
|
||||||
#include <asm/mmu_context.h>
|
#include <asm/mmu_context.h>
|
||||||
|
|
||||||
#ifdef CONFIG_KPROBES
|
#ifdef CONFIG_KPROBES
|
||||||
ATOMIC_NOTIFIER_HEAD(notify_page_fault_chain);
|
static inline int notify_page_fault(struct pt_regs *regs)
|
||||||
|
|
||||||
/* Hook to register for page fault notifications */
|
|
||||||
int register_page_fault_notifier(struct notifier_block *nb)
|
|
||||||
{
|
{
|
||||||
return atomic_notifier_chain_register(¬ify_page_fault_chain, nb);
|
int ret = 0;
|
||||||
}
|
|
||||||
|
|
||||||
int unregister_page_fault_notifier(struct notifier_block *nb)
|
/* kprobe_running() needs smp_processor_id() */
|
||||||
{
|
if (!user_mode(regs)) {
|
||||||
return atomic_notifier_chain_unregister(¬ify_page_fault_chain, nb);
|
preempt_disable();
|
||||||
}
|
if (kprobe_running() && kprobe_fault_handler(regs, 0))
|
||||||
|
ret = 1;
|
||||||
static inline int notify_page_fault(enum die_val val, const char *str,
|
preempt_enable();
|
||||||
struct pt_regs *regs, long err, int trap, int sig)
|
}
|
||||||
{
|
return ret;
|
||||||
struct die_args args = {
|
|
||||||
.regs = regs,
|
|
||||||
.str = str,
|
|
||||||
.err = err,
|
|
||||||
.trapnr = trap,
|
|
||||||
.signr = sig
|
|
||||||
};
|
|
||||||
return atomic_notifier_call_chain(¬ify_page_fault_chain, val, &args);
|
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
static inline int notify_page_fault(enum die_val val, const char *str,
|
static inline int notify_page_fault(struct pt_regs *regs)
|
||||||
struct pt_regs *regs, long err, int trap, int sig)
|
|
||||||
{
|
{
|
||||||
return NOTIFY_DONE;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -120,9 +107,6 @@ static void __kprobes unhandled_fault(unsigned long address,
|
||||||
printk(KERN_ALERT "tsk->{mm,active_mm}->pgd = %016lx\n",
|
printk(KERN_ALERT "tsk->{mm,active_mm}->pgd = %016lx\n",
|
||||||
(tsk->mm ? (unsigned long) tsk->mm->pgd :
|
(tsk->mm ? (unsigned long) tsk->mm->pgd :
|
||||||
(unsigned long) tsk->active_mm->pgd));
|
(unsigned long) tsk->active_mm->pgd));
|
||||||
if (notify_die(DIE_GPF, "general protection fault", regs,
|
|
||||||
0, 0, SIGSEGV) == NOTIFY_STOP)
|
|
||||||
return;
|
|
||||||
die_if_kernel("Oops", regs);
|
die_if_kernel("Oops", regs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -299,8 +283,7 @@ asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
|
||||||
|
|
||||||
fault_code = get_thread_fault_code();
|
fault_code = get_thread_fault_code();
|
||||||
|
|
||||||
if (notify_page_fault(DIE_PAGE_FAULT, "page_fault", regs,
|
if (notify_page_fault(regs))
|
||||||
fault_code, 0, SIGSEGV) == NOTIFY_STOP)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
si_code = SEGV_MAPERR;
|
si_code = SEGV_MAPERR;
|
||||||
|
|
|
@ -7,8 +7,19 @@
|
||||||
|
|
||||||
struct pt_regs;
|
struct pt_regs;
|
||||||
|
|
||||||
extern int register_page_fault_notifier(struct notifier_block *);
|
/*
|
||||||
extern int unregister_page_fault_notifier(struct notifier_block *);
|
* These are only here because kprobes.c wants them to implement a
|
||||||
|
* blatant layering violation. Will hopefully go away soon once all
|
||||||
|
* architectures are updated.
|
||||||
|
*/
|
||||||
|
static inline int register_page_fault_notifier(struct notifier_block *nb)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
static inline int unregister_page_fault_notifier(struct notifier_block *nb)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
extern void bad_trap(struct pt_regs *, long);
|
extern void bad_trap(struct pt_regs *, long);
|
||||||
|
|
||||||
|
@ -20,7 +31,6 @@ enum die_val {
|
||||||
DIE_DIE,
|
DIE_DIE,
|
||||||
DIE_TRAP,
|
DIE_TRAP,
|
||||||
DIE_TRAP_TL1,
|
DIE_TRAP_TL1,
|
||||||
DIE_GPF,
|
|
||||||
DIE_CALL,
|
DIE_CALL,
|
||||||
DIE_PAGE_FAULT,
|
DIE_PAGE_FAULT,
|
||||||
};
|
};
|
||||||
|
|
|
@ -43,4 +43,5 @@ struct kprobe_ctlblk {
|
||||||
|
|
||||||
extern int kprobe_exceptions_notify(struct notifier_block *self,
|
extern int kprobe_exceptions_notify(struct notifier_block *self,
|
||||||
unsigned long val, void *data);
|
unsigned long val, void *data);
|
||||||
|
extern int kprobe_fault_handler(struct pt_regs *regs, int trapnr);
|
||||||
#endif /* _SPARC64_KPROBES_H */
|
#endif /* _SPARC64_KPROBES_H */
|
||||||
|
|
Loading…
Add table
Reference in a new issue