Re: LDT currently unused?

Hans Lermen (lermen@elserv.ffm.fgan.de)
Fri, 12 Jul 1996 11:30:19 +0200 (MET DST)


On 10 Jul 1996, Florian Weimer wrote:

> I'm currently developing an application which needs call gates to
> kernel mode. These call gates are stored in the LDT of a certain
> process at a fixed position (currently, the first six descriptors are
> used by my program). Do I have to expect any conflicts with existing
> software? Are there any libraries which use the LDT?

1. LDT is _NOT_ 'unused'. The kernel uses the first 3 ones in the default LDT.
'Wine' as well as 'DOSemu' use LDT-entries above those.
The default LDT is static, if you create your own entries, the kernel
will allocate a private 8K LDT for the process, taking over the contents
of the default LDT.

2. The syscall you need to fiddle with LTD-stuff is sys_modify_ldt (No.123).
You have to use it directly (no lib-function available)) by defining:

_syscall3(int, modify_ldt, int, func, void *, ptr, unsigned long, bytecount)

Have a look at Wine (memory/ldt.c) or DOSemu (src/dosext/dpmi/dpmi.c)

3. Though the CPU allowes you to have them in the LDT, Call-Gates are
refused by sys_modify_ldt (ldt_info.contents == 3), which will return
-EINVAL, if you anyway want to create one.

4. All other LDT manipulation than using sys_modify_ldt are
refused by the kernel.

Hans
<lermen@fgan.de>