Re: [PATCH] Mutilated form of Andi Kleen's AMD prefetch errata patch

From: Jamie Lokier
Date: Wed Oct 01 2003 - 02:32:34 EST


Andi Kleen wrote:
> Hmm. I guess that's possible, but will be somewhat intrusive in
> do_page_fault()

See recent message from me. All you need is a check "address >=
TASK_SIZE", which is thread already at the start of do_page_fault. So
if you split that conditional like this, from:

if (address >= TASK_SIZE && !(error_code & 5))
goto vmalloc_fault;
mm = tsk->mm;
info.si_code = SEGV_MAPERR;
if (in_atomic() || !mm)
goto bad_area_nosemaphore;

to:

if (address >= TASK_SIZE) {
if (!(error_code & 5))
goto vmalloc_fault;
mm = tsk->mm;
info.si_code = SEGV_MAPERR;
goto bad_area_nosemaphore;
}

doesn't that fix the problem and while also being an improvement in
lots of other ways? The only reason it wouldn't work is if the VMA
list can contain regions >= TASK_SIZE, but I don't think that is done.

> Also you have to be very careful to avoid recursive faults (EIP unmapped)
> recursing further. In the original patch I did that for kernel mode by always
> checking the exception table first to catch the __get_user in __is_prefetch
> early.

I'm looking at "[PATCH] Athlon Prefetch workaround for 2.6.0test6" and
it appears to check the exception table first. That's why I was
wondering why you have the regs->eip == addr check.

search_exception_table doesn't take any locks for non-module entries,
so it can fixup the __get_user in __is_prefetch when that occurs
inside locked regions of the kernel.

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