From owner-svn-src-all@freebsd.org Fri Sep 16 07:09:37 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 375BCBDC4C2; Fri, 16 Sep 2016 07:09:37 +0000 (UTC) (envelope-from bde@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id EB88BE1F; Fri, 16 Sep 2016 07:09:36 +0000 (UTC) (envelope-from bde@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u8G79aAH091772; Fri, 16 Sep 2016 07:09:36 GMT (envelope-from bde@FreeBSD.org) Received: (from bde@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u8G79Z99091770; Fri, 16 Sep 2016 07:09:35 GMT (envelope-from bde@FreeBSD.org) Message-Id: <201609160709.u8G79Z99091770@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bde set sender to bde@FreeBSD.org using -f From: Bruce Evans Date: Fri, 16 Sep 2016 07:09:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r305865 - in head/sys: amd64/amd64 x86/include X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Sep 2016 07:09:37 -0000 Author: bde Date: Fri Sep 16 07:09:35 2016 New Revision: 305865 URL: https://svnweb.freebsd.org/changeset/base/305865 Log: Fix decoding of tf_rsp on amd64, and move TF_HAS_STACKREGS() to the i386-only section, and fix a comment about the amd64 kernel trapframe not having stackregs. tf_rsp doesn't need decoding on amd64, but had an old clone of i386 code to do this in 1 place, and since the amd64 kernel trapframe does have stackregs, the result was an off-by-16 error for %rsp in an error message. Modified: head/sys/amd64/amd64/trap.c head/sys/x86/include/frame.h Modified: head/sys/amd64/amd64/trap.c ============================================================================== --- head/sys/amd64/amd64/trap.c Fri Sep 16 06:31:10 2016 (r305864) +++ head/sys/amd64/amd64/trap.c Fri Sep 16 07:09:35 2016 (r305865) @@ -776,7 +776,6 @@ trap_fatal(frame, eva) { int code, ss; u_int type; - long esp; struct soft_segment_descriptor softseg; char *msg; @@ -807,14 +806,8 @@ trap_fatal(frame, eva) } printf("instruction pointer = 0x%lx:0x%lx\n", frame->tf_cs & 0xffff, frame->tf_rip); - if (TF_HAS_STACKREGS(frame)) { - ss = frame->tf_ss & 0xffff; - esp = frame->tf_rsp; - } else { - ss = GSEL(GDATA_SEL, SEL_KPL); - esp = (long)&frame->tf_rsp; - } - printf("stack pointer = 0x%x:0x%lx\n", ss, esp); + ss = frame->tf_ss & 0xffff; + printf("stack pointer = 0x%x:0x%lx\n", ss, frame->tf_rsp); printf("frame pointer = 0x%x:0x%lx\n", ss, frame->tf_rbp); printf("code segment = base 0x%lx, limit 0x%lx, type 0x%x\n", softseg.ssd_base, softseg.ssd_limit, softseg.ssd_type); Modified: head/sys/x86/include/frame.h ============================================================================== --- head/sys/x86/include/frame.h Fri Sep 16 06:31:10 2016 (r305864) +++ head/sys/x86/include/frame.h Fri Sep 16 07:09:35 2016 (r305865) @@ -98,6 +98,15 @@ struct trapframe_vm86 { int tf_vm86_fs; int tf_vm86_gs; }; + +/* + * This alias for the MI TRAPF_USERMODE() should be used when we don't + * care about user mode itself, but need to know if a frame has stack + * registers. The difference is only logical, but on i386 the logic + * for using TRAPF_USERMODE() is complicated by sometimes treating vm86 + * bioscall mode (which is a special ring 3 user mode) as kernel mode. + */ +#define TF_HAS_STACKREGS(tf) TRAPF_USERMODE(tf) #endif /* __i386__ */ #ifdef __amd64__ @@ -136,7 +145,7 @@ struct trapframe { register_t tf_rip; register_t tf_cs; register_t tf_rflags; - /* below only when crossing rings (user to kernel) */ + /* the amd64 frame always has the stack registers */ register_t tf_rsp; register_t tf_ss; }; @@ -146,13 +155,4 @@ struct trapframe { #define TF_HASFPXSTATE 0x4 #endif /* __amd64__ */ -/* - * This alias for the MI TRAPF_USERMODE() should be used when we don't - * care about user mode itself, but need to know if a frame has stack - * registers. The difference is only logical, but on i386 the logic - * for using TRAPF_USERMODE() is complicated by sometimes treating vm86 - * bioscall mode (which is a special ring 3 user mode) as kernel mode. - */ -#define TF_HAS_STACKREGS(tf) TRAPF_USERMODE(tf) - #endif /* _MACHINE_FRAME_H_ */