PERFORCE change 28182 for review
Peter Wemm
peter at FreeBSD.org
Fri Apr 4 22:28:27 PST 2003
http://perforce.freebsd.org/chv.cgi?CH=28182
Change 28182 by peter at peter_overcee on 2003/04/04 22:27:39
some initial cleanups. s/tf_e*/tf_r*/
remove some cruft - POWERFAIL_NMI certainly qualifies
Affected files ...
.. //depot/projects/hammer/sys/x86_64/x86_64/trap.c#18 edit
Differences ...
==== //depot/projects/hammer/sys/x86_64/x86_64/trap.c#18 (text+ko) ====
@@ -47,7 +47,6 @@
#include "opt_ddb.h"
#include "opt_isa.h"
#include "opt_ktrace.h"
-#include "opt_trap.h"
#include <sys/param.h>
#include <sys/bus.h>
@@ -85,11 +84,6 @@
#include <i386/isa/icu.h>
#include <i386/isa/intr_machdep.h>
-#ifdef POWERFAIL_NMI
-#include <sys/syslog.h>
-#include <machine/clock.h>
-#endif
-
#include <ddb/ddb.h>
#include <sys/sysctl.h>
@@ -170,9 +164,6 @@
u_int sticks = 0;
int i = 0, ucode = 0, type, code;
vm_offset_t eva;
-#ifdef POWERFAIL_NMI
- static int lastalert = 0;
-#endif
atomic_add_int(&cnt.v_trap, 1);
type = frame.tf_trapno;
@@ -185,7 +176,7 @@
}
#endif
- if ((frame.tf_eflags & PSL_I) == 0) {
+ if ((frame.tf_rflags & PSL_I) == 0) {
/*
* Buggy application or kernel code has disabled
* interrupts and then trapped. Enabling interrupts
@@ -263,7 +254,7 @@
case T_BPTFLT: /* bpt instruction fault */
case T_TRCTRAP: /* trace trap */
- frame.tf_eflags &= ~PSL_T;
+ frame.tf_rflags &= ~PSL_T;
i = SIGTRAP;
break;
@@ -301,19 +292,6 @@
#ifdef DEV_ISA
case T_NMI:
-#ifdef POWERFAIL_NMI
-#ifndef TIMER_FREQ
-# define TIMER_FREQ 1193182
-#endif
- mtx_lock(&Giant);
- if (time_second - lastalert > 10) {
- log(LOG_WARNING, "NMI: power fail\n");
- sysbeep(TIMER_FREQ/880, hz);
- lastalert = time_second;
- }
- mtx_unlock(&Giant);
- goto userout;
-#else /* !POWERFAIL_NMI */
/* machine/parity/power fail/"kitchen sink" faults */
/* XXX Giant */
if (isa_nmi(code) == 0) {
@@ -331,7 +309,6 @@
} else if (panic_on_nmi)
panic("NMI indicates hardware failure");
break;
-#endif /* POWERFAIL_NMI */
#endif /* DEV_ISA */
case T_OFLOW: /* integer overflow fault */
@@ -401,7 +378,7 @@
* (XXX) so that we can continue, and generate
* a signal.
*/
- if (frame.tf_eip == (int)cpu_switch_load_gs) {
+ if (frame.tf_rip == (long)cpu_switch_load_gs) {
PCPU_GET(curpcb)->pcb_gs = 0;
PROC_LOCK(p);
psignal(p, SIGBUS);
@@ -419,26 +396,26 @@
* selectors and pointers when the user changes
* them.
*/
- if (frame.tf_eip == (int)doreti_iret) {
- frame.tf_eip = (int)doreti_iret_fault;
+ if (frame.tf_rip == (long)doreti_iret) {
+ frame.tf_rip = (long)doreti_iret_fault;
goto out;
}
- if (frame.tf_eip == (int)doreti_popl_ds) {
- frame.tf_eip = (int)doreti_popl_ds_fault;
+ if (frame.tf_rip == (long)doreti_popl_ds) {
+ frame.tf_rip = (long)doreti_popl_ds_fault;
goto out;
}
- if (frame.tf_eip == (int)doreti_popl_es) {
- frame.tf_eip = (int)doreti_popl_es_fault;
+ if (frame.tf_rip == (long)doreti_popl_es) {
+ frame.tf_rip = (long)doreti_popl_es_fault;
goto out;
}
- if (frame.tf_eip == (int)doreti_popl_fs) {
- frame.tf_eip = (int)doreti_popl_fs_fault;
+ if (frame.tf_rip == (long)doreti_popl_fs) {
+ frame.tf_rip = (long)doreti_popl_fs_fault;
goto out;
}
if (PCPU_GET(curpcb) != NULL &&
PCPU_GET(curpcb)->pcb_onfault != NULL) {
- frame.tf_eip =
- (int)PCPU_GET(curpcb)->pcb_onfault;
+ frame.tf_rip =
+ (long)PCPU_GET(curpcb)->pcb_onfault;
goto out;
}
break;
@@ -453,14 +430,14 @@
* problem here and not every time the kernel is
* entered.
*/
- if (frame.tf_eflags & PSL_NT) {
- frame.tf_eflags &= ~PSL_NT;
+ if (frame.tf_rflags & PSL_NT) {
+ frame.tf_rflags &= ~PSL_NT;
goto out;
}
break;
case T_TRCTRAP: /* trace trap */
- if (frame.tf_eip == (int)IDTVEC(lcall_syscall)) {
+ if (frame.tf_rip == (long)IDTVEC(lcall_syscall)) {
/*
* We've just entered system mode via the
* syscall lcall. Continue single stepping
@@ -469,12 +446,12 @@
*/
goto out;
}
- if (frame.tf_eip == (int)IDTVEC(lcall_syscall) + 1) {
+ if (frame.tf_rip == (long)IDTVEC(lcall_syscall) + 1) {
/*
* The syscall handler has now saved the
* flags. Stop single stepping it.
*/
- frame.tf_eflags &= ~PSL_T;
+ frame.tf_rflags &= ~PSL_T;
goto out;
}
/*
@@ -494,16 +471,6 @@
#ifdef DEV_ISA
case T_NMI:
-#ifdef POWERFAIL_NMI
- mtx_lock(&Giant);
- if (time_second - lastalert > 10) {
- log(LOG_WARNING, "NMI: power fail\n");
- sysbeep(TIMER_FREQ/880, hz);
- lastalert = time_second;
- }
- mtx_unlock(&Giant);
- goto out;
-#else /* !POWERFAIL_NMI */
/* XXX Giant */
/* machine/parity/power fail/"kitchen sink" faults */
if (isa_nmi(code) == 0) {
@@ -521,7 +488,6 @@
} else if (panic_on_nmi == 0)
goto out;
/* FALLTHROUGH */
-#endif /* POWERFAIL_NMI */
#endif /* DEV_ISA */
}
@@ -630,7 +596,7 @@
if (td->td_intr_nesting_level == 0 &&
PCPU_GET(curpcb) != NULL &&
PCPU_GET(curpcb)->pcb_onfault != NULL) {
- frame->tf_eip = (int)PCPU_GET(curpcb)->pcb_onfault;
+ frame->tf_rip = (long)PCPU_GET(curpcb)->pcb_onfault;
return (0);
}
trap_fatal(frame, eva);
@@ -667,31 +633,31 @@
code & PGEX_P ? "protection violation" : "page not present");
}
printf("instruction pointer = 0x%x:0x%x\n",
- frame->tf_cs & 0xffff, frame->tf_eip);
+ frame->tf_cs & 0xffff, frame->tf_rip);
if (ISPL(frame->tf_cs) == SEL_UPL) {
ss = frame->tf_ss & 0xffff;
- esp = frame->tf_esp;
+ esp = frame->tf_rsp;
} else {
ss = GSEL(GDATA_SEL, SEL_KPL);
- esp = (int)&frame->tf_esp;
+ esp = (long)&frame->tf_rsp;
}
printf("stack pointer = 0x%x:0x%x\n", ss, esp);
- printf("frame pointer = 0x%x:0x%x\n", ss, frame->tf_ebp);
+ printf("frame pointer = 0x%x:0x%x\n", ss, frame->tf_rbp);
printf("code segment = base 0x%x, limit 0x%x, type 0x%x\n",
softseg.ssd_base, softseg.ssd_limit, softseg.ssd_type);
printf(" = DPL %d, pres %d, def32 %d, gran %d\n",
softseg.ssd_dpl, softseg.ssd_p, softseg.ssd_def32,
softseg.ssd_gran);
printf("processor eflags = ");
- if (frame->tf_eflags & PSL_T)
+ if (frame->tf_rflags & PSL_T)
printf("trace trap, ");
- if (frame->tf_eflags & PSL_I)
+ if (frame->tf_rflags & PSL_I)
printf("interrupt enabled, ");
- if (frame->tf_eflags & PSL_NT)
+ if (frame->tf_rflags & PSL_NT)
printf("nested task, ");
- if (frame->tf_eflags & PSL_RF)
+ if (frame->tf_rflags & PSL_RF)
printf("resume, ");
- printf("IOPL = %d\n", (frame->tf_eflags & PSL_IOPL) >> 12);
+ printf("IOPL = %d\n", (frame->tf_rflags & PSL_IOPL) >> 12);
printf("current process = ");
if (curproc) {
printf("%lu (%s)\n",
@@ -751,7 +717,7 @@
struct sysent *callp;
struct thread *td = curthread;
struct proc *p = td->td_proc;
- register_t orig_tf_eflags;
+ register_t orig_tf_rflags;
u_int sticks;
int error;
int narg;
@@ -779,9 +745,9 @@
cred_update_thread(td);
if (p->p_flag & P_THREADED)
thread_user_enter(p, td);
- params = (caddr_t)frame.tf_esp + sizeof(int);
- code = frame.tf_eax;
- orig_tf_eflags = frame.tf_eflags;
+ params = (caddr_t)frame.tf_rsp + sizeof(int);
+ code = frame.tf_rax;
+ orig_tf_rflags = frame.tf_rflags;
if (p->p_sysent->sv_prepsyscall) {
/*
@@ -842,7 +808,7 @@
if (error == 0) {
td->td_retval[0] = 0;
- td->td_retval[1] = frame.tf_edx;
+ td->td_retval[1] = frame.tf_rdx;
STOPEVENT(p, S_SCE, narg);
@@ -851,9 +817,9 @@
switch (error) {
case 0:
- frame.tf_eax = td->td_retval[0];
- frame.tf_edx = td->td_retval[1];
- frame.tf_eflags &= ~PSL_C;
+ frame.tf_rax = td->td_retval[0];
+ frame.tf_rdx = td->td_retval[1];
+ frame.tf_rflags &= ~PSL_C;
break;
case ERESTART:
@@ -861,7 +827,7 @@
* Reconstruct pc, assuming lcall $X,y is 7 bytes,
* int 0x80 is 2 bytes. We saved this in tf_err.
*/
- frame.tf_eip -= frame.tf_err;
+ frame.tf_rip -= frame.tf_err;
break;
case EJUSTRETURN:
@@ -874,8 +840,8 @@
else
error = p->p_sysent->sv_errtbl[error];
}
- frame.tf_eax = error;
- frame.tf_eflags |= PSL_C;
+ frame.tf_rax = error;
+ frame.tf_rflags |= PSL_C;
break;
}
@@ -888,8 +854,8 @@
/*
* Traced syscall.
*/
- if (orig_tf_eflags & PSL_T) {
- frame.tf_eflags &= ~PSL_T;
+ if (orig_tf_rflags & PSL_T) {
+ frame.tf_rflags &= ~PSL_T;
trapsignal(td, SIGTRAP, 0);
}
More information about the p4-projects
mailing list