On Tuesday, April 12, 2016 at 2:28:54 PM UTC-4,
robert...@yahoo.com wrote:
> On Tue, 12 Apr 2016 08:18:18 -0700 (PDT), "Rick C. Hodgin"
> <
rick.c...@gmail.com> wrote:
>
> >On Tuesday, April 12, 2016 at 12:32:03 AM UTC-4,
robert...@yahoo.com wrote:
> >> On Mon, 11 Apr 2016 20:25:43 -0700 (PDT), "Rick C. Hodgin"
> >> <
rick.c...@gmail.com> wrote:
> >>
> >> >Why didn't the Intel designers reserve some location in memory for
> >> >a triple fault handler? One which would allow the system memory to
> >> >be dumped to disk or output device if the condition arose?
> >> >
> >> >Why just reboot? Seems improper.
> >>
> >>
> >> They already have a double fault handler. Those should already never
> >> occur, but have a handler in case they do. What would be the point of
> >> triple, quadruple, pentuple, etc. fault handlers? If the OS
> >> implementers couldn't set up the double fault handler correctly (and
> >> remember, the code only has to get to the first instruction of the
> >> double fault handler before that no longer applies), what makes you
> >> think that a triple fault handler will be correctly implemented?
> >
> >There are slots defined in the TSS for multiple stack segments and
> >offsets. Another could be added for this cause
> >
> >My thinking is that there's some reason why a triple fault occurs.
> >It's an unexpected condition and something's awry.
>
>
> You're missing the point - that what the double fault is for.
No. Double-faults are recoverable, and could be brought about by a
faulty driver only. The rest of the system wouldn't need to go down,
just restart the driver.
> At that
> point the system is already fouled up beyond all hope. And it's the
> double fault handler that should do some logging or attempt some sort
> of recovery.
That's what it does. It will terminate whatever process caused the
issue, including loadable driver modules, and then report the event in
some way for examination.
> What you're asking for is that if the system is so
> screwed up that it can't start the double fault handler, that you're
> going to try again with the triple fault handler.
The double-fault handler is signaled when there's an interrupt to some
vector, and due to whatever cause another interrupt occurs.
These are completely recoverable in most situations. It's why there's
a dedicated handler for it. It were always a fatal condition, the 386
designers would've had it reboot then. It's not always fatal, so it
has provided recovery mechanisms.
> What's the point?
> And if you do that, why not a quadruple fault handler to clean up if
> *that* fails?
When a triple fault occurs, something unexpected has occurred beyond a
normal degree of unexpectedness. It is expected that loadable modules
and drivers could fail, so the kernel is designed to catch those errors
and terminate those processes.
When a triple fault occurs, however, something has gone completely awry,
and there's a reason for it that wasn't previously accounted for.
It is desirable to be able to flush memory to disk, or to output to some
debug port, so that an inspection of the machine could be made post-
mortem.
> >And as a result,
> >the conditions which brought about the total collapse may want to be
> >examined. The addition of a triple fault handler would put the
> >machine into a state where it begins executing code at the specified
> >address, using the values from the current TSS which indicate where
> >the stack should go, etc.
>
> That just seems crazy. Why would you try to embed this
> should-never-occur condition in every single TSS? Why not just use
> the interrupt mechanism to select a new TSS for the triple fault?
Because the TSS was created and instantiated when the machine was in a
known, stable state. It would likely have been setup properly.
I'm not opposed to the idea of having a special global interrupt vector
for the triple-fault condition. A single internal register would work.
That would be fine with me.
> >In this case, it would be in a state where every subsequent failure
> >does not do anything except restart at the values indicated in the
> >TSS, and signal a pin that it's in a triple fault condition. By
> >toggling the triple fault pin repeatedly, an external monitoring
> >device could then force the reboot.
>
> Most likely that will just lead to loops of triple faults should you
> ever get to such a point.
The area of memory which is reserved for the triple fault handler, a
relatively small block of probably only 1 KB max, could be protected
by the hardware so that it's not able to be written to unless a particular
RING-0 protocol is followed. This would prevent it from being accidentally
overwritten by an errant program, and would exist for this purpose (to be
able to write out memory should the condition occur).
When I was developing my kernel, I had triple faults on a regular basis.
I never knew why. I wound up doing silly things like inserting:
; Display a message "made it here" on-screen, and then
; entering an infinite loop so I can see where the error
; was occurring.
@@:
jmp @B
Having an image of what was in memory would've aided in trying to track
down where the error occurred. Knowing at least the CS selector, and
EIP would've been beneficial, for example.
Perhaps it would be enough to have those pushed out on the address and
data pins so they can be read externally when the triple-fault pin was
high, though the stack trace would also be desirable, as would the code
that existed at those locations, and the memory they pointed to.
It's not in a fatal state at a double-fault. It has the potential of
being in a fatal state, but it is still potentially recoverable. When
it reaches the triple fault state, that's when it's beyond hope, and
that's why I think it should have this ability, because without it
everything about the current machine environment is lost, but with it
the current machine environment can be saved and examined post-mortem.
> >I'm thinking of my implementation of LibSF 386-x40, and what I want the
> >CPU to do when it reaches code which causes a triple fault.