State Saving
Because DPMI hosts switch stacks automatically across mode
switches, it is sometimes necessary to use the state
save/restore functions while using the raw mode switch
services. The host will maintain information on the "other"
mode's current state. This information will include the
CS:(E)IP, SS:(E)SP, and segment register values. Since the
DPMI client has no way to directly access these values, it
will need to call the state saving functions when performing
nested mode switches.
For example, during hardware interrupts, the DPMI host will
preserve the real mode's segment registers, CS:EIP, and
SS:ESP on the ring 0 stack. However, they are not pushed on
any stack in the VM -- They are only visible at ring 0.
When the raw mode switch functions are called they will
overwrite the information saved by the host. At this point,
the program would return to the wrong address when the
interrupt returned.