From owner-cvs-all@FreeBSD.ORG Mon Apr 11 18:54:05 2005 Return-Path: Delivered-To: cvs-all@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 312DB16A4CE; Mon, 11 Apr 2005 18:54:05 +0000 (GMT) Received: from mail.vicor-nb.com (bigwoop.vicor-nb.com [208.206.78.2]) by mx1.FreeBSD.org (Postfix) with ESMTP id E3A0A43D1F; Mon, 11 Apr 2005 18:54:03 +0000 (GMT) (envelope-from julian@elischer.org) Received: from [208.206.78.97] (julian.vicor-nb.com [208.206.78.97]) by mail.vicor-nb.com (Postfix) with ESMTP id EE3A47A424; Mon, 11 Apr 2005 11:54:01 -0700 (PDT) Message-ID: <425AC7C9.8050801@elischer.org> Date: Mon, 11 Apr 2005 11:54:01 -0700 From: Julian Elischer User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.7.5) Gecko/20050218 X-Accept-Language: en, hu MIME-Version: 1.0 To: Bill Paul References: <200504110202.j3B22Z5k014387@repoman.freebsd.org> In-Reply-To: <200504110202.j3B22Z5k014387@repoman.freebsd.org> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit cc: cvs-src@FreeBSD.org cc: src-committers@FreeBSD.org cc: cvs-all@FreeBSD.org Subject: Re: cvs commit: src/sys/compat/ndis hal_var.h kern_ndis.c subr_ndis.cMakefile src/sys/dev/if_ndis if_ndis.c X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Apr 2005 18:54:05 -0000 Bill Paul wrote: >wpaul 2005-04-11 02:02:35 UTC > > > The twist has to do with the fact that Microsoft supports structured > exception handling in kernel mode. On the i386 arch, exception handling > is implemented by hanging an exception registration list off the > Thread Environment Block (TEB), and the TEB is accessed via the %fs > register. The problem is, we use %fs as a pointer to the pcpu stucture, > which means any driver that tries to write through %fs:0 will overwrite > the curthread pointer and make a serious mess of things. > > To get around this, Project Evil now creates a special entry in > the GDT on each processor. When we call into Windows code, a context > switch routine will fix up %fs so it points to our new descriptor, > which in turn points to a fake TEB. When the Windows code returns, > or calls out to an external routine, we swap %fs back again. Currently, > Project Evil makes use of GDT slot 7, which is all 0s by default. > I fully expect someone to jump up and say I can't do that, but I > couldn't find any code that makes use of this entry anywhere. Sadly, > this was the only method I could come up with that worked on both > UP and SMP. (Modifying the LDT works on UP, but becomes incredibly > complicated on SMP.) If necessary, the context switching stuff can > be yanked out while preserving the convention calling wrappers. > > > > Maybe we could emulate $soft and use %fs as a thread pointer instead and have pcpu pointed to via that :-)