On OEA, turn PSL_USER* into runtime values appropriate for the CPU model

we're executing on; besides dealing with the bits not implemented in the
601's MSR it also removes the silent failure behaviour when passing
PSL_VEC set on a CPU not implementing it.

Also, fix those masks for the 4xx again.
This commit is contained in:
kleink 2004-06-26 21:48:30 +00:00
parent 97e8f81436
commit 0fea7f39a2
3 changed files with 38 additions and 10 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: psl.h,v 1.11 2004/06/26 16:04:55 kleink Exp $ */
/* $NetBSD: psl.h,v 1.12 2004/06/26 21:48:30 kleink Exp $ */
/*
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
@ -61,7 +61,7 @@
#define PSL_RI 0x00000002 /* recoverable interrupt */
#define PSL_LE 0x00000001 /* endian mode (1 == le) */
#define PSL_601_MASK ~(PSL_POW|PSL_ILE|PSL_BE|PSL_RI|PSL_LE)
#define PSL_601_MASK ~(PSL_VEC|PSL_POW|PSL_ILE|PSL_BE|PSL_RI|PSL_LE)
/*
* Floating-point exception modes:
@ -78,16 +78,29 @@
#define PSL_MBO 0
#define PSL_MBZ 0
#define PSL_USERSET (PSL_EE | PSL_PR | PSL_ME | PSL_IR | PSL_DR | PSL_RI)
/*
* A user is not allowed to change any MSR bits except the following:
* We restrict the test to the low 16 bits of the MSR since those are the
* only ones preserved in the trap. Note that this means PSL_VEC needs to
* be restored to SRR1 in userret.
*/
#define PSL_USERSRR1 ((PSL_USERSET|PSL_USERMOD) & 0xFFFF)
#define PSL_USERMOD (PSL_VEC|PSL_FP|PSL_FE0|PSL_FE1|PSL_LE|PSL_SE|PSL_BE)
#if defined(_KERNEL) && !defined(_LOCORE)
#ifdef _KERNEL_OPT
#include "opt_ppcarch.h"
#endif /* _KERNEL_OPT */
#if defined(PPC_OEA)
extern int cpu_psluserset, cpu_pslusermod;
#define PSL_USERSET cpu_psluserset
#define PSL_USERMOD cpu_pslusermod
#else /* PPC_IBM4XX */
#define PSL_USERSET (PSL_EE | PSL_PR | PSL_ME | PSL_IR | PSL_DR)
#define PSL_USERMOD (0)
#endif /* PPC_OEA */
#define PSL_USERSRR1 ((PSL_USERSET|PSL_USERMOD) & 0xFFFF)
#define PSL_USEROK_P(psl) (((psl) & ~PSL_USERMOD) == PSL_USERSET)
#endif /* !_LOCORE */
#endif /* _POWERPC_PSL_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: cpu_subr.c,v 1.13 2004/03/11 15:40:13 christos Exp $ */
/* $NetBSD: cpu_subr.c,v 1.14 2004/06/26 21:48:30 kleink Exp $ */
/*-
* Copyright (c) 2001 Matt Thomas.
@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: cpu_subr.c,v 1.13 2004/03/11 15:40:13 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: cpu_subr.c,v 1.14 2004/06/26 21:48:30 kleink Exp $");
#include "opt_ppcparam.h"
#include "opt_multiprocessor.h"
@ -200,6 +200,7 @@ struct cpu_info cpu_info[1];
#endif
int cpu_altivec;
int cpu_psluserset, cpu_pslusermod;
char cpu_model[80];
void

View File

@ -1,4 +1,4 @@
/* $NetBSD: oea_machdep.c,v 1.18 2004/06/23 22:04:44 kleink Exp $ */
/* $NetBSD: oea_machdep.c,v 1.19 2004/06/26 21:48:30 kleink Exp $ */
/*
* Copyright (C) 2002 Matt Thomas
@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: oea_machdep.c,v 1.18 2004/06/23 22:04:44 kleink Exp $");
__KERNEL_RCSID(0, "$NetBSD: oea_machdep.c,v 1.19 2004/06/26 21:48:30 kleink Exp $");
#include "opt_compat_netbsd.h"
#include "opt_ddb.h"
@ -346,6 +346,20 @@ oea_init(void (*handler)(void))
}
}
/*
* Configure a PSL user mask matching this processor.
*/
cpu_psluserset = PSL_EE | PSL_PR | PSL_ME | PSL_IR | PSL_DR | PSL_RI;
cpu_pslusermod = PSL_FP | PSL_FE0 | PSL_FE1 | PSL_LE | PSL_SE | PSL_BE;
if (cpuvers == MPC601) {
cpu_psluserset &= PSL_601_MASK;
cpu_pslusermod &= PSL_601_MASK;
}
#ifdef ALTIVEC
if (cpu_altivec)
cpu_pslusermod |= PSL_VEC;
#endif
/*
* external interrupt handler install
*/