From nobody Tue Apr 16 21:42:45 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4VJyFL0Bhxz5H8YZ; Tue, 16 Apr 2024 21:42:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4VJyFK6Jz6z4YjR; Tue, 16 Apr 2024 21:42:45 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1713303765; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=q4uXRNVztJoW3bgKqhReSghlALVIVwic+wwDT3wbs14=; b=NAcc145IKx08UPl5uMZyWgzq9gMNzb98/kTnEE1fVoX1kQ0vtTajQoArtsx0sqoHTdmZ2L giQoyCRswGe4GXtn3wuzrY/KEdsPhPowX3ZAZzF8lV4Cl0RJc7Gkh8FUX78Hxr6eVtAwaQ 9YZE2Sg5Zid8KLU/PvawkScd6zOV87MQxRNMt7BMHxE/8fhJ+eceWIuf/F+8q5Y9k4dRvC B+uSf6SaSJTYQ5V9OjZtRGqHXe2l21oAeMTnS3XX4OQkSRagnbMTV/5y8eyaAamUPdEIWD pIb4GDh2xPQKPWH5qU5lt7Zbsi2G3k9UjtD1fRR1+mPh3y1PGWxeygALrR+oQQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1713303765; a=rsa-sha256; cv=none; b=AUuqspfY3QdoWZfA5fgvv9b2+phrXZUhfC+p70yv32bMwRWs5FqCLwl9wrsdE6uSyt7RNU iP3PecqHh7OTKrHcIPi79ihBU/8iUHyb+bunq+2lncwhTO+Q9GvSdOXSCFVW/dUVaLBhYH R2QcQtxt330pat+tY40f47ibymhXIb4rxuSScGehrHakepl6sEBEjHtpRraJouFcY1hdVb aUYvQzsa6a9lRiSQSBJBu+fN5j38xR4IxrCPPPsO/u4gFcZJ1cg9ne9jzGbCR0uDBWjqYg HPzCClJ8eBlfusNh9BHS+IgymNwRKvlDM5MN77QUtJSA1q4/UhiKeEJ9XzjajQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1713303765; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=q4uXRNVztJoW3bgKqhReSghlALVIVwic+wwDT3wbs14=; b=Fn4IbrqlsVpLUtAWJtUnIkKE0cgGw2dSwByiqHYUwKXjZsjtYLc5iEQ+3WAxhCN89zSckj 8QF1cuQdlvPe5GJ4bjKgrp0AUyU4xFbC/3pwyknzjQHfxx93ikiZLH1EGLB8b6rxm9RHEz tEfzB9bIWubEynA8N2S1be75ogZsisqT1DAr/7QMkWlFepjuR+p+9KEBTuDZjPUHtrvj1n k2WjuQZB0NXd6ErjsGfiT+ro30k153cuoVnBrP8CtzuWWkPYTSoQltcMN1VHMttLR8eZxw MxykKNPak3h2UHMh9gGSpCKlIpaN/rZl+Z2YMAKl4Im/7LlGkYS1QqFJBQWCAg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4VJyFK5wgKz10cY; Tue, 16 Apr 2024 21:42:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 43GLgjrl094479; Tue, 16 Apr 2024 21:42:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 43GLgjMK094476; Tue, 16 Apr 2024 21:42:45 GMT (envelope-from git) Date: Tue, 16 Apr 2024 21:42:45 GMT Message-Id: <202404162142.43GLgjMK094476@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Warner Losh Subject: git: 531302411740 - stable/14 - gicv3: Panic if the gicv3 already running List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 5313024117409f58cbe6af04382768df1572d33b Auto-Submitted: auto-generated The branch stable/14 has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=5313024117409f58cbe6af04382768df1572d33b commit 5313024117409f58cbe6af04382768df1572d33b Author: Warner Losh AuthorDate: 2024-02-28 14:08:24 +0000 Commit: Warner Losh CommitDate: 2024-04-16 21:27:35 +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 (cherry picked from commit 51c57ca92ed3d0caf8f3e8c61345ac670d494901) --- 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 16ea48f49b7f..c9eff1e9f474 100644 --- a/sys/arm64/arm64/gicv3_its.c +++ b/sys/arm64/arm64/gicv3_its.c @@ -681,6 +681,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 @@ -692,13 +694,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 */