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_ */
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to