i386: Why putting __USER_DS in kernel threads stack (%esp) ?

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

 



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,

-- 
Ahmed S. Darwish
http://darwish.07.googlepages.com


--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux