Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 23 Feb 2001 18:21:28 +1100 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        John Baldwin <jhb@FreeBSD.org>
Cc:        Doug Rabson <dfr@nlsystems.com>, cvs-all@FreeBSD.org, cvs-committers@FreeBSD.org
Subject:   Re: cvs commit: src/sys/alpha/alpha swtch.s
Message-ID:  <Pine.BSF.4.21.0102231802020.8957-100000@besplex.bde.org>
In-Reply-To: <XFMail.010222111136.jhb@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 22 Feb 2001, John Baldwin wrote:

> On 22-Feb-01 Doug Rabson wrote:
> > On Thu, 22 Feb 2001, John Baldwin wrote:
> >> Oops, bit too hasty.  There is one remaining MD portion in the alpha
> >> ast() that the ia64 ast() has inherited, we set the p->p_md.md_tf field
> >> to point to the trapframe passed in to ast().  Do you know what it is used
> >> for?
> > 
> > Its used in various places to get at the original trapframe which we
> > entered the kernel with. This is needed for instance in signal delivery
> > and execve handling. The i386 equivalent is p_md.md_regs.
> > 
> > I'm not sure how the i386 code gets away without setting md_regs. Perhaps
> > its always set correctly be whatever happened right before the call to
> > ast().

At least on i386's, it would be a bug to call ast() with any frame other
than the original trap frame or equivalent.  ast() can only be called
when the stack has been unwound to the original frame.  The registers
are in that frame.  p_md.md_registers is just a pointer to the registers
in that frame, for use in subroutines where the original frame is not
directly accessible.

> Well, syscall() and trap() on the alpha already setup p->p_md.md_tf.
> It looks like interrupts don't set it in interrupt(), though that
> could be easily fixed.  syscall() and trap() on i386 setup p->p_md.md_regs.
> Hmm, interrupts on i386 do _not_ set p->p_md.md_regs.  I wonder if this

Setting in interrupt handlers would be a bug except for interrupts from
user mode.

> can lead to a bug if an ast is pending when we return from an interrupt to
> userland.  I.e., if a signal is pending, p->p_md.md_regs would be messed up.

On i386's, it always has the same value (a fixed amount below the top
of the process's kernel stack).  Setting it more than once per process
is pessimal.  Not setting it in ast() usually works because there was
a previous syscall or trap that set it.  Note that there is no bug in
old versions that multiplexed ast() through() trap().  Interrupt
handlers were turned into trap handlers before they called ast(), and
trap() set md_regs.  Interrupt handlers still have a slightly different
frame from trap handlers, so setting md_regs for them doesn't even
make sense until they become trap handlers and call ast().

Bruce


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe cvs-all" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0102231802020.8957-100000>