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

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

 



On Sat, Mar 17, 2007 at 11:55:24PM +0700, Mulyadi Santosa wrote:
> Hi...
> 
> >What makes me wonder is that as said in Understanding Linux Kernel (v3):
> >
> >  When CPL (Current Privelege level) is equal to 3, the ds register must
> >  contain the segment selector of the user data segment. When it's equal to
> >  zero, the ds register must contain the segment selector of the kernel 
> >  data
> >  segment.
> >
> >So how come running a kernel thread with DS = __USER_DS ?

[...]

> When kernel thread is switched out and user mode process gets in,
> several steps of context switching happen. One of them of restoring
> register condition, for instance EIP so kernel can start the process
> wherever it was once preempted. pt_regs, IMHO, represents this
> soon-to-be-restored registers, so imagine if __KERNEL_DS is popped
> back to DS register and user mode operates in CPL=3. Screwed, right?

If I have understood what you mean. I think yes, they represent a
soon-to-be-restored registers _(like any process)_. But AFAIK in the registers
restoration phase, the values is restored from the process _own_ kernel mode
stack and not from other process/thread stack. 

Continuing with the kernel_thread() code too, I see:
	regs.xcs = __KERNEL_CS | get_kernel_rpl();

which maybe contradicts ur explanation ? (maybe I'm wrong, who knows).

I'll wait for some high food chain member (Greg, Arjan, Randy ?) to confirm our
thoughts, if no one replied, I'll post the question in LKML and keep you
informed. 

Thanks alot, 

-- 
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