linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* i386: Why putting __USER_DS in kernel threads stack initialization?
@ 2007-03-18 22:58 Ahmed S. Darwish
  2007-03-18 23:15 ` Ahmed S. Darwish
  2007-03-19 11:23 ` linux-os (Dick Johnson)
  0 siblings, 2 replies; 4+ messages in thread
From: Ahmed S. Darwish @ 2007-03-18 22:58 UTC (permalink / raw)
  To: linux-kernel

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, \
	       	       0, NULL, NULL);

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 ?

Thanks,

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
http://darwish.07.googlepages.com


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-03-21 19:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-18 22:58 i386: Why putting __USER_DS in kernel threads stack initialization? Ahmed S. Darwish
2007-03-18 23:15 ` Ahmed S. Darwish
2007-03-19 11:23 ` linux-os (Dick Johnson)
2007-03-21 19:25   ` Ahmed S. Darwish

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).