From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from fhigh-a3-smtp.messagingengine.com (fhigh-a3-smtp.messagingengine.com [103.168.172.154]) (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 D4A3F19BBA; Thu, 9 Jan 2025 06:29:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.154 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736404167; cv=none; b=LPbsFBKmw9+s3m1ba0WRwHbphuwt8fnJQRkh+/8DLyWdhRIjxmEmQJjL7AvqftZn8o/WngUc9znH0kWIwnvfLg7eRBSvWR21KRnosxR+krVJSs8J/34kSUhC25grBI4yMwBUy8QGPP5oFcilEkW1IA0QaSlbF0v/8Vv64AJe2Ts= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736404167; c=relaxed/simple; bh=rTOSHpWKA/TFQljZP9dDng0HmRxk6TEHGd4vINZJUMU=; h=MIME-Version:Date:From:To:Cc:Message-Id:In-Reply-To:References: Subject:Content-Type; b=pQIdnHmeYLFXTuBuB4cdmdSAICowxtk4QS8j5NtQaWZIYLhzlVy1PFwKxiKfrNevvUx9FO5v3C9Zy6I2sjNsb9unhaDNFp1Io9dXYTFpBedCEoA+y6r6C+fIkvfluasr/p0o3BNyDI4YFER4naIsKw3vxVKwxVboGMfAadQbCQ4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arndb.de; spf=pass smtp.mailfrom=arndb.de; dkim=pass (2048-bit key) header.d=arndb.de header.i=@arndb.de header.b=OJF+XRF0; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=SHBUJucD; arc=none smtp.client-ip=103.168.172.154 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arndb.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arndb.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=arndb.de header.i=@arndb.de header.b="OJF+XRF0"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="SHBUJucD" Received: from phl-compute-10.internal (phl-compute-10.phl.internal [10.202.2.50]) by mailfhigh.phl.internal (Postfix) with ESMTP id B196411401D4; Thu, 9 Jan 2025 01:29:23 -0500 (EST) Received: from phl-imap-11 ([10.202.2.101]) by phl-compute-10.internal (MEProxy); Thu, 09 Jan 2025 01:29:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arndb.de; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1736404163; x=1736490563; bh=r0H4KhJhw9oZuXiFEcpgNiv0lbM72Quzo+7KCVOexSs=; b= OJF+XRF0U4rcqHlqzxfE/9HFzMYq5aG5GKmv7zTowKvVjX8cQTQhB3jJmPk3OT+y VwHsgJh6NhnuzrOM7QFarNyqe+xcXRh6rDVK4RYxAwWomkOWd74NqmhJVrlBL8uJ 9ZEEPx1t41nkHgyuvXW7Rp9Kel4XMpqEts9qN/dS+vVcZknCEgY9dwE2J7LRxwQ8 VIUBLB0aAWgWuEaTtf8c5PS8rpE/8Y6jK0t+HESb6ekgCFBLEzNOCjnG3R5mcQaB DL4LVIJ3UyRvUsBybU9cDHiaJN6JVcSaYeg8VjrMzYe8wvr0jM+bw3u6fAChxfsO ugV/TfKFPSOWAKdz9iLmBw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1736404163; x= 1736490563; bh=r0H4KhJhw9oZuXiFEcpgNiv0lbM72Quzo+7KCVOexSs=; b=S HBUJucD721QMcK6+decH0Ebq6wycu3cf18d0JDbsBgfydEWi2K/GoyqpeN9yddAa lbrKMfRFQTGnqqoFZC3grRMAM+/StVfrpNdWc0DNUIECiY4rTfliOBpgLDrqclr3 N3BT/Aj+97dEq7ySQEHeKg7lRGi7i1K0VlTM5o/D6SmVOoPfVqSRyRe0eoodw2ld +pKJ3P2gwlxGB8Hx9k09hNzlwySEkFvYCWj8yEbcvxlC5a6hjQlEJ8eLVufDwKVV 6Jr69K5OtO+CXI5m+/mNmktZuNwj+cTdXkffzScZ1Ft43ppYiLWBD4hYoy5IzoXM uzlNZMCxc3dHmnB3UPgyA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrudeghedgleehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhepofggfffhvfevkfgjfhfutgfgsehtjeertdertddt necuhfhrohhmpedftehrnhguuceuvghrghhmrghnnhdfuceorghrnhgusegrrhhnuggsrd guvgeqnecuggftrfgrthhtvghrnhephfdthfdvtdefhedukeetgefggffhjeeggeetfefg gfevudegudevledvkefhvdeinecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpe hmrghilhhfrhhomheprghrnhgusegrrhhnuggsrdguvgdpnhgspghrtghpthhtohepledp mhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepudekvdehheduudejudehleesudeife drtghomhdprhgtphhtthhopehrohgtkhhsfigrnhhgjeesghhmrghilhdrtghomhdprhgt phhtthhopegtrghsshgvlheskhgvrhhnvghlrdhorhhgpdhrtghpthhtohepkhhishhhoh hnsehkvghrnhgvlhdrohhrghdprhgtphhtthhopehmrghnihhvrghnnhgrnhdrshgrughh rghsihhvrghmsehlihhnrghrohdrohhrghdprhgtphhtthhopehkfieslhhinhhugidrtg homhdprhgtphhtthhopehgrhgvghhkhheslhhinhhugihfohhunhgurghtihhonhdrohhr ghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdroh hrghdprhgtphhtthhopehlihhnuhigqdhptghisehvghgvrhdrkhgvrhhnvghlrdhorhhg X-ME-Proxy: Feedback-ID: i56a14606:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 2ED802220072; Thu, 9 Jan 2025 01:29:23 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Thu, 09 Jan 2025 07:29:01 +0100 From: "Arnd Bergmann" To: "Hans Zhang" <18255117159@163.com>, "Niklas Cassel" Cc: "Manivannan Sadhasivam" , =?UTF-8?Q?Krzysztof_Wilczy=C5=84ski?= , "Kishon Vijay Abraham I" , "Greg Kroah-Hartman" , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, rockswang7@gmail.com Message-Id: <2b6eabad-ebd1-4e7d-b4bf-6b818dfc20ac@app.fastmail.com> In-Reply-To: References: <96b3a0f7-f144-4f2a-9f84-82c31d8ec23e@163.com> <270783b7-70c6-49d5-8464-fb542396e2dd@163.com> <4bfb6c46-6f93-431b-9a8c-038bc7f77241@163.com> <7e025613-3516-4957-b83a-70b125a24fa7@app.fastmail.com> Subject: Re: [v8] misc: pci_endpoint_test: Fix overflow of bar_size Content-Type: text/plain Content-Transfer-Encoding: 7bit On Thu, Jan 9, 2025, at 03:59, Hans Zhang wrote: > On 2025/1/8 22:13, Niklas Cassel wrote: >>>> Ok. Looking at do_div(), it seems to be the correct API to use >>>> for this problem. Just change bar_size type to u64 (instead of casting) >>>> and use do_div() ? That is how it is seems to be used in other drivers. >>> >>> I think using div_u64_rem() instead of do_div() would make this >>> more readable as this is always an inline function, so the type can >>> remain resource_size_t, and the division gets optimized well when >>> that is a 32-bit type. >> >> After patch 1/2, we no longer care about the remainder, so I guess >> div64_u64() is the correct function to use then? div_u64() is the correct interface here, div64_u64() is the even slower version where both arguments are 64-bit wide. > >> drivers/misc/pci_endpoint_test.c:311:11: warning: comparison of > distinct pointer types ('typeof ((bar_size)) *' (aka 'unsigned int *') > and 'uint64_t *' (aka 'unsigned long long *')) > [-Wcompare-distinct-pointer-types] > 311 | remain = do_div(bar_size, buf_size); > | ^~~~~~~~~~~~~~~~~~~~~~~~~~ You don't use div_u64() or div64_u64() here, do_div() is the macro version that must be called with a 64-bit argument. Arnd