# git rev-parse -q --verify 1c27f1fc1549f0e470429f5497a76ad28a37f21a^{commit} 1c27f1fc1549f0e470429f5497a76ad28a37f21a already have revision, skipping fetch # git checkout -q -f -B kisskb 1c27f1fc1549f0e470429f5497a76ad28a37f21a # git clean -qxdf # < git log -1 # commit 1c27f1fc1549f0e470429f5497a76ad28a37f21a # Author: Linus Torvalds # Date: Sat Jun 11 10:30:20 2022 -0700 # # iov_iter: fix build issue due to possible type mis-match # # Commit 6c77676645ad ("iov_iter: Fix iter_xarray_get_pages{,_alloc}()") # introduced a problem on some 32-bit architectures (at least arm, xtensa, # csky,sparc and mips), that have a 'size_t' that is 'unsigned int'. # # The reason is that we now do # # min(nr * PAGE_SIZE - offset, maxsize); # # where 'nr' and 'offset' and both 'unsigned int', and PAGE_SIZE is # 'unsigned long'. As a result, the normal C type rules means that the # first argument to 'min()' ends up being 'unsigned long'. # # In contrast, 'maxsize' is of type 'size_t'. # # Now, 'size_t' and 'unsigned long' are always the same physical type in # the kernel, so you'd think this doesn't matter, and from an actual # arithmetic standpoint it doesn't. # # But on 32-bit architectures 'size_t' is commonly 'unsigned int', even if # it could also be 'unsigned long'. In that situation, both are unsigned # 32-bit types, but they are not the *same* type. # # And as a result 'min()' will complain about the distinct types (ignore # the "pointer types" part of the error message: that's an artifact of the # way we have made 'min()' check types for being the same): # # lib/iov_iter.c: In function 'iter_xarray_get_pages': # include/linux/minmax.h:20:35: error: comparison of distinct pointer types lacks a cast [-Werror] # 20 | (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1))) # | ^~ # lib/iov_iter.c:1464:16: note: in expansion of macro 'min' # 1464 | return min(nr * PAGE_SIZE - offset, maxsize); # | ^~~ # # This was not visible on 64-bit architectures (where we always define # 'size_t' to be 'unsigned long'). # # Force these cases to use 'min_t(size_t, x, y)' to make the type explicit # and avoid the issue. # # [ Nit-picky note: technically 'size_t' doesn't have to match 'unsigned # long' arithmetically. We've certainly historically seen environments # with 16-bit address spaces and 32-bit 'unsigned long'. # # Similarly, even in 64-bit modern environments, 'size_t' could be its # own type distinct from 'unsigned long', even if it were arithmetically # identical. # # So the above type commentary is only really descriptive of the kernel # environment, not some kind of universal truth for the kinds of wild # and crazy situations that are allowed by the C standard ] # # Reported-by: Sudip Mukherjee # Link: https://lore.kernel.org/all/YqRyL2sIqQNDfky2@debian/ # Cc: Jeff Layton # Cc: David Howells # Cc: Al Viro # Signed-off-by: Linus Torvalds # < /opt/cross/kisskb/korg/gcc-11.1.0-nolibc/sh4-linux/bin/sh4-linux-gcc --version # < /opt/cross/kisskb/korg/gcc-11.1.0-nolibc/sh4-linux/bin/sh4-linux-ld --version # < git log --format=%s --max-count=1 1c27f1fc1549f0e470429f5497a76ad28a37f21a # < make -s -j 120 ARCH=sh O=/kisskb/build/linus_sh-allnoconfig_sh4-gcc11 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-11.1.0-nolibc/sh4-linux/bin/sh4-linux- allnoconfig # < make -s -j 120 ARCH=sh O=/kisskb/build/linus_sh-allnoconfig_sh4-gcc11 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-11.1.0-nolibc/sh4-linux/bin/sh4-linux- help # make -s -j 120 ARCH=sh O=/kisskb/build/linus_sh-allnoconfig_sh4-gcc11 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-11.1.0-nolibc/sh4-linux/bin/sh4-linux- olddefconfig # make -s -j 120 ARCH=sh O=/kisskb/build/linus_sh-allnoconfig_sh4-gcc11 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-11.1.0-nolibc/sh4-linux/bin/sh4-linux- Generating include/generated/machtypes.h :1517:2: warning: #warning syscall clone3 not implemented [-Wcpp] /kisskb/src/arch/sh/kernel/machvec.c: In function 'sh_mv_setup': /kisskb/src/arch/sh/kernel/machvec.c:105:33: warning: array subscript 'struct sh_machine_vector[0]' is partly outside array bounds of 'long int[1]' [-Warray-bounds] 105 | sh_mv = *(struct sh_machine_vector *)&__machvec_start; | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /kisskb/src/arch/sh/kernel/machvec.c:13: /kisskb/src/arch/sh/include/asm/sections.h:7:13: note: while referencing '__machvec_start' 7 | extern long __machvec_start, __machvec_end; | ^~~~~~~~~~~~~~~ In file included from /kisskb/src/arch/sh/include/asm/hw_irq.h:6, from /kisskb/src/include/linux/irq.h:594, from /kisskb/src/include/asm-generic/hardirq.h:17, from /kisskb/src/arch/sh/include/asm/hardirq.h:9, from /kisskb/src/include/linux/hardirq.h:11, from /kisskb/src/include/linux/interrupt.h:11, from /kisskb/src/include/linux/serial_core.h:13, from /kisskb/src/include/linux/serial_sci.h:6, from /kisskb/src/arch/sh/kernel/cpu/sh2/setup-sh7619.c:11: /kisskb/src/include/linux/sh_intc.h:100:63: warning: division 'sizeof (void *) / sizeof (void)' does not compute the number of array elements [-Wsizeof-pointer-div] 100 | #define _INTC_ARRAY(a) a, __same_type(a, NULL) ? 0 : sizeof(a)/sizeof(*a) | ^ /kisskb/src/include/linux/sh_intc.h:105:31: note: in expansion of macro '_INTC_ARRAY' 105 | _INTC_ARRAY(vectors), _INTC_ARRAY(groups), \ | ^~~~~~~~~~~ /kisskb/src/include/linux/sh_intc.h:124:15: note: in expansion of macro 'INTC_HW_DESC' 124 | .hw = INTC_HW_DESC(vectors, groups, mask_regs, \ | ^~~~~~~~~~~~ /kisskb/src/arch/sh/kernel/cpu/sh2/setup-sh7619.c:58:8: note: in expansion of macro 'DECLARE_INTC_DESC' 58 | static DECLARE_INTC_DESC(intc_desc, "sh7619", vectors, NULL, | ^~~~~~~~~~~~~~~~~ /kisskb/src/include/linux/sh_intc.h:100:63: warning: division 'sizeof (void *) / sizeof (void)' does not compute the number of array elements [-Wsizeof-pointer-div] 100 | #define _INTC_ARRAY(a) a, __same_type(a, NULL) ? 0 : sizeof(a)/sizeof(*a) | ^ /kisskb/src/include/linux/sh_intc.h:106:9: note: in expansion of macro '_INTC_ARRAY' 106 | _INTC_ARRAY(mask_regs), _INTC_ARRAY(prio_regs), \ | ^~~~~~~~~~~ /kisskb/src/include/linux/sh_intc.h:124:15: note: in expansion of macro 'INTC_HW_DESC' 124 | .hw = INTC_HW_DESC(vectors, groups, mask_regs, \ | ^~~~~~~~~~~~ /kisskb/src/arch/sh/kernel/cpu/sh2/setup-sh7619.c:58:8: note: in expansion of macro 'DECLARE_INTC_DESC' 58 | static DECLARE_INTC_DESC(intc_desc, "sh7619", vectors, NULL, | ^~~~~~~~~~~~~~~~~ /kisskb/src/include/linux/sh_intc.h:100:63: warning: division 'sizeof (void *) / sizeof (void)' does not compute the number of array elements [-Wsizeof-pointer-div] 100 | #define _INTC_ARRAY(a) a, __same_type(a, NULL) ? 0 : sizeof(a)/sizeof(*a) | ^ /kisskb/src/include/linux/sh_intc.h:107:9: note: in expansion of macro '_INTC_ARRAY' 107 | _INTC_ARRAY(sense_regs), _INTC_ARRAY(ack_regs), \ | ^~~~~~~~~~~ /kisskb/src/include/linux/sh_intc.h:124:15: note: in expansion of macro 'INTC_HW_DESC' 124 | .hw = INTC_HW_DESC(vectors, groups, mask_regs, \ | ^~~~~~~~~~~~ /kisskb/src/arch/sh/kernel/cpu/sh2/setup-sh7619.c:58:8: note: in expansion of macro 'DECLARE_INTC_DESC' 58 | static DECLARE_INTC_DESC(intc_desc, "sh7619", vectors, NULL, | ^~~~~~~~~~~~~~~~~ /kisskb/src/include/linux/sh_intc.h:100:63: warning: division 'sizeof (void *) / sizeof (void)' does not compute the number of array elements [-Wsizeof-pointer-div] 100 | #define _INTC_ARRAY(a) a, __same_type(a, NULL) ? 0 : sizeof(a)/sizeof(*a) | ^ /kisskb/src/include/linux/sh_intc.h:107:34: note: in expansion of macro '_INTC_ARRAY' 107 | _INTC_ARRAY(sense_regs), _INTC_ARRAY(ack_regs), \ | ^~~~~~~~~~~ /kisskb/src/include/linux/sh_intc.h:124:15: note: in expansion of macro 'INTC_HW_DESC' 124 | .hw = INTC_HW_DESC(vectors, groups, mask_regs, \ | ^~~~~~~~~~~~ /kisskb/src/arch/sh/kernel/cpu/sh2/setup-sh7619.c:58:8: note: in expansion of macro 'DECLARE_INTC_DESC' 58 | static DECLARE_INTC_DESC(intc_desc, "sh7619", vectors, NULL, | ^~~~~~~~~~~~~~~~~ Kernel: arch/sh/boot/zImage is ready Completed OK # rm -rf /kisskb/build/linus_sh-allnoconfig_sh4-gcc11 # Build took: 0:00:17.134505