From owner-freebsd-amd64@FreeBSD.ORG Sun Oct 3 03:20:03 2010 Return-Path: Delivered-To: freebsd-amd64@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4FFA01065670 for ; Sun, 3 Oct 2010 03:20:03 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 2E31F8FC15 for ; Sun, 3 Oct 2010 03:20:03 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id o933K3VG010562 for ; Sun, 3 Oct 2010 03:20:03 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id o933K3EY010561; Sun, 3 Oct 2010 03:20:03 GMT (envelope-from gnats) Resent-Date: Sun, 3 Oct 2010 03:20:03 GMT Resent-Message-Id: <201010030320.o933K3EY010561@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-amd64@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Zhouyi Zhou Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3D241106564A for ; Sun, 3 Oct 2010 03:10:05 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id 2CAFF8FC08 for ; Sun, 3 Oct 2010 03:10:05 +0000 (UTC) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.3/8.14.3) with ESMTP id o933A4ix095897 for ; Sun, 3 Oct 2010 03:10:04 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.3/8.14.3/Submit) id o933A41i095896; Sun, 3 Oct 2010 03:10:04 GMT (envelope-from nobody) Message-Id: <201010030310.o933A41i095896@www.freebsd.org> Date: Sun, 3 Oct 2010 03:10:04 GMT From: Zhouyi Zhou To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 X-Mailman-Approved-At: Sun, 03 Oct 2010 03:26:43 +0000 Cc: Subject: amd64/151167: amd64 remote debug fails X-BeenThere: freebsd-amd64@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the AMD64 platform List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Oct 2010 03:20:03 -0000 >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 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: