From: Andi Kleen Date: Sat, 16 Apr 2005 22:24:59 +0000 (-0700) Subject: [PATCH] x86_64: Use a common function to find code segment bases X-Git-Tag: v2.6.12-rc3~168 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f1290ec93e5da4a748ca4758a00b580283e06596;p=linux-2.6 [PATCH] x86_64: Use a common function to find code segment bases To avoid some code duplication. Signed-off-by: Andi Kleen Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/arch/x86_64/mm/fault.c b/arch/x86_64/mm/fault.c index d4676ca091..e033092167 100644 --- a/arch/x86_64/mm/fault.c +++ b/arch/x86_64/mm/fault.c @@ -62,21 +62,19 @@ void bust_spinlocks(int yes) static noinline int is_prefetch(struct pt_regs *regs, unsigned long addr, unsigned long error_code) { - unsigned char *instr = (unsigned char *)(regs->rip); + unsigned char *instr; int scan_more = 1; int prefetch = 0; - unsigned char *max_instr = instr + 15; + unsigned char *max_instr; /* If it was a exec fault ignore */ if (error_code & (1<<4)) return 0; - /* Code segments in LDT could have a non zero base. Don't check - when that's possible */ - if (regs->cs & (1<<2)) - return 0; + instr = (unsigned char *)convert_rip_to_linear(current, regs); + max_instr = instr + 15; - if ((regs->cs & 3) != 0 && regs->rip >= TASK_SIZE) + if ((regs->cs & 3) != 0 && instr >= (unsigned char *)TASK_SIZE) return 0; while (scan_more && instr < max_instr) { diff --git a/include/asm-x86_64/ptrace.h b/include/asm-x86_64/ptrace.h index c7865cfedc..5bbc8d3141 100644 --- a/include/asm-x86_64/ptrace.h +++ b/include/asm-x86_64/ptrace.h @@ -86,6 +86,11 @@ struct pt_regs { extern unsigned long profile_pc(struct pt_regs *regs); void signal_fault(struct pt_regs *regs, void __user *frame, char *where); +struct task_struct; + +extern unsigned long +convert_rip_to_linear(struct task_struct *child, struct pt_regs *regs); + enum { EF_CF = 0x00000001, EF_PF = 0x00000004,