From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) (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 4414334DCE2 for ; Sun, 8 Feb 2026 11:42:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.67 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770550938; cv=none; b=E4NxlMgd5CCodXiZfvPjHLuB21UhDxjnAzf5OVZWFYINLKjL+wVXiP3SxBY1M0X4NCYfcdllAhJWTXrFqZX2ANHKXvIiSSF2p7YkAW02Sk0bVyGVLMCUqWl+2NAMCRwBhTifpl1HAygB8kXlBfXKSVLxCNmLe3nmxXF6nMHgNvs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770550938; c=relaxed/simple; bh=43UMcNJoXSmxY1vgHCdnrELO2q3MFAXfRQb8FguLSY8=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Ui3qw6LdQTAnIYFVtmFhFRSpgWbKyTzxBca6sMPUh8md3ETuvUQZpDzBBX0extS/j3OGn3eMzvivVbKyf4+c7vZLmJDJgGFRE+EhvUXzRQ/LcMWeQBgdR1ORNim3S99IrfZuvrSyrTtHVeB5511Eip1a4tp/lBmwU2n2/3H0GLk= 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=ivfDcOEV; arc=none smtp.client-ip=209.85.221.67 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="ivfDcOEV" Received: by mail-wr1-f67.google.com with SMTP id ffacd0b85a97d-43767807cf3so332275f8f.1 for ; Sun, 08 Feb 2026 03:42:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770550937; x=1771155737; 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=wZO/BuVOhTPW2rgtOqM33Oa1WfaOaUVHLNvTuwhjP8k=; b=ivfDcOEV17ujj2+CUoy/iyQIitQYiOJAM03wQzvuBsBn3725uTbFBF3i97hUZzPeF0 GimlI2LuHxABCIy3OgStHBCeMVdcoVHvCpTStALF1fyQgaZr90dGtYix6uI7zVWQYiEq pIb/yoQ7cwP9FR6cJNchn9EHATpAHhkmm3nJ2ocfB+Ua36LwqYPcEzv9GV5NojMAX6u9 87Z9uG3bu07CSsboyT0W3FamxtvdZ1iCXZVjTVs6nMRnuU8XHJEI8Ng9Z5WnfJjQ2mUq PFLVX13OzDXi8SLHcSw4KfXSzyvVEBlT0oCFzBnixkBrlI9zTfA+Hly/L8NlJ9ZTLAf3 +GPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770550937; x=1771155737; 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=wZO/BuVOhTPW2rgtOqM33Oa1WfaOaUVHLNvTuwhjP8k=; b=AuBqu1A3k88xAzxxi6zJkBQUXM5ChAYuAkSi/bTcXFEiyB1pyyHjuPFJx9wTdUpbxj 7uz1z/MZdozGRB3ojwu/jdWsey3i/UyRZpUBnjOTaWlQvX5gs/a6b5lj5QdXMrstoD7L a3IKIn8sN6UdKU3mS7je9PICatl2fM2vH1y+DN5c+sZ4TE9QvFNijWm7dmkWu0K0fS/A XginYKmumstFgbScz5tStSne2xondJg9nabHuicS2fMBPUzlBQimWbE041bemG59FTx2 JAcQKRoZHSsDi3iLgbJzD0piyLhzwy53IPAxZ6iQUqMpIAuE4gZLDHfkZBK9v1t26r/I XgqQ== X-Forwarded-Encrypted: i=1; AJvYcCXc520Pofde5/A5wSZPOJ2/cin0vlCn8XbkD98ZcahpZqJ/BAxSwPz/y6Uy0hibMQ4gfqZkKE9dy0zpmlE=@vger.kernel.org X-Gm-Message-State: AOJu0Ywc/mFI89ndf3rZH9Dejul+meeaez/HdFShep5Hgu/zSz4PBkob jHoVwutlv7Js6yHDg+K8IQePxOCb6sebZoCffgqm/NSlIRbvX4lN4pnO X-Gm-Gg: AZuq6aJzZV8kQcZ5sbOG0036QHdUxxooYqWenJOuQ7fQpaPwdkFG4z0u2TlhKqsIPE8 O1tBKe2i4VM3EV/Ot7FatQVfzedYb6LCmnLgrAFC+0+wY0UADCpsVnb5i0BByGmgBGVzEXU7wCW 2TAmj6yvqnez2u2NWA8GVYF2xSijZEs4d4c6bAAvEI0ayZUdFQI7V7w2zEKXhEEyhwUPH+LniKc R4vY06Z9UAfegHFJmck+Phbu6NvwvyAKjeg1Kta3luuzJlO4ZJW119ZMdNlo/iBd6MeGcm5Uk7z NsDhMvCCQgsE/kQ/uhMMcSe2C60/mcTR+k15duKtZ3yMMNUwrmzYVfWDz2OHUTeyaMqeFBFPX7Y jnWb3MAuK4/R04pvHs6XQKj0Mo5TbEbAmUG7lf0nV3X4SYJOFaP1xHnm1/yQRKsQIjwx8/oXvtg sWMWFZn0Df+2bnod2h93c4ntb8TaFAfNxpqV1JW/cwHRAsJq41luIR X-Received: by 2002:a5d:5848:0:b0:437:6b73:ffac with SMTP id ffacd0b85a97d-4376b740555mr1512420f8f.62.1770550936571; Sun, 08 Feb 2026 03:42:16 -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-4362972fa41sm20364309f8f.23.2026.02.08.03.42.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Feb 2026 03:42:16 -0800 (PST) Date: Sun, 8 Feb 2026 11:42:14 +0000 From: David Laight To: Yury Norov Cc: Nathan Chancellor , Greg Kroah-Hartman , Thomas Gleixner , Peter Zijlstra , Ingo Molnar , Mathieu Desnoyers , Arnd Bergmann , linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, Yury Norov , Lucas De Marchi , Jani Nikula , Vincent Mailhol , Andy Shevchenko , Kees Cook , Andrew Morton Subject: Re: [PATCH next 10/14] bits: Fix assmebler expansions of GENMASK_Uxx() and BIT_Uxx() Message-ID: <20260208114214.270b4982@pumpkin> In-Reply-To: References: <20260121145731.3623-1-david.laight.linux@gmail.com> <20260121145731.3623-11-david.laight.linux@gmail.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=US-ASCII Content-Transfer-Encoding: 7bit On Sat, 7 Feb 2026 22:31:34 -0500 Yury Norov wrote: > On Wed, Jan 21, 2026 at 02:57:27PM +0000, david.laight.linux@gmail.com wrote: > > From: David Laight > > > > The assembler only supports one type of signed integers, so expressions > > using BITS_PER_LONG (etc) cannot be guaranteed to be correct. > > > > Use ((2 << (h)) - (1 << (l))) for all assembler GENMASK() expansions and > > add definitions of BIT_Uxx() as (1 << (nr)). > > > > Note that 64bit results are (probably) only correct for 64bit builds > > and 128bits results will never be valid. > > And this important note will sink in git history. At least it isn't only in the email archives. I can put it in a comment. > > Signed-off-by: David Laight > > This has been discussed in details when those GENMASK_Uxx() were > introduced. Assembler doesn't support C types, and can't provide any > guarantees. It may only confuse readers when they see something like > GENMASK_U8() in the assembler code, and there's nothing on behalf of > that declaration to enforce the limitation. It won't be in asm code, the asm code will be expanding a constant from a C header file. > That's why we didn't add fake C types support in the assembler. Unless > we find a way to enforce C types capacity in assembler(s), let's keep > those macros C-only. But GENMASK_ULL() was already there and would generate invalid values (for small values) on 32bit. The only reason for defining these for assembler is so that .h files that use the definitions can be used in .S files. As soon as any of the BIT_Unn() get used the asm code is likely to try to expand them. David > > Thanks, > Yury