Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 8 Nov 2018 20:48:45 +0000 (UTC)
From:      Justin Hibbits <jhibbits@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r340262 - head/sys/powerpc/powerpc
Message-ID:  <201811082048.wA8KmjRd054478@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhibbits
Date: Thu Nov  8 20:48:44 2018
New Revision: 340262
URL: https://svnweb.freebsd.org/changeset/base/340262

Log:
  powerpc64: Fix "show spr" command on ELFv2 kernels
  
  Summary: When compiling for ELFv2, it is necessary to adjust the offset to
  get_spr and factor in the function prologue to ensure the correct instruction is
  being edited.
  
  Test Plan:
  Before:
  ```
  db> show spr 110
  KDB: reentering
  KDB: stack backtrace:
  0xc008000020fb96e0: at 0xc000000002bb2e34 = kdb_backtrace+0x68
  0xc008000020fb97f0: at 0xc000000002bb3798 = kdb_reenter+0x54
  0xc008000020fb9860: at 0xc000000002f87090 = trap+0x4e4
  0xc008000020fb9990: at 0xc000000002f78a60 = powerpc_interrupt+0x110
  0xc008000020fb9a20: kernel trap 0xe40 by 0xc000000002401978 = get_spr+0x8: srr1=0x9000000000001032
              r1=0xc008000020fb9cd0 cr=0x80009438 xer=0x20040000 ctr=0xc000000002f7b40c r2=0xc0000000037fd000
  saved LR(0xfffffffffffffffb) is invalid.
  ```
  
  After:
  
  ```
  db> show spr 110
  SPR 272(110): c000000003cae900
  ```
  
  Submitted by:	git_bdragon.rtk0.net
  Differential Revision: https://reviews.freebsd.org/D17813

Modified:
  head/sys/powerpc/powerpc/machdep.c

Modified: head/sys/powerpc/powerpc/machdep.c
==============================================================================
--- head/sys/powerpc/powerpc/machdep.c	Thu Nov  8 20:31:12 2018	(r340261)
+++ head/sys/powerpc/powerpc/machdep.c	Thu Nov  8 20:48:44 2018	(r340262)
@@ -530,6 +530,10 @@ DB_SHOW_COMMAND(spr, db_show_spr)
 	saved_sprno = sprno = (intptr_t) addr;
 	sprno = ((sprno & 0x3e0) >> 5) | ((sprno & 0x1f) << 5);
 	p = (uint32_t *)(void *)&get_spr;
+#if defined(_CALL_ELF) && _CALL_ELF == 2
+	/* Account for ELFv2 function prologue. */
+	p += 2;
+#endif
 	*p = (*p & ~0x001ff800) | (sprno << 11);
 	__syncicache(get_spr, cacheline_size);
 	spr = get_spr(sprno);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201811082048.wA8KmjRd054478>