On Thu, 1 Nov 2001, Vlad Romascanu (LMC) wrote:

> hello!
> it seems that in p-mode, if cpl > iopl, popf instructions are not trapped.

correct.

DPMI under DOSEMU runs in normal Linux user space, hence protected mode
with IOPL=0 and CPL=3.

In protected mode popf _never_ traps (except for stack fault), from
the Intel Programmers Manual:

  "... If a POPF instruction is executed with insufficient privilege,
   an exceptions does not occur, but the privileged bits do not change."

> some games like doom and duke3d use popf to reenable interrupts (only when
> sb sound is configured) in a sequence akin to this (code runs in p-mode):
> 
>   pushf

normally without exception in protected mode

>   cli

this gives "general exception" in user space, because CPL>IOPL.
DOSEMU does _not_ set IF due to this, because the Linux kernel won't
allow this on signal return anyway (this would be a security hole).
So, IF remains set and not cleared.

>   ...
>   popf        ; restores if to previous value

this gives no exception, but leaves IF unchanged (set). From the POPF
descriptions of the Intel Programmers Manual:

  "The interrupt flag is altered only when executing at a level at least
   as privileged as the I/O privilege level."

> 
> under window$ nt this freezes the dos session (virtual interrupts are never
> reenabled because popf is not trapped).

We know they are doing weird things :-))

> my question is: how does dosemu work around this limitation?

It should not have any effect except that you can't "protect" parts
of your code from being really interrupted within CLI/STI brackets
(time slice could be given up). However, we do not allow _emulated_
interrupts to happen, so in fact (as we don't get triggered by popf)
we may keep the DPMI programm with emulated interrupts disabled until
the next signal that comes through.

Hans
<[EMAIL PROTECTED]>

-
To unsubscribe from this list: send the line "unsubscribe linux-msdos" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to