Skip to contentSkip to conversation

i486 emu in mainline?

DISCUSSION Nathanael Nerode 1 participant 1 message Oct 10, 2004

lore
Share & tools
lore
#0 lore raw

Some thread necromancy...

Quoted 15 lines · Andrew Morton
Quoted 8 lines · Willy Tarreau <willy <at> w.ods.org> wrote:
Quoted 2 lines · Arjan van de Ven

on first look it seems to be missing a bunch of get_user() calls and does direct access instead....

It was intentional for speed purpose. The areas are checked once with verify_area() when we need to access memory, then data is copied directly from/to memory. I don't think there's any risk, but I can be wrong.

verify_area() simply checks that the address is a legal one for a userspace access (it's not a chunk of kernel memory). But the kernel can still take a pagefault when accessing the address, so you need to use the uaccess functions which will handle the fault appropriately.

Quoted 4 lines

That's put_user(), get_user(), copy_*_user(), etc. Those functions internally perform verify_area(), so if you've already done a verify_area() you can use __put_user(), __get_user(), etc which skip the verify_area() but which still know how to deal with user address faults.

After reviewing the thread, this seems to be the most important reason why this patch can't be included. So I thought, "Hey, I'll fix that."

But put_user, get_user, etc. may sleep (of course). They're also "user context only".

This is a hardware trap handler. What sort of context is that? Is it really "user context"? Worse, we're attempting to emulate an *atomic* instruction (CMPXCHG).

So how do I guarantee:
(1) the original process doesn't get resumed during the sleep (perhaps this is guaranteed by other things?)
(2) nobody else messes with the data we're messing with, so that this is actually atomic. (Note that we're assuming there's no SMP, because this is an i386 and there are no known i386 SMP machines supported by Linux. So the only problem is stuff woken during sleep.) Basically, this means no other process which might share the memory can be woken up during the sleep either. :-P

Is this possible, or hopelessly difficult?

Signature · 1 line
This space intentionally left blank.