From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796387470; b=00LNWaiiA/QmQzID4Dm7n/ukFgrga0QJYhUJsKbHfGt6dev1s5V0rMQrOy29/Of8gnL9 jW7jRkoUfpUw/dzMxbRZxbTIGeV1TtdCG4Nv5Hi3VkRhjn8glhGvHnaH8h5/s9QZCPOd7 7FvHUih/xTgqe3YoAbKifQXztEkU1v5uZ1UCrkwzhYvdkFv/TAuPYMs0R6BS+99sF3Zut LyWs1c3Ged7xNgcwQ+mb6qibNJG0589uYJf4GRvVBXl2L1ioilVNiPm/VwHcLBuiX6IhG hO2EtHvsvsBqthqSvV969gzE02x2+Bu5IDzPT01g2qw1Ob7nFKbTAdOJ89DjOrqkmvg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796387470; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=qQb5FmonvT1FCXk4PNCd8vs71s3z3d6XuE0obByVtYM=; b=eMjzxcsLln1i7SGybSpsXbckhJJT8ekI/7Kl9qo//NIUS4WnwXn3kmMQWyJ8rl6IOj9c zFDlTAp/0nr7oeCGlDDcQ76G8HFBnrYDry3hau8nTNluZ06e9lTl+opMna0Sf/2CAw4DI 3iJOzab0Gc55RgoA77atJzhXVDhJYw25qo/KQnVM2kbHx+o6mVV8tspKLzRaxXMEy1YXv qq0wGXdQid0s/lf6t94F6sGF+Bzfv8vAvvFM5yh50fnNKOKXku6uC8je6W8YMj0PZOd0y Wtz5K4WQryv4e8Giz6xwEqk5DMr+/cgE7Qx53g5TPuwYo1HpKzqNRJZK16JjtLQjw9Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=thAz1vlu; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2001D606A322; Fri, 4 Dec 2026 12:31:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=thAz1vlu Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8CEFD1F000CE; Fri, 4 Dec 2026 12:31:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796387470; bh=qQb5FmonvT1FCXk4PNCd8vs71s3z3d6XuE0obByVtYM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=thAz1vlu5d2FQgPgzFxsiEH5XEjS30YlTSb+PsvJI0Lpu8yP3QzLZutmJ5qr3GZ6g TsT4ao2okpXioHFafwHwXdJkVPTP+e4Pl6zcntGT2EFmK1luwl9IsfidL959RlHG9M 2wlHQhirJuSMK/RDBXlFsAGgqdoE2nv9eXC2Vbxc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Marcel Hofmann , Mathieu Poirier , Sasha Levin , Peng Fan Subject: [PATCH 6.1 0257/1059] remoteproc: imx_rproc: Allow mappings ending at region boundary Date: Fri, 4 Dec 2026 18:56:28 +0900 Message-ID: <20261204100650.930842713@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Marcel Hofmann [ Upstream commit 749eed0c7178c8d53ce4c9acdda4a545721c494b ] The address range checks in imx_rproc_da_to_sys() and imx_rproc_da_to_va() use a strict comparison for the exclusive end address of the requested range. As a result, a valid request that ends exactly at the end of an address translation or mapped memory region is rejected. For a region [start, start + size), a request [addr, addr + len) is contained when: addr >= start && addr + len <= start + size This occurs when a loadable ELF segment fills an entire mapped memory region. This can be produced by a linker script that extends the resource table section to the end of its designated region: .resource_table : { . = ALIGN(8); KEEP(*(.resource_table)) /* Resource table */ . = ALIGN(8); . = ORIGIN(m_rsc_tbl) + LENGTH(m_rsc_tbl); } > m_rsc_tbl =0x00 This produces a ELF program header like: LOAD 0x010000 0xa4220000 0xa4220000 0x01000 0x01000 R 0x1000 In this case, the segment size matches the mapped region size exactly, causing the address translation to fail with: bad phdr da 0xa4220000 mem 0x1000 Rework the upper-bound checks to allow ranges ending exactly at the region boundary while guarding against integer overflow. Fixes: a0ff4aa6f010 ("remoteproc: imx_rproc: add a NXP/Freescale imx_rproc driver") Signed-off-by: Marcel Hofmann Tested-by: Peng Fan #i.MX95-19x19-EVK Link: https://lore.kernel.org/r/20260827123136.438798-1-marcel@hofmania.de Signed-off-by: Mathieu Poirier [ sashal: Dropped the upstream context block that skips other cores' address-translation entries, since this tree lacks ATT_CORE_MASK and core_index, and applied only the bounds-check change. ] Signed-off-by: Sasha Levin --- drivers/remoteproc/imx_rproc.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c index 37612ced203ac..3225d952c8930 100644 --- a/drivers/remoteproc/imx_rproc.c +++ b/drivers/remoteproc/imx_rproc.c @@ -358,10 +358,13 @@ static int imx_rproc_da_to_sys(struct imx_rproc *priv, u64 da, /* parse address translation table */ for (i = 0; i < dcfg->att_size; i++) { const struct imx_rproc_att *att = &dcfg->att[i]; + u64 offset; - if (da >= att->da && da + len < att->da + att->size) { - unsigned int offset = da - att->da; + if (da < att->da) + continue; + offset = da - att->da; + if (offset <= att->size && len <= att->size - offset) { *sys = att->sa + offset; if (is_iomem) *is_iomem = att->flags & ATT_IOMEM; @@ -392,9 +395,14 @@ static void *imx_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len, bool *i return NULL; for (i = 0; i < IMX_RPROC_MEM_MAX; i++) { - if (sys >= priv->mem[i].sys_addr && sys + len < - priv->mem[i].sys_addr + priv->mem[i].size) { - unsigned int offset = sys - priv->mem[i].sys_addr; + u64 offset; + + if (sys < priv->mem[i].sys_addr) + continue; + + offset = sys - priv->mem[i].sys_addr; + if (offset <= priv->mem[i].size && + len <= priv->mem[i].size - offset) { /* __force to make sparse happy with type conversion */ va = (__force void *)(priv->mem[i].cpu_addr + offset); break; -- 2.53.0