From: Sasha Levin Date: Fri, 17 Jul 2020 14:29:08 +0000 (-0400) Subject: Fixes for 4.14 X-Git-Tag: v4.4.231~74 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8fcbecf33088c885cd0bb1e27a84c6be6f9fb2a5;p=thirdparty%2Fkernel%2Fstable-queue.git Fixes for 4.14 Signed-off-by: Sasha Levin --- diff --git a/queue-4.14/arm64-alternative-use-true-and-false-for-boolean-val.patch b/queue-4.14/arm64-alternative-use-true-and-false-for-boolean-val.patch new file mode 100644 index 00000000000..1a06aaf25ef --- /dev/null +++ b/queue-4.14/arm64-alternative-use-true-and-false-for-boolean-val.patch @@ -0,0 +1,41 @@ +From 541e4c7d4481b61baf8c83156fef970e6735fd49 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 7 Aug 2018 18:59:57 -0500 +Subject: arm64: alternative: Use true and false for boolean values + +From: Gustavo A. R. Silva + +[ Upstream commit 3c4d9137eefecf273a520d392071ffc9df0a9a7a ] + +Return statements in functions returning bool should use true or false +instead of an integer value. This code was detected with the help of +Coccinelle. + +Signed-off-by: Gustavo A. R. Silva +Signed-off-by: Will Deacon +Signed-off-by: Sasha Levin +--- + arch/arm64/kernel/alternative.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/arch/arm64/kernel/alternative.c b/arch/arm64/kernel/alternative.c +index 5c4bce4ac381a..b9045d8d05d88 100644 +--- a/arch/arm64/kernel/alternative.c ++++ b/arch/arm64/kernel/alternative.c +@@ -47,11 +47,11 @@ static bool branch_insn_requires_update(struct alt_instr *alt, unsigned long pc) + unsigned long replptr; + + if (kernel_text_address(pc)) +- return 1; ++ return true; + + replptr = (unsigned long)ALT_REPL_PTR(alt); + if (pc >= replptr && pc <= (replptr + alt->alt_len)) +- return 0; ++ return false; + + /* + * Branching into *another* alternate sequence is doomed, and +-- +2.25.1 + diff --git a/queue-4.14/arm64-alternatives-don-t-patch-up-internal-branches.patch b/queue-4.14/arm64-alternatives-don-t-patch-up-internal-branches.patch new file mode 100644 index 00000000000..4cc1a93c162 --- /dev/null +++ b/queue-4.14/arm64-alternatives-don-t-patch-up-internal-branches.patch @@ -0,0 +1,64 @@ +From eb91e36393023cc9b933c632d2b3d856274b87c6 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 9 Jul 2020 15:59:53 +0300 +Subject: arm64/alternatives: don't patch up internal branches + +From: Ard Biesheuvel + +[ Upstream commit 5679b28142193a62f6af93249c0477be9f0c669b ] + +Commit f7b93d42945c ("arm64/alternatives: use subsections for replacement +sequences") moved the alternatives replacement sequences into subsections, +in order to keep the as close as possible to the code that they replace. + +Unfortunately, this broke the logic in branch_insn_requires_update, +which assumed that any branch into kernel executable code was a branch +that required updating, which is no longer the case now that the code +sequences that are patched in are in the same section as the patch site +itself. + +So the only way to discriminate branches that require updating and ones +that don't is to check whether the branch targets the replacement sequence +itself, and so we can drop the call to kernel_text_address() entirely. + +Fixes: f7b93d42945c ("arm64/alternatives: use subsections for replacement sequences") +Reported-by: Alexandru Elisei +Signed-off-by: Ard Biesheuvel +Tested-by: Alexandru Elisei +Link: https://lore.kernel.org/r/20200709125953.30918-1-ardb@kernel.org +Signed-off-by: Will Deacon +Signed-off-by: Sasha Levin +--- + arch/arm64/kernel/alternative.c | 16 ++-------------- + 1 file changed, 2 insertions(+), 14 deletions(-) + +diff --git a/arch/arm64/kernel/alternative.c b/arch/arm64/kernel/alternative.c +index b9045d8d05d88..4c385763c361f 100644 +--- a/arch/arm64/kernel/alternative.c ++++ b/arch/arm64/kernel/alternative.c +@@ -44,20 +44,8 @@ struct alt_region { + */ + static bool branch_insn_requires_update(struct alt_instr *alt, unsigned long pc) + { +- unsigned long replptr; +- +- if (kernel_text_address(pc)) +- return true; +- +- replptr = (unsigned long)ALT_REPL_PTR(alt); +- if (pc >= replptr && pc <= (replptr + alt->alt_len)) +- return false; +- +- /* +- * Branching into *another* alternate sequence is doomed, and +- * we're not even trying to fix it up. +- */ +- BUG(); ++ unsigned long replptr = (unsigned long)ALT_REPL_PTR(alt); ++ return !(pc >= replptr && pc <= (replptr + alt->alt_len)); + } + + #define align_down(x, a) ((unsigned long)(x) & ~(((unsigned long)(a)) - 1)) +-- +2.25.1 + diff --git a/queue-4.14/series b/queue-4.14/series index 981f21ba062..08661e5f8cc 100644 --- a/queue-4.14/series +++ b/queue-4.14/series @@ -57,3 +57,5 @@ arm64-alternatives-use-subsections-for-replacement-s.patch tpm_tis-extra-chip-ops-check-on-error-path-in-tpm_ti.patch gfs2-read-only-mounts-should-grab-the-sd_freeze_gl-g.patch i2c-eg20t-load-module-automatically-if-id-matches.patch +arm64-alternative-use-true-and-false-for-boolean-val.patch +arm64-alternatives-don-t-patch-up-internal-branches.patch