From nobody Wed Feb 28 14:10:48 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 4TlGV10bmkz5BfdP; Wed, 28 Feb 2024 14:10:49 +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 4TlGV05ss2z4ff5; Wed, 28 Feb 2024 14:10:48 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1709129448; 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=/9FUCQM/aYNCe7RmfHjo6HGhyw2uCpIGbIlGIqw8YxI=; b=B4W1IVQ7D308fkypcc/sjINu3zSUfcSibLFiBQQXA+O+zK81PKuFofRHces3b2BAMb5NjJ wVyNpmdbvCX8WsOK6DMi3aeQJg4PWC3aT9xREepHEC/AnUt7z0DDa3lVF1YjAIcVF8APme apGj2h0fqPMwFexDXEOGsD73RjsXic0jPmUcoMuJ16aOc8vqZAkVxt6PpYxv386y9MZrL2 p8K9OmZkY4nH5pT/VB+6gELxaS/Lsvu8PecurJxiadLpwi5z5iO8r8T1krBPir5id4Aemh omx6RMCW5B4EO3Rnv2O84hl+5TRad2eP1ea53SInKRiG3MTNlZD6xJvLSK1ITw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1709129448; a=rsa-sha256; cv=none; b=SiZSOyC0zQSXUAqQPialbuIahU1+wYopGRzEeRuhdrxhoRLliZ4JsTE2+/AlEQpXi81MJH 7TxHx95PSJYTZ9Rh0LuT/KIqMh0AzJqv2x1i2W6DVsT8WCvA1MxgUwW7fwe2vnv+nnNX9/ /aMghtDvIOqPbj9xUI18xKom1NU6SIF03WYEqQNcV+HZhTw9/YbWjRBYC/T97kIZmJxUWd AfdMQ3uYArJEG9IZr60KT97+2iVCppJ6qRpQYipefT5zN88X2pQ/KPX3YXc/5qZoMi44V+ 7SFezEl5H7zx8ppEWhjV488RI9XLgVvECkYAV6TcNEiHuApjzbS5Aws1CH73fA== 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=1709129448; 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=/9FUCQM/aYNCe7RmfHjo6HGhyw2uCpIGbIlGIqw8YxI=; b=SSOAb6ureJf2cQRiwQzD9QUXCfP6NDrTXSAqfshoBUjyqmO/R9+9jLrXlbIe0Tm3TMaPvS DRh7DBhPA++6UmSe0GkfZgnvFyxvzZXij45wD3Z5BHiMIhlduR3JLLpXLNTZi74YxpE78a GpVOUKDtucZEuUHOHX6pWBzh+/aSlwjDYk2qe5oA9SDOybJkSD+laOFsByns2NhPpR38YC IDFEUOxrhQxf7+n0OZlLFPdfX4X0yoHO8C//5C8QhTT8xar0cI2USQtsKTy5Inih1YXzGO F4j4dIbgiFWtvBt4UzxhoNvIru0Pr5s1NhU+WEM8d2T8kaP3FVebvbQw81sXPA== 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 4TlGV04zgqz10Tl; Wed, 28 Feb 2024 14:10:48 +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 41SEAmLG058432; Wed, 28 Feb 2024 14:10:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41SEAm6X058429; Wed, 28 Feb 2024 14:10:48 GMT (envelope-from git) Date: Wed, 28 Feb 2024 14:10:48 GMT Message-Id: <202402281410.41SEAm6X058429@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: cb4a83cff01c - main - gicv3: If the LPI is already allocated, remember it 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: cb4a83cff01cdf871c78115c942c5b34412914d2 Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=cb4a83cff01cdf871c78115c942c5b34412914d2 commit cb4a83cff01cdf871c78115c942c5b34412914d2 Author: Warner Losh AuthorDate: 2024-02-28 14:09:17 +0000 Commit: Warner Losh CommitDate: 2024-02-28 14:09:43 +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 --- 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 71620eec8fce..9fcf13fe433b 100644 --- a/sys/arm64/arm64/gicv3_its.c +++ b/sys/arm64/arm64/gicv3_its.c @@ -685,6 +685,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 @@ -699,8 +701,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 { /*