TARGET_ARCH=powerpc: how to cause a dump from kernel thread without disturbing that thread's stack?

Mark Millard markmi at dsl-only.net
Tue May 23 06:33:51 UTC 2017


I've been trying to track down an occasional
kernel panic on an old PowerMac G5 so-called
"Quad Core" used with 32-bit PowerPC FreeBSD.

The panics report absurdly large exception
figures and such --and it turns out the
content matches some very low memory (not
necessarily properly aligned for its starting
address).

The following is an as-if investigative example.
The eventual details may  differ.

But, presuming that theses tests in these places
were appropriate, I'd like to be able to cause a
dump without making calls that update the contents
of the stack for the kernel thread: I want see the
original stack contents in the dump for its history.
content. The calls to panic in the example code
below would disturb the history available on the
kernel-thread's stack, something I'd like to avoid.

Is there a known FreeBSD technique for preserving
such memory contents when getting a dump at a
specific place?

void
powerpc_interrupt(struct trapframe *framep)
{
        struct thread *td;
        struct trapframe *oldframe;
        register_t ee;

        td = curthread;

if ((void*)framep <= (void*)0x1000) panic("0:bad framep: %p\n", (void*)framep);
if (0x2f00 <= framep->exc) panic("0:bad framep->exc: %x (%p)\n", framep->exc, (void*)framep);

        CTR2(KTR_INTR, "%s: EXC=%x", __func__, framep->exc);

        switch (framep->exc) {
. . .
        default:
                /* Re-enable interrupts if applicable. */
                ee = framep->srr1 & PSL_EE;
                if (ee != 0)
                        mtmsr(mfmsr() | ee);

if ((void*)framep <= (void*)0x1000) panic("1:bad framep: %p\n", (void*)framep);
if (0x2f00 <= framep->exc) panic("1:bad framep->exc: %x (%p)\n", framep->exc, (void*)framep);

                trap(framep);
        }
}


===
Mark Millard
markmi at dsl-only.net



More information about the freebsd-hackers mailing list