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.
This commit is contained in:
Bruce Evans 2016-09-16 07:09:35 +00:00
parent 1e24fd3bd9
commit 5904b5a6f2
2 changed files with 12 additions and 19 deletions

View File

@ -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);

View File

@ -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_ */