From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9EBF91A5BBE; Sat, 2 Aug 2025 15:41:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754149271; cv=none; b=i5sXdnx0C+ePSW3tmHpsZ5Ebg8/3pDQ676nbMYHwUmNg0aOugSvyHxcX8NzpemEpO20bhNsKj4a3AhapTfwXNFBE+LZe6kljYtrzfriTuhaQQ2MfEAhTQ98WpfA1AZ+VoEplmvpOkyYB/LETevsQh5AcPUyJ2tBCHUq3Q/85weU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754149271; c=relaxed/simple; bh=Y6YAQtLntvTlOEW+/be99fXZeJ/UoP5+1aG+orwrsxU=; h=MIME-Version:Date:From:To:Cc:Message-Id:In-Reply-To:References: Subject:Content-Type; b=Cq4a8bU9a0DRrhlKNO2Eq6FLZX2DufofmFiDK4h5W/Ixa6UdZoSMJPIomramvZiUy4jizJgrfxyrBwW811nbrUMnu2PG2ONtplp0vLyjdseGx2RnVGMXU8RxNXTXwof88QLUZLyJ1KCU2Zk+3jstFbeZi+zFX4TJD2Fosrt24fY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hvw+/6xR; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="hvw+/6xR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 764B8C4CEEF; Sat, 2 Aug 2025 15:41:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1754149271; bh=Y6YAQtLntvTlOEW+/be99fXZeJ/UoP5+1aG+orwrsxU=; h=Date:From:To:Cc:In-Reply-To:References:Subject:From; b=hvw+/6xR83WKTCHsOvvN8oU9MCS8cE1YHzb0k4qrITLley6T4I32jTBBX+qUt/fom XpoxSxIt0u2VLnw8n8Op7bGYv7FrVjTdIYcjdzdf3xiNT7wP8erbfsLjbnvWmg8MnD VzVc+rok24tglZVLDMjWGg3lO/ouNXbHhCqIdl4tCIx4NXw1Wnrye7AWHbryIib312 bVf/FmggVyQ1sFP8G1L2vuyb19QiZHh40e0AaY/1jdp3fMrKWXmsPXgUkZaoWw4FQA tg0qRxlngk2RJf9sXyk807cUBqMHBrkUAjgKkR/pkF+kIx+0U3NTrd3sRmwSFvru7k fJQtEqEjFBW3A== Received: from phl-compute-05.internal (phl-compute-05.phl.internal [10.202.2.45]) by mailfauth.phl.internal (Postfix) with ESMTP id 7EA9CF40066; Sat, 2 Aug 2025 11:41:09 -0400 (EDT) Received: from phl-imap-02 ([10.202.2.81]) by phl-compute-05.internal (MEProxy); Sat, 02 Aug 2025 11:41:09 -0400 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgddutdeileeiucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepofggfffhvfevkfgjfhfutgfgsehtjeertdertddtnecuhfhrohhmpedftehrnhgu uceuvghrghhmrghnnhdfuceorghrnhgusehkvghrnhgvlhdrohhrgheqnecuggftrfgrth htvghrnhepjeejffetteefteekieejudeguedvgfeffeeitdduieekgeegfeekhfduhfel hfevnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprg hrnhguodhmvghsmhhtphgruhhthhhpvghrshhonhgrlhhithihqdduvdekhedujedtvdeg qddvkeejtddtvdeigedqrghrnhgupeepkhgvrhhnvghlrdhorhhgsegrrhhnuggsrdguvg dpnhgspghrtghpthhtohepvddtpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopedu kedvheehuddujeduheelseduieefrdgtohhmpdhrtghpthhtohephhgrnhhsrdiihhgrnh hgsegtihigthgvtghhrdgtohhmpdhrtghpthhtohepjhhinhhgohhohhgrnhdusehgmhgr ihhlrdgtohhmpdhrtghpthhtohepsghhvghlghgrrghssehgohhoghhlvgdrtghomhdprh gtphhtthhopehhvghlghgrrghssehkvghrnhgvlhdrohhrghdprhgtphhtthhopehksghu shgthheskhgvrhhnvghlrdhorhhgpdhrtghpthhtohepkhifihhltgiihihnshhkiheskh gvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhpihgvrhgrlhhishhisehkvghrnhgvlhdr ohhrghdprhgtphhtthhopehmrghniheskhgvrhhnvghlrdhorhhg X-ME-Proxy: Feedback-ID: i36794607:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 4B0EE700069; Sat, 2 Aug 2025 11:41:09 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface Precedence: bulk X-Mailing-List: linux-s390@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ThreadId: Tea76caf5b1f73f76 Date: Sat, 02 Aug 2025 17:40:28 +0200 From: "Arnd Bergmann" To: "Hans Zhang" <18255117159@163.com>, "Keith Busch" Cc: "Gerd Bayer" , "Manivannan Sadhasivam" , "Hans Zhang" , "Bjorn Helgaas" , bhelgaas@google.com, "Alexander Gordeev" , "Christian Borntraeger" , =?UTF-8?Q?Ilpo_J=C3=A4rvinen?= , jingoohan1@gmail.com, =?UTF-8?Q?Krzysztof_Wilczy=C5=84ski?= , linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org, linux-next , linux-pci@vger.kernel.org, "Lorenzo Pieralisi" , "Rob Herring" , "Niklas Schnelle" , "Geert Uytterhoeven" Message-Id: <07739ab9-4e34-430c-ac1d-d1f370baccea@app.fastmail.com> In-Reply-To: References: <20250731183944.GA3424583@bhelgaas> <6e34b4af-dff9-4360-b3da-c95ca7c740c9@app.fastmail.com> <9a155e45-f723-4eec-81d3-2547bfe9a4e9@cixtech.com> <06f16b1a55eede3dc3e0bf31ff14eca89ab6f009.camel@linux.ibm.com> <659b8389-16a7-423b-a231-5489c7cc0da9@163.com> Subject: Re: [PATCH] PCI: Fix endianness issues in pci_bus_read_config() Content-Type: text/plain Content-Transfer-Encoding: 7bit On Sat, Aug 2, 2025, at 17:23, Hans Zhang wrote: > On 2025/8/2 02:08, Keith Busch wrote: >> On Sat, Aug 02, 2025 at 12:54:27AM +0800, Hans Zhang wrote: >>> >>> *value = (type)data; \ >>> >>> And this function. Could it be that I misunderstood something? >> >> The above macro retains the caller's type for "value". If the caller >> passes a "u8 *", the value is deferenced as a u8. > > In this macro definition, bus->ops->read needs to ensure the byte order > of the read, as Lukas mentioned; otherwise, there is also a big-endian > issue at this location. No, there is no endianness problem here, the problem with casting the pointer type like u32 *value; *(type *)value = data; or any variation of that is is that it only writes to the first few bytes of *value, and that introduces both the observed endianess problem and possibly worse uninitialized data usage or out-of-bounds stack access. Arnd