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=1796384953; b=QksXV0vSExSaZc3GpDPSh1pD4pz4XYJWiBG3BD/o85JiQGXl7BgQ90anDxgDzs50zY+/ pnNujqghdb7DQyZplQCWN5XgxwN284j1A9/07U+pyI8sZjF48PQ+rkUEHa06RK8DEdbq8 1hNe8eBmNrhtH5loNJ/68ldjOz4ylM7bF1KgOZk6BNsB1jk04IYUQxgY1MRuRaCxiiOcv DaxBMqFHuFo3meL9fZshC09kxMP1CIRI2tzak2kRZ5q2n9yv/8uTUGJducXqJtEwzPQ5k DGtw6is3dT6hiSEOqVY3LueB9yeKPrXegWpIN8Ea1mV1Q49MaMqfT8lggMjUr9VUsqA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796384953; 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=4H96oNK05HPDqGMFcHSZDV+GLRl/SceIS9CMfb9cXRM=; b=PoXmTQnVyfvshzp/sfRCfeYhKfG6zw2I9FNP72qSvZpqlWjC2Nh+0YzuEFItJtRixLV8 16q0R27Jiy0Aq1WqY+Ldut86Frp6/aOTgF0mnJ2anPGdTgrRpGEqsGdwoxmgo5Et/DlV1 h0xLQCQ9viGsg+QeeM+Zr3eU+4N4vPIr6OWX5WGfLIHU5eE6FiPHvselMcM6lfo7pOSqu GeOaEyD7sFIUuZ5amc+xFmTJ9fSVl/BIaOkK9skT7v1v+Ki/kk60ItFaSg/Rf0dLA2kc5 ZHVtzt0hkGazw0IMUbkACHVzb6jywTeCnPejQSVcxA2AIdjmmYCQylegMlgxTgiJEqQ== 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="kFjA/4x+"; 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 F1E53606A32D; Fri, 4 Dec 2026 11:49:12 +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=kFjA/4x+ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 27A551F00A0A; Fri, 4 Dec 2026 11:49:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796384952; bh=4H96oNK05HPDqGMFcHSZDV+GLRl/SceIS9CMfb9cXRM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=kFjA/4x+z22jGpDasTiFpKTIks7TK3QsYzj0pvxvnYCcSVDT/HIiwo0pWfIFteCEu ubt2HK7sYbbWzUAE7Qz0yimTvugY3UOqjlcP2MSVrA+1z+1KDDuq/Lz/wOWqNcZn0f eXhiT7Ikwa8GAOm3qIxWOAF/jDi26nk/m4IIZmdg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Nicolin Chen , Jason Gunthorpe , Mostafa Saleh , Pranjal Shrivastava , Will Deacon , Sasha Levin Subject: [PATCH 6.6 0360/1167] iommu/arm-smmu-v3: Ensure L2 tables are visible before L1 ptrs Date: Fri, 4 Dec 2026 18:56:27 +0900 Message-ID: <20261204100711.360666391@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@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.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Mostafa Saleh [ Upstream commit 84366fb547ed987c4857311da0e5127d95bf97e6 ] Commit 6fabce53f6b9 ("iommu/arm-smmu-v3: Add a missing dma_wmb() for hitless STE update") adds a dma_wmb() to arm_smmu_write_entry() to make sure stream tables and context descriptors are observed first. However, STE L1 table descriptors are configured directly via WRITE_ONCE(), where before that they were zeroed with memset() inside dma_direct_alloc() then written to abort in via memset() also in arm_smmu_init_initial_stes() without a barrier in both cases which means that the SMMUv3 can observe the allocated table before the written descriptors causing it to fetch random data. Similarly in arm_smmu_write_cd_l1_desc() where the L1 CD is written after dma_alloc_coherent() with no barriers. Add dma_wmb() in both cases. Fixes: 48ec83bcbcf5 ("iommu/arm-smmu: Add initial driver support for ARM SMMUv3 devices") Reported-by: Sashiko <> Reviewed-by: Nicolin Chen Reviewed-by: Jason Gunthorpe Signed-off-by: Mostafa Saleh Reviewed-by: Pranjal Shrivastava Tested-by: Nicolin Chen Signed-off-by: Will Deacon [ sashal: Adapted the two helpers to the older __le64 *dst signatures and desc->span, adding dma_wmb() before each WRITE_ONCE(*dst, ...) in place of upstream's struct-based context. ] Signed-off-by: Sasha Levin --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c index 2c5e61786b368..b9b1703a0132c 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -1033,6 +1033,9 @@ static void arm_smmu_write_cd_l1_desc(__le64 *dst, u64 val = (l1_desc->l2ptr_dma & CTXDESC_L1_DESC_L2PTR_MASK) | CTXDESC_L1_DESC_V; + /* Ensure the zero-cleared L2 table is fully visible. */ + dma_wmb(); + /* See comment in arm_smmu_write_ctx_desc() */ WRITE_ONCE(*dst, cpu_to_le64(val)); } @@ -1248,6 +1251,9 @@ arm_smmu_write_strtab_l1_desc(__le64 *dst, struct arm_smmu_strtab_l1_desc *desc) val |= FIELD_PREP(STRTAB_L1_DESC_SPAN, desc->span); val |= desc->l2ptr_dma & STRTAB_L1_DESC_L2PTR_MASK; + /* Ensure the new L2 table is fully visible. */ + dma_wmb(); + /* See comment in arm_smmu_write_ctx_desc() */ WRITE_ONCE(*dst, cpu_to_le64(val)); } -- 2.53.0