From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) (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 C64CB258CDF for ; Mon, 9 Feb 2026 09:42:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770630143; cv=none; b=ZGB58qfb3LpJ6MX3b/MnivLNaXbNdTHVYfV4juGGh/uUV72NaEavzjyNahSHo747sysS1wNiKPzfkcHweJb3xMk3HZBn7p5E4EcLMQSEt4Mthan2L5W0PR+HRun8JvNl+AhJKVnEzCLDV1/7qdf4nBGrEj9RjtpPd0r6X6iUPkw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770630143; c=relaxed/simple; bh=YuFqX3smt6q2CJNEkl9SfXSQYPgPkPODF2ccdqYslFE=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HBfrE3PTcjLAX0StKa58OE7gAekwxKR0w/W5Kvsa2HBdHmSvgG+sg/25b4RbcrtNE4YSj7NPOJ4pBBAI9sdeGYMHajXuYEI3Ba8T0gr8T21KBIjB+GfVsqM857RYZZz030uCU/R4cPFK5mshRZiuv/5gA7RvzQlLIuZVaRHA+HY= 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=cNvrBFmv; arc=none smtp.client-ip=209.85.221.51 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="cNvrBFmv" Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-4362507f396so3152595f8f.0 for ; Mon, 09 Feb 2026 01:42:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770630141; x=1771234941; 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=69fDqZY+sGe7M3B1r7WsUCzwZlIvrT5U0nhB9NLldZY=; b=cNvrBFmvtIaLJMIrbkZ+68gBwb5K5Tmcmes6VvB6DS9SVffkX+FITgO65NJBwIkTeU dUaKeSm1KeqPGPA9yxQ7yvxEAvPMjUjhuA8QVrBnaZfAl4WW9iGYhT+apSVt1D68Ira8 uyhRMpGk+bAJX+U4sOg08yKl+dkZJtcLc9rw25EIimxqvHKwSNd+AF/p4ypa9hGhjk/t 5OVGn+oXbP+0/MWam8i/DaJ7gukWhip3OB5q2jDfml+GuoWl6pYLhdHyPMY3lAIyfQyr 4KCNDHQiPvtRpS73MSSc1HiWfyTVtcab/xxLNiqVIlmfDcX4ljwruU9uAuZGZOQWIFmw FHsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770630141; x=1771234941; 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=69fDqZY+sGe7M3B1r7WsUCzwZlIvrT5U0nhB9NLldZY=; b=QnPWZhW9tj/i5I/abZJYmw/foU4cWo+hCYjVWkqJoYWqITsGDD842R6T54C2NY7IVi Qfpf/xg+nTVJXFNKaVWl0PlaStV9iyx4kiRFbaUhwyZSxKiuhUUhMhGfOBkLL5q5Kc/3 yaJkzmcWnIM7G3paozQ5IgsqlIIP3lUAlV/OQ/cQtBEHs9/w/vqkWdKbR+spdpaG1mi2 rfn/Z4h53ycCwNC2ujk6VXg0Aj8gQ/I+4DjmwBuqU1TqLwlpDa2xF8IkQRurtVRNi2f2 85hM/N1jFgzn/VKi7XOX2HzybbN3keGeDs+x+vpp16/fECwK7DjyYAqSlSg7vUs5FV1q DnmQ== X-Forwarded-Encrypted: i=1; AJvYcCWI5TEEzO9BUTCQxabJFN4blj4F6f4at6qeaFAnQflzWXd/CnQNtW88vuT07YU4TGHXJffsnCKm71AUMfM=@vger.kernel.org X-Gm-Message-State: AOJu0YwM0averNNQKOMoWRWHDqZ5dMyeG8U3OvPttc7SuTYyJhIRObSt hShDD6Po8PBwjFO5cG5DLQDPvU+VqMcWn8BmFekOZsKmT8QHTHjqVP/4apvKPQ== X-Gm-Gg: AZuq6aIzWx0Q2wN1tnQ14m+uQ00pUvxJ+cdCoopJXdefz/Vb88L6G3ZZM0sZWJVD1cv vd7pQuR9Lp4iCbhYxbAeCzdnfwc0DKYdosJgttR+heZOpEuxPReLJBZu4yfyFm5M+qJFGJF0d+x yq6PiOiszAqI3vp7+v9qShrtiVQxcFbzgzI5qrMET74mmvXdkdbfGKPgvPbxuPadGYU3Xz2kCPe RV04YOSHbSUqatyJpNqfHH2WNw9VN4Nwb6eHrE7rmAzkC5dr8LNKohmT9zLFjS1tSE296qaXDa8 HeSCI8BImTonbIglr0kp1NQznz0ZAh15Bsy87Czf5SmzUluQ3iXvGoR/LcbxTT77xpTsz2hoHao IqjeEusYfllOtyqzoPYKMvXBHuqLUUKIIf4zHlUJtfpHXGGWkcAIOo7TUce/Ur7PEGGpLedEOnL iC3HX/u4zATRmt70yN3yhyEYP6IBIX306EBoozMMr0fIKba+jAyWqT X-Received: by 2002:a05:6000:22c6:b0:435:9882:234e with SMTP id ffacd0b85a97d-4362938ff1emr15016035f8f.59.1770630140944; Mon, 09 Feb 2026 01:42:20 -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-436296bcdfcsm26587255f8f.10.2026.02.09.01.42.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Feb 2026 01:42:20 -0800 (PST) Date: Mon, 9 Feb 2026 09: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 08/14] bits: simplify GENMASK_TYPE() Message-ID: <20260209094214.5ed5db27@pumpkin> In-Reply-To: References: <20260121145731.3623-1-david.laight.linux@gmail.com> <20260121145731.3623-9-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 21:36:57 -0500 Yury Norov wrote: > On Wed, Jan 21, 2026 at 02:57:25PM +0000, david.laight.linux@gmail.com wrote: > > From: David Laight > > > > Since the type is always unsigned (T)-1 is always the correct value > > so there is no need to use type_max(). > > > > Signed-off-by: David Laight > > Here you implicitly add a new restriction that all types passed in > GENMASK_TYPE() must be unsigned. Can you enforce it with > is_signed_type(), or at lease with a corresponding comment? GENMASK_TYPE() is an internal define used in the expansions of, for example, GENMASK_U32() - it is always passed an unsigned type. I don't really think it should be used elsewhere at all. In any case I don't think it makes any difference. The value or type_max(t) has to match BITS_PER_TYPE(t) or else the result is wrong, so it has never worked for signed types. I did try adding a signedness check to FIELD_GET(), there is one place in the x86-64 build that uses a signed type and requires the right shift sign extend. That code (in the fault handler) probably ought to be changed. David > > > --- > > include/linux/bits.h | 3 +-- > > 1 file changed, 1 insertion(+), 2 deletions(-) > > > > diff --git a/include/linux/bits.h b/include/linux/bits.h > > index a40cc861b3a7..697318f2a47d 100644 > > --- a/include/linux/bits.h > > +++ b/include/linux/bits.h > > @@ -45,8 +45,7 @@ > > */ > > #define GENMASK_TYPE(t, h, l) \ > > ((t)(GENMASK_INPUT_CHECK(h, l) + \ > > - (type_max(t) << (l) & \ > > - type_max(t) >> (BITS_PER_TYPE(t) - 1 - (h))))) > > + ((t)-1 << (l) & (t)-1 >> (BITS_PER_TYPE(t) - 1 - (h))))) > > > > #define GENMASK(h, l) GENMASK_TYPE(unsigned long, h, l) > > #define GENMASK_ULL(h, l) GENMASK_TYPE(unsigned long long, h, l) > > -- > > 2.39.5