PERFORCE change 97799 for review
Kip Macy
kmacy at FreeBSD.org
Thu May 25 06:17:26 UTC 2006
http://perforce.freebsd.org/chv.cgi?CH=97799
Change 97799 by kmacy at kmacy_storage:sun4v_work on 2006/05/25 06:16:23
save / restore ASI on context switch to make us preemption safe
treat data exception and alignment errors for non-zero contexts as user traps and not kernel traps
Affected files ...
.. //depot/projects/kmacy_sun4v/src/sys/sparc64/sparc64/genassym.c#21 edit
.. //depot/projects/kmacy_sun4v/src/sys/sun4v/include/frame.h#4 edit
.. //depot/projects/kmacy_sun4v/src/sys/sun4v/include/trap.h#8 edit
.. //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/trap.c#12 edit
Differences ...
==== //depot/projects/kmacy_sun4v/src/sys/sparc64/sparc64/genassym.c#21 (text+ko) ====
@@ -339,6 +339,8 @@
ASSYM(TF_SFAR, offsetof(struct trapframe, tf_sfar));
ASSYM(TF_SFSR, offsetof(struct trapframe, tf_sfsr));
ASSYM(TF_TAR, offsetof(struct trapframe, tf_tar));
+#else
+ASSYM(TF_ASI, offsetof(struct trapframe, tf_asi));
#endif
ASSYM(TF_TNPC, offsetof(struct trapframe, tf_tnpc));
ASSYM(TF_TPC, offsetof(struct trapframe, tf_tpc));
==== //depot/projects/kmacy_sun4v/src/sys/sun4v/include/frame.h#4 (text+ko) ====
@@ -50,7 +50,8 @@
uint64_t tf_tstate;
uint64_t tf_pad2[2];
uint64_t tf_wstate;
- uint64_t tf_pad3[2];
+ uint64_t tf_asi;
+ uint64_t tf_pad3[1];
};
/* extra padding can go away once we re-shuffle user-land mcontext
*/
==== //depot/projects/kmacy_sun4v/src/sys/sun4v/include/trap.h#8 (text+ko) ====
@@ -98,6 +98,8 @@
#define T_MAX (T_NONRESUMABLE_ERROR + 1)
#define T_KERNEL 0x100
+#define TRAP_MASK ((1<<8)-1)
+#define TRAP_CTX_SHIFT 10
#define PTL1_BAD_DEBUG 0
#define PTL1_BAD_WTRAP 1
==== //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/trap.c#12 (text+ko) ====
@@ -266,20 +266,23 @@
{
struct thread *td;
struct proc *p;
- int error;
- int sig;
+ int error, sig, ctx;
+ uint64_t trapno;
register_t addr;
ksiginfo_t ksi;
td = PCPU_GET(curthread);
CTR4(KTR_TRAP, "trap: %p type=%s (%s) pil=%#lx", td,
- trap_msg[trap_conversion[type & ~T_KERNEL]],
+ trap_msg[trap_conversion[trapno]],
(TRAPF_USERMODE(tf) ? "user" : "kernel"), rdpr(pil));
PCPU_LAZY_INC(cnt.v_trap);
- if ((tf->tf_tstate & TSTATE_PRIV) == 0) {
+ trapno = (type & TRAP_MASK);
+ ctx = (type >> TRAP_CTX_SHIFT);
+
+ if (((tf->tf_tstate & TSTATE_PRIV) == 0) || (ctx != 0)) {
KASSERT(td != NULL, ("trap: curthread NULL"));
KASSERT(td->td_proc != NULL, ("trap: curproc NULL"));
@@ -290,12 +293,12 @@
if (td->td_ucred != p->p_ucred)
cred_update_thread(td);
- switch (type) {
+ switch (trapno) {
case T_DATA_MISS:
case T_DATA_PROTECTION:
addr = TLB_TAR_VA(data);
case T_INSTRUCTION_MISS:
- sig = trap_pfault(td, tf, type, data);
+ sig = trap_pfault(td, tf, trapno, data);
break;
case T_FILL:
sig = rwindow_load(td, tf, 2);
@@ -306,11 +309,18 @@
case T_SPILL:
sig = rwindow_save(td);
break;
+ case T_DATA_EXCEPTION:
+ case T_DATA_ERROR:
+ case T_MEM_ADDRESS_NOT_ALIGNED:
+ addr = data;
+ sig = trap_sig[trap_conversion[trapno]];
+ break;
+
default:
- if (type < 0 || type >= T_MAX ||
- trap_sig[type] == -1)
+ if (trapno < 0 || trapno >= T_MAX ||
+ trap_sig[trapno] == -1)
panic("trap: bad trap type");
- sig = trap_sig[trap_conversion[type]];
+ sig = trap_sig[trap_conversion[trapno]];
break;
}
@@ -318,22 +328,24 @@
/* Translate fault for emulators. */
if (p->p_sysent->sv_transtrap != NULL) {
sig = p->p_sysent->sv_transtrap(sig,
- type);
+ trapno);
}
if (debugger_on_signal &&
(sig == 4 || sig == 10 || sig == 11))
kdb_enter("trapsig");
+#ifdef VERBOSE
if (sig == 4 || sig == 10 || sig == 11)
- printf("trap: %ld:%s: 0x%lx at 0x%lx on cpu=%d sig=%d\n", type,
- trap_msg[trap_conversion[type]], data, tf->tf_tpc, curcpu, sig);
+ printf("trap: %ld:%s: 0x%lx at 0x%lx on cpu=%d sig=%d\n", trapno,
+ trap_msg[trap_conversion[trapno]], data, tf->tf_tpc, curcpu, sig);
+#endif
/* XXX I've renumbered the traps to largely reflect what the hardware uses
* so this will need to be re-visited
*/
ksiginfo_init_trap(&ksi);
ksi.ksi_signo = sig;
- ksi.ksi_code = (int)trap_conversion[type]; /* XXX not POSIX */
+ ksi.ksi_code = (int)trap_conversion[trapno]; /* XXX not POSIX */
ksi.ksi_addr = (void *)addr;
- ksi.ksi_trapno = (int)trap_conversion[type];
+ ksi.ksi_trapno = (int)trap_conversion[trapno];
trapsignal(td, &ksi);
}
@@ -350,50 +362,27 @@
}
#endif
- switch (type & ~T_KERNEL) {
+ switch (trapno) {
#ifdef KDB
case T_BREAKPOINT:
case T_KSTACK_FAULT:
- error = (kdb_trap(type, 0, tf) == 0);
+ error = (kdb_trap(trapno, 0, tf) == 0);
TF_DONE(tf);
break;
#endif
case T_DATA_MISS:
case T_DATA_PROTECTION:
case T_INSTRUCTION_MISS:
- error = trap_pfault(td, tf, type, data);
+ error = trap_pfault(td, tf, trapno, data);
break;
case T_DATA_EXCEPTION:
printf("data exception on 0x%lx at 0x%lx\n", data, tf->tf_tpc);
- printf("trap: %ld=%s: 0x%lx at 0x%lx:0x%lx\n", type & ~T_KERNEL, trap_msg[trap_conversion[type & ~T_KERNEL]], data, tf->tf_tpc, tf->tf_tnpc);
- error = 1;
- break;
+ printf("trap: %ld=%s: 0x%lx at 0x%lx:0x%lx\n", trapno, trap_msg[trap_conversion[trapno]], data, tf->tf_tpc, tf->tf_tnpc);
+ case T_DATA_ERROR:
case T_MEM_ADDRESS_NOT_ALIGNED:
-#ifdef notyet
- if ((tf->tf_sfsr & MMU_SFSR_FV) != 0 &&
- MMU_SFSR_GET_ASI(tf->tf_sfsr) == ASI_AIUP) {
- if (tf->tf_tpc >= (u_long)copy_nofault_begin &&
- tf->tf_tpc <= (u_long)copy_nofault_end) {
- tf->tf_tpc = (u_long)copy_fault;
- tf->tf_tnpc = tf->tf_tpc + 4;
- error = 0;
- break;
- }
- if (tf->tf_tpc >= (u_long)fs_nofault_begin &&
- tf->tf_tpc <= (u_long)fs_nofault_end) {
- tf->tf_tpc = (u_long)fs_fault;
- tf->tf_tnpc = tf->tf_tpc + 4;
- error = 0;
- break;
- }
- }
-#endif
error = 1;
break;
- case T_DATA_ERROR:
- UNIMPLEMENTED;
- error = 1;
- break;
+
case T_ILLEGAL_INSTRUCTION:
if (tf->tf_tpc > KERNBASE) {
printf("illinstr: 0x%lx\n", tf->tf_tpc);
@@ -406,7 +395,7 @@
}
if (error != 0)
- panic("trap: %ld=%s: 0x%lx at 0x%lx:0x%lx error=%d", type & ~T_KERNEL, trap_msg[trap_conversion[type & ~T_KERNEL]], data, tf->tf_tpc, tf->tf_tnpc, error);
+ panic("trap: %ld=%s: 0x%lx at 0x%lx:0x%lx error=%d", trapno, trap_msg[trap_conversion[trapno]], data, tf->tf_tpc, tf->tf_tnpc, error);
}
CTR1(KTR_TRAP, "trap: td=%p return", td);
}
More information about the p4-projects
mailing list