Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 08 May 2003 08:15:22 -0700
From:      Peter Wemm <peter@wemm.org>
To:        John Baldwin <jhb@FreeBSD.org>
Cc:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   Re: PERFORCE change 30777 for review 
Message-ID:  <20030508151522.36B8D2A8AB@canning.wemm.org>
In-Reply-To: <XFMail.20030508103950.jhb@FreeBSD.org> 

next in thread | previous in thread | raw e-mail | index | archive | help
John Baldwin wrote:
> 
> On 08-May-2003 Peter Wemm wrote:
> > http://perforce.freebsd.org/chv.cgi?CH=30777
> > 
> > Change 30777 by peter@peter_overcee on 2003/05/08 01:21:28
> > 
> >       Change the page IDTVEC back to an interrupt gate instead of a trap
> >       gate.  Otherwise we could preempt and %cr2 could be reused on another
> >       process when it faults.
> > 
> > Affected files ...
> > 
> > .. //depot/projects/hammer/sys/amd64/amd64/machdep.c#12 edit
> > .. //depot/projects/hammer/sys/amd64/amd64/trap.c#6 edit
> > 
> > Differences ...
> > 
> > ==== //depot/projects/hammer/sys/amd64/amd64/machdep.c#12 (text+ko) ====
> > 
> > @@ -1219,7 +1219,7 @@
> >       setidt(11, &IDTVEC(missing),  SDT_SYSTGT, SEL_KPL, 0);
> >       setidt(12, &IDTVEC(stk),  SDT_SYSTGT, SEL_KPL, 0);
> >       setidt(13, &IDTVEC(prot),  SDT_SYSTGT, SEL_KPL, 0);
> > -     setidt(14, &IDTVEC(page),  SDT_SYSTGT, SEL_KPL, 0);
> > +     setidt(14, &IDTVEC(page),  SDT_SYSIGT, SEL_KPL, 0);
> >       setidt(15, &IDTVEC(rsvd),  SDT_SYSTGT, SEL_KPL, 0);
> >       setidt(16, &IDTVEC(fpu),  SDT_SYSTGT, SEL_KPL, 0);
> >       setidt(17, &IDTVEC(align), SDT_SYSTGT, SEL_KPL, 0);
> > 
> > ==== //depot/projects/hammer/sys/amd64/amd64/trap.c#6 (text+ko) ====
> > 
> > @@ -213,9 +213,17 @@
> >                * do the VM lookup, so just consider it a fatal trap so the
> >                * kernel can print out a useful trap message and even get
> >                * to the debugger.
> > +              *
> > +              * Note that T_PAGEFLT is registered as an interrupt gate.  T
    his
> > +              * is just like a trap gate, except interrupts are disabled. 
     This
> > +              * happens to be critically important, because we could other
    wise
> > +              * preempt and run another process that may cause %cr2 to be
> > +              * clobbered for something else.
> >                */
> >               eva = rcr2();
> > -             if (PCPU_GET(spinlocks) != NULL)
> > +             if (PCPU_GET(spinlocks) == NULL)
> > +                     enable_intr();
> > +             else
> >                       trap_fatal(&frame, eva);
> >       }
> 
> The spinlocks check only works if witness is on.  What you want to
> do is check td_critnest > 0 instead.

Hmm.  I was just going by the i386 code.  Is that wrong too, or is this
because I'm using the cheat implementation of the nonlazy critical masking?

Cheers,
-Peter
--
Peter Wemm - peter@wemm.org; peter@FreeBSD.org; peter@yahoo-inc.com
"All of this is for nothing if we don't go to the stars" - JMS/B5



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030508151522.36B8D2A8AB>