From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (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 900442FFFA4 for ; Mon, 19 Jan 2026 17:47:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768844856; cv=none; b=pSwhR0bz8zqFgwsm7bIKvrGQTJ/Nad7HGSCqFgmGKovKOoHJDeT4uzeVfVYaNiiQaDOM/ZbYxfu6jsxh+iP4pnSxy+yLhKzKd4HApqlW8a7sEuOSRZtuC3unXrVfCdKd1g7vszmM1E/Crg8RZG7Y7y4CvrjIbZBcDkCvmGGL1m4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768844856; c=relaxed/simple; bh=uFWIzT/NGXdCZyvcgR0/FUoFNBord156hv8OfVms58Y=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QPDdLTBYRhe290wV18gtT1NJ0wQubIgrNlErkFXTR6cuXmGOqZGkxSF+8i/YnZBzD8ld3nhC4DeNJFQQCz3Dn8Uan/2aJ7ZGEEqvy0i/MAFmtbcNpOhM8OivAcG1063PU/DwFh8PVFloW4BmVElEPkB7oed2eB5N5nLbIMWRHfo= 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=GMtYY/zm; arc=none smtp.client-ip=209.85.128.50 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="GMtYY/zm" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-47ee301a06aso41998355e9.0 for ; Mon, 19 Jan 2026 09:47:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1768844853; x=1769449653; 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=l2ACadv0hgsZtux+LBE5pG2d7aO4i+uY5axwwBu8vVQ=; b=GMtYY/zmJhPX5Xs7FJm3rgdUKdWIuhIklepJ1p4sddiSk/m48GgcuCFWYojivUWl0S ItcXWhV3LEwOv4TzwJv2L8CLKQ44AK3D7QBES/aeXyukZebzf2e+NZ46lwP+vS2RJDr5 Fas+NRvNzp81+95dkDBYnUxXK/nnySKrAwae2kWZV4CNSP878KpANRKljUJLJ2uB15oC sAxiISTwz31imERKHeIZ9AEFL9R6RLEjaJRY0JjT2sDdN+s30Rb5I1AXTdLHzspGThuB tiCttjFFxbiQp8IPlnnIJDSDi/RKZC4j2b5/myFO+GiYQyFzJrxUbAtTdQo9bs/p5O/b sM7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768844853; x=1769449653; 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=l2ACadv0hgsZtux+LBE5pG2d7aO4i+uY5axwwBu8vVQ=; b=Vf2RFF9J6X10umIwZNTDJLS+0yLIoCBZAJwi8peMjZiAEkFurqEYEf9NX/gokE+mz0 uc9JHjn0DCQZFh8EAOpzE2iSBrjxWlLe8DB3i0QTXwCrAA7GDFJCg888Agq3fSRaWrtQ aJyj9N8mA5Th1JIbB8eJb+PCC7YD0ZEm22Cth8ZO+/yYm/WbmsWtWJ2uWP5bfB6vR6MS Q1mO4/6YfRKf5bZQanJL5CYTElmyh35nsvSH2mrG9fJbC6TLISra5CeDNb51vOMCfXoC ModR/6b8DOGrkIy6KPI8mluQirsQnzz12dUE8nUMkjm6WSjKV7tlZpdwx0xOM0D18Tgn QpXw== X-Forwarded-Encrypted: i=1; AJvYcCVytCzmybuCNy+gJvLn1AX0Mo7fkO1Rgau9SJfcS64NA4oH51GhQ3hjun39L5wTZ4FHHDV01iFG/Bv6fTw=@vger.kernel.org X-Gm-Message-State: AOJu0YzdDCpDF6Cue7uMlW0ctv27iGg5bUsumQGpKpuSRqujXT7A/u+p TxE6cWaf8MyY2M0DNOGofhgEuE+4X7TQCl4SN7eT8SsXLgobglvkqOPh X-Gm-Gg: AZuq6aLKuIKokKnJrCq7SFlVMJmEzLJElfuN96PiP89V5V6oJr+jCr4D/qaR/GdlMKN A4hqctRpU+p1vZmDEnz2INDb1dCwkXsdmLXNwo8b9oDugSESeLlAXZUNgdWImm9hwY6yFQVkU7Z 698C4K7s2MiaGfhUR1YEr+tg8LGPPBTnK9QwJ+APIWTCpOx6Mt2pzMLUduOgVWg0diDPHMt7zdp S9mnBiMugwTj4Jq87kr3681Hzwf+rcUHUmS/PtP/wyACdSeXgjdWjdE1Qh3djznLmsUC4Qoo+WM uuVdxrUZzGVOP/+fIFRWr9lWcMLFYjvKhf/ENgFUZx7jtl1apO7dLhasELv9JVT1QnE+Jq4HbTw K7eYx9HAsJxPvAx3ke54jUkdCjqlY9Xi8slBHdJkhNn4pW+j9mPd11iKWjl883Y9TaYc0sxk9HN QCkskkOcGFK20ec4ZmJ11VH0Sv/dtYewkwRvnspfN+Cb3UprdbCQt9 X-Received: by 2002:a5d:588e:0:b0:431:9b2:61b0 with SMTP id ffacd0b85a97d-4356a03dd73mr15899699f8f.25.1768844852626; Mon, 19 Jan 2026 09:47:32 -0800 (PST) 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-43569921dedsm24242699f8f.9.2026.01.19.09.47.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Jan 2026 09:47:32 -0800 (PST) Date: Mon, 19 Jan 2026 17:47:30 +0000 From: David Laight To: "Arnd Bergmann" Cc: Thomas =?UTF-8?B?V2Vpw59zY2h1aA==?= , "David S . Miller" , "Andreas Larsson" , "Andy Lutomirski" , "Thomas Gleixner" , "Ingo Molnar" , "Borislav Petkov" , "Dave Hansen" , x86@kernel.org, "H. Peter Anvin" , "Heiko Carstens" , "Vasily Gorbik" , "Alexander Gordeev" , "Christian Borntraeger" , "Sven Schnelle" , sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, Linux-Arch , linux-s390@vger.kernel.org Subject: Re: [PATCH 4/4] asm-generic/bitsperlong.h: Add sanity checks for __BITS_PER_LONG Message-ID: <20260119174730.5a20169d@pumpkin> In-Reply-To: <4e4b1b5b-5f7d-4604-b5ef-0d0726263843@app.fastmail.com> References: <20260116-vdso-compat-checkflags-v1-0-4a83b4fbb0d3@linutronix.de> <20260116-vdso-compat-checkflags-v1-4-4a83b4fbb0d3@linutronix.de> <20260119100619.479bcff3@pumpkin> <20260119111037-4decf57f-2094-4fac-bcf4-03506791b197@linutronix.de> <20260119103758.3afb5927@pumpkin> <20260119114526-a15e7172-fc4c-40d0-a651-7c4a21acb1c8@linutronix.de> <72a2744a-debc-4d8f-b418-5d6a595c2578@app.fastmail.com> <20260119143735-ca5b7901-b501-4cb8-8e5d-10f4e2f8b650@linutronix.de> <4e4b1b5b-5f7d-4604-b5ef-0d0726263843@app.fastmail.com> 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=UTF-8 Content-Transfer-Encoding: quoted-printable On Mon, 19 Jan 2026 15:57:49 +0100 "Arnd Bergmann" wrote: > On Mon, Jan 19, 2026, at 14:41, Thomas Wei=C3=9Fschuh wrote: > > On Mon, Jan 19, 2026 at 01:45:04PM +0100, Arnd Bergmann wrote: =20 > >> On Mon, Jan 19, 2026, at 11:56, Thomas Wei=C3=9Fschuh wrote: =20 > >> > On Mon, Jan 19, 2026 at 10:37:58AM +0000, David Laight wrote: =20 > >> >>=20 > >> >> Don't you need a check that it isn't wrong on a user system? > >> >> Which is what I thought it was doing. =20 > >> > > >> > Not really. The overrides defined by arch/*/include/uapi/asm/bitsper= long.h are > >> > being tested here. If they work in the kernel build I assume they al= so work > >> > in userspace. =20 > >>=20 > >> I think You could just move check into include/asm-generic/bitsperlong= .h > >> to make this more obvious with the #ifdef __KERNEL__, and remove the > >> disabled check from my original version there. =20 > > > > Ok. I'd like to keep your existing test though, as it tests something d= ifferent > > and it would be nice to have that too at some point. =20 >=20 > Sure, that works too. I wonder if one of the recent vdso cleanups > also happened to address the problem with the incorrect BITS_PER_LONG > being visible in the vdso code. Maybe we can already turn that on again. There is vdso/bits.h, but everything actually includes linux/bits.h first. I was wondering what happens if you are actually using the 'uapi' headers to build programs (may nolibc ones). On x86-64, 'gcc foo.c' might work, but 'gcc -m32 foo.c' will find exactly the same headers and go badly wrong unless everything is based on compiler defines. An assert (of some kind) that checks the pre-processor BITS_PER_LONG constant actually matches sizof (long) seems reasonable for all build. The alternative is to (somehow) manage to avoid needing a pre-processor constant at all, moving everything to 'integer constant expressions' instead (good luck with that...). I'm most of the way through a 'de-bloat' patchset for bits.h. I'm sure there is a good reason why GENMASK(hi, lo) isn't defined as '((type)2 << hi) - ((type)1 << lo)'. Since that definition doesn't need the bit-width in any form. (Just beat up any static checker that objects to '2 << hi' being zero.) I've only made that change for ASM files - IIRC the assembler only supports one size of signed integer. David