All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ARM: head.S: explicitly map DT even if it lives in the first physical section
@ 2020-11-16 14:56 Ard Biesheuvel
  2020-11-16 22:19 ` Guillaume Tucker
  2020-11-16 23:33 ` Linus Walleij
  0 siblings, 2 replies; 4+ messages in thread
From: Ard Biesheuvel @ 2020-11-16 14:56 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Ard Biesheuvel, guillaume.tucker, linus.walleij, linux, nico

The early ATAGS/DT mapping code uses SECTION_SHIFT to mask low order
bits of R2, and decides that no ATAGS/DTB were provided if the resulting
value is 0x0.

This means that on systems where DRAM starts at 0x0 (such as Raspberry
Pi), no explicit mapping of the DT will be created if R2 points into the
first 1 MB section of memory. This was not a problem before, because the
decompressed kernel is loaded at the base of DRAM and mapped using
sections as well, and so as long as the DT is referenced via a virtual
address that uses the same translation (the linear map, in this case),
things work fine.

However, commit 149a3ffe62b9dbc3 ("9012/1: move device tree mapping out of
linear region") changes this, and now the DT is referenced via a virtual
address that is disjoint from the linear mapping of DRAM, and so we need
the early code to create the DT mapping unconditionally.

So let's create the early DT mapping for any value of R2 != 0x0.

Fixes: 149a3ffe62b9dbc3 ("9012/1: move device tree mapping out of linear region")
Reported-by: Guillaume Tucker <guillaume.tucker@collabora.com>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
 arch/arm/kernel/head.S | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
index 28687fd1240a..7f62c5eccdf3 100644
--- a/arch/arm/kernel/head.S
+++ b/arch/arm/kernel/head.S
@@ -265,10 +265,10 @@ __create_page_tables:
 	 * We map 2 sections in case the ATAGs/DTB crosses a section boundary.
 	 */
 	mov	r0, r2, lsr #SECTION_SHIFT
-	movs	r0, r0, lsl #SECTION_SHIFT
+	cmp	r2, #0
 	ldrne	r3, =FDT_FIXED_BASE >> (SECTION_SHIFT - PMD_ORDER)
 	addne	r3, r3, r4
-	orrne	r6, r7, r0
+	orrne	r6, r7, r0, lsl #SECTION_SHIFT
 	strne	r6, [r3], #1 << PMD_ORDER
 	addne	r6, r6, #1 << SECTION_SHIFT
 	strne	r6, [r3]
-- 
2.17.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] 4+ messages in thread

* Re: [PATCH] ARM: head.S: explicitly map DT even if it lives in the first physical section
  2020-11-16 14:56 [PATCH] ARM: head.S: explicitly map DT even if it lives in the first physical section Ard Biesheuvel
@ 2020-11-16 22:19 ` Guillaume Tucker
  2020-11-16 23:33 ` Linus Walleij
  1 sibling, 0 replies; 4+ messages in thread
From: Guillaume Tucker @ 2020-11-16 22:19 UTC (permalink / raw)
  To: Ard Biesheuvel, linux-arm-kernel
  Cc: linus.walleij, linux, kernelci-results, nico

On 16/11/2020 14:56, Ard Biesheuvel wrote:
> The early ATAGS/DT mapping code uses SECTION_SHIFT to mask low order
> bits of R2, and decides that no ATAGS/DTB were provided if the resulting
> value is 0x0.
> 
> This means that on systems where DRAM starts at 0x0 (such as Raspberry
> Pi), no explicit mapping of the DT will be created if R2 points into the
> first 1 MB section of memory. This was not a problem before, because the
> decompressed kernel is loaded at the base of DRAM and mapped using
> sections as well, and so as long as the DT is referenced via a virtual
> address that uses the same translation (the linear map, in this case),
> things work fine.
> 
> However, commit 149a3ffe62b9dbc3 ("9012/1: move device tree mapping out of
> linear region") changes this, and now the DT is referenced via a virtual
> address that is disjoint from the linear mapping of DRAM, and so we need
> the early code to create the DT mapping unconditionally.
> 
> So let's create the early DT mapping for any value of R2 != 0x0.
> 
> Fixes: 149a3ffe62b9dbc3 ("9012/1: move device tree mapping out of linear region")
> Reported-by: Guillaume Tucker <guillaume.tucker@collabora.com>

This was initially found by a kernelci.org automated bisection,
so please also include this trailer if it's OK with you:

  Reported-by: "kernelci.org bot" <bot@kernelci.org>

As explained on the other thread, this fixes the early kernel
boot issue but then it fails to load the ramdisk.  I'll try to
see if there's any issue on the bootloader side.

Thanks,
Guillaume

> Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
> ---
>  arch/arm/kernel/head.S | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
> index 28687fd1240a..7f62c5eccdf3 100644
> --- a/arch/arm/kernel/head.S
> +++ b/arch/arm/kernel/head.S
> @@ -265,10 +265,10 @@ __create_page_tables:
>  	 * We map 2 sections in case the ATAGs/DTB crosses a section boundary.
>  	 */
>  	mov	r0, r2, lsr #SECTION_SHIFT
> -	movs	r0, r0, lsl #SECTION_SHIFT
> +	cmp	r2, #0
>  	ldrne	r3, =FDT_FIXED_BASE >> (SECTION_SHIFT - PMD_ORDER)
>  	addne	r3, r3, r4
> -	orrne	r6, r7, r0
> +	orrne	r6, r7, r0, lsl #SECTION_SHIFT
>  	strne	r6, [r3], #1 << PMD_ORDER
>  	addne	r6, r6, #1 << SECTION_SHIFT
>  	strne	r6, [r3]
> 


_______________________________________________
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] 4+ messages in thread

* Re: [PATCH] ARM: head.S: explicitly map DT even if it lives in the first physical section
  2020-11-16 14:56 [PATCH] ARM: head.S: explicitly map DT even if it lives in the first physical section Ard Biesheuvel
  2020-11-16 22:19 ` Guillaume Tucker
@ 2020-11-16 23:33 ` Linus Walleij
  2020-11-17  8:21   ` Ard Biesheuvel
  1 sibling, 1 reply; 4+ messages in thread
From: Linus Walleij @ 2020-11-16 23:33 UTC (permalink / raw)
  To: Ard Biesheuvel; +Cc: Guillaume Tucker, Russell King, Linux ARM, Nicolas Pitre

On Mon, Nov 16, 2020 at 3:57 PM Ard Biesheuvel <ardb@kernel.org> wrote:

> The early ATAGS/DT mapping code uses SECTION_SHIFT to mask low order
> bits of R2, and decides that no ATAGS/DTB were provided if the resulting
> value is 0x0.
>
> This means that on systems where DRAM starts at 0x0 (such as Raspberry
> Pi), no explicit mapping of the DT will be created if R2 points into the
> first 1 MB section of memory. This was not a problem before, because the
> decompressed kernel is loaded at the base of DRAM and mapped using
> sections as well, and so as long as the DT is referenced via a virtual
> address that uses the same translation (the linear map, in this case),
> things work fine.
>
> However, commit 149a3ffe62b9dbc3 ("9012/1: move device tree mapping out of
> linear region") changes this, and now the DT is referenced via a virtual
> address that is disjoint from the linear mapping of DRAM, and so we need
> the early code to create the DT mapping unconditionally.
>
> So let's create the early DT mapping for any value of R2 != 0x0.
>
> Fixes: 149a3ffe62b9dbc3 ("9012/1: move device tree mapping out of linear region")
> Reported-by: Guillaume Tucker <guillaume.tucker@collabora.com>
> Signed-off-by: Ard Biesheuvel <ardb@kernel.org>

That's a good catch!
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

_______________________________________________
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] 4+ messages in thread

* Re: [PATCH] ARM: head.S: explicitly map DT even if it lives in the first physical section
  2020-11-16 23:33 ` Linus Walleij
@ 2020-11-17  8:21   ` Ard Biesheuvel
  0 siblings, 0 replies; 4+ messages in thread
From: Ard Biesheuvel @ 2020-11-17  8:21 UTC (permalink / raw)
  To: Linus Walleij; +Cc: Guillaume Tucker, Russell King, Linux ARM, Nicolas Pitre

On Tue, 17 Nov 2020 at 00:33, Linus Walleij <linus.walleij@linaro.org> wrote:
>
> On Mon, Nov 16, 2020 at 3:57 PM Ard Biesheuvel <ardb@kernel.org> wrote:
>
> > The early ATAGS/DT mapping code uses SECTION_SHIFT to mask low order
> > bits of R2, and decides that no ATAGS/DTB were provided if the resulting
> > value is 0x0.
> >
> > This means that on systems where DRAM starts at 0x0 (such as Raspberry
> > Pi), no explicit mapping of the DT will be created if R2 points into the
> > first 1 MB section of memory. This was not a problem before, because the
> > decompressed kernel is loaded at the base of DRAM and mapped using
> > sections as well, and so as long as the DT is referenced via a virtual
> > address that uses the same translation (the linear map, in this case),
> > things work fine.
> >
> > However, commit 149a3ffe62b9dbc3 ("9012/1: move device tree mapping out of
> > linear region") changes this, and now the DT is referenced via a virtual
> > address that is disjoint from the linear mapping of DRAM, and so we need
> > the early code to create the DT mapping unconditionally.
> >
> > So let's create the early DT mapping for any value of R2 != 0x0.
> >
> > Fixes: 149a3ffe62b9dbc3 ("9012/1: move device tree mapping out of linear region")
> > Reported-by: Guillaume Tucker <guillaume.tucker@collabora.com>
> > Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
>
> That's a good catch!
> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
>

I have dropped this into rmk's patch system as 9027/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] 4+ messages in thread

end of thread, other threads:[~2020-11-17  8:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-16 14:56 [PATCH] ARM: head.S: explicitly map DT even if it lives in the first physical section Ard Biesheuvel
2020-11-16 22:19 ` Guillaume Tucker
2020-11-16 23:33 ` Linus Walleij
2020-11-17  8:21   ` 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.