From b291daba6fc1b6ac32dcb37aa92b7cc15bcfdf6b Mon Sep 17 00:00:00 2001 From: Marcel Moolenaar Date: Tue, 9 Dec 2003 09:52:14 +0000 Subject: [PATCH] Don't panic for misalignment traps when the onfault handler is set. Not all transfers between kernel and user space are byte oriented and thus alignment safe. Especially fuword*() and suword*() are sensitive to alignment but in general more optimal than block copies. By catching the misalignment trap we avoid pessimizing the common case of properly aligned memory accesses which we would do if we were to use byte copies or adding tests for proper alignment. Note that the expectation that the kernel produces aligned pointers is unchanged. This change therefore relates to possible unaligned pointers generated in userland. --- sys/ia64/ia64/trap.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/sys/ia64/ia64/trap.c b/sys/ia64/ia64/trap.c index 96df12533d7..e8622aac72f 100644 --- a/sys/ia64/ia64/trap.c +++ b/sys/ia64/ia64/trap.c @@ -648,8 +648,17 @@ trap(int vector, struct trapframe *framep) if (sig == 0) goto out; ucode = framep->tf_special.ifa; /* VA */ - } else + } else { + /* Check for copyin/copyout fault. */ + if (td != NULL && td->td_pcb->pcb_onfault != 0) { + framep->tf_special.iip = + td->td_pcb->pcb_onfault; + framep->tf_special.psr &= ~IA64_PSR_RI; + td->td_pcb->pcb_onfault = 0; + goto out; + } trap_panic(vector, framep); + } break; case IA64_VEC_FLOATING_POINT_FAULT: