svn commit: r343167 - in head/sys/powerpc: powerpc pseries
Justin Hibbits
jhibbits at FreeBSD.org
Sat Jan 19 04:47:20 UTC 2019
Author: jhibbits
Date: Sat Jan 19 04:47:19 2019
New Revision: 343167
URL: https://svnweb.freebsd.org/changeset/base/343167
Log:
powerpc: Fix opaque irq data initialization
The powerpc_intr structure is not zero-initialized, so on an invariants
build would panic in the xics driver with an invalid pointer. Also fix the
xics driver to share the private data setup code between xics_enable() and
xics_bind().
Reported by: Leonardo Bianconi
Modified:
head/sys/powerpc/powerpc/intr_machdep.c
head/sys/powerpc/pseries/xics.c
Modified: head/sys/powerpc/powerpc/intr_machdep.c
==============================================================================
--- head/sys/powerpc/powerpc/intr_machdep.c Fri Jan 18 23:54:51 2019 (r343166)
+++ head/sys/powerpc/powerpc/intr_machdep.c Sat Jan 19 04:47:19 2019 (r343167)
@@ -209,6 +209,7 @@ intr_lookup(u_int irq)
i->event = NULL;
i->cntp = NULL;
+ i->priv = NULL;
i->trig = INTR_TRIGGER_CONFORM;
i->pol = INTR_POLARITY_CONFORM;
i->irq = irq;
Modified: head/sys/powerpc/pseries/xics.c
==============================================================================
--- head/sys/powerpc/pseries/xics.c Fri Jan 18 23:54:51 2019 (r343166)
+++ head/sys/powerpc/pseries/xics.c Sat Jan 19 04:47:19 2019 (r343167)
@@ -295,6 +295,20 @@ xics_attach(device_t dev)
return (0);
}
+static __inline struct xicp_intvec *
+xicp_setup_priv(struct xicp_softc *sc, u_int irq, void **priv)
+{
+ if (*priv == NULL) {
+ KASSERT(sc->nintvecs + 1 < nitems(sc->intvecs),
+ ("Too many XICP interrupts"));
+ mtx_lock(&sc->sc_mtx);
+ *priv = &sc->intvecs[sc->nintvecs++];
+ mtx_unlock(&sc->sc_mtx);
+ }
+
+ return (*priv);
+}
+
/*
* PIC I/F methods.
*/
@@ -311,11 +325,8 @@ xicp_bind(device_t dev, u_int irq, cpuset_t cpumask, v
if (irq == MAX_XICP_IRQS)
return;
- if (*priv == NULL)
- *priv = &sc->intvecs[sc->nintvecs++];
+ iv = xicp_setup_priv(sc, irq, priv);
- iv = *priv;
-
/*
* This doesn't appear to actually support affinity groups, so pick a
* random CPU.
@@ -426,14 +437,7 @@ xicp_enable(device_t dev, u_int irq, u_int vector, voi
/* Bind to this CPU to start: distrib. ID is last entry in gserver# */
cpu = PCPU_GET(hwref);
- if (*priv == NULL) {
- KASSERT(sc->nintvecs + 1 < nitems(sc->intvecs),
- ("Too many XICP interrupts"));
- mtx_lock(&sc->sc_mtx);
- *priv = &sc->intvecs[sc->nintvecs++];
- mtx_unlock(&sc->sc_mtx);
- }
- intr = *priv;
+ intr = xicp_setup_priv(sc, irq, priv);
intr->irq = irq;
intr->vector = vector;
More information about the svn-src-all
mailing list