Bug 224872 - powerpc64: ddb breakpoints throwing a fast kernel trap
Summary: powerpc64: ddb breakpoints throwing a fast kernel trap
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: powerpc Any
: --- Affects Only Me
Assignee: freebsd-ppc mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-01-03 17:53 UTC by Breno Leitao
Modified: 2019-06-05 14:20 UTC (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Breno Leitao 2018-01-03 17:53:06 UTC
Trying to use DDB on powerpc64, I found that it throws a 0x400 exception.

OK boot -d
Booting...
Kernel entry at 0x102620 ...
KDB: debugger backends: ddb
KDB: current backend: ddb
KDB: enter: Boot flags requested debugger
[ thread pid 0 tid 0 ]
Stopped at      .kdb_enter+0x60:        ld      r2, r1, 0x28


db> break platform_smp_start_cpu
db> continue

fatal kernel trap:

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

[ thread pid 0 tid 0 ]
Stopped at      0x426f6f7420666c60
Comment 1 Justin Hibbits freebsd_committer 2018-01-03 18:06:18 UTC
0x426f6f7420666c60 Looks like a string: "Boot fl`"

I don't think anyone in powerpc-land has tried breakpoints in DDB recently.
Comment 2 Leonardo Bianconi 2018-12-21 15:15:48 UTC
This issue already has a solution: https://reviews.freebsd.org/D14484, but need to be tested in a 32bit machine.
If someone has access to a 32bit machine, please, could test it?
Comment 3 Mark Millard 2018-12-21 19:45:46 UTC
(In reply to Leonardo Bianconi from comment #2)

At least on old PowerMac G5's, 32-bit powerpc FreeBSD can boot
and run the 64-bit capable G5's. So some of the testing might
be able to be done that way?
Comment 4 Brandon Bergren 2019-01-07 22:21:12 UTC
I was able to verify this fix on my (32-bit) iBook G4. (Built without vt so the keyboard would work in early ddb)

Looks good here.
Comment 5 commit-hook freebsd_committer 2019-02-04 16:02:17 UTC
A commit references this bug:

Author: luporl
Date: Mon Feb  4 16:02:04 UTC 2019
New revision: 343744
URL: https://svnweb.freebsd.org/changeset/base/343744

Log:
  powerpc64: Add a trap stack area

  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.

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

  PR:		224872
  Submitted by:	breno.leitao_gmail.com
  Reviewed by:	jhibbits
  Differential Revision:	https://reviews.freebsd.org/D14484

Changes:
  head/sys/powerpc/aim/locore32.S
  head/sys/powerpc/aim/locore64.S
  head/sys/powerpc/aim/trap_subr32.S
  head/sys/powerpc/aim/trap_subr64.S
Comment 6 commit-hook freebsd_committer 2019-06-05 14:20:10 UTC
A commit references this bug:

Author: luporl
Date: Wed Jun  5 14:19:55 UTC 2019
New revision: 348690
URL: https://svnweb.freebsd.org/changeset/base/348690

Log:
  MFC r343744:

  powerpc64: Add a trap stack area

  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.

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

  PR:             224872
  Submitted by:   breno.leitao_gmail.com
  Reviewed by:    jhibbits
  Differential Revision:  https://reviews.freebsd.org/D14484

Changes:
_U  stable/12/
  stable/12/sys/powerpc/aim/locore32.S
  stable/12/sys/powerpc/aim/locore64.S
  stable/12/sys/powerpc/aim/trap_subr32.S
  stable/12/sys/powerpc/aim/trap_subr64.S