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=1796384990; b=gsXq0ulKEatlL/bAKY1N+39h0HCAXFRqUtvLu2nXgdCaXKeBHJU795Qe/8LOTxACTAqD ct2FlEYVJf8B+NgZltbG/hHkbhDFkp1+M9uWA61ltkremKZMnpOOfIS6Nbga7NSpumTiT Ri8DRtC1JyTb7qFTqSYLMf2BD+BJNHVH8yzRCEycNgh+izto1MbnIn38Z9ePNyKTpPO0+ oOHDdjnPZ2fOp8+QW7qCIp7DBxm3SG3fBCp89jS9AbSsqQ2HL4VwHGYygQfxe4wIBKTnG 0DDgjnZq8e0B10BQjcQH+LGCeqJOPUvAUqyFR5aOziB2iwFNiCrm5XqnavJIDQf5KUA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796384990; 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=luH+MiNPO5ONirr5VrMBF/+woKdAN9JIOoXohbY6UwU=; b=iaPfj1Y146HWIj8xJzUSlfnZrbXpiweH/Kh29wjer6sbzDCMrwRSXS7BjdyUQnFTtK1D H7UnpdQkcVzTX1ILxp0s9YtLw5aVIaIhU3jgXtaQRW0KS2K0B1dCMdQRQgBlwVlX907C4 nPJva9PlMVPKD+p5bq5fA8gvnVAAbTLRygC4LlsoZvL/bPr3PruC6cZHUoYbxCW8fXsrZ z6v7MoNh9zEV3HaCr2Y7yfICgoc6BSy+fPd1+JBj7RMnKS9fvUHYeiee8yBquzF4jO68m juo78MKylNx2X65SMjoE19+vyGQqXavUjICNWL63KUQ5zR00qh0gQFl2c6+lxVChWiw== 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=XuBfJXF1; 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 2D855606A322; Fri, 4 Dec 2026 11:49:49 +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=XuBfJXF1 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 608A11F000C2; Fri, 4 Dec 2026 11:49:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796384989; bh=luH+MiNPO5ONirr5VrMBF/+woKdAN9JIOoXohbY6UwU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=XuBfJXF1A3iSEi8Eu3r7VlP+0p2jyeBxDcL8xY0Sv1GaCl0fG0ZkCcIhAsxLcubhB zYccYu/a4mWZCLSjsudmKOm6FXuqdkstVFq2I5Df64KNgcz4qQT49GBzLp8FlLSAfV 28SYLmClhM4kvUMilGe4tMNhIieMDZMwgRMsSQ7A= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Alison Schofield , Li Ming , Dave Jiang , Sasha Levin Subject: [PATCH 6.6 0323/1167] cxl/hdm: Make switch decoder target parsing endian-safe Date: Fri, 4 Dec 2026 18:55:50 +0900 Message-ID: <20261204100710.420553681@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: Alison Schofield [ Upstream commit 3f846646b3d3b5699139e686e1107d231a725860 ] Switch decoder target IDs are stored one per byte, starting with target 0 in the least significant byte. The current code accesses those bytes in memory order, which only matches register order on little-endian hosts. On big-endian hosts, the target IDs are reversed and the decoder is associated with the wrong downstream ports. Place the register values in a byte array in little-endian order and index the target IDs from there, so the target mapping is independent of host endianness. Fixes: d17d0540a0db ("cxl/core/hdm: Add CXL standard decoder enumeration to the core") Signed-off-by: Alison Schofield Reviewed-by: Li Ming Link: https://patch.msgid.link/b0526825b3c3ffdb78837563e178d9aa27b6bbb8.1786143520.git.alison.schofield@intel.com Signed-off-by: Dave Jiang Signed-off-by: Sasha Levin --- drivers/cxl/core/hdm.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/cxl/core/hdm.c b/drivers/cxl/core/hdm.c index 493c024eafc1a..f46e206724642 100644 --- a/drivers/cxl/core/hdm.c +++ b/drivers/cxl/core/hdm.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* Copyright(c) 2022 Intel Corporation. All rights reserved. */ #include +#include #include #include @@ -840,15 +841,12 @@ static int init_hdm_decoder(struct cxl_port *port, struct cxl_decoder *cxld, u64 *dpa_base, struct cxl_endpoint_dvsec_info *info) { struct cxl_endpoint_decoder *cxled = NULL; + u8 target_id[CXL_HDM_DECODER0_TL_TARGETS]; u64 size, base, skip, dpa_size, lo, hi; bool committed; u32 remainder; int i, rc; u32 ctrl; - union { - u64 value; - unsigned char target_id[8]; - } target_list; if (should_emulate_decoders(info)) return cxl_setup_hdm_decoder_from_dvsec(port, cxld, dpa_base, @@ -957,11 +955,12 @@ static int init_hdm_decoder(struct cxl_port *port, struct cxl_decoder *cxld, return -ENXIO; } - lo = readl(hdm + CXL_HDM_DECODER0_TL_LOW(which)); - hi = readl(hdm + CXL_HDM_DECODER0_TL_HIGH(which)); - target_list.value = (hi << 32) + lo; + put_unaligned_le32(readl(hdm + CXL_HDM_DECODER0_TL_LOW(which)), + &target_id[0]); + put_unaligned_le32(readl(hdm + CXL_HDM_DECODER0_TL_HIGH(which)), + &target_id[4]); for (i = 0; i < cxld->interleave_ways; i++) - target_map[i] = target_list.target_id[i]; + target_map[i] = target_id[i]; return 0; } -- 2.53.0