From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (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 E41893ADBB4 for ; Wed, 24 Jun 2026 08:21:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782289319; cv=none; b=dUJEWkJsIEKzoedGZgSrA+8uuMB+wzTGmqXc2mRMxF+RA+XQTFFmX8iB4WQb4AeAjcAjyEfHTaFnPzHzHih+Gu38rb3b+UFwvcsdcl0JRVapeDwTnXoxZCT0ZdWdNi4xRTSvG1Ge7EAA3TMy6WvN3i4m4ulhe+2sLNV2EFPrxms= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782289319; c=relaxed/simple; bh=vWn6dm3R7Kmkyi4Uh4/4JYHK+SHYjGqshNPj+yAotDc=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=i8mApa+zPhS+NLrsrVMo1praR3RHzfX9G6+9UPBnKsgAoOGHfpz4OLEEHfCa8uCVpK/S6jxEUh3+XYCiEwUYYzSal2kEM8ukzexKsJKhDkrvFq6KGRDlQYHfeq8Cnp8zczsJbwaZypWh2l84v3bCMjajImqoAY9r+UNxwH6Fjqw= 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=Fpc3L6W/; arc=none smtp.client-ip=209.85.128.46 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="Fpc3L6W/" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-49241896317so3239655e9.3 for ; Wed, 24 Jun 2026 01:21:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782289313; x=1782894113; 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=nrNkRYpGE2wr41uvhQoSOFvFgie0Z5ui0eSKjkt6gnI=; b=Fpc3L6W/CYL2JMfNM/0e++mBjj9pLhAcjt1y4tw+2IoFug2Msk5wxakbL/TqW4lN9p p8sU/u7GPDNy6ktZ0Gq5TTqQxT4ihZRQP6bSUbT1tiPE4fOMBX/OapGmvkGo/xQgcKJb l9hwCpdmbEGxSSqWRMAltbIoBSWCP9pZYnxPGwdgqNzAfL226No2qtcZ31ob/VgZwAUl qVi0Fs8M7guwQ9dR3IMtG5J/AnCVwOAdzjzA4xBUfbP4X5Mx28aqbcvpOJ8Vf53qbX6x Wtizrupm5JD+torMBIPVN43k0CkajLJMO02/BloCriECqGxIXX3/m36szq2u1JU9zzAV 2ayw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782289313; x=1782894113; 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=nrNkRYpGE2wr41uvhQoSOFvFgie0Z5ui0eSKjkt6gnI=; b=rPX4iKrkkWK7XJpXe8NS/ZxrJju9S7w1Ng+TFt5jR5pFDXrYBIpRhb5yh3jM3Yju90 WOPtinxq7yCg7oZ37IWt1n1+Rd0fvF4YUsShfuVPfhgSeocbeAugZvkclzHezAtyFZlP QboQ6cjyKaNA1dr/1S7u0J3GDIi6SwvGQPc6z2J/kBOpOzFmIrcQF1vxkXM+noLh4f+o 014QPDn7NR7uSzlWLhcLYssXd/ysqivQIRDqyn71TLyrLnZvCr/QszSoriLcxujkH+OT eIUDlFzcI8kUn+582ChfyOfQwvTuSw3sq+j2IAnNa4a8FmnsfUrr5rdoubC6FfkRIl3C G1VQ== X-Forwarded-Encrypted: i=1; AFNElJ97tXtvpG7kcwF6ZGSV4KWiAislhNU/x1JfHYCmd5KmwJpiiPbjgUHO5xeTtlppSgOA0iw/Ft/JF1C5D0A=@vger.kernel.org X-Gm-Message-State: AOJu0Ywsm9Aes4U+s9FFQSmrqcInBdHTbUAJ63Hqvh9ES+0BVhq1dTfz FdTwjg42X24HCsxKxvLk/zs3ZSSpwBZ1CORMnd05WPFTC+u41QFyVwdp2Hkw70RX X-Gm-Gg: AfdE7cmybAWhExBtbXttl0xIS58zCS87ZmpVUFHYVvL7IDZBH6hl9phcNc8G5Zs6emO AjQJHaWR053LUmH2tKDBJPOkH1268zNCrOlx9CCjiUdbnlkli0GxYWIg28tj7VY58U1p6K1aVYK 88DfoAnyoi3udgGWHCZt0Qf8Vc5WVvjXV9wy0ZlSGqDosvkbDJ+jTINb9s9dD6Zfah4ntMkA7Wj SxUt8f7QvQNKsrXgXY8DyhsgCvPrf0jUH54ebMEEvMxatCT485MCbj9tiUOMGMmYAL6xQOIlQSu 4HqO4cXxlSD3sF/B7w+IbyXpZiWUWbNgY6Lc2LSgjMl1cY/GNBS6wwSJTV7eA+axNkS1NvzjNEg 7ifu7OA7Eotgy/b14lMiW75SHDeoMhlHxUhBlmOBA6J6mrtdvpKiGTvnHcpye9HuJ0CuDw2Y4Ad VuD+utnVPFpBcaqDFrhlLk6tM6Izf4evGa+KFoYkRUzQUH1wmIsg== X-Received: by 2002:a05:600c:5701:b0:492:43d2:9e6e with SMTP id 5b1f17b1804b1-4926084769dmr22175025e9.9.1782289312951; Wed, 24 Jun 2026 01:21:52 -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 5b1f17b1804b1-4923fe7ba08sm434766395e9.11.2026.06.24.01.21.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jun 2026 01:21:52 -0700 (PDT) Date: Wed, 24 Jun 2026 09:21:49 +0100 From: David Laight To: Al Viro Cc: Ben Dooks , Andrew Morton , linux-kernel@vger.kernel.org Subject: Re: [PATCH] lib/iomem_copy: fix __iomem casts Message-ID: <20260624092149.15316790@pumpkin> In-Reply-To: <20260624000436.GH2636677@ZenIV> References: <20260622124857.379868-1-ben.dooks@codethink.co.uk> <20260623234720.GG2636677@ZenIV> <20260624000436.GH2636677@ZenIV> 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 01:04:36 +0100 Al Viro wrote: > On Wed, Jun 24, 2026 at 12:47:20AM +0100, Al Viro wrote: > > On Mon, Jun 22, 2026 at 01:48:57PM +0100, Ben Dooks wrote: > > > The iomem_copy.c code discards __iomem address space when using > > > the IS_ALIGNED() macro. It would make more sense to fix this in > > > one place by aing a PTR_ALIGNED_LONG() macro and then doing the > > > necessary casts there before invoking IS_ALIGNED(). > > > > > > As part of this, also force the pointer to an unsigned long as > > > pointers are generally not signed, although there is no warning > > > as yet on treating pointers as signed. > > > > > +#define PTR_ALIGNED_LONG(__ptr) IS_ALIGNED((__force unsigned long)__ptr, sizeof(long)) > > > > Casting to unsigned long is fine (indeed, casting a pointer to long had > > been very odd in the first place), but... why __force? Casts to unsigned long > > (de facto uintptr_t) do *not* require __force - they are explicitly allowed, > > unless you pass -Wcast-from-as in sparse arguments. -Wall does not turn > > those on; -Wsparse-all would, but kbuild doesn't pass that. > > FWIW, we have 170+ places where IS_ALIGNED((unsigned long)pointer, _) > or IS_ALIGNED((uintptr_t)pointer, _) is used in the tree... > Would is be better to add an IS_PTR_UNALIGNED(ptr, type) that returns (unsigned long)(ptr) & (sizeof(type) - 1) since I suspect quite a few of those places do fixups and need the offset? David