# git rev-parse -q --verify 4ea6e7299deb821cd410d8efb8ad86de9f867251^{commit} 4ea6e7299deb821cd410d8efb8ad86de9f867251 already have revision, skipping fetch # git checkout -q -f -B kisskb 4ea6e7299deb821cd410d8efb8ad86de9f867251 # git clean -qxdf # < git log -1 # commit 4ea6e7299deb821cd410d8efb8ad86de9f867251 # Author: Ravi Bangoria # Date: Thu Jun 13 09:00:14 2019 +0530 # # powerpc/watchpoint: Restore NV GPRs while returning from exception # # powerpc hardware triggers watchpoint before executing the instruction. # To make trigger-after-execute behavior, kernel emulates the # instruction. If the instruction is 'load something into non-volatile # register', exception handler should restore emulated register state # while returning back, otherwise there will be register state # corruption. eg, adding a watchpoint on a list can corrput the list: # # # cat /proc/kallsyms | grep kthread_create_list # c00000000121c8b8 d kthread_create_list # # Add watchpoint on kthread_create_list->prev: # # # perf record -e mem:0xc00000000121c8c0 # # Run some workload such that new kthread gets invoked. eg, I just # logged out from console: # # list_add corruption. next->prev should be prev (c000000001214e00), \ # but was c00000000121c8b8. (next=c00000000121c8b8). # WARNING: CPU: 59 PID: 309 at lib/list_debug.c:25 __list_add_valid+0xb4/0xc0 # CPU: 59 PID: 309 Comm: kworker/59:0 Kdump: loaded Not tainted 5.1.0-rc7+ #69 # ... # NIP __list_add_valid+0xb4/0xc0 # LR __list_add_valid+0xb0/0xc0 # Call Trace: # __list_add_valid+0xb0/0xc0 (unreliable) # __kthread_create_on_node+0xe0/0x260 # kthread_create_on_node+0x34/0x50 # create_worker+0xe8/0x260 # worker_thread+0x444/0x560 # kthread+0x160/0x1a0 # ret_from_kernel_thread+0x5c/0x70 # # List corruption happened because it uses 'load into non-volatile # register' instruction: # # Snippet from __kthread_create_on_node: # # c000000000136be8: addis r29,r2,-19 # c000000000136bec: ld r29,31424(r29) # if (!__list_add_valid(new, prev, next)) # c000000000136bf0: mr r3,r30 # c000000000136bf4: mr r5,r28 # c000000000136bf8: mr r4,r29 # c000000000136bfc: bl c00000000059a2f8 <__list_add_valid+0x8> # # Register state from WARN_ON(): # # GPR00: c00000000059a3a0 c000007ff23afb50 c000000001344e00 0000000000000075 # GPR04: 0000000000000000 0000000000000000 0000001852af8bc1 0000000000000000 # GPR08: 0000000000000001 0000000000000007 0000000000000006 00000000000004aa # GPR12: 0000000000000000 c000007ffffeb080 c000000000137038 c000005ff62aaa00 # GPR16: 0000000000000000 0000000000000000 c000007fffbe7600 c000007fffbe7370 # GPR20: c000007fffbe7320 c000007fffbe7300 c000000001373a00 0000000000000000 # GPR24: fffffffffffffef7 c00000000012e320 c000007ff23afcb0 c000000000cb8628 # GPR28: c00000000121c8b8 c000000001214e00 c000007fef5b17e8 c000007fef5b17c0 # # Watchpoint hit at 0xc000000000136bec. # # addis r29,r2,-19 # => r29 = 0xc000000001344e00 + (-19 << 16) # => r29 = 0xc000000001214e00 # # ld r29,31424(r29) # => r29 = *(0xc000000001214e00 + 31424) # => r29 = *(0xc00000000121c8c0) # # 0xc00000000121c8c0 is where we placed a watchpoint and thus this # instruction was emulated by emulate_step. But because handle_dabr_fault # did not restore emulated register state, r29 still contains stale # value in above register state. # # Fixes: 5aae8a5370802 ("powerpc, hw_breakpoints: Implement hw_breakpoints for 64-bit server processors") # Signed-off-by: Ravi Bangoria # Cc: stable@vger.kernel.org # 2.6.36+ # Signed-off-by: Michael Ellerman # < /opt/cross/kisskb/gcc-4.6.3-nolibc/powerpc-linux/bin/powerpc-linux-gcc --version # < /opt/cross/kisskb/gcc-4.6.3-nolibc/powerpc-linux/bin/powerpc-linux-ld --version # < git log --format=%s --max-count=1 4ea6e7299deb821cd410d8efb8ad86de9f867251 # < make -s -j 24 ARCH=powerpc O=/kisskb/build/powerpc-next-rand_powerpc-randconfig_powerpc-gcc4.6 CROSS_COMPILE=/opt/cross/kisskb/gcc-4.6.3-nolibc/powerpc-linux/bin/powerpc-linux- randconfig KCONFIG_SEED=0x56C46268 # Added to kconfig CONFIG_STANDALONE=y # Added to kconfig CONFIG_BUILD_DOCSRC=n # Added to kconfig CONFIG_MODULE_SIG=n # Added to kconfig CONFIG_CPU_BIG_ENDIAN=y # Added to kconfig CONFIG_PPC64=y # Added to kconfig CONFIG_PPC_DISABLE_WERROR=y # Added to kconfig CONFIG_SECTION_MISMATCH_WARN_ONLY=y # Added to kconfig CONFIG_PREVENT_FIRMWARE_BUILD=y # Added to kconfig CONFIG_CC_STACKPROTECTOR_STRONG=n # Added to kconfig CONFIG_GCC_PLUGINS=n # Added to kconfig CONFIG_LD_HEAD_STUB_CATCH=y # Added to kconfig CONFIG_TRIM_UNUSED_KSYMS=n # yes \n | make -s -j 24 ARCH=powerpc O=/kisskb/build/powerpc-next-rand_powerpc-randconfig_powerpc-gcc4.6 CROSS_COMPILE=/opt/cross/kisskb/gcc-4.6.3-nolibc/powerpc-linux/bin/powerpc-linux- oldconfig yes: standard output: Broken pipe # make -s -j 24 ARCH=powerpc O=/kisskb/build/powerpc-next-rand_powerpc-randconfig_powerpc-gcc4.6 CROSS_COMPILE=/opt/cross/kisskb/gcc-4.6.3-nolibc/powerpc-linux/bin/powerpc-linux- /kisskb/src/kernel/printk/printk.c: In function 'devkmsg_sysctl_set_loglvl': /kisskb/src/kernel/printk/printk.c:194:16: warning: 'old' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/lib/mpi/mpicoder.c: In function 'mpi_read_raw_from_sgl': /kisskb/src/lib/mpi/mpicoder.c:352:8: warning: 'buff' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/mm/vmalloc.c: In function 'alloc_vmap_area.isra.30': /kisskb/src/mm/vmalloc.c:976:28: warning: 'lva' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/mm/vmalloc.c:916:20: note: 'lva' was declared here /kisskb/src/mm/vmalloc.c: In function 'pcpu_get_vm_areas': /kisskb/src/mm/vmalloc.c:976:28: warning: 'lva' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/mm/vmalloc.c:916:20: note: 'lva' was declared here /kisskb/src/mm/ksm.c: In function 'stable_node_dup': /kisskb/src/mm/ksm.c:1410:15: warning: 'found_rmap_hlist_len' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/lib/rhashtable.c: In function 'rhashtable_rehash_one': /kisskb/src/include/linux/rhashtable.h:110:10: warning: 'next' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/lib/rhashtable.c:225:28: note: 'next' was declared here /kisskb/src/fs/f2fs/node.c: In function '__set_nat_cache_dirty': /kisskb/src/include/linux/list.h:63:13: warning: 'head' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/fs/f2fs/node.c:237:24: note: 'head' was declared here /kisskb/src/net/core/gen_stats.c: In function '__gnet_stats_copy_basic': /kisskb/src/include/linux/seqlock.h:205:9: warning: 'seq' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/net/core/gen_stats.c:150:15: note: 'seq' was declared here /kisskb/src/drivers/hwtracing/intel_th/msu.c: In function 'msc_buffer_win_alloc': /kisskb/src/drivers/hwtracing/intel_th/msu.c:783:21: warning: unused variable 'i' [-Wunused-variable] /kisskb/src/drivers/hwtracing/intel_th/msu.c: In function 'msc_buffer_win_free': /kisskb/src/drivers/hwtracing/intel_th/msu.c:863:6: warning: unused variable 'i' [-Wunused-variable] /kisskb/src/fs/proc/inode.c: In function 'proc_reg_open': /kisskb/src/include/linux/list.h:65:12: warning: 'pdeo' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/fs/proc/inode.c:331:21: note: 'pdeo' was declared here /kisskb/src/net/core/dev.c: In function 'validate_xmit_skb_list': /kisskb/src/net/core/dev.c:3419:15: warning: 'tail' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/drivers/i2c/busses/i2c-sh_mobile.c: In function 'sh_mobile_i2c_isr_rx': /kisskb/src/drivers/i2c/busses/i2c-sh_mobile.c:399:26: warning: 'data' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/fs/ocfs2/alloc.c: In function 'ocfs2_trim_mainbm': /kisskb/src/fs/ocfs2/alloc.c:7604:17: warning: 'first_bit' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/fs/splice.c: In function '__do_compat_sys_vmsplice': /kisskb/src/fs/splice.c:1394:29: warning: 'type' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/fs/splice.c: In function '__do_sys_vmsplice': /kisskb/src/fs/splice.c:1368:22: warning: 'type' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/drivers/nvme/target/io-cmd-bdev.c: In function 'nvmet_bdev_execute_discard': /kisskb/src/drivers/nvme/target/io-cmd-bdev.c:232:21: warning: 'status' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/drivers/mtd/ubi/eba.c: In function 'try_write_vid_and_data': /kisskb/src/drivers/mtd/ubi/eba.c:1001:7: warning: 'opnum' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/drivers/tty/serial/8250/8250_core.c: In function 'serial_unlink_irq_chain': /kisskb/src/drivers/tty/serial/8250/8250_core.c:242:2: warning: 'i' may be used uninitialized in this function [-Wuninitialized] In file included from /kisskb/src/drivers/rtc/rtc-da9052.c:21:0: /kisskb/src/include/linux/mfd/da9052/da9052.h: In function 'da9052_group_read': /kisskb/src/include/linux/mfd/da9052/da9052.h:143:6: warning: 'ret' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/drivers/vhost/vhost.c: In function 'vhost_vq_avail_empty': /kisskb/src/drivers/vhost/vhost.c:2405:32: warning: 'avail_idx' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/drivers/vhost/vhost.c: In function 'vhost_get_vq_desc': /kisskb/src/drivers/vhost/vhost.c:2136:23: warning: 'ring_head' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/drivers/vhost/vhost.c:2106:33: warning: 'avail_idx' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/drivers/usb/serial/f81534.c: In function 'f81534_set_register': /kisskb/src/drivers/usb/serial/f81534.c:247:3: warning: 'status' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/drivers/usb/serial/f81534.c: In function 'f81534_get_register': /kisskb/src/drivers/usb/serial/f81534.c:286:3: warning: 'status' may be used uninitialized in this function [-Wuninitialized] WARNING: vmlinux.o(.text.unlikely+0x47c): Section mismatch in reference from the function .populate_initrd_image() to the function .init.text:.unpack_to_rootfs() The function .populate_initrd_image() references the function __init .unpack_to_rootfs(). This is often because .populate_initrd_image lacks a __init annotation or the annotation of .unpack_to_rootfs is wrong. WARNING: vmlinux.o(.text.unlikely+0x4e0): Section mismatch in reference from the function .populate_initrd_image() to the function .init.text:.xwrite() The function .populate_initrd_image() references the function __init .xwrite(). This is often because .populate_initrd_image lacks a __init annotation or the annotation of .xwrite is wrong. Inconsistent kallsyms data Try make KALLSYMS_EXTRA_PASS=1 as a workaround make[1]: *** [/kisskb/src/Makefile:1052: vmlinux] Error 1 make: *** [Makefile:179: sub-make] Error 2 Command 'make -s -j 24 ARCH=powerpc O=/kisskb/build/powerpc-next-rand_powerpc-randconfig_powerpc-gcc4.6 CROSS_COMPILE=/opt/cross/kisskb/gcc-4.6.3-nolibc/powerpc-linux/bin/powerpc-linux- ' returned non-zero exit status 2 # rm -rf /kisskb/build/powerpc-next-rand_powerpc-randconfig_powerpc-gcc4.6 # Build took: 0:03:25.970151