From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [62.89.141.173]) (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 742E11C5F27 for ; Tue, 23 Jun 2026 23:47:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.89.141.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782258446; cv=none; b=pdyU5GpL6z1WnGYxTpAOMY/3HXmUTH2FW00UNe6iIaX7z5It9DytC+xB5Ll0rGF0OBgvWdNv9NGnQbBFiJNA5dHg/VwudwGjqoMqubUrplzWk8nOPxR72jQfD7rs1o2PuLtVv2XoqPaIXU7tCRxfp3kul7xUO2uRMdqQAKMOT5M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782258446; c=relaxed/simple; bh=spoecJC9gPIqwUHmXQMiELjeLHo+kt95TK5Oy/gu3O4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Z08ncvHDk7PPc0MyKVUsxWZugLz9v4ky580390tzD3kveKyuDrTpFZaoVuYXQMxRE2pB4uSNOZxrDjrRIezua/9MHyQ81Bf4dbM3G7yCtfeAiO0AF3DPtNFpCP2tRnvpN8QDh1g8PrwlPAuzLCwgwbeT0Y8pJ+8NAFgRd/LgCDc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk; spf=none smtp.mailfrom=ftp.linux.org.uk; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b=HvYKAh+x; arc=none smtp.client-ip=62.89.141.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ftp.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b="HvYKAh+x" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=zPDGmImVT4kafvgC3OOo9HoiasUiMT1P5ZRwauHKSD0=; b=HvYKAh+xKRA9fcT8ys5NNJwbeV 7ZKKgHK7N/cGc+lwuoVQo3AloCOwI26YqMGnA3Kl+gth0itUbeO743hClqEfX6dnpe8l5NY8jJbea 34zcdHWnTjGnc2NmWWnKiQYhudbwr9bdZGJykmXpyO79J6VPjrjZtY7dG7K621MMXr04kvDrYhVRD VzvafxQYoCTXJPutdnPEEUPmzaJU2D2cGC1jcHzX/UcpG/cx/oqQ3/dTk4UqJyGb1Z8OkKrcq7Mi8 b/Qe9TysueGqjaQ9/KDe26jgYmb7Tqv9C9crSa+v+Dcd/qMyWr1qsDkR8qKy9pPKv0+ANV7SqzS9h DZmFaIIQ==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.99.4 #2 (Red Hat Linux)) id 1wcAps-000000014mX-272f; Tue, 23 Jun 2026 23:47:21 +0000 Date: Wed, 24 Jun 2026 00:47:20 +0100 From: Al Viro To: Ben Dooks Cc: Andrew Morton , linux-kernel@vger.kernel.org Subject: Re: [PATCH] lib/iomem_copy: fix __iomem casts Message-ID: <20260623234720.GG2636677@ZenIV> References: <20260622124857.379868-1-ben.dooks@codethink.co.uk> 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-Disposition: inline In-Reply-To: <20260622124857.379868-1-ben.dooks@codethink.co.uk> Sender: Al Viro 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. ; cat >/tmp/a.c <<'EOF' #define __iomem __attribute__((noderef, address_space(__iomem))) static int f(void __iomem *p) { return (unsigned long)p; } static int g(void __iomem *p) { return (long)p; } EOF ; sparse /tmp/a.c /tmp/a.c:10:17: warning: cast removes address space '__iomem' of expression ; sparse -Wcast-from-as /tmp/a.c /tmp/a.c:5:17: warning: cast removes address space '__iomem' of expression /tmp/a.c:10:17: warning: cast removes address space '__iomem' of expression ; sparse -Wall /tmp/a.c /tmp/a.c:10:17: warning: cast removes address space '__iomem' of expression ; sparse -Wsparse-all /tmp/a.c /tmp/a.c:5:17: warning: cast removes address space '__iomem' of expression /tmp/a.c:10:17: warning: cast removes address space '__iomem' of expression