From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1C31334A3A5 for ; Thu, 25 Jun 2026 07:45:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782373505; cv=none; b=rJnLeHItj8jhlObI5T+CdN/3L+eB3EAHPA01jabpOPoz3XF251qdMUWvCpGXjAfYs/2UafToUfIjw2W5UlczHiTQi+69G5gzmNarL4+3dQyIqCWSY5aRFpviTC/bS6bsWj7m1CRhAjFDIDy2GuZkg5y42nr6xb5OEB/MAhXpP6w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782373505; c=relaxed/simple; bh=YeJXzriIDfluh0Ye+Z0A3XrygBXFzdp3e/NMJXQULuA=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=CUpKo4IFyKX8d6uDjgdbymxwBN1JfDPPMxBG9N5IO4F0XNp7bbs3J3BUvP6IIfaBuuVcxBz8kAXdE6DFQL5vMKiMMlcNyE8QVe4fqdRG5yDB0539aDGdZPuJ6ueFrQNp7ujnsFwvP4wflIe1KQt7F1rQ8SarPJnm3g1gwH5Wn5A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Su3Fye9N; arc=none smtp.client-ip=209.85.221.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Su3Fye9N" Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-45fd464d51fso1125177f8f.3 for ; Thu, 25 Jun 2026 00:45:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782373502; x=1782978302; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=L8xoSSuA8UVVk90oX5gPPxTiv5/TluVnjfAU4xzudUI=; b=Su3Fye9N2hW28SG1LG8SuUuE7kAw8X895/arFkNUDwVE3q6GWXMIQNKUYQ2jOYk2Ac OsDhXNTQp7fz3LLU/8pV+U16ZSFwVj4ic3+E+1Fgm7aQm8gm8ZBU/AHi88st9cMdXEFQ 4aI4Rre7Or0DJOkSSYL1vBHC/IxIO5nZErh26kgw19NGjoFQciNUcvB+uAoBhLeqpdpG X0MBkxj7I0obIgLm0AEk4U8Uw0NA5db1IO9Bwbd0kGDMNQPYXZXv4ISq/rTGp8Z4nsAe 68NJhgF1GJCNoNFAiWLV159E6RluLHfL5agDXxkHuKWVQUVMGAZKN4BRtete0tUAixwG f30g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782373502; x=1782978302; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=L8xoSSuA8UVVk90oX5gPPxTiv5/TluVnjfAU4xzudUI=; b=N3Bba7wtmVVi6+B26iBNPqeIoHytBK7pZ9/uRv9/byObEcDP4fIdC6W++YEhYmZJgD 4fEQA4zbpBVz00NC8PG21br7238dspZdzIRK8BdfnN1pvLvp4LLfM9EvHR/5UNKBIx9i 2tUS0okQ+YSCl74DQW6Kl6fCJmj3SZ8U1dbwOTnXialV2xro7J4py/vYSYbbzUk00hVR ANAZG9fDdWhexLWDrWd6G6JB49fUnKK/VzkJq7Q7RI2N8MkncuezURSHrryjJ40MLY8B 3Vrswh3Npx4ZULDP2EEYp8wE53FXfOnn1pVB4FyC84kzUdzT86YSrXfwYaioOZYLLsi2 3uWA== X-Forwarded-Encrypted: i=1; AHgh+RpbnbQEnip/gfDd2/DgwjRWZlNqVOf45i5oTTpDQ4yEPNZKJdeqs3VXGk6zuMo3g1H7e8Ko2uaJV4eQkfg=@vger.kernel.org X-Gm-Message-State: AOJu0Yy/8yMrOSIZQeo3Ylc6dokotnNjf4yHK8dm4yFInO5OX8U0anv7 VftQrFec60zRhOrlsjTLykTCUj8xsYYNmH4vQdvCZGSO9D3Gl4Bd+Hwk X-Gm-Gg: AfdE7clHenGjAr0z5ecJnpQ3X7E6G68eTFENhaw15hj+G2oquBsdX0NCiWeuRGt6lJg XhS60eIzX1+5nw1YMHAM7uhu5tqmHtoqOXZ863oVjW+BwKyF949hzJFqmS/KBzIDyEsvs2lPPST 4RJPKAzHfTMlwWRXw69a8txSSW3tqLByQbx+pSui0CJptVpyq1/+5v2FV+1cIJha8oBPzhn3Rv0 sYVQmQcE7J2Xz02lzaJ1r8D6Ugpe7xdYZoGvPPqg5WaO+vxxuHzErT+cBRRN72cLImdF7hcHwN+ jB2sSPOjhU6wR77pyXvnPBWh27LLNAwDNa0bRh5GZ6uW5D5us1bPf89DY6kcEv5f8xEd4a0hb0H NFNNVE+uQgOCrI9syXILscbl3X/TfgamzHrWQA8H9y/0w45fKU/WWa7SrnKcXoiEG3ewL5z7r3+ KVkW26kS2TMLXscWyVKmEE8/w6mezS7elpeVf6wl/RVSzERHtOvA== X-Received: by 2002:a05:6000:428a:b0:465:1c33:1494 with SMTP id ffacd0b85a97d-46dc04610damr2026412f8f.2.1782373502207; Thu, 25 Jun 2026 00:45:02 -0700 (PDT) Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-46caad603b3sm10957157f8f.7.2026.06.25.00.45.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jun 2026 00:45:01 -0700 (PDT) Date: Thu, 25 Jun 2026 08:44:59 +0100 From: David Laight To: Jakub Kicinski Cc: Daniel Golle , Andrew Lunn , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH net 1/2] net: dsa: mxl862xx: avoid unaligned 16-bit access in api_wrap Message-ID: <20260625084459.7393409f@pumpkin> In-Reply-To: <20260624175239.1b97aaa6@kernel.org> References: <599327521db465a534d277de53ab9b6cac01928b.1781702256.git.daniel@makrotopia.org> <20260619100154.794168e5@pumpkin> <20260624175239.1b97aaa6@kernel.org> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Wed, 24 Jun 2026 17:52:39 -0700 Jakub Kicinski wrote: > On Fri, 19 Jun 2026 10:01:54 +0100 David Laight wrote: > > > The MXL862XX_API_* macros pass the address of a stack-allocated, __packed > > > firmware-ABI struct to mxl862xx_api_wrap() as a void *. The struct has an > > > alignment of 1, so the compiler is free to place it at an odd address. > > > > > > mxl862xx_api_wrap() reinterprets that buffer as a __le16 * and accesses it > > > with data[i], for which the compiler assumes the natural 2-byte alignment > > > of __le16 and emits aligned 16-bit loads/stores (e.g. lhu/sh on MIPS). > > > When the buffer lands on an odd address these fault on architectures that > > > do not support unaligned access, such as MIPS32. > > > > Isn't the correct fix to not pack the structure? > > (or probably any of the associated structures??) > > Agreed, this is very silly: > > struct mxl862xx_register_mod { > __le16 addr; > __le16 data; > __le16 mask; > } __packed; > > But some structs won't get aligned: > > struct mxl862xx_mac_table_clear { > u8 type; > u8 port_id; > } __packed; Does that one need an aligned(2) ? > So I guess the "just don't pack" will have some corner cases, too. The main problem is the original 32bit arm abi which 32bit aligns all structures. But that is pretty much dead and would want a packed_if_arm_oabi define. Unlikely to be relevant for this code. David