From: kernel test robot <lkp@intel.com> To: Vijayakannan Ayyathurai <vijayakannan.ayyathurai@intel.com> Cc: kbuild-all@lists.01.org, "Linux Memory Management List" <linux-mm@kvack.org>, "Thierry Reding" <thierry.reding@gmail.com>, "Lai, Poey Seng" <poey.seng.lai@intel.com>, "Vineetha G. Jaya Kumaran" <vineetha.g.jaya.kumaran@intel.com>, "Andy Shevchenko" <andriy.shevchenko@linux.intel.com>, "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de> Subject: [linux-next:master 4911/5794] include/linux/bitfield.h:119:3: error: call to '__bad_mask' declared with attribute error: bad bitfield mask Date: Mon, 16 Nov 2020 03:58:09 +0800 [thread overview] Message-ID: <202011160303.qi5aRChY-lkp@intel.com> (raw) [-- Attachment #1: Type: text/plain, Size: 11735 bytes --] tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master head: 92edc4aef86780a8ad01b092c6d6630bb3cb423d commit: 4a2d447bea5bdb175e0defaefcba74fc1517dff0 [4911/5794] pwm: Add PWM driver for Intel Keem Bay config: arm64-randconfig-p002-20201116 (attached as .config) compiler: aarch64-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://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=4a2d447bea5bdb175e0defaefcba74fc1517dff0 git remote add linux-next https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git git fetch --no-tags linux-next master git checkout 4a2d447bea5bdb175e0defaefcba74fc1517dff0 # save the attached .config to linux build tree COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=arm64 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 'keembay_pwm_update_bits.isra.0' at include/linux/bitfield.h:124:17: >> include/linux/bitfield.h:119:3: error: call to '__bad_mask' declared with attribute error: bad bitfield mask 119 | __bad_mask(); | ^~~~~~~~~~~~ In function 'field_multiplier', inlined from 'keembay_pwm_update_bits.isra.0' at include/linux/bitfield.h:154:1: >> include/linux/bitfield.h:119:3: error: call to '__bad_mask' declared with attribute error: bad bitfield mask 119 | __bad_mask(); | ^~~~~~~~~~~~ vim +/__bad_mask +119 include/linux/bitfield.h 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 43 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 44 #define __BF_FIELD_CHECK(_mask, _reg, _val, _pfx) \ 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 45 ({ \ 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 46 BUILD_BUG_ON_MSG(!__builtin_constant_p(_mask), \ 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 47 _pfx "mask is not constant"); \ e36488c83b6d871 Arnd Bergmann 2018-08-17 48 BUILD_BUG_ON_MSG((_mask) == 0, _pfx "mask is zero"); \ 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 49 BUILD_BUG_ON_MSG(__builtin_constant_p(_val) ? \ 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 50 ~((_mask) >> __bf_shf(_mask)) & (_val) : 0, \ 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 51 _pfx "value too large for the field"); \ 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 52 BUILD_BUG_ON_MSG((_mask) > (typeof(_reg))~0ull, \ 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 53 _pfx "type of reg too small for mask"); \ 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 54 __BUILD_BUG_ON_NOT_POWER_OF_2((_mask) + \ 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 55 (1ULL << __bf_shf(_mask))); \ 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 56 }) 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 57 e31a50162feb352 Alex Elder 2020-03-12 58 /** e31a50162feb352 Alex Elder 2020-03-12 59 * FIELD_MAX() - produce the maximum value representable by a field e31a50162feb352 Alex Elder 2020-03-12 60 * @_mask: shifted mask defining the field's length and position e31a50162feb352 Alex Elder 2020-03-12 61 * e31a50162feb352 Alex Elder 2020-03-12 62 * FIELD_MAX() returns the maximum value that can be held in the field e31a50162feb352 Alex Elder 2020-03-12 63 * specified by @_mask. e31a50162feb352 Alex Elder 2020-03-12 64 */ e31a50162feb352 Alex Elder 2020-03-12 65 #define FIELD_MAX(_mask) \ e31a50162feb352 Alex Elder 2020-03-12 66 ({ \ e31a50162feb352 Alex Elder 2020-03-12 67 __BF_FIELD_CHECK(_mask, 0ULL, 0ULL, "FIELD_MAX: "); \ e31a50162feb352 Alex Elder 2020-03-12 68 (typeof(_mask))((_mask) >> __bf_shf(_mask)); \ e31a50162feb352 Alex Elder 2020-03-12 69 }) e31a50162feb352 Alex Elder 2020-03-12 70 1697599ee301a52 Jakub Kicinski 2017-02-09 71 /** 1697599ee301a52 Jakub Kicinski 2017-02-09 72 * FIELD_FIT() - check if value fits in the field 1697599ee301a52 Jakub Kicinski 2017-02-09 73 * @_mask: shifted mask defining the field's length and position 1697599ee301a52 Jakub Kicinski 2017-02-09 74 * @_val: value to test against the field 1697599ee301a52 Jakub Kicinski 2017-02-09 75 * 1697599ee301a52 Jakub Kicinski 2017-02-09 76 * Return: true if @_val can fit inside @_mask, false if @_val is too big. 1697599ee301a52 Jakub Kicinski 2017-02-09 77 */ 1697599ee301a52 Jakub Kicinski 2017-02-09 78 #define FIELD_FIT(_mask, _val) \ 1697599ee301a52 Jakub Kicinski 2017-02-09 79 ({ \ 444da3f52407d74 Jakub Kicinski 2020-08-10 80 __BF_FIELD_CHECK(_mask, 0ULL, 0ULL, "FIELD_FIT: "); \ 1697599ee301a52 Jakub Kicinski 2017-02-09 81 !((((typeof(_mask))_val) << __bf_shf(_mask)) & ~(_mask)); \ 1697599ee301a52 Jakub Kicinski 2017-02-09 82 }) 1697599ee301a52 Jakub Kicinski 2017-02-09 83 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 84 /** 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 85 * FIELD_PREP() - prepare a bitfield element 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 86 * @_mask: shifted mask defining the field's length and position 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 87 * @_val: value to put in the field 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 88 * 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 89 * FIELD_PREP() masks and shifts up the value. The result should 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 90 * be combined with other fields of the bitfield using logical OR. 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 91 */ 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 92 #define FIELD_PREP(_mask, _val) \ 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 93 ({ \ 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 94 __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); \ 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 95 ((typeof(_mask))(_val) << __bf_shf(_mask)) & (_mask); \ 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 96 }) 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 97 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 98 /** 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 99 * FIELD_GET() - extract a bitfield element 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 100 * @_mask: shifted mask defining the field's length and position 7240767450d6d83 Masahiro Yamada 2017-10-03 101 * @_reg: value of entire bitfield 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 102 * 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 103 * FIELD_GET() extracts the field specified by @_mask from the 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 104 * bitfield passed in as @_reg by masking and shifting it down. 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 105 */ 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 106 #define FIELD_GET(_mask, _reg) \ 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 107 ({ \ 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 108 __BF_FIELD_CHECK(_mask, _reg, 0U, "FIELD_GET: "); \ 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 109 (typeof(_mask))(((_reg) & (_mask)) >> __bf_shf(_mask)); \ 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 110 }) 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 111 e7d4a95da86e0b0 Johannes Berg 2018-06-20 112 extern void __compiletime_error("value doesn't fit into mask") 00b0c9b82663ac4 Al Viro 2017-12-14 113 __field_overflow(void); 00b0c9b82663ac4 Al Viro 2017-12-14 114 extern void __compiletime_error("bad bitfield mask") 00b0c9b82663ac4 Al Viro 2017-12-14 115 __bad_mask(void); 00b0c9b82663ac4 Al Viro 2017-12-14 116 static __always_inline u64 field_multiplier(u64 field) 00b0c9b82663ac4 Al Viro 2017-12-14 117 { 00b0c9b82663ac4 Al Viro 2017-12-14 118 if ((field | (field - 1)) & ((field | (field - 1)) + 1)) 00b0c9b82663ac4 Al Viro 2017-12-14 @119 __bad_mask(); 00b0c9b82663ac4 Al Viro 2017-12-14 120 return field & -field; 00b0c9b82663ac4 Al Viro 2017-12-14 121 } 00b0c9b82663ac4 Al Viro 2017-12-14 122 static __always_inline u64 field_mask(u64 field) 00b0c9b82663ac4 Al Viro 2017-12-14 123 { 00b0c9b82663ac4 Al Viro 2017-12-14 124 return field / field_multiplier(field); 00b0c9b82663ac4 Al Viro 2017-12-14 125 } e31a50162feb352 Alex Elder 2020-03-12 126 #define field_max(field) ((typeof(field))field_mask(field)) 00b0c9b82663ac4 Al Viro 2017-12-14 127 #define ____MAKE_OP(type,base,to,from) \ 00b0c9b82663ac4 Al Viro 2017-12-14 128 static __always_inline __##type type##_encode_bits(base v, base field) \ 00b0c9b82663ac4 Al Viro 2017-12-14 129 { \ e7d4a95da86e0b0 Johannes Berg 2018-06-20 130 if (__builtin_constant_p(v) && (v & ~field_mask(field))) \ 00b0c9b82663ac4 Al Viro 2017-12-14 131 __field_overflow(); \ 00b0c9b82663ac4 Al Viro 2017-12-14 132 return to((v & field_mask(field)) * field_multiplier(field)); \ 00b0c9b82663ac4 Al Viro 2017-12-14 133 } \ 00b0c9b82663ac4 Al Viro 2017-12-14 134 static __always_inline __##type type##_replace_bits(__##type old, \ 00b0c9b82663ac4 Al Viro 2017-12-14 135 base val, base field) \ 00b0c9b82663ac4 Al Viro 2017-12-14 136 { \ 00b0c9b82663ac4 Al Viro 2017-12-14 137 return (old & ~to(field)) | type##_encode_bits(val, field); \ 00b0c9b82663ac4 Al Viro 2017-12-14 138 } \ 00b0c9b82663ac4 Al Viro 2017-12-14 139 static __always_inline void type##p_replace_bits(__##type *p, \ 00b0c9b82663ac4 Al Viro 2017-12-14 140 base val, base field) \ 00b0c9b82663ac4 Al Viro 2017-12-14 141 { \ 00b0c9b82663ac4 Al Viro 2017-12-14 142 *p = (*p & ~to(field)) | type##_encode_bits(val, field); \ 00b0c9b82663ac4 Al Viro 2017-12-14 143 } \ 00b0c9b82663ac4 Al Viro 2017-12-14 144 static __always_inline base type##_get_bits(__##type v, base field) \ 00b0c9b82663ac4 Al Viro 2017-12-14 145 { \ 00b0c9b82663ac4 Al Viro 2017-12-14 146 return (from(v) & field)/field_multiplier(field); \ 00b0c9b82663ac4 Al Viro 2017-12-14 147 } 00b0c9b82663ac4 Al Viro 2017-12-14 148 #define __MAKE_OP(size) \ 00b0c9b82663ac4 Al Viro 2017-12-14 149 ____MAKE_OP(le##size,u##size,cpu_to_le##size,le##size##_to_cpu) \ 00b0c9b82663ac4 Al Viro 2017-12-14 150 ____MAKE_OP(be##size,u##size,cpu_to_be##size,be##size##_to_cpu) \ 00b0c9b82663ac4 Al Viro 2017-12-14 151 ____MAKE_OP(u##size,u##size,,) 37a3862e1238262 Johannes Berg 2018-06-20 152 ____MAKE_OP(u8,u8,,) 00b0c9b82663ac4 Al Viro 2017-12-14 153 __MAKE_OP(16) 00b0c9b82663ac4 Al Viro 2017-12-14 154 __MAKE_OP(32) 00b0c9b82663ac4 Al Viro 2017-12-14 155 __MAKE_OP(64) 00b0c9b82663ac4 Al Viro 2017-12-14 156 #undef __MAKE_OP 00b0c9b82663ac4 Al Viro 2017-12-14 157 #undef ____MAKE_OP 00b0c9b82663ac4 Al Viro 2017-12-14 158 :::::: The code at line 119 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@lists.01.org [-- Attachment #2: .config.gz --] [-- Type: application/gzip, Size: 38893 bytes --]
WARNING: multiple messages have this Message-ID (diff)
From: kernel test robot <lkp@intel.com> To: kbuild-all@lists.01.org Subject: [linux-next:master 4911/5794] include/linux/bitfield.h:119:3: error: call to '__bad_mask' declared with attribute error: bad bitfield mask Date: Mon, 16 Nov 2020 03:58:09 +0800 [thread overview] Message-ID: <202011160303.qi5aRChY-lkp@intel.com> (raw) [-- Attachment #1: Type: text/plain, Size: 11897 bytes --] tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master head: 92edc4aef86780a8ad01b092c6d6630bb3cb423d commit: 4a2d447bea5bdb175e0defaefcba74fc1517dff0 [4911/5794] pwm: Add PWM driver for Intel Keem Bay config: arm64-randconfig-p002-20201116 (attached as .config) compiler: aarch64-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://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=4a2d447bea5bdb175e0defaefcba74fc1517dff0 git remote add linux-next https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git git fetch --no-tags linux-next master git checkout 4a2d447bea5bdb175e0defaefcba74fc1517dff0 # save the attached .config to linux build tree COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=arm64 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 'keembay_pwm_update_bits.isra.0' at include/linux/bitfield.h:124:17: >> include/linux/bitfield.h:119:3: error: call to '__bad_mask' declared with attribute error: bad bitfield mask 119 | __bad_mask(); | ^~~~~~~~~~~~ In function 'field_multiplier', inlined from 'keembay_pwm_update_bits.isra.0' at include/linux/bitfield.h:154:1: >> include/linux/bitfield.h:119:3: error: call to '__bad_mask' declared with attribute error: bad bitfield mask 119 | __bad_mask(); | ^~~~~~~~~~~~ vim +/__bad_mask +119 include/linux/bitfield.h 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 43 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 44 #define __BF_FIELD_CHECK(_mask, _reg, _val, _pfx) \ 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 45 ({ \ 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 46 BUILD_BUG_ON_MSG(!__builtin_constant_p(_mask), \ 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 47 _pfx "mask is not constant"); \ e36488c83b6d871 Arnd Bergmann 2018-08-17 48 BUILD_BUG_ON_MSG((_mask) == 0, _pfx "mask is zero"); \ 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 49 BUILD_BUG_ON_MSG(__builtin_constant_p(_val) ? \ 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 50 ~((_mask) >> __bf_shf(_mask)) & (_val) : 0, \ 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 51 _pfx "value too large for the field"); \ 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 52 BUILD_BUG_ON_MSG((_mask) > (typeof(_reg))~0ull, \ 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 53 _pfx "type of reg too small for mask"); \ 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 54 __BUILD_BUG_ON_NOT_POWER_OF_2((_mask) + \ 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 55 (1ULL << __bf_shf(_mask))); \ 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 56 }) 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 57 e31a50162feb352 Alex Elder 2020-03-12 58 /** e31a50162feb352 Alex Elder 2020-03-12 59 * FIELD_MAX() - produce the maximum value representable by a field e31a50162feb352 Alex Elder 2020-03-12 60 * @_mask: shifted mask defining the field's length and position e31a50162feb352 Alex Elder 2020-03-12 61 * e31a50162feb352 Alex Elder 2020-03-12 62 * FIELD_MAX() returns the maximum value that can be held in the field e31a50162feb352 Alex Elder 2020-03-12 63 * specified by @_mask. e31a50162feb352 Alex Elder 2020-03-12 64 */ e31a50162feb352 Alex Elder 2020-03-12 65 #define FIELD_MAX(_mask) \ e31a50162feb352 Alex Elder 2020-03-12 66 ({ \ e31a50162feb352 Alex Elder 2020-03-12 67 __BF_FIELD_CHECK(_mask, 0ULL, 0ULL, "FIELD_MAX: "); \ e31a50162feb352 Alex Elder 2020-03-12 68 (typeof(_mask))((_mask) >> __bf_shf(_mask)); \ e31a50162feb352 Alex Elder 2020-03-12 69 }) e31a50162feb352 Alex Elder 2020-03-12 70 1697599ee301a52 Jakub Kicinski 2017-02-09 71 /** 1697599ee301a52 Jakub Kicinski 2017-02-09 72 * FIELD_FIT() - check if value fits in the field 1697599ee301a52 Jakub Kicinski 2017-02-09 73 * @_mask: shifted mask defining the field's length and position 1697599ee301a52 Jakub Kicinski 2017-02-09 74 * @_val: value to test against the field 1697599ee301a52 Jakub Kicinski 2017-02-09 75 * 1697599ee301a52 Jakub Kicinski 2017-02-09 76 * Return: true if @_val can fit inside @_mask, false if @_val is too big. 1697599ee301a52 Jakub Kicinski 2017-02-09 77 */ 1697599ee301a52 Jakub Kicinski 2017-02-09 78 #define FIELD_FIT(_mask, _val) \ 1697599ee301a52 Jakub Kicinski 2017-02-09 79 ({ \ 444da3f52407d74 Jakub Kicinski 2020-08-10 80 __BF_FIELD_CHECK(_mask, 0ULL, 0ULL, "FIELD_FIT: "); \ 1697599ee301a52 Jakub Kicinski 2017-02-09 81 !((((typeof(_mask))_val) << __bf_shf(_mask)) & ~(_mask)); \ 1697599ee301a52 Jakub Kicinski 2017-02-09 82 }) 1697599ee301a52 Jakub Kicinski 2017-02-09 83 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 84 /** 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 85 * FIELD_PREP() - prepare a bitfield element 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 86 * @_mask: shifted mask defining the field's length and position 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 87 * @_val: value to put in the field 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 88 * 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 89 * FIELD_PREP() masks and shifts up the value. The result should 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 90 * be combined with other fields of the bitfield using logical OR. 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 91 */ 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 92 #define FIELD_PREP(_mask, _val) \ 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 93 ({ \ 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 94 __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); \ 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 95 ((typeof(_mask))(_val) << __bf_shf(_mask)) & (_mask); \ 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 96 }) 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 97 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 98 /** 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 99 * FIELD_GET() - extract a bitfield element 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 100 * @_mask: shifted mask defining the field's length and position 7240767450d6d83 Masahiro Yamada 2017-10-03 101 * @_reg: value of entire bitfield 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 102 * 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 103 * FIELD_GET() extracts the field specified by @_mask from the 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 104 * bitfield passed in as @_reg by masking and shifting it down. 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 105 */ 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 106 #define FIELD_GET(_mask, _reg) \ 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 107 ({ \ 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 108 __BF_FIELD_CHECK(_mask, _reg, 0U, "FIELD_GET: "); \ 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 109 (typeof(_mask))(((_reg) & (_mask)) >> __bf_shf(_mask)); \ 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 110 }) 3e9b3112ec74f19 Jakub Kicinski 2016-08-31 111 e7d4a95da86e0b0 Johannes Berg 2018-06-20 112 extern void __compiletime_error("value doesn't fit into mask") 00b0c9b82663ac4 Al Viro 2017-12-14 113 __field_overflow(void); 00b0c9b82663ac4 Al Viro 2017-12-14 114 extern void __compiletime_error("bad bitfield mask") 00b0c9b82663ac4 Al Viro 2017-12-14 115 __bad_mask(void); 00b0c9b82663ac4 Al Viro 2017-12-14 116 static __always_inline u64 field_multiplier(u64 field) 00b0c9b82663ac4 Al Viro 2017-12-14 117 { 00b0c9b82663ac4 Al Viro 2017-12-14 118 if ((field | (field - 1)) & ((field | (field - 1)) + 1)) 00b0c9b82663ac4 Al Viro 2017-12-14 @119 __bad_mask(); 00b0c9b82663ac4 Al Viro 2017-12-14 120 return field & -field; 00b0c9b82663ac4 Al Viro 2017-12-14 121 } 00b0c9b82663ac4 Al Viro 2017-12-14 122 static __always_inline u64 field_mask(u64 field) 00b0c9b82663ac4 Al Viro 2017-12-14 123 { 00b0c9b82663ac4 Al Viro 2017-12-14 124 return field / field_multiplier(field); 00b0c9b82663ac4 Al Viro 2017-12-14 125 } e31a50162feb352 Alex Elder 2020-03-12 126 #define field_max(field) ((typeof(field))field_mask(field)) 00b0c9b82663ac4 Al Viro 2017-12-14 127 #define ____MAKE_OP(type,base,to,from) \ 00b0c9b82663ac4 Al Viro 2017-12-14 128 static __always_inline __##type type##_encode_bits(base v, base field) \ 00b0c9b82663ac4 Al Viro 2017-12-14 129 { \ e7d4a95da86e0b0 Johannes Berg 2018-06-20 130 if (__builtin_constant_p(v) && (v & ~field_mask(field))) \ 00b0c9b82663ac4 Al Viro 2017-12-14 131 __field_overflow(); \ 00b0c9b82663ac4 Al Viro 2017-12-14 132 return to((v & field_mask(field)) * field_multiplier(field)); \ 00b0c9b82663ac4 Al Viro 2017-12-14 133 } \ 00b0c9b82663ac4 Al Viro 2017-12-14 134 static __always_inline __##type type##_replace_bits(__##type old, \ 00b0c9b82663ac4 Al Viro 2017-12-14 135 base val, base field) \ 00b0c9b82663ac4 Al Viro 2017-12-14 136 { \ 00b0c9b82663ac4 Al Viro 2017-12-14 137 return (old & ~to(field)) | type##_encode_bits(val, field); \ 00b0c9b82663ac4 Al Viro 2017-12-14 138 } \ 00b0c9b82663ac4 Al Viro 2017-12-14 139 static __always_inline void type##p_replace_bits(__##type *p, \ 00b0c9b82663ac4 Al Viro 2017-12-14 140 base val, base field) \ 00b0c9b82663ac4 Al Viro 2017-12-14 141 { \ 00b0c9b82663ac4 Al Viro 2017-12-14 142 *p = (*p & ~to(field)) | type##_encode_bits(val, field); \ 00b0c9b82663ac4 Al Viro 2017-12-14 143 } \ 00b0c9b82663ac4 Al Viro 2017-12-14 144 static __always_inline base type##_get_bits(__##type v, base field) \ 00b0c9b82663ac4 Al Viro 2017-12-14 145 { \ 00b0c9b82663ac4 Al Viro 2017-12-14 146 return (from(v) & field)/field_multiplier(field); \ 00b0c9b82663ac4 Al Viro 2017-12-14 147 } 00b0c9b82663ac4 Al Viro 2017-12-14 148 #define __MAKE_OP(size) \ 00b0c9b82663ac4 Al Viro 2017-12-14 149 ____MAKE_OP(le##size,u##size,cpu_to_le##size,le##size##_to_cpu) \ 00b0c9b82663ac4 Al Viro 2017-12-14 150 ____MAKE_OP(be##size,u##size,cpu_to_be##size,be##size##_to_cpu) \ 00b0c9b82663ac4 Al Viro 2017-12-14 151 ____MAKE_OP(u##size,u##size,,) 37a3862e1238262 Johannes Berg 2018-06-20 152 ____MAKE_OP(u8,u8,,) 00b0c9b82663ac4 Al Viro 2017-12-14 153 __MAKE_OP(16) 00b0c9b82663ac4 Al Viro 2017-12-14 154 __MAKE_OP(32) 00b0c9b82663ac4 Al Viro 2017-12-14 155 __MAKE_OP(64) 00b0c9b82663ac4 Al Viro 2017-12-14 156 #undef __MAKE_OP 00b0c9b82663ac4 Al Viro 2017-12-14 157 #undef ____MAKE_OP 00b0c9b82663ac4 Al Viro 2017-12-14 158 :::::: The code at line 119 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: 38893 bytes --]
next reply other threads:[~2020-11-15 19:58 UTC|newest] Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-11-15 19:58 kernel test robot [this message] 2020-11-15 19:58 ` [linux-next:master 4911/5794] include/linux/bitfield.h:119:3: error: call to '__bad_mask' declared with attribute error: bad bitfield mask kernel test robot 2020-11-16 9:08 ` [PATCH RFC] pwm: keembay: Fix build failure with -Os Uwe Kleine-König 2020-11-16 9:08 ` Uwe Kleine-König 2020-11-17 17:29 ` Ayyathurai, Vijayakannan 2020-11-17 17:29 ` Ayyathurai, Vijayakannan 2020-11-18 9:48 ` Uwe Kleine-König 2020-11-18 9:48 ` Uwe Kleine-König 2020-11-18 10:06 ` Uwe Kleine-König 2020-11-18 10:06 ` Uwe Kleine-König 2020-11-18 17:41 ` Ayyathurai, Vijayakannan 2020-11-18 17:41 ` Ayyathurai, Vijayakannan 2020-11-18 18:01 ` Thierry Reding 2020-11-18 18:01 ` Thierry Reding 2020-11-18 18:00 ` Thierry Reding 2020-11-18 18:00 ` Thierry Reding
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=202011160303.qi5aRChY-lkp@intel.com \ --to=lkp@intel.com \ --cc=andriy.shevchenko@linux.intel.com \ --cc=kbuild-all@lists.01.org \ --cc=linux-mm@kvack.org \ --cc=poey.seng.lai@intel.com \ --cc=thierry.reding@gmail.com \ --cc=u.kleine-koenig@pengutronix.de \ --cc=vijayakannan.ayyathurai@intel.com \ --cc=vineetha.g.jaya.kumaran@intel.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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.