Date: Sun, 3 Oct 2010 03:10:04 GMT From: Zhouyi Zhou <zhouzhouyi@gmail.com> To: freebsd-gnats-submit@FreeBSD.org Subject: amd64/151167: amd64 remote debug fails Message-ID: <201010030310.o933A41i095896@www.freebsd.org> Resent-Message-ID: <201010030320.o933K3EY010561@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 151167 >Category: amd64 >Synopsis: amd64 remote debug fails >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-amd64 >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sun Oct 03 03:20:02 UTC 2010 >Closed-Date: >Last-Modified: >Originator: Zhouyi Zhou >Release: FreeBSD 8.0 >Organization: Institute of Computing Technology, CAS >Environment: FreeBSD zzy 8.0-RELEASE FreeBSD 8.0-RELEASE #137: Sun Oct 3 14:25:54 UTC 2010 root@zzy:/usr/src/sys/amd64/compile/GENERIC amd64 >Description: When remote debug FreeBSD 8.0 using gdb on a Intel x86_64 machine, the next command will cause kernel panic. >How-To-Repeat: use next command to step over a function all will cause kernel panic for example: Breakpoint 1, fork1 (td=0xffffff0002fce390, flags=20, pages=4, procp=0xffffff804a0afaf0) at ../../../kern/kern_fork.c:283 283 newproc = uma_zalloc(proc_zone, M_WAITOK); (gdb) n >Fix: The problems is in some intel x86_64 machines, the computing the rsp from trap frame is not correct. void makectx(struct trapframe *tf, struct pcb *pcb) { pcb->pcb_r12 = tf->tf_r12; pcb->pcb_r13 = tf->tf_r13; pcb->pcb_r14 = tf->tf_r14; pcb->pcb_r15 = tf->tf_r15; 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; } But according to <Intel 64 and IA-32 Architecutres Software Developer's Manual Volume 3A: System Programming Guide, Part 1> section 5.14.2: (64-bit mode also pushes SS:RSP unconditionally, rather than only on a CPL change). So the function makectx in sys/amd64/amd64/machdep.c should be modified as void makectx(struct trapframe *tf, struct pcb *pcb) { pcb->pcb_r12 = tf->tf_r12; pcb->pcb_r13 = tf->tf_r13; pcb->pcb_r14 = tf->tf_r14; pcb->pcb_r15 = tf->tf_r15; pcb->pcb_rbp = tf->tf_rbp; pcb->pcb_rbx = tf->tf_rbx; pcb->pcb_rip = tf->tf_rip; pcb->pcb_rsp = tf->tf_rsp; } >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201010030310.o933A41i095896>