Question about kernel_thread in UML TT mode
Hi,all:
I found UML only implement its own kernel_thread function but doesn't implement kernel_thread_helper function. Then how does UML start a kernel thread in TT mode? Is there any other functions being called? Thanks a lot!
Alex
-------------------------------------------------------
SF.Net email is sponsored by: Tell us your software development plans! Take this survey and enter to win a one-year sub to SourceForge.net Plus IDC's 2005 look-ahead and a copy of this survey
Click here to start! http://www.idcswdc.com/cgi-bin/survey?id5hix
_______________________________________________
User-mode-linux-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
Quoted 4 lines · Alex LIU
Hi,all:
I found UML only implement its own
kernel_threadfunction but doesn't implementkernel_thread_helperfunction.
??? What's kernel_thread_helper? kernel_thread calls the arch-independent do_fork(), which works like the rest. In particular, it will call the arch-specific copy_thread; and copy_thread_tt will do the necessary work.
Quoted 4 lines
Then how does UML start a kernel
thread in TT mode? Is there any other functions being called? Thanks a lot!Alex
Signature · 17 lines
Paolo Giarrusso, aka Blaisorblade Skype user "PaoloGiarrusso" Linux registered user n. 292729 http://www.user-mode-linux.org/~blaisorblade ------------------------------------------------------- SF.Net email is sponsored by: Tell us your software development plans! Take this survey and enter to win a one-year sub to SourceForge.net Plus IDC's 2005 look-ahead and a copy of this survey Click here to start! http://www.idcswdc.com/cgi-bin/survey?id=105hix _______________________________________________ User-mode-linux-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
Quoted 1 line · Blaisorblade
What's
kernel_thread_helper?
kernel_thread_helper and kernel_thread are defined in i386 as following:
-----------------------------------------------
/*
* This gets run with %ebx containing the
* function to call, and %edx containing
* the "args".
*/
extern void kernel_thread_helper(void);
__asm__(".section .text\n"
".align 4\n" "kernel_thread_helper:\n\t" "movl %edx,%eax\n\t" "pushl %edx\n\t" "call *%ebx\n\t" "pushl %eax\n\t" "call do_exit\n" ".previous");
/*
* Create a kernel thread
*/
int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
{
struct pt_regs regs;
/* BProc: (SLAVE) kernel forks are not subject to BProc's
* remote process management stuff. */
bproc_kcall();
memset(®s, 0, sizeof(regs));
regs.ebx = (unsigned long) fn;
regs.edx = (unsigned long) arg;
regs.xds = __USER_DS;
regs.xes = __USER_DS;
regs.orig_eax = -1;
regs.eip = (unsigned long) kernel_thread_helper;
regs.xcs = __KERNEL_CS;
regs.eflags = X86_EFLAGS_IF | X86_EFLAGS_SF | X86_EFLAGS_PF | 0x2;
/* Ok, create the new process.. */
return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0, ®s, 0, NULL, NULL);
}-----------------------------------------------
I think kernel_thread_helper make the new generated kernel thread to call the function and then exit. But in UML there is no kernel_thread_helper. Then how does UML make its kernel thread call the function and then exit? Thanks a lot!
Alex
-------------------------------------------------------
SF.Net email is sponsored by: Tell us your software development plans! Take this survey and enter to win a one-year sub to SourceForge.net Plus IDC's 2005 look-ahead and a copy of this survey
Click here to start! http://www.idcswdc.com/cgi-bin/survey?id5hix
_______________________________________________
User-mode-linux-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
Quoted 10 lines
extern void
kernel_thread_helper(void);
__asm__(".section .text\n"".align 4\n" "kernel_thread_helper:\n\t" "movl %edx,%eax\n\t" "pushl %edx\n\t" "call *%ebx\n\t" "pushl %eax\n\t" "call do_exit\n" ".previous");
kernel_thread helper is just a dummy wrapper to feed into kernel_thread and can probably look at as a static local function only for use of x86 implementation of kernel_thread.
Stian
-------------------------------------------------------
SF.Net email is sponsored by: Tell us your software development plans! Take this survey and enter to win a one-year sub to SourceForge.net Plus IDC's 2005 look-ahead and a copy of this survey
Click here to start! http://www.idcswdc.com/cgi-bin/survey?id=105hix
_______________________________________________
User-mode-linux-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel