All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ARM: decompressor: clean decompressed kernel from cache twice on v7
@ 2021-02-04 13:02 Ard Biesheuvel
  2021-02-05  8:53 ` Ard Biesheuvel
  0 siblings, 1 reply; 2+ messages in thread
From: Ard Biesheuvel @ 2021-02-04 13:02 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: kernelci.org bot, maz, linus.walleij, linux, guillaume.tucker,
	Ard Biesheuvel

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" <bot@kernelci.org>
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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ARM: decompressor: clean decompressed kernel from cache twice on v7
  2021-02-04 13:02 [PATCH] ARM: decompressor: clean decompressed kernel from cache twice on v7 Ard Biesheuvel
@ 2021-02-05  8:53 ` Ard Biesheuvel
  0 siblings, 0 replies; 2+ messages in thread
From: Ard Biesheuvel @ 2021-02-05  8:53 UTC (permalink / raw)
  To: Linux ARM
  Cc: Marc Zyngier, Linus Walleij, Russell King, kernelci.org bot,
	Guillaume Tucker

On Thu, 4 Feb 2021 at 14:03, Ard Biesheuvel <ardb@kernel.org> 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" <bot@kernelci.org>
> Signed-off-by: Ard Biesheuvel <ardb@kernel.org>

Please disregard this patch - this turns out to be an interoperability
issue with LLVM ld.lld

> ---
>  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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-02-05  8:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-04 13:02 [PATCH] ARM: decompressor: clean decompressed kernel from cache twice on v7 Ard Biesheuvel
2021-02-05  8:53 ` Ard Biesheuvel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.