DragonFly BSD
DragonFly kernel List (threaded) for 2004-04
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: nvidia machdep.c patch still useful ?

From: David Rhodus <drhodus@xxxxxxxxxxx>
Date: Wed, 7 Apr 2004 14:20:31 -0400

On Apr 7, 2004, at 1:47 AM, Matthew Dillon wrote:

:Hrm. What is the FS segment standardly used for, if anything?
:I'm familiar with Win32's use of it as a per-thread data area. For
:example, "mov eax, fs:[0]" is a common instruction emitted by Win32
:compilers when setting up exception handlers. This caused some problems
:with WINE when some (versions of) OSes would trash FS.

    %fs cannot be set to anything useful by userland, at least I don't
    think it can.  %gs can be set to a user-defined custom segment.

A lot of this is a problem from nvidia because their driver makes use of the %gs register but without saving and restoring it. This is because they are also using the %gs register to maintain their internal thread state. Segment registers generally belong to the operating system. I personally think we should not allow the nvidia driver to use the %gs register, at least until they start doing things a little better and save and restore the %gs inside their driver. I know there are system which they can't grab the %gs segment register on right now.

We are exporting the %fs register to userland using the same
method as %gs right now. So, yes, userland applications can
come along and muck with it. Examples of applications that
make use of the %fs register are WINE and OpenGL. One
somewhat particular item is you will have a time running an
OpenGL program inside WINE as one will end up self
corrupting the other by trashing the %fs register.


233 #define LSYS5CALLS_SEL 0 /* forced by intel BCS */
234 #define LSYS5SIGR_SEL 1
235 #define L43BSDCALLS_SEL 2 /* notyet */
236 #define LUCODE_SEL 3
237 #define LSOL26CALLS_SEL 4 /* Solaris >= 2.6 system call gate */
238 #define LUDATA_SEL 5
239 /* separate stack, es,fs,gs sels ? */
240 /* #define LPOSIXCALLS_SEL 5*/ /* notyet */
241 #define LBSDICALLS_SEL 16 /* BSDI system call gate */
242 #define NLDT (LBSDICALLS_SEL + 1)

LUCODE_SEL is used by kernel to load _ucodesel to user %cs
LUDATA_SEL is used by kernel to load _udatasel to user %ds, %es, %fs, %gs.


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