Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/arm Add __NO_FIQ to prevent testing of the PSR FIQ bit



details:   https://anonhg.NetBSD.org/src/rev/1d10f59e10a0
branches:  trunk
changeset: 331539:1d10f59e10a0
user:      matt <matt%NetBSD.org@localhost>
date:      Wed Aug 13 21:41:32 2014 +0000

description:
Add __NO_FIQ to prevent testing of the PSR FIQ bit
Use VALID_R15_PSR(pc, spsr) instead of testing explicitly

diffstat:

 sys/arch/arm/arm/ast.c             |   9 +++++----
 sys/arch/arm/arm/process_machdep.c |  17 +++++------------
 sys/arch/arm/arm/syscall.c         |   6 +++---
 sys/arch/arm/arm32/fault.c         |  24 +++++++++++++++++-------
 sys/arch/arm/include/locore.h      |  10 +++++++---
 5 files changed, 37 insertions(+), 29 deletions(-)

diffs (204 lines):

diff -r d662eff025d1 -r 1d10f59e10a0 sys/arch/arm/arm/ast.c
--- a/sys/arch/arm/arm/ast.c    Wed Aug 13 21:10:31 2014 +0000
+++ b/sys/arch/arm/arm/ast.c    Wed Aug 13 21:41:32 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ast.c,v 1.23 2014/03/28 21:43:49 matt Exp $    */
+/*     $NetBSD: ast.c,v 1.24 2014/08/13 21:41:32 matt Exp $    */
 
 /*
  * Copyright (c) 1994,1995 Mark Brinicombe
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ast.c,v 1.23 2014/03/28 21:43:49 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ast.c,v 1.24 2014/08/13 21:41:32 matt Exp $");
 
 #include "opt_ddb.h"
 
@@ -86,7 +86,8 @@
 #endif
 
 #if defined(__PROG32) && defined(DIAGNOSTIC)
-       KASSERT((lwp_trapframe(l)->tf_spsr & IF32_bits) == 0);
+       KASSERT(VALID_R15_PSR(lwp_trapframe(l)->tf_pc,
+           lwp_trapframe(l)->tf_spsr));
 #endif
 }
 
@@ -111,7 +112,7 @@
 #endif
 
 #ifdef __PROG32
-       KASSERT((tf->tf_spsr & IF32_bits) == 0);
+       KASSERT(VALID_R15_PSR(tf->tf_pc, tf->tf_spsr));
 #endif
 
        curcpu()->ci_data.cpu_ntrap++;
diff -r d662eff025d1 -r 1d10f59e10a0 sys/arch/arm/arm/process_machdep.c
--- a/sys/arch/arm/arm/process_machdep.c        Wed Aug 13 21:10:31 2014 +0000
+++ b/sys/arch/arm/arm/process_machdep.c        Wed Aug 13 21:41:32 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: process_machdep.c,v 1.29 2014/01/04 00:10:02 dsl Exp $ */
+/*     $NetBSD: process_machdep.c,v 1.30 2014/08/13 21:41:32 matt Exp $        */
 
 /*
  * Copyright (c) 1993 The Regents of the University of California.
@@ -133,7 +133,7 @@
 
 #include <sys/param.h>
 
-__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.29 2014/01/04 00:10:02 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.30 2014/08/13 21:41:32 matt Exp $");
 
 #include <sys/proc.h>
 #include <sys/ptrace.h>
@@ -158,15 +158,12 @@
        regs->r_pc = tf->tf_pc;
        regs->r_cpsr = tf->tf_spsr;
 
+       KASSERT(VALID_R15_PSR(tf->tf_pc, tf->tf_spsr));
+
 #ifdef THUMB_CODE
        if (tf->tf_spsr & PSR_T_bit)
                regs->r_pc |= 1;
 #endif
-#ifdef DIAGNOSTIC
-       if ((tf->tf_spsr & PSR_MODE) == PSR_USR32_MODE
-            && (tf->tf_spsr & IF32_bits))
-               panic("process_read_regs: IRQs/FIQs blocked in user process");
-#endif
 
        return(0);
 }
@@ -204,11 +201,7 @@
        if ((regs->r_pc & 1) || (regs->r_cpsr & PSR_T_bit))
                tf->tf_spsr |= PSR_T_bit;
 #endif
-#ifdef DIAGNOSTIC
-       if ((tf->tf_spsr & PSR_MODE) == PSR_USR32_MODE
-            && (tf->tf_spsr & IF32_bits))
-               panic("process_read_regs: IRQs/FIQs blocked in user process");
-#endif
+       KASSERT(VALID_R15_PSR(tf->tf_pc, tf->tf_spsr));
 #else /* __PROG26 */
        if ((regs->r_pc & (R15_MODE | R15_IRQ_DISABLE | R15_FIQ_DISABLE)) != 0)
                return EPERM;
diff -r d662eff025d1 -r 1d10f59e10a0 sys/arch/arm/arm/syscall.c
--- a/sys/arch/arm/arm/syscall.c        Wed Aug 13 21:10:31 2014 +0000
+++ b/sys/arch/arm/arm/syscall.c        Wed Aug 13 21:41:32 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: syscall.c,v 1.59 2014/01/29 18:45:21 matt Exp $        */
+/*     $NetBSD: syscall.c,v 1.60 2014/08/13 21:41:32 matt Exp $        */
 
 /*-
  * Copyright (c) 2000, 2003 The NetBSD Foundation, Inc.
@@ -71,7 +71,7 @@
 
 #include <sys/param.h>
 
-__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.59 2014/01/29 18:45:21 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.60 2014/08/13 21:41:32 matt Exp $");
 
 #include <sys/cpu.h>
 #include <sys/device.h>
@@ -109,7 +109,7 @@
        if ((tf->tf_r15 & R15_IRQ_DISABLE) == 0)
                int_on();
 #else
-       KASSERT((tf->tf_spsr & IF32_bits) == 0);
+       KASSERT(VALID_R15_PSR(tf->tf_pc, tf->tf_spsr));
        restore_interrupts(tf->tf_spsr & IF32_bits);
 #endif
 
diff -r d662eff025d1 -r 1d10f59e10a0 sys/arch/arm/arm32/fault.c
--- a/sys/arch/arm/arm32/fault.c        Wed Aug 13 21:10:31 2014 +0000
+++ b/sys/arch/arm/arm32/fault.c        Wed Aug 13 21:41:32 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fault.c,v 1.100 2014/04/12 09:11:47 skrll Exp $        */
+/*     $NetBSD: fault.c,v 1.101 2014/08/13 21:41:32 matt Exp $ */
 
 /*
  * Copyright 2003 Wasabi Systems, Inc.
@@ -81,7 +81,7 @@
 #include "opt_kgdb.h"
 
 #include <sys/types.h>
-__KERNEL_RCSID(0, "$NetBSD: fault.c,v 1.100 2014/04/12 09:11:47 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fault.c,v 1.101 2014/08/13 21:41:32 matt Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -253,9 +253,14 @@
        ci->ci_data.cpu_ntrap++;
 
        /* Re-enable interrupts if they were enabled previously */
-       KASSERT(!TRAP_USERMODE(tf) || (tf->tf_spsr & IF32_bits) == 0);
+       KASSERT(!TRAP_USERMODE(tf) || VALID_R15_PSR(tf->tf_pc, tf->tf_spsr));
+#ifdef __NO_FIQ
+       if (__predict_true((tf->tf_spsr & I32_bit) != I32_bit))
+               restore_interrupts(tf->tf_spsr & IF32_bits);
+#else
        if (__predict_true((tf->tf_spsr & IF32_bits) != IF32_bits))
                restore_interrupts(tf->tf_spsr & IF32_bits);
+#endif
 
        /* Get the current lwp structure */
 
@@ -800,14 +805,19 @@
         * from user mode so we know interrupts were not disabled.
         * But we check anyway.
         */
-       KASSERT(!TRAP_USERMODE(tf) || (tf->tf_spsr & IF32_bits) == 0);
-       if (__predict_true((tf->tf_spsr & I32_bit) != IF32_bits))
+       KASSERT(!TRAP_USERMODE(tf) || VALID_R15_PSR(tf->tf_pc, tf->tf_spsr));
+#ifdef __NO_FIQ
+       if (__predict_true((tf->tf_spsr & I32_bit) != I32_bit))
                restore_interrupts(tf->tf_spsr & IF32_bits);
+#else
+       if (__predict_true((tf->tf_spsr & IF32_bits) != IF32_bits))
+               restore_interrupts(tf->tf_spsr & IF32_bits);
+#endif
 
        /* See if the CPU state needs to be fixed up */
        switch (prefetch_abort_fixup(tf)) {
        case ABORT_FIXUP_RETURN:
-               KASSERT(!TRAP_USERMODE(tf) || (tf->tf_spsr & IF32_bits) == 0);
+               KASSERT(!TRAP_USERMODE(tf) || VALID_R15_PSR(tf->tf_pc, tf->tf_spsr));
                return;
        case ABORT_FIXUP_FAILED:
                /* Deliver a SIGILL to the process */
@@ -890,7 +900,7 @@
        call_trapsignal(l, tf, &ksi);
 
 out:
-       KASSERT(!TRAP_USERMODE(tf) || (tf->tf_spsr & IF32_bits) == 0);
+       KASSERT(!TRAP_USERMODE(tf) || VALID_R15_PSR(tf->tf_pc, tf->tf_spsr));
        userret(l);
 }
 
diff -r d662eff025d1 -r 1d10f59e10a0 sys/arch/arm/include/locore.h
--- a/sys/arch/arm/include/locore.h     Wed Aug 13 21:10:31 2014 +0000
+++ b/sys/arch/arm/include/locore.h     Wed Aug 13 21:41:32 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: locore.h,v 1.16 2014/03/28 21:39:09 matt Exp $ */
+/*     $NetBSD: locore.h,v 1.17 2014/08/13 21:41:32 matt Exp $ */
 
 /*
  * Copyright (c) 1994-1996 Mark Brinicombe.
@@ -112,9 +112,13 @@
  */
 
 #ifdef __PROG32
+#ifdef __NO_FIQ
 #define VALID_R15_PSR(r15,psr)                                         \
-       (((psr) & PSR_MODE) == PSR_USR32_MODE &&                        \
-               ((psr) & (I32_bit | F32_bit)) == 0)
+       (((psr) & PSR_MODE) == PSR_USR32_MODE && ((psr) & I32_bit) == 0)
+#else
+#define VALID_R15_PSR(r15,psr)                                         \
+       (((psr) & PSR_MODE) == PSR_USR32_MODE && ((psr) & IF32_bits) == 0)
+#endif
 #else
 #define VALID_R15_PSR(r15,psr)                                         \
        (((r15) & R15_MODE) == R15_MODE_USR &&                          \



Home | Main Index | Thread Index | Old Index