From: Sasha Levin Date: Sun, 24 May 2020 13:51:24 +0000 (-0400) Subject: Fixes for 5.4 X-Git-Tag: v4.4.225~32 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2cb0bcf79d239fe847cae367b41906e75d9c954c;p=thirdparty%2Fkernel%2Fstable-queue.git Fixes for 5.4 Signed-off-by: Sasha Levin --- diff --git a/queue-5.4/bpf-avoid-setting-bpf-insns-pages-read-only-when-pro.patch b/queue-5.4/bpf-avoid-setting-bpf-insns-pages-read-only-when-pro.patch new file mode 100644 index 00000000000..84628513a2f --- /dev/null +++ b/queue-5.4/bpf-avoid-setting-bpf-insns-pages-read-only-when-pro.patch @@ -0,0 +1,49 @@ +From 68140e8c2db5f66566544090842b263755994bae Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 29 Nov 2019 23:29:11 +0100 +Subject: bpf: Avoid setting bpf insns pages read-only when prog is jited + +From: Daniel Borkmann + +[ Upstream commit e1608f3fa857b600045b6df7f7dadc70eeaa4496 ] + +For the case where the interpreter is compiled out or when the prog is jited +it is completely unnecessary to set the BPF insn pages as read-only. In fact, +on frequent churn of BPF programs, it could lead to performance degradation of +the system over time since it would break the direct map down to 4k pages when +calling set_memory_ro() for the insn buffer on x86-64 / arm64 and there is no +reverse operation. Thus, avoid breaking up large pages for data maps, and only +limit this to the module range used by the JIT where it is necessary to set +the image read-only and executable. + +Suggested-by: Peter Zijlstra +Signed-off-by: Daniel Borkmann +Signed-off-by: Alexei Starovoitov +Link: https://lore.kernel.org/bpf/20191129222911.3710-1-daniel@iogearbox.net +Signed-off-by: Sasha Levin +--- + include/linux/filter.h | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +diff --git a/include/linux/filter.h b/include/linux/filter.h +index 0367a75f873b..3bbc72dbc69e 100644 +--- a/include/linux/filter.h ++++ b/include/linux/filter.h +@@ -770,8 +770,12 @@ bpf_ctx_narrow_access_offset(u32 off, u32 size, u32 size_default) + + static inline void bpf_prog_lock_ro(struct bpf_prog *fp) + { +- set_vm_flush_reset_perms(fp); +- set_memory_ro((unsigned long)fp, fp->pages); ++#ifndef CONFIG_BPF_JIT_ALWAYS_ON ++ if (!fp->jited) { ++ set_vm_flush_reset_perms(fp); ++ set_memory_ro((unsigned long)fp, fp->pages); ++ } ++#endif + } + + static inline void bpf_jit_binary_lock_ro(struct bpf_binary_header *hdr) +-- +2.25.1 + diff --git a/queue-5.4/kbuild-remove-debug-info-from-kallsyms-linking.patch b/queue-5.4/kbuild-remove-debug-info-from-kallsyms-linking.patch new file mode 100644 index 00000000000..ec562468404 --- /dev/null +++ b/queue-5.4/kbuild-remove-debug-info-from-kallsyms-linking.patch @@ -0,0 +1,142 @@ +From bfc32cab387b55e358d7055b44b81a111876280b Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 3 Mar 2020 18:18:34 -0800 +Subject: kbuild: Remove debug info from kallsyms linking + +From: Kees Cook + +[ Upstream commit af73d78bd384aa9b8789aa6e7ddbb165f971276f ] + +When CONFIG_DEBUG_INFO is enabled, the two kallsyms linking steps spend +time collecting and writing the dwarf sections to the temporary output +files. kallsyms does not need this information, and leaving it off +halves their linking time. This is especially noticeable without +CONFIG_DEBUG_INFO_REDUCED. The BTF linking stage, however, does still +need those details. + +Refactor the BTF and kallsyms generation stages slightly for more +regularized temporary names. Skip debug during kallsyms links. +Additionally move "info BTF" to the correct place since commit +8959e39272d6 ("kbuild: Parameterize kallsyms generation and correct +reporting"), which added "info LD ..." to vmlinux_link calls. + +For a full debug info build with BTF, my link time goes from 1m06s to +0m54s, saving about 12 seconds, or 18%. + +Signed-off-by: Kees Cook +Signed-off-by: Daniel Borkmann +Acked-by: Andrii Nakryiko +Link: https://lore.kernel.org/bpf/202003031814.4AEA3351@keescook +Signed-off-by: Sasha Levin +--- + scripts/link-vmlinux.sh | 28 +++++++++++++++++++--------- + 1 file changed, 19 insertions(+), 9 deletions(-) + +diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh +index 408b5c0b99b1..aa1386079f0c 100755 +--- a/scripts/link-vmlinux.sh ++++ b/scripts/link-vmlinux.sh +@@ -63,12 +63,18 @@ vmlinux_link() + local lds="${objtree}/${KBUILD_LDS}" + local output=${1} + local objects ++ local strip_debug + + info LD ${output} + + # skip output file argument + shift + ++ # The kallsyms linking does not need debug symbols included. ++ if [ "$output" != "${output#.tmp_vmlinux.kallsyms}" ] ; then ++ strip_debug=-Wl,--strip-debug ++ fi ++ + if [ "${SRCARCH}" != "um" ]; then + objects="--whole-archive \ + ${KBUILD_VMLINUX_OBJS} \ +@@ -79,6 +85,7 @@ vmlinux_link() + ${@}" + + ${LD} ${KBUILD_LDFLAGS} ${LDFLAGS_vmlinux} \ ++ ${strip_debug#-Wl,} \ + -o ${output} \ + -T ${lds} ${objects} + else +@@ -91,6 +98,7 @@ vmlinux_link() + ${@}" + + ${CC} ${CFLAGS_vmlinux} \ ++ ${strip_debug} \ + -o ${output} \ + -Wl,-T,${lds} \ + ${objects} \ +@@ -106,6 +114,8 @@ gen_btf() + { + local pahole_ver + local bin_arch ++ local bin_format ++ local bin_file + + if ! [ -x "$(command -v ${PAHOLE})" ]; then + echo >&2 "BTF: ${1}: pahole (${PAHOLE}) is not available" +@@ -118,8 +128,9 @@ gen_btf() + return 1 + fi + +- info "BTF" ${2} + vmlinux_link ${1} ++ ++ info "BTF" ${2} + LLVM_OBJCOPY=${OBJCOPY} ${PAHOLE} -J ${1} + + # dump .BTF section into raw binary file to link with final vmlinux +@@ -127,11 +138,12 @@ gen_btf() + cut -d, -f1 | cut -d' ' -f2) + bin_format=$(LANG=C ${OBJDUMP} -f ${1} | grep 'file format' | \ + awk '{print $4}') ++ bin_file=.btf.vmlinux.bin + ${OBJCOPY} --change-section-address .BTF=0 \ + --set-section-flags .BTF=alloc -O binary \ +- --only-section=.BTF ${1} .btf.vmlinux.bin ++ --only-section=.BTF ${1} $bin_file + ${OBJCOPY} -I binary -O ${bin_format} -B ${bin_arch} \ +- --rename-section .data=.BTF .btf.vmlinux.bin ${2} ++ --rename-section .data=.BTF $bin_file ${2} + } + + # Create ${2} .o file with all symbols from the ${1} object file +@@ -166,8 +178,8 @@ kallsyms() + kallsyms_step() + { + kallsymso_prev=${kallsymso} +- kallsymso=.tmp_kallsyms${1}.o +- kallsyms_vmlinux=.tmp_vmlinux${1} ++ kallsyms_vmlinux=.tmp_vmlinux.kallsyms${1} ++ kallsymso=${kallsyms_vmlinux}.o + + vmlinux_link ${kallsyms_vmlinux} "${kallsymso_prev}" ${btf_vmlinux_bin_o} + kallsyms ${kallsyms_vmlinux} ${kallsymso} +@@ -190,7 +202,6 @@ cleanup() + { + rm -f .btf.* + rm -f .tmp_System.map +- rm -f .tmp_kallsyms* + rm -f .tmp_vmlinux* + rm -f System.map + rm -f vmlinux +@@ -253,9 +264,8 @@ ${OBJCOPY} -j .modinfo -O binary vmlinux.o modules.builtin.modinfo + + btf_vmlinux_bin_o="" + if [ -n "${CONFIG_DEBUG_INFO_BTF}" ]; then +- if gen_btf .tmp_vmlinux.btf .btf.vmlinux.bin.o ; then +- btf_vmlinux_bin_o=.btf.vmlinux.bin.o +- else ++ btf_vmlinux_bin_o=.btf.vmlinux.bin.o ++ if ! gen_btf .tmp_vmlinux.btf $btf_vmlinux_bin_o ; then + echo >&2 "Failed to generate BTF for vmlinux" + echo >&2 "Try to disable CONFIG_DEBUG_INFO_BTF" + exit 1 +-- +2.25.1 + diff --git a/queue-5.4/media-fdp1-fix-r-car-m3-n-naming-in-debug-message.patch b/queue-5.4/media-fdp1-fix-r-car-m3-n-naming-in-debug-message.patch new file mode 100644 index 00000000000..3b11bb1bc95 --- /dev/null +++ b/queue-5.4/media-fdp1-fix-r-car-m3-n-naming-in-debug-message.patch @@ -0,0 +1,37 @@ +From a67a3781f4ce8cffccb1597ffb885fa0b8011ecf Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 24 Oct 2019 10:09:16 -0300 +Subject: media: fdp1: Fix R-Car M3-N naming in debug message + +From: Geert Uytterhoeven + +[ Upstream commit c05b9d7b9f3ece2831e4e4829f10e904df296df8 ] + +The official name is "R-Car M3-N", not "R-Car M3N". + +Fixes: 4e8c120de9268fc2 ("media: fdp1: Support M3N and E3 platforms") +Signed-off-by: Geert Uytterhoeven +Reviewed-by: Kieran Bingham +Signed-off-by: Hans Verkuil +Signed-off-by: Mauro Carvalho Chehab +Signed-off-by: Sasha Levin +--- + drivers/media/platform/rcar_fdp1.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/media/platform/rcar_fdp1.c b/drivers/media/platform/rcar_fdp1.c +index cb93a13e1777..97bed45360f0 100644 +--- a/drivers/media/platform/rcar_fdp1.c ++++ b/drivers/media/platform/rcar_fdp1.c +@@ -2369,7 +2369,7 @@ static int fdp1_probe(struct platform_device *pdev) + dprintk(fdp1, "FDP1 Version R-Car H3\n"); + break; + case FD1_IP_M3N: +- dprintk(fdp1, "FDP1 Version R-Car M3N\n"); ++ dprintk(fdp1, "FDP1 Version R-Car M3-N\n"); + break; + case FD1_IP_E3: + dprintk(fdp1, "FDP1 Version R-Car E3\n"); +-- +2.25.1 + diff --git a/queue-5.4/revert-gfs2-don-t-demote-a-glock-until-its-revokes-a.patch b/queue-5.4/revert-gfs2-don-t-demote-a-glock-until-its-revokes-a.patch new file mode 100644 index 00000000000..be8ddf3b8a9 --- /dev/null +++ b/queue-5.4/revert-gfs2-don-t-demote-a-glock-until-its-revokes-a.patch @@ -0,0 +1,48 @@ +From 3f23edac4a55b9f605c2ce5ee8b525b34aab1202 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 8 May 2020 15:01:25 -0500 +Subject: Revert "gfs2: Don't demote a glock until its revokes are written" + +From: Bob Peterson + +[ Upstream commit b14c94908b1b884276a6608dea3d0b1b510338b7 ] + +This reverts commit df5db5f9ee112e76b5202fbc331f990a0fc316d6. + +This patch fixes a regression: patch df5db5f9ee112 allowed function +run_queue() to bypass its call to do_xmote() if revokes were queued for +the glock. That's wrong because its call to do_xmote() is what is +responsible for calling the go_sync() glops functions to sync both +the ail list and any revokes queued for it. By bypassing the call, +gfs2 could get into a stand-off where the glock could not be demoted +until its revokes are written back, but the revokes would not be +written back because do_xmote() was never called. + +It "sort of" works, however, because there are other mechanisms like +the log flush daemon (logd) that can sync the ail items and revokes, +if it deems it necessary. The problem is: without file system pressure, +it might never deem it necessary. + +Signed-off-by: Bob Peterson +Signed-off-by: Sasha Levin +--- + fs/gfs2/glock.c | 3 --- + 1 file changed, 3 deletions(-) + +diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c +index 21820a5b388f..0290a22ebccf 100644 +--- a/fs/gfs2/glock.c ++++ b/fs/gfs2/glock.c +@@ -639,9 +639,6 @@ __acquires(&gl->gl_lockref.lock) + goto out_unlock; + if (nonblock) + goto out_sched; +- smp_mb(); +- if (atomic_read(&gl->gl_revokes) != 0) +- goto out_sched; + set_bit(GLF_DEMOTE_IN_PROGRESS, &gl->gl_flags); + GLOCK_BUG_ON(gl, gl->gl_demote_state == LM_ST_EXCLUSIVE); + gl->gl_target = gl->gl_demote_state; +-- +2.25.1 + diff --git a/queue-5.4/series b/queue-5.4/series index cf9521efa49..fc5b0f4c0a5 100644 --- a/queue-5.4/series +++ b/queue-5.4/series @@ -76,3 +76,7 @@ drm-i915-gvt-init-dpll-ddi-vreg-for-virtual-display-instead-of-inheritance.patch drm-i915-propagate-error-from-completed-fences.patch powerpc-remove-strict_kernel_rwx-incompatibility-wit.patch powerpc-64s-disable-strict_kernel_rwx.patch +bpf-avoid-setting-bpf-insns-pages-read-only-when-pro.patch +kbuild-remove-debug-info-from-kallsyms-linking.patch +revert-gfs2-don-t-demote-a-glock-until-its-revokes-a.patch +media-fdp1-fix-r-car-m3-n-naming-in-debug-message.patch