[PATCH 1/1] rseq/selftests: add __rseq_abi misalignment check
The kernel rseq syscall expects that struct rseq is 32 bytes aligned and returns EINVAL otherwise. Even though __rseq_abi is declared as static and proper aligned attribute is present __rseq_abi is a part of thread local storage. It turns out that on some platforms TLS itself is not properly aligned (at least for threads created), which is a glibc nptl bug and should be eventually fixed and backported. But in a meanwhile add __rseq_abi misalignment check, which would detect this situation and skip rseq test with some user friendly message. glibc bug: https://sourceware.org/bugzilla/show_bug.cgi?id=23403 Signed-off-by: Vasily Gorbik --- tools/testing/selftests/rseq/rseq.c | 19 +++ .../testing/selftests/rseq/run_param_test.sh | 4 ++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/rseq/rseq.c b/tools/testing/selftests/rseq/rseq.c index 4847e97ed049..50b13318395a 100644 --- a/tools/testing/selftests/rseq/rseq.c +++ b/tools/testing/selftests/rseq/rseq.c @@ -64,6 +64,23 @@ static int sys_rseq(volatile struct rseq *rseq_abi, uint32_t rseq_len, return syscall(__NR_rseq, rseq_abi, rseq_len, flags, sig); } +/* + * rseq syscall might fail on some platforms due to wrong alignment of TLS + * variables: + * https://sourceware.org/bugzilla/show_bug.cgi?id=23403 + * + * check if glibc bug is present and skip the test in this case + */ +static void assert_rseq_abi_aligned() +{ + if ((unsigned long)&__rseq_abi & (__alignof__(__rseq_abi) - 1)) { + fputs("__rseq_abi is not properly aligned, which is a known \n" + "glibc nptl bug (https://sourceware.org/bugzilla/show_bug.cgi?id=23403).\n" + "You need a fixed version of glibc to run this test.\n", stderr); + exit(4); /* skip this test */ + } +} + int rseq_register_current_thread(void) { int rc, ret = 0; @@ -72,6 +89,7 @@ int rseq_register_current_thread(void) signal_off_save(&oldset); if (refcount++) goto end; + assert_rseq_abi_aligned(); rc = sys_rseq(&__rseq_abi, sizeof(struct rseq), 0, RSEQ_SIG); if (!rc) { assert(rseq_current_cpu_raw() >= 0); @@ -94,6 +112,7 @@ int rseq_unregister_current_thread(void) signal_off_save(&oldset); if (--refcount) goto end; + assert_rseq_abi_aligned(); rc = sys_rseq(&__rseq_abi, sizeof(struct rseq), RSEQ_FLAG_UNREGISTER, RSEQ_SIG); if (!rc) diff --git a/tools/testing/selftests/rseq/run_param_test.sh b/tools/testing/selftests/rseq/run_param_test.sh index 3acd6d75ff9f..56caf5e3de3e 100755 --- a/tools/testing/selftests/rseq/run_param_test.sh +++ b/tools/testing/selftests/rseq/run_param_test.sh @@ -34,9 +34,9 @@ function do_tests() local i=0 while [ "$i" -lt "${#TEST_LIST[@]}" ]; do echo "Running test ${TEST_NAME[$i]}" - ./param_test ${TEST_LIST[$i]} -r ${REPS} ${@} ${EXTRA_ARGS} || exit 1 + ./param_test ${TEST_LIST[$i]} -r ${REPS} ${@} ${EXTRA_ARGS} || exit $? echo "Running compare-twice test ${TEST_NAME[$i]}" - ./param_test_compare_twice ${TEST_LIST[$i]} -r ${REPS} ${@} ${EXTRA_ARGS} || exit 1 + ./param_test_compare_twice ${TEST_LIST[$i]} -r ${REPS} ${@} ${EXTRA_ARGS} || exit $? let "i++" done } -- 2.18.0.13.gd42ae10
[PATCH 0/1] rseq/selftests: add __rseq_abi misalignment check
While implementing rseq selftest for s390 a glibc problem with tls variables alignment has been discovered. It turned out to be a general problem affecting several architectures. The bug opened for this problem: https://sourceware.org/bugzilla/show_bug.cgi?id=23403 There is no fix yet. On s390 __rseq_abi ends up aligned to 0x10 instead of 0x20 which makes rseq selftest fail every time. The change proposed adds __rseq_abi misalignment check, produces user friendly message and skips the test. Vasily Gorbik (1): rseq/selftests: add __rseq_abi misalignment check tools/testing/selftests/rseq/rseq.c | 19 +++ .../testing/selftests/rseq/run_param_test.sh | 4 ++-- 2 files changed, 21 insertions(+), 2 deletions(-) -- 2.18.0.13.gd42ae10
[PATCH 0/4] ftrace build improvements
Support for -fentry -mrecord-mcount and -mnop-mcount has been added for s390 in gcc master branch. An attempt to build 4.18 for s390 with that gcc would produce a kernel with no __mcount_loc though because of the new condition in scripts/Makefile.build:210 which disables recordmcount tool if compiler supports -mrecord-mcount (s390 relies on combination of -mhotpatch=0,3 gcc flag and recordmcount.pl). This patch series adds s390 ftrace support based on combination of -pg -fentry -mrecord-mcount and -mnop-mcount gcc flags (that fixes issue mentioned above). At the same time this patch series fixes couple of minor issues and adds -mnop-mcount gcc flag support (utilized by s390). Vasily Gorbik (4): trace: handle CC_FLAGS_FTRACE more accurately trace: avoid calling cc-option -mrecord-mcount for every Makefile trace: add -mcount-nop option support s390/ftrace: add -mfentry and -mnop-mcount support Makefile | 24 arch/s390/Kconfig | 2 ++ arch/s390/Makefile | 16 +--- arch/s390/include/asm/ftrace.h | 6 +++--- arch/s390/kernel/ftrace.c | 2 +- arch/s390/kernel/mcount.S | 2 +- kernel/trace/Kconfig | 5 + kernel/trace/ftrace.c | 2 ++ scripts/Makefile.build | 9 +++-- 9 files changed, 46 insertions(+), 22 deletions(-) -- 2.18.0.13.gd42ae10
[PATCH 2/4] trace: avoid calling cc-option -mrecord-mcount for every Makefile
Currently if CONFIG_FTRACE_MCOUNT_RECORD is enabled -mrecord-mcount compiler flag support is tested for every Makefile. Top 4 cc-option usages: 511 -mrecord-mcount 11 -fno-stack-protector 9 -Wno-override-init 2 -fsched-pressure To address that move cc-option from scripts/Makefile.build to top Makefile and export CC_USING_RECORD_MCOUNT to be used in original place. While doing that also add -mrecord-mcount to CC_FLAGS_FTRACE (if gcc actually supports it). Signed-off-by: Vasily Gorbik --- Makefile | 7 +++ scripts/Makefile.build | 9 +++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 503f533277c7..621ebdbfbf89 100644 --- a/Makefile +++ b/Makefile @@ -743,6 +743,13 @@ ifdef CONFIG_FUNCTION_TRACER ifndef CC_FLAGS_FTRACE CC_FLAGS_FTRACE := -pg endif +ifdef CONFIG_FTRACE_MCOUNT_RECORD + # gcc 5 supports generating the mcount tables directly + ifeq ($(call cc-option-yn,-mrecord-mcount),y) +CC_FLAGS_FTRACE+= -mrecord-mcount +export CC_USING_RECORD_MCOUNT := 1 + endif +endif ifdef CONFIG_HAVE_FENTRY ifeq ($(call cc-option-yn, -mfentry),y) CC_FLAGS_FTRACE+= -mfentry diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 514ed63ff571..42ecb8cf7666 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -206,11 +206,8 @@ cmd_modversions_c = \ endif ifdef CONFIG_FTRACE_MCOUNT_RECORD -# gcc 5 supports generating the mcount tables directly -ifneq ($(call cc-option,-mrecord-mcount,y),y) -KBUILD_CFLAGS += -mrecord-mcount -else -# else do it all manually +ifndef CC_USING_RECORD_MCOUNT +# compiler will not generate __mcount_loc use recordmcount or recordmcount.pl ifdef BUILD_C_RECORDMCOUNT ifeq ("$(origin RECORDMCOUNT_WARN)", "command line") RECORDMCOUNT_FLAGS = -w @@ -239,7 +236,7 @@ cmd_record_mcount = \ "$(CC_FLAGS_FTRACE)" ]; then \ $(sub_cmd_record_mcount)\ fi; -endif # -record-mcount +endif # CC_USING_RECORD_MCOUNT endif # CONFIG_FTRACE_MCOUNT_RECORD ifdef CONFIG_STACK_VALIDATION -- 2.18.0.13.gd42ae10
[PATCH 1/4] trace: handle CC_FLAGS_FTRACE more accurately
CC_FLAGS_FTRACE is exported and later used to remove ftrace relevant build flags from files which should be built without ftrace support. For that reason add -mfentry to CC_FLAGS_FTRACE as well. That fixes a problem with vdso32 build on s390, where -mfentry could not be used together with -m31 flag. At the same time flags like -pg and -mfentry are not relevant for asm files, so avoid adding them to KBUILD_AFLAGS. Introduce CC_FLAGS_USING instead of CC_USING_FENTRY to collect -DCC_USING_FENTRY (and future alike) which are relevant for both KBUILD_CFLAGS and KBUILD_AFLAGS. Signed-off-by: Vasily Gorbik --- Makefile | 11 +++ 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 7a3c4548162b..503f533277c7 100644 --- a/Makefile +++ b/Makefile @@ -743,12 +743,15 @@ ifdef CONFIG_FUNCTION_TRACER ifndef CC_FLAGS_FTRACE CC_FLAGS_FTRACE := -pg endif -export CC_FLAGS_FTRACE ifdef CONFIG_HAVE_FENTRY -CC_USING_FENTRY:= $(call cc-option, -mfentry -DCC_USING_FENTRY) + ifeq ($(call cc-option-yn, -mfentry),y) +CC_FLAGS_FTRACE+= -mfentry +CC_FLAGS_USING += -DCC_USING_FENTRY + endif endif -KBUILD_CFLAGS += $(CC_FLAGS_FTRACE) $(CC_USING_FENTRY) -KBUILD_AFLAGS += $(CC_USING_FENTRY) +export CC_FLAGS_FTRACE +KBUILD_CFLAGS += $(CC_FLAGS_FTRACE) $(CC_FLAGS_USING) +KBUILD_AFLAGS += $(CC_FLAGS_USING) ifdef CONFIG_DYNAMIC_FTRACE ifdef CONFIG_HAVE_C_RECORDMCOUNT BUILD_C_RECORDMCOUNT := y -- 2.18.0.13.gd42ae10
[PATCH 4/4] s390/ftrace: add -mfentry and -mnop-mcount support
Utilize -mfentry and -mnop-mcount gcc options together with -mrecord-mcount to get compiler generated calls to the profiling functions as nops which are compatible with current -mhotpatch=0,3 approach. At the same time -mrecord-mcount enables __mcount_loc section generation by the compiler which allows to avoid using scripts/recordmcount.pl script. Signed-off-by: Vasily Gorbik --- arch/s390/Kconfig | 2 ++ arch/s390/Makefile | 16 +--- arch/s390/include/asm/ftrace.h | 6 +++--- arch/s390/kernel/ftrace.c | 2 +- arch/s390/kernel/mcount.S | 2 +- 5 files changed, 16 insertions(+), 12 deletions(-) diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig index 8a1863d9ed53..71c2d9de379f 100644 --- a/arch/s390/Kconfig +++ b/arch/s390/Kconfig @@ -136,6 +136,7 @@ config S390 select HAVE_DYNAMIC_FTRACE select HAVE_DYNAMIC_FTRACE_WITH_REGS select HAVE_EFFICIENT_UNALIGNED_ACCESS + select HAVE_FENTRY select HAVE_FTRACE_MCOUNT_RECORD select HAVE_FUNCTION_GRAPH_TRACER select HAVE_FUNCTION_TRACER @@ -157,6 +158,7 @@ config S390 select HAVE_MEMBLOCK_NODE_MAP select HAVE_MEMBLOCK_PHYS_MAP select HAVE_MOD_ARCH_SPECIFIC + select HAVE_NOP_MCOUNT select HAVE_OPROFILE select HAVE_PERF_EVENTS select HAVE_REGS_AND_STACK_ACCESS_API diff --git a/arch/s390/Makefile b/arch/s390/Makefile index 68a690442be0..8498babb5dad 100644 --- a/arch/s390/Makefile +++ b/arch/s390/Makefile @@ -86,13 +86,15 @@ ifdef CONFIG_EXPOLINE endif ifdef CONFIG_FUNCTION_TRACER -# make use of hotpatch feature if the compiler supports it -cc_hotpatch:= -mhotpatch=0,3 -ifeq ($(call cc-option-yn,$(cc_hotpatch)),y) -CC_FLAGS_FTRACE := $(cc_hotpatch) -KBUILD_AFLAGS += -DCC_USING_HOTPATCH -KBUILD_CFLAGS += -DCC_USING_HOTPATCH -endif + ifeq ($(call cc-option-yn,-mfentry -mnop-mcount),n) +# make use of hotpatch feature if the compiler supports it +cc_hotpatch:= -mhotpatch=0,3 +ifeq ($(call cc-option-yn,$(cc_hotpatch)),y) + CC_FLAGS_FTRACE := $(cc_hotpatch) + KBUILD_AFLAGS+= -DCC_USING_HOTPATCH + KBUILD_CFLAGS+= -DCC_USING_HOTPATCH +endif + endif endif # Test CFI features of binutils diff --git a/arch/s390/include/asm/ftrace.h b/arch/s390/include/asm/ftrace.h index cfccc0edd00d..8ea270fdc7fb 100644 --- a/arch/s390/include/asm/ftrace.h +++ b/arch/s390/include/asm/ftrace.h @@ -4,7 +4,7 @@ #define ARCH_SUPPORTS_FTRACE_OPS 1 -#ifdef CC_USING_HOTPATCH +#if defined(CC_USING_HOTPATCH) || defined(CC_USING_NOP_MCOUNT) #define MCOUNT_INSN_SIZE 6 #else #define MCOUNT_INSN_SIZE 24 @@ -42,7 +42,7 @@ struct ftrace_insn { static inline void ftrace_generate_nop_insn(struct ftrace_insn *insn) { #ifdef CONFIG_FUNCTION_TRACER -#ifdef CC_USING_HOTPATCH +#if defined(CC_USING_HOTPATCH) || defined(CC_USING_NOP_MCOUNT) /* brcl 0,0 */ insn->opc = 0xc004; insn->disp = 0; @@ -57,7 +57,7 @@ static inline void ftrace_generate_nop_insn(struct ftrace_insn *insn) static inline int is_ftrace_nop(struct ftrace_insn *insn) { #ifdef CONFIG_FUNCTION_TRACER -#ifdef CC_USING_HOTPATCH +#if defined(CC_USING_HOTPATCH) || defined(CC_USING_NOP_MCOUNT) if (insn->disp == 0) return 1; #else diff --git a/arch/s390/kernel/ftrace.c b/arch/s390/kernel/ftrace.c index dc76d813e420..84be7f02d0c2 100644 --- a/arch/s390/kernel/ftrace.c +++ b/arch/s390/kernel/ftrace.c @@ -61,7 +61,7 @@ unsigned long ftrace_plt; static inline void ftrace_generate_orig_insn(struct ftrace_insn *insn) { -#ifdef CC_USING_HOTPATCH +#if defined(CC_USING_HOTPATCH) || defined(CC_USING_NOP_MCOUNT) /* brcl 0,0 */ insn->opc = 0xc004; insn->disp = 0; diff --git a/arch/s390/kernel/mcount.S b/arch/s390/kernel/mcount.S index 27110f3294ed..e93fbf02490c 100644 --- a/arch/s390/kernel/mcount.S +++ b/arch/s390/kernel/mcount.S @@ -35,7 +35,7 @@ ENTRY(ftrace_caller) .globl ftrace_regs_caller .setftrace_regs_caller,ftrace_caller lgr %r1,%r15 -#ifndef CC_USING_HOTPATCH +#if !(defined(CC_USING_HOTPATCH) || defined(CC_USING_NOP_MCOUNT)) aghi%r0,MCOUNT_RETURN_FIXUP #endif aghi%r15,-STACK_FRAME_SIZE -- 2.18.0.13.gd42ae10
[PATCH 3/4] trace: add -mcount-nop option support
-mcount-nop gcc option generates the calls to the profiling functions as nops which allows to avoid patching mcount jump with NOP instructions initially. -mcount-nop gcc option will be activated if platform selects HAVE_NOP_MCOUNT and gcc actually supports it. In addition to that CC_USING_NOP_MCOUNT is defined and could be used by architectures to adapt ftrace patching behavior. Signed-off-by: Vasily Gorbik --- Makefile | 6 ++ kernel/trace/Kconfig | 5 + kernel/trace/ftrace.c | 2 ++ 3 files changed, 13 insertions(+) diff --git a/Makefile b/Makefile index 621ebdbfbf89..281f4ededf3a 100644 --- a/Makefile +++ b/Makefile @@ -749,6 +749,12 @@ ifdef CONFIG_FTRACE_MCOUNT_RECORD CC_FLAGS_FTRACE+= -mrecord-mcount export CC_USING_RECORD_MCOUNT := 1 endif + ifdef CONFIG_HAVE_NOP_MCOUNT +ifeq ($(call cc-option-yn, -mnop-mcount),y) + CC_FLAGS_FTRACE += -mnop-mcount + CC_FLAGS_USING += -DCC_USING_NOP_MCOUNT +endif + endif endif ifdef CONFIG_HAVE_FENTRY ifeq ($(call cc-option-yn, -mfentry),y) diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig index dcc0166d1997..855109214e3d 100644 --- a/kernel/trace/Kconfig +++ b/kernel/trace/Kconfig @@ -47,6 +47,11 @@ config HAVE_FENTRY help Arch supports the gcc options -pg with -mfentry +config HAVE_NOP_MCOUNT + bool + help + Arch supports the gcc options -pg with -mrecord-mcount and -nop-mcount + config HAVE_C_RECORDMCOUNT bool help diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index caf9cbf35816..310dfcb20d5b 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -2981,12 +2981,14 @@ static int ftrace_update_code(struct module *mod, struct ftrace_page *new_pgs) p = &pg->records[i]; p->flags = rec_flags; +#ifndef CC_USING_NOP_MCOUNT /* * Do the initial record conversion from mcount jump * to the NOP instructions. */ if (!ftrace_code_disable(mod, p)) break; +#endif update_cnt++; } -- 2.18.0.13.gd42ae10
[PATCH v2 1/1] rseq/selftests: add __rseq_abi misalignment check
The kernel rseq syscall expects that struct rseq is 32 bytes aligned and returns EINVAL otherwise. Even though __rseq_abi is declared as static and proper aligned attribute is present __rseq_abi is a part of thread local storage. It turns out that on some platforms TLS itself is not properly aligned (at least for threads created), which is a glibc nptl bug and should be eventually fixed and backported. But in a meanwhile add __rseq_abi misalignment check, which would detect this situation and skip rseq test with some user friendly message. glibc bug: https://sourceware.org/bugzilla/show_bug.cgi?id=23403 Signed-off-by: Vasily Gorbik --- tools/testing/selftests/rseq/rseq.c | 20 +++ .../testing/selftests/rseq/run_param_test.sh | 4 ++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/rseq/rseq.c b/tools/testing/selftests/rseq/rseq.c index 4847e97ed049..3de7f0e7442e 100644 --- a/tools/testing/selftests/rseq/rseq.c +++ b/tools/testing/selftests/rseq/rseq.c @@ -64,6 +64,24 @@ static int sys_rseq(volatile struct rseq *rseq_abi, uint32_t rseq_len, return syscall(__NR_rseq, rseq_abi, rseq_len, flags, sig); } +/* + * rseq syscall might fail on some platforms due to wrong alignment of TLS + * variables: + * https://sourceware.org/bugzilla/show_bug.cgi?id=23403 + * + * check if glibc bug is present and skip the test in this case + */ +static void assert_rseq_abi_aligned(void) +{ + if ((unsigned long)&__rseq_abi & (__alignof__(__rseq_abi) - 1)) { + fputs("__rseq_abi is not properly aligned, which is a known\n" + "glibc nptl bug (https://sourceware.org/bugzilla/show_bug.cgi?id=23403).\n" + "You need a fixed version of glibc to run this test.\n", + stderr); + exit(4); /* skip this test */ + } +} + int rseq_register_current_thread(void) { int rc, ret = 0; @@ -72,6 +90,7 @@ int rseq_register_current_thread(void) signal_off_save(&oldset); if (refcount++) goto end; + assert_rseq_abi_aligned(); rc = sys_rseq(&__rseq_abi, sizeof(struct rseq), 0, RSEQ_SIG); if (!rc) { assert(rseq_current_cpu_raw() >= 0); @@ -94,6 +113,7 @@ int rseq_unregister_current_thread(void) signal_off_save(&oldset); if (--refcount) goto end; + assert_rseq_abi_aligned(); rc = sys_rseq(&__rseq_abi, sizeof(struct rseq), RSEQ_FLAG_UNREGISTER, RSEQ_SIG); if (!rc) diff --git a/tools/testing/selftests/rseq/run_param_test.sh b/tools/testing/selftests/rseq/run_param_test.sh index 3acd6d75ff9f..56caf5e3de3e 100755 --- a/tools/testing/selftests/rseq/run_param_test.sh +++ b/tools/testing/selftests/rseq/run_param_test.sh @@ -34,9 +34,9 @@ function do_tests() local i=0 while [ "$i" -lt "${#TEST_LIST[@]}" ]; do echo "Running test ${TEST_NAME[$i]}" - ./param_test ${TEST_LIST[$i]} -r ${REPS} ${@} ${EXTRA_ARGS} || exit 1 + ./param_test ${TEST_LIST[$i]} -r ${REPS} ${@} ${EXTRA_ARGS} || exit $? echo "Running compare-twice test ${TEST_NAME[$i]}" - ./param_test_compare_twice ${TEST_LIST[$i]} -r ${REPS} ${@} ${EXTRA_ARGS} || exit 1 + ./param_test_compare_twice ${TEST_LIST[$i]} -r ${REPS} ${@} ${EXTRA_ARGS} || exit $? let "i++" done } -- 2.18.0.13.gd42ae10
[PATCH] kbuild: add Map option to save vmlinux linker map file(s)
Add "Map" kbuild option, so that "make Map=1" would save vmlinux linker map into vmlinux.map, which is quite useful during making kernel changes related to how the kernel is composed. KBUILD_SAVE_LINK_MAP flag is exported and architectures supporting compressed kernel images might respect it and produce arch/*/boot/compressed/vmlinux.map for the decompressor code as well. Signed-off-by: Vasily Gorbik --- .gitignore | 1 + Makefile | 14 ++ 2 files changed, 15 insertions(+) diff --git a/.gitignore b/.gitignore index 97ba6b79834c..1d2308e597ad 100644 --- a/.gitignore +++ b/.gitignore @@ -44,6 +44,7 @@ *.xz Module.symvers modules.builtin +vmlinux.map # # Top-level generic files diff --git a/Makefile b/Makefile index 7a3c4548162b..f1790deae03b 100644 --- a/Makefile +++ b/Makefile @@ -176,6 +176,14 @@ ifndef KBUILD_CHECKSRC KBUILD_CHECKSRC = 0 endif +# Use 'make Map=1' to enable saving linker map file(s): +# vmlinux.map for vmlinux, +# (arch/*/boot/compressed/vmlinux.map for arch/*/boot/compressed/vmlinux) + +ifeq ("$(origin Map)", "command line") + export KBUILD_SAVE_LINK_MAP := $(Map) +endif + # Use make M=dir to specify directory of external module to build # Old syntax make ... SUBDIRS=$PWD is still supported # Setting the environment variable KBUILD_EXTMOD take precedence @@ -838,6 +846,11 @@ ifeq ($(CONFIG_STRIP_ASM_SYMS),y) LDFLAGS_vmlinux+= $(call ld-option, -X,) endif +ifdef KBUILD_SAVE_LINK_MAP +LDFLAGS_vmlinux+= -Map=vmlinux.map +CLEAN_FILES+= vmlinux.map +endif + # insure the checker run with the right endianness CHECKFLAGS += $(if $(CONFIG_CPU_BIG_ENDIAN),-mbig-endian,-mlittle-endian) @@ -1434,6 +1447,7 @@ help: @echo '2: warnings which occur quite often but may still be relevant' @echo '3: more obscure warnings, can most likely be ignored' @echo 'Multiple levels can be combined with W=12 or W=123' + @echo ' make Map=1 [targets] Save vmlinux linker map file(s)' @echo '' @echo 'Execute "make" or "make all" to build all targets marked with [*] ' @echo 'For further info see the ./README file' -- 2.18.0.13.gd42ae10
[PATCH 1/1] kbuild: allow alternate src for target's implicit prerequisite
With kbuild there is no easy way to re-compile source files from another directory, which is required for the decompressor on some platforms (files like lib/ctype.c, lib/cmdline.c, etc). Writing custom build rules for those files is not feasible since original rules are complex and kbuild functions and variables are not exposed. The simplest solution is to reverse include source files either into existing files or separate files. That eliminates the need to tackle with the kbuild rules, but is ugly. Here is another solution to that problem, utilizing secondary expansion. Build rules are in a form: $(obj)/%.o: $(src)/%.c ... $(obj)/%.o: $(src)/%.S ... "src" variable could be changed to cover the need of specifying alternate source file directory. src := $(if $(SRCDIR_$(@F)),$(SRCDIR_$(@F)),$(src)) So, if there is SRCDIR_ set, it will be used, original "src" is used otherwise. But that wouldn't work as it is. To be able to utilize automatic variables in implicit prerequisite secondary expansion has to be used and src value has to be additionally escaped. Alternate src dir then could be specified in Makefile as: obj-y := file1.o file2.o SRCDIR_file1.o := file1/src/dir SRCDIR_file2.o := file2/src/dir Which is enough to build $(obj)/file1.o from file1/src/dir/file1.(c|S), and $(obj)/file2.o from file2/src/dir/file2.(c|S) Secondary expansion has been introduced with make 3.81, which is minimal supported version by kbuild itself. Signed-off-by: Vasily Gorbik --- scripts/Makefile.build | 26 +++--- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 514ed63ff571..97c6ece96cfb 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -70,6 +70,10 @@ $(warning kbuild: Makefile.build is included improperly) endif # === +# Allow to specify alternate source directory of target's implicit prerequisite +# e.g. 'SRCDIR_cmdline.o := lib' +.SECONDEXPANSION: +srcdir := $$(if $$(SRCDIR_$$(@F)),$$(SRCDIR_$$(@F)),$(src)) ifneq ($(strip $(lib-y) $(lib-m) $(lib-)),) lib-target := $(obj)/lib.a @@ -134,13 +138,13 @@ $(obj-m) : quiet_modtag := [M] quiet_cmd_cc_s_c = CC $(quiet_modtag) $@ cmd_cc_s_c = $(CC) $(c_flags) $(DISABLE_LTO) -fverbose-asm -S -o $@ $< -$(obj)/%.s: $(src)/%.c FORCE +$(obj)/%.s: $(srcdir)/%.c FORCE $(call if_changed_dep,cc_s_c) quiet_cmd_cpp_i_c = CPP $(quiet_modtag) $@ cmd_cpp_i_c = $(CPP) $(c_flags) -o $@ $< -$(obj)/%.i: $(src)/%.c FORCE +$(obj)/%.i: $(srcdir)/%.c FORCE $(call if_changed_dep,cpp_i_c) # These mirror gensymtypes_S and co below, keep them in synch. @@ -157,7 +161,7 @@ cmd_cc_symtypes_c = \ $(call cmd_gensymtypes_c,true,$@) >/dev/null; \ test -s $@ || rm -f $@ -$(obj)/%.symtypes : $(src)/%.c FORCE +$(obj)/%.symtypes : $(srcdir)/%.c FORCE $(call cmd,cc_symtypes_c) # LLVM assembly @@ -165,7 +169,7 @@ $(obj)/%.symtypes : $(src)/%.c FORCE quiet_cmd_cc_ll_c = CC $(quiet_modtag) $@ cmd_cc_ll_c = $(CC) $(c_flags) -emit-llvm -S -o $@ $< -$(obj)/%.ll: $(src)/%.c FORCE +$(obj)/%.ll: $(srcdir)/%.c FORCE $(call if_changed_dep,cc_ll_c) # C (.c) files @@ -313,7 +317,7 @@ cmd_undef_syms = echo endif # Built-in and composite module parts -$(obj)/%.o: $(src)/%.c $(recordmcount_source) $(objtool_dep) FORCE +$(obj)/%.o: $(srcdir)/%.c $(recordmcount_source) $(objtool_dep) FORCE $(call cmd,force_checksrc) $(call if_changed_rule,cc_o_c) @@ -330,7 +334,7 @@ quiet_cmd_cc_lst_c = MKLST $@ $(CONFIG_SHELL) $(srctree)/scripts/makelst $*.o \ System.map $(OBJDUMP) > $@ -$(obj)/%.lst: $(src)/%.c FORCE +$(obj)/%.lst: $(srcdir)/%.c FORCE $(call if_changed_dep,cc_lst_c) # Compile assembler sources (.S) @@ -370,14 +374,14 @@ cmd_cc_symtypes_S = \ $(call cmd_gensymtypes_S,true,$@) >/dev/null; \ test -s $@ || rm -f $@ -$(obj)/%.symtypes : $(src)/%.S FORCE +$(obj)/%.symtypes : $(srcdir)/%.S FORCE $(call cmd,cc_symtypes_S) quiet_cmd_cpp_s_S = CPP $(quiet_modtag) $@ cmd_cpp_s_S = $(CPP) $(a_flags) -o $@ $< -$(obj)/%.s: $(src)/%.S FORCE +$(obj)/%.s: $(srcdir)/%.S FORCE $(call if_changed_dep,cpp_s_S) quiet_cmd_as_o_S = AS $(quiet_modtag) $@ @@ -413,7 +417,7 @@ cmd_modversions_S = \ endif endif -$(obj)/%.o: $(src)/%.S $(objtool_dep) FORCE +$(obj)/%.o: $(srcdir)/%.S $(objtool_dep) FORCE $(call if_changed_rule,as_o_S) targets += $(filter-out $(subdir-obj-y), $(real-obj-y)) $(real-obj-m) $(lib-y) @@ -425,7 +429,7 @@ quiet_cmd_cpp
[PATCH 0/1] kbuild: allow alternate src for target's implicit prerequisite
While adding more functionality to s390's decompressor code and looking at other architectures implementation there is an apparent need to reuse some code outside of arch/*/boot folder (files like lib/ctype.c, lib/cmdline.c and others). On s390 there is a need to rebuild and reuse few additional files to print out early error messages (console support, ebcdic, arch/s390/lib/mem.S). This list will be extended with additional features implementation (like kaslr, etc). Current solution seems to be reverse including source files, which is ugly. The following patch proposes another way to address that problem, which in the end would we used like: in some arch/*/boot/Makefile: obj-y := ctype.o cmdline.o mem.o ..some local files.. SRCDIR_ctype.o := lib SRCDIR_cmdline.o := lib SRCDIR_mem.o := arch/s390/lib Vasily Gorbik (1): kbuild: allow alternate src for target's implicit prerequisite scripts/Makefile.build | 26 +++--- 1 file changed, 15 insertions(+), 11 deletions(-) -- 2.18.0.13.gd42ae10
Re: [PATCH 2/4] trace: avoid calling cc-option -mrecord-mcount for every Makefile
On Mon, Aug 06, 2018 at 11:07:40AM -0700, Andi Kleen wrote: > On Mon, Aug 06, 2018 at 03:17:44PM +0200, Vasily Gorbik wrote: > > Currently if CONFIG_FTRACE_MCOUNT_RECORD is enabled -mrecord-mcount > > compiler flag support is tested for every Makefile. > > Good catch. Does it make a measurable compile time difference? > A bit more than couple of seconds, but it does make a difference for a delta build: with patch: real0m9.405s user0m6.966s sys 0m2.287s without: real0m12.153s user0m9.058s sys 0m3.026s with -j48 on s390 24 cores lpar: with patch: real0m1.949s user0m7.034s sys 0m2.400s without: real0m2.255s user0m9.243s sys 0m3.266s > > > > Top 4 cc-option usages: > > 511 -mrecord-mcount
Re: [PATCH 4/4] s390/ftrace: add -mfentry and -mnop-mcount support
On Tue, Aug 07, 2018 at 07:30:17AM +0200, Heiko Carstens wrote: > On Mon, Aug 06, 2018 at 03:17:47PM +0200, Vasily Gorbik wrote: > > Utilize -mfentry and -mnop-mcount gcc options together with > > -mrecord-mcount to get compiler generated calls to the profiling functions > > as nops which are compatible with current -mhotpatch=0,3 approach. At the > > same time -mrecord-mcount enables __mcount_loc section generation by > > the compiler which allows to avoid using scripts/recordmcount.pl script. > > > > Signed-off-by: Vasily Gorbik > > --- > > arch/s390/Kconfig | 2 ++ > > arch/s390/Makefile | 16 +--- > > arch/s390/include/asm/ftrace.h | 6 +++--- > > arch/s390/kernel/ftrace.c | 2 +- > > arch/s390/kernel/mcount.S | 2 +- > > 5 files changed, 16 insertions(+), 12 deletions(-) > > Do you have numbers which tell how much this reduces the compile time of > the kernel on s390? I assume this change makes quite some difference. > Very roughly, best time across several runs. With -j24 on 24 core lpar with -mfentry -mrecord-mcount etc real0m54.748s user12m32.041s sys 1m17.778s vs -mhotpatch=0,3 + scripts/recordmcount.pl: real0m56.752s user12m52.386s sys 1m35.873s
[PATCH next-lockdown 0/1] debugfs EPERM fix for 'Kernel lockdown for secure boot' patch series
Not sure whom to offer the fix, since 'Kernel lockdown for secure boot' in not upstream, but it has been picked by fedora and ubuntu. And I see it in next-lockdown branch of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security.git So, in addition to (prior to) opening bug reports to distributions I'm sending this patch hoping to reach its origin from where distributions had picked it. Vasily Gorbik (1): debugfs: avoid EPERM when no open file operation defined fs/debugfs/file.c | 10 ++ 1 file changed, 6 insertions(+), 4 deletions(-) -- 2.18.0.13.gd42ae10
[PATCH next-lockdown 1/1] debugfs: avoid EPERM when no open file operation defined
With "debugfs: Restrict debugfs when the kernel is locked down" return code "r" is unconditionally set to -EPERM, which stays like that until function return if no "open" file operation defined, effectivelly resulting in "Operation not permitted" for all such files despite kernel lock down status or CONFIG_LOCK_DOWN_KERNEL being enabled. In particular this breaks 2 debugfs files on s390: /sys/kernel/debug/s390_hypfs/diag_304 /sys/kernel/debug/s390_hypfs/diag_204 To address that set EPERM return code only when debugfs_is_locked_down returns true. Fixes: 3fc322605158 ("debugfs: Restrict debugfs when the kernel is locked down") Signed-off-by: Vasily Gorbik --- fs/debugfs/file.c | 10 ++ 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c index 51cb894c21f2..89c86faaa02a 100644 --- a/fs/debugfs/file.c +++ b/fs/debugfs/file.c @@ -167,9 +167,10 @@ static int open_proxy_open(struct inode *inode, struct file *filp) real_fops = debugfs_real_fops(filp); - r = -EPERM; - if (debugfs_is_locked_down(inode, filp, real_fops)) + if (debugfs_is_locked_down(inode, filp, real_fops)) { + r = -EPERM; goto out; + } real_fops = fops_get(real_fops); if (!real_fops) { @@ -296,9 +297,10 @@ static int full_proxy_open(struct inode *inode, struct file *filp) return r == -EIO ? -ENOENT : r; real_fops = debugfs_real_fops(filp); - r = -EPERM; - if (debugfs_is_locked_down(inode, filp, real_fops)) + if (debugfs_is_locked_down(inode, filp, real_fops)) { + r = -EPERM; goto out; + } real_fops = fops_get(real_fops); if (!real_fops) { -- 2.18.0.13.gd42ae10
Re: [PATCH 1/1] s390/virtio_ccw: fix config change notifications
On Thu, Jun 13, 2024 at 03:21:15PM +0200, Halil Pasic wrote: > On Wed, 12 Jun 2024 16:04:15 +0200 > Thomas Huth wrote: > > > On 11/06/2024 23.47, Halil Pasic wrote: > > > Commit e3e9bda38e6d ("s390/virtio_ccw: use DMA handle from DMA API") > > > broke configuration change notifications for virtio-ccw by putting the > > > DMA address of *indicatorp directly into ccw->cda disregarding the fact > > > that if !!(vcdev->is_thinint) then the function > > > virtio_ccw_register_adapter_ind() will overwrite that ccw->cda value > > > with the address of the virtio_thinint_area so it can actually set up > > > the adapter interrupts via CCW_CMD_SET_IND_ADAPTER. Thus we end up > > > pointing to the wrong object for both CCW_CMD_SET_IND if setting up the > > > adapter interrupts fails, and for CCW_CMD_SET_CONF_IND regardless > > > whether it succeeds or fails. > > > > > > To fix this, let us save away the dma address of *indicatorp in a local > > > variable, and copy it to ccw->cda after the "vcdev->is_thinint" branch. > > > > > > Reported-by: Boqiao Fu > > > Reported-by: Sebastian Mitterle > > > Fixes: e3e9bda38e6d ("s390/virtio_ccw: use DMA handle from DMA API") > > > Signed-off-by: Halil Pasic > > > --- > > > I know that checkpatch.pl complains about a missing 'Closes' tag. > > > Unfortunately I don't have an appropriate URL at hand. @Sebastian, > > > @Boqiao: do you have any suggetions? > > > > Closes: https://issues.redhat.com/browse/RHEL-39983 > > ? > > Yep! That is a public bug tracker bug. Qualifies! > @Vasily: Can you guys pick hat one up when picking the patch? Sure, applied. Thanks!
Re: [PATCH 26/27] debugfs: Restrict debugfs when the kernel is locked down
On Wed, Mar 06, 2019 at 03:59:12PM -0800, Matthew Garrett wrote: > From: David Howells > > static int open_proxy_open(struct inode *inode, struct file *filp) > { > struct dentry *dentry = F_DENTRY(filp); > @@ -147,6 +166,11 @@ static int open_proxy_open(struct inode *inode, struct > file *filp) > return r == -EIO ? -ENOENT : r; > > real_fops = debugfs_real_fops(filp); > + > + r = -EPERM; > + if (debugfs_is_locked_down(inode, filp, real_fops)) > + goto out; > + > real_fops = fops_get(real_fops); > if (!real_fops) { > /* Huh? Module did not clean up after itself at exit? */ > @@ -272,6 +296,10 @@ static int full_proxy_open(struct inode *inode, struct > file *filp) > return r == -EIO ? -ENOENT : r; > > real_fops = debugfs_real_fops(filp); > + r = -EPERM; > + if (debugfs_is_locked_down(inode, filp, real_fops)) > + goto out; > + > real_fops = fops_get(real_fops); > if (!real_fops) { > /* Huh? Module did not cleanup after itself at exit? */ Please be aware that this patch has been known to cause problems in distributions which picked this patch series already: ubuntu: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1807686 fedora: https://bugzilla.redhat.com/show_bug.cgi?id=1658675 as well as rhel 8. I've sent around this potential fix which has been picked by the distributions (offered via bugzillas), but went apparently unnoticed at lkml: https://lkml.org/lkml/2018/11/21/634 https://lkml.org/lkml/2018/11/21/635 """ With "debugfs: Restrict debugfs when the kernel is locked down" return code "r" is unconditionally set to -EPERM, which stays like that until function return if no "open" file operation defined, effectivelly resulting in "Operation not permitted" for all such files despite kernel lock down status or CONFIG_LOCK_DOWN_KERNEL being enabled. """ I would appreciate if you consider that change, possibly just squashing into yours.
[GIT PULL] s390 updates for 5.11-rc6
Hello Linus, please pull s390 fixes for 5.11-rc6. Thank you, Vasily The following changes since commit 6ee1d745b7c9fd573fba142a2efdad76a9f1cb04: Linux 5.11-rc5 (2021-01-24 16:47:14 -0800) are available in the Git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git tags/s390-5.11-4 for you to fetch changes up to e82080e1f456467cc185fe65ee69fe9f9bd0b576: s390: uv: Fix sysfs max number of VCPUs reporting (2021-01-27 13:00:04 +0100) - Fix max number of VCPUs reported via ultravisor information sysfs interface. - Fix memory leaks during vfio-ap resources clean up on KVM pointer invalidation notification. - Fix potential specification exception by avoiding unnecessary interrupts disable after queue reset in vfio-ap. Janosch Frank (1): s390: uv: Fix sysfs max number of VCPUs reporting Tony Krowiak (2): s390/vfio-ap: clean up vfio_ap resources when KVM pointer invalidated s390/vfio-ap: No need to disable IRQ after queue reset arch/s390/boot/uv.c | 2 +- arch/s390/include/asm/uv.h| 4 +- arch/s390/kernel/uv.c | 2 +- drivers/s390/crypto/vfio_ap_drv.c | 6 +- drivers/s390/crypto/vfio_ap_ops.c | 149 -- drivers/s390/crypto/vfio_ap_private.h | 12 +-- 6 files changed, 101 insertions(+), 74 deletions(-)
[GIT PULL] s390 patches for the 5.12 merge window #2
Hello Linus, please pull the second round of s390 fixes and features for 5.12. Thank you, Vasily The following changes since commit df24212a493afda0d4de42176bea10d45825e9a0: Merge tag 's390-5.12-1' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux (2021-02-21 13:40:06 -0800) are available in the Git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git tags/s390-5.12-2 for you to fetch changes up to cf6acb8bdb1d829b85a4daa2944bf9e71c93f4b9: s390/cpumf: Add support for complete counter set extraction (2021-02-24 00:31:23 +0100) s390 updates for the 5.12 merge window #2 - Fix physical vs virtual confusion in some basic mm macros and routines. Caused by __pa == __va on s390 currently. - Get rid of on-stack cpu masks. - Add support for complete CPU counter set extraction. - Add arch_irq_work_raise implementation. - virtio-ccw revision and opcode fixes. Alexander Gordeev (4): s390/mm: make pXd_deref() macros return a pointer s390/mm: fix invalid __pa() usage in pfn_pXd() macros s390/mm: fix phys vs virt confusion in pgtable allocation routines s390/mm: fix phys vs virt confusion in vmem_*() functions family Cornelia Huck (1): virtio/s390: implement virtio-ccw revision 2 correctly Heiko Carstens (5): s390/opcodes: rename selhhhr to selfhr s390/smp: consolidate locking for smp_rescan() s390/smp: __smp_rescan_cpus() - move cpumask away from stack s390/smp: smp_emergency_stop() - move cpumask away from stack s390/topology: move cpumasks away from stack Ilya Leoshkevich (1): s390/smp: implement arch_irq_work_raise() Thomas Richter (1): s390/cpumf: Add support for complete counter set extraction arch/s390/include/asm/irq_work.h | 12 + arch/s390/include/asm/pgalloc.h| 2 +- arch/s390/include/asm/pgtable.h| 16 +- arch/s390/include/uapi/asm/perf_cpum_cf_diag.h | 51 +++ arch/s390/kernel/perf_cpum_cf_diag.c | 548 +++-- arch/s390/kernel/smp.c | 28 +- arch/s390/kernel/topology.c| 25 +- arch/s390/mm/pgalloc.c | 22 +- arch/s390/mm/vmem.c| 30 +- arch/s390/tools/opcodes.txt| 2 +- drivers/s390/virtio/virtio_ccw.c | 4 +- include/linux/cpuhotplug.h | 1 + 12 files changed, 660 insertions(+), 81 deletions(-) create mode 100644 arch/s390/include/asm/irq_work.h create mode 100644 arch/s390/include/uapi/asm/perf_cpum_cf_diag.h
Re: linux plumbers + clang + s390 virtualized testing
On Thu, Jul 16, 2020 at 01:28:40PM +0200, Heiko Carstens wrote: > Hi Nick, > > > We were very excited to see your patches going by for enabling Clang > > support for s390. Since then, we've added s390 builds to our > > continuous integration setup. > > > > We've been running into a few issues with doing virtualized boot tests > > of our kernels on s390. > > > > I was curious if you'll both be attending Linux plumbers conf? If we > > carve out time for an s390+clang talk, would this be of interest to > > you to attend? > > I will not attend, however cannot speak for Vasily. He will have to > answer as soon as he returns - besides that enabling Clang support for > s390 was done by Vasily anyway :) I will attend and it would surely be interesting to me and other s390 folks. Your efforts are greatly appreciated! BTW I believe basic Clang support for s390 came earlier in 5.2 with a lot of efforts from Arnd Bergmann. My part was fixing recent breakages and bugging our s390 clang team (which did all the great work) to get kernel specific features support in clang 10 and 11 to reach features parity with gcc. And eventually doing few adjustments so that features which came with clang 10 and 11 are working smoothly. That is s390 "asm goto" support and specific compiler flags for ftrace support and stack packing.
Re: linux plumbers + clang + s390 virtualized testing
On Thu, Aug 06, 2020 at 12:02:52PM -0700, Nick Desaulniers wrote: > On Wed, Jul 29, 2020 at 6:51 AM Vasily Gorbik wrote: > > > > > > We were very excited to see your patches going by for enabling Clang > > > > support for s390. Since then, we've added s390 builds to our > > > > continuous integration setup. > > > > > > > > We've been running into a few issues with doing virtualized boot tests > > > > of our kernels on s390. > > > > > > > > I was curious if you'll both be attending Linux plumbers conf? If we > > > > carve out time for an s390+clang talk, would this be of interest to > > > > you to attend? > > I will attend and it would surely be interesting to me and other > > s390 folks. Your efforts are greatly appreciated! > > Cool, so our MC has been approved: > https://www.linuxplumbersconf.org/event/7/page/80-accepted-microconferences#llvm-cr > > But we're super tight on time and probably won't be able to do a > session on s390 at the MC. That said, I have just submitted a BoF > proposal since we have more topics internal to our group we'd like to > have more time to discuss. I've added s390 testing to the list of > potential topics, too. I'll re-ping this thread once I hear back > about whether it gets approved or not. > > That said, we do meet once every other week virtually online, see > links: https://clangbuiltlinux.github.io/. > > > > > BTW I believe basic Clang support for s390 came earlier in 5.2 with > > a lot of efforts from Arnd Bergmann. > > > > My part was fixing recent breakages and bugging our s390 clang team > > (which did all the great work) to get kernel specific features support > > in clang 10 and 11 to reach features parity with gcc. And eventually > > doing few adjustments so that features which came with clang 10 and > > 11 are working smoothly. That is s390 "asm goto" support and specific > > compiler flags for ftrace support and stack packing. > > That's awesome; I'd love to get the chance to meet your s390 LLVM > team; in general it can take a while to get bugs routed to folks most > empowered to fix them until you know who they are. > > Would you, any fellow s390 kernel and LLVM folks be interested in > attending one of our virtual meetings, even if it's just to say "hi" > quickly? Next one is next Wednesday. > > Usually we go over whatever firedrills we've been running the past two > weeks, but sometimes have presentations of folks projects and > research. I think it would be cool to get more background on s390 and > work out the issues we're running into with testing. I've added few more people in To. We'll try to make it next Wednesday, but no promises since we are based in Germany and this is quite late for us.
Re: Is s390's new generic-using syscall code actually correct?
Hi Andy, On Sat, Mar 20, 2021 at 08:48:34PM -0700, Andy Lutomirski wrote: > Hi all- > > I'm working on my kentry patchset, and I encountered: > > commit 56e62a73702836017564eaacd5212e4d0fa1c01d > Author: Sven Schnelle > Date: Sat Nov 21 11:14:56 2020 +0100 > > s390: convert to generic entry > > As part of this work, I was cleaning up the generic syscall helpers, > and I encountered the goodies in do_syscall() and __do_syscall(). > > I'm trying to wrap my head around the current code, and I'm rather confused. > > 1. syscall_exit_to_user_mode_work() does *all* the exit work, not just > the syscall exit work. So a do_syscall() that gets called twice will > do the loopy part of the exit work (e.g. signal handling) twice. Is > this intentional? If so, why? > > 2. I don't understand how this PIF_SYSCALL_RESTART thing is supposed > to work. Looking at the code in Linus' tree, if a signal is pending > and a syscall returns -ERESTARTSYS, the syscall will return back to > do_syscall(). The work (as in (1)) gets run, calling do_signal(), > which will notice -ERESTARTSYS and set PIF_SYSCALL_RESTART. > Presumably it will also push the signal frame onto the stack and aim > the return address at the svc instruction mentioned in the commit > message from "s390: convert to generic entry". Then __do_syscall() > will turn interrupts back on and loop right back into do_syscall(). > That seems incorrect. > > Can you enlighten me? My WIP tree is here: > https://git.kernel.org/pub/scm/linux/kernel/git/luto/linux.git/log/?h=x86/kentry > For all the details to that change we'd have to wait for Sven, who is back next week. > Here are my changes to s390, and I don't think they're really correct: > > > https://git.kernel.org/pub/scm/linux/kernel/git/luto/linux.git/diff/arch/s390/kernel/syscall.c?h=x86/kentry&id=58a459922be0fb8e0f17aeaebcb0ac8d0575a62c Couple of things: syscall_exit_to_user_mode_prepare is static, and there is another code path in arch/s390/kernel/traps.c using enter_from_user_mode/exit_to_user_mode. Anyhow I gave your branch a spin and got few new failures on strace test suite, in particular on restart_syscall test. I'll try to find time to look into details.
User stacktrace garbage when USER_STACKTRACE_SUPPORT is not enabled
Hi Steven, At least on s390 since commit cbc3b92ce037 ("tracing: Set kernel_stack's caller size properly") kernel stack trace contains 8 garbage values in the end. I assume those are supposed to be filled by ftrace_trace_userstack, which is only implemented on x86. sshd-804 [050] 1997.252608: kernel_stack: => trampoline_probe_handler (549628c94) => kprobe_handler (549629260) => kprobe_exceptions_notify (549629370) => notify_die (549686e5e) => illegal_op (54960d440) => __do_pgm_check (54a106b08) => pgm_check_handler (54a112cc8) => kretprobe_trampoline (549629438) => kretprobe_trampoline (549629436) => do_syscall (549611ee6) => __do_syscall (54a106ccc) => system_call (54a112b5a) => 76901000322 => 22125e4d8 => 22125e8f8 => e54100040100 => _end (322000c) => 2 => 20f892ec0002 => 20f898b80002 kernel/trace/trace_entries.h: 159 #define FTRACE_STACK_ENTRIES8 160 161 FTRACE_ENTRY(kernel_stack, stack_entry, 162 163 TRACE_STACK, 164 165 F_STRUCT( 166 __field(int,size) 167 __array(unsigned long, caller, FTRACE_STACK_ENTRIES) 168 ), Is there any reason to keep those 8 extra values in the caller array if CONFIG_USER_STACKTRACE_SUPPORT is not enabled? Any advice how to fix that gracefully? It seems to work if I simply set FTRACE_STACK_ENTRIES to 0 when CONFIG_USER_STACKTRACE_SUPPORT is not enabled.
Re: User stacktrace garbage when USER_STACKTRACE_SUPPORT is not enabled
On Wed, Mar 31, 2021 at 10:37:49AM -0400, Steven Rostedt wrote: > But after writing all of the above, I think I found a bug! It's this: > > size = nr_entries * sizeof(unsigned long); > event = __trace_buffer_lock_reserve(buffer, TRACE_STACK, > sizeof(*entry) + size, trace_ctx); > > > I said the above commit did not play a role in output, but it does play a > role in creating the struct stack_trace entry. And by making it a fixed > array (even though it's not used) it added 8 more entries to the stack! > > This should fix the problem: > > -- Steve > > diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c > index 3c605957bb5c..507a30bf26e4 100644 > --- a/kernel/trace/trace.c > +++ b/kernel/trace/trace.c > @@ -2985,7 +2985,8 @@ static void __ftrace_trace_stack(struct trace_buffer > *buffer, > > size = nr_entries * sizeof(unsigned long); > event = __trace_buffer_lock_reserve(buffer, TRACE_STACK, > - sizeof(*entry) + size, trace_ctx); > + (sizeof(*entry) - sizeof(entry->caller)) + > size, > + trace_ctx); > if (!event) > goto out; > entry = ring_buffer_event_data(event); It does! Thanks for the explanation and for the fix. I wonder why nobody noticed and complained about that since v5.6. Acked-by: Vasily Gorbik
Re: User stacktrace garbage when USER_STACKTRACE_SUPPORT is not enabled
On Wed, Mar 31, 2021 at 05:09:00PM -0400, Steven Rostedt wrote: > On Wed, 31 Mar 2021 22:51:15 +0200 > Vasily Gorbik wrote: > > > It does! Thanks for the explanation and for the fix. I wonder why nobody > > noticed and complained about that since v5.6. > > Because it didn't lose data, just added extra junk. > > > > > Acked-by: Vasily Gorbik > > Want to give a "tested-by" too? I only tested it on s390 (manually + ftrace selftest), quite frankly. If it qualifies: Tested-by: Vasily Gorbik # s390 only
[GIT PULL] s390 patches for the 5.12 merge window
Hello Linus, please pull s390 changes for 5.12. There are small common code and alpha/Kconfig changes caused by 96c0a6a72d18 ("s390,alpha: switch to 64-bit ino_t"). Which has been discussed here: lkml.kernel.org/r/YCV7QiyoweJwvN+m@osiris The following changes since commit 19c329f6808995b142b3966301f217c831e7cf31: Linux 5.11-rc4 (2021-01-17 16:37:05 -0800) are available in the Git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git tags/s390-5.12-1 for you to fetch changes up to 2223318c2862edc7f5b282939b850b19fc934ec4: s390/qdio: remove 'merge_pending' mechanism (2021-02-13 17:17:55 +0100) Thank you, Vasily s390 updates for the 5.12 merge window - Convert to using the generic entry infrastructure. - Add vdso time namespace support. - Switch s390 and alpha to 64-bit ino_t. As discussed here lkml.kernel.org/r/YCV7QiyoweJwvN+m@osiris - Get rid of expensive stck (store clock) usages where possible. Utilize cpu alternatives to patch stckf when supported. - Make tod_clock usage less error prone by converting it to a union and rework code which is using it. - Machine check handler fixes and cleanups. - Drop couple of minor inline asm optimizations to fix clang build. - Default configs changes notably to make libvirt happy. - Various changes to rework and improve qdio code. - Other small various fixes and improvements all over the code. Alexander Egorenkov (2): s390: update defconfigs s390/thread_info.h: fix task_struct declaration warning Alexander Gordeev (1): s390/tlb: make cleared_pXs flags consistent with generic code Chengyang Fan (1): s390/ap: remove unneeded semicolon Colin Ian King (1): s390/tape: Fix spelling mistake in function name tape_3590_erp_succeded Halil Pasic (1): s390/defconfig: add some NFT modules Harald Freudenberger (2): s390/crypto: improve retry logic in case of master key change s390/zcrypt: return EIO when msg retry limit reached Heiko Carstens (34): s390/atomic: remove small optimization to fix clang build s390/bitops: remove small optimization to fix clang build s390: update defconfigs s390/vdso: remove VDSO32_LBASE compat leftover s390/vdso: fix vdso data page definition s390/vdso: convert vdso_init() to arch_initcall s390/vdso: simplify vdso size calculation s390/vdso: remove BUG_ON() s390/vdso: remove superfluous check s390/vdso: remove superfluous variables s390/vdso: misc simple code changes s390/vdso: get rid of vdso_fault s390/vdso: put vdso datapage in a separate vma s390/vdso: move data page before code pages s390/vdso: simplify __arch_get_hw_counter() s390/vdso: implement generic vdso time namespace support s390/vdso: on timens page fault prefault also VVAR page s390/vtime: fix inline assembly clobber list s390/cpum_cf_diag: use get_tod_clock_fast() s390/time: use stcke instead of stck s390/entry: use cpu alternative for stck/stckf s390/alternatives: add alternative_input() / alternative_io() s390/vtime: use cpu alternative for stck/stckf s390,alpha: switch to 64-bit ino_t s390/time: introduce union tod_clock s390/time: rename store_tod_clock_ext() and use union tod_clock s390/time: introduce new store_tod_clock_ext() s390/time: convert tod_clock_base to union s390/vdso: use union tod_clock s390/kvm: use union tod_clock s390/debug: use union tod_clock s390/hypfs: use store_tod_clock_ext() s390/crypto: use store_tod_clock_ext() s390/time: remove get_tod_clock_ext() Jan Höppner (1): Documentations: scsi, kvm: Update s390-tools GitHub URL Jiapeng Zhong (1): s390: Simplify the calculation of variables Julian Wiedmann (11): s390/cio: remove ccw_device_add() wrapper s390/cio: use dma helpers for setting masks s390/qdio: remove Input tasklet code s390/qdio: remove qdio_inbound_q_moved() wrapper s390/qdio: adopt new tasklet API s390/qdio: make thinint registration symmetric s390/qdio: track time of last data IRQ for each device s390/qdio: inline qdio_kick_handler() s390/qdio: rework q->qdio_error indication s390/qdio: improve handling of PENDING buffers for QEBSM devices s390/qdio: remove 'merge_pending' mechanism Marc Hartmayer (1): s390/debug_config: enable kmemleak detector Niklas Schnelle (2): s390/pci: remove superfluous zdev->zbus check s390/pci: refactor zpci_create_device() Sven Schnelle (10): s390: convert to generic entry s390: remove asmlinkage s390: pass struct pt_regs instead of registers to syscalls s390: add missing include to arch/s390/kernel/signal.c s390: open code SWITCH_KERNEL macro s390: use
Re: [PATCH] x86/insn: Fix vector instructions decoding on big endian
On Fri, Nov 13, 2020 at 11:30:52AM -0600, Josh Poimboeuf wrote: > On Fri, Nov 13, 2020 at 05:09:54PM +0100, Vasily Gorbik wrote: > > Running instruction decoder posttest on s390 with allyesconfig shows > > errors. Instructions used in couple of kernel objects could not be > > correctly decoded on big endian system. > > > > insn_decoder_test: warning: objdump says 6 bytes, but insn_get_length() > > says 5 > > insn_decoder_test: warning: Found an x86 instruction decoder bug, please > > report this. > > insn_decoder_test: warning: 831eb4e1:62 d1 fd 48 7f 04 24 > > vmovdqa64 %zmm0,(%r12) > > insn_decoder_test: warning: objdump says 7 bytes, but insn_get_length() > > says 6 > > insn_decoder_test: warning: Found an x86 instruction decoder bug, please > > report this. > > insn_decoder_test: warning: 831eb4e8:62 51 fd 48 7f 44 24 01 > > vmovdqa64 %zmm8,0x40(%r12) > > insn_decoder_test: warning: objdump says 8 bytes, but insn_get_length() > > says 6 > > > > This is because in few places instruction field bytes are set directly > > with further usage of "value". To address that introduce and use > > insn_set_byte() helper, which correctly updates "value" on big endian > > systems. > > > > Signed-off-by: Vasily Gorbik > > --- > > Please let me know if this patch is good as it is or I should squash it > > into the patch 2 of my patch series and resend it again. > > It all looks good to me, thanks! > > Masami, does this patch look good, and also patches 1-2 of the series? > (I think you previously ACKed patch 2). > Friendly ping...
Re: [PATCH] scripts/sorttable: Fix ORC unwind table sorting on big endian
On Sat, Nov 14, 2020 at 01:53:10PM +0100, Vasily Gorbik wrote: > Currently when x86_64 kernel is cross compiled on big endian hardware > ORC unwind table is not sorted correctly. Due to missing byte swaps and > treating size as 4-byte value ORC sections sizes end up as 0 and the > problem is silently ignored. > > Make ORC unwind table sorting endianness aware. > > Signed-off-by: Vasily Gorbik > --- > This goes on top of the patch series: > > http://lkml.kernel.org/r/cover.thread-1e2854.your-ad-here.call-01605220128-ext-6070@work.hours > > scripts/sorttable.h | 20 +++- > 1 file changed, 11 insertions(+), 9 deletions(-) Friendly ping...
[GIT PULL] s390 updates for 5.11-rc2
Hello Linus, please pull s390 changes for 5.11-rc2. Thank you, Vasily The following changes since commit 5c8fe583cce542aa0b84adc939ce85293de36e5e: Linux 5.11-rc1 (2020-12-27 15:30:22 -0800) are available in the Git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git tags/s390-5.11-3 for you to fetch changes up to 129975e75b9a2ba528d7f58be2e338cd644f6ed8: s390/Kconfig: sort config S390 select list once again (2020-12-30 17:08:53 +0100) - Update defconfigs and sort config select list. Heiko Carstens (2): s390: update defconfigs s390/Kconfig: sort config S390 select list once again arch/s390/Kconfig| 31 +-- arch/s390/configs/debug_defconfig| 12 +--- arch/s390/configs/defconfig | 11 +++ arch/s390/configs/zfcpdump_defconfig | 2 ++ 4 files changed, 35 insertions(+), 21 deletions(-) diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig index e84bdd15150b..c72874f09741 100644 --- a/arch/s390/Kconfig +++ b/arch/s390/Kconfig @@ -54,17 +54,23 @@ config KASAN_SHADOW_OFFSET config S390 def_bool y + # + # Note: keep this list sorted alphabetically + # + imply IMA_SECURE_AND_OR_TRUSTED_BOOT select ARCH_BINFMT_ELF_STATE select ARCH_HAS_DEBUG_VM_PGTABLE select ARCH_HAS_DEBUG_WX select ARCH_HAS_DEVMEM_IS_ALLOWED select ARCH_HAS_ELF_RANDOMIZE + select ARCH_HAS_FORCE_DMA_UNENCRYPTED select ARCH_HAS_FORTIFY_SOURCE select ARCH_HAS_GCOV_PROFILE_ALL select ARCH_HAS_GIGANTIC_PAGE select ARCH_HAS_KCOV select ARCH_HAS_MEM_ENCRYPT select ARCH_HAS_PTE_SPECIAL + select ARCH_HAS_SCALED_CPUTIME select ARCH_HAS_SET_MEMORY select ARCH_HAS_STRICT_KERNEL_RWX select ARCH_HAS_STRICT_MODULE_RWX @@ -111,8 +117,10 @@ config S390 select ARCH_WANT_IPC_PARSE_VERSION select BUILDTIME_TABLE_SORT select CLONE_BACKWARDS2 + select CPU_NO_EFFICIENT_FFS if !HAVE_MARCH_Z9_109_FEATURES select DMA_OPS if PCI select DYNAMIC_FTRACE if FUNCTION_TRACER + select GENERIC_ALLOCATOR select GENERIC_CPU_AUTOPROBE select GENERIC_CPU_VULNERABILITIES select GENERIC_FIND_FIRST_BIT @@ -126,22 +134,21 @@ config S390 select HAVE_ARCH_JUMP_LABEL_RELATIVE select HAVE_ARCH_KASAN select HAVE_ARCH_KASAN_VMALLOC - select CPU_NO_EFFICIENT_FFS if !HAVE_MARCH_Z9_109_FEATURES select HAVE_ARCH_SECCOMP_FILTER select HAVE_ARCH_SOFT_DIRTY select HAVE_ARCH_TRACEHOOK select HAVE_ARCH_TRANSPARENT_HUGEPAGE select HAVE_ARCH_VMAP_STACK select HAVE_ASM_MODVERSIONS - select HAVE_EBPF_JIT if PACK_STACK && HAVE_MARCH_Z196_FEATURES select HAVE_CMPXCHG_DOUBLE select HAVE_CMPXCHG_LOCAL select HAVE_DEBUG_KMEMLEAK select HAVE_DMA_CONTIGUOUS select HAVE_DYNAMIC_FTRACE select HAVE_DYNAMIC_FTRACE_WITH_REGS - select HAVE_FAST_GUP + select HAVE_EBPF_JIT if PACK_STACK && HAVE_MARCH_Z196_FEATURES select HAVE_EFFICIENT_UNALIGNED_ACCESS + select HAVE_FAST_GUP select HAVE_FENTRY select HAVE_FTRACE_MCOUNT_RECORD select HAVE_FUNCTION_ERROR_INJECTION @@ -163,16 +170,15 @@ config S390 select HAVE_KRETPROBES select HAVE_KVM select HAVE_LIVEPATCH - select HAVE_PERF_REGS - select HAVE_PERF_USER_STACK_DUMP select HAVE_MEMBLOCK_PHYS_MAP - select MMU_GATHER_NO_GATHER select HAVE_MOD_ARCH_SPECIFIC + select HAVE_NMI select HAVE_NOP_MCOUNT select HAVE_OPROFILE select HAVE_PCI select HAVE_PERF_EVENTS - select MMU_GATHER_RCU_TABLE_FREE + select HAVE_PERF_REGS + select HAVE_PERF_USER_STACK_DUMP select HAVE_REGS_AND_STACK_ACCESS_API select HAVE_RELIABLE_STACKTRACE select HAVE_RSEQ @@ -181,6 +187,8 @@ config S390 select HAVE_VIRT_CPU_ACCOUNTING_IDLE select IOMMU_HELPER if PCI select IOMMU_SUPPORTif PCI + select MMU_GATHER_NO_GATHER + select MMU_GATHER_RCU_TABLE_FREE select MODULES_USE_ELF_RELA select NEED_DMA_MAP_STATE if PCI select NEED_SG_DMA_LENGTH if PCI @@ -190,17 +198,12 @@ config S390 select PCI_MSI if PCI select PCI_MSI_ARCH_FALLBACKS if PCI_MSI select SPARSE_IRQ + select SWIOTLB select SYSCTL_EXCEPTION_TRACE select THREAD_INFO_IN_TASK select TTY select VIRT_CPU_ACCOUNTING - select ARCH_HAS_SCALED_CPUTIME - select HAVE_NMI - select ARCH_HAS_FORCE_DMA_UNENCRYPTED - select SWIOTLB - select GENERIC_ALLOCATOR - imp
Re: [PATCH] stacktrace: Move documentation for arch_stack_walk_reliable() to header
On Mon, Jan 18, 2021 at 09:10:21PM +, Mark Brown wrote: > Currently arch_stack_wallk_reliable() is documented with an identical > comment in both x86 and S/390 implementations which is a bit redundant. > Move this to the header and convert to kerneldoc while we're at it. > > Cc: Thomas Gleixner > Cc: Ingo Molnar > Cc: Borislav Petkov > Cc: "H. Peter Anvin" > Cc: Heiko Carstens > Cc: Vasily Gorbik > Cc: Christian Borntraeger > Cc: Josh Poimboeuf > Cc: Jiri Kosina > Cc: Miroslav Benes > Cc: Petr Mladek > Cc: Joe Lawrence > Cc: x...@kernel.org > Cc: linux-s...@vger.kernel.org > Cc: live-patch...@vger.kernel.org > Signed-off-by: Mark Brown > --- > arch/s390/kernel/stacktrace.c | 6 -- > arch/x86/kernel/stacktrace.c | 6 -- > include/linux/stacktrace.h| 19 +++ > 3 files changed, 19 insertions(+), 12 deletions(-) Acked-by: Vasily Gorbik
Re: [PATCH] s390/tape: Fix spelling mistake in function name tape_3590_erp_succeded
On Mon, Jan 18, 2021 at 11:32:22AM +, Colin King wrote: > From: Colin Ian King > > Rename tape_3590_erp_succeded to tape_3590_erp_succeeded to fix a > spelling mistake in the function name. > > Signed-off-by: Colin Ian King > --- > drivers/s390/char/tape_3590.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) Applied, thanks.
[GIT PULL] s390 patches for the 5.4 merge window
ode. - Use refcount_t for reference counters for couple of places in mm code. - Logging improvements and return code fix in vfio-ccw code. - Couple of zpci fixes and minor refactoring. - Remove some outdated documentation. - Fix secure boot detection. - Other various minor code clean ups. Chuhong Yuan (2): s390/extmem: use refcount_t for refcount s390/mm: use refcount_t for refcount Cornelia Huck (1): vfio-ccw: add some logging Denis Efremov (1): s390/pci: PCI_IOV_RESOURCES loop refactoring in zpci_map_resources Halil Pasic (1): s390: vfio-ap: fix warning reset not completed Harald Freudenberger (10): s390/zcrypt: move cca misc functions to new code file s390/zcrypt: add base code for cca crypto card info support s390/zcrypt: new sysfs attributes serialnr and mkvps s390/pkey: pkey cleanup: narrow in-kernel API, fix some variable types s390/zcrypt: extend cca_findcard function and helper s390/zcrypt: Add low level functions for CCA AES cipher keys s390/pkey: add CCA AES cipher key support s390/paes: Prepare paes functions for large key blobs s390/zcrypt: fix wrong handling of cca cipher keygenflags s390/crypto: xts-aes-s390 fix extra run-time crypto self tests finding Heiko Carstens (2): Documentation/s390: remove outdated dasd documentation Documentation/s390: remove outdated debugging390 documentation Joerg Schmidbauer (1): s390/crypto: Support for SHA3 via CPACF (MSA6) Martin Schwidefsky (1): s390: add support for IBM z15 machines Masahiro Yamada (1): s390: remove pointless drivers-y in drivers/s390/Makefile Philipp Rudo (1): s390/sclp: Fix bit checked for has_sipl Sebastian Ott (1): s390/pci: fix MSI message data Thomas Richter (1): s390/cpum_sf: Fix line length and format string Vasily Gorbik (25): s390: move vmalloc option parsing to startup code s390/startup: add initial pgm check handler s390/startup: purge obsolete .gitignore patterns s390: clean .bss before running uncompressed kernel s390/kasan: provide uninstrumented __strlen s390/process: avoid potential reading of freed stack s390/kasan: avoid report in get_wchan s390/stacktrace: use common arch_stack_walk infrastructure s390/startup: adjust _sdma and _edma to page boundaries s390/startup: round down "mem" option to page boundary s390/numa: correct early_param handling s390/vmcp: correct early_param handling s390/startup: correct command line options parsing s390/vdso: reuse kstrtobool for option value parsing s390/cmma: reuse kstrtobool for option value parsing s390/mem_detect: provide single get_mem_detect_end s390/kaslr: reserve memory for kasan usage s390/pci: avoid using strncmp with hardcoded length s390/module: avoid using strncmp with hardcoded length s390/sclp: avoid using strncmp with hardcoded length s390/setup: avoid using strncmp with hardcoded length s390/kasan: add kdump support Merge tag 'vfio-ccw-20190828' of https://git.kernel.org/.../kvms390/vfio-ccw into features s390/base: remove unused s390_base_mcck_handler s390/startup: add pgm check info printing Wei Yongjun (1): vfio-ccw: fix error return code in vfio_ccw_sch_init() Documentation/s390/dasd.rst | 84 - Documentation/s390/debugging390.rst | 2613 --- Documentation/s390/index.rst|2 - arch/s390/Kconfig | 19 + arch/s390/Makefile |2 + arch/s390/boot/Makefile |2 +- arch/s390/boot/boot.h |1 + arch/s390/boot/compressed/.gitignore|3 - arch/s390/boot/compressed/vmlinux.lds.S |3 +- arch/s390/boot/head.S | 32 +- arch/s390/boot/ipl_parm.c | 11 +- arch/s390/boot/kaslr.c | 41 +- arch/s390/boot/mem_detect.c |7 - arch/s390/boot/pgm_check_info.c | 90 ++ arch/s390/boot/startup.c|6 + arch/s390/configs/debug_defconfig |2 + arch/s390/configs/defconfig |2 + arch/s390/crypto/Makefile |2 + arch/s390/crypto/aes_s390.c |6 + arch/s390/crypto/paes_s390.c| 184 ++- arch/s390/crypto/sha.h | 12 +- arch/s390/crypto/sha3_256_s390.c| 147 ++ arch/s390/crypto/sha3_512_s390.c| 155 ++ arch/s390/crypto/sha_common.c | 75 +- arch/s390/include/asm/cpacf.h |8 + arch/s390/include/asm/gmap.h|4 +- arch/s390/include/asm/mem_detect.h | 12 + arch/s390/include/asm/pgtable.h |1 + arch/s390/include/asm/pkey.h| 114 +- arch/s390/include/asm/processor.h
[GIT PULL] s390 updates for 5.4-rc2
Hello Linus, please pull s390 changes for 5.4-rc2. Thank you, Vasily The following changes since commit 54ecb8f7028c5eb3d740bb82b0f1d90f2df63c5c: Linux 5.4-rc1 (2019-09-30 10:35:40 -0700) are available in the Git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git tags/s390-5.4-3 for you to fetch changes up to d0dea733f60efe94257d08ae6eba81d0b511d0a9: KVM: s390: mark __insn32_query() as __always_inline (2019-10-05 13:51:22 +0200) s390 updates for 5.4-rc2 - Default configs updates. - Fix build errors with CC_OPTIMIZE_FOR_SIZE due to usage of "i" constraint for function arguments. Two kvm changes acked-by Christian Borntraeger. - Fix -Wunused-but-set-variable warnings in mm code. - Avoid a constant misuse in qdio. - Handle a case when cpumf is temporarily unavailable. Heiko Carstens (8): s390/atomic,bitops: mark function(s) __always_inline s390/cpu_mf: mark function(s) __always_inline s390/jump_label: mark function(s) __always_inline s390/mm: mark function(s) __always_inline s390/pci: mark function(s) __always_inline s390: update defconfigs KVM: s390: fix __insn32_query() inline assembly KVM: s390: mark __insn32_query() as __always_inline Jiri Kosina (1): s390: mark __cpacf_query() as __always_inline Julian Wiedmann (1): s390/qdio: clarify size of the QIB parm area Qian Cai (1): s390/mm: fix -Wunused-but-set-variable warnings Thomas Richter (3): s390/cpumf: Use consistant debug print format s390/cpumsf: Check for CPU Measurement sampling s390/cpumf: Fix indentation in sampling device driver arch/s390/configs/debug_defconfig| 24 arch/s390/configs/defconfig | 25 - arch/s390/configs/zfcpdump_defconfig | 2 +- arch/s390/include/asm/atomic_ops.h | 2 +- arch/s390/include/asm/bitops.h | 8 arch/s390/include/asm/cpacf.h| 2 +- arch/s390/include/asm/cpu_mf.h | 8 ++-- arch/s390/include/asm/hugetlb.h | 9 +++-- arch/s390/include/asm/jump_label.h | 4 ++-- arch/s390/include/asm/pgtable.h | 25 + arch/s390/include/asm/qdio.h | 2 +- arch/s390/kernel/perf_cpum_cf_diag.c | 4 ++-- arch/s390/kernel/perf_cpum_sf.c | 8 +++- arch/s390/kvm/kvm-s390.c | 6 +++--- arch/s390/pci/pci_clp.c | 2 +- drivers/s390/cio/qdio_setup.c| 2 +- drivers/s390/net/qeth_core_main.c| 3 +-- 17 files changed, 83 insertions(+), 53 deletions(-)
[GIT PULL] s390 patches for the 5.4 merge window #2
Hello Linus, please pull the second round of s390 fixes and features for 5.4. Thank you, Vasily The following changes since commit d590284419b1d7cc2dc646e9bdde4da19061cf0f: Merge tag 's390-5.4-1' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux (2019-09-17 14:04:43 -0700) are available in the Git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git tags/s390-5.4-2 for you to fetch changes up to ab5758848039de9a4b249d46e4ab591197eebaf2: s390/cio: exclude subchannels with no parent from pseudo check (2019-09-23 23:27:53 +0200) s390 updates for the 5.4 merge window #2 - Fix 3 kasan findings. - Add PERF_EVENT_IOC_PERIOD ioctl support. - Add Crypto Express7S support and extend sysfs attributes for pkey. - Minor common I/O layer documentation corrections. Cornelia Huck (1): s390/cio: fix intparm documentation Harald Freudenberger (1): s390/zcrypt: CEX7S exploitation support Ingo Franzki (1): s390/pkey: Add sysfs attributes to emit AES CIPHER key blobs Thomas Richter (2): s390/cpum_sf: Support ioctl PERF_EVENT_IOC_PERIOD s390/cpumf: Remove mixed white space Vasily Gorbik (3): s390/topology: avoid firing events before kobjs are created s390/cio: avoid calling strlen on null pointer s390/cio: exclude subchannels with no parent from pseudo check arch/s390/include/asm/cpu_mf.h | 10 +-- arch/s390/include/asm/perf_event.h | 2 + arch/s390/include/uapi/asm/zcrypt.h | 4 +- arch/s390/kernel/perf_cpum_sf.c | 165 +++- arch/s390/kernel/topology.c | 3 +- drivers/s390/cio/ccwgroup.c | 2 +- drivers/s390/cio/css.c | 2 + drivers/s390/cio/device_ops.c | 23 +++-- drivers/s390/crypto/ap_bus.c| 12 +-- drivers/s390/crypto/ap_bus.h| 3 +- drivers/s390/crypto/pkey_api.c | 113 drivers/s390/crypto/vfio_ap_drv.c | 2 + drivers/s390/crypto/zcrypt_api.h| 3 +- drivers/s390/crypto/zcrypt_cex4.c | 72 +++- 14 files changed, 334 insertions(+), 82 deletions(-)
Re: [PATCH 2/2] s390: add Linux banner to the compressed image
On Sun, Jul 14, 2019 at 03:52:52PM +, Petr Tesarik wrote: > On Sun, 14 Jul 2019 16:35:33 +0200 > Vasily Gorbik wrote: > > > On Fri, Jul 12, 2019 at 07:21:01PM +0200, Petr Tesarik wrote: > > > Various tools determine the kernel version from a given binary by > > > scanning for the Linux banner string. This does not work if the > > > banner string is compressed, but we can link it once more into the > > > uncompressed portion of bzImage. > > > But even before discussing solutions I would like to understand the > > problem first. Which specific tools are you referring to? What are they > > good for? And how do they get the kernel version from other architectures > > compressed images? > > The tool I'm aware of is called get_kernel_version. It's built as part > of openSUSE aaa_base and is used at install time. I'm not quite sure > how it is used, but I have added Raymund Will to Cc; he can provide > more information. There's also an open bug for it: > > https://bugzilla.opensuse.org/show_bug.cgi?id=1139939 Oh, I see, found it, thanks. Very interesting tool. https://github.com/openSUSE/aaa_base/blob/master/get_kernel_version.c And the only usage of this tool I found is to get the kernel version of /boot/image (on s390) to run depmod during yast-installation/src/clients/network_finish.rb I also see that queries to rpm are already done from yast-yast2/library/system/src/modules/Kernel.rb Wouldn't it be more reliable (and portable) to just get the kernel version from rpm metadata? Without using unreliable tools? Or find some other solution, since this is the only use case for the tool? $ rpm -qf --qf '%{VERSION}-%{RELEASE}.%{ARCH}\n' /boot/vmlinuz-5.1.17-300.fc30.x86_64 5.1.17-300.fc30.x86_64 [it looks like openSUSE kernel rpms don't have metadata to reconstruct full kernel version currently, but that could be improved?] Anyhow, I'm not opposed to an idea to make it possible to detect the kernel version from bzImage. But it should be reliable. So, see the follow on patch I'm sending.
[PATCH] s390: enable detection of kernel version from bzImage
Extend "parmarea" to include an offset of the version string, which is stored as 8-byte big endian value. To retrieve version string from bzImage reliably, one should check the presence of "S390EP" ascii string at 0x10008 (available since v3.2), then read the version string offset from 0x10428 (which has been 0 since v3.2 up to now). The string is null terminated. Could be retrieved with the following "file" command magic (requires file v5.34): 8 string \x02\x00\x00\x18\x60\x00\x00\x50\x02\x00\x00\x68\x60\x00\x00\x50\x40\x40\x40\x40\x40\x40\x40\x40 Linux S390 >0x10008 string S390EP >>0x10428 bequad >0 >>>(0x10428.Q) string >\0 \b, version %s Signed-off-by: Vasily Gorbik --- arch/s390/boot/Makefile | 2 +- arch/s390/boot/head.S | 1 + arch/s390/boot/version.c | 6 ++ arch/s390/include/asm/setup.h | 4 +++- 4 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 arch/s390/boot/version.c diff --git a/arch/s390/boot/Makefile b/arch/s390/boot/Makefile index 7cba96e7587b..4cf0bddb7d92 100644 --- a/arch/s390/boot/Makefile +++ b/arch/s390/boot/Makefile @@ -36,7 +36,7 @@ CFLAGS_sclp_early_core.o += -I$(srctree)/drivers/s390/char obj-y := head.o als.o startup.o mem_detect.o ipl_parm.o ipl_report.o obj-y += string.o ebcdic.o sclp_early_core.o mem.o ipl_vmparm.o cmdline.o -obj-y += ctype.o text_dma.o +obj-y += version.o ctype.o text_dma.o obj-$(CONFIG_PROTECTED_VIRTUALIZATION_GUEST) += uv.o obj-$(CONFIG_RELOCATABLE) += machine_kexec_reloc.o obj-$(CONFIG_RANDOMIZE_BASE) += kaslr.o diff --git a/arch/s390/boot/head.S b/arch/s390/boot/head.S index 028aab03a9e7..2087bed6e60f 100644 --- a/arch/s390/boot/head.S +++ b/arch/s390/boot/head.S @@ -361,6 +361,7 @@ ENTRY(startup_kdump) .quad 0 # INITRD_SIZE .quad 0 # OLDMEM_BASE .quad 0 # OLDMEM_SIZE + .quad kernel_version # points to kernel version string .orgCOMMAND_LINE .byte "root=/dev/ram0 ro" diff --git a/arch/s390/boot/version.c b/arch/s390/boot/version.c new file mode 100644 index ..ea5e49651931 --- /dev/null +++ b/arch/s390/boot/version.c @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0 +#include +#include + +const char kernel_version[] = UTS_RELEASE + " (" LINUX_COMPILE_BY "@" LINUX_COMPILE_HOST ") " UTS_VERSION; diff --git a/arch/s390/include/asm/setup.h b/arch/s390/include/asm/setup.h index 925889d360c1..e5d28a475f76 100644 --- a/arch/s390/include/asm/setup.h +++ b/arch/s390/include/asm/setup.h @@ -54,6 +54,7 @@ #define INITRD_SIZE_OFFSET 0x10410 #define OLDMEM_BASE_OFFSET 0x10418 #define OLDMEM_SIZE_OFFSET 0x10420 +#define KERNEL_VERSION_OFFSET 0x10428 #define COMMAND_LINE_OFFSET0x10480 #ifndef __ASSEMBLY__ @@ -74,7 +75,8 @@ struct parmarea { unsigned long initrd_size; /* 0x10410 */ unsigned long oldmem_base; /* 0x10418 */ unsigned long oldmem_size; /* 0x10420 */ - char pad1[0x10480 - 0x10428]; /* 0x10428 - 0x10480 */ + unsigned long kernel_version; /* 0x10428 */ + char pad1[0x10480 - 0x10430]; /* 0x10430 - 0x10480 */ char command_line[ARCH_COMMAND_LINE_SIZE]; /* 0x10480 */ }; -- 2.21.0
Re: [PATCH] s390: enable detection of kernel version from bzImage
On Tue, Jul 16, 2019 at 10:30:14AM +, Petr Tesarik wrote: > On Tue, 16 Jul 2019 00:12:19 +0200 > Vasily Gorbik wrote: > > > Extend "parmarea" to include an offset of the version string, which is > > stored as 8-byte big endian value. > > > > To retrieve version string from bzImage reliably, one should check the > > presence of "S390EP" ascii string at 0x10008 (available since v3.2), > > then read the version string offset from 0x10428 (which has been 0 > > since v3.2 up to now). The string is null terminated. > > > > Could be retrieved with the following "file" command magic (requires > > file v5.34): > > 8 string > > \x02\x00\x00\x18\x60\x00\x00\x50\x02\x00\x00\x68\x60\x00\x00\x50\x40\x40\x40\x40\x40\x40\x40\x40 > > Linux S390 > > >0x10008 string S390EP > > >>0x10428 bequad >0 > > >>>(0x10428.Q) string >\0 \b, version %s > > > > Signed-off-by: Vasily Gorbik > > This looks great! Much cleaner than the original approach. > > Thank you, > Petr T Then I'll add Reported-by: Petr Tesarik Suggested-by: Petr Tesarik if you don't mind and try to queue that for 5.3.
Re: [PATCH] s390: ptrace: hard-code "s390x" instead of UTS_MACHINE
On Mon, Apr 13, 2020 at 10:31:13AM +0900, Masahiro Yamada wrote: > s390 uses the UTS_MACHINE defined arch/s390/Makefile as follows: > > UTS_MACHINE := s390x > > We do not need to pass the fixed string from the command line. > Hard-code user_regset_view::name, like many other architectures do. > > Signed-off-by: Masahiro Yamada > --- > > arch/s390/kernel/Makefile | 5 - > arch/s390/kernel/ptrace.c | 2 +- > 2 files changed, 1 insertion(+), 6 deletions(-) Yes, since we don't have 31-bit kernel build support for s390 anymore this makes sense. Applied, thanks.
[GIT PULL] s390 updates for 5.4-rc3
Hello Linus, please pull s390 changes for 5.4-rc3. Thank you, Vasily The following changes since commit da0c9ea146cbe92b832f1b0f694840ea8eb33cce: Linux 5.4-rc2 (2019-10-06 14:27:30 -0700) are available in the Git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git tags/s390-5.4-4 for you to fetch changes up to 062795fcdcb2d22822fb42644b1d76a8ad8439b3: s390/uaccess: avoid (false positive) compiler warnings (2019-10-11 12:27:25 +0200) s390 updates for 5.4-rc3 - Fix virtio-ccw DMA regression. - Fix compiler warnings in uaccess. Christian Borntraeger (1): s390/uaccess: avoid (false positive) compiler warnings Halil Pasic (1): s390/cio: fix virtio-ccw DMA without PV arch/s390/include/asm/uaccess.h | 4 ++-- drivers/s390/cio/cio.h | 1 + drivers/s390/cio/css.c | 7 ++- drivers/s390/cio/device.c | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h index bd2fd9a7821d..a470f1fa9f2a 100644 --- a/arch/s390/include/asm/uaccess.h +++ b/arch/s390/include/asm/uaccess.h @@ -83,7 +83,7 @@ raw_copy_to_user(void __user *to, const void *from, unsigned long n); __rc; \ }) -static inline int __put_user_fn(void *x, void __user *ptr, unsigned long size) +static __always_inline int __put_user_fn(void *x, void __user *ptr, unsigned long size) { unsigned long spec = 0x01UL; int rc; @@ -113,7 +113,7 @@ static inline int __put_user_fn(void *x, void __user *ptr, unsigned long size) return rc; } -static inline int __get_user_fn(void *x, const void __user *ptr, unsigned long size) +static __always_inline int __get_user_fn(void *x, const void __user *ptr, unsigned long size) { unsigned long spec = 0x01UL; int rc; diff --git a/drivers/s390/cio/cio.h b/drivers/s390/cio/cio.h index ba7d2480613b..dcdaba689b20 100644 --- a/drivers/s390/cio/cio.h +++ b/drivers/s390/cio/cio.h @@ -113,6 +113,7 @@ struct subchannel { enum sch_todo todo; struct work_struct todo_work; struct schib_config config; + u64 dma_mask; char *driver_override; /* Driver name to force a match */ } __attribute__ ((aligned(8))); diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c index 1fbfb0a93f5f..831850435c23 100644 --- a/drivers/s390/cio/css.c +++ b/drivers/s390/cio/css.c @@ -232,7 +232,12 @@ struct subchannel *css_alloc_subchannel(struct subchannel_id schid, * belong to a subchannel need to fit 31 bit width (e.g. ccw). */ sch->dev.coherent_dma_mask = DMA_BIT_MASK(31); - sch->dev.dma_mask = &sch->dev.coherent_dma_mask; + /* +* But we don't have such restrictions imposed on the stuff that +* is handled by the streaming API. +*/ + sch->dma_mask = DMA_BIT_MASK(64); + sch->dev.dma_mask = &sch->dma_mask; return sch; err: diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c index 131430bd48d9..0c6245fc7706 100644 --- a/drivers/s390/cio/device.c +++ b/drivers/s390/cio/device.c @@ -710,7 +710,7 @@ static struct ccw_device * io_subchannel_allocate_dev(struct subchannel *sch) if (!cdev->private) goto err_priv; cdev->dev.coherent_dma_mask = sch->dev.coherent_dma_mask; - cdev->dev.dma_mask = &cdev->dev.coherent_dma_mask; + cdev->dev.dma_mask = sch->dev.dma_mask; dma_pool = cio_gp_dma_create(&cdev->dev, 1); if (!dma_pool) goto err_dma_pool;
[PATCH] latent_entropy: avoid build error when plugin cflags are not set
Some architectures set up CFLAGS for linux decompressor phase from scratch and do not include GCC_PLUGINS_CFLAGS. Since "latent_entropy" variable declaration is generated by the plugin code itself including linux/random.h in decompressor code then would cause a build error. E.g. on s390: In file included from ./include/linux/net.h:22, from ./include/linux/skbuff.h:29, from ./include/linux/if_ether.h:23, from ./arch/s390/include/asm/diag.h:12, from arch/s390/boot/startup.c:8: ./include/linux/random.h: In function 'add_latent_entropy': ./include/linux/random.h:26:39: error: 'latent_entropy' undeclared (first use in this function); did you mean 'add_latent_entropy'? 26 | add_device_randomness((const void *)&latent_entropy, | ^~ | add_latent_entropy ./include/linux/random.h:26:39: note: each undeclared identifier is reported only once for each function it appears in The build error is triggered by commit a80313ff91ab ("s390/kernel: introduce .dma sections") which made it into 5.2 merge window. To address that avoid using CONFIG_GCC_PLUGIN_LATENT_ENTROPY in favour of LATENT_ENTROPY_PLUGIN definition which is defined as a part of gcc plugins cflags and hence reflect more accurately when gcc plugin is active. Besides that it is also used for similar purpose in linux/compiler-gcc.h for latent_entropy attribute definition. Signed-off-by: Vasily Gorbik --- include/linux/random.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/random.h b/include/linux/random.h index 445a0ea4ff49..d4eb9b3789ad 100644 --- a/include/linux/random.h +++ b/include/linux/random.h @@ -20,7 +20,7 @@ struct random_ready_callback { extern void add_device_randomness(const void *, unsigned int); -#if defined(CONFIG_GCC_PLUGIN_LATENT_ENTROPY) && !defined(__CHECKER__) +#if defined(LATENT_ENTROPY_PLUGIN) && !defined(__CHECKER__) static inline void add_latent_entropy(void) { add_device_randomness((const void *)&latent_entropy, -- 2.18.0.13.gd42ae10
[GIT PULL] s390 patches for the 5.3 merge window #2
Hello Linus, please pull the second round of s390 fixes and features for 5.3. Thank you, Vasily The following changes since commit 1758feddb0f9751debdc865fefde94b45907c948: Merge tag 's390-5.3-1' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux (2019-07-08 10:06:12 -0700) are available in the Git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git tags/s390-5.3-2 for you to fetch changes up to 9a159190414d461fdac7ae5bb749c2d532b35419: s390/unwind: avoid int overflow in outside_of_stack (2019-07-11 20:40:02 +0200) s390 updates for the 5.3 merge window #2 - Fix integer overflow during stack frame unwind with invalid backchain. - Cleanup unused symbol export in zcrypt code. - Fix MIO addressing control activation in PCI code and expose its usage via sysfs. - Fix kernel image signature verification report presence detection. - Fix irq registration in vfio-ap code. - Add CPU measurement counters for newer machines. - Add base DASD thin provisioning support and code cleanups. Christian Borntraeger (1): s390: vfio-ap: fix irq registration Denis Efremov (1): s390/zcrypt: remove the exporting of ap_query_configuration Jan Höppner (14): s390/dasd: Remove unused structs and function prototypes s390/dasd: Remove old defines and function s390/dasd: Make layout analysis ESE compatible s390/dasd: Put sub-order definitions in a separate section s390/dasd: Recognise data for ESE volumes s390/dasd: Add dynamic formatting support for ESE volumes s390/dasd: Fix whitespace s390/dasd: Add missing intensity definition s390/dasd: Add dasd_sleep_on_queue_interruptible() s390/dasd: Add new ioctl to release space s390/dasd: Make dasd_setup_queue() a discipline function s390/dasd: Use ALIGN_DOWN macro s390/dasd: Add discard support for ESE volumes s390/dasd: Handle out-of-space constraint Philipp Rudo (1): s390/ipl: Fix detection of has_secure attribute Sebastian Ott (2): s390: fix setting of mio addressing control s390/pci: add mio_enabled attribute Thomas Richter (1): s390/cpumf: Add extended counter set definitions for model 8561 and 8562 Vasily Gorbik (1): s390/unwind: avoid int overflow in outside_of_stack arch/s390/include/asm/pci_insn.h | 10 - arch/s390/include/asm/sclp.h | 1 - arch/s390/include/uapi/asm/dasd.h | 154 +++--- arch/s390/kernel/early.c | 2 - arch/s390/kernel/ipl.c | 7 +- arch/s390/kernel/perf_cpum_cf_events.c | 2 + arch/s390/kernel/unwind_bc.c | 2 +- arch/s390/pci/pci.c| 4 +- arch/s390/pci/pci_sysfs.c | 10 + drivers/s390/block/dasd.c | 233 ++-- drivers/s390/block/dasd_devmap.c | 70 ++- drivers/s390/block/dasd_diag.c | 22 +- drivers/s390/block/dasd_eckd.c | 966 +++-- drivers/s390/block/dasd_eckd.h | 175 +- drivers/s390/block/dasd_eer.c | 1 + drivers/s390/block/dasd_fba.c | 45 +- drivers/s390/block/dasd_fba.h | 5 + drivers/s390/block/dasd_int.h | 33 +- drivers/s390/block/dasd_ioctl.c| 56 ++ drivers/s390/char/sclp_early.c | 1 - drivers/s390/crypto/ap_bus.c | 1 - drivers/s390/crypto/vfio_ap_ops.c | 3 +- 22 files changed, 1547 insertions(+), 256 deletions(-)
Re: [PATCH 2/2] s390: add Linux banner to the compressed image
On Fri, Jul 12, 2019 at 07:21:01PM +0200, Petr Tesarik wrote: > Various tools determine the kernel version from a given binary by > scanning for the Linux banner string. This does not work if the > banner string is compressed, but we can link it once more into the > uncompressed portion of bzImage. > > Signed-off-by: Petr Tesarik > --- > arch/s390/boot/compressed/Makefile | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/arch/s390/boot/compressed/Makefile > b/arch/s390/boot/compressed/Makefile > index fa529c5b4486..9bc4685477c5 100644 > --- a/arch/s390/boot/compressed/Makefile > +++ b/arch/s390/boot/compressed/Makefile > @@ -11,6 +11,7 @@ UBSAN_SANITIZE := n > KASAN_SANITIZE := n > > obj-y:= $(if $(CONFIG_KERNEL_UNCOMPRESSED),,decompressor.o) piggy.o > info.o > +obj-y += ../../../../init/banner.o We don't reuse objects from another build stage, we rebuild them with distinct decompressor's build flags. $ git grep "ctype.[oc]" -- arch/s390/boot arch/s390/boot/Makefile:obj-y += ctype.o text_dma.o arch/s390/boot/ctype.c:#include "../../../lib/ctype.c" Besides that, there is a special CONFIG_KERNEL_UNCOMPRESSED mode, with which "strings vmlinuz | grep 'Linux version'" I assume you are using would still yield result. Adding the second version of banner would produce duplicated result in this case. But even before discussing solutions I would like to understand the problem first. Which specific tools are you referring to? What are they good for? And how do they get the kernel version from other architectures compressed images?
Re: linux-next: Tree for Aug 13
On Tue, Aug 13, 2019 at 07:19:24PM +1000, Stephen Rothwell wrote: > Merging security/next-testing (a4848e06f9af Merge branch 'next-lockdown' into > next-testing) > CONFLICT (content): Merge conflict in kernel/trace/trace_kprobe.c > CONFLICT (content): Merge conflict in fs/tracefs/inode.c > Applying: early_security_init() needs a stub got !CONFIG_SECURITY Hi all, next-lockdown causes panic on s390 when doing: cat /sys/kernel/debug/tracing/events/syscalls/sys_enter_read/id [ 3972.384027] Unable to handle kernel pointer dereference in virtual kernel address space [ 3972.384031] Failing address: TEID: 0887 [ 3972.384032] Fault in home space mode while using kernel ASCE. [ 3972.384033] AS:744cc007 R3:0001fffd0007 S:0001fffd6000 P:013d [ 3972.384051] Oops: 0004 ilc:1 [#1] SMP [ 3972.384053] Modules linked in: binfmt_misc(E) dm_crypt(E) lcs(E) ctcm(E) fsm(E) algif_skcipher(E) af_alg(E) nfsv3(E) nfs_acl(E) nfs(E) lockd(E) grace(E) sctp(E) quota_v2(E) quota_tree(E) ntfs(E) vfat(E) fat(E) overlay(E) loop(E) dm_service_time(E) kvm(E) xt_CHECKSUM(E) xt_MASQUERADE(E) xt_tcpudp(E) ip6t_rpfilter(E) ip6t_REJECT(E) nf_reject_ipv6(E) ipt_REJECT(E) nf_reject_ipv4(E) xt_conntrack(E) ip6table_nat(E) ip6table_mangle(E) ip6table_raw(E) tun(E) ip6table_security(E) bridge(E) iptable_nat(E) nf_nat(E) stp(E) llc(E) iptable_mangle(E) iptable_raw(E) iptable_security(E) nf_conntrack(E) nf_defrag_ipv6(E) nf_defrag_ipv4(E) ip_set(E) nfnetlink(E) ip6table_filter(E) ip6_tables(E) iptable_filter(E) ip_tables(E) x_tables(E) sunrpc(E) dm_multipath(E) dm_mod(E) scsi_dh_rdac(E) scsi_dh_emc(E) scsi_dh_alua(E) s390_trng(E) ghash_s390(E) prng(E) aes_s390(E) des_s390(E) des_generic(E) sha512_s390(E) sha1_s390(E) vfio_ccw(E) vfio_mdev(E) mdev(E) vfio_iommu_type1(E) vfio(E) eadm_sch(E) sch_fq_codel(E) [ 3972.384076] sha256_s390(E) sha_common(E) pkey(E) zcrypt(E) rng_core(E) autofs4(E) [last unloaded: dummy_del_mod] [ 3972.384084] CPU: 17 PID: 45118 Comm: psvc-ioctl-bpf1 Tainted: G OE 5.3.0-20190813.rc4.git0.8e72ac275c63.301.fc30.s390x+next #1 [ 3972.384086] Hardware name: IBM 3906 M04 704 (LPAR) [ 3972.384087] Krnl PSW : 0704c0018000 (0x0) [ 3972.384090]R:0 T:1 IO:1 EX:1 Key:0 M:1 W:0 P:0 AS:3 CC:0 PM:0 RI:0 EA:3 [ 3972.384103] Krnl GPRS: 03e004c0fb90 0001f912abf0 000197b36800 [ 3972.384104]000197b36810 0001 0001 000197b36810 [ 3972.384105]736ae3a0 0001 0001f912abf0 000197b36800 [ 3972.384106]00013aff 73c625a8 734a1486 03e004c0fbc8 [ 3972.384110] Krnl Code:>: illegal 0002: illegal 0004: illegal 0006: illegal 0008: illegal 000a: illegal 000c: illegal 000e: illegal [ 3972.384116] Call Trace: [ 3972.384122] ([<734a1486>] do_dentry_open+0x206/0x3c0) [ 3972.384125] [<734b8c1e>] do_last+0x16e/0x918 [ 3972.384126] [<734b944e>] path_openat+0x86/0x2b8 [ 3972.384128] [<734baa64>] do_filp_open+0x7c/0xf8 [ 3972.384129] [<734a3484>] do_sys_open+0x18c/0x258 [ 3972.384134] [<73c457cc>] system_call+0xd8/0x2c8 [ 3972.384135] Last Breaking-Event-Address: [ 3972.384139] [<736ae3fa>] default_open_file+0x5a/0x78 [ 3972.384141] Kernel panic - not syncing: Fatal exception: panic_on_oops Which correspond to: fs/tracefs/inode.c:46 static int default_open_file(struct inode *inode, struct file *filp) 45 real_fops = dentry->d_fsdata; 46 return real_fops->open(inode, filp); Commit which introduces the problem: commit 757ff7244358406dd16a7f5f623ca40ed27c603c Author: Matthew Garrett AuthorDate: Wed Aug 7 17:07:19 2019 -0700 Commit: James Morris CommitDate: Fri Aug 9 22:23:58 2019 -0700 tracefs: Restrict tracefs when the kernel is locked down Tracefs may release more information about the kernel than desirable, so restrict it when the kernel is locked down in confidentiality mode by preventing open(). Signed-off-by: Matthew Garrett Reviewed-by: Steven Rostedt (VMware) Signed-off-by: James Morris --- fs/tracefs/inode.c | 40 +++- include/linux/security.h | 1 + security/lockdown/lockdown.c | 1 + 3 files changed, 41 insertions(+), 1 deletion(-) Using default s390 config, where # CONFIG_SECURITY_LOCKDOWN_LSM is not set -- ⢋⡀⣀⠹ ⠠⣶⡦⠀ ⣿⣿⣿⠏⣴⣮⣴⣧⠈⢿⣿⣿ ⣿⣿⡏⢰⣿⠖⣠⣿⡆⠈
Re: linux-next: Tree for Aug 13
On Tue, Aug 13, 2019 at 02:41:55PM +0200, Vasily Gorbik wrote: > On Tue, Aug 13, 2019 at 07:19:24PM +1000, Stephen Rothwell wrote: > > Merging security/next-testing (a4848e06f9af Merge branch 'next-lockdown' > > into next-testing) > > CONFLICT (content): Merge conflict in kernel/trace/trace_kprobe.c > > CONFLICT (content): Merge conflict in fs/tracefs/inode.c > > Applying: early_security_init() needs a stub got !CONFIG_SECURITY > > Hi all, > > next-lockdown causes panic on s390 when doing: > cat /sys/kernel/debug/tracing/events/syscalls/sys_enter_read/id > > [ 3972.384027] Unable to handle kernel pointer dereference in virtual kernel > address space > [ 3972.384031] Failing address: TEID: 0887 > [ 3972.384032] Fault in home space mode while using kernel ASCE. > [ 3972.384033] AS:744cc007 R3:0001fffd0007 S:0001fffd6000 > P:013d > [ 3972.384051] Oops: 0004 ilc:1 [#1] SMP > [ 3972.384053] Modules linked in: binfmt_misc(E) dm_crypt(E) lcs(E) ctcm(E) > fsm(E) algif_skcipher(E) af_alg(E) nfsv3(E) nfs_acl(E) nfs(E) lockd(E) > grace(E) sctp(E) quota_v2(E) quota_tree(E) ntfs(E) vfat(E) fat(E) overlay(E) > loop(E) dm_service_time(E) kvm(E) xt_CHECKSUM(E) xt_MASQUERADE(E) > xt_tcpudp(E) ip6t_rpfilter(E) ip6t_REJECT(E) nf_reject_ipv6(E) ipt_REJECT(E) > nf_reject_ipv4(E) xt_conntrack(E) ip6table_nat(E) ip6table_mangle(E) > ip6table_raw(E) tun(E) ip6table_security(E) bridge(E) iptable_nat(E) > nf_nat(E) stp(E) llc(E) iptable_mangle(E) iptable_raw(E) iptable_security(E) > nf_conntrack(E) nf_defrag_ipv6(E) nf_defrag_ipv4(E) ip_set(E) nfnetlink(E) > ip6table_filter(E) ip6_tables(E) iptable_filter(E) ip_tables(E) x_tables(E) > sunrpc(E) dm_multipath(E) dm_mod(E) scsi_dh_rdac(E) scsi_dh_emc(E) > scsi_dh_alua(E) s390_trng(E) ghash_s390(E) prng(E) aes_s390(E) des_s390(E) > des_generic(E) sha512_s390(E) sha1_s390(E) vfio_ccw(E) vfio_mdev(E) mdev(E) > vfio_iommu_type1(E) vfio(E) eadm_sch(E) sch_fq_codel(E) > [ 3972.384076] sha256_s390(E) sha_common(E) pkey(E) zcrypt(E) rng_core(E) > autofs4(E) [last unloaded: dummy_del_mod] > [ 3972.384084] CPU: 17 PID: 45118 Comm: psvc-ioctl-bpf1 Tainted: G > OE 5.3.0-20190813.rc4.git0.8e72ac275c63.301.fc30.s390x+next #1 > [ 3972.384086] Hardware name: IBM 3906 M04 704 (LPAR) > [ 3972.384087] Krnl PSW : 0704c0018000 (0x0) > [ 3972.384090]R:0 T:1 IO:1 EX:1 Key:0 M:1 W:0 P:0 AS:3 CC:0 PM:0 > RI:0 EA:3 > [ 3972.384103] Krnl GPRS: 03e004c0fb90 0001f912abf0 > 000197b36800 > [ 3972.384104]000197b36810 0001 0001 > 000197b36810 > [ 3972.384105]736ae3a0 0001 0001f912abf0 > 000197b36800 > [ 3972.384106]00013aff 73c625a8 734a1486 > 03e004c0fbc8 > [ 3972.384110] Krnl Code:>: illegal > 0002: illegal > 0004: illegal > 0006: illegal > 0008: illegal > 000a: illegal > 000c: illegal > 000e: illegal > [ 3972.384116] Call Trace: > [ 3972.384122] ([<734a1486>] do_dentry_open+0x206/0x3c0) > [ 3972.384125] [<734b8c1e>] do_last+0x16e/0x918 > [ 3972.384126] [<734b944e>] path_openat+0x86/0x2b8 > [ 3972.384128] [<734baa64>] do_filp_open+0x7c/0xf8 > [ 3972.384129] [<734a3484>] do_sys_open+0x18c/0x258 > [ 3972.384134] [<73c457cc>] system_call+0xd8/0x2c8 > [ 3972.384135] Last Breaking-Event-Address: > [ 3972.384139] [<736ae3fa>] default_open_file+0x5a/0x78 > [ 3972.384141] Kernel panic - not syncing: Fatal exception: panic_on_oops > > Which correspond to: > fs/tracefs/inode.c:46 > static int default_open_file(struct inode *inode, struct file *filp) > 45 real_fops = dentry->d_fsdata; > 46 return real_fops->open(inode, filp); > > Commit which introduces the problem: > commit 757ff7244358406dd16a7f5f623ca40ed27c603c > Author: Matthew Garrett > AuthorDate: Wed Aug 7 17:07:19 2019 -0700 > Commit: James Morris > CommitDate: Fri Aug 9 22:23:58 2019 -0700 > > tracefs: Restrict tracefs when the kernel is locked down > > Tracefs may
[PATCH] tracefs: avoid crash when open callback is not set
Some tracefs files, e.g. tracing/events/syscalls/*/id do not define "open" file operation. Yet commit 757ff7244358 ("tracefs: Restrict tracefs when the kernel is locked down") introduces "open" proxy which unconditionally calls original open callback, which causes kernel crash when the callback is 0. Fix that by simply returning 0, if open callback is not set. Fixes: 757ff7244358 ("tracefs: Restrict tracefs when the kernel is locked down") Signed-off-by: Vasily Gorbik --- fs/tracefs/inode.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c index 12a325fb4cbd..77407632c916 100644 --- a/fs/tracefs/inode.c +++ b/fs/tracefs/inode.c @@ -43,7 +43,9 @@ static int default_open_file(struct inode *inode, struct file *filp) return ret; real_fops = dentry->d_fsdata; - return real_fops->open(inode, filp); + if (real_fops->open) + return real_fops->open(inode, filp); + return 0; } static ssize_t default_read_file(struct file *file, char __user *buf, -- ⢋⡀⣀⠹ ⠠⣶⡦⠀ ⣿⣿⣿⠏⣴⣮⣴⣧⠈⢿⣿⣿ ⣿⣿⡏⢰⣿⠖⣠⣿⡆⠈⣿⣿ ⣿⢛⣵⣄⠙⣶⣶⡟⣅⣠⠹⣿ ⣿⣜⣛⠻⢎⣉⣉⣀⠿⣫⣵⣿
Re: linux-next: Tree for Aug 13
On Tue, Aug 13, 2019 at 10:56:45AM -0400, Steven Rostedt wrote: > > This looks related to what Marek posted. > > > https://lore.kernel.org/linux-security-module/3028ed35-3b6d-459f-f3c8-103c5636f...@samsung.com/ > > Care to apply the change he suggested to see if it fixes the issue for > you. If it does, Marek, can you make an official patch? > > -- Steve Right, same issue - same fix. Oh well, at least I got a bit more familiar with the code. -- ⢋⡀⣀⠹ ⠠⣶⡦⠀ ⣿⣿⣿⠏⣴⣮⣴⣧⠈⢿⣿⣿ ⣿⣿⡏⢰⣿⠖⣠⣿⡆⠈⣿⣿ ⣿⢛⣵⣄⠙⣶⣶⡟⣅⣠⠹⣿ ⣿⣜⣛⠻⢎⣉⣉⣀⠿⣫⣵⣿
[GIT PULL] s390 updates for 5.3-rc4
Hello Linus, please pull s390 changes for 5.3-rc4. Thank you, Vasily The following changes since commit e21a712a9685488f5ce80495b37b9fdbe96c230d: Linux 5.3-rc3 (2019-08-04 18:40:12 -0700) are available in the Git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git tags/s390-5.3-5 for you to fetch changes up to 404861e15b5fa7edbab22400f9174c1a21fde731: s390/vdso: map vdso also for statically linked binaries (2019-08-09 11:03:28 +0200) s390 updates for 5.3-rc4 - Map vdso also for statically linked binaries like all other architectures. - Fix no .bss usage compile-time check to account common objects with the help of binutils size tool. Top level Makefile change acked-by Masahiro. - A fix to make perf happy with _etext symbol type. - Fix dump_pagetables which is broken since p*d_offset implementation change to comply with mm/gup.c expectations. - Revert memory sharing for diag calls in protected virtualization, since this is not required after all. - Couple of other minor code cleanups. Heiko Carstens (1): s390/vdso: map vdso also for statically linked binaries Vasily Gorbik (8): s390/protvirt: avoid memory sharing for diag 308 set/store s390/mm: fix dump_pagetables top level page table walking s390/setup: adjust start_code of init_mm to _text s390/unwind: remove stack recursion warning s390/head64: cleanup unused labels s390: put _stext and _etext into .text section kbuild: add OBJSIZE variable for the size tool s390/build: use size command to perform empty .bss check Makefile | 7 --- arch/s390/boot/ipl_parm.c | 2 -- arch/s390/kernel/dumpstack.c | 6 +- arch/s390/kernel/head64.S | 7 --- arch/s390/kernel/ipl.c| 9 - arch/s390/kernel/setup.c | 3 +-- arch/s390/kernel/vdso.c | 5 - arch/s390/kernel/vmlinux.lds.S| 10 -- arch/s390/mm/dump_pagetables.c| 12 ++-- arch/s390/scripts/Makefile.chkbss | 3 +-- 10 files changed, 17 insertions(+), 47 deletions(-) diff --git a/Makefile b/Makefile index 23cdf1f41364..01683ba84d4c 100644 --- a/Makefile +++ b/Makefile @@ -419,6 +419,7 @@ NM = $(CROSS_COMPILE)nm STRIP = $(CROSS_COMPILE)strip OBJCOPY= $(CROSS_COMPILE)objcopy OBJDUMP= $(CROSS_COMPILE)objdump +OBJSIZE= $(CROSS_COMPILE)size PAHOLE = pahole LEX= flex YACC = bison @@ -475,9 +476,9 @@ GCC_PLUGINS_CFLAGS := CLANG_FLAGS := export ARCH SRCARCH CONFIG_SHELL HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE AS LD CC -export CPP AR NM STRIP OBJCOPY OBJDUMP PAHOLE KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS -export MAKE LEX YACC AWK INSTALLKERNEL PERL PYTHON PYTHON2 PYTHON3 UTS_MACHINE -export HOSTCXX KBUILD_HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS +export CPP AR NM STRIP OBJCOPY OBJDUMP OBJSIZE PAHOLE LEX YACC AWK INSTALLKERNEL +export PERL PYTHON PYTHON2 PYTHON3 CHECK CHECKFLAGS MAKE UTS_MACHINE HOSTCXX +export KBUILD_HOSTCXXFLAGS KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS LDFLAGS_MODULE export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS KBUILD_LDFLAGS export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE diff --git a/arch/s390/boot/ipl_parm.c b/arch/s390/boot/ipl_parm.c index 3c49bde8aa5e..b8aa6a9f937b 100644 --- a/arch/s390/boot/ipl_parm.c +++ b/arch/s390/boot/ipl_parm.c @@ -48,9 +48,7 @@ void store_ipl_parmblock(void) { int rc; - uv_set_shared(__pa(&ipl_block)); rc = __diag308(DIAG308_STORE, &ipl_block); - uv_remove_shared(__pa(&ipl_block)); if (rc == DIAG308_RC_OK && ipl_block.hdr.version <= IPL_MAX_SUPPORTED_VERSION) ipl_block_valid = 1; diff --git a/arch/s390/kernel/dumpstack.c b/arch/s390/kernel/dumpstack.c index ac06c3949ab3..34bdc60c0b11 100644 --- a/arch/s390/kernel/dumpstack.c +++ b/arch/s390/kernel/dumpstack.c @@ -114,12 +114,8 @@ int get_stack_info(unsigned long sp, struct task_struct *task, * If it comes up a second time then there's something wrong going on: * just break out and report an unknown stack type. */ - if (*visit_mask & (1UL << info->type)) { - printk_deferred_once(KERN_WARNING - "WARNING: stack recursion on stack type %d\n", - info->type); + if (*visit_mask & (1UL << info->type)) goto unknown; - } *visit_mask |= 1UL << info->type; return 0; unknown: diff --git a/arch/s390/kernel/head64.S b/arch/s390/kernel/head64.S index 5aea1a527443..f384a18e6c26 100644 --- a/arch/s390/kernel/head64.S +++ b/arch/s390/kernel/head64.S @@ -60,12
Re: [PATCH v3 1/3] kasan: support backing vmalloc space with real shadow memory
On Wed, Jul 31, 2019 at 05:15:48PM +1000, Daniel Axtens wrote: > Hook into vmalloc and vmap, and dynamically allocate real shadow > memory to back the mappings. > > Most mappings in vmalloc space are small, requiring less than a full > page of shadow space. Allocating a full shadow page per mapping would > therefore be wasteful. Furthermore, to ensure that different mappings > use different shadow pages, mappings would have to be aligned to > KASAN_SHADOW_SCALE_SIZE * PAGE_SIZE. > > Instead, share backing space across multiple mappings. Allocate > a backing page the first time a mapping in vmalloc space uses a > particular page of the shadow region. Keep this page around > regardless of whether the mapping is later freed - in the mean time > the page could have become shared by another vmalloc mapping. > > This can in theory lead to unbounded memory growth, but the vmalloc > allocator is pretty good at reusing addresses, so the practical memory > usage grows at first but then stays fairly stable. > > This requires architecture support to actually use: arches must stop > mapping the read-only zero page over portion of the shadow region that > covers the vmalloc space and instead leave it unmapped. > > This allows KASAN with VMAP_STACK, and will be needed for architectures > that do not have a separate module space (e.g. powerpc64, which I am > currently working on). It also allows relaxing the module alignment > back to PAGE_SIZE. > > Link: https://bugzilla.kernel.org/show_bug.cgi?id=202009 > Signed-off-by: Daniel Axtens > > --- Acked-by: Vasily Gorbik I've added s390 specific kasan init part and the whole thing looks good! Unfortunately I also had to make additional changes in s390 code, so s390 part would go later through s390 tree. But looking forward seeing your patch series upstream.
[GIT PULL] s390 updates for 5.3-rc3
Hello Linus, please pull s390 changes for 5.3-rc3. Thank you, Vasily The following changes since commit 609488bc979f99f805f34e9a32c1e3b71179d10b: Linux 5.3-rc2 (2019-07-28 12:47:02 -0700) are available in the Git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git tags/s390-5.3-4 for you to fetch changes up to 3cdd98606750a5a1d1c8bcda5b481cb86ed67b3b: s390/zcrypt: adjust switch fall through comments for -Wimplicit-fallthrough (2019-08-02 13:58:23 +0200) s390 updates for 5.3-rc3 - Default configs updates. - Minor qdio cleanup. - Sparse warnings fixes. - Implicit-fallthrough warnings fixes. Heiko Carstens (3): s390: update configs s390/mm: add fallthrough annotations s390/tape: add fallthrough annotations Julian Wiedmann (1): s390: clean up qdio.h Vasily Gorbik (8): s390/boot: add missing declarations and includes s390/lib: add missing include s390/perf: make cf_diag_csd static s390/kexec: add missing include to machine_kexec_reloc.c s390/mm: make gmap_test_and_clear_dirty_pmd static s390/3215: add switch fall through comment for -Wimplicit-fallthrough vfio-ccw: make vfio_ccw_async_region_ops static s390/zcrypt: adjust switch fall through comments for -Wimplicit-fallthrough arch/s390/boot/boot.h | 1 + arch/s390/boot/kaslr.c | 1 + arch/s390/configs/debug_defconfig | 330 - arch/s390/configs/defconfig| 233 ++- arch/s390/configs/zfcpdump_defconfig | 31 ++-- arch/s390/include/asm/qdio.h | 10 +- arch/s390/include/asm/setup.h | 1 + arch/s390/kernel/machine_kexec_reloc.c | 1 + arch/s390/kernel/perf_cpum_cf_diag.c | 2 +- arch/s390/lib/xor.c| 1 + arch/s390/mm/fault.c | 3 + arch/s390/mm/gmap.c| 4 +- drivers/s390/char/con3215.c| 1 + drivers/s390/char/tape_core.c | 3 + drivers/s390/cio/vfio_ccw_async.c | 2 +- drivers/s390/crypto/ap_queue.c | 1 + drivers/s390/crypto/zcrypt_msgtype6.c | 17 +- 17 files changed, 392 insertions(+), 250 deletions(-)
[PATCH 2/2] s390/build: use size command to perform empty .bss check
Currently empty .bss checks performed do not pay attention to "common objects" in object files which end up in .bss section eventually. The "size" tool is a part of binutils and since version 2.18 provides "--common" command line option, which allows to account "common objects" sizes in .bss section size. Utilize "size --common" to perform accurate check that .bss section is unused. Besides that the size tool handles object files without .bss section gracefully and doesn't require additional objdump run. The linux kernel requires binutils 2.20 since 4.13. Kbuild exports OBJSIZE to reference the right size tool. Signed-off-by: Vasily Gorbik --- arch/s390/scripts/Makefile.chkbss | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/s390/scripts/Makefile.chkbss b/arch/s390/scripts/Makefile.chkbss index 884a9caff5fb..ba1d7a8a242f 100644 --- a/arch/s390/scripts/Makefile.chkbss +++ b/arch/s390/scripts/Makefile.chkbss @@ -11,8 +11,7 @@ chkbss: $(addprefix $(obj)/, $(chkbss-files)) quiet_cmd_chkbss = CHKBSS $< cmd_chkbss = \ - if $(OBJDUMP) -h $< | grep -q "\.bss" && \ - ! $(OBJDUMP) -j .bss -w -h $< | awk 'END { if ($$3) exit 1 }'; then \ + if ! $(OBJSIZE) --common $< | awk 'END { if ($$3) exit 1 }'; then \ echo "error: $< .bss section is not empty" >&2; exit 1; \ fi; \ touch $@; -- 2.21.0
[PATCH 1/2] kbuild: add OBJSIZE variable for the size tool
Define and export OBJSIZE variable for "size" tool from binutils to be used in architecture specific Makefiles (naming the variable just "SIZE" would be too risky). In particular this tool is useful to perform checks that early boot code is not using bss section (which might have not been zeroed yet or intersects with initrd or other files boot loader might have put right after the linux kernel). Signed-off-by: Vasily Gorbik --- Makefile | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index fa0fbe7851ea..ff4cff29fe46 100644 --- a/Makefile +++ b/Makefile @@ -419,6 +419,7 @@ NM = $(CROSS_COMPILE)nm STRIP = $(CROSS_COMPILE)strip OBJCOPY= $(CROSS_COMPILE)objcopy OBJDUMP= $(CROSS_COMPILE)objdump +OBJSIZE= $(CROSS_COMPILE)size PAHOLE = pahole LEX= flex YACC = bison @@ -474,9 +475,9 @@ KBUILD_LDFLAGS := GCC_PLUGINS_CFLAGS := export ARCH SRCARCH CONFIG_SHELL HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE AS LD CC -export CPP AR NM STRIP OBJCOPY OBJDUMP PAHOLE KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS -export MAKE LEX YACC AWK INSTALLKERNEL PERL PYTHON PYTHON2 PYTHON3 UTS_MACHINE -export HOSTCXX KBUILD_HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS +export CPP AR NM STRIP OBJCOPY OBJDUMP OBJSIZE PAHOLE LEX YACC AWK INSTALLKERNEL +export PERL PYTHON PYTHON2 PYTHON3 CHECK CHECKFLAGS MAKE UTS_MACHINE HOSTCXX +export KBUILD_HOSTCXXFLAGS KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS LDFLAGS_MODULE export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS KBUILD_LDFLAGS export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE -- 2.21.0
Re: [PATCH 2/2] s390/build: use size command to perform empty .bss check
On Wed, Aug 07, 2019 at 11:33:40AM +0900, Masahiro Yamada wrote: > On Tue, Aug 6, 2019 at 7:56 PM Vasily Gorbik wrote: > > > > Currently empty .bss checks performed do not pay attention to "common > > objects" in object files which end up in .bss section eventually. > > > > The "size" tool is a part of binutils and since version 2.18 provides > > "--common" command line option, which allows to account "common objects" > > sizes in .bss section size. Utilize "size --common" to perform accurate > > check that .bss section is unused. Besides that the size tool handles > > object files without .bss section gracefully and doesn't require > > additional objdump run. > > > > The linux kernel requires binutils 2.20 since 4.13. > > > > Kbuild exports OBJSIZE to reference the right size tool. > > > > Signed-off-by: Vasily Gorbik > > --- > > arch/s390/scripts/Makefile.chkbss | 3 +-- > > 1 file changed, 1 insertion(+), 2 deletions(-) > > > > diff --git a/arch/s390/scripts/Makefile.chkbss > > b/arch/s390/scripts/Makefile.chkbss > > index 884a9caff5fb..ba1d7a8a242f 100644 > > --- a/arch/s390/scripts/Makefile.chkbss > > +++ b/arch/s390/scripts/Makefile.chkbss > > @@ -11,8 +11,7 @@ chkbss: $(addprefix $(obj)/, $(chkbss-files)) > > > > quiet_cmd_chkbss = CHKBSS $< > >cmd_chkbss = \ > > - if $(OBJDUMP) -h $< | grep -q "\.bss" && \ > > - ! $(OBJDUMP) -j .bss -w -h $< | awk 'END { if ($$3) exit 1 }'; > > then \ > > + if ! $(OBJSIZE) --common $< | awk 'END { if ($$3) exit 1 }'; then \ > > While you are touching this line, > you may also want to replace 'awk' with $(AWK), > which is defined in the top-level Makefile. Indeed, thank you!
Re: [PATCH 1/2] kbuild: add OBJSIZE variable for the size tool
On Wed, Aug 07, 2019 at 11:32:04AM +0900, Masahiro Yamada wrote: > Hi. > > On Tue, Aug 6, 2019 at 7:56 PM Vasily Gorbik wrote: > > > > Define and export OBJSIZE variable for "size" tool from binutils to be > > used in architecture specific Makefiles (naming the variable just "SIZE" > > would be too risky). In particular this tool is useful to perform checks > > that early boot code is not using bss section (which might have not been > > zeroed yet or intersects with initrd or other files boot loader might > > have put right after the linux kernel). > > > > Signed-off-by: Vasily Gorbik > > I think you want to apply both to the s390 tree. If so, > > Acked-by: Masahiro Yamada > > Thanks. Yes, I would take it via s390 tree. Thank you!
Re: [PATCH] s390/cio: introduce driver_override on the css bus
On Wed, Jul 03, 2019 at 04:55:06PM +0200, Cornelia Huck wrote: > On Mon, 24 Jun 2019 09:17:40 +0200 > Cornelia Huck wrote: > > > On Fri, 21 Jun 2019 18:19:36 +0200 (CEST) > > Sebastian Ott wrote: > > > > > On Thu, 13 Jun 2019, Cornelia Huck wrote: > > > > Sometimes, we want to control which of the matching drivers > > > > binds to a subchannel device (e.g. for subchannels we want to > > > > handle via vfio-ccw). > > > > > > > > For pci devices, a mechanism to do so has been introduced in > > > > 782a985d7af2 ("PCI: Introduce new device binding path using > > > > pci_dev.driver_override"). It makes sense to introduce the > > > > driver_override attribute for subchannel devices as well, so > > > > that we can easily extend the 'driverctl' tool (which makes > > > > use of the driver_override attribute for pci). > > > > > > > > Note that unlike pci we still require a driver override to > > > > match the subchannel type; matching more than one subchannel > > > > type is probably not useful anyway. > > > > > > > > Signed-off-by: Cornelia Huck > > > > > > Reviewed-by: Sebastian Ott > > > > > > Should I take that via our git tree or do you have other patches > > > depending > > > on this one? > > > > > > > No, this patch is stand-alone; everything else is happening in user > > space, so taking it via your tree would be great. Thanks! > > Friendly ping (I don't see it on s390/features yet; or is this going > via some other path?) > It is there now. Just waited until latest ci results to push the branch. Sorry for delay.
[PATCH] kallsyms: exclude kasan local symbols on s390
gcc asan instrumentation emits the following sequence to store frame pc when the kernel is built with CONFIG_RELOCATABLE: debug/vsprintf.s: .section.data.rel.ro.local,"aw" .align 8 .LC3: .quad .LASANPC4826@GOTOFF .text .align 8 .type number, @function number: .LASANPC4826: and in case reloc is issued for LASANPC label it also gets into .symtab with the same address as actual function symbol: $ nm -n vmlinux | grep 01397150 01397150 t .LASANPC4826 01397150 t number In the end kernel backtraces are almost unreadable: [ 143.748476] Call Trace: [ 143.748484] ([<2da3e62c>] .LASANPC2671+0x114/0x190) [ 143.748492] [<2eca1a58>] .LASANPC2612+0x110/0x160 [ 143.748502] [<2de9d830>] print_address_description+0x80/0x3b0 [ 143.748511] [<2de9dd64>] __kasan_report+0x15c/0x1c8 [ 143.748521] [<2ecb56d4>] strrchr+0x34/0x60 [ 143.748534] [<03ff800a9a40>] kasan_strings+0xb0/0x148 [test_kasan] [ 143.748547] [<03ff800a9bba>] kmalloc_tests_init+0xe2/0x528 [test_kasan] [ 143.748555] [<2da2117c>] .LASANPC4069+0x354/0x748 [ 143.748563] [<2dbfbb16>] do_init_module+0x136/0x3b0 [ 143.748571] [<2dbff3f4>] .LASANPC3191+0x2164/0x25d0 [ 143.748580] [<2dbffc4c>] .LASANPC3196+0x184/0x1b8 [ 143.748587] [<2ecdf2ec>] system_call+0xd8/0x2d8 Since LASANPC labels are not even unique and get into .symtab only due to relocs filter them out in kallsyms. Signed-off-by: Vasily Gorbik --- scripts/kallsyms.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index e17837f1d3f2..ae6504d07fd6 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -150,6 +150,9 @@ static int read_symbol(FILE *in, struct sym_entry *s) /* exclude debugging symbols */ else if (stype == 'N' || stype == 'n') return -1; + /* exclude s390 kasan local symbols */ + else if (!strncmp(sym, ".LASANPC", 8)) + return -1; /* include the type field in the symbol name, so that it gets * compressed together */ -- 2.21.0
[PATCH] s390: ap: constify parameter of match_apqn
From: Christian Borntraeger commit 92ce7e83b4e5 ("driver_find_device: Unify the match function with class_find_device()") changed the prototype of driver_find_device to use a const void pointer. Change match_apqn accordingly. Fixes: ec89b55e3bce ("s390: ap: implement PAPQ AQIC interception in kernel") Signed-off-by: Christian Borntraeger Signed-off-by: Vasily Gorbik --- drivers/s390/crypto/vfio_ap_ops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c index 2c9fb1423a39..7e85ba7c6ef0 100644 --- a/drivers/s390/crypto/vfio_ap_ops.c +++ b/drivers/s390/crypto/vfio_ap_ops.c @@ -26,7 +26,7 @@ static int vfio_ap_mdev_reset_queues(struct mdev_device *mdev); -static int match_apqn(struct device *dev, void *data) +static int match_apqn(struct device *dev, const void *data) { struct vfio_ap_queue *q = dev_get_drvdata(dev); -- 2.21.0
[GIT PULL] s390 patches for the 5.3 merge window
m: force swiotlb for protected virtualization s390/cio: introduce DMA pools to cio s390/cio: add basic protected virtualization support s390/airq: use DMA memory for adapter interrupts virtio/s390: use cacheline aligned airq bit vectors virtio/s390: add indirection to indicators access virtio/s390: use DMA memory for ccw I/O and classic notifiers virtio/s390: make airq summary indicators DMA Harald Freudenberger (1): s390/zcrypt: support special flagged EP11 cprbs Heiko Carstens (11): Merge tag 'vfio-ccw-20190603' of https://git.kernel.org/.../kvms390/vfio-ccw into features s390: enforce CONFIG_SMP s390: enforce CONFIG_HOTPLUG_CPU s390/boot: disable address-of-packed-member warning s390/jump_label: remove unused structure definition s390/kdump: get rid of compile warning processor: remove spin_cpu_yield processor: get rid of cpu_relax_yield s390: replace defconfig with performance_defconfig s390/sclp: remove call home support s390: fix stfle zero padding Julian Wiedmann (4): s390/qdio: handle PENDING state for QEBSM devices s390/cio: move struct node_descriptor to cio.h s390/qdio: (re-)initialize tiqdio list entries s390/qdio: don't touch the dsci in tiqdio_add_input_queues() Krzysztof Kozlowski (1): s390/configs: remove useless UEVENT_HELPER_PATH Martin Schwidefsky (4): s390/jump_label: replace stop_machine with smp_call_function s390/disassembler: update opcode table s390: improve wait logic of stop_machine Update default configuration Masahiro Yamada (6): s390: do not pass $(LINUXINCLUDE) to gen_opcode_table.c s390: drop unneeded -Wall addition from tools Makefile s390: drop redundant directory creation from tools Makefile s390: drop meaningless 'targets' from tools Makefile s390/purgatory: update .gitignore s390: fix unrecognized __aligned() in uapi header Mauro Carvalho Chehab (3): docs: Debugging390.txt: convert table to ascii artwork docs: s390: convert docs to ReST and rename to *.rst s390: include/asm/debug.h add kerneldoc markups Pierre Morel (4): s390: ap: kvm: add PQAP interception for AQIC vfio: ap: register IOMMU VFIO notifier s390: ap: implement PAPQ AQIC interception in kernel s390: ap: kvm: Enable PQAP/AQIC facility for the guest Sebastian Ott (3): s390/cio: fix kdoc for tiqdio_thinint_handler s390/pci: deal with devices that have no support for MIO instructions s390/pci: correctly handle MIO opt-out Steffen Maier (3): docs: s390: restore important non-kdoc parts of s390dbf.rst docs: s390: unify and update s390dbf kdocs at debug.c docs: s390: s390dbf: typos and formatting, update crash command Vasily Gorbik (6): RAID/s390: remove invalid 'r' inline asm operand modifier s390/traps: simplify data exception handler Merge tag 'vfio-ccw-20190621' of https://git.kernel.org/.../kvms390/vfio-ccw into features s390/kasan: avoid false positives during stack unwind s390/unwind: cleanup unused READ_ONCE_TASK_STACK Merge tag 'vfio-ccw-20190705' of https://git.kernel.org/.../kvms390/vfio-ccw into features xiaolinkui (1): s390/idal: use struct_size() in kmalloc() Documentation/ABI/testing/sysfs-bus-css| 23 + Documentation/admin-guide/kernel-parameters.txt|4 +- Documentation/driver-api/s390-drivers.rst |4 +- Documentation/s390/{3270.txt => 3270.rst} | 85 +- Documentation/s390/Debugging390.txt| 2142 Documentation/s390/{cds.txt => cds.rst}| 368 +-- Documentation/s390/{CommonIO => common_io.rst} | 49 +- Documentation/s390/{DASD => dasd.rst} | 33 +- Documentation/s390/debugging390.rst| 2613 .../s390/{driver-model.txt => driver-model.rst}| 179 +- Documentation/s390/index.rst | 30 + .../s390/{monreader.txt => monreader.rst} | 85 +- Documentation/s390/{qeth.txt => qeth.rst} | 36 +- Documentation/s390/s390dbf.rst | 487 Documentation/s390/s390dbf.txt | 667 - Documentation/s390/text_files.rst | 11 + Documentation/s390/{vfio-ap.txt => vfio-ap.rst}| 499 ++-- Documentation/s390/{vfio-ccw.txt => vfio-ccw.rst} | 92 +- Documentation/s390/{zfcpdump.txt => zfcpdump.rst} |2 + Documentation/sysctl/kernel.txt| 16 - MAINTAINERS|4 +- arch/powerpc/include/asm/processor.h |2 - arch/s390/Kconfig | 41 +- arch/s390/Makefile |1 + arch/s390/configs/debug_defc
Re: [PATCH] s390/zcrypt: remove the exporting of ap_query_configuration
On Wed, Jul 10, 2019 at 08:44:53AM +0200, Harald Freudenberger wrote: > On 09.07.19 14:25, Denis Efremov wrote: > > The function ap_query_configuration is declared static and marked > > EXPORT_SYMBOL, which is at best an odd combination. Because the > > function is not used outside of the drivers/s390/crypto/ap_bus.c > > file it is defined in, this commit removes the EXPORT_SYMBOL() marking. > > > > Fixes: f1b0a4343c41 ("s390/zcrypt: Integrate ap_asm.h into > > include/asm/ap.h.") > > Fixes: 050349b5b71d ("s390/zcrypt: externalize AP config info query") > > Signed-off-by: Denis Efremov > > --- > > drivers/s390/crypto/ap_bus.c | 1 - > > 1 file changed, 1 deletion(-) > > > > diff --git a/drivers/s390/crypto/ap_bus.c b/drivers/s390/crypto/ap_bus.c > > index b9fc502c58c2..379e43b79006 100644 > > --- a/drivers/s390/crypto/ap_bus.c > > +++ b/drivers/s390/crypto/ap_bus.c > > @@ -208,7 +208,6 @@ static inline int ap_query_configuration(struct > > ap_config_info *info) > > return -EINVAL; > > return ap_qci(info); > > } > > -EXPORT_SYMBOL(ap_query_configuration); > > > > /** > > * ap_init_configuration(): Allocate and query configuration array. > This function was exported a while ago for KVM code. However, never used. > So removing the export is the right thing. Thanks Denis > > Heiko/Vasily will you pick this patch please? > > Reviewed-by: Harald Freudenberger > Applied, thanks.
[v4.17-rc5][bisected] be83bbf80682 breaks /proc/vmcore mmap
Greetings, be83bbf80682 "mmap: introduce sane default mmap limits" introduced a problem with mapping /proc/vmcore if it is bigger than 2gb. This breaks s390 kernel zfcpdump. But it should be a general problem. Please consider the following one-liner fix, if it makes sense. Vasily Gorbik (1): procfs: fix mmap() for /proc/vmcore fs/proc/inode.c | 1 + 1 file changed, 1 insertion(+) -- ⢀⡵⣤⡴⣅ 2.17.0 ⠏⢟⡛⣛⠏⠇ space invaders edition
[PATCH] procfs: fix mmap() for /proc/vmcore
Procfs does not set max file size (s_maxbytes) and ends up with default value of MAX_NON_LFS ((1UL<<31) - 1) Commit be83bbf80682 ("mmap: introduce sane default mmap limits") introduced "pgoff" limits checks for mmap, considering fs max file size as upper limit, which made it impossible to mmap /proc/vmcore file contents above 2Gb (/proc/vmcore appears to be the only procfs file supporting mmap). Reuse MAX_LFS_FILESIZE as procfs s_maxbytes value. Fixes: be83bbf80682 ("mmap: introduce sane default mmap limits") Signed-off-by: Vasily Gorbik --- fs/proc/inode.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/proc/inode.c b/fs/proc/inode.c index 2cf3b74391ca..de1b3b1da883 100644 --- a/fs/proc/inode.c +++ b/fs/proc/inode.c @@ -502,6 +502,7 @@ int proc_fill_super(struct super_block *s, void *data, int silent) /* User space would break if executables or devices appear on proc */ s->s_iflags |= SB_I_USERNS_VISIBLE | SB_I_NOEXEC | SB_I_NODEV; s->s_flags |= SB_NODIRATIME | SB_NOSUID | SB_NOEXEC; + s->s_maxbytes = MAX_LFS_FILESIZE; s->s_blocksize = 1024; s->s_blocksize_bits = 10; s->s_magic = PROC_SUPER_MAGIC; -- ⢀⡵⣤⡴⣅ 2.17.0 ⠏⢟⡛⣛⠏⠇ space invaders edition
Re: [PATCH] procfs: fix mmap() for /proc/vmcore
On Fri, May 18, 2018 at 09:12:56PM -0700, Linus Torvalds wrote: > On Fri, May 18, 2018 at 8:43 PM Al Viro wrote: > > > Not quite. The things like > > if (unlikely(*ppos >= inode->i_sb->s_maxbytes)) > > return 0; > > iov_iter_truncate(iter, inode->i_sb->s_maxbytes); > > protect most of the regular files (see mm/filemap.c). And for devices > (which is > > where the majority of crap ->read()/->write() is) it's obviously not > applicable - > > ->s_maxbytes of *what*? > > Yeah that "s_maxbytes of what" is I think the real issue. We should never > have made s_maxbytes be super-block specific: we should have made it be > per-inode, and then have inode_init_always() initialize it using something > like the file_mmap_size_max() logic. > > (So we'd still have a "sb_maxbytes" that filesystems would fill in, but it > would only be used as a "fill in inode value for regular files for this > superblock"). > > Then we could actually protect read/write properly, because many of the > nasty bugs have been in character device drivers. > > Oh well. It would still be a good thing to do some day, I suspect, but it's > clearly not the case now, and so s_maxbytes actually has much less coverage > than I was hoping for. > > (And thus also the problems with /proc/vmcore - it never saw s_maxbytes > limits before). > > Oh, well. The lack of any meaningful s_maxbytes coverage for proc obviously > means that my objections against Vasily's patch are mostly invalid. Even if > /proc does use "generic_file_llseek()" a lot and that should limit things > to 4G offsets, you can just use pread64/pwrite64 to see if you can screw up > the offset. > > I'd still prefer to limit the damage to just "vmcore". > > Something like the below COMPLETELY UNTESTED patch? Vasily? Would work, but file_mmap_size_max first checks if (S_ISREG(inode->i_mode)) return inode->i_sb->s_maxbytes; before if (file->f_mode & FMODE_UNSIGNED_OFFSET) return 0; so, as it is this patch does not fix the issue. > Linus > > fs/proc/vmcore.c | 8 > 1 file changed, 8 insertions(+) > > diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c > index a45f0af22a60..83278c547127 100644 > --- a/fs/proc/vmcore.c > +++ b/fs/proc/vmcore.c > @@ -491,7 +491,15 @@ static int mmap_vmcore(struct file *file, struct > vm_area_struct *vma) > } > #endif > > +/* Mark vmcore as being able and willing to do 64-bit mmaps */ > +static int vmcore_open(struct inode *inode, struct file *file) > +{ > + file->f_mode |= FMODE_UNSIGNED_OFFSET; > + return 0; > +} > + > static const struct file_operations proc_vmcore_operations = { > + .open = vmcore_open, > .read = read_vmcore, > .llseek = default_llseek, > .mmap = mmap_vmcore,
Re: [PATCH 1/1] s390/pci: Log new handle in clp_disable_fh()
On Thu, May 28, 2020 at 12:01:45PM +0200, Pierre Morel wrote: > > On 2020-05-28 11:08, Petr Tesarik wrote: > > Hi all, > > > > just a gentle ping. > > > > If the current behaviour (logging the original handle) was intended, > > then it was worth mentioning in the commit message for 17cdec960cf77, > > which made the change, but since that's no longer an option, I'd be > > happy with an explanation in email. > > > > Petr T > > > > On Fri, 22 May 2020 20:39:22 +0200 > > Petr Tesarik wrote: > > > > > After disabling a function, the original handle is logged instead of > > > the disabled handle. > > Hi Petr, > > Sorry for the delay, no doubt, you are right, the fh in zpci_dbg is the old > one and we should use the one in the zdev struct. > > Thanks, > Pierre > > Reviewed-by: Pierre Morel Applied, thanks
Re: [PATCH] mm/page_alloc: silence a KASAN false positive
On Wed, Jun 10, 2020 at 08:26:00AM -0400, Qian Cai wrote: > On Wed, Jun 10, 2020 at 07:54:50AM +0200, Dmitry Vyukov wrote: > > On Wed, Jun 10, 2020 at 7:22 AM Qian Cai wrote: > > > > > > kernel_init_free_pages() will use memset() on s390 to clear all pages > > > from kmalloc_order() which will override KASAN redzones because a > > > redzone was setup from the end of the allocation size to the end of the > > > last page. Silence it by not reporting it there. An example of the > > > report is, > > > > Interesting. The reason why we did not hit it on x86_64 is because > > clear_page is implemented in asm (arch/x86/lib/clear_page_64.S) and > > thus is not instrumented. Arm64 probably does the same. However, on > > s390 clear_page is defined to memset. > > clear_[high]page are pretty extensively used in the kernel. > > We can either do this, or make clear_page non instrumented on s390 as > > well to match the existing implicit assumption. The benefit of the > > current approach is that we can find some real use-after-free's and > > maybe out-of-bounds on clear_page. The downside is that we may need > > more of these annotations. Thoughts? > > Since we had already done the same thing in poison_page(), I suppose we > could do the same here. Also, clear_page() has been used in many places > on s390, and it is not clear to me if those are all safe like this. > > There might be more annotations required, so it probably up to s390 > maintainers (CC'ed) if they prefer not instrumenting clear_page() like > other arches. > Sorry for delay. I assume you tested it without CONFIG_JUMP_LABEL. I had to fix couple of things before I was able to use init_on_alloc=1 and init_on_free=1 boot options on s390 to reproduce KASAN problem: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h=v5.8-rc3&id=998f5bbe3dbdab81c1cfb1aef7c3892f5d24f6c7 https://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git/commit/?h=fixes&id=95e61b1b5d6394b53d147c0fcbe2ae70fbe09446 https://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git/commit/?h=fixes&id=d6df52e9996dcc2062c3d9c9123288468bb95b52 Back to clear_page - we could certainly make it non-instrumented. But it didn't cause any problems so far. And as Dmitry pointed out we could potentially find additional bugs with it. So, I'm leaning towards original solution proposed. For that you have my Acked-by: Vasily Gorbik Tested-by: Vasily Gorbik Thank you for looking into this! Andrew, would you pick this change up? Thank you Vasily
[PATCH v2] objtool: avoid ../ headers includes and name clashes
Currently objtool headers are being included either by their base name or included via ../ from a parent directory. In case of a base name usage: #include "warn.h" #include "arch_elf.h" it does not make it apparent from which directory the file comes from. To make it slightly better, and actually to avoid name clashes some arch specific files have "arch_" suffix. And files from an arch folder have to revert to including via ../ e.g: #include "../../elf.h" With additional architectures support and the code base growth there is a need for clearer headers naming scheme for multiple reasons: 1. to make it instantly obvious where these files come from (objtool itself / objtool arch|generic folders / some other external files), 2. to avoid name clashes of objtool arch specific headers, potential obtool arch generic headers and the system header files (there is /usr/include/elf.h already), 3. to avoid ../ includes and improve code readability. 4. to give a warm fuzzy feeling to developers who are mostly kernel developers and are accustomed to linux kernel headers arranging scheme. Doesn't this make it instantly obvious where are these files come from? #include #include And doesn't it look nicer to avoid ugly ../ includes? Which also guarantees this is elf.h from the objtool and not /usr/include/elf.h. #include This patch defines and implements new objtool headers arranging scheme. Which is: - all generic headers go to include/objtool (similar to include/linux) - all arch headers go to arch/$(SRCARCH)/include/arch (to get arch prefix). This is similar to linux arch specific "asm/*" headers but we are not abusing "asm" name and calling it what it is. This also helps to prevent name clashes (arch is not used in system headers or kernel exports). To bring objtool to this state the following things are done: 1. current top level tools/objtool/ headers are moved into include/objtool/ subdirectory, 2. arch specific headers, currently only arch/x86/include/ are moved into arch/x86/include/arch/ and were stripped of "arch_" suffix, 3. new -I$(srctree)/tools/objtool/include include path to make includes like possible, 4. rewriting file includes, 5. make git not to ignore include/objtool/ subdirectory. Signed-off-by: Vasily Gorbik --- v1 - v2: patch is rebased on top of [RFC PATCH RESEND v4] objtool and cross compilation patch series. tools/objtool/.gitignore | 2 +- tools/objtool/Makefile | 1 + tools/objtool/arch/x86/decode.c | 8 .../arch/x86/include/{ => arch}/cfi_regs.h | 0 .../arch/x86/include/{arch_elf.h => arch/elf.h} | 0 .../{arch_endianness.h => arch/endianness.h} | 0 .../include/{arch_special.h => arch/special.h} | 0 tools/objtool/arch/x86/special.c | 4 ++-- tools/objtool/builtin-check.c| 4 ++-- tools/objtool/builtin-orc.c | 4 ++-- tools/objtool/check.c| 16 tools/objtool/elf.c | 6 +++--- tools/objtool/{ => include/objtool}/arch.h | 4 ++-- tools/objtool/{ => include/objtool}/builtin.h| 0 tools/objtool/{ => include/objtool}/cfi.h| 2 +- tools/objtool/{ => include/objtool}/check.h | 4 ++-- tools/objtool/{ => include/objtool}/elf.h| 0 tools/objtool/{ => include/objtool}/endianness.h | 2 +- tools/objtool/{ => include/objtool}/objtool.h| 2 +- tools/objtool/{ => include/objtool}/special.h| 4 ++-- tools/objtool/{ => include/objtool}/warn.h | 2 +- tools/objtool/objtool.c | 6 +++--- tools/objtool/orc_dump.c | 6 +++--- tools/objtool/orc_gen.c | 6 +++--- tools/objtool/special.c | 10 +- tools/objtool/weak.c | 2 +- 26 files changed, 48 insertions(+), 47 deletions(-) rename tools/objtool/arch/x86/include/{ => arch}/cfi_regs.h (100%) rename tools/objtool/arch/x86/include/{arch_elf.h => arch/elf.h} (100%) rename tools/objtool/arch/x86/include/{arch_endianness.h => arch/endianness.h} (100%) rename tools/objtool/arch/x86/include/{arch_special.h => arch/special.h} (100%) rename tools/objtool/{ => include/objtool}/arch.h (96%) rename tools/objtool/{ => include/objtool}/builtin.h (100%) rename tools/objtool/{ => include/objtool}/cfi.h (96%) rename tools/objtool/{ => include/objtool}/check.h (96%) rename tools/objtool/{ => include/objtool}/elf.h (100%) rename tools/objtool/{ => include/objtool}/endianness.h (97%) rename tools/objtool/{ => include/objtool}/objtool.h (96%) rename tools/objtool/{ => include/objtool}/special.h (94%) rename tools/objtool/{ =&g
[RFC PATCH RESEND v4 1/4] objtool: allow nested externs to enable BUILD_BUG()
Currently BUILD_BUG() macro is expanded to smth like the following: do { extern void __compiletime_assert_0(void) __attribute__((error("BUILD_BUG failed"))); if (!(!(1))) __compiletime_assert_0(); } while (0); If used in a function body this obviously would produce build errors with -Wnested-externs and -Werror. Build objtool with -Wno-nested-externs to enable BUILD_BUG() usage. Signed-off-by: Vasily Gorbik --- tools/objtool/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/objtool/Makefile b/tools/objtool/Makefile index 33d1e3ca8efd..4ea9a833dde7 100644 --- a/tools/objtool/Makefile +++ b/tools/objtool/Makefile @@ -37,7 +37,7 @@ INCLUDES := -I$(srctree)/tools/include \ -I$(srctree)/tools/arch/$(HOSTARCH)/include/uapi \ -I$(srctree)/tools/arch/$(SRCARCH)/include \ -I$(srctree)/tools/objtool/arch/$(SRCARCH)/include -WARNINGS := $(EXTRA_WARNINGS) -Wno-switch-default -Wno-switch-enum -Wno-packed +WARNINGS := $(EXTRA_WARNINGS) -Wno-switch-default -Wno-switch-enum -Wno-packed -Wno-nested-externs CFLAGS := -Werror $(WARNINGS) $(KBUILD_HOSTCFLAGS) -g $(INCLUDES) $(LIBELF_FLAGS) LDFLAGS += $(LIBELF_LIBS) $(LIBSUBCMD) $(KBUILD_HOSTLDFLAGS) -- ⢋⡀⣀⠹ ⠠⣶⡦⠀ ⣿⣿⣿⠏⣴⣮⣴⣧⠈⢿⣿⣿ ⣿⣿⡏⢰⣿⠖⣠⣿⡆⠈⣿⣿ ⣿⢛⣵⣄⠙⣶⣶⡟⣅⣠⠹⣿ ⣿⣜⣛⠻⢎⣉⣉⣀⠿⣫⣵⣿
[RFC PATCH RESEND v4 4/4] objtool: fix x86 orc generation on big endian cross compiles
Correct objtool orc generation endianness problems to enable fully functional x86 cross compiles on big endian hardware. Introduces bswap_if_needed macro which does a byte swap if target endianness doesn't match the host, i.e. cross compilation for little endian on big endian and vice versa. To be used for multi-byte values conversion, which are read from / about to be written to a target native endianness ELF file. Signed-off-by: Vasily Gorbik --- arch/x86/include/asm/orc_types.h | 10 + tools/arch/x86/include/asm/orc_types.h| 10 + .../arch/x86/include/arch_endianness.h| 9 + tools/objtool/check.c | 5 ++- tools/objtool/endianness.h| 38 +++ tools/objtool/orc_dump.c | 5 ++- tools/objtool/orc_gen.c | 3 ++ tools/objtool/special.c | 6 ++- 8 files changed, 80 insertions(+), 6 deletions(-) create mode 100644 tools/objtool/arch/x86/include/arch_endianness.h create mode 100644 tools/objtool/endianness.h diff --git a/arch/x86/include/asm/orc_types.h b/arch/x86/include/asm/orc_types.h index fdbffec4cfde..5a2baf28a1dc 100644 --- a/arch/x86/include/asm/orc_types.h +++ b/arch/x86/include/asm/orc_types.h @@ -40,6 +40,8 @@ #define ORC_REG_MAX15 #ifndef __ASSEMBLY__ +#include + /* * This struct is more or less a vastly simplified version of the DWARF Call * Frame Information standard. It contains only the necessary parts of DWARF @@ -51,10 +53,18 @@ struct orc_entry { s16 sp_offset; s16 bp_offset; +#if defined(__LITTLE_ENDIAN_BITFIELD) unsignedsp_reg:4; unsignedbp_reg:4; unsignedtype:2; unsignedend:1; +#elif defined(__BIG_ENDIAN_BITFIELD) + unsignedbp_reg:4; + unsignedsp_reg:4; + unsignedunused:5; + unsignedend:1; + unsignedtype:2; +#endif } __packed; #endif /* __ASSEMBLY__ */ diff --git a/tools/arch/x86/include/asm/orc_types.h b/tools/arch/x86/include/asm/orc_types.h index fdbffec4cfde..5a2baf28a1dc 100644 --- a/tools/arch/x86/include/asm/orc_types.h +++ b/tools/arch/x86/include/asm/orc_types.h @@ -40,6 +40,8 @@ #define ORC_REG_MAX15 #ifndef __ASSEMBLY__ +#include + /* * This struct is more or less a vastly simplified version of the DWARF Call * Frame Information standard. It contains only the necessary parts of DWARF @@ -51,10 +53,18 @@ struct orc_entry { s16 sp_offset; s16 bp_offset; +#if defined(__LITTLE_ENDIAN_BITFIELD) unsignedsp_reg:4; unsignedbp_reg:4; unsignedtype:2; unsignedend:1; +#elif defined(__BIG_ENDIAN_BITFIELD) + unsignedbp_reg:4; + unsignedsp_reg:4; + unsignedunused:5; + unsignedend:1; + unsignedtype:2; +#endif } __packed; #endif /* __ASSEMBLY__ */ diff --git a/tools/objtool/arch/x86/include/arch_endianness.h b/tools/objtool/arch/x86/include/arch_endianness.h new file mode 100644 index ..7c362527da20 --- /dev/null +++ b/tools/objtool/arch/x86/include/arch_endianness.h @@ -0,0 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +#ifndef _ARCH_ENDIANNESS_H +#define _ARCH_ENDIANNESS_H + +#include + +#define __TARGET_BYTE_ORDER __LITTLE_ENDIAN + +#endif /* _ARCH_ENDIANNESS_H */ diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 2df9f769412e..fd892b77e98f 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -13,6 +13,7 @@ #include "special.h" #include "warn.h" #include "arch_elf.h" +#include "endianness.h" #include #include @@ -1370,7 +1371,7 @@ static int read_unwind_hints(struct objtool_file *file) cfa = &insn->cfi.cfa; if (hint->type == UNWIND_HINT_TYPE_RET_OFFSET) { - insn->ret_offset = hint->sp_offset; + insn->ret_offset = bswap_if_needed(hint->sp_offset); continue; } @@ -1382,7 +1383,7 @@ static int read_unwind_hints(struct objtool_file *file) return -1; } - cfa->offset = hint->sp_offset; + cfa->offset = bswap_if_needed(hint->sp_offset); insn->cfi.type = hint->type; insn->cfi.end = hint->end; } diff --git a/tools/objtool/endianness.h b/tools/objtool/endianness.h new file mode 100644 index ..ebece3191b58 --- /dev/null +++ b/tools/objtool/endianness.h @@ -0,0 +1,38 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +#ifndef _OBJTOOL_ENDIANNESS_H +#define _OBJTOOL_ENDIANNESS_H + +#include +#include +#include "arch_endian
[RFC PATCH RESEND v4 0/4] objtool and cross compilation
Sorry for the extra noise. Patches has been resent because one of them has been corrupted. That's what you get for post-editing mailbox in vim, few wrong extra strokes and your wife wants to divorce you because you just copied and pretty-formatted her threatening message to your internet service provider from another buffer. rfc v1 - rfc v2: - rebased onto tip/objtool/core - reformatted couple of lines rfc v2 - rfc v3: - reused __*_ENDIAN_BITFIELD and dropped unneeded byteswap if __KERNEL__ is defined following David's suggestions, - re-splitted changes and made x86 instruction decoder a separate patch, - extra patch to add -Wno-nested-externs build flag to enable BUILD_BUG() usage, - added a safer and more readable leXX_to_cpu macro in x86 instruction decoder, - simplified includes. Switched to using leXX_to_cpu/cpu_to_leXX in the objtool and x86 instruction decoder since is included in the objtool already. rfc v3 - rfc v4: - patch 4: objtool: fix x86 orc generation on big endian cross compiles - introduced "bswap_if_needed()" macro for multi-byte values conversion, which are read from / about to be written to a target native endianness ELF file. - patch 2: x86/insn: instruction decoder and big endian cross compiles - changed subject prefix from objtool to x86/insn - reformated leXX_to_cpu macro make it easier to read Currently objtool seems to be the only tool from all the build tools needed for x86 build which breaks x86 cross compilation on big endian systems. But besides x86 cross compilation, endianness awareness is also needed for big endian architectures objtool support in general. We have working prototype of objtool support and orc unwinder for s390 made originally by Martin Schwidefsky. I'm trying to bring it in shape again and refactor to share more code with "generic" part. But first things first. This patch series points to endianness problems which should be addressed. Recent "other architectures support" patches currently moved only some problematic parts into x86 arch specific folder. Besides that even though big endian stuff is only needed for the objtool arch/x86/lib/insn.c and arch/x86/include/asm/insn.h are shared across the kernel source and the tools, so changes are applied to both. Any suggestions how to make patches more acceptable are welcome. Martin Schwidefsky (2): x86/insn: instruction decoder and big endian cross compiles objtool: correct rebuilding of reloc sections Vasily Gorbik (2): objtool: allow nested externs to enable BUILD_BUG() objtool: fix x86 orc generation on big endian cross compiles arch/x86/include/asm/insn.h | 33 ++ arch/x86/include/asm/orc_types.h | 10 ++ arch/x86/lib/insn.c | 101 -- tools/arch/x86/include/asm/insn.h | 33 ++ tools/arch/x86/include/asm/orc_types.h| 10 ++ tools/arch/x86/lib/insn.c | 101 -- tools/objtool/Makefile| 2 +- .../arch/x86/include/arch_endianness.h| 9 ++ tools/objtool/check.c | 5 +- tools/objtool/elf.c | 34 +++--- tools/objtool/endianness.h| 38 +++ tools/objtool/orc_dump.c | 5 +- tools/objtool/orc_gen.c | 3 + tools/objtool/special.c | 6 +- 14 files changed, 260 insertions(+), 130 deletions(-) create mode 100644 tools/objtool/arch/x86/include/arch_endianness.h create mode 100644 tools/objtool/endianness.h -- ⢋⡀⣀⠹ ⠠⣶⡦⠀ ⣿⣿⣿⠏⣴⣮⣴⣧⠈⢿⣿⣿ ⣿⣿⡏⢰⣿⠖⣠⣿⡆⠈⣿⣿ ⣿⢛⣵⣄⠙⣶⣶⡟⣅⣠⠹⣿ ⣿⣜⣛⠻⢎⣉⣉⣀⠿⣫⣵⣿
[RFC PATCH RESEND v4 3/4] objtool: correct rebuilding of reloc sections
From: Martin Schwidefsky Currently relocations generated in elf_rebuild_rel_reloc_section/ elf_rebuild_rela_reloc_section functions are broken if the objtool is built and run on big endian system. E.g. the following errors pop up during x86 cross compilation: x86_64-9.1.0-ld: fs/efivarfs/inode.o: bad reloc symbol index (0x200 >= 0x22) for offset 0 in section `.orc_unwind_ip' x86_64-9.1.0-ld: final link failed: bad value To address that convert those functions to do things similar to elf_write_reloc(), reuse gelf_update_rel/gelf_update_rela libelf library functions. Signed-off-by: Martin Schwidefsky Co-developed-by: Vasily Gorbik Signed-off-by: Vasily Gorbik --- tools/objtool/elf.c | 34 +++--- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c index 4e1d7460574b..5c0341b0cde3 100644 --- a/tools/objtool/elf.c +++ b/tools/objtool/elf.c @@ -829,25 +829,27 @@ static int elf_rebuild_rel_reloc_section(struct section *sec, int nr) { struct reloc *reloc; int idx = 0, size; - GElf_Rel *relocs; + void *buf; /* Allocate a buffer for relocations */ - size = nr * sizeof(*relocs); - relocs = malloc(size); - if (!relocs) { + size = nr * sizeof(GElf_Rel); + buf = malloc(size); + if (!buf) { perror("malloc"); return -1; } - sec->data->d_buf = relocs; + sec->data->d_buf = buf; sec->data->d_size = size; + sec->data->d_type = ELF_T_REL; sec->sh.sh_size = size; idx = 0; list_for_each_entry(reloc, &sec->reloc_list, list) { - relocs[idx].r_offset = reloc->offset; - relocs[idx].r_info = GELF_R_INFO(reloc->sym->idx, reloc->type); + reloc->rel.r_offset = reloc->offset; + reloc->rel.r_info = GELF_R_INFO(reloc->sym->idx, reloc->type); + gelf_update_rel(sec->data, idx, &reloc->rel); idx++; } @@ -858,26 +860,28 @@ static int elf_rebuild_rela_reloc_section(struct section *sec, int nr) { struct reloc *reloc; int idx = 0, size; - GElf_Rela *relocs; + void *buf; /* Allocate a buffer for relocations with addends */ - size = nr * sizeof(*relocs); - relocs = malloc(size); - if (!relocs) { + size = nr * sizeof(GElf_Rela); + buf = malloc(size); + if (!buf) { perror("malloc"); return -1; } - sec->data->d_buf = relocs; + sec->data->d_buf = buf; sec->data->d_size = size; + sec->data->d_type = ELF_T_RELA; sec->sh.sh_size = size; idx = 0; list_for_each_entry(reloc, &sec->reloc_list, list) { - relocs[idx].r_offset = reloc->offset; - relocs[idx].r_addend = reloc->addend; - relocs[idx].r_info = GELF_R_INFO(reloc->sym->idx, reloc->type); + reloc->rela.r_offset = reloc->offset; + reloc->rela.r_addend = reloc->addend; + reloc->rela.r_info = GELF_R_INFO(reloc->sym->idx, reloc->type); + gelf_update_rela(sec->data, idx, &reloc->rela); idx++; } -- ⢋⡀⣀⠹ ⠠⣶⡦⠀ ⣿⣿⣿⠏⣴⣮⣴⣧⠈⢿⣿⣿ ⣿⣿⡏⢰⣿⠖⣠⣿⡆⠈⣿⣿ ⣿⢛⣵⣄⠙⣶⣶⡟⣅⣠⠹⣿ ⣿⣜⣛⠻⢎⣉⣉⣀⠿⣫⣵⣿
[RFC PATCH RESEND v4 2/4] x86/insn: instruction decoder and big endian cross compiles
From: Martin Schwidefsky x86 instruction decoder code is shared across the kernel source and the tools. Currently objtool seems to be the only tool from build tools needed which breaks x86 cross compilation on big endian systems. Make the x86 instruction decoder build host endianness agnostic to support x86 cross compilation and enable objtool to implement endianness awareness for big endian architectures support. Signed-off-by: Martin Schwidefsky Co-developed-by: Vasily Gorbik Signed-off-by: Vasily Gorbik --- arch/x86/include/asm/insn.h | 33 ++ arch/x86/lib/insn.c | 101 ++ tools/arch/x86/include/asm/insn.h | 33 ++ tools/arch/x86/lib/insn.c | 101 ++ 4 files changed, 160 insertions(+), 108 deletions(-) diff --git a/arch/x86/include/asm/insn.h b/arch/x86/include/asm/insn.h index 5c1ae3eff9d4..004e27bdf121 100644 --- a/arch/x86/include/asm/insn.h +++ b/arch/x86/include/asm/insn.h @@ -7,9 +7,12 @@ * Copyright (C) IBM Corporation, 2009 */ +#include /* insn_attr_t is defined in inat.h */ #include +#if defined(__BYTE_ORDER) ? __BYTE_ORDER == __LITTLE_ENDIAN : defined(__LITTLE_ENDIAN) + struct insn_field { union { insn_value_t value; @@ -20,6 +23,36 @@ struct insn_field { unsigned char nbytes; }; +static inline void insn_field_set(struct insn_field *p, insn_value_t v, + unsigned char n) +{ + p->value = v; + p->nbytes = n; +} + +#else + +struct insn_field { + insn_value_t value; + union { + insn_value_t little; + insn_byte_t bytes[4]; + }; + /* !0 if we've run insn_get_xxx() for this field */ + unsigned char got; + unsigned char nbytes; +}; + +static inline void insn_field_set(struct insn_field *p, insn_value_t v, + unsigned char n) +{ + p->value = v; + p->little = __cpu_to_le32(v); + p->nbytes = n; +} + +#endif + struct insn { struct insn_field prefixes; /* * Prefixes diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c index 404279563891..520b31fc1f1a 100644 --- a/arch/x86/lib/insn.c +++ b/arch/x86/lib/insn.c @@ -5,6 +5,7 @@ * Copyright (C) IBM Corporation, 2002, 2004, 2009 */ +#include #ifdef __KERNEL__ #include #else @@ -15,15 +16,28 @@ #include +#define leXX_to_cpu(t, r) \ +({ \ + __typeof__(t) v;\ + switch (sizeof(t)) {\ + case 4: v = le32_to_cpu(r); break; \ + case 2: v = le16_to_cpu(r); break; \ + case 1: v = r; break; \ + default:\ + BUILD_BUG(); break; \ + } \ + v; \ +}) + /* Verify next sizeof(t) bytes can be on the same instruction */ #define validate_next(t, insn, n) \ ((insn)->next_byte + sizeof(t) + n <= (insn)->end_kaddr) #define __get_next(t, insn)\ - ({ t r = *(t*)insn->next_byte; insn->next_byte += sizeof(t); r; }) + ({ t r = *(t*)insn->next_byte; insn->next_byte += sizeof(t); leXX_to_cpu(t, r); }) #define __peek_nbyte_next(t, insn, n) \ - ({ t r = *(t*)((insn)->next_byte + n); r; }) + ({ t r = *(t*)((insn)->next_byte + n); leXX_to_cpu(t, r); }) #define get_next(t, insn) \ ({ if (unlikely(!validate_next(t, insn, 0))) goto err_out; __get_next(t, insn); }) @@ -157,8 +171,7 @@ void insn_get_prefixes(struct insn *insn) b = peek_next(insn_byte_t, insn); attr = inat_get_opcode_attribute(b); if (inat_is_rex_prefix(attr)) { - insn->rex_prefix.value = b; - insn->rex_prefix.nbytes = 1; + insn_field_set(&insn->rex_prefix, b, 1); insn->next_byte++; if (X86_REX_W(b)) /* REX.W overrides opnd_size */ @@ -295,8 +308,7 @@ void insn_get_modrm(struct insn *insn) if (inat_has_modrm(insn->attr)) { mod = get_next(insn_byte_t, insn); - modrm->value = mod; - modrm->nbytes = 1; + insn_field_set(modrm, mod, 1); if (inat_is_group(insn->attr)) { pfx_id = insn_last_prefix_id(insn); insn->attr = inat_get
Re: [RFC PATCH v4 4/4] objtool: fix x86 orc generation on big endian cross compiles
On Mon, Oct 05, 2020 at 09:03:28AM -0500, Josh Poimboeuf wrote: > On Sun, Oct 04, 2020 at 04:30:54PM +0200, Vasily Gorbik wrote: > > @@ -77,8 +78,9 @@ static int get_alt_entry(struct elf *elf, struct > > special_entry *entry, > > if (entry->feature) { > > unsigned short feature; > > > > - feature = *(unsigned short *)(sec->data->d_buf + offset + > > - entry->feature); > > + feature = bswap_if_needed(*(unsigned short *)(sec->data->d_buf + > > + offset + > > + entry->feature)); > > arch_handle_alternative(feature, alt); > > } > > --- > > arch/x86/include/asm/orc_types.h | 10 + > > tools/arch/x86/include/asm/orc_types.h| 10 + > > .../arch/x86/include/arch_endianness.h| 9 + > > This patch is misformatted. Almost like it was concatenated with > itself? Indeed. I wonder how that could have happened. Sorry for that. I've resent patches with rebased patch "objtool: avoid ../ headers includes and name clashes" on top. This time I checked patches could be applied from outgoing mailbox before sending it.
[RFC PATCH 0/2] objtool and cross compilation
This is based on v5.9-rc7, before "other architectures support" patches starting pouring in. Currently objtool seems to be the only tool from build tools needed which breaks x86 cross compilation on big endian systems. But besides x86 cross compilation, endianness awareness is also needed for big endian architectures objtool support in general. We have working prototype of objtool support and orc unwinder for s390 made originally by Martin Schwidefsky. I'm trying to bring it in shape again and refactor to share more code with "generic" part. But first things first. These 2 patches point to endianness problems which should be addressed. And I'd be glad to get any ideas how to make them less ugly. New "other architectures support" patches currently move only some problematic parts into x86 arch specific folder. But the main problem is that arch/x86/lib/insn.c and arch/x86/include/asm/insn.h are shared across the kernel source and the tools, and there is no common way to address endianness problems. Since big endian stuff is only needed for the objtool and not for the kernel I can try to hide alternative big endian definitions in tools only header which is included only if __KERNEL__ is not defined. But that kind of defeats the idea of sharing those files 1 to 1 with tools. Thoughts? Any suggestions are welcome. Martin Schwidefsky (1): objtool: x86 instruction decoder and big endian cross compiles Vasily Gorbik (1): objtool: fix x86 orc generation on big endian cross compiles arch/x86/include/asm/insn.h| 43 arch/x86/include/asm/orc_types.h | 24 +++ arch/x86/lib/insn.c| 95 +++--- tools/arch/x86/include/asm/insn.h | 43 tools/arch/x86/include/asm/orc_types.h | 24 +++ tools/arch/x86/lib/insn.c | 95 +++--- tools/objtool/check.c | 4 +- tools/objtool/elf.c| 34 + tools/objtool/orc_dump.c | 4 +- tools/objtool/orc_gen.c| 2 + tools/objtool/special.c| 4 +- 11 files changed, 243 insertions(+), 129 deletions(-) -- ⢋⡀⣀⠹ ⠠⣶⡦⠀ ⣿⣿⣿⠏⣴⣮⣴⣧⠈⢿⣿⣿ ⣿⣿⡏⢰⣿⠖⣠⣿⡆⠈⣿⣿ ⣿⢛⣵⣄⠙⣶⣶⡟⣅⣠⠹⣿ ⣿⣜⣛⠻⢎⣉⣉⣀⠿⣫⣵⣿
[RFC PATCH 1/2] objtool: x86 instruction decoder and big endian cross compiles
From: Martin Schwidefsky Make the x86 instruction decoder of the objtool usable on big endian machines. This is useful for compile tests on non x86, big endian hardware. Co-developed-by: Vasily Gorbik [ gor: more endianness problems findings fixes / rebasing ] Signed-off-by: Martin Schwidefsky Signed-off-by: Vasily Gorbik --- arch/x86/include/asm/insn.h | 43 ++ arch/x86/lib/insn.c | 95 +-- tools/arch/x86/include/asm/insn.h | 43 ++ tools/arch/x86/lib/insn.c | 95 +-- tools/objtool/check.c | 4 +- tools/objtool/elf.c | 34 ++- tools/objtool/special.c | 4 +- 7 files changed, 191 insertions(+), 127 deletions(-) diff --git a/arch/x86/include/asm/insn.h b/arch/x86/include/asm/insn.h index 5c1ae3eff9d4..8d9864b09552 100644 --- a/arch/x86/include/asm/insn.h +++ b/arch/x86/include/asm/insn.h @@ -8,8 +8,17 @@ */ /* insn_attr_t is defined in inat.h */ +#ifdef __KERNEL__ +#include +#include +#else +#include +#endif #include +#if defined(__BYTE_ORDER) ? \ + __BYTE_ORDER == __LITTLE_ENDIAN : defined(__LITTLE_ENDIAN) + struct insn_field { union { insn_value_t value; @@ -20,6 +29,40 @@ struct insn_field { unsigned char nbytes; }; +static inline void insn_field_set(struct insn_field *p, insn_value_t v, + unsigned char n) +{ + p->value = v; + p->nbytes = n; +} + +#else + +struct insn_field { + insn_value_t value; + union { + insn_value_t little; + insn_byte_t bytes[4]; + }; + /* !0 if we've run insn_get_xxx() for this field */ + unsigned char got; + unsigned char nbytes; +}; + +static inline void insn_field_set(struct insn_field *p, insn_value_t v, + unsigned char n) +{ + p->value = v; +#ifdef __KERNEL__ + p->little = __swap32(v); +#else + p->little = __bswap_32(v); +#endif + p->nbytes = n; +} + +#endif + struct insn { struct insn_field prefixes; /* * Prefixes diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c index 404279563891..9150bdc8a6d6 100644 --- a/arch/x86/lib/insn.c +++ b/arch/x86/lib/insn.c @@ -15,15 +15,23 @@ #include +#ifdef __KERNEL__ +#define letoh(t, r) \ + ((sizeof(t) == 4) ? le32_to_cpu(r) : (sizeof(t) == 2) ? le16_to_cpu(r) : r) +#else +#define letoh(t, r) \ + ((sizeof(t) == 4) ? le32toh(r) : (sizeof(t) == 2) ? le16toh(r) : r) +#endif + /* Verify next sizeof(t) bytes can be on the same instruction */ #define validate_next(t, insn, n) \ ((insn)->next_byte + sizeof(t) + n <= (insn)->end_kaddr) #define __get_next(t, insn)\ - ({ t r = *(t*)insn->next_byte; insn->next_byte += sizeof(t); r; }) + ({ t r = *(t*)insn->next_byte; insn->next_byte += sizeof(t); letoh(t, r); }) #define __peek_nbyte_next(t, insn, n) \ - ({ t r = *(t*)((insn)->next_byte + n); r; }) + ({ t r = *(t*)((insn)->next_byte + n); letoh(t, r); }) #define get_next(t, insn) \ ({ if (unlikely(!validate_next(t, insn, 0))) goto err_out; __get_next(t, insn); }) @@ -157,8 +165,7 @@ void insn_get_prefixes(struct insn *insn) b = peek_next(insn_byte_t, insn); attr = inat_get_opcode_attribute(b); if (inat_is_rex_prefix(attr)) { - insn->rex_prefix.value = b; - insn->rex_prefix.nbytes = 1; + insn_field_set(&insn->rex_prefix, b, 1); insn->next_byte++; if (X86_REX_W(b)) /* REX.W overrides opnd_size */ @@ -295,8 +302,7 @@ void insn_get_modrm(struct insn *insn) if (inat_has_modrm(insn->attr)) { mod = get_next(insn_byte_t, insn); - modrm->value = mod; - modrm->nbytes = 1; + insn_field_set(modrm, mod, 1); if (inat_is_group(insn->attr)) { pfx_id = insn_last_prefix_id(insn); insn->attr = inat_get_group_attribute(mod, pfx_id, @@ -334,7 +340,7 @@ int insn_rip_relative(struct insn *insn) * For rip-relative instructions, the mod field (top 2 bits) * is zero and the r/m field (bottom 3 bits) is 0x5. */ - return (modrm->nbytes && (modrm->value & 0xc7) == 0x5); + return (modrm->nbytes && (modrm->bytes[0] & 0xc7) == 0x5); } /** @@ -353,11 +359,11 @@ void insn_get_sib(struct insn *insn) if (!insn->modrm.got) insn_get_modrm(insn); if (insn->modrm.nbytes) { - modrm = (insn_byte_t)insn->modrm.value; + modrm = in
[RFC PATCH 2/2] objtool: fix x86 orc generation on big endian cross compiles
Correct objtool orc generation endianness problems to enable fully functional x86 cross compiles on big endian hardware. Signed-off-by: Vasily Gorbik --- arch/x86/include/asm/orc_types.h | 24 tools/arch/x86/include/asm/orc_types.h | 24 tools/objtool/orc_dump.c | 4 ++-- tools/objtool/orc_gen.c| 2 ++ 4 files changed, 52 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/asm/orc_types.h b/arch/x86/include/asm/orc_types.h index d25534940bde..931f99b70af3 100644 --- a/arch/x86/include/asm/orc_types.h +++ b/arch/x86/include/asm/orc_types.h @@ -61,6 +61,13 @@ #define UNWIND_HINT_TYPE_RET_OFFSET3 #ifndef __ASSEMBLY__ +#ifdef __KERNEL__ +#include +#include +#else +#include +#endif + /* * This struct is more or less a vastly simplified version of the DWARF Call * Frame Information standard. It contains only the necessary parts of DWARF @@ -69,6 +76,9 @@ * the stack for a given code address. Each instance of the struct corresponds * to one or more code locations. */ +#if defined(__BYTE_ORDER) ? \ + __BYTE_ORDER == __LITTLE_ENDIAN : defined(__LITTLE_ENDIAN) + struct orc_entry { s16 sp_offset; s16 bp_offset; @@ -78,6 +88,20 @@ struct orc_entry { unsignedend:1; } __packed; +#else + +struct orc_entry { + s16 sp_offset; + s16 bp_offset; + unsignedbp_reg:4; + unsignedsp_reg:4; + unsignedunused:5; + unsignedend:1; + unsignedtype:2; +} __packed; + +#endif + /* * This struct is used by asm and inline asm code to manually annotate the * location of registers on the stack for the ORC unwinder. diff --git a/tools/arch/x86/include/asm/orc_types.h b/tools/arch/x86/include/asm/orc_types.h index d25534940bde..931f99b70af3 100644 --- a/tools/arch/x86/include/asm/orc_types.h +++ b/tools/arch/x86/include/asm/orc_types.h @@ -61,6 +61,13 @@ #define UNWIND_HINT_TYPE_RET_OFFSET3 #ifndef __ASSEMBLY__ +#ifdef __KERNEL__ +#include +#include +#else +#include +#endif + /* * This struct is more or less a vastly simplified version of the DWARF Call * Frame Information standard. It contains only the necessary parts of DWARF @@ -69,6 +76,9 @@ * the stack for a given code address. Each instance of the struct corresponds * to one or more code locations. */ +#if defined(__BYTE_ORDER) ? \ + __BYTE_ORDER == __LITTLE_ENDIAN : defined(__LITTLE_ENDIAN) + struct orc_entry { s16 sp_offset; s16 bp_offset; @@ -78,6 +88,20 @@ struct orc_entry { unsignedend:1; } __packed; +#else + +struct orc_entry { + s16 sp_offset; + s16 bp_offset; + unsignedbp_reg:4; + unsignedsp_reg:4; + unsignedunused:5; + unsignedend:1; + unsignedtype:2; +} __packed; + +#endif + /* * This struct is used by asm and inline asm code to manually annotate the * location of registers on the stack for the ORC unwinder. diff --git a/tools/objtool/orc_dump.c b/tools/objtool/orc_dump.c index fca46e006fc2..0fbf8521c891 100644 --- a/tools/objtool/orc_dump.c +++ b/tools/objtool/orc_dump.c @@ -196,11 +196,11 @@ int orc_dump(const char *_objname) printf(" sp:"); - print_reg(orc[i].sp_reg, orc[i].sp_offset); + print_reg(orc[i].sp_reg, (s16)le16toh(orc[i].sp_offset)); printf(" bp:"); - print_reg(orc[i].bp_reg, orc[i].bp_offset); + print_reg(orc[i].bp_reg, (s16)le16toh(orc[i].bp_offset)); printf(" type:%s end:%d\n", orc_type_name(orc[i].type), orc[i].end); diff --git a/tools/objtool/orc_gen.c b/tools/objtool/orc_gen.c index 968f55e6dd94..b3978fad93e6 100644 --- a/tools/objtool/orc_gen.c +++ b/tools/objtool/orc_gen.c @@ -90,6 +90,8 @@ static int create_orc_entry(struct elf *elf, struct section *u_sec, struct secti /* populate ORC data */ orc = (struct orc_entry *)u_sec->data->d_buf + idx; memcpy(orc, o, sizeof(*orc)); + orc->sp_offset = htole16(orc->sp_offset); + orc->bp_offset = htole16(orc->bp_offset); /* populate reloc for ip */ reloc = malloc(sizeof(*reloc)); -- ⢋⡀⣀⠹ ⠠⣶⡦⠀ ⣿⣿⣿⠏⣴⣮⣴⣧⠈⢿⣿⣿ ⣿⣿⡏⢰⣿⠖⣠⣿⡆⠈⣿⣿ ⣿⢛⣵⣄⠙⣶⣶⡟⣅⣠⠹⣿ ⣿⣜⣛⠻⢎⣉⣉⣀⠿⣫⣵⣿
[RFC PATCH v2 2/2] objtool: fix x86 orc generation on big endian cross compiles
Correct objtool orc generation endianness problems to enable fully functional x86 cross compiles on big endian hardware. Signed-off-by: Vasily Gorbik --- arch/x86/include/asm/orc_types.h | 24 tools/arch/x86/include/asm/orc_types.h | 24 tools/objtool/orc_dump.c | 4 ++-- tools/objtool/orc_gen.c| 2 ++ 4 files changed, 52 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/asm/orc_types.h b/arch/x86/include/asm/orc_types.h index fdbffec4cfde..c72bee8e6ec0 100644 --- a/arch/x86/include/asm/orc_types.h +++ b/arch/x86/include/asm/orc_types.h @@ -40,6 +40,13 @@ #define ORC_REG_MAX15 #ifndef __ASSEMBLY__ +#ifdef __KERNEL__ +#include +#include +#else +#include +#endif + /* * This struct is more or less a vastly simplified version of the DWARF Call * Frame Information standard. It contains only the necessary parts of DWARF @@ -48,6 +55,9 @@ * the stack for a given code address. Each instance of the struct corresponds * to one or more code locations. */ + +#if defined(__BYTE_ORDER) ? __BYTE_ORDER == __LITTLE_ENDIAN : defined(__LITTLE_ENDIAN) + struct orc_entry { s16 sp_offset; s16 bp_offset; @@ -57,6 +67,20 @@ struct orc_entry { unsignedend:1; } __packed; +#else + +struct orc_entry { + s16 sp_offset; + s16 bp_offset; + unsignedbp_reg:4; + unsignedsp_reg:4; + unsignedunused:5; + unsignedend:1; + unsignedtype:2; +} __packed; + +#endif + #endif /* __ASSEMBLY__ */ #endif /* _ORC_TYPES_H */ diff --git a/tools/arch/x86/include/asm/orc_types.h b/tools/arch/x86/include/asm/orc_types.h index fdbffec4cfde..c72bee8e6ec0 100644 --- a/tools/arch/x86/include/asm/orc_types.h +++ b/tools/arch/x86/include/asm/orc_types.h @@ -40,6 +40,13 @@ #define ORC_REG_MAX15 #ifndef __ASSEMBLY__ +#ifdef __KERNEL__ +#include +#include +#else +#include +#endif + /* * This struct is more or less a vastly simplified version of the DWARF Call * Frame Information standard. It contains only the necessary parts of DWARF @@ -48,6 +55,9 @@ * the stack for a given code address. Each instance of the struct corresponds * to one or more code locations. */ + +#if defined(__BYTE_ORDER) ? __BYTE_ORDER == __LITTLE_ENDIAN : defined(__LITTLE_ENDIAN) + struct orc_entry { s16 sp_offset; s16 bp_offset; @@ -57,6 +67,20 @@ struct orc_entry { unsignedend:1; } __packed; +#else + +struct orc_entry { + s16 sp_offset; + s16 bp_offset; + unsignedbp_reg:4; + unsignedsp_reg:4; + unsignedunused:5; + unsignedend:1; + unsignedtype:2; +} __packed; + +#endif + #endif /* __ASSEMBLY__ */ #endif /* _ORC_TYPES_H */ diff --git a/tools/objtool/orc_dump.c b/tools/objtool/orc_dump.c index 5e6a95368d35..19fa6f65040e 100644 --- a/tools/objtool/orc_dump.c +++ b/tools/objtool/orc_dump.c @@ -197,11 +197,11 @@ int orc_dump(const char *_objname) printf(" sp:"); - print_reg(orc[i].sp_reg, orc[i].sp_offset); + print_reg(orc[i].sp_reg, (s16)le16toh(orc[i].sp_offset)); printf(" bp:"); - print_reg(orc[i].bp_reg, orc[i].bp_offset); + print_reg(orc[i].bp_reg, (s16)le16toh(orc[i].bp_offset)); printf(" type:%s end:%d\n", orc_type_name(orc[i].type), orc[i].end); diff --git a/tools/objtool/orc_gen.c b/tools/objtool/orc_gen.c index 235663b96adc..ab9cff93fabd 100644 --- a/tools/objtool/orc_gen.c +++ b/tools/objtool/orc_gen.c @@ -96,6 +96,8 @@ static int create_orc_entry(struct elf *elf, struct section *u_sec, struct secti /* populate ORC data */ orc = (struct orc_entry *)u_sec->data->d_buf + idx; memcpy(orc, o, sizeof(*orc)); + orc->sp_offset = htole16(orc->sp_offset); + orc->bp_offset = htole16(orc->bp_offset); /* populate reloc for ip */ reloc = malloc(sizeof(*reloc)); -- ⢋⡀⣀⠹ ⠠⣶⡦⠀ ⣿⣿⣿⠏⣴⣮⣴⣧⠈⢿⣿⣿ ⣿⣿⡏⢰⣿⠖⣠⣿⡆⠈⣿⣿ ⣿⢛⣵⣄⠙⣶⣶⡟⣅⣠⠹⣿ ⣿⣜⣛⠻⢎⣉⣉⣀⠿⣫⣵⣿
[RFC PATCH v2 1/2] objtool: x86 instruction decoder and big endian cross compiles
From: Martin Schwidefsky Make the x86 instruction decoder of the objtool usable on big endian machines. This is useful for compile tests on non x86, big endian hardware. Co-developed-by: Vasily Gorbik [ gor: more endianness problems findings fixes / rebasing ] Signed-off-by: Martin Schwidefsky Signed-off-by: Vasily Gorbik --- arch/x86/include/asm/insn.h | 42 ++ arch/x86/lib/insn.c | 95 +-- tools/arch/x86/include/asm/insn.h | 42 ++ tools/arch/x86/lib/insn.c | 95 +-- tools/objtool/arch/x86/special.c | 2 +- tools/objtool/check.c | 4 +- tools/objtool/elf.c | 34 ++- 7 files changed, 188 insertions(+), 126 deletions(-) diff --git a/arch/x86/include/asm/insn.h b/arch/x86/include/asm/insn.h index 5c1ae3eff9d4..e5a2bcc41ac4 100644 --- a/arch/x86/include/asm/insn.h +++ b/arch/x86/include/asm/insn.h @@ -8,8 +8,16 @@ */ /* insn_attr_t is defined in inat.h */ +#ifdef __KERNEL__ +#include +#include +#else +#include +#endif #include +#if defined(__BYTE_ORDER) ? __BYTE_ORDER == __LITTLE_ENDIAN : defined(__LITTLE_ENDIAN) + struct insn_field { union { insn_value_t value; @@ -20,6 +28,40 @@ struct insn_field { unsigned char nbytes; }; +static inline void insn_field_set(struct insn_field *p, insn_value_t v, + unsigned char n) +{ + p->value = v; + p->nbytes = n; +} + +#else + +struct insn_field { + insn_value_t value; + union { + insn_value_t little; + insn_byte_t bytes[4]; + }; + /* !0 if we've run insn_get_xxx() for this field */ + unsigned char got; + unsigned char nbytes; +}; + +static inline void insn_field_set(struct insn_field *p, insn_value_t v, + unsigned char n) +{ + p->value = v; +#ifdef __KERNEL__ + p->little = __swap32(v); +#else + p->little = __bswap_32(v); +#endif + p->nbytes = n; +} + +#endif + struct insn { struct insn_field prefixes; /* * Prefixes diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c index 404279563891..9150bdc8a6d6 100644 --- a/arch/x86/lib/insn.c +++ b/arch/x86/lib/insn.c @@ -15,15 +15,23 @@ #include +#ifdef __KERNEL__ +#define letoh(t, r) \ + ((sizeof(t) == 4) ? le32_to_cpu(r) : (sizeof(t) == 2) ? le16_to_cpu(r) : r) +#else +#define letoh(t, r) \ + ((sizeof(t) == 4) ? le32toh(r) : (sizeof(t) == 2) ? le16toh(r) : r) +#endif + /* Verify next sizeof(t) bytes can be on the same instruction */ #define validate_next(t, insn, n) \ ((insn)->next_byte + sizeof(t) + n <= (insn)->end_kaddr) #define __get_next(t, insn)\ - ({ t r = *(t*)insn->next_byte; insn->next_byte += sizeof(t); r; }) + ({ t r = *(t*)insn->next_byte; insn->next_byte += sizeof(t); letoh(t, r); }) #define __peek_nbyte_next(t, insn, n) \ - ({ t r = *(t*)((insn)->next_byte + n); r; }) + ({ t r = *(t*)((insn)->next_byte + n); letoh(t, r); }) #define get_next(t, insn) \ ({ if (unlikely(!validate_next(t, insn, 0))) goto err_out; __get_next(t, insn); }) @@ -157,8 +165,7 @@ void insn_get_prefixes(struct insn *insn) b = peek_next(insn_byte_t, insn); attr = inat_get_opcode_attribute(b); if (inat_is_rex_prefix(attr)) { - insn->rex_prefix.value = b; - insn->rex_prefix.nbytes = 1; + insn_field_set(&insn->rex_prefix, b, 1); insn->next_byte++; if (X86_REX_W(b)) /* REX.W overrides opnd_size */ @@ -295,8 +302,7 @@ void insn_get_modrm(struct insn *insn) if (inat_has_modrm(insn->attr)) { mod = get_next(insn_byte_t, insn); - modrm->value = mod; - modrm->nbytes = 1; + insn_field_set(modrm, mod, 1); if (inat_is_group(insn->attr)) { pfx_id = insn_last_prefix_id(insn); insn->attr = inat_get_group_attribute(mod, pfx_id, @@ -334,7 +340,7 @@ int insn_rip_relative(struct insn *insn) * For rip-relative instructions, the mod field (top 2 bits) * is zero and the r/m field (bottom 3 bits) is 0x5. */ - return (modrm->nbytes && (modrm->value & 0xc7) == 0x5); + return (modrm->nbytes && (modrm->bytes[0] & 0xc7) == 0x5); } /** @@ -353,11 +359,11 @@ void insn_get_sib(struct insn *insn) if (!insn->modrm.got) insn_get_modrm(insn); if (insn->modrm.nbytes) { - modrm = (insn_byte_t)insn->modrm.value; + modrm = insn->modrm
[RFC PATCH v2 0/2] objtool and cross compilation
rfc v1 - rfc v2: - rebased onto tip/objtool/core - reformatted couple of lines Currently objtool seems to be the only tool from build tools needed which breaks x86 cross compilation on big endian systems. But besides x86 cross compilation, endianness awareness is also needed for big endian architectures objtool support in general. We have working prototype of objtool support and orc unwinder for s390 made originally by Martin Schwidefsky. I'm trying to bring it in shape again and refactor to share more code with "generic" part. But first things first. These 2 patches point to endianness problems which should be addressed. And I'd be glad to get any ideas how to make them less ugly. New "other architectures support" patches currently move only some problematic parts into x86 arch specific folder. But the main problem is that arch/x86/lib/insn.c and arch/x86/include/asm/insn.h are shared across the kernel source and the tools, and there is no common way to address endianness problems. Since big endian stuff is only needed for the objtool and not for the kernel I can try to hide alternative big endian definitions in tools only header which is included only if __KERNEL__ is not defined. But that kind of defeats the idea of sharing those files 1 to 1 with tools. Thoughts? Any suggestions are welcome. Martin Schwidefsky (1): objtool: x86 instruction decoder and big endian cross compiles Vasily Gorbik (1): objtool: fix x86 orc generation on big endian cross compiles arch/x86/include/asm/insn.h| 42 arch/x86/include/asm/orc_types.h | 24 +++ arch/x86/lib/insn.c| 95 +++--- tools/arch/x86/include/asm/insn.h | 42 tools/arch/x86/include/asm/orc_types.h | 24 +++ tools/arch/x86/lib/insn.c | 95 +++--- tools/objtool/arch/x86/special.c | 2 +- tools/objtool/check.c | 4 +- tools/objtool/elf.c| 34 + tools/objtool/orc_dump.c | 4 +- tools/objtool/orc_gen.c| 2 + 11 files changed, 240 insertions(+), 128 deletions(-) -- ⢋⡀⣀⠹ ⠠⣶⡦⠀ ⣿⣿⣿⠏⣴⣮⣴⣧⠈⢿⣿⣿ ⣿⣿⡏⢰⣿⠖⣠⣿⡆⠈⣿⣿ ⣿⢛⣵⣄⠙⣶⣶⡟⣅⣠⠹⣿ ⣿⣜⣛⠻⢎⣉⣉⣀⠿⣫⣵⣿
[RFC PATCH v3 2/4] objtool: x86 instruction decoder and big endian cross compiles
From: Martin Schwidefsky Currently objtool seems to be the only tool from build tools needed which breaks x86 cross compilation on big endian systems. Make the x86 instruction decoder of the objtool usable on big endian machines. Signed-off-by: Martin Schwidefsky Co-developed-by: Vasily Gorbik Signed-off-by: Vasily Gorbik --- arch/x86/include/asm/insn.h | 35 ++ arch/x86/lib/insn.c | 108 +++--- tools/arch/x86/include/asm/insn.h | 35 ++ tools/arch/x86/lib/insn.c | 108 +++--- 4 files changed, 178 insertions(+), 108 deletions(-) diff --git a/arch/x86/include/asm/insn.h b/arch/x86/include/asm/insn.h index 5c1ae3eff9d4..bff79b22da54 100644 --- a/arch/x86/include/asm/insn.h +++ b/arch/x86/include/asm/insn.h @@ -7,9 +7,12 @@ * Copyright (C) IBM Corporation, 2009 */ +#include /* insn_attr_t is defined in inat.h */ #include +#if defined(__BYTE_ORDER) ? __BYTE_ORDER == __LITTLE_ENDIAN : defined(__LITTLE_ENDIAN) + struct insn_field { union { insn_value_t value; @@ -20,6 +23,38 @@ struct insn_field { unsigned char nbytes; }; +static inline void insn_field_set(struct insn_field *p, insn_value_t v, + unsigned char n) +{ + p->value = v; + p->nbytes = n; +} + +#else + +struct insn_field { + insn_value_t value; + union { + insn_value_t little; + insn_byte_t bytes[4]; + }; + /* !0 if we've run insn_get_xxx() for this field */ + unsigned char got; + unsigned char nbytes; +}; + +static inline void insn_field_set(struct insn_field *p, insn_value_t v, + unsigned char n) +{ + p->value = v; +#ifndef __KERNEL__ + p->little = __bswap_32(v); +#endif + p->nbytes = n; +} + +#endif + struct insn { struct insn_field prefixes; /* * Prefixes diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c index 404279563891..bbd4a5f15d83 100644 --- a/arch/x86/lib/insn.c +++ b/arch/x86/lib/insn.c @@ -5,6 +5,7 @@ * Copyright (C) IBM Corporation, 2002, 2004, 2009 */ +#include #ifdef __KERNEL__ #include #else @@ -15,15 +16,35 @@ #include +#define leXX_to_cpu(t, r) \ +({ \ + __typeof__(t) v;\ + switch (sizeof(t)) {\ + case 4: \ + v = le32_to_cpu(r); \ + break; \ + case 2: \ + v = le16_to_cpu(r); \ + break; \ + case 1: \ + v = r; \ + break; \ + default:\ + BUILD_BUG();\ + break; \ + } \ + v; \ +}) + /* Verify next sizeof(t) bytes can be on the same instruction */ #define validate_next(t, insn, n) \ ((insn)->next_byte + sizeof(t) + n <= (insn)->end_kaddr) #define __get_next(t, insn)\ - ({ t r = *(t*)insn->next_byte; insn->next_byte += sizeof(t); r; }) + ({ t r = *(t*)insn->next_byte; insn->next_byte += sizeof(t); leXX_to_cpu(t, r); }) #define __peek_nbyte_next(t, insn, n) \ - ({ t r = *(t*)((insn)->next_byte + n); r; }) + ({ t r = *(t*)((insn)->next_byte + n); leXX_to_cpu(t, r); }) #define get_next(t, insn) \ ({ if (unlikely(!validate_next(t, insn, 0))) goto err_out; __get_next(t, insn); }) @@ -157,8 +178,7 @@ void insn_get_prefixes(struct insn *insn) b = peek_next(insn_byte_t, insn); attr = inat_get_opcode_attribute(b); if (inat_is_rex_prefix(attr)) { - insn->rex_prefix.value = b; - insn->rex_prefix.nbytes = 1; + insn_field_set(&insn->rex_prefix, b, 1); insn->next_byte++; if (X86_REX_W(b)) /* REX.W overrides opnd_size */ @@ -295,8 +315,7 @@ void insn_get_modrm(struct insn *insn) if (inat_has_
[RFC PATCH v3 4/4] objtool: fix x86 orc generation on big endian cross compiles
Correct objtool orc generation endianness problems to enable fully functional x86 cross compiles on big endian hardware. Signed-off-by: Vasily Gorbik --- arch/x86/include/asm/orc_types.h | 10 ++ tools/arch/x86/include/asm/orc_types.h | 10 ++ tools/objtool/arch/x86/special.c | 2 +- tools/objtool/check.c | 4 ++-- tools/objtool/orc_dump.c | 4 ++-- tools/objtool/orc_gen.c| 2 ++ 6 files changed, 27 insertions(+), 5 deletions(-) diff --git a/arch/x86/include/asm/orc_types.h b/arch/x86/include/asm/orc_types.h index fdbffec4cfde..5a2baf28a1dc 100644 --- a/arch/x86/include/asm/orc_types.h +++ b/arch/x86/include/asm/orc_types.h @@ -40,6 +40,8 @@ #define ORC_REG_MAX15 #ifndef __ASSEMBLY__ +#include + /* * This struct is more or less a vastly simplified version of the DWARF Call * Frame Information standard. It contains only the necessary parts of DWARF @@ -51,10 +53,18 @@ struct orc_entry { s16 sp_offset; s16 bp_offset; +#if defined(__LITTLE_ENDIAN_BITFIELD) unsignedsp_reg:4; unsignedbp_reg:4; unsignedtype:2; unsignedend:1; +#elif defined(__BIG_ENDIAN_BITFIELD) + unsignedbp_reg:4; + unsignedsp_reg:4; + unsignedunused:5; + unsignedend:1; + unsignedtype:2; +#endif } __packed; #endif /* __ASSEMBLY__ */ diff --git a/tools/arch/x86/include/asm/orc_types.h b/tools/arch/x86/include/asm/orc_types.h index fdbffec4cfde..5a2baf28a1dc 100644 --- a/tools/arch/x86/include/asm/orc_types.h +++ b/tools/arch/x86/include/asm/orc_types.h @@ -40,6 +40,8 @@ #define ORC_REG_MAX15 #ifndef __ASSEMBLY__ +#include + /* * This struct is more or less a vastly simplified version of the DWARF Call * Frame Information standard. It contains only the necessary parts of DWARF @@ -51,10 +53,18 @@ struct orc_entry { s16 sp_offset; s16 bp_offset; +#if defined(__LITTLE_ENDIAN_BITFIELD) unsignedsp_reg:4; unsignedbp_reg:4; unsignedtype:2; unsignedend:1; +#elif defined(__BIG_ENDIAN_BITFIELD) + unsignedbp_reg:4; + unsignedsp_reg:4; + unsignedunused:5; + unsignedend:1; + unsignedtype:2; +#endif } __packed; #endif /* __ASSEMBLY__ */ diff --git a/tools/objtool/arch/x86/special.c b/tools/objtool/arch/x86/special.c index fd4af88c0ea5..8349842aac82 100644 --- a/tools/objtool/arch/x86/special.c +++ b/tools/objtool/arch/x86/special.c @@ -9,7 +9,7 @@ void arch_handle_alternative(unsigned short feature, struct special_alt *alt) { - switch (feature) { + switch (le16_to_cpu(feature)) { case X86_FEATURE_SMAP: /* * If UACCESS validation is enabled; force that alternative; diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 2df9f769412e..f20a4be2fb22 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -1370,7 +1370,7 @@ static int read_unwind_hints(struct objtool_file *file) cfa = &insn->cfi.cfa; if (hint->type == UNWIND_HINT_TYPE_RET_OFFSET) { - insn->ret_offset = hint->sp_offset; + insn->ret_offset = le16_to_cpu(hint->sp_offset); continue; } @@ -1382,7 +1382,7 @@ static int read_unwind_hints(struct objtool_file *file) return -1; } - cfa->offset = hint->sp_offset; + cfa->offset = le16_to_cpu(hint->sp_offset); insn->cfi.type = hint->type; insn->cfi.end = hint->end; } diff --git a/tools/objtool/orc_dump.c b/tools/objtool/orc_dump.c index 5e6a95368d35..4cea20520ca7 100644 --- a/tools/objtool/orc_dump.c +++ b/tools/objtool/orc_dump.c @@ -197,11 +197,11 @@ int orc_dump(const char *_objname) printf(" sp:"); - print_reg(orc[i].sp_reg, orc[i].sp_offset); + print_reg(orc[i].sp_reg, (s16)le16_to_cpu(orc[i].sp_offset)); printf(" bp:"); - print_reg(orc[i].bp_reg, orc[i].bp_offset); + print_reg(orc[i].bp_reg, (s16)le16_to_cpu(orc[i].bp_offset)); printf(" type:%s end:%d\n", orc_type_name(orc[i].type), orc[i].end); diff --git a/tools/objtool/orc_gen.c b/tools/objtool/orc_gen.c index 235663b96adc..123fd718ea9a 100644 --- a/tools/objtool/orc_gen.c +++ b/tools/objtool/orc_gen.c @@ -96,6 +96,8 @@ static int create_orc_entry(struct elf *elf, struct section *u_sec, struct secti /* populate ORC data */ orc = (struct orc_entry *)u_sec->data->d_buf + i
[RFC PATCH v3 0/4] objtool and cross compilation
rfc v1 - rfc v2: - rebased onto tip/objtool/core - reformatted couple of lines rfc v2 - rfc v3: - reused __*_ENDIAN_BITFIELD and dropped unneeded byteswap if __KERNEL__ is defined following David's suggestions, - re-splitted changes and made x86 instruction decoder a separate patch, - extra patch to add -Wno-nested-externs build flag to enable BUILD_BUG() usage, - added a safer and more readable leXX_to_cpu macro in x86 instruction decoder, - simplified includes. Switched to using leXX_to_cpu/cpu_to_leXX in the objtool and x86 instruction decoder since is included in the objtool already. Currently objtool seems to be the only tool from all the build tools needed for x86 build which breaks x86 cross compilation on big endian systems. But besides x86 cross compilation, endianness awareness is also needed for big endian architectures objtool support in general. We have working prototype of objtool support and orc unwinder for s390 made originally by Martin Schwidefsky. I'm trying to bring it in shape again and refactor to share more code with "generic" part. But first things first. This patch series points to endianness problems which should be addressed. Recent "other architectures support" patches currently moved only some problematic parts into x86 arch specific folder. Besides that even though big endian stuff is only needed for the objtool arch/x86/lib/insn.c and arch/x86/include/asm/insn.h are shared across the kernel source and the tools, so changes are applied to both. Any suggestions how to make patches more acceptable are welcome. Martin Schwidefsky (2): objtool: x86 instruction decoder and big endian cross compiles objtool: correct rebuilding of reloc sections Vasily Gorbik (2): objtool: allow nested externs to enable BUILD_BUG() objtool: fix x86 orc generation on big endian cross compiles arch/x86/include/asm/insn.h| 35 arch/x86/include/asm/orc_types.h | 10 +++ arch/x86/lib/insn.c| 108 - tools/arch/x86/include/asm/insn.h | 35 tools/arch/x86/include/asm/orc_types.h | 10 +++ tools/arch/x86/lib/insn.c | 108 - tools/objtool/Makefile | 2 +- tools/objtool/arch/x86/special.c | 2 +- tools/objtool/check.c | 4 +- tools/objtool/elf.c| 34 tools/objtool/orc_dump.c | 4 +- tools/objtool/orc_gen.c| 2 + 12 files changed, 225 insertions(+), 129 deletions(-) -- ⢋⡀⣀⠹ ⠠⣶⡦⠀ ⣿⣿⣿⠏⣴⣮⣴⣧⠈⢿⣿⣿ ⣿⣿⡏⢰⣿⠖⣠⣿⡆⠈⣿⣿ ⣿⢛⣵⣄⠙⣶⣶⡟⣅⣠⠹⣿ ⣿⣜⣛⠻⢎⣉⣉⣀⠿⣫⣵⣿
[RFC PATCH v3 3/4] objtool: correct rebuilding of reloc sections
From: Martin Schwidefsky Currently relocations generated in elf_rebuild_rel_reloc_section/ elf_rebuild_rela_reloc_section functions are broken if the objtool is built and run on big endian system. E.g. the following errors pop up during x86 cross compilation: x86_64-9.1.0-ld: fs/efivarfs/inode.o: bad reloc symbol index (0x200 >= 0x22) for offset 0 in section `.orc_unwind_ip' x86_64-9.1.0-ld: final link failed: bad value To address that convert those functions to do things similar to elf_write_reloc(), reuse gelf_update_rel/gelf_update_rela libelf library functions. Signed-off-by: Martin Schwidefsky Co-developed-by: Vasily Gorbik Signed-off-by: Vasily Gorbik --- tools/objtool/elf.c | 34 +++--- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c index 4e1d7460574b..5c0341b0cde3 100644 --- a/tools/objtool/elf.c +++ b/tools/objtool/elf.c @@ -829,25 +829,27 @@ static int elf_rebuild_rel_reloc_section(struct section *sec, int nr) { struct reloc *reloc; int idx = 0, size; - GElf_Rel *relocs; + void *buf; /* Allocate a buffer for relocations */ - size = nr * sizeof(*relocs); - relocs = malloc(size); - if (!relocs) { + size = nr * sizeof(GElf_Rel); + buf = malloc(size); + if (!buf) { perror("malloc"); return -1; } - sec->data->d_buf = relocs; + sec->data->d_buf = buf; sec->data->d_size = size; + sec->data->d_type = ELF_T_REL; sec->sh.sh_size = size; idx = 0; list_for_each_entry(reloc, &sec->reloc_list, list) { - relocs[idx].r_offset = reloc->offset; - relocs[idx].r_info = GELF_R_INFO(reloc->sym->idx, reloc->type); + reloc->rel.r_offset = reloc->offset; + reloc->rel.r_info = GELF_R_INFO(reloc->sym->idx, reloc->type); + gelf_update_rel(sec->data, idx, &reloc->rel); idx++; } @@ -858,26 +860,28 @@ static int elf_rebuild_rela_reloc_section(struct section *sec, int nr) { struct reloc *reloc; int idx = 0, size; - GElf_Rela *relocs; + void *buf; /* Allocate a buffer for relocations with addends */ - size = nr * sizeof(*relocs); - relocs = malloc(size); - if (!relocs) { + size = nr * sizeof(GElf_Rela); + buf = malloc(size); + if (!buf) { perror("malloc"); return -1; } - sec->data->d_buf = relocs; + sec->data->d_buf = buf; sec->data->d_size = size; + sec->data->d_type = ELF_T_RELA; sec->sh.sh_size = size; idx = 0; list_for_each_entry(reloc, &sec->reloc_list, list) { - relocs[idx].r_offset = reloc->offset; - relocs[idx].r_addend = reloc->addend; - relocs[idx].r_info = GELF_R_INFO(reloc->sym->idx, reloc->type); + reloc->rela.r_offset = reloc->offset; + reloc->rela.r_addend = reloc->addend; + reloc->rela.r_info = GELF_R_INFO(reloc->sym->idx, reloc->type); + gelf_update_rela(sec->data, idx, &reloc->rela); idx++; } -- ⢋⡀⣀⠹ ⠠⣶⡦⠀ ⣿⣿⣿⠏⣴⣮⣴⣧⠈⢿⣿⣿ ⣿⣿⡏⢰⣿⠖⣠⣿⡆⠈⣿⣿ ⣿⢛⣵⣄⠙⣶⣶⡟⣅⣠⠹⣿ ⣿⣜⣛⠻⢎⣉⣉⣀⠿⣫⣵⣿
[RFC PATCH v3 1/4] objtool: allow nested externs to enable BUILD_BUG()
Currently BUILD_BUG() macro is expanded to smth like the following: do { extern void __compiletime_assert_0(void) __attribute__((error("BUILD_BUG failed"))); if (!(!(1))) __compiletime_assert_0(); } while (0); If used in a function body this obviously would produce build errors with -Wnested-externs and -Werror. Build objtool with -Wno-nested-externs to enable BUILD_BUG() usage. Signed-off-by: Vasily Gorbik --- tools/objtool/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/objtool/Makefile b/tools/objtool/Makefile index 33d1e3ca8efd..4ea9a833dde7 100644 --- a/tools/objtool/Makefile +++ b/tools/objtool/Makefile @@ -37,7 +37,7 @@ INCLUDES := -I$(srctree)/tools/include \ -I$(srctree)/tools/arch/$(HOSTARCH)/include/uapi \ -I$(srctree)/tools/arch/$(SRCARCH)/include \ -I$(srctree)/tools/objtool/arch/$(SRCARCH)/include -WARNINGS := $(EXTRA_WARNINGS) -Wno-switch-default -Wno-switch-enum -Wno-packed +WARNINGS := $(EXTRA_WARNINGS) -Wno-switch-default -Wno-switch-enum -Wno-packed -Wno-nested-externs CFLAGS := -Werror $(WARNINGS) $(KBUILD_HOSTCFLAGS) -g $(INCLUDES) $(LIBELF_FLAGS) LDFLAGS += $(LIBELF_LIBS) $(LIBSUBCMD) $(KBUILD_HOSTLDFLAGS) -- ⢋⡀⣀⠹ ⠠⣶⡦⠀ ⣿⣿⣿⠏⣴⣮⣴⣧⠈⢿⣿⣿ ⣿⣿⡏⢰⣿⠖⣠⣿⡆⠈⣿⣿ ⣿⢛⣵⣄⠙⣶⣶⡟⣅⣠⠹⣿ ⣿⣜⣛⠻⢎⣉⣉⣀⠿⣫⣵⣿
[PATCH] objtool: avoid ../ headers includes and name clashes
Currently objtool headers are being included either by their base name or included via ../ from a parent directory. In case of a base name usage: #include "warn.h" #include "arch_elf.h" it does not make it apparent from which directory the file comes from. To make it slightly better, and actually to avoid name clashes some arch specific files have "arch_" suffix. And files from an arch folder have to revert to including via ../ e.g: #include "../../elf.h" With additional architectures support and the code base growth there is a need for clearer headers naming scheme for multiple reasons: 1. to make it instantly obvious where these files come from (objtool itself / objtool arch|generic folders / some other external files), 2. to avoid name clashes of objtool arch specific headers, potential obtool arch generic headers and the system header files (there is /usr/include/elf.h already), 3. to avoid ../ includes and improve code readability. 4. to give a warm fuzzy feeling to developers who are mostly kernel developers and are accustomed to linux kernel headers arranging scheme. Doesn't this make it instantly obvious where are these files come from? #include #include And doesn't it look nicer to avoid ugly ../ includes? Which also guarantees this is elf.h from the objtool and not /usr/include/elf.h. #include This patch defines and implements new objtool headers arranging scheme. Which is: - all generic headers go to include/objtool (similar to include/linux) - all arch headers go to arch/$(SRCARCH)/include/arch (to get arch prefix). This is similar to linux arch specific "asm/*" headers but we are not abusing "asm" name and calling it what it is. This also helps to prevent name clashes (arch is not used in system headers or kernel exports). To bring objtool to this state the following things are done: 1. current top level tools/objtool/ headers are moved into include/objtool/ subdirectory, 2. arch specific headers, currently only arch/x86/include/ are moved into arch/x86/include/arch/ and were stripped of "arch_" suffix, 3. new -I$(srctree)/tools/objtool/include include path to make includes like possible, 4. rewriting file includes, 5. make git not to ignore include/objtool/ subdirectory. Signed-off-by: Vasily Gorbik --- tools/objtool/.gitignore | 2 +- tools/objtool/Makefile | 1 + tools/objtool/arch/x86/decode.c| 8 .../objtool/arch/x86/include/{ => arch}/cfi_regs.h | 0 .../arch/x86/include/{arch_elf.h => arch/elf.h}| 0 .../x86/include/{arch_special.h => arch/special.h} | 0 tools/objtool/arch/x86/special.c | 4 ++-- tools/objtool/builtin-check.c | 4 ++-- tools/objtool/builtin-orc.c| 4 ++-- tools/objtool/check.c | 14 +++--- tools/objtool/elf.c| 6 +++--- tools/objtool/{ => include/objtool}/arch.h | 4 ++-- tools/objtool/{ => include/objtool}/builtin.h | 0 tools/objtool/{ => include/objtool}/cfi.h | 2 +- tools/objtool/{ => include/objtool}/check.h| 4 ++-- tools/objtool/{ => include/objtool}/elf.h | 0 tools/objtool/{ => include/objtool}/objtool.h | 2 +- tools/objtool/{ => include/objtool}/special.h | 4 ++-- tools/objtool/{ => include/objtool}/warn.h | 2 +- tools/objtool/objtool.c| 6 +++--- tools/objtool/orc_dump.c | 4 ++-- tools/objtool/orc_gen.c| 4 ++-- tools/objtool/special.c| 8 tools/objtool/weak.c | 2 +- 24 files changed, 43 insertions(+), 42 deletions(-) rename tools/objtool/arch/x86/include/{ => arch}/cfi_regs.h (100%) rename tools/objtool/arch/x86/include/{arch_elf.h => arch/elf.h} (100%) rename tools/objtool/arch/x86/include/{arch_special.h => arch/special.h} (100%) rename tools/objtool/{ => include/objtool}/arch.h (96%) rename tools/objtool/{ => include/objtool}/builtin.h (100%) rename tools/objtool/{ => include/objtool}/cfi.h (96%) rename tools/objtool/{ => include/objtool}/check.h (96%) rename tools/objtool/{ => include/objtool}/elf.h (100%) rename tools/objtool/{ => include/objtool}/objtool.h (96%) rename tools/objtool/{ => include/objtool}/special.h (94%) rename tools/objtool/{ => include/objtool}/warn.h (98%) diff --git a/tools/objtool/.gitignore b/tools/objtool/.gitignore index 45cefda24c7b..14236db3677f 100644 --- a/tools/objtool/.gitignore +++ b/tools/objtool/.gitignore @@ -1,4 +1,4 @@ # SPDX-License-Identifier: GPL-2.0-only arch/x86/lib/inat-tables.c -objtool +/objtool fixdep diff --git a/tools/objtool/Makefile b/tools/o
[RFC PATCH v4 0/4] objtool and cross compilation
rfc v1 - rfc v2: - rebased onto tip/objtool/core - reformatted couple of lines rfc v2 - rfc v3: - reused __*_ENDIAN_BITFIELD and dropped unneeded byteswap if __KERNEL__ is defined following David's suggestions, - re-splitted changes and made x86 instruction decoder a separate patch, - extra patch to add -Wno-nested-externs build flag to enable BUILD_BUG() usage, - added a safer and more readable leXX_to_cpu macro in x86 instruction decoder, - simplified includes. Switched to using leXX_to_cpu/cpu_to_leXX in the objtool and x86 instruction decoder since is included in the objtool already. rfc v3 - rfc v4: - patch 4: objtool: fix x86 orc generation on big endian cross compiles - introduced "bswap_if_needed()" macro for multi-byte values conversion, which are read from / about to be written to a target native endianness ELF file. - patch 2: x86/insn: instruction decoder and big endian cross compiles - changed subject prefix from objtool to x86/insn - reformated leXX_to_cpu macro make it easier to read Currently objtool seems to be the only tool from all the build tools needed for x86 build which breaks x86 cross compilation on big endian systems. But besides x86 cross compilation, endianness awareness is also needed for big endian architectures objtool support in general. We have working prototype of objtool support and orc unwinder for s390 made originally by Martin Schwidefsky. I'm trying to bring it in shape again and refactor to share more code with "generic" part. But first things first. This patch series points to endianness problems which should be addressed. Recent "other architectures support" patches currently moved only some problematic parts into x86 arch specific folder. Besides that even though big endian stuff is only needed for the objtool arch/x86/lib/insn.c and arch/x86/include/asm/insn.h are shared across the kernel source and the tools, so changes are applied to both. Any suggestions how to make patches more acceptable are welcome. Martin Schwidefsky (2): x86/insn: instruction decoder and big endian cross compiles objtool: correct rebuilding of reloc sections Vasily Gorbik (2): objtool: allow nested externs to enable BUILD_BUG() objtool: fix x86 orc generation on big endian cross compiles arch/x86/include/asm/insn.h | 33 ++ arch/x86/include/asm/orc_types.h | 10 ++ arch/x86/lib/insn.c | 101 -- tools/arch/x86/include/asm/insn.h | 33 ++ tools/arch/x86/include/asm/orc_types.h| 10 ++ tools/arch/x86/lib/insn.c | 101 -- tools/objtool/Makefile| 2 +- .../arch/x86/include/arch_endianness.h| 9 ++ tools/objtool/check.c | 5 +- tools/objtool/elf.c | 34 +++--- tools/objtool/endianness.h| 38 +++ tools/objtool/orc_dump.c | 5 +- tools/objtool/orc_gen.c | 3 + tools/objtool/special.c | 6 +- 14 files changed, 260 insertions(+), 130 deletions(-) create mode 100644 tools/objtool/arch/x86/include/arch_endianness.h create mode 100644 tools/objtool/endianness.h -- ⢋⡀⣀⠹ ⠠⣶⡦⠀ ⣿⣿⣿⠏⣴⣮⣴⣧⠈⢿⣿⣿ ⣿⣿⡏⢰⣿⠖⣠⣿⡆⠈⣿⣿ ⣿⢛⣵⣄⠙⣶⣶⡟⣅⣠⠹⣿ ⣿⣜⣛⠻⢎⣉⣉⣀⠿⣫⣵⣿
[RFC PATCH v4 3/4] objtool: correct rebuilding of reloc sections
From: Martin Schwidefsky Currently relocations generated in elf_rebuild_rel_reloc_section/ elf_rebuild_rela_reloc_section functions are broken if the objtool is built and run on big endian system. E.g. the following errors pop up during x86 cross compilation: x86_64-9.1.0-ld: fs/efivarfs/inode.o: bad reloc symbol index (0x200 >= 0x22) for offset 0 in section `.orc_unwind_ip' x86_64-9.1.0-ld: final link failed: bad value To address that convert those functions to do things similar to elf_write_reloc(), reuse gelf_update_rel/gelf_update_rela libelf library functions. Signed-off-by: Martin Schwidefsky Co-developed-by: Vasily Gorbik Signed-off-by: Vasily Gorbik --- tools/objtool/elf.c | 34 +++--- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c index 4e1d7460574b..5c0341b0cde3 100644 --- a/tools/objtool/elf.c +++ b/tools/objtool/elf.c @@ -829,25 +829,27 @@ static int elf_rebuild_rel_reloc_section(struct section *sec, int nr) { struct reloc *reloc; int idx = 0, size; - GElf_Rel *relocs; + void *buf; /* Allocate a buffer for relocations */ - size = nr * sizeof(*relocs); - relocs = malloc(size); - if (!relocs) { + size = nr * sizeof(GElf_Rel); + buf = malloc(size); + if (!buf) { perror("malloc"); return -1; } - sec->data->d_buf = relocs; + sec->data->d_buf = buf; sec->data->d_size = size; + sec->data->d_type = ELF_T_REL; sec->sh.sh_size = size; idx = 0; list_for_each_entry(reloc, &sec->reloc_list, list) { - relocs[idx].r_offset = reloc->offset; - relocs[idx].r_info = GELF_R_INFO(reloc->sym->idx, reloc->type); + reloc->rel.r_offset = reloc->offset; + reloc->rel.r_info = GELF_R_INFO(reloc->sym->idx, reloc->type); + gelf_update_rel(sec->data, idx, &reloc->rel); idx++; } @@ -858,26 +860,28 @@ static int elf_rebuild_rela_reloc_section(struct section *sec, int nr) { struct reloc *reloc; int idx = 0, size; - GElf_Rela *relocs; + void *buf; /* Allocate a buffer for relocations with addends */ - size = nr * sizeof(*relocs); - relocs = malloc(size); - if (!relocs) { + size = nr * sizeof(GElf_Rela); + buf = malloc(size); + if (!buf) { perror("malloc"); return -1; } - sec->data->d_buf = relocs; + sec->data->d_buf = buf; sec->data->d_size = size; + sec->data->d_type = ELF_T_RELA; sec->sh.sh_size = size; idx = 0; list_for_each_entry(reloc, &sec->reloc_list, list) { - relocs[idx].r_offset = reloc->offset; - relocs[idx].r_addend = reloc->addend; - relocs[idx].r_info = GELF_R_INFO(reloc->sym->idx, reloc->type); + reloc->rela.r_offset = reloc->offset; + reloc->rela.r_addend = reloc->addend; + reloc->rela.r_info = GELF_R_INFO(reloc->sym->idx, reloc->type); + gelf_update_rela(sec->data, idx, &reloc->rela); idx++; } -- ⢋⡀⣀⠹ ⠠⣶⡦⠀ ⣿⣿⣿⠏⣴⣮⣴⣧⠈⢿⣿⣿ ⣿⣿⡏⢰⣿⠖⣠⣿⡆⠈⣿⣿ ⣿⢛⣵⣄⠙⣶⣶⡟⣅⣠⠹⣿ ⣿⣜⣛⠻⢎⣉⣉⣀⠿⣫⣵⣿
[RFC PATCH v4 4/4] objtool: fix x86 orc generation on big endian cross compiles
Correct objtool orc generation endianness problems to enable fully functional x86 cross compiles on big endian hardware. Introduces bswap_if_needed macro which does a byte swap if target endianness doesn't match the host, i.e. cross compilation for little endian on big endian and vice versa. To be used for multi-byte values conversion, which are read from / about to be written to a target native endianness ELF file. Signed-off-by: Vasily Gorbik diff --git a/arch/x86/include/asm/orc_types.h b/arch/x86/include/asm/orc_types.h index fdbffec4cfde..5a2baf28a1dc 100644 --- a/arch/x86/include/asm/orc_types.h +++ b/arch/x86/include/asm/orc_types.h @@ -40,6 +40,8 @@ #define ORC_REG_MAX15 #ifndef __ASSEMBLY__ +#include + /* * This struct is more or less a vastly simplified version of the DWARF Call * Frame Information standard. It contains only the necessary parts of DWARF @@ -51,10 +53,18 @@ struct orc_entry { s16 sp_offset; s16 bp_offset; +#if defined(__LITTLE_ENDIAN_BITFIELD) unsignedsp_reg:4; unsignedbp_reg:4; unsignedtype:2; unsignedend:1; +#elif defined(__BIG_ENDIAN_BITFIELD) + unsignedbp_reg:4; + unsignedsp_reg:4; + unsignedunused:5; + unsignedend:1; + unsignedtype:2; +#endif } __packed; #endif /* __ASSEMBLY__ */ diff --git a/tools/arch/x86/include/asm/orc_types.h b/tools/arch/x86/include/asm/orc_types.h index fdbffec4cfde..5a2baf28a1dc 100644 --- a/tools/arch/x86/include/asm/orc_types.h +++ b/tools/arch/x86/include/asm/orc_types.h @@ -40,6 +40,8 @@ #define ORC_REG_MAX15 #ifndef __ASSEMBLY__ +#include + /* * This struct is more or less a vastly simplified version of the DWARF Call * Frame Information standard. It contains only the necessary parts of DWARF @@ -51,10 +53,18 @@ struct orc_entry { s16 sp_offset; s16 bp_offset; +#if defined(__LITTLE_ENDIAN_BITFIELD) unsignedsp_reg:4; unsignedbp_reg:4; unsignedtype:2; unsignedend:1; +#elif defined(__BIG_ENDIAN_BITFIELD) + unsignedbp_reg:4; + unsignedsp_reg:4; + unsignedunused:5; + unsignedend:1; + unsignedtype:2; +#endif } __packed; #endif /* __ASSEMBLY__ */ diff --git a/tools/objtool/arch/x86/include/arch_endianness.h b/tools/objtool/arch/x86/include/arch_endianness.h new file mode 100644 index ..7c362527da20 --- /dev/null +++ b/tools/objtool/arch/x86/include/arch_endianness.h @@ -0,0 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +#ifndef _ARCH_ENDIANNESS_H +#define _ARCH_ENDIANNESS_H + +#include + +#define __TARGET_BYTE_ORDER __LITTLE_ENDIAN + +#endif /* _ARCH_ENDIANNESS_H */ diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 2df9f769412e..fd892b77e98f 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -13,6 +13,7 @@ #include "special.h" #include "warn.h" #include "arch_elf.h" +#include "endianness.h" #include #include @@ -1370,7 +1371,7 @@ static int read_unwind_hints(struct objtool_file *file) cfa = &insn->cfi.cfa; if (hint->type == UNWIND_HINT_TYPE_RET_OFFSET) { - insn->ret_offset = hint->sp_offset; + insn->ret_offset = bswap_if_needed(hint->sp_offset); continue; } @@ -1382,7 +1383,7 @@ static int read_unwind_hints(struct objtool_file *file) return -1; } - cfa->offset = hint->sp_offset; + cfa->offset = bswap_if_needed(hint->sp_offset); insn->cfi.type = hint->type; insn->cfi.end = hint->end; } diff --git a/tools/objtool/endianness.h b/tools/objtool/endianness.h new file mode 100644 index ..ebece3191b58 --- /dev/null +++ b/tools/objtool/endianness.h @@ -0,0 +1,38 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +#ifndef _OBJTOOL_ENDIANNESS_H +#define _OBJTOOL_ENDIANNESS_H + +#include +#include +#include "arch_endianness.h" + +#ifndef __TARGET_BYTE_ORDER +#error undefined arch __TARGET_BYTE_ORDER +#endif + +#if __BYTE_ORDER != __TARGET_BYTE_ORDER +#define __NEED_BSWAP 1 +#else +#define __NEED_BSWAP 0 +#endif + +/* + * Does a byte swap if target endianness doesn't match the host, i.e. cross + * compilation for little endian on big endian and vice versa. + * To be used for multi-byte values conversion, which are read from / about + * to be written to a target native endianness ELF file. + */ +#define bswap_if_needed(val) \ +({
[RFC PATCH v4 2/4] x86/insn: instruction decoder and big endian cross compiles
From: Martin Schwidefsky x86 instruction decoder code is shared across the kernel source and the tools. Currently objtool seems to be the only tool from build tools needed which breaks x86 cross compilation on big endian systems. Make the x86 instruction decoder build host endianness agnostic to support x86 cross compilation and enable objtool to implement endianness awareness for big endian architectures support. Signed-off-by: Martin Schwidefsky Co-developed-by: Vasily Gorbik Signed-off-by: Vasily Gorbik --- arch/x86/include/asm/insn.h | 33 ++ arch/x86/lib/insn.c | 101 ++ tools/arch/x86/include/asm/insn.h | 33 ++ tools/arch/x86/lib/insn.c | 101 ++ 4 files changed, 160 insertions(+), 108 deletions(-) diff --git a/arch/x86/include/asm/insn.h b/arch/x86/include/asm/insn.h index 5c1ae3eff9d4..004e27bdf121 100644 --- a/arch/x86/include/asm/insn.h +++ b/arch/x86/include/asm/insn.h @@ -7,9 +7,12 @@ * Copyright (C) IBM Corporation, 2009 */ +#include /* insn_attr_t is defined in inat.h */ #include +#if defined(__BYTE_ORDER) ? __BYTE_ORDER == __LITTLE_ENDIAN : defined(__LITTLE_ENDIAN) + struct insn_field { union { insn_value_t value; @@ -20,6 +23,36 @@ struct insn_field { unsigned char nbytes; }; +static inline void insn_field_set(struct insn_field *p, insn_value_t v, + unsigned char n) +{ + p->value = v; + p->nbytes = n; +} + +#else + +struct insn_field { + insn_value_t value; + union { + insn_value_t little; + insn_byte_t bytes[4]; + }; + /* !0 if we've run insn_get_xxx() for this field */ + unsigned char got; + unsigned char nbytes; +}; + +static inline void insn_field_set(struct insn_field *p, insn_value_t v, + unsigned char n) +{ + p->value = v; + p->little = __cpu_to_le32(v); + p->nbytes = n; +} + +#endif + struct insn { struct insn_field prefixes; /* * Prefixes diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c index 404279563891..520b31fc1f1a 100644 --- a/arch/x86/lib/insn.c +++ b/arch/x86/lib/insn.c @@ -5,6 +5,7 @@ * Copyright (C) IBM Corporation, 2002, 2004, 2009 */ +#include #ifdef __KERNEL__ #include #else @@ -15,15 +16,28 @@ #include +#define leXX_to_cpu(t, r) \ +({ \ + __typeof__(t) v;\ + switch (sizeof(t)) {\ + case 4: v = le32_to_cpu(r); break; \ + case 2: v = le16_to_cpu(r); break; \ + case 1: v = r; break; \ + default:\ + BUILD_BUG(); break; \ + } \ + v; \ +}) + /* Verify next sizeof(t) bytes can be on the same instruction */ #define validate_next(t, insn, n) \ ((insn)->next_byte + sizeof(t) + n <= (insn)->end_kaddr) #define __get_next(t, insn)\ - ({ t r = *(t*)insn->next_byte; insn->next_byte += sizeof(t); r; }) + ({ t r = *(t*)insn->next_byte; insn->next_byte += sizeof(t); leXX_to_cpu(t, r); }) #define __peek_nbyte_next(t, insn, n) \ - ({ t r = *(t*)((insn)->next_byte + n); r; }) + ({ t r = *(t*)((insn)->next_byte + n); leXX_to_cpu(t, r); }) #define get_next(t, insn) \ ({ if (unlikely(!validate_next(t, insn, 0))) goto err_out; __get_next(t, insn); }) @@ -157,8 +171,7 @@ void insn_get_prefixes(struct insn *insn) b = peek_next(insn_byte_t, insn); attr = inat_get_opcode_attribute(b); if (inat_is_rex_prefix(attr)) { - insn->rex_prefix.value = b; - insn->rex_prefix.nbytes = 1; + insn_field_set(&insn->rex_prefix, b, 1); insn->next_byte++; if (X86_REX_W(b)) /* REX.W overrides opnd_size */ @@ -295,8 +308,7 @@ void insn_get_modrm(struct insn *insn) if (inat_has_modrm(insn->attr)) { mod = get_next(insn_byte_t, insn); - modrm->value = mod; - modrm->nbytes = 1; + insn_field_set(modrm, mod, 1); if (inat_is_group(insn->attr)) { pfx_id = insn_last_prefix_id(insn); insn->attr = inat_get
[RFC PATCH v4 1/4] objtool: allow nested externs to enable BUILD_BUG()
Currently BUILD_BUG() macro is expanded to smth like the following: do { extern void __compiletime_assert_0(void) __attribute__((error("BUILD_BUG failed"))); if (!(!(1))) __compiletime_assert_0(); } while (0); If used in a function body this obviously would produce build errors with -Wnested-externs and -Werror. Build objtool with -Wno-nested-externs to enable BUILD_BUG() usage. Signed-off-by: Vasily Gorbik --- tools/objtool/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/objtool/Makefile b/tools/objtool/Makefile index 33d1e3ca8efd..4ea9a833dde7 100644 --- a/tools/objtool/Makefile +++ b/tools/objtool/Makefile @@ -37,7 +37,7 @@ INCLUDES := -I$(srctree)/tools/include \ -I$(srctree)/tools/arch/$(HOSTARCH)/include/uapi \ -I$(srctree)/tools/arch/$(SRCARCH)/include \ -I$(srctree)/tools/objtool/arch/$(SRCARCH)/include -WARNINGS := $(EXTRA_WARNINGS) -Wno-switch-default -Wno-switch-enum -Wno-packed +WARNINGS := $(EXTRA_WARNINGS) -Wno-switch-default -Wno-switch-enum -Wno-packed -Wno-nested-externs CFLAGS := -Werror $(WARNINGS) $(KBUILD_HOSTCFLAGS) -g $(INCLUDES) $(LIBELF_FLAGS) LDFLAGS += $(LIBELF_LIBS) $(LIBSUBCMD) $(KBUILD_HOSTLDFLAGS) -- ⢋⡀⣀⠹ ⠠⣶⡦⠀ ⣿⣿⣿⠏⣴⣮⣴⣧⠈⢿⣿⣿ ⣿⣿⡏⢰⣿⠖⣠⣿⡆⠈⣿⣿ ⣿⢛⣵⣄⠙⣶⣶⡟⣅⣠⠹⣿ ⣿⣜⣛⠻⢎⣉⣉⣀⠿⣫⣵⣿
[PATCH 1/1] perf build: Allow nested externs to enable BUILD_BUG() usage
Currently BUILD_BUG() macro is expanded to smth like the following: do { extern void __compiletime_assert_0(void) __attribute__((error("BUILD_BUG failed"))); if (!(!(1))) __compiletime_assert_0(); } while (0); If used in a function body this obviously would produce build errors with -Wnested-externs and -Werror. To enable BUILD_BUG() usage in tools/arch/x86/lib/insn.c which perf includes in intel-pt-decoder, build perf without -Wnested-externs. Reported-by: Stephen Rothwell Signed-off-by: Vasily Gorbik --- tools/perf/Makefile.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config index 190be4fa5c21..8137a6046a47 100644 --- a/tools/perf/Makefile.config +++ b/tools/perf/Makefile.config @@ -16,7 +16,7 @@ $(shell printf "" > $(OUTPUT).config-detected) detected = $(shell echo "$(1)=y" >> $(OUTPUT).config-detected) detected_var = $(shell echo "$(1)=$($(1))" >> $(OUTPUT).config-detected) -CFLAGS := $(EXTRA_CFLAGS) $(EXTRA_WARNINGS) +CFLAGS := $(EXTRA_CFLAGS) $(filter-out -Wnested-externs,$(EXTRA_WARNINGS)) include $(srctree)/tools/scripts/Makefile.arch -- ⢋⡀⣀⠹ ⠠⣶⡦⠀ ⣿⣿⣿⠏⣴⣮⣴⣧⠈⢿⣿⣿ ⣿⣿⡏⢰⣿⠖⣠⣿⡆⠈⣿⣿ ⣿⢛⣵⣄⠙⣶⣶⡟⣅⣠⠹⣿ ⣿⣜⣛⠻⢎⣉⣉⣀⠿⣫⣵⣿
Re: linux-next: build failure after merge of the tip tree
On Fri, Oct 09, 2020 at 03:28:46PM +1100, Stephen Rothwell wrote: > Hi all, > > After merging the tip tree, today's linux-next build (perf) failed > like this: > > In file included from tools/include/linux/build_bug.h:5, > from tools/include/linux/kernel.h:8, > from util/intel-pt-decoder/intel-pt-insn-decoder.c:7: > util/intel-pt-decoder/../../../arch/x86/lib/insn.c: In function > '__insn_get_emulate_prefix': > tools/include/linux/compiler.h:37:38: error: nested extern declaration of > '__compiletime_assert_0' [-Werror=nested-externs] >37 | _compiletime_assert(condition, msg, __compiletime_assert_, > __COUNTER__) > | ^ ...snip... > > Caused by commit > > 2a522b53c470 ("x86/insn: Support big endian cross-compiles") > > I have reverted commits > > a23b701ae9b3 objtool: Rework header include paths > 1b4998c364bc objtool: Fix x86 orc generation on big endian cross compiles > 317664a7fcc9 objtool: Fix reloc generation on big endian cross compiles > 2a522b53c470 x86/insn: Support big endian cross-compiles > 2486baae2cf6 objtool: Allow nested externs to enable BUILD_BUG() > > for today. > > This is a PowerPC LE native build of tools/perf. Oh, I missed that. Sorry about that. Obviously x86 instruction decoder is also used in perf. The question is, should we just disable -Wnested-externs for perf like we did for the objtool. Or since we got BUILD_BUG() implementation in tools simply disable -Wnested-externs for all tools altogether? By throwing it out of EXTRA_WARNINGS. Vasily Gorbik (1): perf build: Allow nested externs to enable BUILD_BUG() usage tools/perf/Makefile.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- ⢋⡀⣀⠹ ⠠⣶⡦⠀ ⣿⣿⣿⠏⣴⣮⣴⣧⠈⢿⣿⣿ ⣿⣿⡏⢰⣿⠖⣠⣿⡆⠈⣿⣿ ⣿⢛⣵⣄⠙⣶⣶⡟⣅⣠⠹⣿ ⣿⣜⣛⠻⢎⣉⣉⣀⠿⣫⣵⣿
Re: [PATCH 1/1] perf build: Allow nested externs to enable BUILD_BUG() usage
On Fri, Oct 09, 2020 at 01:23:27PM +0200, Jiri Olsa wrote: > On Fri, Oct 09, 2020 at 08:47:45AM +0200, Vasily Gorbik wrote: > > Currently BUILD_BUG() macro is expanded to smth like the following: ...snip... > > diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config > > index 190be4fa5c21..8137a6046a47 100644 > > --- a/tools/perf/Makefile.config > > +++ b/tools/perf/Makefile.config > > @@ -16,7 +16,7 @@ $(shell printf "" > $(OUTPUT).config-detected) > > detected = $(shell echo "$(1)=y" >> $(OUTPUT).config-detected) > > detected_var = $(shell echo "$(1)=$($(1))" >> $(OUTPUT).config-detected) > > > > -CFLAGS := $(EXTRA_CFLAGS) $(EXTRA_WARNINGS) > > +CFLAGS := $(EXTRA_CFLAGS) $(filter-out -Wnested-externs,$(EXTRA_WARNINGS)) > > looks good, but I can't apply the patch with 'git am' > > Applying: perf build: Allow nested externs to enable BUILD_BUG() usage > error: patch failed: tools/perf/Makefile.config:16 > error: tools/perf/Makefile.config: patch does not apply > Patch failed at 0001 perf build: Allow nested externs to enable > BUILD_BUG() usage > hint: Use 'git am --show-current-patch=diff' to see the failed patch > When you have resolved this problem, run "git am --continue". > If you prefer to skip this patch, run "git am --skip" instead. > To restore the original branch and stop patching, run "git am --abort". > > I wonder it's that picture at the bottom ;-) > > jirka > > > > > > include $(srctree)/tools/scripts/Makefile.arch > > > > -- > > ⢋⡀⣀⠹ > > ⠠⣶⡦⠀ > > ⣿⣿⣿⠏⣴⣮⣴⣧⠈⢿⣿⣿ > > ⣿⣿⡏⢰⣿⠖⣠⣿⡆⠈⣿⣿ > > ⣿⢛⣵⣄⠙⣶⣶⡟⣅⣠⠹⣿ > > ⣿⣜⣛⠻⢎⣉⣉⣀⠿⣫⣵⣿ > What? This makes tux and blind people very unhappy. Those are nothing else but braille utf-8 characters. And I've seen people on lkml are using those, i.e. debian icon in a signature. Oh, well... I'll avoid using this signature in future. BTW which branch did you try to apply it on? I've just checked perf/core and there should be no conflicts as well. But I assume this should go via objtool together with other changes which introduced that BUILD_BUG() usage. Anyhow I've resent the patch without fancy signatures included.
[PATCH RESEND 1/1] perf build: Allow nested externs to enable BUILD_BUG() usage
Currently BUILD_BUG() macro is expanded to smth like the following: do { extern void __compiletime_assert_0(void) __attribute__((error("BUILD_BUG failed"))); if (!(!(1))) __compiletime_assert_0(); } while (0); If used in a function body this obviously would produce build errors with -Wnested-externs and -Werror. To enable BUILD_BUG() usage in tools/arch/x86/lib/insn.c which perf includes in intel-pt-decoder, build perf without -Wnested-externs. Reported-by: Stephen Rothwell Signed-off-by: Vasily Gorbik --- Resend with no fancy signatures. tools/perf/Makefile.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config index 854da830b5ca..834061e94e7c 100644 --- a/tools/perf/Makefile.config +++ b/tools/perf/Makefile.config @@ -16,7 +16,7 @@ $(shell printf "" > $(OUTPUT).config-detected) detected = $(shell echo "$(1)=y" >> $(OUTPUT).config-detected) detected_var = $(shell echo "$(1)=$($(1))" >> $(OUTPUT).config-detected) -CFLAGS := $(EXTRA_CFLAGS) $(EXTRA_WARNINGS) +CFLAGS := $(EXTRA_CFLAGS) $(filter-out -Wnested-externs,$(EXTRA_WARNINGS)) include $(srctree)/tools/scripts/Makefile.arch -- 2.25.4
Re: [tip: objtool/core] x86/insn: Support big endian cross-compiles
On Fri, Oct 09, 2020 at 10:49:21PM +0200, Borislav Petkov wrote: > On Fri, Oct 09, 2020 at 10:38:22PM +0200, Peter Zijlstra wrote: > > On Wed, Oct 07, 2020 at 04:20:19PM -, tip-bot2 for Martin Schwidefsky > > wrote: > > > The following commit has been merged into the objtool/core branch of tip: > > > > > > Commit-ID: 2a522b53c47051d3bf98748418f4f8e5f20d2c04 > > > Gitweb: > > > https://git.kernel.org/tip/2a522b53c47051d3bf98748418f4f8e5f20d2c04 > > > > > > x86/insn: Support big endian cross-compiles > > > > This commit breaks the x86 build with CONFIG_X86_DECODER_SELFTEST=y. > > > > I've asked Boris to truncate tip/objtool/core. > > Yeah, top 4 are gone until this is resolved. > > What I would suggest is to have a look at how tools/ headers are kept > separate from kernel proper ones, see tools/include/ and how those > headers there are full of dummy definitions just so it builds. > > And then including a global one like linux/kernel.h is just looking for > trouble: > > In file included from ./include/uapi/linux/byteorder/little_endian.h:12, > from ./include/linux/byteorder/little_endian.h:5, > from /usr/include/x86_64-linux-gnu/asm/byteorder.h:5, > from ./arch/x86/include/asm/insn.h:10, > from arch/x86/tools/insn_sanity.c:21: > ./tools/include/linux/types.h:30:18: error: conflicting types for ‘u64’ >30 | typedef uint64_t u64; Sigh... I have not realized there are more usages of insn.c which are conditionally compiled. It's not like you grep *.c files to find who includes them regularity. Looks like there is no way to find common byte swapping helpers for the kernel and tools then. Even though tools provide quite a bunch of them in tools/include/. So, completely avoiding mixing "kernel" and "userspace" headers would look like the following (delta to commit mentioned above): --- diff --git a/arch/x86/include/asm/insn.h b/arch/x86/include/asm/insn.h index 004e27bdf121..68197fe18a11 100644 --- a/arch/x86/include/asm/insn.h +++ b/arch/x86/include/asm/insn.h @@ -7,7 +7,13 @@ * Copyright (C) IBM Corporation, 2009 */ +#ifdef __KERNEL__ #include +#define insn_cpu_to_le32 cpu_to_le32 +#else +#include +#define insn_cpu_to_le32 htole32 +#endif /* insn_attr_t is defined in inat.h */ #include @@ -47,7 +53,7 @@ static inline void insn_field_set(struct insn_field *p, insn_value_t v, unsigned char n) { p->value = v; - p->little = __cpu_to_le32(v); + p->little = insn_cpu_to_le32(v); p->nbytes = n; } diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c index 520b31fc1f1a..003f32ff7798 100644 --- a/arch/x86/lib/insn.c +++ b/arch/x86/lib/insn.c @@ -5,7 +5,6 @@ * Copyright (C) IBM Corporation, 2002, 2004, 2009 */ -#include #ifdef __KERNEL__ #include #else @@ -16,15 +15,23 @@ #include +#ifdef __KERNEL__ +#define insn_le32_to_cpu le32_to_cpu +#define insn_le16_to_cpu le16_to_cpu +#else +#define insn_le32_to_cpu le32toh +#define insn_le16_to_cpu le16toh +#endif + #define leXX_to_cpu(t, r) \ ({ \ __typeof__(t) v;\ switch (sizeof(t)) {\ - case 4: v = le32_to_cpu(r); break; \ - case 2: v = le16_to_cpu(r); break; \ + case 4: v = insn_le32_to_cpu(r); break; \ + case 2: v = insn_le16_to_cpu(r); break; \ case 1: v = r; break; \ - default:\ - BUILD_BUG(); break; \ + default: /* relying on -Wuninitialized to report this */\ + break; \ } \ v; \ }) -- And the same for the tools/* No linux/kernel.h means no BUILD_BUG(), but -Wuninitialized actually does a decent job in this case: arch/x86/../../../arch/x86/lib/insn.c:605:37: error: variable 'v' is uninitialized when used here [-Werror,-Wuninitialized] insn_field_set(&insn->immediate2, get_next(long, insn), 1); ^~~~ Masami, Josh, would that be acceptable? Should I resent the entire patch series again with these changes squashed? Or just as a separate commit which would go on top?
[GIT PULL] s390 updates for 5.9-rc7
Hello Linus, please pull s390 changes for 5.9-rc7. Thank you, Vasily The following changes since commit ba4f184e126b751d1bffad5897f263108befc780: Linux 5.9-rc6 (2020-09-20 16:33:55 -0700) are available in the Git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git tags/s390-5.9-7 for you to fetch changes up to f7e80983f0cf470bb82036e73bff4d5a7daf8fc2: s390/zcrypt: Fix ZCRYPT_PERDEV_REQCNT ioctl (2020-09-24 09:57:24 +0200) s390 fixes for 5.9-rc7 - Fix truncated ZCRYPT_PERDEV_REQCNT ioctl result. Copy entire reqcnt list. Christian Borntraeger (1): s390/zcrypt: Fix ZCRYPT_PERDEV_REQCNT ioctl drivers/s390/crypto/zcrypt_api.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/s390/crypto/zcrypt_api.c b/drivers/s390/crypto/zcrypt_api.c index 4dbbfd88262c..f314936b5462 100644 --- a/drivers/s390/crypto/zcrypt_api.c +++ b/drivers/s390/crypto/zcrypt_api.c @@ -1449,7 +1449,8 @@ static long zcrypt_unlocked_ioctl(struct file *filp, unsigned int cmd, if (!reqcnt) return -ENOMEM; zcrypt_perdev_reqcnt(reqcnt, AP_DEVICES); - if (copy_to_user((int __user *) arg, reqcnt, sizeof(reqcnt))) + if (copy_to_user((int __user *) arg, reqcnt, +sizeof(u32) * AP_DEVICES)) rc = -EFAULT; kfree(reqcnt); return rc;
Re: [patch V2 34/46] PCI/MSI: Make arch_.*_msi_irq[s] fallbacks selectable
On Fri, Sep 25, 2020 at 09:54:52AM -0400, Qian Cai wrote: > On Wed, 2020-08-26 at 13:17 +0200, Thomas Gleixner wrote: > > From: Thomas Gleixner > > > > The arch_.*_msi_irq[s] fallbacks are compiled in whether an architecture > > requires them or not. Architectures which are fully utilizing hierarchical > > irq domains should never call into that code. > > > > It's not only architectures which depend on that by implementing one or > > more of the weak functions, there is also a bunch of drivers which relies > > on the weak functions which invoke msi_controller::setup_irq[s] and > > msi_controller::teardown_irq. > > > > Make the architectures and drivers which rely on them select them in Kconfig > > and if not selected replace them by stub functions which emit a warning and > > fail the PCI/MSI interrupt allocation. > > > > Signed-off-by: Thomas Gleixner > > Today's linux-next will have some warnings on s390x: > > .config: https://gitlab.com/cailca/linux-mm/-/blob/master/s390.config > > WARNING: unmet direct dependencies detected for PCI_MSI_ARCH_FALLBACKS > Depends on [n]: PCI [=n] > Selected by [y]: > - S390 [=y] > > WARNING: unmet direct dependencies detected for PCI_MSI_ARCH_FALLBACKS > Depends on [n]: PCI [=n] > Selected by [y]: > - S390 [=y] > Yes, as well as on mips and sparc which also don't FORCE_PCI. This seems to work for s390: diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig index b0b7acf07eb8..41136fbe909b 100644 --- a/arch/s390/Kconfig +++ b/arch/s390/Kconfig @@ -192,3 +192,3 @@ config S390 select PCI_MSI if PCI - select PCI_MSI_ARCH_FALLBACKS + select PCI_MSI_ARCH_FALLBACKS if PCI select SET_FS
Re: [PATCH -next] s390/3215: simplify the return expression of tty3215_open()
On Mon, Sep 21, 2020 at 09:11:01PM +0800, Qinglang Miao wrote: > Simplify the return expression. > > Signed-off-by: Qinglang Miao > --- > drivers/s390/char/con3215.c | 7 +-- > 1 file changed, 1 insertion(+), 6 deletions(-) > > diff --git a/drivers/s390/char/con3215.c b/drivers/s390/char/con3215.c > index 92757f9bd..d8acabbb1 100644 > --- a/drivers/s390/char/con3215.c > +++ b/drivers/s390/char/con3215.c > @@ -978,7 +978,6 @@ static int tty3215_install(struct tty_driver *driver, > struct tty_struct *tty) > static int tty3215_open(struct tty_struct *tty, struct file * filp) > { > struct raw3215_info *raw = tty->driver_data; > - int retval; > > tty_port_tty_set(&raw->port, tty); > > @@ -986,11 +985,7 @@ static int tty3215_open(struct tty_struct *tty, struct > file * filp) > /* >* Start up 3215 device >*/ > - retval = raw3215_startup(raw); > - if (retval) > - return retval; > - > - return 0; > + return raw3215_startup(raw); > } Applied, thank you.
[GIT PULL] s390 updates for 5.7-rc7
Hello Linus, please pull s390 changes for 5.7-rc7. Thank you, Vasily The following changes since commit 2ef96a5bb12be62ef75b5828c0aab838ebb29cb8: Linux 5.7-rc5 (2020-05-10 15:16:58 -0700) are available in the Git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git tags/s390-5.7-4 for you to fetch changes up to 4c1cbcbd6c56c79de2c07159be4f55386bb0bef2: s390/kaslr: add support for R_390_JMP_SLOT relocation type (2020-05-20 10:13:27 +0200) s390 updates for 5.7-rc7 - Add missing R_390_JMP_SLOT relocation type in KASLR code. - Fix set_huge_pte_at for empty ptes issue which has been uncovered with arch page table helper tests. - Correct initrd location for kdump kernel. - Fix s390_mmio_read/write with MIO in PCI code. Gerald Schaefer (2): s390/mm: fix set_huge_pte_at() for empty ptes s390/kaslr: add support for R_390_JMP_SLOT relocation type Niklas Schnelle (1): s390/pci: Fix s390_mmio_read/write with MIO Philipp Rudo (1): s390/kexec_file: fix initrd location for kdump kernel arch/s390/include/asm/pci_io.h | 10 +- arch/s390/kernel/machine_kexec_file.c | 2 +- arch/s390/kernel/machine_kexec_reloc.c | 1 + arch/s390/mm/hugetlbpage.c | 9 +- arch/s390/pci/pci_mmio.c | 213 - 5 files changed, 227 insertions(+), 8 deletions(-) diff --git a/arch/s390/include/asm/pci_io.h b/arch/s390/include/asm/pci_io.h index cd060b5dd8fd..e4dc64cc9c55 100644 --- a/arch/s390/include/asm/pci_io.h +++ b/arch/s390/include/asm/pci_io.h @@ -8,6 +8,10 @@ #include #include +/* I/O size constraints */ +#define ZPCI_MAX_READ_SIZE 8 +#define ZPCI_MAX_WRITE_SIZE128 + /* I/O Map */ #define ZPCI_IOMAP_SHIFT 48 #define ZPCI_IOMAP_ADDR_BASE 0x8000UL @@ -140,7 +144,8 @@ static inline int zpci_memcpy_fromio(void *dst, while (n > 0) { size = zpci_get_max_write_size((u64 __force) src, - (u64) dst, n, 8); + (u64) dst, n, + ZPCI_MAX_READ_SIZE); rc = zpci_read_single(dst, src, size); if (rc) break; @@ -161,7 +166,8 @@ static inline int zpci_memcpy_toio(volatile void __iomem *dst, while (n > 0) { size = zpci_get_max_write_size((u64 __force) dst, - (u64) src, n, 128); + (u64) src, n, + ZPCI_MAX_WRITE_SIZE); if (size > 8) /* main path */ rc = zpci_write_block(dst, src, size); else diff --git a/arch/s390/kernel/machine_kexec_file.c b/arch/s390/kernel/machine_kexec_file.c index 8415ae7d2a23..f9e4baa64b67 100644 --- a/arch/s390/kernel/machine_kexec_file.c +++ b/arch/s390/kernel/machine_kexec_file.c @@ -151,7 +151,7 @@ static int kexec_file_add_initrd(struct kimage *image, buf.mem += crashk_res.start; buf.memsz = buf.bufsz; - data->parm->initrd_start = buf.mem; + data->parm->initrd_start = data->memsz; data->parm->initrd_size = buf.memsz; data->memsz += buf.memsz; diff --git a/arch/s390/kernel/machine_kexec_reloc.c b/arch/s390/kernel/machine_kexec_reloc.c index d5035de9020e..b7182cec48dc 100644 --- a/arch/s390/kernel/machine_kexec_reloc.c +++ b/arch/s390/kernel/machine_kexec_reloc.c @@ -28,6 +28,7 @@ int arch_kexec_do_relocs(int r_type, void *loc, unsigned long val, break; case R_390_64: /* Direct 64 bit. */ case R_390_GLOB_DAT: + case R_390_JMP_SLOT: *(u64 *)loc = val; break; case R_390_PC16:/* PC relative 16 bit. */ diff --git a/arch/s390/mm/hugetlbpage.c b/arch/s390/mm/hugetlbpage.c index f01daddcbc5e..4632d4e26b66 100644 --- a/arch/s390/mm/hugetlbpage.c +++ b/arch/s390/mm/hugetlbpage.c @@ -159,10 +159,13 @@ void set_huge_pte_at(struct mm_struct *mm, unsigned long addr, rste &= ~_SEGMENT_ENTRY_NOEXEC; /* Set correct table type for 2G hugepages */ - if ((pte_val(*ptep) & _REGION_ENTRY_TYPE_MASK) == _REGION_ENTRY_TYPE_R3) - rste |= _REGION_ENTRY_TYPE_R3 | _REGION3_ENTRY_LARGE; - else + if ((pte_val(*ptep) & _REGION_ENTRY_TYPE_MASK) == _REGION_ENTRY_TYPE_R3) { + if (likely(pte_present(pte))) + rste |= _REGION3_ENTRY_LARGE; + rste |= _REGION_ENTRY_TYPE_R3; + } else if (likely(pte_present(pte))) rste |= _SEGMENT_ENTRY_LARGE; + clear_huge_pte_skeys(mm, rste); pte_val(*ptep) = rste; } diff --git a/arch/s390/pci/pc
Re: [GIT PULL] s390 patches for the 5.8 merge window
On Mon, Jun 08, 2020 at 12:12:57PM -0700, Linus Torvalds wrote: > On Mon, Jun 8, 2020 at 12:09 PM Linus Torvalds > wrote: > > > > On Mon, Jun 8, 2020 at 8:35 AM Vasily Gorbik wrote: > > > > > > Please note 2 minor merge conflict resolutions below: > > > > There was a third because of the iommu tree I merged today. Looks fine, thank you. > Oh, and please don't post the whole patch in your pull request. Yes, this was not intentional. Sorry about that. Vasily
[GIT PULL] s390 updates for 5.9-rc3
Hello Linus, please pull s390 changes for 5.9-rc3. Thank you, Vasily The following changes since commit d012a7190fc1fd72ed48911e77ca97ba4521bccd: Linux 5.9-rc2 (2020-08-23 14:08:43 -0700) are available in the Git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git tags/s390-5.9-4 for you to fetch changes up to bffc2f7aa96343f91931272d7a8a2d8d925e1ab2: s390/vmem: fix vmem_add_range for 4-level paging (2020-08-26 18:07:05 +0200) s390 fixes for 5.9-rc3 - Disable preemption trace in percpu macros since the lockdep code itself uses percpu variables now and it causes recursions. - Fix kernel space 4-level paging broken by recent vmem rework. Sven Schnelle (1): s390: don't trace preemption in percpu macros Vasily Gorbik (1): s390/vmem: fix vmem_add_range for 4-level paging arch/s390/include/asm/percpu.h | 28 ++-- arch/s390/mm/vmem.c| 1 + 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/arch/s390/include/asm/percpu.h b/arch/s390/include/asm/percpu.h index 50b4ce8cddfd..918f0ba4f4d2 100644 --- a/arch/s390/include/asm/percpu.h +++ b/arch/s390/include/asm/percpu.h @@ -29,7 +29,7 @@ typedef typeof(pcp) pcp_op_T__; \ pcp_op_T__ old__, new__, prev__;\ pcp_op_T__ *ptr__; \ - preempt_disable(); \ + preempt_disable_notrace(); \ ptr__ = raw_cpu_ptr(&(pcp));\ prev__ = *ptr__;\ do {\ @@ -37,7 +37,7 @@ new__ = old__ op (val); \ prev__ = cmpxchg(ptr__, old__, new__); \ } while (prev__ != old__); \ - preempt_enable(); \ + preempt_enable_notrace(); \ new__; \ }) @@ -68,7 +68,7 @@ typedef typeof(pcp) pcp_op_T__; \ pcp_op_T__ val__ = (val); \ pcp_op_T__ old__, *ptr__; \ - preempt_disable(); \ + preempt_disable_notrace(); \ ptr__ = raw_cpu_ptr(&(pcp));\ if (__builtin_constant_p(val__) && \ ((szcast)val__ > -129) && ((szcast)val__ < 128)) { \ @@ -84,7 +84,7 @@ : [val__] "d" (val__) \ : "cc");\ } \ - preempt_enable(); \ + preempt_enable_notrace(); \ } #define this_cpu_add_4(pcp, val) arch_this_cpu_add(pcp, val, "laa", "asi", int) @@ -95,14 +95,14 @@ typedef typeof(pcp) pcp_op_T__; \ pcp_op_T__ val__ = (val); \ pcp_op_T__ old__, *ptr__; \ - preempt_disable(); \ + preempt_disable_notrace(); \ ptr__ = raw_cpu_ptr(&(pcp));\ asm volatile( \ op "%[old__],%[val__],%[ptr__]\n" \ : [old__] "=d" (old__), [ptr__] "+Q" (*ptr__) \ : [val__] "d" (val__) \ : "cc");\ - preempt_enable(); \ + preempt_enable_notrace(); \ old__ + val__; \ }) @@ -114,14 +114,14 @@ typedef typeof(pcp) pcp_op_T__; \ pcp_op_T__ val__ = (val); \ pcp_op_T__ old__, *ptr__; \ - preempt_disable();
[GIT PULL] s390 updates for 5.9-rc4
Hello Linus, please pull s390 changes for 5.9-rc4. Thank you, Vasily The following changes since commit f75aef392f869018f78cfedf3c320a6b3fcfda6b: Linux 5.9-rc3 (2020-08-30 16:01:54 -0700) are available in the Git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git tags/s390-5.9-5 for you to fetch changes up to 5c60ed283e1d87e161441bb273541a948ee96f6a: s390: update defconfigs (2020-09-02 13:17:05 +0200) s390 fixes for 5.9-rc4 - Fix GENERIC_LOCKBREAK dependency on PREEMPTION in Kconfig broken because of a typo. - Update defconfigs. Eric Farman (1): s390: fix GENERIC_LOCKBREAK dependency typo in Kconfig Heiko Carstens (1): s390: update defconfigs arch/s390/Kconfig| 2 +- arch/s390/configs/debug_defconfig| 4 arch/s390/configs/defconfig | 3 +++ arch/s390/configs/zfcpdump_defconfig | 1 + 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig index 3d86e12e8e3c..b29fcc66ec39 100644 --- a/arch/s390/Kconfig +++ b/arch/s390/Kconfig @@ -30,7 +30,7 @@ config GENERIC_BUG_RELATIVE_POINTERS def_bool y config GENERIC_LOCKBREAK - def_bool y if PREEMPTTION + def_bool y if PREEMPTION config PGSTE def_bool y if KVM diff --git a/arch/s390/configs/debug_defconfig b/arch/s390/configs/debug_defconfig index 0cf9a82326a8..7228aabe9da6 100644 --- a/arch/s390/configs/debug_defconfig +++ b/arch/s390/configs/debug_defconfig @@ -626,6 +626,7 @@ CONFIG_NTFS_RW=y CONFIG_PROC_KCORE=y CONFIG_TMPFS=y CONFIG_TMPFS_POSIX_ACL=y +CONFIG_TMPFS_INODE64=y CONFIG_HUGETLBFS=y CONFIG_CONFIGFS_FS=m CONFIG_ECRYPT_FS=m @@ -807,6 +808,7 @@ CONFIG_DEBUG_NOTIFIERS=y CONFIG_BUG_ON_DATA_CORRUPTION=y CONFIG_DEBUG_CREDENTIALS=y CONFIG_RCU_TORTURE_TEST=m +CONFIG_RCU_REF_SCALE_TEST=m CONFIG_RCU_CPU_STALL_TIMEOUT=300 # CONFIG_RCU_TRACE is not set CONFIG_LATENCYTOP=y @@ -818,6 +820,7 @@ CONFIG_PREEMPT_TRACER=y CONFIG_SCHED_TRACER=y CONFIG_FTRACE_SYSCALLS=y CONFIG_BLK_DEV_IO_TRACE=y +CONFIG_BPF_KPROBE_OVERRIDE=y CONFIG_HIST_TRIGGERS=y CONFIG_S390_PTDUMP=y CONFIG_NOTIFIER_ERROR_INJECTION=m @@ -829,6 +832,7 @@ CONFIG_FAIL_MAKE_REQUEST=y CONFIG_FAIL_IO_TIMEOUT=y CONFIG_FAIL_FUTEX=y CONFIG_FAULT_INJECTION_DEBUG_FS=y +CONFIG_FAIL_FUNCTION=y CONFIG_FAULT_INJECTION_STACKTRACE_FILTER=y CONFIG_LKDTM=m CONFIG_TEST_LIST_SORT=y diff --git a/arch/s390/configs/defconfig b/arch/s390/configs/defconfig index 5df9759e8ff6..fab03b7a6932 100644 --- a/arch/s390/configs/defconfig +++ b/arch/s390/configs/defconfig @@ -617,6 +617,7 @@ CONFIG_NTFS_RW=y CONFIG_PROC_KCORE=y CONFIG_TMPFS=y CONFIG_TMPFS_POSIX_ACL=y +CONFIG_TMPFS_INODE64=y CONFIG_HUGETLBFS=y CONFIG_CONFIGFS_FS=m CONFIG_ECRYPT_FS=m @@ -763,6 +764,7 @@ CONFIG_PANIC_ON_OOPS=y CONFIG_TEST_LOCKUP=m CONFIG_BUG_ON_DATA_CORRUPTION=y CONFIG_RCU_TORTURE_TEST=m +CONFIG_RCU_REF_SCALE_TEST=m CONFIG_RCU_CPU_STALL_TIMEOUT=60 CONFIG_LATENCYTOP=y CONFIG_BOOTTIME_TRACING=y @@ -771,6 +773,7 @@ CONFIG_STACK_TRACER=y CONFIG_SCHED_TRACER=y CONFIG_FTRACE_SYSCALLS=y CONFIG_BLK_DEV_IO_TRACE=y +CONFIG_BPF_KPROBE_OVERRIDE=y CONFIG_HIST_TRIGGERS=y CONFIG_S390_PTDUMP=y CONFIG_LKDTM=m diff --git a/arch/s390/configs/zfcpdump_defconfig b/arch/s390/configs/zfcpdump_defconfig index 4091c50449cd..8f67c55625f9 100644 --- a/arch/s390/configs/zfcpdump_defconfig +++ b/arch/s390/configs/zfcpdump_defconfig @@ -74,5 +74,6 @@ CONFIG_DEBUG_KERNEL=y CONFIG_PANIC_ON_OOPS=y # CONFIG_SCHED_DEBUG is not set CONFIG_RCU_CPU_STALL_TIMEOUT=60 +# CONFIG_RCU_TRACE is not set # CONFIG_FTRACE is not set # CONFIG_RUNTIME_TESTING_MENU is not set
[PATCH] kbuild: remove unused OBJSIZE
The "size" tool has been solely used by s390 to enforce .bss section usage restrictions in early startup code. Since commit 980d5f9ab36b ("s390/boot: enable .bss section for compressed kernel") and commit 2e83e0eb85ca ("s390: clean .bss before running uncompressed kernel") these restrictions have been lifted for the decompressor and uncompressed kernel and the size tool is now unused. Signed-off-by: Vasily Gorbik --- Documentation/kbuild/llvm.rst | 5 ++--- Makefile | 4 +--- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Documentation/kbuild/llvm.rst b/Documentation/kbuild/llvm.rst index cf3ca236d2cc..21c847890d03 100644 --- a/Documentation/kbuild/llvm.rst +++ b/Documentation/kbuild/llvm.rst @@ -57,9 +57,8 @@ to enable them. :: They can be enabled individually. The full list of the parameters: :: make CC=clang LD=ld.lld AR=llvm-ar NM=llvm-nm STRIP=llvm-strip \ - OBJCOPY=llvm-objcopy OBJDUMP=llvm-objdump OBJSIZE=llvm-size \ - READELF=llvm-readelf HOSTCC=clang HOSTCXX=clang++ HOSTAR=llvm-ar \ - HOSTLD=ld.lld + OBJCOPY=llvm-objcopy OBJDUMP=llvm-objdump READELF=llvm-readelf \ + HOSTCC=clang HOSTCXX=clang++ HOSTAR=llvm-ar HOSTLD=ld.lld Currently, the integrated assembler is disabled by default. You can pass ``LLVM_IAS=1`` to enable it. diff --git a/Makefile b/Makefile index d35a59f98e83..d2123c2c829a 100644 --- a/Makefile +++ b/Makefile @@ -433,7 +433,6 @@ NM = llvm-nm OBJCOPY= llvm-objcopy OBJDUMP= llvm-objdump READELF= llvm-readelf -OBJSIZE= llvm-size STRIP = llvm-strip else CC = $(CROSS_COMPILE)gcc @@ -443,7 +442,6 @@ NM = $(CROSS_COMPILE)nm OBJCOPY= $(CROSS_COMPILE)objcopy OBJDUMP= $(CROSS_COMPILE)objdump READELF= $(CROSS_COMPILE)readelf -OBJSIZE= $(CROSS_COMPILE)size STRIP = $(CROSS_COMPILE)strip endif PAHOLE = pahole @@ -509,7 +507,7 @@ KBUILD_LDFLAGS := CLANG_FLAGS := export ARCH SRCARCH CONFIG_SHELL BASH HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE LD CC -export CPP AR NM STRIP OBJCOPY OBJDUMP OBJSIZE READELF PAHOLE RESOLVE_BTFIDS LEX YACC AWK INSTALLKERNEL +export CPP AR NM STRIP OBJCOPY OBJDUMP READELF PAHOLE RESOLVE_BTFIDS LEX YACC AWK INSTALLKERNEL export PERL PYTHON PYTHON3 CHECK CHECKFLAGS MAKE UTS_MACHINE HOSTCXX export KGZIP KBZIP2 KLZOP LZMA LZ4 XZ ZSTD export KBUILD_HOSTCXXFLAGS KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS LDFLAGS_MODULE -- 2.25.4