summaryrefslogtreecommitdiffstats
path: root/libexec/save-entropy
diff options
context:
space:
mode:
authorwpaul <wpaul@FreeBSD.org>2005-04-11 02:02:35 +0000
committerwpaul <wpaul@FreeBSD.org>2005-04-11 02:02:35 +0000
commita3b2d3191d684cc192012aa160695992e980f7fc (patch)
treec9baad954353fef64e8c9153b1fbd740ba9a5d42 /libexec/save-entropy
parentdff27787ebafbf9cb586beef441c793c09833c53 (diff)
downloadFreeBSD-src-a3b2d3191d684cc192012aa160695992e980f7fc.zip
FreeBSD-src-a3b2d3191d684cc192012aa160695992e980f7fc.tar.gz
Create new i386 windows/bsd thunking layer, similar to the amd64 thunking
layer, but with a twist. 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. (Fortunately, it looks like Microsoft uses some special epilog/prolog code on amd64 to implement exception handling, so the same nastiness won't be necessary on that arch.) The advantages are: - Any driver that uses %fs as though it were a TEB pointer won't clobber pcpu. - All the __stdcall/__fastcall/__regparm stuff that's specific to gcc goes away. Also, while I'm here, switch NdisGetSystemUpTime() back to using nanouptime() again. It turns out nanouptime() is way more accurate than just using ticks(). On slower machines, the Atheros drivers I tested seem to take a long time to associate due to the loss in accuracy.
Diffstat (limited to 'libexec/save-entropy')
0 files changed, 0 insertions, 0 deletions
OpenPOWER on IntegriCloud