Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/arm/broadcom Sprinkle KASSERTs



details:   https://anonhg.NetBSD.org/src/rev/c48174d7988f
branches:  trunk
changeset: 454695:c48174d7988f
user:      skrll <skrll%NetBSD.org@localhost>
date:      Wed Sep 25 16:57:10 2019 +0000

description:
Sprinkle KASSERTs

diffstat:

 sys/arch/arm/broadcom/bcm2835_intr.c |  19 ++++++++++++++++---
 1 files changed, 16 insertions(+), 3 deletions(-)

diffs (92 lines):

diff -r 0d34750013da -r c48174d7988f sys/arch/arm/broadcom/bcm2835_intr.c
--- a/sys/arch/arm/broadcom/bcm2835_intr.c      Wed Sep 25 16:50:28 2019 +0000
+++ b/sys/arch/arm/broadcom/bcm2835_intr.c      Wed Sep 25 16:57:10 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bcm2835_intr.c,v 1.23 2019/09/25 16:50:28 skrll Exp $  */
+/*     $NetBSD: bcm2835_intr.c,v 1.24 2019/09/25 16:57:10 skrll Exp $  */
 
 /*-
  * Copyright (c) 2012, 2015 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bcm2835_intr.c,v 1.23 2019/09/25 16:50:28 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm2835_intr.c,v 1.24 2019/09/25 16:57:10 skrll Exp $");
 
 #define _INTR_PRIVATE
 
@@ -309,6 +309,8 @@
        const uint32_t oldipl_mask = __BIT(oldipl);
        int ipl_mask = 0;
 
+       KASSERT(cpuid < BCM2836_NCPUS);
+
        ci->ci_data.cpu_nintr++;
 
        bcm2835_barrier();
@@ -479,6 +481,7 @@
        const bus_space_handle_t ioh = bcml1icu_sc->sc_ioh;
        const cpuid_t cpuid = pic - &bcm2836mp_pic[0];
 
+       KASSERT(cpuid < BCM2836_NCPUS);
        KASSERT(irqbase == 0);
 
        if (irq_mask & BCM2836MP_TIMER_IRQS) {
@@ -525,6 +528,7 @@
        const bus_space_handle_t ioh = bcml1icu_sc->sc_ioh;
        const cpuid_t cpuid = pic - &bcm2836mp_pic[0];
 
+       KASSERT(cpuid < BCM2836_NCPUS);
        KASSERT(irqbase == 0);
 
        if (irq_mask & BCM2836MP_TIMER_IRQS) {
@@ -562,6 +566,7 @@
        uint32_t lpending;
        int ipl = 0;
 
+       KASSERT(cpuid < BCM2836_NCPUS);
        KASSERT(pic == &bcm2836mp_pic[cpuid]);
 
        bcm2835_barrier();
@@ -598,10 +603,13 @@
 #if defined(MULTIPROCESSOR)
 static void bcm2836mp_cpu_init(struct pic_softc *pic, struct cpu_info *ci)
 {
+       const cpuid_t cpuid = ci->ci_core_id;
+
+       KASSERT(cpuid < BCM2836_NCPUS);
 
        /* Enable IRQ and not FIQ */
        bus_space_write_4(bcml1icu_sc->sc_iot, bcml1icu_sc->sc_ioh,
-           BCM2836_LOCAL_MAILBOX_IRQ_CONTROLN(ci->ci_core_id), 1);
+           BCM2836_LOCAL_MAILBOX_IRQ_CONTROLN(cpuid), 1);
 }
 
 static void
@@ -612,6 +620,7 @@
        KASSERT(pic->pic_cpus != NULL);
 
        const cpuid_t cpuid = pic - &bcm2836mp_pic[0];
+       KASSERT(cpuid < BCM2836_NCPUS);
 
        bus_space_write_4(bcml1icu_sc->sc_iot, bcml1icu_sc->sc_ioh,
            BCM2836_LOCAL_MAILBOX0_SETN(cpuid), __BIT(ipi));
@@ -624,6 +633,8 @@
        const cpuid_t cpuid = ci->ci_core_id;
        uint32_t ipimask, bit;
 
+       KASSERT(cpuid < BCM2836_NCPUS);
+
        ipimask = bus_space_read_4(bcml1icu_sc->sc_iot, bcml1icu_sc->sc_ioh,
            BCM2836_LOCAL_MAILBOX0_CLRN(cpuid));
        bus_space_write_4(bcml1icu_sc->sc_iot, bcml1icu_sc->sc_ioh,
@@ -671,6 +682,8 @@
        const cpuid_t cpuid = ci->ci_core_id;
        struct pic_softc * const pic = &bcm2836mp_pic[cpuid];
 
+       KASSERT(cpuid < BCM2836_NCPUS);
+
 #if defined(MULTIPROCESSOR)
        pic->pic_cpus = ci->ci_kcpuset;
 



Home | Main Index | Thread Index | Old Index