DragonFly BSD
DragonFly kernel List (threaded) for 2003-11
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: Userapi, Reflection


From: Galen Sampson <galen_sampson@xxxxxxxxx>
Date: Tue, 04 Nov 2003 10:15:26 -0800
Cc: coolvibe@xxxxxxxxxxxxxxxx, todd.lewis@xxxxxx

Emiel Kollof wrote:
* Lewis, Todd (todd.lewis@xxxxxx) wrote:

Maybe I'm misunderstanding, I don't understand why code needs to be in the
kernel.  Why not just, at run-time, link in the appropriate
syscall-decoder/rewriter depending on the personality of the binary?  New
syscalls for linux would just require updating
/lib/libpersonality_linux.so...


I like this idea. The more we can push into userspace, the better.


This is the idea. When you said you would like to "link in the appropriate syscall-decoder/rewriter depending on the personality of the binary" there are a couple of things that must happen:
1) The kernel must know which peronality to map in
2) The kernel must re-arrange the interrupt trap to jump to user space
instead of the kernel
3) This must happen for staticly linked programs and dynamically
linked programs.



Also, Matt, when you're talking about 0x80 being a userspace interrupt,
would that require rewriting the binary, valgrind-style, or is there some
hardware trick that could be used, or is there some other way?  My
understanding of x86 is that 0x80 always context-switches into the kernel,
but I am a novice in such matters.


I don't think that apps need to be rewritten. int 0x80 can always be
hooked up to do something else (like figure out which syscall is called
from which personality, and then send the required dragonfly message).

Of course, IANAAH (asm hacker), so I could be completely wrong about
this.

"Installing" a personality into the kernel does not make it "part of the kernel". It lets the kernel know where on disk this peronality is, which address to map this code to in the process, and which int 0xXX call the personality thinks is a system call. So for linux "installing" would be something like "hey kernel, when you see a binary marked 'linux' you should: map /usr/libexec/peronality/linux.so to (user space) 0x0b000000, int 0x80 should jump to (user space) 0x0b000000".
The reason this is different than usual is rtld is only used if the binary is dynamically linked. This means that the kernel must do the mapping, not rtld, because statically linked programs do not have rtld invoked at all. The kernel must also determine which personality to map, not rtld. Another reason the kernel must be involved is because mapping int 0xXX to an address is a privileged operation, it can't be done by a user process. This will need clarification from someone who knows about these things.


Regards,
Galen




[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]