[lkml]   [2007]   [Mar]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Subjecti386: Why putting __USER_DS in kernel threads stack initialization?
Hi list,

Reading the kernel threads initialization code I see:

int kernel_thread(...) {

struct pt_regs regs;
memset(&regs, 0, sizeof(regs));
** regs.xds = __USER_DS;
** regs.xes = __USER_DS;
/* Ok, create the new process.. */
return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0, &regs, \

Continuing with the code, the threads stack (beginning from %esp) is
initialized with the passed *regs from do_fork:

int copy_thread(..., struct task_struct *p, struct pt_regs *regs) {

struct pt_regs * childregs;
struct task_struct *tsk;
childregs = task_pt_regs(p);
** *childregs = *regs;
** p->thread.esp = (unsigned long) childregs;

So the question is what will a _kernel_ thread do with the Usermode Segment
address ?


P.S. I've tried commenting out both lines which led to a non functional init,
Also setting them to __USER_DS made init start but stopped issuing the error:
`Panic: Segment violation at 0x8049798 - Sleeping for 30 seconds'

Ahmed S. Darwish

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2007-03-19 00:01    [W:0.040 / U:1.720 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site