delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/02/19/16:03:56

X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f
From: Charles Sandmann <sandmann AT clio DOT rice DOT edu>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: DS and ESP
Date: Tue, 19 Feb 2002 12:58:45 CST
Organization: Rice University, Houston TX
Lines: 22
Message-ID: <3c72a065.sandmann@clio.rice.edu>
References: <a4rfgu$sbg$1 AT news DOT tpi DOT pl> <a4t25g$nn0$1 AT antares DOT lu DOT erisoft DOT se> <3c727c49 DOT sandmann AT clio DOT rice DOT edu> <3C729854 DOT 7EBE42E4 AT yahoo DOT com>
NNTP-Posting-Host: clio.rice.edu
X-Trace: joe.rice.edu 1014145694 8205 128.42.105.3 (19 Feb 2002 19:08:14 GMT)
X-Complaints-To: abuse AT rice DOT edu
NNTP-Posting-Date: 19 Feb 2002 19:08:14 GMT
X-NewsEditor: ED-1.5.9
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

> > If the DPMI provider is done correctly either hardware interrupts or
> > even page faults work fine even when the user ESP is invalid.  All of
> > these should be handled on the locked 4Kb DPMI internal stack and
> > never touch the user stack.  So, it turns out that code isn't broken :-)
> 
> Doesn't the interrupt itself to the stack switching code have to
> store a return address on the user stack? and maybe the flags
> too.  Or is that all in the hardware?

The hardware has a built in feature to swap stacks on a change of ring
(priv).  In the case of a hardware interrupt or exception we change
execution to ring 0 (instead of ring 3) which also swaps to an internal
ring 0 stack.  All values are set on that stack (or one which it also
may swap to).  The appropriate "return" will restore the ring 3 stack
as being current.

This is required for stable operation - what would happen if you need to
expand the stack downward (crossing a page boundary) in the middle of
a page fault?  Or an exception?  This is one of the problems with any
"ring 0" DPMI provider - that there is no way to protect against these
type of double faults - so you must do something special to catch them
in which case they are not recoverable.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019