All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] raspberrypi: reserve first two pages in efi memory map
@ 2020-02-26 14:03 kevans at FreeBSD.org
  2020-02-26 18:06 ` Matthias Brugger
  0 siblings, 1 reply; 4+ messages in thread
From: kevans at FreeBSD.org @ 2020-02-26 14:03 UTC (permalink / raw)
  To: u-boot

From: Kyle Evans <kevans@FreeBSD.org>

The psci stub provided by Raspberry Pi is around 5k in size, thus residing
in the first two pages of memory. Without this reservation, the next stage
or OS assume they're free to use the second page and may get catastrophic
results from clobbering it.

Signed-off-by: Kyle Evans <kevans@FreeBSD.org>
Cc: Matthias Brugger <mbrugger@suse.com>
---
 board/raspberrypi/rpi/rpi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c
index e367ba3092..d3f9bd16ac 100644
--- a/board/raspberrypi/rpi/rpi.c
+++ b/board/raspberrypi/rpi/rpi.c
@@ -488,8 +488,8 @@ int ft_board_setup(void *blob, bd_t *bd)
 	lcd_dt_simplefb_add_node(blob);
 
 #ifdef CONFIG_EFI_LOADER
-	/* Reserve the spin table */
-	efi_add_memory_map(0, 1, EFI_RESERVED_MEMORY_TYPE, 0);
+	/* Reserve the first two pages for spin table/psci stub. */
+	efi_add_memory_map(0, 2, EFI_RESERVED_MEMORY_TYPE, 0);
 #endif
 
 	return 0;
-- 
2.25.1

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

* [PATCH] raspberrypi: reserve first two pages in efi memory map
  2020-02-26 14:03 [PATCH] raspberrypi: reserve first two pages in efi memory map kevans at FreeBSD.org
@ 2020-02-26 18:06 ` Matthias Brugger
  2020-02-26 18:26   ` Kyle Evans
  0 siblings, 1 reply; 4+ messages in thread
From: Matthias Brugger @ 2020-02-26 18:06 UTC (permalink / raw)
  To: u-boot



On 26/02/2020 15:03, kevans at FreeBSD.org wrote:
> From: Kyle Evans <kevans@FreeBSD.org>
> 
> The psci stub provided by Raspberry Pi is around 5k in size, thus residing
> in the first two pages of memory. Without this reservation, the next stage
> or OS assume they're free to use the second page and may get catastrophic
> results from clobbering it.
> 
> Signed-off-by: Kyle Evans <kevans@FreeBSD.org>
> Cc: Matthias Brugger <mbrugger@suse.com>
> ---
>  board/raspberrypi/rpi/rpi.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c
> index e367ba3092..d3f9bd16ac 100644
> --- a/board/raspberrypi/rpi/rpi.c
> +++ b/board/raspberrypi/rpi/rpi.c
> @@ -488,8 +488,8 @@ int ft_board_setup(void *blob, bd_t *bd)
>  	lcd_dt_simplefb_add_node(blob);
>  
>  #ifdef CONFIG_EFI_LOADER
> -	/* Reserve the spin table */
> -	efi_add_memory_map(0, 1, EFI_RESERVED_MEMORY_TYPE, 0);
> +	/* Reserve the first two pages for spin table/psci stub. */
> +	efi_add_memory_map(0, 2, EFI_RESERVED_MEMORY_TYPE, 0);

Is this that changed recently or was the memory reservation wrong from the
beginning?

Reagrds,
Matthias

>  #endif
>  
>  	return 0;
> 

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

* [PATCH] raspberrypi: reserve first two pages in efi memory map
  2020-02-26 18:06 ` Matthias Brugger
@ 2020-02-26 18:26   ` Kyle Evans
  2020-02-26 18:41     ` Kyle Evans
  0 siblings, 1 reply; 4+ messages in thread
From: Kyle Evans @ 2020-02-26 18:26 UTC (permalink / raw)
  To: u-boot

On Wed, Feb 26, 2020 at 12:06 PM Matthias Brugger <mbrugger@suse.com> wrote:
>
>
>
> On 26/02/2020 15:03, kevans at FreeBSD.org wrote:
> > From: Kyle Evans <kevans@FreeBSD.org>
> >
> > The psci stub provided by Raspberry Pi is around 5k in size, thus residing
> > in the first two pages of memory. Without this reservation, the next stage
> > or OS assume they're free to use the second page and may get catastrophic
> > results from clobbering it.
> >
> > Signed-off-by: Kyle Evans <kevans@FreeBSD.org>
> > Cc: Matthias Brugger <mbrugger@suse.com>
> > ---
> >  board/raspberrypi/rpi/rpi.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c
> > index e367ba3092..d3f9bd16ac 100644
> > --- a/board/raspberrypi/rpi/rpi.c
> > +++ b/board/raspberrypi/rpi/rpi.c
> > @@ -488,8 +488,8 @@ int ft_board_setup(void *blob, bd_t *bd)
> >       lcd_dt_simplefb_add_node(blob);
> >
> >  #ifdef CONFIG_EFI_LOADER
> > -     /* Reserve the spin table */
> > -     efi_add_memory_map(0, 1, EFI_RESERVED_MEMORY_TYPE, 0);
> > +     /* Reserve the first two pages for spin table/psci stub. */
> > +     efi_add_memory_map(0, 2, EFI_RESERVED_MEMORY_TYPE, 0);
>
> Is this that changed recently or was the memory reservation wrong from the
> beginning?
>

As far as I can tell it just wasn't quite accounted for in the initial
reservation -- Linux presumably uses spin-table as described in the
DTS, where-as FreeBSD opts for PSCI instead since it's available. I
don't have a good intuition for who else may be using PSCI for RPi; we
may be in the minority.

FWIW, /memreserve/ in the upstream (raspberrypi/firmware) DTB also do
not account for PSCI stubs -- I've filed an issue[1] there, as well.

Thanks,

Kyle Evans

[1] https://github.com/raspberrypi/firmware/issues/1340

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

* [PATCH] raspberrypi: reserve first two pages in efi memory map
  2020-02-26 18:26   ` Kyle Evans
@ 2020-02-26 18:41     ` Kyle Evans
  0 siblings, 0 replies; 4+ messages in thread
From: Kyle Evans @ 2020-02-26 18:41 UTC (permalink / raw)
  To: u-boot

On Wed, Feb 26, 2020 at 12:26 PM Kyle Evans <kevans@freebsd.org> wrote:
>
> On Wed, Feb 26, 2020 at 12:06 PM Matthias Brugger <mbrugger@suse.com> wrote:
> >
> >
> >
> > On 26/02/2020 15:03, kevans at FreeBSD.org wrote:
> > > From: Kyle Evans <kevans@FreeBSD.org>
> > >
> > > The psci stub provided by Raspberry Pi is around 5k in size, thus residing
> > > in the first two pages of memory. Without this reservation, the next stage
> > > or OS assume they're free to use the second page and may get catastrophic
> > > results from clobbering it.
> > >
> > > Signed-off-by: Kyle Evans <kevans@FreeBSD.org>
> > > Cc: Matthias Brugger <mbrugger@suse.com>
> > > ---
> > >  board/raspberrypi/rpi/rpi.c | 4 ++--
> > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c
> > > index e367ba3092..d3f9bd16ac 100644
> > > --- a/board/raspberrypi/rpi/rpi.c
> > > +++ b/board/raspberrypi/rpi/rpi.c
> > > @@ -488,8 +488,8 @@ int ft_board_setup(void *blob, bd_t *bd)
> > >       lcd_dt_simplefb_add_node(blob);
> > >
> > >  #ifdef CONFIG_EFI_LOADER
> > > -     /* Reserve the spin table */
> > > -     efi_add_memory_map(0, 1, EFI_RESERVED_MEMORY_TYPE, 0);
> > > +     /* Reserve the first two pages for spin table/psci stub. */
> > > +     efi_add_memory_map(0, 2, EFI_RESERVED_MEMORY_TYPE, 0);
> >
> > Is this that changed recently or was the memory reservation wrong from the
> > beginning?
> >
>
> As far as I can tell it just wasn't quite accounted for in the initial
> reservation -- Linux presumably uses spin-table as described in the
> DTS, where-as FreeBSD opts for PSCI instead since it's available. I
> don't have a good intuition for who else may be using PSCI for RPi; we
> may be in the minority.
>
> FWIW, /memreserve/ in the upstream (raspberrypi/firmware) DTB also do
> not account for PSCI stubs -- I've filed an issue[1] there, as well.
>
> Thanks,
>
> Kyle Evans
>
> [1] https://github.com/raspberrypi/firmware/issues/1340

Upon further examination, it looks like I've managed to confuse myself
and we're using our own stub derived from the upstream spintable
stuff... let's disregard this patch, I'll look into rolling up a new
one as both upstream implementation and ours should pass the required
reservation size through to U-Boot via x1.

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

end of thread, other threads:[~2020-02-26 18:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-26 14:03 [PATCH] raspberrypi: reserve first two pages in efi memory map kevans at FreeBSD.org
2020-02-26 18:06 ` Matthias Brugger
2020-02-26 18:26   ` Kyle Evans
2020-02-26 18:41     ` Kyle Evans

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.