Re: [PATCH next 11/14] bit: Strengthen compile-time tests in GENMASK() and BIT()

From: kernel test robot

Date: Wed Jan 21 2026 - 20:12:46 EST


Hi,

kernel test robot noticed the following build errors:

[auto build test ERROR on next-20260120]

url: https://github.com/intel-lab-lkp/linux/commits/david-laight-linux-gmail-com/overflow-Reduce-expansion-of-__type_max/20260122-013456
base: next-20260120
patch link: https://lore.kernel.org/r/20260121145731.3623-12-david.laight.linux%40gmail.com
patch subject: [PATCH next 11/14] bit: Strengthen compile-time tests in GENMASK() and BIT()
config: s390-randconfig-001-20260122 (https://download.01.org/0day-ci/archive/20260122/202601220829.MgTMeqqN-lkp@xxxxxxxxx/config)
compiler: s390-linux-gcc (GCC) 8.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260122/202601220829.MgTMeqqN-lkp@xxxxxxxxx/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202601220829.MgTMeqqN-lkp@xxxxxxxxx/

All errors (new ones prefixed by >>):

In file included from arch/s390/include/asm/bug.h:60,
from include/linux/bug.h:5,
from include/linux/mmdebug.h:5,
from arch/s390/include/asm/cmpxchg.h:11,
from arch/s390/include/asm/atomic.h:16,
from include/linux/atomic.h:7,
from include/asm-generic/bitops/atomic.h:5,
from arch/s390/include/asm/bitops.h:75,
from include/linux/bitops.h:67,
from include/linux/kernel.h:23,
from net/core/page_pool.c:10:
In function 'netmem_clear_pp_magic',
inlined from 'page_pool_clear_pp_info' at net/core/page_pool.c:721:2:
>> include/linux/bits.h:35:4: error: call to 'GENMASK_INPUT_CHECK_FAIL' declared with attribute error: Invalid bit numbers
GENMASK_INPUT_CHECK_FAIL()))
^~~~~~~~~~~~~~~~~~~~~~~~~~
include/asm-generic/bug.h:120:25: note: in definition of macro 'WARN_ON_ONCE'
int __ret_warn_on = !!(condition); \
^~~~~~~~~
include/linux/bits.h:54:17: note: in expansion of macro 'GENMASK_INPUT_CHECK'
((unsigned int)GENMASK_INPUT_CHECK(h, l, BITS_PER_TYPE(t)) + \
^~~~~~~~~~~~~~~~~~~
include/linux/bits.h:58:24: note: in expansion of macro 'GENMASK_TYPE'
#define GENMASK(h, l) GENMASK_TYPE(unsigned long, h, l)
^~~~~~~~~~~~
include/linux/mm.h:4641:27: note: in expansion of macro 'GENMASK'
#define PP_DMA_INDEX_MASK GENMASK(PP_DMA_INDEX_BITS + PP_DMA_INDEX_SHIFT - 1, \
^~~~~~~
net/core/netmem_priv.h:18:52: note: in expansion of macro 'PP_DMA_INDEX_MASK'
WARN_ON_ONCE(netmem_to_nmdesc(netmem)->pp_magic & PP_DMA_INDEX_MASK);
^~~~~~~~~~~~~~~~~
--
In file included from include/linux/bitops.h:6,
from arch/s390/include/asm/machine.h:25,
from arch/s390/include/asm/lowcore.h:13,
from arch/s390/include/asm/current.h:13,
from arch/s390/include/asm/preempt.h:5,
from include/linux/preempt.h:79,
from arch/s390/include/asm/timex.h:13,
from include/linux/timex.h:67,
from include/linux/time32.h:13,
from include/linux/time.h:60,
from include/linux/stat.h:19,
from include/linux/module.h:13,
from net/core/skbuff.c:37:
In function 'netmem_get_pp_magic',
inlined from 'netmem_is_pp' at net/core/netmem_priv.h:25:10,
inlined from 'napi_pp_put_page' at net/core/skbuff.c:1027:6:
>> include/linux/bits.h:35:4: error: call to 'GENMASK_INPUT_CHECK_FAIL' declared with attribute error: Invalid bit numbers
GENMASK_INPUT_CHECK_FAIL()))
^~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/bits.h:54:17: note: in expansion of macro 'GENMASK_INPUT_CHECK'
((unsigned int)GENMASK_INPUT_CHECK(h, l, BITS_PER_TYPE(t)) + \
^~~~~~~~~~~~~~~~~~~
include/linux/bits.h:58:24: note: in expansion of macro 'GENMASK_TYPE'
#define GENMASK(h, l) GENMASK_TYPE(unsigned long, h, l)
^~~~~~~~~~~~
include/linux/mm.h:4641:27: note: in expansion of macro 'GENMASK'
#define PP_DMA_INDEX_MASK GENMASK(PP_DMA_INDEX_BITS + PP_DMA_INDEX_SHIFT - 1, \
^~~~~~~
net/core/netmem_priv.h:8:47: note: in expansion of macro 'PP_DMA_INDEX_MASK'
return netmem_to_nmdesc(netmem)->pp_magic & ~PP_DMA_INDEX_MASK;
^~~~~~~~~~~~~~~~~
In function 'netmem_is_pp',
inlined from 'napi_pp_put_page' at net/core/skbuff.c:1027:6:
>> include/linux/bits.h:35:4: error: call to 'GENMASK_INPUT_CHECK_FAIL' declared with attribute error: Invalid bit numbers
GENMASK_INPUT_CHECK_FAIL()))
^~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/bits.h:54:17: note: in expansion of macro 'GENMASK_INPUT_CHECK'
((unsigned int)GENMASK_INPUT_CHECK(h, l, BITS_PER_TYPE(t)) + \
^~~~~~~~~~~~~~~~~~~
include/linux/bits.h:58:24: note: in expansion of macro 'GENMASK_TYPE'
#define GENMASK(h, l) GENMASK_TYPE(unsigned long, h, l)
^~~~~~~~~~~~
include/linux/mm.h:4641:27: note: in expansion of macro 'GENMASK'
#define PP_DMA_INDEX_MASK GENMASK(PP_DMA_INDEX_BITS + PP_DMA_INDEX_SHIFT - 1, \
^~~~~~~
include/linux/mm.h:4650:25: note: in expansion of macro 'PP_DMA_INDEX_MASK'
#define PP_MAGIC_MASK ~(PP_DMA_INDEX_MASK | 0x3UL)
^~~~~~~~~~~~~~~~~
net/core/netmem_priv.h:25:40: note: in expansion of macro 'PP_MAGIC_MASK'
return (netmem_get_pp_magic(netmem) & PP_MAGIC_MASK) == PP_SIGNATURE;
^~~~~~~~~~~~~
In function 'netmem_get_pp_magic',
inlined from 'netmem_is_pp' at net/core/netmem_priv.h:25:10,
inlined from 'napi_pp_put_page' at net/core/skbuff.c:1027:6:
>> include/linux/bits.h:35:4: error: call to 'GENMASK_INPUT_CHECK_FAIL' declared with attribute error: Invalid bit numbers
GENMASK_INPUT_CHECK_FAIL()))
^~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/bits.h:54:17: note: in expansion of macro 'GENMASK_INPUT_CHECK'
((unsigned int)GENMASK_INPUT_CHECK(h, l, BITS_PER_TYPE(t)) + \
^~~~~~~~~~~~~~~~~~~
include/linux/bits.h:58:24: note: in expansion of macro 'GENMASK_TYPE'
#define GENMASK(h, l) GENMASK_TYPE(unsigned long, h, l)
^~~~~~~~~~~~
include/linux/mm.h:4641:27: note: in expansion of macro 'GENMASK'
#define PP_DMA_INDEX_MASK GENMASK(PP_DMA_INDEX_BITS + PP_DMA_INDEX_SHIFT - 1, \
^~~~~~~
net/core/netmem_priv.h:8:47: note: in expansion of macro 'PP_DMA_INDEX_MASK'
return netmem_to_nmdesc(netmem)->pp_magic & ~PP_DMA_INDEX_MASK;
^~~~~~~~~~~~~~~~~
In function 'netmem_is_pp',
inlined from 'napi_pp_put_page' at net/core/skbuff.c:1027:6:
>> include/linux/bits.h:35:4: error: call to 'GENMASK_INPUT_CHECK_FAIL' declared with attribute error: Invalid bit numbers
GENMASK_INPUT_CHECK_FAIL()))
^~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/bits.h:54:17: note: in expansion of macro 'GENMASK_INPUT_CHECK'
((unsigned int)GENMASK_INPUT_CHECK(h, l, BITS_PER_TYPE(t)) + \
^~~~~~~~~~~~~~~~~~~
include/linux/bits.h:58:24: note: in expansion of macro 'GENMASK_TYPE'
#define GENMASK(h, l) GENMASK_TYPE(unsigned long, h, l)
^~~~~~~~~~~~
include/linux/mm.h:4641:27: note: in expansion of macro 'GENMASK'
#define PP_DMA_INDEX_MASK GENMASK(PP_DMA_INDEX_BITS + PP_DMA_INDEX_SHIFT - 1, \
^~~~~~~
include/linux/mm.h:4650:25: note: in expansion of macro 'PP_DMA_INDEX_MASK'
#define PP_MAGIC_MASK ~(PP_DMA_INDEX_MASK | 0x3UL)
^~~~~~~~~~~~~~~~~
net/core/netmem_priv.h:25:40: note: in expansion of macro 'PP_MAGIC_MASK'
return (netmem_get_pp_magic(netmem) & PP_MAGIC_MASK) == PP_SIGNATURE;
^~~~~~~~~~~~~
In function 'netmem_get_pp_magic',
inlined from 'netmem_is_pp' at net/core/netmem_priv.h:25:10,
inlined from 'skb_pp_frag_ref' at net/core/skbuff.c:1067:7,
inlined from 'skb_try_coalesce' at net/core/skbuff.c:6203:6:
>> include/linux/bits.h:35:4: error: call to 'GENMASK_INPUT_CHECK_FAIL' declared with attribute error: Invalid bit numbers
GENMASK_INPUT_CHECK_FAIL()))
^~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/bits.h:54:17: note: in expansion of macro 'GENMASK_INPUT_CHECK'
((unsigned int)GENMASK_INPUT_CHECK(h, l, BITS_PER_TYPE(t)) + \
^~~~~~~~~~~~~~~~~~~
include/linux/bits.h:58:24: note: in expansion of macro 'GENMASK_TYPE'
#define GENMASK(h, l) GENMASK_TYPE(unsigned long, h, l)
^~~~~~~~~~~~
include/linux/mm.h:4641:27: note: in expansion of macro 'GENMASK'
#define PP_DMA_INDEX_MASK GENMASK(PP_DMA_INDEX_BITS + PP_DMA_INDEX_SHIFT - 1, \
^~~~~~~
net/core/netmem_priv.h:8:47: note: in expansion of macro 'PP_DMA_INDEX_MASK'
return netmem_to_nmdesc(netmem)->pp_magic & ~PP_DMA_INDEX_MASK;
^~~~~~~~~~~~~~~~~
In function 'netmem_is_pp',
inlined from 'skb_pp_frag_ref' at net/core/skbuff.c:1067:7,
inlined from 'skb_try_coalesce' at net/core/skbuff.c:6203:6:
>> include/linux/bits.h:35:4: error: call to 'GENMASK_INPUT_CHECK_FAIL' declared with attribute error: Invalid bit numbers
GENMASK_INPUT_CHECK_FAIL()))
^~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/bits.h:54:17: note: in expansion of macro 'GENMASK_INPUT_CHECK'
((unsigned int)GENMASK_INPUT_CHECK(h, l, BITS_PER_TYPE(t)) + \
^~~~~~~~~~~~~~~~~~~
include/linux/bits.h:58:24: note: in expansion of macro 'GENMASK_TYPE'
#define GENMASK(h, l) GENMASK_TYPE(unsigned long, h, l)
^~~~~~~~~~~~
include/linux/mm.h:4641:27: note: in expansion of macro 'GENMASK'
#define PP_DMA_INDEX_MASK GENMASK(PP_DMA_INDEX_BITS + PP_DMA_INDEX_SHIFT - 1, \
^~~~~~~
include/linux/mm.h:4650:25: note: in expansion of macro 'PP_DMA_INDEX_MASK'
#define PP_MAGIC_MASK ~(PP_DMA_INDEX_MASK | 0x3UL)
^~~~~~~~~~~~~~~~~
net/core/netmem_priv.h:25:40: note: in expansion of macro 'PP_MAGIC_MASK'
return (netmem_get_pp_magic(netmem) & PP_MAGIC_MASK) == PP_SIGNATURE;
^~~~~~~~~~~~~
In function 'netmem_get_pp_magic',
inlined from 'netmem_is_pp' at net/core/netmem_priv.h:25:10,
inlined from 'skb_pp_frag_ref' at net/core/skbuff.c:1067:7,
inlined from 'skb_try_coalesce' at net/core/skbuff.c:6203:6:
>> include/linux/bits.h:35:4: error: call to 'GENMASK_INPUT_CHECK_FAIL' declared with attribute error: Invalid bit numbers
GENMASK_INPUT_CHECK_FAIL()))
^~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/bits.h:54:17: note: in expansion of macro 'GENMASK_INPUT_CHECK'
((unsigned int)GENMASK_INPUT_CHECK(h, l, BITS_PER_TYPE(t)) + \
^~~~~~~~~~~~~~~~~~~
include/linux/bits.h:58:24: note: in expansion of macro 'GENMASK_TYPE'
#define GENMASK(h, l) GENMASK_TYPE(unsigned long, h, l)
^~~~~~~~~~~~
include/linux/mm.h:4641:27: note: in expansion of macro 'GENMASK'
#define PP_DMA_INDEX_MASK GENMASK(PP_DMA_INDEX_BITS + PP_DMA_INDEX_SHIFT - 1, \
^~~~~~~
net/core/netmem_priv.h:8:47: note: in expansion of macro 'PP_DMA_INDEX_MASK'
return netmem_to_nmdesc(netmem)->pp_magic & ~PP_DMA_INDEX_MASK;
^~~~~~~~~~~~~~~~~
In function 'netmem_is_pp',
inlined from 'skb_pp_frag_ref' at net/core/skbuff.c:1067:7,
inlined from 'skb_try_coalesce' at net/core/skbuff.c:6203:6:
>> include/linux/bits.h:35:4: error: call to 'GENMASK_INPUT_CHECK_FAIL' declared with attribute error: Invalid bit numbers
GENMASK_INPUT_CHECK_FAIL()))
^~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/bits.h:54:17: note: in expansion of macro 'GENMASK_INPUT_CHECK'
((unsigned int)GENMASK_INPUT_CHECK(h, l, BITS_PER_TYPE(t)) + \
^~~~~~~~~~~~~~~~~~~
include/linux/bits.h:58:24: note: in expansion of macro 'GENMASK_TYPE'
#define GENMASK(h, l) GENMASK_TYPE(unsigned long, h, l)
^~~~~~~~~~~~
include/linux/mm.h:4641:27: note: in expansion of macro 'GENMASK'
#define PP_DMA_INDEX_MASK GENMASK(PP_DMA_INDEX_BITS + PP_DMA_INDEX_SHIFT - 1, \
^~~~~~~
include/linux/mm.h:4650:25: note: in expansion of macro 'PP_DMA_INDEX_MASK'
#define PP_MAGIC_MASK ~(PP_DMA_INDEX_MASK | 0x3UL)
^~~~~~~~~~~~~~~~~
net/core/netmem_priv.h:25:40: note: in expansion of macro 'PP_MAGIC_MASK'
return (netmem_get_pp_magic(netmem) & PP_MAGIC_MASK) == PP_SIGNATURE;
^~~~~~~~~~~~~


vim +/GENMASK_INPUT_CHECK_FAIL +35 include/linux/bits.h

25
26 #ifndef KBUILD_EXTRA_WARNc
27 #define GENMASK_INPUT_CHECK(h, l, width) 0
28 #else
29 int GENMASK_INPUT_CHECK_FAIL(void) __compiletime_error("Invalid bit numbers");
30 #define GENMASK_INPUT_CHECK(h, l, width) \
31 (__builtin_choose_expr(__is_constexpr((l) > (h)), \
32 sizeof(struct { char low_bit_greater_than_high[-((l) > (h))];}), \
33 __builtin_constant_p((l) | (h)) && \
34 ((l) < 0 || (l) > (h) || (h) >= width) && \
> 35 GENMASK_INPUT_CHECK_FAIL()))
36 #endif
37

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki