From 9c0fed3dcfd71bdd6c09a79a70b629db56c36e71 Mon Sep 17 00:00:00 2001 From: Doug Rabson Date: Wed, 30 Dec 1998 10:38:59 +0000 Subject: Various changes to support OSF1 emulation: * Move the user stack from VM_MAXUSER_ADDRESS to a place below the 32bit boundary (needed to support 32bit OSF programs). This should also save one pagetable per process. * Add cvtqlsv to the set of instructions handled by the floating point software completion code. * Disable all floating point exceptions by default. * A minor change to execve to allow the OSF1 image activator to support dynamic loading. --- sys/alpha/alpha/fp_emulate.c | 34 ++++++++++++++++++++++++++-------- sys/alpha/alpha/machdep.c | 10 +++++----- sys/alpha/alpha/trap.c | 5 +++-- sys/alpha/alpha/vm_machdep.c | 10 +++++----- sys/alpha/include/vmparam.h | 12 ++++++++++-- 5 files changed, 49 insertions(+), 22 deletions(-) (limited to 'sys/alpha') diff --git a/sys/alpha/alpha/fp_emulate.c b/sys/alpha/alpha/fp_emulate.c index 32ec7eeb310e7..d6dc1653e3837 100644 --- a/sys/alpha/alpha/fp_emulate.c +++ b/sys/alpha/alpha/fp_emulate.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id$ + * $Id: fp_emulate.c,v 1.1 1998/12/04 10:52:47 dfr Exp $ */ #include @@ -208,6 +208,17 @@ static fp_register_t fp_reserved(union alpha_instruction ins, return GETREG(fpregs, ins.f_format.fc); } +static fp_register_t fp_cvtql(union alpha_instruction ins, + int src, int rnd, + u_int64_t control, u_int64_t *status, + struct fpreg *fpregs) + +{ + fp_register_t fb = GETREG(fpregs, ins.f_format.fb); + *status |= FPCR_INV; + return ((fb.q & 0xc0000000) << 32 | (fb.q & 0x3fffffff) << 29); +} + static int fp_emulate(union alpha_instruction ins, struct proc *p) { u_int64_t control = p->p_addr->u_pcb.pcb_fp_control; @@ -235,11 +246,13 @@ static int fp_emulate(union alpha_instruction ins, struct proc *p) u_int64_t status; /* - * Only attempt to emulate ieee instructions. + * Only attempt to emulate ieee instructions & integer overflow */ - if (ins.common.opcode != op_flti) + if ((ins.common.opcode != op_flti) && + (ins.f_format.function != fltl_cvtqlsv)){ + printf("fp_emulate: unhandled opcode = 0x%x, fun = 0x%x\n",ins.common.opcode,ins.f_format.function); return 0; - + } /* * Dump the float registers into the pcb so we can get at * them. @@ -259,10 +272,15 @@ static int fp_emulate(union alpha_instruction ins, struct proc *p) if (rnd == 3) rnd = (fpregs->fpr_cr >> FPCR_DYN_SHIFT) & 3; status = 0; - result = ops[ins.f_format.function & 0xf](ins, src, rnd, - control, &status, - fpregs); - + if (ins.common.opcode == op_fltl + && ins.f_format.function == fltl_cvtqlsv) + result = fp_cvtql(ins, src, rnd, control, &status, + fpregs); + else + result = ops[ins.f_format.function & 0xf](ins, src, rnd, + control, &status, + fpregs); + /* * Handle exceptions. */ diff --git a/sys/alpha/alpha/machdep.c b/sys/alpha/alpha/machdep.c index 39090de0c42dc..64de963593c52 100644 --- a/sys/alpha/alpha/machdep.c +++ b/sys/alpha/alpha/machdep.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: machdep.c,v 1.27 1998/12/16 16:28:56 bde Exp $ + * $Id: machdep.c,v 1.28 1998/12/23 11:50:50 dfr Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -1474,11 +1474,11 @@ setregs(struct proc *p, u_long entry, u_long stack) bzero(tfp->tf_regs, FRAME_SIZE * sizeof tfp->tf_regs[0]); bzero(&p->p_addr->u_pcb.pcb_fp, sizeof p->p_addr->u_pcb.pcb_fp); - p->p_addr->u_pcb.pcb_fp_control = (IEEE_TRAP_ENABLE_INV - | IEEE_TRAP_ENABLE_DZE - | IEEE_TRAP_ENABLE_OVF); + p->p_addr->u_pcb.pcb_fp_control = 0; p->p_addr->u_pcb.pcb_fp.fpr_cr = (FPCR_DYN_NORMAL - | FPCR_INED | FPCR_UNFD); + | FPCR_INVD | FPCR_DZED + | FPCR_OVFD | FPCR_INED + | FPCR_UNFD); alpha_pal_wrusp(stack); tfp->tf_regs[FRAME_PS] = ALPHA_PSL_USERSET; diff --git a/sys/alpha/alpha/trap.c b/sys/alpha/alpha/trap.c index 1811faca31536..107f1b06a6de9 100644 --- a/sys/alpha/alpha/trap.c +++ b/sys/alpha/alpha/trap.c @@ -1,4 +1,4 @@ -/* $Id: trap.c,v 1.8 1998/12/04 22:54:42 archie Exp $ */ +/* $Id: trap.c,v 1.9 1998/12/16 15:21:50 bde Exp $ */ /* $NetBSD: trap.c,v 1.31 1998/03/26 02:21:46 thorpej Exp $ */ /* @@ -450,7 +450,8 @@ trap(a0, a1, a2, entry, framep) * we need to reflect that as an access error. */ if (map != kernel_map && - (caddr_t)va >= vm->vm_maxsaddr) { + (caddr_t)va >= vm->vm_maxsaddr + && (caddr_t)va < (caddr_t)USRSTACK) { if (rv == KERN_SUCCESS) { unsigned nss; diff --git a/sys/alpha/alpha/vm_machdep.c b/sys/alpha/alpha/vm_machdep.c index e8507857689bf..592a089d11c70 100644 --- a/sys/alpha/alpha/vm_machdep.c +++ b/sys/alpha/alpha/vm_machdep.c @@ -38,7 +38,7 @@ * * from: @(#)vm_machdep.c 7.3 (Berkeley) 5/13/91 * Utah $Hdr: vm_machdep.c 1.16.1.1 89/06/23$ - * $Id: vm_machdep.c,v 1.5 1998/12/04 10:52:47 dfr Exp $ + * $Id: vm_machdep.c,v 1.6 1998/12/16 15:21:50 bde Exp $ */ /* * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University. @@ -151,11 +151,11 @@ cpu_fork(p1, p2) * Set the floating point state. */ if ((p2->p_addr->u_pcb.pcb_fp_control & IEEE_INHERIT) == 0) { - p2->p_addr->u_pcb.pcb_fp_control = (IEEE_TRAP_ENABLE_INV - | IEEE_TRAP_ENABLE_DZE - | IEEE_TRAP_ENABLE_OVF); + p2->p_addr->u_pcb.pcb_fp_control = 0; p2->p_addr->u_pcb.pcb_fp.fpr_cr = (FPCR_DYN_NORMAL - | FPCR_INED | FPCR_UNFD); + | FPCR_INVD | FPCR_DZED + | FPCR_OVFD | FPCR_INED + | FPCR_UNFD); } /* diff --git a/sys/alpha/include/vmparam.h b/sys/alpha/include/vmparam.h index fead056e3d0c4..04c62a65a5460 100644 --- a/sys/alpha/include/vmparam.h +++ b/sys/alpha/include/vmparam.h @@ -1,4 +1,4 @@ -/* $Id: vmparam.h,v 1.2 1998/06/10 10:55:30 dfr Exp $ */ +/* $Id: vmparam.h,v 1.3 1998/06/14 13:45:15 dfr Exp $ */ /* From: NetBSD: vmparam.h,v 1.6 1997/09/23 23:23:23 mjacob Exp */ #ifndef _ALPHA_VMPARAM_H #define _ALPHA_VMPARAM_H @@ -54,7 +54,15 @@ * kernel stack. */ #define USRTEXT CLBYTES -#define USRSTACK VM_MAXUSER_ADDRESS +/* #define USRSTACK VM_MAXUSER_ADDRESS */ + +/* + * This stack location is suitable for OSF1 emulation. Some OSF + * programs are built as 32bit and assume that the stack is reachable + * with a 32bit value. OSF1 manages to have a variable location for + * the user stack which we should probably also support. + */ +#define USRSTACK (0x12000000LL - (UPAGES*PAGE_SIZE)) /* * Virtual memory related constants, all in bytes -- cgit v1.3