Hi,
It seems that I found a bug in the latest version of L4Android kernel. I'm familiar enough with the code base so your comments are highly appreciated.
The main thread for L4Linux (i.e., the thread running l4x_server_loop()) didn't initialize l4x_stack before execution. Therefore, this thread crashes whenever it calls cli() / sti().
Calling vmalloc() and kmalloc() can reproduce this bug reliably. Here is a patch to fix this problem.
~Haohui
--- a/arch/l4/kernel/main.c +++ b/arch/l4/kernel/main.c @@ -2501,6 +2501,8 @@ int __init_refok L4_CV main(int argc, char **argv) * for these areas so far */ //l4x_register_pointer_section(&_edata, 0, "data");
+ l4x_stack_setup(current_thread_info(), l4_utcb(), 0); + /* Send start message to main thread. */ l4_ipc_send(l4lx_thread_get_cap(main_id), l4_utcb(), l4_msgtag(0, 0, 0, 0), L4_IPC_NEVER);
On Sun Apr 01, 2012 at 15:09:11 -0500, Mai, Haohui wrote:
It seems that I found a bug in the latest version of L4Android kernel. I'm familiar enough with the code base so your comments are highly appreciated.
The main thread for L4Linux (i.e., the thread running l4x_server_loop()) didn't initialize l4x_stack before execution. Therefore, this thread crashes whenever it calls cli() / sti().
Calling vmalloc() and kmalloc() can reproduce this bug reliably. Here is a patch to fix this problem.
On this thread no Linux code must be called, so any stack setup is not required. Call Linux functionality only in proper CPU contexts.
Adam
One more related question -- it seems that when I call Linux functions, e.g., vmalloc(). The contents of message registers are no longer preserved.
Is it desired behavior?
I appreciate if you could document it somewhere if it's indeed the case. :-)
~Haohui
On Apr 2, 2012, at 4:23 AM, Adam Lackorzynski wrote:
On Sun Apr 01, 2012 at 15:09:11 -0500, Mai, Haohui wrote:
It seems that I found a bug in the latest version of L4Android kernel. I'm familiar enough with the code base so your comments are highly appreciated.
The main thread for L4Linux (i.e., the thread running l4x_server_loop()) didn't initialize l4x_stack before execution. Therefore, this thread crashes whenever it calls cli() / sti().
Calling vmalloc() and kmalloc() can reproduce this bug reliably. Here is a patch to fix this problem.
On this thread no Linux code must be called, so any stack setup is not required. Call Linux functionality only in proper CPU contexts.
Adam
Adam adam@os.inf.tu-dresden.de Lackorzynski http://os.inf.tu-dresden.de/~adam/
l4-hackers mailing list l4-hackers@os.inf.tu-dresden.de http://os.inf.tu-dresden.de/mailman/listinfo/l4-hackers
On Mon Apr 02, 2012 at 12:58:35 -0500, Haohui Mai wrote:
One more related question -- it seems that when I call Linux functions, e.g., vmalloc(). The contents of message registers are no longer preserved.
Is it desired behavior?
Indeed it cannot be expected that this is the case. To preserve the contents the vCPU needs to be locked appropriately to prevent preemptions. The L4XV_* wrappers can be used for that.
Adam
l4-hackers@os.inf.tu-dresden.de