Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 3 Oct 2010 13:52:18 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r213382 - head/sys/amd64/amd64
Message-ID:  <201010031352.o93DqIjS077328@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Sun Oct  3 13:52:17 2010
New Revision: 213382
URL: http://svn.freebsd.org/changeset/base/213382

Log:
  The makectx() function, used by kdb_trap() to reconstruct pcb from
  trap frame when trap initiated kdb entry, incorrectly calculated the
  value of %rsp for trapped thread.
  
  According to Intel(R) 64 and IA-32 Architectures Software Developer's Manual
  Volume 3A: System Programming Guide, Part 1, rev. 035, 6.14.2 64-Bit Mode
  Stack Frame, "64-bit mode ... pushes SS:RSP unconditionally, rather than
  only on a CPL change."
  Even assuming the conditional push of the %ss:%rsp, the calculation
  was still wrong because sizeof(tf_ss) + sizeof(tf_rsp) == 16 on amd64.
  
  Always use the tf_rsp from trap frame. The change supposedly fixes
  stepping when using kgdb backend for kdb.
  
  Submitted by:	Zhouyi Zhou <zhouzhouyi gmail com>
  PR:	amd64/151167
  Reviewed by:	avg
  MFC after:	1 week

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

Modified: head/sys/amd64/amd64/machdep.c
==============================================================================
--- head/sys/amd64/amd64/machdep.c	Sun Oct  3 13:13:10 2010	(r213381)
+++ head/sys/amd64/amd64/machdep.c	Sun Oct  3 13:52:17 2010	(r213382)
@@ -1799,7 +1799,7 @@ makectx(struct trapframe *tf, struct pcb
 	pcb->pcb_rbp = tf->tf_rbp;
 	pcb->pcb_rbx = tf->tf_rbx;
 	pcb->pcb_rip = tf->tf_rip;
-	pcb->pcb_rsp = (ISPL(tf->tf_cs)) ? tf->tf_rsp : (long)(tf + 1) - 8;
+	pcb->pcb_rsp = tf->tf_rsp;
 }
 
 int



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