From nobody Sat Feb 7 17:55:08 2026 Received: from mailtransmit05.runbox.com (mailtransmit05.runbox.com [185.226.149.38]) (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 09F9046AF08; Wed, 21 Jan 2026 14:58:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.38 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769007488; cv=none; b=D3t3ZXRXr1ZazuhKl8XcfcrGuEeEw31RpFjFJLUmJIPhW6LeLVWZDf+tQoboYwEhqhE4uIP7AlevCOchwwvKN4XqgnqSQwZVSFv6U+ahr0UXDbu6tbQC2tIEtm+gZfAwGl2uJ9CMy/Q4XIEuXC8vkY3uFXDKr8FU0sg/84e5sGo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769007488; c=relaxed/simple; bh=OA02ELFmnpBDdrGrXQuvFuiTkYOKMCAqIO8bG+Pl/e4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=iSQHQM4D4B0goLSxV4R6xUTzYPkp4Y12WxFrIdzu+kYiqxQ7Ffcc5kWJYKAjI3eA7dSUhtr4XS5BPi1QtgtyD0nDT5l0PlSosbSNyNGDQilMCQKIhRqEkOhMdXUg7wVy2T3DkunigO17iQR8+FOYwxyYadAjGZG/WgmuAB06WrM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=bwCgj4UW; arc=none smtp.client-ip=185.226.149.38 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="bwCgj4UW" Received: from mailtransmit03.runbox ([10.9.9.163] helo=aibo.runbox.com) by mailtransmit05.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1viZeV-008Pd7-QC; Wed, 21 Jan 2026 15:57:47 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector2; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=DxIhPg/CrbU4/R5zWg9CgbE9VAZfvxZOQr4uB5RIp+Y=; b=bwCgj4UWCr20Pxcet9xGPzvypg +FG6Vowg31CoGVzLsFmzg2bfeYiVSbUioPFODND4CYg3RaFQ2U8W5eGeuHvkUeNSpHQ9gNFm0JiSA KB9EydKlS6hMTlAJVMsxsp71OFE0+eo1S2p/EqVnlExVTz0NE9yqMkuigo/nlN0KMimQONboeJIqO /lCOsCHR6jl9pzizM7Jtm1jI8nxXHYMV254l1UnM1CY1iE2SFWOKCxXsbS0xbnBBN/y0PhGG2P9SZ nkBIAbcSXpPUHCJBDi+XeieoT3FSskZiTer2osCLW3evkvRCzYO8jKeADssVvy9H3bREo7xRGGgJP jmP9tE9w==; Received: from [10.9.9.72] (helo=submission01.runbox) by mailtransmit03.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1viZeV-0006kf-Bf; Wed, 21 Jan 2026 15:57:47 +0100 Received: by submission01.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1viZeS-00GH6h-IM; Wed, 21 Jan 2026 15:57:44 +0100 From: david.laight.linux@gmail.com To: 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 Cc: David Laight Subject: [PATCH next 01/14] overflow: Reduce expansion of __type_max() Date: Wed, 21 Jan 2026 14:57:18 +0000 Message-Id: <20260121145731.3623-2-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20260121145731.3623-1-david.laight.linux@gmail.com> References: <20260121145731.3623-1-david.laight.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Laight Change '(x - 1) + x' to '2 * (x - 1) + 1' to avoid expanding the non-trivial __type_half_max() twice. Signed-off-by: David Laight Reviewed-by: Kees Cook Reviewed-by: Yury Norov --- include/linux/overflow.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/overflow.h b/include/linux/overflow.h index 736f633b2d5f..4f014d55ab25 100644 --- a/include/linux/overflow.h +++ b/include/linux/overflow.h @@ -31,7 +31,7 @@ * credit to Christian Biere. */ #define __type_half_max(type) ((type)1 << (8*sizeof(type) - 1 - is_signed_= type(type))) -#define __type_max(T) ((T)((__type_half_max(T) - 1) + __type_half_max(T))) +#define __type_max(T) ((T)(2 * (__type_half_max(T) - 1) + 1)) #define type_max(t) __type_max(typeof(t)) #define __type_min(T) ((T)((T)-type_max(T)-(T)1)) #define type_min(t) __type_min(typeof(t)) --=20 2.39.5 From nobody Sat Feb 7 17:55:08 2026 Received: from mailtransmit04.runbox.com (mailtransmit04.runbox.com [185.226.149.37]) (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 C3C6C4A2E04 for ; Wed, 21 Jan 2026 14:58:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.37 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769007492; cv=none; b=ZwvR2VHo3cmzRXC5go+mAsrBr6hql0PyHifwgYSo004OjsNlGzCd1D9j8O8jAyQBXopU2oHfjEofP7rgGARBHUPMRgEHZk2Td09w7lZYwofHOqF3vga/hQw9WHdDR6as3sthRTpqio03gM0HvnkB8UiG/ziBD6Na85kNesrZwbQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769007492; c=relaxed/simple; bh=KnD6lUbvGcRchKcNZZh/x1v8Ivn5Z3m9i5iGppglY/M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=txXS9NVTQyDxEGn0fCpczemXXAMLaw5XgY4hwllCkPnQ6VISjPpw101RvGwBIdE7lhtWFtCsy5fnra7snH4wHHZcwmEra57XO8i5kzNoizNYcb2WlmjU/uzBOAIiiH4dEzk0eRQLceXoyjJ/eeBsnBjQ9oCu1z8vdluufUyPzfo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=qLagF0dg; arc=none smtp.client-ip=185.226.149.37 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="qLagF0dg" Received: from mailtransmit03.runbox ([10.9.9.163] helo=aibo.runbox.com) by mailtransmit04.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1viZeV-008XC5-AB; Wed, 21 Jan 2026 15:57:47 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector2; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=woWiGteby0nhO3keCjO/XMIhwTt+aq04kL0xpr3EbPg=; b=qLagF0dgYYDg8S2PrryXBn9dXe u01E9/j0t8fFoNRWbmP4RGYkd+TC6D6c5H6/89a7J07kehtzHK9KPDgjicbrvupq9p2WeZOTS3gaE kcgsBJE76RHSrMnfXTMapxfAYRhqcrhwA74jf0EMi5cpiQh8PIZow/HG88vb2LC6H/p6JGH4chQsp ajzohJd8YBsMuEGeJt9KFxBCf8ZxeIOuugeVNYtV0bkLkwIuJSjzg4eIHRg5Ii23WljRXk2eLmkZR Q6EA0su+3xNKD1hrJTN12c43hYnK0Rz5EDTzk7TGUnbSbtq3SqggCVYiQFo2d7IRQHGu9KldnK+9S h4Dx+60Q==; Received: from [10.9.9.72] (helo=submission01.runbox) by mailtransmit03.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1viZeU-0006kD-JG; Wed, 21 Jan 2026 15:57:47 +0100 Received: by submission01.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1viZeT-00GH6h-4t; Wed, 21 Jan 2026 15:57:45 +0100 From: david.laight.linux@gmail.com To: 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 Cc: David Laight Subject: [PATCH next 02/14] kbuild: Add W=c for additional compile time checks Date: Wed, 21 Jan 2026 14:57:19 +0000 Message-Id: <20260121145731.3623-3-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20260121145731.3623-1-david.laight.linux@gmail.com> References: <20260121145731.3623-1-david.laight.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Laight Some compile time checks significantly bloat the pre-processor output (particularly when the get nested). Since the checks aren't really needed on every compilation enable with W=3Dc (adds -DKBUILD_EXTRA_WARNc) so the checks can be enabled per-build. Make W=3D1 imply W=3Dc so the build-bot includes the checks. As well as reducing the bloat from existing checks (like those in GENMASK() and FIELD_PREP()) it lets additional checks be added while there are still 'false positives' without breaking normal builds. Signed-off-by: David Laight --- scripts/Makefile.warn | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/scripts/Makefile.warn b/scripts/Makefile.warn index 68e6fafcb80c..e8a799850973 100644 --- a/scripts/Makefile.warn +++ b/scripts/Makefile.warn @@ -2,8 +2,9 @@ # =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D # make W=3D... settings # -# There are four warning groups enabled by W=3D1, W=3D2, W=3D3, and W=3De -# They are independent, and can be combined like W=3D12 or W=3D123e. +# There are five warning groups enabled by W=3Dc, W=3D1, W=3D2, W=3D3, and= W=3De +# They are independent, and can be combined like W=3D12 or W=3D123e, +# except that W=3D1 implies W=3Dc. # =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 # Default set of warnings, always enabled @@ -109,6 +110,13 @@ KBUILD_CFLAGS +=3D $(call cc-option,-Wenum-conversion) =20 KBUILD_CFLAGS +=3D -Wunused =20 +# +# W=3Dc - Expensive compile-time checks, implied by W=3D1 +# +ifneq ($(findstring c, $(KBUILD_EXTRA_WARN))$(findstring 1, $(KBUILD_EXTRA= _WARN)),) +KBUILD_CPPFLAGS +=3D -DKBUILD_EXTRA_WARNc +endif + # # W=3D1 - warnings which may be relevant and do not occur too often # --=20 2.39.5 From nobody Sat Feb 7 17:55:08 2026 Received: from mailtransmit04.runbox.com (mailtransmit04.runbox.com [185.226.149.37]) (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 532FC4A13A0 for ; Wed, 21 Jan 2026 14:58:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.37 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769007491; cv=none; b=Xq/8I5gs1tpO3Vr/MN+BlyJ/LgfOuvjj8020B/3+IQBq1qr7UFUw7+4ihziqryZm8j/bvQO0cE3TK1je2k88PnIAuStGU41kjnv0UQITghw9UcDAULTKE94u2h98Am1krFzwUCXupmZ+EPULmFUnWN+hn4UQqtxlBjH/ER93DSw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769007491; c=relaxed/simple; bh=foIGQMOAHWwCNroXsDE7jRsNmbGSBwa8yV3vFc2z48A=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=sJW1emcUC9XolozPU1Dl8lXQVH9Z2l3xzLe/p1Hcq6ullvERfYY8Nj3H2Mk+/WPqfuwkKNDJdof02y+KHq6A5yanskx53fhhkidYwnh6hBfRTw8Uescq3+qkIg72knCwkaO0tST50qevJ007nDGVv0uK9o02wiarknvhUys7huo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=HaW/GUkV; arc=none smtp.client-ip=185.226.149.37 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="HaW/GUkV" Received: from mailtransmit02.runbox ([10.9.9.162] helo=aibo.runbox.com) by mailtransmit04.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1viZeU-008XBz-Hc; Wed, 21 Jan 2026 15:57:46 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector2; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=2gq8v9rIKK/WZOVtXyQBP19csssyxOXjWNwk4Hfn2/0=; b=HaW/GUkVH2w4hPqHQaP/dYVF2Q pVkYu5IGc+XLh3/i5cXUCnSAfy0Xm5x7V9eMiDozvHjyngPjaJzW8UHxjEwW+1wVpXM0zfssdvF/a joU2beF7UXXt+0JXuf7VT5YFS4IXiXU+0rLoPpEZddPrN5PoMs+4yuyMN5p9v4a4EsI5XLaDEdqXP yNjzgUcGeQWmlqiJnK2cxfEf2+KOyMEMtiKkKBmxfrg3FohGyOzL80P07OCIADWwQH1/PuR4FnPwf jYshxnA3sFoNJS6huJURh5MkMccTOEnv3GWSileZr/JiuF9eLENz2MUr8fvzIlum4zg5Wsk0jnEYk a4znAFog==; Received: from [10.9.9.72] (helo=submission01.runbox) by mailtransmit02.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1viZeU-0001qf-4L; Wed, 21 Jan 2026 15:57:46 +0100 Received: by submission01.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1viZeT-00GH6h-PY; Wed, 21 Jan 2026 15:57:45 +0100 From: david.laight.linux@gmail.com To: 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 , Tomasz Figa , Marek Szyprowski Cc: David Laight Subject: [PATCH next 03/14] media: videobuf2-core: Use static_assert() for sanity check Date: Wed, 21 Jan 2026 14:57:20 +0000 Message-Id: <20260121145731.3623-4-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20260121145731.3623-1-david.laight.linux@gmail.com> References: <20260121145731.3623-1-david.laight.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Laight Compile-time tests being added to BIT() make it an 'integer constant expression' rather than a pre-processor expression for W=3D1 builds. Change the BIT(PLANE_INDEX_BITS) !=3D VIDEO_MAX_PLANES test to use static_assert() so the code compiles. Signed-off-by: David Laight --- drivers/media/common/videobuf2/videobuf2-core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/medi= a/common/videobuf2/videobuf2-core.c index 2df566f409b6..90dedab2aeb2 100644 --- a/drivers/media/common/videobuf2/videobuf2-core.c +++ b/drivers/media/common/videobuf2/videobuf2-core.c @@ -37,9 +37,9 @@ #define MAX_BUFFER_INDEX BIT_MASK(30 - PLANE_INDEX_SHIFT) #define BUFFER_INDEX_MASK (MAX_BUFFER_INDEX - 1) =20 -#if BIT(PLANE_INDEX_BITS) !=3D VIDEO_MAX_PLANES -#error PLANE_INDEX_BITS order must be equal to VIDEO_MAX_PLANES -#endif + +static_assert(BIT(PLANE_INDEX_BITS) =3D=3D VIDEO_MAX_PLANES, + "PLANE_INDEX_BITS order must be equal to VIDEO_MAX_PLANES"); =20 static int debug; module_param(debug, int, 0644); --=20 2.39.5 From nobody Sat Feb 7 17:55:08 2026 Received: from mailtransmit05.runbox.com (mailtransmit05.runbox.com [185.226.149.38]) (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 245FB4A2E18; Wed, 21 Jan 2026 14:58:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.38 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769007492; cv=none; b=IYhkaxUt0VBjrE+PmyTpgJJgJFKydsyux6g8y2h+ew9jVPCYMc5cz3hj3XnAkc3z0pnkakuj/tm1wJgtuEKkFEr7s07eVBhSAm2G55NiFB+Ut349Vm2LA8Zv7NDv15M12c+Q1jOJNBPb3BZC+KhVquNdlpEldQE+cHZxuTXfDpE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769007492; c=relaxed/simple; bh=JlyCbBO/oW/tetnWdx5yD/0V4biAgpc2VSyHl/0RTW0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=X2U4dBl/zc+f1FFg090usXYXYZcYL7hAqZxXLzBSPtBATgCbu9X2GdLtC6PGOewe7O1r2kyVtoLDUdEz7oklikSMdbkZokVU1+5tkYRSFiUNFRrzdapqYGYwr19WBK2iN+5bs3pMnvIi+EK0xUHA9uhHutTG/U+vXoVJ2ayh8UM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=TQpTqX20; arc=none smtp.client-ip=185.226.149.38 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="TQpTqX20" Received: from mailtransmit03.runbox ([10.9.9.163] helo=aibo.runbox.com) by mailtransmit05.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1viZeo-008PiQ-Mt; Wed, 21 Jan 2026 15:58:06 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector2; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=WM4AW6T2eDyt9U4IgVqebjKOg5YLOCiW8yPgHypoOSI=; b=TQpTqX206asVFeUievc6JJj2Ek wqM7hs9wGnUIBcVPffkgPJu35kJBxxzsR6ggD4iCy8WkxMilxNWKv+q0fl22fysXKLxuLkDUEej3Y 2hDCPBx0icb4re8+5jeccNdZ/26VGRObehh/+WDHThfk8Q824W8M3ulRBNKEx5mn3si3Pbh4MifXH tcFJB3rT6sHgFWa3yTGmxxWpiGX7K8XJmhqNwe+xpsdDh5J/E8HZiqe9hRZeN+t5LMoKnoJOSUUJH 75XjD6uzEhHqsYD/zEeIIPTOEi4GJHc5kZFD85Rx0SxFOXnX4Rk8ZLcdJlDTnCtlh2hikrq7v21KN PtqXaVcw==; Received: from [10.9.9.72] (helo=submission01.runbox) by mailtransmit03.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1viZeo-0006qQ-8M; Wed, 21 Jan 2026 15:58:06 +0100 Received: by submission01.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1viZeU-00GH6h-CH; Wed, 21 Jan 2026 15:57:46 +0100 From: david.laight.linux@gmail.com To: 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 Cc: David Laight Subject: [PATCH next 04/14] media: atomisp: Use static_assert() for sanity check Date: Wed, 21 Jan 2026 14:57:21 +0000 Message-Id: <20260121145731.3623-5-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20260121145731.3623-1-david.laight.linux@gmail.com> References: <20260121145731.3623-1-david.laight.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Laight Compile-time tests being added to BIT() make it an 'integer constant expression' rather than a pre-processor expression for W=3D1 builds. Change the FRAC_ACC !=3D BDS_UNIT test to use static_assert() so the code compiles. Signed-off-by: David Laight --- .../kernels/fixedbds/fixedbds_1.0/ia_css_fixedbds_param.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/media/atomisp/pci/isp/kernels/fixedbds/fixedbd= s_1.0/ia_css_fixedbds_param.h b/drivers/staging/media/atomisp/pci/isp/kerne= ls/fixedbds/fixedbds_1.0/ia_css_fixedbds_param.h index f7e5669d5125..31bce7b2650e 100644 --- a/drivers/staging/media/atomisp/pci/isp/kernels/fixedbds/fixedbds_1.0/i= a_css_fixedbds_param.h +++ b/drivers/staging/media/atomisp/pci/isp/kernels/fixedbds/fixedbds_1.0/i= a_css_fixedbds_param.h @@ -13,9 +13,8 @@ #define BDS_UNIT 8 #define FRAC_LOG 3 #define FRAC_ACC BIT(FRAC_LOG) -#if FRAC_ACC !=3D BDS_UNIT -#error "FRAC_ACC and BDS_UNIT need to be merged into one define" -#endif +static_assert(FRAC_ACC =3D=3D BDS_UNIT, + "FRAC_ACC and BDS_UNIT need to be merged into one define"); =20 struct sh_css_isp_bds_params { int baf_strength; --=20 2.39.5 From nobody Sat Feb 7 17:55:08 2026 Received: from mailtransmit04.runbox.com (mailtransmit04.runbox.com [185.226.149.37]) (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 F071B4DB546; Wed, 21 Jan 2026 14:58:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.37 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769007500; cv=none; b=hk/W7nw4TTeHlqO8WTY0POcud7n1oIkpJJuNi+ATwErOGB6FLYVCEeLkUqlXGc97Djnx+wU8Q8TDjxTY4vCA3+Yp6+nQjiWQJm5/sAU5DsXVHCQkWwAxvl8QLxd6zJwxQx+aMTFsasER8HirBYt9C9Toba8MpUojxq9Btl/nMuA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769007500; c=relaxed/simple; bh=0GrGhWbwswqou6wzlsc9dE/G/veSAbRQW0iD5Ve4Dls=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Fys2fb8hCmZco7SAcAWe0v9hd+opNfULS84y+LGnzZOYYW3v4OwhaXTcNGgm9JeuM+PPPVfR8d7q6xjTSIjACm2FZN8/YRQUgLhfeC+3L+A2n9VIARjfY/f71TPsJh4fH0Jft8a4gJ/T/tIRtIvD/GCQy0zSmGd6OZgTvAJh8vw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=HeFJaC1m; arc=none smtp.client-ip=185.226.149.37 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="HeFJaC1m" Received: from mailtransmit02.runbox ([10.9.9.162] helo=aibo.runbox.com) by mailtransmit04.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1viZes-008XEu-IO; Wed, 21 Jan 2026 15:58:10 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector2; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=eNMRSz5L8fgL8ctUrXiNlrxD38QSSH4gIK6f6XdjByE=; b=HeFJaC1mdaOqO1JFtCyHaDqb+o AYbWVZoW4TkLPEY6c7eJ5zI0XROXccqy7RUoBXtNgEihN/3n3OME26NmwnJOISA1MophY0qHodcRs sRMMMr8/9oE94ctgx35jyRY+HVHmjHGefqARHNdLoT2XoYD0AKtjnrq8oHUVENSDbfzd+l7udyn/r kQrIxELHzkwwbh1Q8jNeS9XGONZUP76CWdNavaltvVSuWHgewUiXCScsctVEk+PGKMb/DIXH3olBd r5ffBQZhia625IXmRCUdzJ3lSVKxvROrC+GOiErca0omVSy1EL73FZzFreX/t3F5/GlqqVPL63Pqr 9ZgCLz+A==; Received: from [10.9.9.72] (helo=submission01.runbox) by mailtransmit02.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1viZes-0001sg-6G; Wed, 21 Jan 2026 15:58:10 +0100 Received: by submission01.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1viZeV-00GH6h-40; Wed, 21 Jan 2026 15:57:47 +0100 From: david.laight.linux@gmail.com To: 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 , Tony Nguyen , Przemek Kitszel , "David S. Miller" , Eric Dumazet , Jakub Kicinski , netdev@vger.kernel.org Cc: David Laight Subject: [PATCH next 05/14] ixgbevf: Use C test for PAGE_SIZE > IXGBE_MAX_DATA_PER_TXD Date: Wed, 21 Jan 2026 14:57:22 +0000 Message-Id: <20260121145731.3623-6-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20260121145731.3623-1-david.laight.linux@gmail.com> References: <20260121145731.3623-1-david.laight.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Laight Compile-time tests being added to BIT() make it an 'integer constant expression' rather than a pre-processor expression for W=3D1 builds. This means BIT() can't be used in pre-processor conditional that checks 'PAGE_SIZE > IXGBE_MAX_DATA_PER_TXD'. Change to use a normal 'if' statement, the compiler will optimise away the unwanted code. Signed-off-by: David Laight Reviewed-by: Simon Horman --- .../net/ethernet/intel/ixgbevf/ixgbevf_main.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c b/drivers/ne= t/ethernet/intel/ixgbevf/ixgbevf_main.c index d5ce20f47def..65dd5834d0cf 100644 --- a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c +++ b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c @@ -4166,9 +4166,6 @@ static int ixgbevf_xmit_frame_ring(struct sk_buff *sk= b, u32 tx_flags =3D 0; u16 count =3D TXD_USE_COUNT(skb_headlen(skb)); struct ixgbevf_ipsec_tx_data ipsec_tx =3D { 0 }; -#if PAGE_SIZE > IXGBE_MAX_DATA_PER_TXD - unsigned short f; -#endif u8 hdr_len =3D 0; u8 *dst_mac =3D skb_header_pointer(skb, 0, 0, NULL); =20 @@ -4183,15 +4180,15 @@ static int ixgbevf_xmit_frame_ring(struct sk_buff *= skb, * + 1 desc for context descriptor, * otherwise try next time */ -#if PAGE_SIZE > IXGBE_MAX_DATA_PER_TXD - for (f =3D 0; f < skb_shinfo(skb)->nr_frags; f++) { - skb_frag_t *frag =3D &skb_shinfo(skb)->frags[f]; + if (PAGE_SIZE > IXGBE_MAX_DATA_PER_TXD) { + for (unsigned int f =3D 0; f < skb_shinfo(skb)->nr_frags; f++) { + skb_frag_t *frag =3D &skb_shinfo(skb)->frags[f]; =20 - count +=3D TXD_USE_COUNT(skb_frag_size(frag)); + count +=3D TXD_USE_COUNT(skb_frag_size(frag)); + } + } else { + count +=3D skb_shinfo(skb)->nr_frags; } -#else - count +=3D skb_shinfo(skb)->nr_frags; -#endif if (ixgbevf_maybe_stop_tx(tx_ring, count + 3)) { tx_ring->tx_stats.tx_busy++; return NETDEV_TX_BUSY; --=20 2.39.5 From nobody Sat Feb 7 17:55:08 2026 Received: from mailtransmit05.runbox.com (mailtransmit05.runbox.com [185.226.149.38]) (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 AA4174D90A3 for ; Wed, 21 Jan 2026 14:58:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.38 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769007494; cv=none; b=jAjnO9wV2MkwkYfJi8+aXP7SquMmT/2LHrpRMrAmLjRnJPDrv+XaC5dD0NrQYE/PzF9SK7b0j/ikqIWsv/pCM3E1t8vVVPslI0RtHcOEMuAZyCOAuf1pmBa8jFZpeBYJe7hlryXliMpTjQmD99DHfIjX4GpCzW8i3QF//m1UyKg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769007494; c=relaxed/simple; bh=FCdBQZWdHf1xz/vTnMEdIXZEqr+wf1tzdzM9W6byHso=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=pnEuXfyexRUFWt4f06hnYLppan32kjuEImsaohWmSUFQxJ5sKlgVUA2QFoOux4/SJ9oqGD1EgJR1+ryinEGBVReQXHhVLNRPw3Mzm1W9bDnAN7j6kYYUQaM4s/fsE83nCbCrO4+yB36WEXDn9ITAYuTP2M67ZrfFGaQbec9MXMQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=XSDNZIi5; arc=none smtp.client-ip=185.226.149.38 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="XSDNZIi5" Received: from mailtransmit03.runbox ([10.9.9.163] helo=aibo.runbox.com) by mailtransmit05.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1viZes-008PjA-6N; Wed, 21 Jan 2026 15:58:10 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector2; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=hJGbMvfP6awI5d5SmhxetgsrjF7ICeJkS4xNExqiD7w=; b=XSDNZIi52k9PTUjt93fTkefYnJ aRIMMgME/yim+sQhk6KpuvIpQp4TkTNSW2w2DfwvdC9s403+iQTgHVIjvYbnf4oN0T4HXznKDTcem UyOdZwrD06TyvMvQnoFFWzDl8DEUO5Acn9s7ezfgivXBTP29/i41IofrMuoHI0y6nb9b+2Yb/nyT8 j7vE9k1g+WHCv01oIdpssVIwD7q46jeaAvhiOIQv3UCQdiGOXknmPWCPi21sJZ0GUnkWYrFl0D10c hAltNDFvzR5PqFjQCqaeSWYiJfEUeaed3pL4I1dJWQFPLFBBUUUc98T2uxkNDzhvpzcTfjkZaXrD5 8KOKrDRA==; Received: from [10.9.9.72] (helo=submission01.runbox) by mailtransmit03.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1viZer-0006qk-NJ; Wed, 21 Jan 2026 15:58:09 +0100 Received: by submission01.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1viZeV-00GH6h-Mc; Wed, 21 Jan 2026 15:57:47 +0100 From: david.laight.linux@gmail.com To: 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 Cc: David Laight Subject: [PATCH next 06/14] asm-generic: include linux/bits.h not vdso/bits.h Date: Wed, 21 Jan 2026 14:57:23 +0000 Message-Id: <20260121145731.3623-7-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20260121145731.3623-1-david.laight.linux@gmail.com> References: <20260121145731.3623-1-david.laight.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Laight thread_info_tif.h isn't part of the vdso, use the linux/bits.h header. Signed-off-by: David Laight --- include/asm-generic/thread_info_tif.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/asm-generic/thread_info_tif.h b/include/asm-generic/th= read_info_tif.h index da1610a78f92..afdc23204674 100644 --- a/include/asm-generic/thread_info_tif.h +++ b/include/asm-generic/thread_info_tif.h @@ -2,7 +2,7 @@ #ifndef _ASM_GENERIC_THREAD_INFO_TIF_H_ #define _ASM_GENERIC_THREAD_INFO_TIF_H_ =20 -#include +#include =20 /* Bits 16-31 are reserved for architecture specific purposes */ =20 --=20 2.39.5 From nobody Sat Feb 7 17:55:08 2026 Received: from mailtransmit05.runbox.com (mailtransmit05.runbox.com [185.226.149.38]) (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 ACDDA4D90A6; Wed, 21 Jan 2026 14:58:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.38 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769007494; cv=none; b=nfzoDamFEzDHFwl8q5QaYTXDJ+tLYs+DvQNELX4zZc+QDRVFZVHYfVpLGHxovnA9forhEojRYZRmvq3rr75oz0dZRVRfylZPKQfai++gwQ1jBDHOsLAe5E/yd8y8eXDy4HERTBh1WTPZmMuib/9mbqx/vzA/rGbDkOOMTNjK4sw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769007494; c=relaxed/simple; bh=KfKTerWE4WB0dhSUpbGy/FH9has/LNkq3+TZTkpYEn8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jCGgHyd6NJn/qVcS15Ggyjp0j9SxCDdVSfwu752Ws5xmPxzw/fjsl/6SA5rjXpKIfjUOQdIFHJyBzhyj2gSY1BXlJDQ61o8m4F/PFFQam9bolcw+fG8ufLCiis1vgA2Zk9nWE6UL5NAE7gaCvpIm1w1LMvLPCv2T9WbfCGG6Ozk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=hAL/R/1+; arc=none smtp.client-ip=185.226.149.38 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="hAL/R/1+" Received: from mailtransmit02.runbox ([10.9.9.162] helo=aibo.runbox.com) by mailtransmit05.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1viZen-008Phe-BZ; Wed, 21 Jan 2026 15:58:05 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector2; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=pS7N/XfIeq0Cy6irt5k3pB4HIbS7v7ivLocvksuTg0k=; b=hAL/R/1+gSyvjodvTSSNzdvFYR Qq2WbRIF3T6jUB5ahMOwjf6kQvtBwtZgdrctgzh2I1+IALjSiYqqmo/z3KiYBI8OwB0Kvyk2GfO40 Pj6DjXF1BpIJMCnE4CSa+xu8rIIl+WRFgSoERAqOrtRDhKj0YoJzsJsd5eZQ9CyJg1i3skRiBHp+J TlINDErSMOGFWEz7+wK3REZUFC4liAMCpEeUBWeyGdlSOLGPs3PsH090gEN98qlX3xkXF9ziIpwXT XrWizY1cDI8ou1VfXNlh57LnFwTkBNOaKYkuFOXKpWfR4nDf/xn2Y/p6if7aLjyf/mpp5xFtnDS0t ErJiTTHw==; Received: from [10.9.9.72] (helo=submission01.runbox) by mailtransmit02.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1viZem-0001sE-RS; Wed, 21 Jan 2026 15:58:05 +0100 Received: by submission01.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1viZeW-00GH6h-9G; Wed, 21 Jan 2026 15:57:48 +0100 From: david.laight.linux@gmail.com To: 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 Cc: David Laight Subject: [PATCH next 07/14] x86/tlb: include linux/bits.h not vdso/bits.h Date: Wed, 21 Jan 2026 14:57:24 +0000 Message-Id: <20260121145731.3623-8-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20260121145731.3623-1-david.laight.linux@gmail.com> References: <20260121145731.3623-1-david.laight.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Laight asm/tlb.h isn't part of the vdso, use the linux/bits.h header. Signed-off-by: David Laight --- arch/x86/include/asm/tlb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/include/asm/tlb.h b/arch/x86/include/asm/tlb.h index 866ea78ba156..e61c6de73e70 100644 --- a/arch/x86/include/asm/tlb.h +++ b/arch/x86/include/asm/tlb.h @@ -7,7 +7,7 @@ static inline void tlb_flush(struct mmu_gather *tlb); =20 #include #include -#include +#include #include =20 static inline void tlb_flush(struct mmu_gather *tlb) --=20 2.39.5 From nobody Sat Feb 7 17:55:08 2026 Received: from mailtransmit05.runbox.com (mailtransmit05.runbox.com [185.226.149.38]) (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 C4C634A1394 for ; Wed, 21 Jan 2026 14:58:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.38 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769007490; cv=none; b=hUDXlLn5DPWXtiOGlvEt3oMtgYPGaKwsM15XHgJGag+wuF6yvtsWrskwlyGZf81rYdKwN9T0lromKCEFB1FD4Rrcn6SUIIDNIgcioac4SImcvdRPjVpBH00DggYw2a0fWXeAbzv2zcN5vVjTIL0JQJrcimdh7+PHIi2szCD3aZc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769007490; c=relaxed/simple; bh=WLWZVpeZhx+DAeWbAnRY6lcMK6WxhnXbv31m9woOk6g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=e/DnqM5DArL0VpbrL5FB+zVbucEIDjW4SJmFHHkylkxwG0AEo0dZBK5u1PUIKdoiuFnYLmgR45W/oxSYXj2uf6s/ErWeIkFOrMVnxyowW7bfj24DqDdwJo/urwZB6++uLzGzBg7iBEVHocRzan4nRdHTfBMwDKeB/68qjd0Dq5I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=vr0CBPMR; arc=none smtp.client-ip=185.226.149.38 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="vr0CBPMR" Received: from mailtransmit03.runbox ([10.9.9.163] helo=aibo.runbox.com) by mailtransmit05.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1viZen-008Pi9-QK; Wed, 21 Jan 2026 15:58:05 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector2; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=cF43fDD/g1BgXHMaIGGBWzL2e37s8+SbQXJh1FJtOkY=; b=vr0CBPMRBRE+lctEWWosrDIQZG z3juNwE4hOINU5wiKjyzCNEMuKgO09OkDRks9znM75u5Ne7WXSFdoPzwIuQlwVhV6jkAsdPvxslTg gTgWnzPznfOW0OlPzmhiTK69V0hki0sI873zqRx+H2RrQY88brR14ATnQuo2GLEH2odmKsOiwUPZq 39O9HEEPdo+SRgnCkA1PvvV7GbShnjFOjWY5eEmFlueEXWCGAYsJH/EpgdqSABBXJHQRbdw2vu7QA tTlFEfNva1z7tEvGneXL9RmhW+nAlmeoPantOXbe+Fo1HYO4dvRwh8JIsCXf7kEWNwrJn+ORg8MXL bLelEwsA==; Received: from [10.9.9.72] (helo=submission01.runbox) by mailtransmit03.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1viZen-0006qK-BQ; Wed, 21 Jan 2026 15:58:05 +0100 Received: by submission01.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1viZeW-00GH6h-Rn; Wed, 21 Jan 2026 15:57:48 +0100 From: david.laight.linux@gmail.com To: 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 Cc: David Laight Subject: [PATCH next 08/14] bits: simplify GENMASK_TYPE() Date: Wed, 21 Jan 2026 14:57:25 +0000 Message-Id: <20260121145731.3623-9-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20260121145731.3623-1-david.laight.linux@gmail.com> References: <20260121145731.3623-1-david.laight.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 --- 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))))) =20 #define GENMASK(h, l) GENMASK_TYPE(unsigned long, h, l) #define GENMASK_ULL(h, l) GENMASK_TYPE(unsigned long long, h, l) --=20 2.39.5 From nobody Sat Feb 7 17:55:08 2026 Received: from mailtransmit04.runbox.com (mailtransmit04.runbox.com [185.226.149.37]) (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 C3D684A2E05 for ; Wed, 21 Jan 2026 14:58:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.37 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769007493; cv=none; b=GAMlCN0H9gq66eUy5+6FgxccfBnAhXxAAf9N36oglbLJN6XtRKaXTddsf5C8AI0coL33TU9SqU/Y7ZPHthKdJztt2IEii3lsRME8ZTjxNkAddel2wgZD7VgPSs5ZY9PNutW+YxGd3wqGBhlv5mHG4r988Qiwfz+VuJSicTnpYAY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769007493; c=relaxed/simple; bh=1cHBQHEyqWPZ51YmiIdEAZN+oAUWjME/Gol7MEr4hLs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=hH9rGS/yml8gYofjcoHPUXo/5B30dzaMOpdabepFg9Kbost3MiRWGkuQjmmGzHNmCoBgErqXt+Rhk6/qxSJ9vaec/gxvhRxxIsEBfYLsTMDTdskiw+17aoyGso/9yNiAun2Yc7pDRRbSG5IXIg+GtpFNVMeQfHbmZPdhwk0fW04= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=AE2Gu1iC; arc=none smtp.client-ip=185.226.149.37 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="AE2Gu1iC" Received: from mailtransmit02.runbox ([10.9.9.162] helo=aibo.runbox.com) by mailtransmit04.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1viZeo-008XDT-6Y; Wed, 21 Jan 2026 15:58:06 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector2; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=fkOOOuXIe68/qJN84cF/oemnl/qDhRt1xPrfHh5OqwM=; b=AE2Gu1iCc38H1M0Sf1ZKgxKcXZ m5W7ZH6mq7c80J6MXuZqiN0uJJioaT1hz3NK1P5ld17IEA16Ub2c41zUuLnnUiD+jKOfp9nDTrWCL iZLusyFpegMsW26woqI5HlOgBp8ksxtdtXBzuqVTtvUotn3Uy/yhOFw4KzutSFEtm+TRi/IXCCpOl xI8qAORrnb/xZJOrz0OLlQ/ZUM7tGScjSuPPQvrbYpsSgcLssYGFrocoCV5C8466F+3KQnSgSmsoc txWtIkMxHUIR4NKv7d4RAXObX8iAIAF6dcaCrNwLekRfBBZ+HMs6m7J98YXZbHS9Qy+zdfVORCr1l PskC2bZg==; Received: from [10.9.9.72] (helo=submission01.runbox) by mailtransmit02.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1viZen-0001sK-QY; Wed, 21 Jan 2026 15:58:05 +0100 Received: by submission01.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1viZeX-00GH6h-EQ; Wed, 21 Jan 2026 15:57:49 +0100 From: david.laight.linux@gmail.com To: 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 Cc: David Laight Subject: [PATCH next 09/14] bits: Change BIT_U8/16() and GENMASK_U8/16() to have unsigned values Date: Wed, 21 Jan 2026 14:57:26 +0000 Message-Id: <20260121145731.3623-10-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20260121145731.3623-1-david.laight.linux@gmail.com> References: <20260121145731.3623-1-david.laight.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Laight Casting the value of BIT_U*() and GENMASK_U8() to (u8) is pointless. Although it changes what typeof(BIT_U8()) returns the value will always be promoted to 'signed int' before it is used. Instead force the expression to be an unsigned type. Avoids unexpected sign extension from, for example: u64 v =3D BIT_U8(7) << 24; Fix the KUNIT tests to match. Signed-off-by: David Laight --- include/linux/bits.h | 6 +++--- lib/tests/test_bits.c | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/linux/bits.h b/include/linux/bits.h index 697318f2a47d..23bc94815569 100644 --- a/include/linux/bits.h +++ b/include/linux/bits.h @@ -44,8 +44,8 @@ * - GENMASK_U32(33, 15): doesn't fit in a u32 */ #define GENMASK_TYPE(t, h, l) \ - ((t)(GENMASK_INPUT_CHECK(h, l) + \ - ((t)-1 << (l) & (t)-1 >> (BITS_PER_TYPE(t) - 1 - (h))))) + ((unsigned int)GENMASK_INPUT_CHECK(h, l) + \ + ((t)-1 << (l) & (t)-1 >> (BITS_PER_TYPE(t) - 1 - (h)))) =20 #define GENMASK(h, l) GENMASK_TYPE(unsigned long, h, l) #define GENMASK_ULL(h, l) GENMASK_TYPE(unsigned long long, h, l) @@ -67,7 +67,7 @@ #define BIT_INPUT_CHECK(type, nr) \ BUILD_BUG_ON_ZERO(const_true((nr) >=3D BITS_PER_TYPE(type))) =20 -#define BIT_TYPE(type, nr) ((type)(BIT_INPUT_CHECK(type, nr) + BIT_ULL(nr)= )) +#define BIT_TYPE(type, nr) ((unsigned int)BIT_INPUT_CHECK(type, nr) + ((ty= pe)1 << (nr))) =20 #define BIT_U8(nr) BIT_TYPE(u8, nr) #define BIT_U16(nr) BIT_TYPE(u16, nr) diff --git a/lib/tests/test_bits.c b/lib/tests/test_bits.c index ab88e50d2edf..55be8230f9e7 100644 --- a/lib/tests/test_bits.c +++ b/lib/tests/test_bits.c @@ -9,20 +9,20 @@ =20 #define assert_type(t, x) _Generic(x, t: x, default: 0) =20 -static_assert(assert_type(u8, BIT_U8(0)) =3D=3D 1u); -static_assert(assert_type(u16, BIT_U16(0)) =3D=3D 1u); +static_assert(assert_type(unsigned int, BIT_U8(0)) =3D=3D 1u); +static_assert(assert_type(unsigned int, BIT_U16(0)) =3D=3D 1u); static_assert(assert_type(u32, BIT_U32(0)) =3D=3D 1u); static_assert(assert_type(u64, BIT_U64(0)) =3D=3D 1ull); =20 -static_assert(assert_type(u8, BIT_U8(7)) =3D=3D 0x80u); -static_assert(assert_type(u16, BIT_U16(15)) =3D=3D 0x8000u); +static_assert(assert_type(unsigned int, BIT_U8(7)) =3D=3D 0x80u); +static_assert(assert_type(unsigned int, BIT_U16(15)) =3D=3D 0x8000u); static_assert(assert_type(u32, BIT_U32(31)) =3D=3D 0x80000000u); static_assert(assert_type(u64, BIT_U64(63)) =3D=3D 0x8000000000000000ull); =20 static_assert(assert_type(unsigned long, GENMASK(31, 0)) =3D=3D U32_MAX); static_assert(assert_type(unsigned long long, GENMASK_ULL(63, 0)) =3D=3D U= 64_MAX); -static_assert(assert_type(u8, GENMASK_U8(7, 0)) =3D=3D U8_MAX); -static_assert(assert_type(u16, GENMASK_U16(15, 0)) =3D=3D U16_MAX); +static_assert(assert_type(unsigned int, GENMASK_U8(7, 0)) =3D=3D U8_MAX); +static_assert(assert_type(unsigned int, GENMASK_U16(15, 0)) =3D=3D U16_MAX= ); static_assert(assert_type(u32, GENMASK_U32(31, 0)) =3D=3D U32_MAX); static_assert(assert_type(u64, GENMASK_U64(63, 0)) =3D=3D U64_MAX); =20 --=20 2.39.5 From nobody Sat Feb 7 17:55:08 2026 Received: from mailtransmit05.runbox.com (mailtransmit05.runbox.com [185.226.149.38]) (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 032EF4A33F6 for ; Wed, 21 Jan 2026 14:58:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.38 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769007497; cv=none; b=WX2yu8m4wAalUuVS+3cu/wcVDvIAcZfh25Hd9giwPUHpC25wN88TPViCtaBjlqczyLO1OkSbttaUSwQLRFRNQmrVbv0kvNNWzDr8oJ0U/8qJ3JOoY/bFe745OG2y1cFxUooGkgHTgNVLXhLdpWxXUQGs1awra/GvZB27No2BrcQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769007497; c=relaxed/simple; bh=x2rrcpb/s3mTtuY4bVsmxaUW1vje9Nqmah8JcL8MUHw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=QPUOtqfUSZyLYlgKrcU5IrHJ0/8wrCbrXjwmFul/N/FUJ+iYOmts4NqccUsF344up2jW3U/hZTUXTrlN6P3xwRYdLdFL1DgcxmKX39fpD/aH9ARw4jkv5i7nWtJ5HwqmHuWh5btSDOVzzGfJNjCYeY2dZ1J/Ve0IYI6bD4u4t2s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=Cy3l9jVF; arc=none smtp.client-ip=185.226.149.38 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="Cy3l9jVF" Received: from mailtransmit02.runbox ([10.9.9.162] helo=aibo.runbox.com) by mailtransmit05.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1viZer-008Pit-8v; Wed, 21 Jan 2026 15:58:09 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector2; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=lR0OR/0w0VcAlZlqORMKFUweAPjLQDsHqvIpq/QZ4pI=; b=Cy3l9jVF89F6ACDblSUg/2W7ve a2y+ET6ZC7cQ25S/v6wkfuI5QmSAGwZXrHkLqhDl/950/lMtzcbBRW9BhessiMnCygAH2AnkK4fwY eSoSkjIP/8SPAfENToSx175Bo6E2paKFi1uEebo0PVJEcBjF/vAOAliOdWu4hOUnc+tPP6Wy05vWl 8zVcGnSeJoGeJFEdvUZMl+HDD0TRnDQ1K9nTOh/iLpFc/Q/NQ8qbsdN03qVDCEAueeOBfaLlHs2JT Q0lv6a2v+oEpO1qxh/FO2JWv6qBvwl/wr6bRDi9duYHNwAlHZj8ZoKnZHcYgbqfwjw28r/neszQr2 L9Zh/CLg==; Received: from [10.9.9.72] (helo=submission01.runbox) by mailtransmit02.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1viZeq-0001sa-KN; Wed, 21 Jan 2026 15:58:08 +0100 Received: by submission01.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1viZeY-00GH6h-0s; Wed, 21 Jan 2026 15:57:50 +0100 From: david.laight.linux@gmail.com To: 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 Cc: David Laight Subject: [PATCH next 10/14] bits: Fix assmebler expansions of GENMASK_Uxx() and BIT_Uxx() Date: Wed, 21 Jan 2026 14:57:27 +0000 Message-Id: <20260121145731.3623-11-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20260121145731.3623-1-david.laight.linux@gmail.com> References: <20260121145731.3623-1-david.laight.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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. Signed-off-by: David Laight --- include/linux/bits.h | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/include/linux/bits.h b/include/linux/bits.h index 23bc94815569..43631a334314 100644 --- a/include/linux/bits.h +++ b/include/linux/bits.h @@ -19,14 +19,6 @@ */ #if !defined(__ASSEMBLY__) =20 -/* - * Missing asm support - * - * GENMASK_U*() and BIT_U*() depend on BITS_PER_TYPE() which relies on siz= eof(), - * something not available in asm. Nevertheless, fixed width integers is a= C - * concept. Assembly code can rely on the long and long long versions inst= ead. - */ - #include #include #include @@ -46,6 +38,7 @@ #define GENMASK_TYPE(t, h, l) \ ((unsigned int)GENMASK_INPUT_CHECK(h, l) + \ ((t)-1 << (l) & (t)-1 >> (BITS_PER_TYPE(t) - 1 - (h)))) +#endif =20 #define GENMASK(h, l) GENMASK_TYPE(unsigned long, h, l) #define GENMASK_ULL(h, l) GENMASK_TYPE(unsigned long long, h, l) @@ -56,9 +49,10 @@ #define GENMASK_U64(h, l) GENMASK_TYPE(u64, h, l) #define GENMASK_U128(h, l) GENMASK_TYPE(u128, h, l) =20 +#if !defined(__ASSEMBLY__) /* - * Fixed-type variants of BIT(), with additional checks like GENMASK_TYPE(= ). The - * following examples generate compiler warnings due to -Wshift-count-over= flow: + * Fixed-type variants of BIT(), with additional checks like GENMASK_TYPE(= ). + * The following examples generate compiler warnings from BIT_INPUT_CHECK(= ). * * - BIT_U8(8) * - BIT_U32(-1) @@ -68,21 +62,28 @@ BUILD_BUG_ON_ZERO(const_true((nr) >=3D BITS_PER_TYPE(type))) =20 #define BIT_TYPE(type, nr) ((unsigned int)BIT_INPUT_CHECK(type, nr) + ((ty= pe)1 << (nr))) +#endif /* defined(__ASSEMBLY__) */ =20 #define BIT_U8(nr) BIT_TYPE(u8, nr) #define BIT_U16(nr) BIT_TYPE(u16, nr) #define BIT_U32(nr) BIT_TYPE(u32, nr) #define BIT_U64(nr) BIT_TYPE(u64, nr) =20 -#else /* defined(__ASSEMBLY__) */ +#if defined(__ASSEMBLY__) =20 /* - * BUILD_BUG_ON_ZERO is not available in h files included from asm files, - * disable the input check if that is the case. + * The assmebler only supports one size of signed integer rather than + * the fixed width integer types of C. + * There is also no method for reported invalid input. + * Error in .h files will usually be picked up when compiled into C files. + * + * Define type-size agnostic definitions that generate the correct value + * provided it can be represented by the assembler. */ -#define GENMASK(h, l) __GENMASK(h, l) -#define GENMASK_ULL(h, l) __GENMASK_ULL(h, l) =20 -#endif /* !defined(__ASSEMBLY__) */ +#define GENMASK_TYPE(t, h, l) ((2 << (h)) - (1 << (l))) +#define BIT_TYPE(type, nr) (1 << (nr)) + +#endif /* defined(__ASSEMBLY__) */ =20 #endif /* __LINUX_BITS_H */ --=20 2.39.5 From nobody Sat Feb 7 17:55:08 2026 Received: from mailtransmit05.runbox.com (mailtransmit05.runbox.com [185.226.149.38]) (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 7EEF04DA559 for ; Wed, 21 Jan 2026 14:58:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.38 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769007499; cv=none; b=QjCumDQY3TpeQVCVujgFMViTQhebirCDTnF3/cxZALl4Y2NiNp/goDtbyDsK+iN+tdLKp/UtEDcnTcJEifupaBWZUk67kUw6eSlNlXM7Ddk4v5LdWyUBaDAwpEbigZwry4RTCv78/oulGPPV0tnxx2je/8BoMXUeLyQ8jCb5xZE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769007499; c=relaxed/simple; bh=9z932AX2THRzZwBiCjTQT1xPsk/txnKGYIBFuNTbx7E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=rhZkk77xWsD8TZmIQVDlrfiHybzcF2AGTwJlKItdRiEFVkdkAOOxOml7VV6B9hy1mrnirL3NQTFfD0p8Ro/WS/Rn+VhpOcjuN20IoRGzaPXmhp6D0OdySqWck1vbts0GnQnLlfQeg2Gb87hkNQI2aoQRiqZBlkQ1TFLJqsbiiTI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=fsOrgJpJ; arc=none smtp.client-ip=185.226.149.38 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="fsOrgJpJ" Received: from mailtransmit03.runbox ([10.9.9.163] helo=aibo.runbox.com) by mailtransmit05.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1viZer-008Pj1-KA; Wed, 21 Jan 2026 15:58:09 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector2; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=QBokfTpeY0lxQBhpa1t9vMqhCgqf0zlOgr8/cK4ZzTI=; b=fsOrgJpJ+OWxKof8tKg1CULuIU RiOlBCcNZdh/QGshYZWiOrLMlIzY0Yi28GgGtZ5EvEnDWfn8r5h5o6usvOuF82Mytsq+ji8XX536b c1P63guvEelUI6+NvfQufYMT/4CRVAf+AcUR1McKNKzQ+AUNbc+uXb7JCxMbIgwAmvgesXvspjLRC 22pjGzx1Qli7bWJ2fXOvObf85SxzKAfoNoIjT0NsJmu4LivO4FNFVaps9GxeydToqc5gqrnPvrXi6 q6fUrB1aVjNx3dpLi65AJlChUcdFBRSlMmh+CFXC/MpRRFJGoSvNq9p/rxcM09o//UigU6LoiqGs2 DdtzJItA==; Received: from [10.9.9.72] (helo=submission01.runbox) by mailtransmit03.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1viZer-0006qe-8s; Wed, 21 Jan 2026 15:58:09 +0100 Received: by submission01.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1viZeY-00GH6h-KG; Wed, 21 Jan 2026 15:57:50 +0100 From: david.laight.linux@gmail.com To: 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 Cc: David Laight Subject: [PATCH next 11/14] bit: Strengthen compile-time tests in GENMASK() and BIT() Date: Wed, 21 Jan 2026 14:57:28 +0000 Message-Id: <20260121145731.3623-12-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20260121145731.3623-1-david.laight.linux@gmail.com> References: <20260121145731.3623-1-david.laight.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Laight The current checks in GENMASK/BIT (eg reversed high/low) only work for 'integer constant expressions' not 'compile-time constants'. This is true for const_true() and -Wshift-count-overflow/negative. While compile-time constants may be unusual, they can happen through function inlining. This isn't too bad with gcc, but if clang detects a negative/over-large shift it treats it as 'undefined behaviour' and silently discards all code that would use the result, so: int f(u32 x) {int n =3D 32; return x >> n; } generates a function that just contains a 'return' instruction. If 'n' was a variable that happened to be 32, most modern cpu mask the count - so would return 'x', some might return 0. Add extra checks for arguments that pass __builtin_constant_p() but are not 'integer constant expressions. __builtin_choose_expr() isn't strong enough to allow _Static_assert() or ({ ... }) in the other branch so non-standard schemes are used to report the errors. To reduce pre-processor bloat the checks are only enabled for W=3Dc (implied by W=3D1) builds (where they are errors). Update the unit tests to match. Signed-off-by: David Laight --- include/linux/bits.h | 45 +++++++++++++++++++++++++++++++++---------- lib/tests/test_bits.c | 34 +++++++++++++++++++------------- 2 files changed, 56 insertions(+), 23 deletions(-) diff --git a/include/linux/bits.h b/include/linux/bits.h index 43631a334314..0f559038981d 100644 --- a/include/linux/bits.h +++ b/include/linux/bits.h @@ -23,20 +23,35 @@ #include #include =20 -#define GENMASK_INPUT_CHECK(h, l) BUILD_BUG_ON_ZERO(const_true((l) > (h))) +#ifndef KBUILD_EXTRA_WARNc +#define GENMASK_INPUT_CHECK(h, l, width) 0 +#else +int GENMASK_INPUT_CHECK_FAIL(void) __compiletime_error("Invalid bit number= s"); +#define GENMASK_INPUT_CHECK(h, l, width) \ + (__builtin_choose_expr(__is_constexpr((l) > (h)), \ + sizeof(struct { char low_bit_greater_than_high[-((l) > (h))];}), \ + __builtin_constant_p((l) | (h)) && \ + ((l) < 0 || (l) > (h) || (h) >=3D width) && \ + GENMASK_INPUT_CHECK_FAIL())) +#endif =20 /* - * Generate a mask for the specified type @t. Additional checks are made to - * guarantee the value returned fits in that type, relying on - * -Wshift-count-overflow compiler check to detect incompatible arguments. + * Generate a mask for the specified type @t. + * Checks are made to guarantee the value returned fits in that type. + * The compiler's -Wshift-count-overflow/negative check detects invalid va= lues + * from 'constant integer expressions' but not other compile time constant= s. + * Clang treats out of value constants as 'undefined behaviour' and stops + * generating code - so explicit checks are needed. + * Neither BUILD_BUG() nor BUILD_BUG_ON_ZERO() can be used. + * * For example, all these create build errors or warnings: * * - GENMASK(15, 20): wrong argument order * - GENMASK(72, 15): doesn't fit unsigned long * - GENMASK_U32(33, 15): doesn't fit in a u32 */ -#define GENMASK_TYPE(t, h, l) \ - ((unsigned int)GENMASK_INPUT_CHECK(h, l) + \ +#define GENMASK_TYPE(t, h, l) \ + ((unsigned int)GENMASK_INPUT_CHECK(h, l, BITS_PER_TYPE(t)) + \ ((t)-1 << (l) & (t)-1 >> (BITS_PER_TYPE(t) - 1 - (h)))) #endif =20 @@ -52,16 +67,26 @@ #if !defined(__ASSEMBLY__) /* * Fixed-type variants of BIT(), with additional checks like GENMASK_TYPE(= ). - * The following examples generate compiler warnings from BIT_INPUT_CHECK(= ). + * The following examples generate compiler errors from BIT_INPUT_CHECK(). * * - BIT_U8(8) * - BIT_U32(-1) * - BIT_U32(40) */ -#define BIT_INPUT_CHECK(type, nr) \ - BUILD_BUG_ON_ZERO(const_true((nr) >=3D BITS_PER_TYPE(type))) =20 -#define BIT_TYPE(type, nr) ((unsigned int)BIT_INPUT_CHECK(type, nr) + ((ty= pe)1 << (nr))) +#ifndef KBUILD_EXTRA_WARNc +#define BIT_INPUT_CHECK(nr, width) 0 +#else +int BIT_INPUT_CHECK_FAIL(void) __compiletime_error("Bit number out of rang= e"); +#define BIT_INPUT_CHECK(nr, width) \ + (__builtin_choose_expr(__is_constexpr(nr), \ + sizeof(struct { char bit_number_too_big[-((nr) >=3D (width))];}), \ + __builtin_constant_p(nr) && ((nr) < 0 || (nr) >=3D width) && \ + BIT_INPUT_CHECK_FAIL())) +#endif + +#define BIT_TYPE(type, nr) \ + ((unsigned int)BIT_INPUT_CHECK(+(nr), BITS_PER_TYPE(type)) + ((type)1 << = (nr))) #endif /* defined(__ASSEMBLY__) */ =20 #define BIT_U8(nr) BIT_TYPE(u8, nr) diff --git a/lib/tests/test_bits.c b/lib/tests/test_bits.c index 55be8230f9e7..36eb4661e78b 100644 --- a/lib/tests/test_bits.c +++ b/lib/tests/test_bits.c @@ -3,6 +3,8 @@ * Test cases for functions and macros in bits.h */ =20 +#define KBUILD_EXTRA_WARNc 1 + #include #include #include @@ -118,24 +120,30 @@ static void genmask_u128_test(struct kunit *test) =20 static void genmask_input_check_test(struct kunit *test) { - unsigned int x, y; - int z, w; + unsigned int x =3D 1, y =3D 2; + int z =3D 1, w =3D 2; + + OPTIMIZER_HIDE_VAR(x); + OPTIMIZER_HIDE_VAR(y); + OPTIMIZER_HIDE_VAR(z); + OPTIMIZER_HIDE_VAR(w); =20 /* Unknown input */ - KUNIT_EXPECT_EQ(test, 0, GENMASK_INPUT_CHECK(x, 0)); - KUNIT_EXPECT_EQ(test, 0, GENMASK_INPUT_CHECK(0, x)); - KUNIT_EXPECT_EQ(test, 0, GENMASK_INPUT_CHECK(x, y)); + KUNIT_EXPECT_EQ(test, 0, GENMASK_INPUT_CHECK(x, 0, 32)); + KUNIT_EXPECT_EQ(test, 0, GENMASK_INPUT_CHECK(0, x, 32)); + KUNIT_EXPECT_EQ(test, 0, GENMASK_INPUT_CHECK(x, y, 32)); =20 - KUNIT_EXPECT_EQ(test, 0, GENMASK_INPUT_CHECK(z, 0)); - KUNIT_EXPECT_EQ(test, 0, GENMASK_INPUT_CHECK(0, z)); - KUNIT_EXPECT_EQ(test, 0, GENMASK_INPUT_CHECK(z, w)); + KUNIT_EXPECT_EQ(test, 0, GENMASK_INPUT_CHECK(z, 0, 32)); + KUNIT_EXPECT_EQ(test, 0, GENMASK_INPUT_CHECK(0, z, 32)); + KUNIT_EXPECT_EQ(test, 0, GENMASK_INPUT_CHECK(z, w, 32)); =20 /* Valid input */ - KUNIT_EXPECT_EQ(test, 0, GENMASK_INPUT_CHECK(1, 1)); - KUNIT_EXPECT_EQ(test, 0, GENMASK_INPUT_CHECK(39, 21)); - KUNIT_EXPECT_EQ(test, 0, GENMASK_INPUT_CHECK(100, 80)); - KUNIT_EXPECT_EQ(test, 0, GENMASK_INPUT_CHECK(110, 65)); - KUNIT_EXPECT_EQ(test, 0, GENMASK_INPUT_CHECK(127, 0)); + KUNIT_EXPECT_EQ(test, 0, GENMASK_INPUT_CHECK(1, 1, 32)); + KUNIT_EXPECT_EQ(test, 0, GENMASK_INPUT_CHECK(39, 21, 64)); + + KUNIT_EXPECT_EQ(test, 0, GENMASK_INPUT_CHECK(100, 80, 128)); + KUNIT_EXPECT_EQ(test, 0, GENMASK_INPUT_CHECK(110, 65, 128)); + KUNIT_EXPECT_EQ(test, 0, GENMASK_INPUT_CHECK(127, 0, 128)); } =20 =20 --=20 2.39.5 From nobody Sat Feb 7 17:55:08 2026 Received: from mailtransmit04.runbox.com (mailtransmit04.runbox.com [185.226.149.37]) (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 AD2244DB561 for ; Wed, 21 Jan 2026 14:58:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.37 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769007501; cv=none; b=a5KpELkSRDmkCUccH3HSlo/T8dRxS8/3spa5x+voB4f0MjuBPk3i397uNJKogKOhdzE40Hc/xVWz+Hh8xYUMNU8bKI+Xn0fWXIB046RLt/D3xWqtTSyga2pCKA+x9/PwSvfqvkLyowWVgK2xufNsGQIaLg8jd4LDW5ZjT5eXGsg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769007501; c=relaxed/simple; bh=OuoX9rZ0eSyjPgtxw+7n9VkSoFoOdOkSZxjyKEbJrlc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=aekE5H2x0If/l3ww41YOTcLUQg8zTojEDIs6aveYKunqhIzzWtPSZOeDxOa5NsQWZDAa1YH0QPRlFnoqJq+Oq4nJBkYuengw8jZmNW+ere82I+zLH7X0W2ThV6i+nKLcQn+dEfJ9iiCoRhwpL5LigTjOe2lRcAvAE589ogx2Le8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=HNAKmRJA; arc=none smtp.client-ip=185.226.149.37 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="HNAKmRJA" Received: from mailtransmit02.runbox ([10.9.9.162] helo=aibo.runbox.com) by mailtransmit04.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1viZet-008XFR-Th; Wed, 21 Jan 2026 15:58:11 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector2; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=/ToXfeXh3OPuvD0iNKmVcu+YVeCSv/mDVOYNbMhE++U=; b=HNAKmRJAX0l0p8ILIbUcsRcn7m PHCbvFoW1SX91LbL+trQBUEQdshO58/rQ6TvPnLbUCz8mFhxEJPonSM0uj9gTeUWpcO43FIMsusj3 6YNSn6t1o2MwV7vQ4aEMOyMs9HB5PC7plzImRnYAmLB25+4qX6GVUzInGb+Ov/ep+SZO+CYFYFOUM qUnaLsCL6bCn0MWLtivbqF6QmfciRMkktsFFz+bzEo6HQBSTwn3jYGXRTBAmNswjE3rVtwhvOf50D txbqmIToXte4S5sQmitgsmZ5hzAZF68aPCzPvh7cjVdz5O/at3v8DSjAtLpoN5C9huqS/DMk0lr8i MTQfFeCw==; Received: from [10.9.9.72] (helo=submission01.runbox) by mailtransmit02.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1viZet-0001tU-Aq; Wed, 21 Jan 2026 15:58:11 +0100 Received: by submission01.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1viZeZ-00GH6h-79; Wed, 21 Jan 2026 15:57:51 +0100 From: david.laight.linux@gmail.com To: 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 Cc: David Laight Subject: [PATCH next 12/14] bits: move the defitions of BIT() and BIT_ULL() back to linux/bits.h Date: Wed, 21 Jan 2026 14:57:29 +0000 Message-Id: <20260121145731.3623-13-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20260121145731.3623-1-david.laight.linux@gmail.com> References: <20260121145731.3623-1-david.laight.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Laight The definition of BIT() was moved from linux/bits.h to vdso/bits.h to isolate the vdso from 'normal' kernel headers. BIT_ULL() was then moved to be defined in the same place for consistency. Since then linux/bits.h had gained BIT_Unn() and it really makes sense for BIT() and BIT_ULL() to be defined in the same place. Move BIT_ULL() and make code that include both headers use the definition of BIT() from linux/bits.h Add BIT_U128() for completness. This lets BIT() pick up the extra compile time checks for W=3D[1c] builds that detect errors like: long foo(void) { int x =3D 64; return BIT(x); } For which clang (silently) just generates a 'return' instruction. Note that nothing the the x86-64 build relies on the definition in vdso/bits.h, linux/bits.h is always included. Signed-off-by: David Laight --- include/linux/bits.h | 7 ++++++- include/vdso/bits.h | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/include/linux/bits.h b/include/linux/bits.h index 0f559038981d..3dd32b9eef35 100644 --- a/include/linux/bits.h +++ b/include/linux/bits.h @@ -2,7 +2,6 @@ #ifndef __LINUX_BITS_H #define __LINUX_BITS_H =20 -#include #include =20 #define BIT_MASK(nr) (UL(1) << ((nr) % BITS_PER_LONG)) @@ -89,10 +88,16 @@ int BIT_INPUT_CHECK_FAIL(void) __compiletime_error("Bit= number out of range"); ((unsigned int)BIT_INPUT_CHECK(+(nr), BITS_PER_TYPE(type)) + ((type)1 << = (nr))) #endif /* defined(__ASSEMBLY__) */ =20 +/* Prefer this definition of BIT() to the one in vdso/bits.h */ +#undef BIT +#define __VDSO_BITS_H +#define BIT(nr) BIT_TYPE(unsigned long, nr) +#define BIT_ULL(nr) BIT_TYPE(unsigned long long, nr) #define BIT_U8(nr) BIT_TYPE(u8, nr) #define BIT_U16(nr) BIT_TYPE(u16, nr) #define BIT_U32(nr) BIT_TYPE(u32, nr) #define BIT_U64(nr) BIT_TYPE(u64, nr) +#define BIT_U128(nr) BIT_TYPE(u128, nr) =20 #if defined(__ASSEMBLY__) =20 diff --git a/include/vdso/bits.h b/include/vdso/bits.h index 388b212088ea..a6ac1e6b637c 100644 --- a/include/vdso/bits.h +++ b/include/vdso/bits.h @@ -4,7 +4,7 @@ =20 #include =20 +/* Most code picks up BIT() from linux/bits.h */ #define BIT(nr) (UL(1) << (nr)) -#define BIT_ULL(nr) (ULL(1) << (nr)) =20 #endif /* __VDSO_BITS_H */ --=20 2.39.5 From nobody Sat Feb 7 17:55:08 2026 Received: from mailtransmit05.runbox.com (mailtransmit05.runbox.com [185.226.149.38]) (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 D3C714A33F9; Wed, 21 Jan 2026 14:58:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.38 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769007500; cv=none; b=OwPsyxPnFjw7MnCHBFMdg5HQm/frv5aPFAlAM5130uufB0470xWrZSG3ezl0yDnPF7+bnG8KmYNfP3pKmkOm+e12LR2KmymvQax4P9DNe2XA6xfvv4OEVzF8ZVijDMkZytH6+k35JKk4Zsx9Fng3SMyfpwaykx1c3VEB5ucX3Rg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769007500; c=relaxed/simple; bh=GrU5G25/P99RLLNQ7KSbxlvGQaNMjUwXFB4EvQMlbdY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=hCYJpqQPjVrjMy5ESACaFoxEOzan6HX3ByEnM1C3rSgf8O9hIIrfpWd7OGSc9CdEzQ88IGVRREzG4XpAidgx5Xw0p8v2bHE3WxnBanGYrforWa8QT+5XQaouMBdOeRo2MLs5R2EPbYh/L9sMOeGnUdze+i6WygLLGMrBW5Ni8Q4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=mumsnJE3; arc=none smtp.client-ip=185.226.149.38 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="mumsnJE3" Received: from mailtransmit02.runbox ([10.9.9.162] helo=aibo.runbox.com) by mailtransmit05.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1viZet-008Pjm-DL; Wed, 21 Jan 2026 15:58:11 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector2; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=IMLT+9LEWzpcaNrLe+KYWU3xSE5AFfmLcg7xui5sLPw=; b=mumsnJE3uG328eoTonga0q7XW6 YfxKMj4TyOcRNmcEom1hQhXoXBkDtQJu67uXD+e6W/e3KOT/1MalE7MCaGuQK/8u/AEkbuxda2HHT LZfVxqkJIlusPga7K1VSy/+CuaFF+ZiA4GfpPYtAgnVNcCG9/WEZ5yGVRzcgdyaG6rY+G1wK2Jf7w 78dhBKJBBpTGGbdUyGJ3tfUzOdyJDMtcXt5+N6AMhNCsqGPBSIN7Pn76W+JivjdCDplOkc11JweDB NbWmJf6JRbCnVRg0slt8LFoU+ehGPwqntj1KNg+urxtMk28oyxwHFvC3eK+dCu+jr+BNAK5xm0nC/ 3m/rHDYg==; Received: from [10.9.9.72] (helo=submission01.runbox) by mailtransmit02.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1viZes-0001sq-Lm; Wed, 21 Jan 2026 15:58:11 +0100 Received: by submission01.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1viZeZ-00GH6h-QD; Wed, 21 Jan 2026 15:57:51 +0100 From: david.laight.linux@gmail.com To: 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 Cc: David Laight Subject: [PATCH next 13/14] test_bits: Change all the tests to be compile-time tests Date: Wed, 21 Jan 2026 14:57:30 +0000 Message-Id: <20260121145731.3623-14-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20260121145731.3623-1-david.laight.linux@gmail.com> References: <20260121145731.3623-1-david.laight.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Laight Since all the GENMASK() values are compile-time constants they can be tested with BUILD_BUG_ON() rather than KUNIT_EXPECT_EQ(). Signed-off-by: David Laight --- lib/tests/test_bits.c | 90 +++++++++++++++++++++---------------------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/lib/tests/test_bits.c b/lib/tests/test_bits.c index 36eb4661e78b..4d3a895f490c 100644 --- a/lib/tests/test_bits.c +++ b/lib/tests/test_bits.c @@ -32,30 +32,30 @@ static_assert(assert_type(u64, GENMASK_U64(63, 0)) =3D= =3D U64_MAX); =20 static void __genmask_test(struct kunit *test) { - KUNIT_EXPECT_EQ(test, 1ul, __GENMASK(0, 0)); - KUNIT_EXPECT_EQ(test, 3ul, __GENMASK(1, 0)); - KUNIT_EXPECT_EQ(test, 6ul, __GENMASK(2, 1)); - KUNIT_EXPECT_EQ(test, 0xFFFFFFFFul, __GENMASK(31, 0)); + BUILD_BUG_ON(__GENMASK(0, 0) !=3D 1ul); + BUILD_BUG_ON(__GENMASK(1, 0) !=3D 3ul); + BUILD_BUG_ON(__GENMASK(2, 1) !=3D 6ul); + BUILD_BUG_ON(__GENMASK(31, 0) !=3D 0xFFFFFFFFul); } =20 static void __genmask_ull_test(struct kunit *test) { - KUNIT_EXPECT_EQ(test, 1ull, __GENMASK_ULL(0, 0)); - KUNIT_EXPECT_EQ(test, 3ull, __GENMASK_ULL(1, 0)); - KUNIT_EXPECT_EQ(test, 0x000000ffffe00000ull, __GENMASK_ULL(39, 21)); - KUNIT_EXPECT_EQ(test, 0xffffffffffffffffull, __GENMASK_ULL(63, 0)); + BUILD_BUG_ON(__GENMASK_ULL(0, 0) !=3D 1ull); + BUILD_BUG_ON(__GENMASK_ULL(1, 0) !=3D 3ull); + BUILD_BUG_ON(__GENMASK_ULL(39, 21) !=3D 0x000000ffffe00000ull); + BUILD_BUG_ON(__GENMASK_ULL(63, 0) !=3D 0xffffffffffffffffull); } =20 static void genmask_test(struct kunit *test) { - KUNIT_EXPECT_EQ(test, 1ul, GENMASK(0, 0)); - KUNIT_EXPECT_EQ(test, 3ul, GENMASK(1, 0)); - KUNIT_EXPECT_EQ(test, 6ul, GENMASK(2, 1)); - KUNIT_EXPECT_EQ(test, 0xFFFFFFFFul, GENMASK(31, 0)); + BUILD_BUG_ON(GENMASK(0, 0) !=3D 1ul); + BUILD_BUG_ON(GENMASK(1, 0) !=3D 3ul); + BUILD_BUG_ON(GENMASK(2, 1) !=3D 6ul); + BUILD_BUG_ON(GENMASK(31, 0) !=3D 0xFFFFFFFFul); =20 - KUNIT_EXPECT_EQ(test, 1u, GENMASK_U8(0, 0)); - KUNIT_EXPECT_EQ(test, 3u, GENMASK_U16(1, 0)); - KUNIT_EXPECT_EQ(test, 0x10000, GENMASK_U32(16, 16)); + BUILD_BUG_ON(GENMASK_U8(0, 0) !=3D 1u); + BUILD_BUG_ON(GENMASK_U16(1, 0) !=3D 3u); + BUILD_BUG_ON(GENMASK_U32(16, 16) !=3D 0x10000); =20 #ifdef TEST_GENMASK_FAILURES /* these should fail compilation */ @@ -75,10 +75,10 @@ static void genmask_test(struct kunit *test) =20 static void genmask_ull_test(struct kunit *test) { - KUNIT_EXPECT_EQ(test, 1ull, GENMASK_ULL(0, 0)); - KUNIT_EXPECT_EQ(test, 3ull, GENMASK_ULL(1, 0)); - KUNIT_EXPECT_EQ(test, 0x000000ffffe00000ull, GENMASK_ULL(39, 21)); - KUNIT_EXPECT_EQ(test, 0xffffffffffffffffull, GENMASK_ULL(63, 0)); + BUILD_BUG_ON(GENMASK_ULL(0, 0) !=3D 1ull); + BUILD_BUG_ON(GENMASK_ULL(1, 0) !=3D 3ull); + BUILD_BUG_ON(GENMASK_ULL(39, 21) !=3D 0x000000ffffe00000ull); + BUILD_BUG_ON(GENMASK_ULL(63, 0) !=3D 0xffffffffffffffffull); =20 #ifdef TEST_GENMASK_FAILURES /* these should fail compilation */ @@ -92,23 +92,23 @@ static void genmask_u128_test(struct kunit *test) { #ifdef CONFIG_ARCH_SUPPORTS_INT128 /* Below 64 bit masks */ - KUNIT_EXPECT_EQ(test, 0x0000000000000001ull, GENMASK_U128(0, 0)); - KUNIT_EXPECT_EQ(test, 0x0000000000000003ull, GENMASK_U128(1, 0)); - KUNIT_EXPECT_EQ(test, 0x0000000000000006ull, GENMASK_U128(2, 1)); - KUNIT_EXPECT_EQ(test, 0x00000000ffffffffull, GENMASK_U128(31, 0)); - KUNIT_EXPECT_EQ(test, 0x000000ffffe00000ull, GENMASK_U128(39, 21)); - KUNIT_EXPECT_EQ(test, 0xffffffffffffffffull, GENMASK_U128(63, 0)); + BUILD_BUG_ON(GENMASK_U128(0, 0) !=3D 0x0000000000000001ull); + BUILD_BUG_ON(GENMASK_U128(1, 0) !=3D 0x0000000000000003ull); + BUILD_BUG_ON(GENMASK_U128(2, 1) !=3D 0x0000000000000006ull); + BUILD_BUG_ON(GENMASK_U128(31, 0) !=3D 0x00000000ffffffffull); + BUILD_BUG_ON(GENMASK_U128(39, 21) !=3D 0x000000ffffe00000ull); + BUILD_BUG_ON(GENMASK_U128(63, 0) !=3D 0xffffffffffffffffull); =20 /* Above 64 bit masks - only 64 bit portion can be validated once */ - KUNIT_EXPECT_EQ(test, 0xffffffffffffffffull, GENMASK_U128(64, 0) >> 1); - KUNIT_EXPECT_EQ(test, 0x00000000ffffffffull, GENMASK_U128(81, 50) >> 50); - KUNIT_EXPECT_EQ(test, 0x0000000000ffffffull, GENMASK_U128(87, 64) >> 64); - KUNIT_EXPECT_EQ(test, 0x0000000000ff0000ull, GENMASK_U128(87, 80) >> 64); - - KUNIT_EXPECT_EQ(test, 0xffffffffffffffffull, GENMASK_U128(127, 0) >> 64); - KUNIT_EXPECT_EQ(test, 0xffffffffffffffffull, (u64)GENMASK_U128(127, 0)); - KUNIT_EXPECT_EQ(test, 0x0000000000000003ull, GENMASK_U128(127, 126) >> 12= 6); - KUNIT_EXPECT_EQ(test, 0x0000000000000001ull, GENMASK_U128(127, 127) >> 12= 7); + BUILD_BUG_ON(GENMASK_U128(64, 0) >> 1 !=3D 0xffffffffffffffffull); + BUILD_BUG_ON(GENMASK_U128(81, 50) >> 50 !=3D 0x00000000ffffffffull); + BUILD_BUG_ON(GENMASK_U128(87, 64) >> 64 !=3D 0x0000000000ffffffull); + BUILD_BUG_ON(GENMASK_U128(87, 80) >> 64 !=3D 0x0000000000ff0000ull); + + BUILD_BUG_ON(GENMASK_U128(127, 0) >> 64 !=3D 0xffffffffffffffffull); + BUILD_BUG_ON((u64)GENMASK_U128(127, 0) !=3D 0xffffffffffffffffull); + BUILD_BUG_ON(GENMASK_U128(127, 126) >> 126 !=3D 0x0000000000000003ull); + BUILD_BUG_ON(GENMASK_U128(127, 127) >> 127 !=3D 0x0000000000000001ull); #ifdef TEST_GENMASK_FAILURES /* these should fail compilation */ GENMASK_U128(0, 1); @@ -129,21 +129,21 @@ static void genmask_input_check_test(struct kunit *te= st) OPTIMIZER_HIDE_VAR(w); =20 /* Unknown input */ - KUNIT_EXPECT_EQ(test, 0, GENMASK_INPUT_CHECK(x, 0, 32)); - KUNIT_EXPECT_EQ(test, 0, GENMASK_INPUT_CHECK(0, x, 32)); - KUNIT_EXPECT_EQ(test, 0, GENMASK_INPUT_CHECK(x, y, 32)); + BUILD_BUG_ON(GENMASK_INPUT_CHECK(x, 0, 32) !=3D 0); + BUILD_BUG_ON(GENMASK_INPUT_CHECK(0, x, 32) !=3D 0); + BUILD_BUG_ON(GENMASK_INPUT_CHECK(x, y, 32) !=3D 0); =20 - KUNIT_EXPECT_EQ(test, 0, GENMASK_INPUT_CHECK(z, 0, 32)); - KUNIT_EXPECT_EQ(test, 0, GENMASK_INPUT_CHECK(0, z, 32)); - KUNIT_EXPECT_EQ(test, 0, GENMASK_INPUT_CHECK(z, w, 32)); + BUILD_BUG_ON(GENMASK_INPUT_CHECK(z, 0, 32) !=3D 0); + BUILD_BUG_ON(GENMASK_INPUT_CHECK(0, z, 32) !=3D 0); + BUILD_BUG_ON(GENMASK_INPUT_CHECK(z, w, 32) !=3D 0); =20 /* Valid input */ - KUNIT_EXPECT_EQ(test, 0, GENMASK_INPUT_CHECK(1, 1, 32)); - KUNIT_EXPECT_EQ(test, 0, GENMASK_INPUT_CHECK(39, 21, 64)); + BUILD_BUG_ON(GENMASK_INPUT_CHECK(1, 1, 32) !=3D 0); + BUILD_BUG_ON(GENMASK_INPUT_CHECK(39, 21, 64) !=3D 0); =20 - KUNIT_EXPECT_EQ(test, 0, GENMASK_INPUT_CHECK(100, 80, 128)); - KUNIT_EXPECT_EQ(test, 0, GENMASK_INPUT_CHECK(110, 65, 128)); - KUNIT_EXPECT_EQ(test, 0, GENMASK_INPUT_CHECK(127, 0, 128)); + BUILD_BUG_ON(GENMASK_INPUT_CHECK(100, 80, 128) !=3D 0); + BUILD_BUG_ON(GENMASK_INPUT_CHECK(110, 65, 128) !=3D 0); + BUILD_BUG_ON(GENMASK_INPUT_CHECK(127, 0, 128) !=3D 0); } =20 =20 --=20 2.39.5 From nobody Sat Feb 7 17:55:08 2026 Received: from mailtransmit05.runbox.com (mailtransmit05.runbox.com [185.226.149.38]) (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 192C74A13B5 for ; Wed, 21 Jan 2026 14:58:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.38 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769007491; cv=none; b=MRlNchApCVFh7r4CDK1EF5t+xXO1v2jp5OdJOG2uYhmqD+B5oO0a/uQ5V588Z5vc9jbx1SljLrd7OhSbd8RhOLdy1vpLoLzmukbYZmsGvwTYboRm+4GgtZZHUBT0fFUIlmuBV1w8g6OEor2+fU8WyKZXpDvJuD7AiVZKO8i8f2o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769007491; c=relaxed/simple; bh=gi0nk5NkqUvAm05qNBkzD1OrZj3hVKAmw95hlk8CKFY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Q0paQ3aF1BfDCyZatx+uOxILIvArE5Ek17rS59NxZyBOCzqrjOaZqexvIc4UIC5diNbUKRSdZ2LMllroexw2B8b68hIKOCsM4k+J7mOZ9TiPZmoRi7A5kLhFqgKHNpDAwnPFRUShJUMzKc4UfpAKC8nb1xNk16XJQF+3CjVmezI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=kguTAMzC; arc=none smtp.client-ip=185.226.149.38 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="kguTAMzC" Received: from mailtransmit03.runbox ([10.9.9.163] helo=aibo.runbox.com) by mailtransmit05.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1viZep-008PiY-6M; Wed, 21 Jan 2026 15:58:07 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector2; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=Ru1DgE8CQ/ycviFbDjOYAl+7Lss1ZyJkmQPVcZDGOIc=; b=kguTAMzC3fq+S8TPapXM6ZaOS6 Pg9VKbJZpPW30odB+GQfnTAnyAYFlKtMApqAsyJQVLul9QrisKRbwFcTOp47TW+wFS4Lw9ErTEw9o o3Iobf5eLgCT8N2PcJMtaRwAbYESGZ712bksDUo8kSIcDNr8/H4iZKsf89SfE84++guL/TlHBRUk2 nWPmIDpZoHBmG6oCNr4Hz5KHXA3W2h2jpx1uS0oA6nmllfSfZyLQXfgdOlFuSoYoFasQlE7drNVmo f2brUkybeJqdezD5MXVJx5CB2TcRLHqSyWhynl+SgdAV1keBRdICGvg2Yq5ntULmcL7X6dsxozWXC A1xS7iFQ==; Received: from [10.9.9.72] (helo=submission01.runbox) by mailtransmit03.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1viZeo-0006qW-O4; Wed, 21 Jan 2026 15:58:06 +0100 Received: by submission01.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1viZea-00GH6h-CT; Wed, 21 Jan 2026 15:57:52 +0100 From: david.laight.linux@gmail.com To: 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 Cc: David Laight Subject: [PATCH next 14/14] test_bits: include some invalid input tests for GENMASK_INPUT_CHECK() Date: Wed, 21 Jan 2026 14:57:31 +0000 Message-Id: <20260121145731.3623-15-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20260121145731.3623-1-david.laight.linux@gmail.com> References: <20260121145731.3623-1-david.laight.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Laight The check for invalid 'compile time constant' parameters can easily be changed to return 'failed' rather than generating a compile time error. Add some tests for negative, swapped and overlarge values. Signed-off-by: David Laight --- lib/tests/test_bits.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/tests/test_bits.c b/lib/tests/test_bits.c index 4d3a895f490c..9642c55f5487 100644 --- a/lib/tests/test_bits.c +++ b/lib/tests/test_bits.c @@ -144,6 +144,22 @@ static void genmask_input_check_test(struct kunit *tes= t) BUILD_BUG_ON(GENMASK_INPUT_CHECK(100, 80, 128) !=3D 0); BUILD_BUG_ON(GENMASK_INPUT_CHECK(110, 65, 128) !=3D 0); BUILD_BUG_ON(GENMASK_INPUT_CHECK(127, 0, 128) !=3D 0); + + /* + * Invalid input + * Change GENMASK_INPUT_CHECK() return 'fail' rather than + * generating a compile-time error. + */ +#define GENMASK_INPUT_CHECK_FAIL() 1 + z =3D 0; + BUILD_BUG_ON(GENMASK_INPUT_CHECK(z + 31, -1, 32) =3D=3D 0); + BUILD_BUG_ON(GENMASK_INPUT_CHECK(z + 0, 1, 32) =3D=3D 0); + BUILD_BUG_ON(GENMASK_INPUT_CHECK(z + 8, 0, 8) =3D=3D 0); + BUILD_BUG_ON(GENMASK_INPUT_CHECK(z + 16, 0, 16) =3D=3D 0); + BUILD_BUG_ON(GENMASK_INPUT_CHECK(z + 32, 0, 32) =3D=3D 0); + BUILD_BUG_ON(GENMASK_INPUT_CHECK(z + 64, 0, 64) =3D=3D 0); + BUILD_BUG_ON(GENMASK_INPUT_CHECK(z + 128, 0, 128) =3D=3D 0); +#undef GENMASK_INPUT_CHECK_FAIL } =20 =20 --=20 2.39.5