[PATCH] x86_64: Use a common function to find code segment bases

To avoid some code duplication.

Signed-off-by: Andi Kleen <ak@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
Andi Kleen 2005-04-16 15:24:59 -07:00 коммит произвёл Linus Torvalds
Родитель e502cdd63d
Коммит f1290ec93e
2 изменённых файлов: 10 добавлений и 7 удалений

Просмотреть файл

@ -62,21 +62,19 @@ void bust_spinlocks(int yes)
static noinline int is_prefetch(struct pt_regs *regs, unsigned long addr, static noinline int is_prefetch(struct pt_regs *regs, unsigned long addr,
unsigned long error_code) unsigned long error_code)
{ {
unsigned char *instr = (unsigned char *)(regs->rip); unsigned char *instr;
int scan_more = 1; int scan_more = 1;
int prefetch = 0; int prefetch = 0;
unsigned char *max_instr = instr + 15; unsigned char *max_instr;
/* If it was a exec fault ignore */ /* If it was a exec fault ignore */
if (error_code & (1<<4)) if (error_code & (1<<4))
return 0; return 0;
/* Code segments in LDT could have a non zero base. Don't check instr = (unsigned char *)convert_rip_to_linear(current, regs);
when that's possible */ max_instr = instr + 15;
if (regs->cs & (1<<2))
return 0;
if ((regs->cs & 3) != 0 && regs->rip >= TASK_SIZE) if ((regs->cs & 3) != 0 && instr >= (unsigned char *)TASK_SIZE)
return 0; return 0;
while (scan_more && instr < max_instr) { while (scan_more && instr < max_instr) {

Просмотреть файл

@ -86,6 +86,11 @@ struct pt_regs {
extern unsigned long profile_pc(struct pt_regs *regs); extern unsigned long profile_pc(struct pt_regs *regs);
void signal_fault(struct pt_regs *regs, void __user *frame, char *where); 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 { enum {
EF_CF = 0x00000001, EF_CF = 0x00000001,
EF_PF = 0x00000004, EF_PF = 0x00000004,