Page MenuHomeFreeBSD

powerpc64: Add a trap stack area
ClosedPublic

Authored by breno.leitao_gmail.com on Feb 23 2018, 5:07 PM.

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

Repository
rS FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

This comment was removed by breno.leitao_gmail.com.
This comment was removed by breno.leitao_gmail.com.
jhibbits added inline comments.May 3 2018, 7:55 PM
sys/powerpc/aim/locore32.S
62 ↗(On Diff #39754)

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 ↗(On Diff #39754)

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.

luporl added a subscriber: luporl.Jan 7 2019, 7:45 PM

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

luporl added a comment.Feb 4 2019, 3:21 PM

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

jhibbits accepted this revision.Feb 4 2019, 3:42 PM

Looks fine to me now.

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.