[PATCH] ARM: decompressor: clean decompressed kernel from cache twice on v7

Subsystems: arm port, the rest

STALE2049d

2 messages, 1 author, 2021-02-05 · open the first message on its own page

[PATCH] ARM: decompressor: clean decompressed kernel from cache twice on v7

From: Ard Biesheuvel <ardb@kernel.org>
Date: 2021-02-04 13:04:32

Commit 5a29552af92dbd62 ("ARM: 9052/1: decompressor: cover BSS in cache
clean and reorder with MMU disable on v7") moved cleaning of the kernel
image to after the point where the MMU and caches are disabled, which is
more in line with the architectural requirements. Unfortunately, doing
so caused a regression on Clang builds, crashing before any diagnostic
output is printed.

Given that the full cleaning the cache afterwards is required in any
case, let's reinstate the original cache clean of just the decompressed
image occurring beforehand, amounting to a partial revert of the commit
in question. Doing so has been confirmed by the reporter of the
regression to mitigate it.

Fixes: 5a29552af92dbd62 ("ARM: 9052/1: decompressor: cover BSS in ...")
Reported-by: "kernelci.org bot" <redacted>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
 arch/arm/boot/compressed/head.S | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S
index 5c97d341de6b..4e49ac64bf49 100644
--- a/arch/arm/boot/compressed/head.S
+++ b/arch/arm/boot/compressed/head.S
@@ -616,14 +616,18 @@ not_relocated:	mov	r0, #0
 		@ operations on the range [R0, R1], making this prior call to
 		@ cache_clean_flush() redundant. In other cases, the clean is
 		@ performed by set/way and R0/R1 are ignored.
+		@ However, not performing the redundant cache clean before
+		@ turning the MMU and caches off has been observed to cause
+		@ regressions, so on v7+ systems, the decompressed kernel image
+		@ is cleaned twice.
 		@
-		mov	r0, #0
-		mov	r1, #0
+		get_inflated_image_size	r6, r2, r3
+		mov	r0, r4			@ start of decompressed kernel
+		add	r1, r0, r6		@ end of decompressed kernel
 		bl	cache_clean_flush
 
-		get_inflated_image_size	r1, r2, r3
 		ldr	r2, =_kernel_bss_size
-		add	r1, r1, r2
+		add	r1, r2, r6
 
 		mov	r0, r4			@ start of decompressed kernel
 		add	r1, r1, r0		@ end of kernel BSS
-- 
2.20.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

Re: [PATCH] ARM: decompressor: clean decompressed kernel from cache twice on v7

From: Ard Biesheuvel <ardb@kernel.org>
Date: 2021-02-05 08:55:24

On Thu, 4 Feb 2021 at 14:03, Ard Biesheuvel [off-list ref] wrote:
Commit 5a29552af92dbd62 ("ARM: 9052/1: decompressor: cover BSS in cache
clean and reorder with MMU disable on v7") moved cleaning of the kernel
image to after the point where the MMU and caches are disabled, which is
more in line with the architectural requirements. Unfortunately, doing
so caused a regression on Clang builds, crashing before any diagnostic
output is printed.

Given that the full cleaning the cache afterwards is required in any
case, let's reinstate the original cache clean of just the decompressed
image occurring beforehand, amounting to a partial revert of the commit
in question. Doing so has been confirmed by the reporter of the
regression to mitigate it.

Fixes: 5a29552af92dbd62 ("ARM: 9052/1: decompressor: cover BSS in ...")
Reported-by: "kernelci.org bot" <redacted>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Please disregard this patch - this turns out to be an interoperability
issue with LLVM ld.lld
quoted hunk
---
 arch/arm/boot/compressed/head.S | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S
index 5c97d341de6b..4e49ac64bf49 100644
--- a/arch/arm/boot/compressed/head.S
+++ b/arch/arm/boot/compressed/head.S
@@ -616,14 +616,18 @@ not_relocated:    mov     r0, #0
                @ operations on the range [R0, R1], making this prior call to
                @ cache_clean_flush() redundant. In other cases, the clean is
                @ performed by set/way and R0/R1 are ignored.
+               @ However, not performing the redundant cache clean before
+               @ turning the MMU and caches off has been observed to cause
+               @ regressions, so on v7+ systems, the decompressed kernel image
+               @ is cleaned twice.
                @
-               mov     r0, #0
-               mov     r1, #0
+               get_inflated_image_size r6, r2, r3
+               mov     r0, r4                  @ start of decompressed kernel
+               add     r1, r0, r6              @ end of decompressed kernel
                bl      cache_clean_flush

-               get_inflated_image_size r1, r2, r3
                ldr     r2, =_kernel_bss_size
-               add     r1, r1, r2
+               add     r1, r2, r6

                mov     r0, r4                  @ start of decompressed kernel
                add     r1, r1, r0              @ end of kernel BSS
--
2.20.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help