Page MenuHomeFreeBSD

powerpc64: Add a trap stack area
ClosedPublic

Authored by breno.leitao_gmail.com on Feb 23 2018, 5:07 PM.
Referenced Files
F81674769: D14484.diff
Fri, Apr 19, 6:29 PM
Unknown Object (File)
Sat, Mar 30, 12:05 AM
Unknown Object (File)
Sat, Mar 30, 12:05 AM
Unknown Object (File)
Sat, Mar 30, 12:05 AM
Unknown Object (File)
Jan 15 2024, 4:56 PM
Unknown Object (File)
Dec 15 2023, 3:44 PM
Unknown Object (File)
Dec 12 2023, 3:09 AM
Unknown Object (File)
Nov 24 2023, 12:00 AM

Details

Summary

Currently, the trap code switches to the the temporary stack in the dbtrap
section. It works in most cases, but in the beginning of the execution, the
temp stack is being used, as starting in the powerpc_init() code.

In this current scenario, the stack is being overwritten, which causes the
return of breakpoint() to take abnormal execution, as showed in the following
trap:

fatal kernel trap:

exception       = 0x400 (instruction storage interrupt)
virtual address = 0x426f6f7420666c60
srr0            = 0x426f6f7420666c60 (0x426f6f7420666c60)
srr1            = 0x8000000040001032
lr              = 0x426f6f7420666c61 (0x426f6f7420666c61)
curthread       = 0x1441460
pid = 0, comm =

In this case, it loads a string ('boot fla') in the corrupted stack and tried
to jump to this place as it is a valid text address.

This current patchset create a small stack to use by the dbtrap: codepath
avoiding the corruption of the temporary stack.

PR: 224872

Diff Detail

Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 15223
Build 15291: arc lint + arc unit

Event Timeline

sys/powerpc/aim/locore32.S
62

Do you intend this only to be used by debug traps? If so, those are only used when KDB is enabled, so you should wrap this with a \#ifdef KDB, same with the other one.

Add a trap stack area

Added #ifdef when defining trap stack as it will be used only if
KDB is enabled.

sys/powerpc/aim/locore32.S
62

I faced this issue again and realized that it is still in review.
Added #ifdef as requested as the trap stack will only be used if KDB is enabled.

32-bit version of the code is working OK on my iBook G4.

@jhibbits, is this change good to go now? It would be nice to get DDB working on boot.

This revision is now accepted and ready to land.Feb 4 2019, 3:42 PM
This revision was automatically updated to reflect the committed changes.