From nobody Wed Feb 28 14:10:41 2024 X-Original-To: dev-commits-src-main@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 4TlGTt44Nvz5BfVN; Wed, 28 Feb 2024 14:10:42 +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 4TlGTt0P4Cz4frX; Wed, 28 Feb 2024 14:10:42 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1709129442; 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=PzmA+l2Ws/USoXmHtwLftPs/nkaxu3DuKe/48VlFvAU=; b=kFuE3xVkjUCWk+GtKFCHUk2/V0XX3hbUI5CoC8GpJk0Ig1fRxwsggp+wQ1ooE/49XCNjXw YU+g4l6g9xw6dXYulbiI91JSBU7MynB3qw1CODmQnDtHSaLU/rzhzJbGeOoIjS8EaVgh97 0gL1RX2/uVAn9uO2kb9bAiR3z8Ah0SsvZJt171KZk3jA9Dx7EazTAgpFO5LmWxYA5dkb5A aBohkf9Q1E7eO8lynB4hWZ+GFdwF9EF2cO1WpmXIm9nPpGHXIdPTel2t+cvWfHW4ezUp9w WzBrXU95YphPkVlSGOEUwBLFJG6vlwjl7yM5ORJp+WvgctnX5yxA1+tCar3a7g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1709129442; a=rsa-sha256; cv=none; b=CFLapf3yajBdW3aK/Bsu6yxEP4zGr35ge2ttE6MBizVtTyJLCriNVVw6veKLaTgagrRzZL 139w74N4D9/iZOLNRL5A3ju8se+OmMiM5F7bUIdd2+st18dFjjTXJQiD6Dv5cMZIvHUnCc 1R9hfnomvll6/7QuzOGBg8xw3Qo0Qihf9Tmy+36W/D6L/swslL96wc4NqArQe4uwnx5gYj zsgzxZ9bkFQBXctkTRbyz031rVQkO7+0ZZrq9p7Y0bZb8AzwAzqLQQEkv2rv1ffmmwX+1T tTdWy9B3zeGEtsIHuKgZ+h1Hmd8QjTMTDKLbqlYCZTiPFpY9TZ4LcNp0Rm3oSA== 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=1709129442; 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=PzmA+l2Ws/USoXmHtwLftPs/nkaxu3DuKe/48VlFvAU=; b=eaim3huje7463Vut3bO1Kx7DZbZeDbO6x5KA9IzDd5iRWwQw4hUj55qDWUQS5X2RzbsH1C ut6xE6asOw7NUxBa0f+KEkUJwxXSpv3ys2ou4QvNYA10Qi3cpl+m1qceEwIwxnV3+nGfo1 pGY4S4aW+5e2h70hebbHLZ2BoxyRotD6iwYJ0+xOuIq1HHIDiQ50uXe7UmGuIbjl+5PYEe iC1AszBgG3aTHz8rhxsCNcxUB5ISAk7yYcV2y2Q15roTGVsin/fLxzTOLCrMtuq2Av2kNo 5b1kpAoxoOyaTyuHmFpN4SkZkhOkgZiPuK8D6q8bYp5XtB/1iw0UtCheKVNwtg== 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 4TlGTs6cBPz10mf; Wed, 28 Feb 2024 14:10:41 +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 41SEAfFQ057194; Wed, 28 Feb 2024 14:10:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41SEAfe7057191; Wed, 28 Feb 2024 14:10:41 GMT (envelope-from git) Date: Wed, 28 Feb 2024 14:10:41 GMT Message-Id: <202402281410.41SEAfe7057191@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 51c57ca92ed3 - main - gicv3: Panic if the gicv3 already running List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 51c57ca92ed3d0caf8f3e8c61345ac670d494901 Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=51c57ca92ed3d0caf8f3e8c61345ac670d494901 commit 51c57ca92ed3d0caf8f3e8c61345ac670d494901 Author: Warner Losh AuthorDate: 2024-02-28 14:08:24 +0000 Commit: Warner Losh 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 */