* [intel-linux-intel-lts:5.4/preempt-rt 11524/17326] include/linux/bitfield.h:106:3: error: call to '__bad_mask' declared with attribute error: bad bitfield mask
@ 2021-07-07 11:24 kernel test robot
0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2021-07-07 11:24 UTC (permalink / raw)
To: kbuild-all
[-- Attachment #1: Type: text/plain, Size: 10852 bytes --]
tree: https://github.com/intel/linux-intel-lts.git 5.4/preempt-rt
head: afc96dcd16aa7b79407a923f1d438146679805ad
commit: c5612e33a5de5b6ae673f25b4b36da9bf54e9ee5 [11524/17326] pwm: Add count attribute in sysfs for Intel Keem Bay
config: powerpc64-buildonly-randconfig-r006-20210707 (attached as .config)
compiler: powerpc64le-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel/linux-intel-lts/commit/c5612e33a5de5b6ae673f25b4b36da9bf54e9ee5
git remote add intel-linux-intel-lts https://github.com/intel/linux-intel-lts.git
git fetch --no-tags intel-linux-intel-lts 5.4/preempt-rt
git checkout c5612e33a5de5b6ae673f25b4b36da9bf54e9ee5
# save the attached .config to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross O=build_dir ARCH=powerpc SHELL=/bin/bash drivers/pwm/
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
In file included from drivers/pwm/pwm-keembay.c:16:
In function 'field_multiplier',
inlined from 'u32_encode_bits' at include/linux/bitfield.h:111:17,
inlined from 'keembay_pwm_update_bits.isra.0' at include/linux/bitfield.h:140:1:
>> include/linux/bitfield.h:106:3: error: call to '__bad_mask' declared with attribute error: bad bitfield mask
106 | __bad_mask();
| ^~~~~~~~~~~~
In function 'field_multiplier',
inlined from 'u32_encode_bits' at include/linux/bitfield.h:140:1,
inlined from 'keembay_pwm_update_bits.isra.0' at include/linux/bitfield.h:140:1:
>> include/linux/bitfield.h:106:3: error: call to '__bad_mask' declared with attribute error: bad bitfield mask
106 | __bad_mask();
| ^~~~~~~~~~~~
vim +/__bad_mask +106 include/linux/bitfield.h
3e9b3112ec74f1 Jakub Kicinski 2016-08-31 43
3e9b3112ec74f1 Jakub Kicinski 2016-08-31 44 #define __BF_FIELD_CHECK(_mask, _reg, _val, _pfx) \
3e9b3112ec74f1 Jakub Kicinski 2016-08-31 45 ({ \
3e9b3112ec74f1 Jakub Kicinski 2016-08-31 46 BUILD_BUG_ON_MSG(!__builtin_constant_p(_mask), \
3e9b3112ec74f1 Jakub Kicinski 2016-08-31 47 _pfx "mask is not constant"); \
e36488c83b6d87 Arnd Bergmann 2018-08-17 48 BUILD_BUG_ON_MSG((_mask) == 0, _pfx "mask is zero"); \
3e9b3112ec74f1 Jakub Kicinski 2016-08-31 49 BUILD_BUG_ON_MSG(__builtin_constant_p(_val) ? \
3e9b3112ec74f1 Jakub Kicinski 2016-08-31 50 ~((_mask) >> __bf_shf(_mask)) & (_val) : 0, \
3e9b3112ec74f1 Jakub Kicinski 2016-08-31 51 _pfx "value too large for the field"); \
3e9b3112ec74f1 Jakub Kicinski 2016-08-31 52 BUILD_BUG_ON_MSG((_mask) > (typeof(_reg))~0ull, \
3e9b3112ec74f1 Jakub Kicinski 2016-08-31 53 _pfx "type of reg too small for mask"); \
3e9b3112ec74f1 Jakub Kicinski 2016-08-31 54 __BUILD_BUG_ON_NOT_POWER_OF_2((_mask) + \
3e9b3112ec74f1 Jakub Kicinski 2016-08-31 55 (1ULL << __bf_shf(_mask))); \
3e9b3112ec74f1 Jakub Kicinski 2016-08-31 56 })
3e9b3112ec74f1 Jakub Kicinski 2016-08-31 57
1697599ee301a5 Jakub Kicinski 2017-02-09 58 /**
1697599ee301a5 Jakub Kicinski 2017-02-09 59 * FIELD_FIT() - check if value fits in the field
1697599ee301a5 Jakub Kicinski 2017-02-09 60 * @_mask: shifted mask defining the field's length and position
1697599ee301a5 Jakub Kicinski 2017-02-09 61 * @_val: value to test against the field
1697599ee301a5 Jakub Kicinski 2017-02-09 62 *
1697599ee301a5 Jakub Kicinski 2017-02-09 63 * Return: true if @_val can fit inside @_mask, false if @_val is too big.
1697599ee301a5 Jakub Kicinski 2017-02-09 64 */
1697599ee301a5 Jakub Kicinski 2017-02-09 65 #define FIELD_FIT(_mask, _val) \
1697599ee301a5 Jakub Kicinski 2017-02-09 66 ({ \
5be9072b8121b5 Jakub Kicinski 2020-08-10 67 __BF_FIELD_CHECK(_mask, 0ULL, 0ULL, "FIELD_FIT: "); \
1697599ee301a5 Jakub Kicinski 2017-02-09 68 !((((typeof(_mask))_val) << __bf_shf(_mask)) & ~(_mask)); \
1697599ee301a5 Jakub Kicinski 2017-02-09 69 })
1697599ee301a5 Jakub Kicinski 2017-02-09 70
3e9b3112ec74f1 Jakub Kicinski 2016-08-31 71 /**
3e9b3112ec74f1 Jakub Kicinski 2016-08-31 72 * FIELD_PREP() - prepare a bitfield element
3e9b3112ec74f1 Jakub Kicinski 2016-08-31 73 * @_mask: shifted mask defining the field's length and position
3e9b3112ec74f1 Jakub Kicinski 2016-08-31 74 * @_val: value to put in the field
3e9b3112ec74f1 Jakub Kicinski 2016-08-31 75 *
3e9b3112ec74f1 Jakub Kicinski 2016-08-31 76 * FIELD_PREP() masks and shifts up the value. The result should
3e9b3112ec74f1 Jakub Kicinski 2016-08-31 77 * be combined with other fields of the bitfield using logical OR.
3e9b3112ec74f1 Jakub Kicinski 2016-08-31 78 */
3e9b3112ec74f1 Jakub Kicinski 2016-08-31 79 #define FIELD_PREP(_mask, _val) \
3e9b3112ec74f1 Jakub Kicinski 2016-08-31 80 ({ \
3e9b3112ec74f1 Jakub Kicinski 2016-08-31 81 __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); \
3e9b3112ec74f1 Jakub Kicinski 2016-08-31 82 ((typeof(_mask))(_val) << __bf_shf(_mask)) & (_mask); \
3e9b3112ec74f1 Jakub Kicinski 2016-08-31 83 })
3e9b3112ec74f1 Jakub Kicinski 2016-08-31 84
3e9b3112ec74f1 Jakub Kicinski 2016-08-31 85 /**
3e9b3112ec74f1 Jakub Kicinski 2016-08-31 86 * FIELD_GET() - extract a bitfield element
3e9b3112ec74f1 Jakub Kicinski 2016-08-31 87 * @_mask: shifted mask defining the field's length and position
7240767450d6d8 Masahiro Yamada 2017-10-03 88 * @_reg: value of entire bitfield
3e9b3112ec74f1 Jakub Kicinski 2016-08-31 89 *
3e9b3112ec74f1 Jakub Kicinski 2016-08-31 90 * FIELD_GET() extracts the field specified by @_mask from the
3e9b3112ec74f1 Jakub Kicinski 2016-08-31 91 * bitfield passed in as @_reg by masking and shifting it down.
3e9b3112ec74f1 Jakub Kicinski 2016-08-31 92 */
3e9b3112ec74f1 Jakub Kicinski 2016-08-31 93 #define FIELD_GET(_mask, _reg) \
3e9b3112ec74f1 Jakub Kicinski 2016-08-31 94 ({ \
3e9b3112ec74f1 Jakub Kicinski 2016-08-31 95 __BF_FIELD_CHECK(_mask, _reg, 0U, "FIELD_GET: "); \
3e9b3112ec74f1 Jakub Kicinski 2016-08-31 96 (typeof(_mask))(((_reg) & (_mask)) >> __bf_shf(_mask)); \
3e9b3112ec74f1 Jakub Kicinski 2016-08-31 97 })
3e9b3112ec74f1 Jakub Kicinski 2016-08-31 98
e7d4a95da86e0b Johannes Berg 2018-06-20 99 extern void __compiletime_error("value doesn't fit into mask")
00b0c9b82663ac Al Viro 2017-12-14 100 __field_overflow(void);
00b0c9b82663ac Al Viro 2017-12-14 101 extern void __compiletime_error("bad bitfield mask")
00b0c9b82663ac Al Viro 2017-12-14 102 __bad_mask(void);
00b0c9b82663ac Al Viro 2017-12-14 103 static __always_inline u64 field_multiplier(u64 field)
00b0c9b82663ac Al Viro 2017-12-14 104 {
00b0c9b82663ac Al Viro 2017-12-14 105 if ((field | (field - 1)) & ((field | (field - 1)) + 1))
00b0c9b82663ac Al Viro 2017-12-14 @106 __bad_mask();
00b0c9b82663ac Al Viro 2017-12-14 107 return field & -field;
00b0c9b82663ac Al Viro 2017-12-14 108 }
00b0c9b82663ac Al Viro 2017-12-14 109 static __always_inline u64 field_mask(u64 field)
00b0c9b82663ac Al Viro 2017-12-14 110 {
00b0c9b82663ac Al Viro 2017-12-14 111 return field / field_multiplier(field);
00b0c9b82663ac Al Viro 2017-12-14 112 }
00b0c9b82663ac Al Viro 2017-12-14 113 #define ____MAKE_OP(type,base,to,from) \
00b0c9b82663ac Al Viro 2017-12-14 114 static __always_inline __##type type##_encode_bits(base v, base field) \
00b0c9b82663ac Al Viro 2017-12-14 115 { \
e7d4a95da86e0b Johannes Berg 2018-06-20 116 if (__builtin_constant_p(v) && (v & ~field_mask(field))) \
00b0c9b82663ac Al Viro 2017-12-14 117 __field_overflow(); \
00b0c9b82663ac Al Viro 2017-12-14 118 return to((v & field_mask(field)) * field_multiplier(field)); \
00b0c9b82663ac Al Viro 2017-12-14 119 } \
00b0c9b82663ac Al Viro 2017-12-14 120 static __always_inline __##type type##_replace_bits(__##type old, \
00b0c9b82663ac Al Viro 2017-12-14 121 base val, base field) \
00b0c9b82663ac Al Viro 2017-12-14 122 { \
00b0c9b82663ac Al Viro 2017-12-14 123 return (old & ~to(field)) | type##_encode_bits(val, field); \
00b0c9b82663ac Al Viro 2017-12-14 124 } \
00b0c9b82663ac Al Viro 2017-12-14 125 static __always_inline void type##p_replace_bits(__##type *p, \
00b0c9b82663ac Al Viro 2017-12-14 126 base val, base field) \
00b0c9b82663ac Al Viro 2017-12-14 127 { \
00b0c9b82663ac Al Viro 2017-12-14 128 *p = (*p & ~to(field)) | type##_encode_bits(val, field); \
00b0c9b82663ac Al Viro 2017-12-14 129 } \
00b0c9b82663ac Al Viro 2017-12-14 130 static __always_inline base type##_get_bits(__##type v, base field) \
00b0c9b82663ac Al Viro 2017-12-14 131 { \
00b0c9b82663ac Al Viro 2017-12-14 132 return (from(v) & field)/field_multiplier(field); \
00b0c9b82663ac Al Viro 2017-12-14 133 }
00b0c9b82663ac Al Viro 2017-12-14 134 #define __MAKE_OP(size) \
00b0c9b82663ac Al Viro 2017-12-14 135 ____MAKE_OP(le##size,u##size,cpu_to_le##size,le##size##_to_cpu) \
00b0c9b82663ac Al Viro 2017-12-14 136 ____MAKE_OP(be##size,u##size,cpu_to_be##size,be##size##_to_cpu) \
00b0c9b82663ac Al Viro 2017-12-14 137 ____MAKE_OP(u##size,u##size,,)
37a3862e123826 Johannes Berg 2018-06-20 138 ____MAKE_OP(u8,u8,,)
00b0c9b82663ac Al Viro 2017-12-14 139 __MAKE_OP(16)
00b0c9b82663ac Al Viro 2017-12-14 140 __MAKE_OP(32)
00b0c9b82663ac Al Viro 2017-12-14 141 __MAKE_OP(64)
00b0c9b82663ac Al Viro 2017-12-14 142 #undef __MAKE_OP
00b0c9b82663ac Al Viro 2017-12-14 143 #undef ____MAKE_OP
00b0c9b82663ac Al Viro 2017-12-14 144
:::::: The code at line 106 was first introduced by commit
:::::: 00b0c9b82663ac42e5a09f58ce960f81f29d64ee Add primitives for manipulating bitfields both in host- and fixed-endian.
:::::: TO: Al Viro <viro@zeniv.linux.org.uk>
:::::: CC: Al Viro <viro@zeniv.linux.org.uk>
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 34059 bytes --]
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-07-07 11:24 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-07 11:24 [intel-linux-intel-lts:5.4/preempt-rt 11524/17326] include/linux/bitfield.h:106:3: error: call to '__bad_mask' declared with attribute error: bad bitfield mask kernel test robot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.