From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============3031124137413402042==" MIME-Version: 1.0 From: kernel test robot To: kbuild-all@lists.01.org Subject: [intel-lts:5.4/yocto 11123/20394] include/linux/bitfield.h:106:17: error: call to '__bad_mask' declared with attribute error: bad bitfield mask Date: Fri, 21 Jan 2022 16:08:46 +0800 Message-ID: <202201211634.Gsb8Nf6P-lkp@intel.com> List-Id: --===============3031124137413402042== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Hi Poey, FYI, the error/warning still remains. tree: https://github.com/intel/linux-intel-lts.git 5.4/yocto head: 36f93ff941f127f4137ab369aecbdd995fb58c66 commit: c5612e33a5de5b6ae673f25b4b36da9bf54e9ee5 [11123/20394] pwm: Add cou= nt attribute in sysfs for Intel Keem Bay config: nds32-buildonly-randconfig-r005-20220119 (https://download.01.org/0= day-ci/archive/20220121/202201211634.Gsb8Nf6P-lkp(a)intel.com/config) compiler: nds32le-linux-gcc (GCC) 11.2.0 reproduce (this is a W=3D1 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/c5612e33a5de5b6ae= 673f25b4b36da9bf54e9ee5 git remote add intel-lts https://github.com/intel/linux-intel-lts.g= it git fetch --no-tags intel-lts 5.4/yocto git checkout c5612e33a5de5b6ae673f25b4b36da9bf54e9ee5 # save the config file to linux build tree mkdir build_dir COMPILER_INSTALL_PATH=3D$HOME/0day COMPILER=3Dgcc-11.2.0 make.cross= O=3Dbuild_dir ARCH=3Dnds32 SHELL=3D/bin/bash drivers/pwm/ If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot All errors (new ones prefixed by >>): In file included from drivers/pwm/pwm-keembay.c:16: In function 'field_multiplier', inlined from 'field_mask' at include/linux/bitfield.h:111:17, inlined from 'u32_encode_bits' at include/linux/bitfield.h:140:1, inlined from 'u32_replace_bits' at include/linux/bitfield.h:140:1, inlined from 'keembay_pwm_update_bits' at drivers/pwm/pwm-keembay.c:= 55:9: >> include/linux/bitfield.h:106:17: error: call to '__bad_mask' declared wi= th 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 'u32_replace_bits' at include/linux/bitfield.h:140:1, inlined from 'keembay_pwm_update_bits' at drivers/pwm/pwm-keembay.c:= 55:9: >> include/linux/bitfield.h:106:17: error: call to '__bad_mask' declared wi= th 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(_m= ask, _reg, _val, _pfx) \ 3e9b3112ec74f1 Jakub Kicinski 2016-08-31 45 ({ \ 3e9b3112ec74f1 Jakub Kicinski 2016-08-31 46 BUILD_BUG_ON_MSG(!__built= in_constant_p(_mask), \ 3e9b3112ec74f1 Jakub Kicinski 2016-08-31 47 _pfx "mask is not cons= tant"); \ e36488c83b6d87 Arnd Bergmann 2018-08-17 48 BUILD_BUG_ON_MSG((_mask) = =3D=3D 0, _pfx "mask is zero"); \ 3e9b3112ec74f1 Jakub Kicinski 2016-08-31 49 BUILD_BUG_ON_MSG(__builti= n_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_sh= f(_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 v= alue fits in the field 1697599ee301a5 Jakub Kicinski 2017-02-09 60 * @_mask: shifted mask def= ining the field's length and position 1697599ee301a5 Jakub Kicinski 2017-02-09 61 * @_val: value to test ag= ainst the field 1697599ee301a5 Jakub Kicinski 2017-02-09 62 * 1697599ee301a5 Jakub Kicinski 2017-02-09 63 * Return: true if @_val ca= n 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, _v= al) \ 1697599ee301a5 Jakub Kicinski 2017-02-09 66 ({ \ 5be9072b8121b5 Jakub Kicinski 2020-08-10 67 __BF_FIELD_CHECK(_mask, 0= ULL, 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 def= ining 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 s= hifts up the value. The result should 3e9b3112ec74f1 Jakub Kicinski 2016-08-31 77 * be combined with other f= ields 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, 0= ULL, _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 def= ining 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, _r= eg) \ 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_e= rror("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_e= rror("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_multi= plier(field); 00b0c9b82663ac Al Viro 2017-12-14 112 } 00b0c9b82663ac Al Viro 2017-12-14 113 #define ____MAKE_OP(type,ba= se,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 =3D (*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)/f= ield_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##si= ze,cpu_to_le##size,le##size##_to_cpu) \ 00b0c9b82663ac Al Viro 2017-12-14 136 ____MAKE_OP(be##size,u##si= ze,cpu_to_be##size,be##size##_to_cpu) \ 00b0c9b82663ac Al Viro 2017-12-14 137 ____MAKE_OP(u##size,u##siz= e,,) 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 manipula= ting bitfields both in host- and fixed-endian. :::::: TO: Al Viro :::::: CC: Al Viro --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org --===============3031124137413402042==--