git: 51c57ca92ed3 - main - gicv3: Panic if the gicv3 already running
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 28 Feb 2024 14:10:41 UTC
The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=51c57ca92ed3d0caf8f3e8c61345ac670d494901 commit 51c57ca92ed3d0caf8f3e8c61345ac670d494901 Author: Warner Losh <imp@FreeBSD.org> AuthorDate: 2024-02-28 14:08:24 +0000 Commit: Warner Losh <imp@FreeBSD.org> CommitDate: 2024-02-28 14:09:42 +0000 gicv3: Panic if the gicv3 already running Due to undefined behavior, it's impossible to re-program a gicv3 ITS table once it's programmed once. Memory corruption happens otherwise. Panic if we detect the LPI is already enabled. Sponsored by: Netflix Reviewed by: andrew Differential Revision: https://reviews.freebsd.org/D44033 --- sys/arm64/arm64/gicv3_its.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/sys/arm64/arm64/gicv3_its.c b/sys/arm64/arm64/gicv3_its.c index 195e07af3288..d3df0a571e95 100644 --- a/sys/arm64/arm64/gicv3_its.c +++ b/sys/arm64/arm64/gicv3_its.c @@ -680,6 +680,8 @@ gicv3_its_conftable_init(struct gicv3_its_softc *sc) { /* note: we assume the ITS children are serialized by the parent */ static void *conf_table; + device_t gicv3; + uint32_t ctlr; /* * The PROPBASER is a singleton in our parent. We only set it up the @@ -691,13 +693,20 @@ gicv3_its_conftable_init(struct gicv3_its_softc *sc) return; } - /* - * Just allocate contiguous pages. We'll configure the PROPBASER - * register later in its_init_cpu_lpi(). - */ - conf_table = contigmalloc(LPI_CONFTAB_SIZE, - M_GICV3_ITS, M_WAITOK, 0, LPI_CONFTAB_MAX_ADDR, - LPI_CONFTAB_ALIGN, 0); + gicv3 = device_get_parent(sc->dev); + ctlr = gic_r_read_4(gicv3, GICR_CTLR); + if ((ctlr & GICR_CTLR_LPI_ENABLE) != 0) { + panic("gicv3 already enabled, can't reprogram."); + } else { + + /* + * Otherwise just allocate contiguous pages. We'll configure the + * PROPBASER register later in its_init_cpu_lpi(). + */ + conf_table = contigmalloc(LPI_CONFTAB_SIZE, + M_GICV3_ITS, M_WAITOK, 0, LPI_CONFTAB_MAX_ADDR, + LPI_CONFTAB_ALIGN, 0); + } sc->sc_conf_base = conf_table; /* Set the default configuration */