From owner-freebsd-hackers Tue Sep 18 21:29:33 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from peter3.wemm.org (c1315225-a.plstn1.sfba.home.com [24.14.150.180]) by hub.freebsd.org (Postfix) with ESMTP id 6C62337B408; Tue, 18 Sep 2001 21:29:29 -0700 (PDT) Received: from overcee.netplex.com.au (overcee.wemm.org [10.0.0.3]) by peter3.wemm.org (8.11.0/8.11.0) with ESMTP id f8J4TTM97574; Tue, 18 Sep 2001 21:29:29 -0700 (PDT) (envelope-from peter@wemm.org) Received: from wemm.org (localhost [127.0.0.1]) by overcee.netplex.com.au (Postfix) with ESMTP id F229F380A; Tue, 18 Sep 2001 21:29:28 -0700 (PDT) (envelope-from peter@wemm.org) X-Mailer: exmh version 2.3.1 01/18/2001 with nmh-1.0.4 To: John Baldwin Cc: hackers@FreeBSD.ORG Subject: Re: JKH Project: x86: pcb_ext In-Reply-To: Date: Tue, 18 Sep 2001 21:29:28 -0700 From: Peter Wemm Message-Id: <20010919042928.F229F380A@overcee.netplex.com.au> Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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 - peter@FreeBSD.org; peter@yahoo-inc.com; peter@netplex.com.au "All of this is for nothing if we don't go to the stars" - JMS/B5 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message