From nobody Tue Apr 16 21:42:52 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 4VJyFT2NNwz5H7rk; Tue, 16 Apr 2024 21:42:53 +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 4VJyFS5cnmz4Ylx; Tue, 16 Apr 2024 21:42:52 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1713303772; 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=uAhLnvyB7S1X6zWYjNTMM6TKlmQZnVg5ATmXEDrP2CE=; b=GOxw+4JuxqAius9tf+Mw4zK/QE4JHq4w+HnmyaMLGnE/LezDTbS8hDUoVjY1CgYZnoOs3e wYNG4eocs5V6dmpzGkhqJD4nIc0zWoklaJ9y1oBqKQ7590opAH6AMP6whg4AzHSSrvSN1q W2Z6k6oGZsVg3ZoJZ2+J2PKBUFn6NC7d8gCMKbbG5XMwxX11tntdcJRQqS1m3SGFxFZAVg wjKrnpGTYXeaKrI2jB+Qxv5fFMNj9KEu+hLoi8va3Jh7k1jJcOkbJNzl3yk+PcyOSWeAON i0TLM/cPib8085aKRNWIkGnhSlG5ifA8sxtQBoCRzZAZvzX3tFOnyGmShAzbQg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1713303772; a=rsa-sha256; cv=none; b=l1ybpAn72C2wG7WVmGlAAz6atpe0puSGbJAG3OxNaXDx0dZB6IFznAHAzaCXgekokIkDUs f5Ed7LKghIyZDBhxGNg0MvLo89h8netRkp0uUerWQ+wV6O/kbQj3XNYVQS7TWWjosYC/oN 6KMsknBg1tyLaiDE3r+gfuKYSX9psPiiXpRXYCPNqhy45wk6Zx3BT2VVLiBksHBbHhO7Ej l5g6uVUmwik0TaC72JcJYfo3TpfTrfKX85qzNMzmDlvIcT34UX8CsXX1a8PAWF/vwgTJhS 0FA8PX/gyVDvlr6N+T0UBGXwbcjaxLEOPUQzsQXQgjxZvt3rH+6RXu+4UGFbdg== 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=1713303772; 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=uAhLnvyB7S1X6zWYjNTMM6TKlmQZnVg5ATmXEDrP2CE=; b=ru5FBMuXfeumixYG6AOudrUuL52VuJ8blrVRZLfKWZ3pHTP+D+vWqv2jOxYqyvVnE7g+1h NfYzTAGKe+mi6EvjGZQF9Ef/rBk5kyLDvXPiorbKuNHwl2HwWH3fn9fwvW3mhHeICRzCrw Jf+mjUjd1/TVyUSa90f9R51bskuNgMRJFbzp8IdNK4UheDRWRTAbxarMqV6q02aLGrCYd7 1DReN9xt/+WzPROjzMFcXZiOsDdaRWAzGTf7A4Uj6SHpqmxvuoapAMUQ8zQlnVC3WsKrt6 Z0CNVlKnm+Yh03SIqJQDo+QDNdEp0LK40aoxRPysBVYwi11bWPFIRoz8BuALCA== 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 4VJyFS51Ptz10Lq; Tue, 16 Apr 2024 21:42:52 +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 43GLgqSX094798; Tue, 16 Apr 2024 21:42:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 43GLgqki094795; Tue, 16 Apr 2024 21:42:52 GMT (envelope-from git) Date: Tue, 16 Apr 2024 21:42:52 GMT Message-Id: <202404162142.43GLgqki094795@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: d476e51525ff - stable/14 - gicv3: If the LPI is already allocated, remember it 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: d476e51525ff9e5c489feec14f64aa8c1d38c5b5 Auto-Submitted: auto-generated The branch stable/14 has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=d476e51525ff9e5c489feec14f64aa8c1d38c5b5 commit d476e51525ff9e5c489feec14f64aa8c1d38c5b5 Author: Warner Losh AuthorDate: 2024-02-28 14:09:17 +0000 Commit: Warner Losh CommitDate: 2024-04-16 21:28:41 +0000 gicv3: If the LPI is already allocated, remember it If the LPI Configuration Tabel has been pre-allocated by the boot loader, then we have to remember PROPBASER and use it rather than allocating memory for it ourselves. Linux provides us with a reserved table that contains all the gicv3 allocations, so make sure what we read from PROPBASER matches something in that table. Normally, bare metal boot loaders leave the gic in a reset state. However, Linux brings it up fully so it can do I/O to boot the next kernel via kexec. Since the gicv3 PENDBASER can't be reset while running due to undefined behavior, we must reuse what's there for both PENDBASER and PROPBASER. With this commit, the workaround is complete. Details are at https://lkml.iu.edu/hypermail/linux/kernel/1809.2/06246.html and pointers in the thread. Sponsored by: Netflix Reviewed by: andrew Differential Revision: https://reviews.freebsd.org/D44038 (cherry picked from commit cb4a83cff01cdf871c78115c942c5b34412914d2) --- sys/arm64/arm64/gicv3_its.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/sys/arm64/arm64/gicv3_its.c b/sys/arm64/arm64/gicv3_its.c index 49d9c08a4ffd..02c063fe57b5 100644 --- a/sys/arm64/arm64/gicv3_its.c +++ b/sys/arm64/arm64/gicv3_its.c @@ -686,6 +686,8 @@ gicv3_its_conftable_init(struct gicv3_its_softc *sc) int extra_flags = 0; device_t gicv3; uint32_t ctlr; + vm_paddr_t conf_pa; + vm_offset_t conf_va; /* * The PROPBASER is a singleton in our parent. We only set it up the @@ -700,8 +702,32 @@ gicv3_its_conftable_init(struct gicv3_its_softc *sc) gicv3 = device_get_parent(sc->dev); ctlr = gic_r_read_4(gicv3, GICR_CTLR); if ((ctlr & GICR_CTLR_LPI_ENABLE) != 0) { - extra_flags = ITS_FLAGS_LPI_PREALLOC; - panic("gicv3 already enabled, can't reprogram."); + conf_pa = gic_r_read_8(gicv3, GICR_PROPBASER); + conf_pa &= GICR_PROPBASER_PA_MASK; + /* + * If there was a pre-existing PROPBASER, then we need to honor + * it because implemenetation defined behavior in gicv3 makes it + * impossible to quiesce to change it out. We will only see a + * pre-existing one when we've been kexec'd from a Linux kernel, + * or from a LinuxBoot environment. + * + * Linux provides us with a MEMRESERVE table that we put into + * the excluded physmem area. If PROPBASER isn't in this tabke, + * the system cannot run due to random memory corruption, + * so we panic for this case. + */ + if (!physmem_excluded(conf_pa, LPI_CONFTAB_SIZE)) + panic("gicv3 PROPBASER needs to reuse %#lx, but not reserved\n", + conf_pa); + conf_va = PHYS_TO_DMAP(conf_pa); + if (!pmap_klookup(conf_va, NULL)) + panic("Can't mapped prior LPI mapping into VA\n"); + conf_table = (void *)conf_va; + extra_flags = ITS_FLAGS_LPI_PREALLOC | ITS_FLAGS_LPI_CONF_FLUSH; + if (bootverbose) + device_printf(sc->dev, + "LPI enabled, conf table using pa %#lx va %lx\n", + conf_pa, conf_va); } else { /*