John Baldwin wrote:
> Here's a Junior Kernel Hacker project for someone:
>
> - Move pcb_ext and pcb_ldt out of the pcb of struct thread and into
> struct mdproc; I.e., you probably want to do something like this:
> - Rename struct pcb_ext to struct proc_tss and struct pcb_ldt to
> struct proc_ldt. (Fixup pcb_ext member names to use a tss_
> prefix instead of ext_)
> - Have a struct mdproc as so:
>
> struct mdproc {
> struct proc_tss *md_tss;
> struct proc_ldt *md_ldt;
> }
>
> Prior to KSE this was just annoyance but wasn't an actual problem. With KSE
> threads are temporary, whereas the ldt and tss are per-process properties
> that need to stick around.
Just so that somebody doesn't get a nasty suprise.. this is not as
simple as it sounds.. There are several configurations of "extended" pcb,
including having a seperate i386tss.. The nasty part is that some of this
is per-thread because there is a per-thread kernel stack pointer embedded
in it.
The upshot of this is that there probably needs to be a "master" pcb extension
that gets propagated to thread children.
In particular, look at these fragmets of swtch.s:
movl PCB_EXT(%edx), %edi /* new tss descriptor */
[..]
movl %edx, PCPU(COMMON_TSS) + TSS_ESP0 /* stack is below pcb */
[..]
movl PCPU(TSS_GDT), %ebx /* entry in GDT */
movl 0(%edi), %eax
movl %eax, 0(%ebx)
movl 4(%edi), %eax
movl %eax, 4(%ebx)
movl $GPROC0_SEL*8, %esi /* GSEL(entry, SEL_KPL) */
ltr %si
I think this is actually broken right now since the tss_esp0 is pointing
to the wrong location.. It's actually pointing to an unmapped page.
And note how we install the per-thread tss extension pointer into the
per-cpu tss slot in the gdt.
And, sys_machdep.c:
ext->ext_tss.tss_esp0 = td->td_kstack + ctob(KSTACK_PAGES) -
sizeof(struct pcb) - 16;
We cannot entirely move the extended tss into into a mdproc since td_kstack
is different in each thread.
The more I think about it, the right place may be the kse, since that outlives
the threads and is per-cpu unlike the process.
Or, we just say "no pcb extensions for kse processes".
Cheers,
-Peter
--
Peter Wemm - [EMAIL PROTECTED]; [EMAIL PROTECTED]; [EMAIL PROTECTED]
"All of this is for nothing if we don't go to the stars" - JMS/B5
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message