lkml.org 
[lkml]   [2003]   [Sep]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] Athlon Prefetch workaround for 2.6.0test6
Andi Kleen wrote:
> + /*
> + * Avoid recursive faults. This catches the kernel jumping to nirvana.
> + * More complicated races with unmapped EIP are handled elsewhere for
> + * user space.
> + */
> + if (regs->eip == addr)
> + return 0;

I'm curious - how does this help?

If the kernel jumps into nirvana, it will page fault. is_prefetch()
will do a __get_user which will fault - recursion, ok. The inner
fault handler will reach fixup_exception(), fixup the __get_user, and
return without recursing further. is_prefetch() will simply return.

So how does the above test help?

> + if (seg & (1<<2))
> + desc = current->mm->context.ldt;
> + else
> + desc = (u32 *)&cpu_gdt_table[smp_processor_id()];
> + desc = (void *)desc + (seg & ~7);
> + return (desc[0] >> 16) |
> + ((desc[1] & 0xFF) << 16) |
> + (desc[1] & 0xFF000000);

In addition to needing get_cpu() to protect the GDT access, this code
needs to take down(&current->mm->context.sem) for the LDT access.

Otherwise, context.ldt may have been vfree()'d by the time you use it,
and the desc[0..1] accesses will panic.

Thanks,
-- Jamie

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:49    [W:1.471 / U:0.080 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site