# git rev-parse -q --verify 7e8cecfabd0072e81869ab9415fac7e2c2d97d57^{commit} 7e8cecfabd0072e81869ab9415fac7e2c2d97d57 already have revision, skipping fetch # git checkout -q -f -B kisskb 7e8cecfabd0072e81869ab9415fac7e2c2d97d57 # git clean -qxdf # < git log -1 # commit 7e8cecfabd0072e81869ab9415fac7e2c2d97d57 # Author: Michael Ellerman # Date: Mon May 2 18:14:01 2022 +1000 # # powerpc/vdso: Fix incorrect CFI in gettimeofday.S # # As reported by Alan, the CFI (Call Frame Information) in the VDSO time # routines is incorrect since commit ce7d8056e38b ("powerpc/vdso: Prepare # for switching VDSO to generic C implementation."). # # In particular the changes to the frame address register (r1) are not # properly described, which prevents gdb from being able to generate a # backtrace from inside VDSO functions, eg: # # Breakpoint 1, 0x00007ffff7f804dc in __kernel_clock_gettime () # (gdb) bt # #0 0x00007ffff7f804dc in __kernel_clock_gettime () # #1 0x00007ffff7d8872c in clock_gettime@@GLIBC_2.17 () from /lib64/libc.so.6 # #2 0x00007fffffffd960 in ?? () # #3 0x00007ffff7d8872c in clock_gettime@@GLIBC_2.17 () from /lib64/libc.so.6 # Backtrace stopped: frame did not save the PC # # Alan helpfully describes some rules for correctly maintaining the CFI information: # # 1) Every adjustment to the current frame address reg (ie. r1) must be # described, and exactly at the instruction where r1 changes. Why? # Because stack unwinding might want to access previous frames. # 2) If a function changes LR or any non-volatile register, the save # location for those regs must be given. The cfi can be at any # instruction after the saves up to the point that the reg is # changed. (Exception: LR save should be described before a bl.) # 3) If asychronous unwind info is needed then restores of LR and # non-volatile regs must also be described. The cfi can be at any # instruction after the reg is restored up to the point where the # save location is (potentially) trashed. # # Fix the inability to backtrace by adding CFI directives describing the # changes to r1, ie. satisfying rule 1. # # Also change the information for LR to point to the copy saved on the # stack, not the value in r0 that will be overwritten by the function # call. # # Finally, add CFI directives describing the save/restore of r2. # # With the fix gdb can correctly back trace and navigate up and down the stack: # # Breakpoint 1, 0x00007ffff7f804dc in __kernel_clock_gettime () # (gdb) bt # #0 0x00007ffff7f804dc in __kernel_clock_gettime () # #1 0x00007ffff7d8872c in clock_gettime@@GLIBC_2.17 () from /lib64/libc.so.6 # #2 0x0000000100015b60 in gettime () # #3 0x000000010000c8bc in print_long_format () # #4 0x000000010000d180 in print_current_files () # #5 0x00000001000054ac in main () # (gdb) up # #1 0x00007ffff7d8872c in clock_gettime@@GLIBC_2.17 () from /lib64/libc.so.6 # (gdb) # #2 0x0000000100015b60 in gettime () # (gdb) # #3 0x000000010000c8bc in print_long_format () # (gdb) # #4 0x000000010000d180 in print_current_files () # (gdb) # #5 0x00000001000054ac in main () # (gdb) # Initial frame selected; you cannot go up. # (gdb) down # #4 0x000000010000d180 in print_current_files () # (gdb) # #3 0x000000010000c8bc in print_long_format () # (gdb) # #2 0x0000000100015b60 in gettime () # (gdb) # #1 0x00007ffff7d8872c in clock_gettime@@GLIBC_2.17 () from /lib64/libc.so.6 # (gdb) # #0 0x00007ffff7f804dc in __kernel_clock_gettime () # (gdb) # # Fixes: ce7d8056e38b ("powerpc/vdso: Prepare for switching VDSO to generic C implementation.") # Cc: stable@vger.kernel.org # v5.11+ # Reported-by: Alan Modra # Signed-off-by: Michael Ellerman # < /opt/cross/kisskb/korg/gcc-9.4.0-nolibc/powerpc64-linux/bin/powerpc64-linux-gcc --version # < /opt/cross/kisskb/korg/gcc-9.4.0-nolibc/powerpc64-linux/bin/powerpc64-linux-ld --version # < git log --format=%s --max-count=1 7e8cecfabd0072e81869ab9415fac7e2c2d97d57 # < make -s -j 120 ARCH=powerpc O=/kisskb/build/powerpc-fixes_mpc85xx_defconfig+KVM_powerpc-gcc9 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-9.4.0-nolibc/powerpc64-linux/bin/powerpc64-linux- mpc85xx_defconfig # Added to kconfig CONFIG_PPC_E500MC=y # Added to kconfig CONFIG_VIRTUALIZATION=y # Added to kconfig CONFIG_KVM_E500MC=y # Added to kconfig # < make -s -j 120 ARCH=powerpc O=/kisskb/build/powerpc-fixes_mpc85xx_defconfig+KVM_powerpc-gcc9 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-9.4.0-nolibc/powerpc64-linux/bin/powerpc64-linux- help # make -s -j 120 ARCH=powerpc O=/kisskb/build/powerpc-fixes_mpc85xx_defconfig+KVM_powerpc-gcc9 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-9.4.0-nolibc/powerpc64-linux/bin/powerpc64-linux- olddefconfig .config:4336:warning: override: reassigning to symbol PPC_E500MC .config:4337:warning: override: reassigning to symbol VIRTUALIZATION # make -s -j 120 ARCH=powerpc O=/kisskb/build/powerpc-fixes_mpc85xx_defconfig+KVM_powerpc-gcc9 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-9.4.0-nolibc/powerpc64-linux/bin/powerpc64-linux- In file included from /kisskb/src/include/linux/bitops.h:33, from /kisskb/src/include/linux/kernel.h:22, from /kisskb/src/include/linux/cpumask.h:10, from /kisskb/src/include/linux/smp.h:13, from /kisskb/src/include/linux/lockdep.h:14, from /kisskb/src/include/linux/mutex.h:17, from /kisskb/src/arch/powerpc/include/asm/kvm_ppc.h:15, from /kisskb/src/arch/powerpc/kvm/e500_emulate.c:12: /kisskb/src/arch/powerpc/include/asm/bitops.h: In function 'kvmppc_core_emulate_op_e500': /kisskb/src/arch/powerpc/include/asm/bitops.h:104:3: error: asm operand 2 probably doesn't match constraints [-Werror] 104 | asm volatile ( \ | ^~~ /kisskb/src/arch/powerpc/include/asm/bitops.h:126:1: note: in expansion of macro 'DEFINE_CLROP' 126 | DEFINE_CLROP(clear_bits, "") | ^~~~~~~~~~~~ /kisskb/src/arch/powerpc/include/asm/bitops.h:104:3: error: impossible constraint in 'asm' 104 | asm volatile ( \ | ^~~ /kisskb/src/arch/powerpc/include/asm/bitops.h:126:1: note: in expansion of macro 'DEFINE_CLROP' 126 | DEFINE_CLROP(clear_bits, "") | ^~~~~~~~~~~~ cc1: all warnings being treated as errors make[3]: *** [/kisskb/src/scripts/Makefile.build:288: arch/powerpc/kvm/e500_emulate.o] Error 1 make[3]: *** Waiting for unfinished jobs.... make[2]: *** [/kisskb/src/scripts/Makefile.build:550: arch/powerpc/kvm] Error 2 make[2]: *** Waiting for unfinished jobs.... make[1]: *** [/kisskb/src/Makefile:1834: arch/powerpc] Error 2 make[1]: *** Waiting for unfinished jobs.... In file included from /kisskb/src/include/linux/build_bug.h:5, from /kisskb/src/include/linux/container_of.h:5, from /kisskb/src/include/linux/list.h:5, from /kisskb/src/include/linux/module.h:12, from /kisskb/src/drivers/net/ethernet/freescale/fs_enet/mac-scc.c:15: /kisskb/src/drivers/net/ethernet/freescale/fs_enet/mac-scc.c: In function 'allocate_bd': /kisskb/src/include/linux/err.h:22:49: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] 22 | #define IS_ERR_VALUE(x) unlikely((unsigned long)(void *)(x) >= (unsigned long)-MAX_ERRNO) | ^ /kisskb/src/include/linux/compiler.h:78:42: note: in definition of macro 'unlikely' 78 | # define unlikely(x) __builtin_expect(!!(x), 0) | ^ /kisskb/src/drivers/net/ethernet/freescale/fs_enet/mac-scc.c:139:6: note: in expansion of macro 'IS_ERR_VALUE' 139 | if (IS_ERR_VALUE(fep->ring_mem_addr)) | ^~~~~~~~~~~~ make: *** [Makefile:219: __sub-make] Error 2 Command 'make -s -j 120 ARCH=powerpc O=/kisskb/build/powerpc-fixes_mpc85xx_defconfig+KVM_powerpc-gcc9 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-9.4.0-nolibc/powerpc64-linux/bin/powerpc64-linux- ' returned non-zero exit status 2 # rm -rf /kisskb/build/powerpc-fixes_mpc85xx_defconfig+KVM_powerpc-gcc9 # Build took: 0:00:45.818078