All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hw/openrisc: page-align FDT address
@ 2022-04-28 10:35 ` Jason A. Donenfeld
  0 siblings, 0 replies; 4+ messages in thread
From: Jason A. Donenfeld @ 2022-04-28 10:35 UTC (permalink / raw)
  To: openrisc, qemu-devel, shorne; +Cc: Peter Maydell, Jason A. Donenfeld

The QEMU-provided FDT was only being recognized by the kernel when it
was used in conjunction with -initrd. Without it, the magic bytes
wouldn't be there and the kernel couldn't load it. This patch fixes the
issue by page aligning the provided FDT.

Cc: Stafford Horne <shorne@gmail.com>
Cc: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
 hw/openrisc/openrisc_sim.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/openrisc/openrisc_sim.c b/hw/openrisc/openrisc_sim.c
index 8184caa60b..99b14940f4 100644
--- a/hw/openrisc/openrisc_sim.c
+++ b/hw/openrisc/openrisc_sim.c
@@ -356,7 +356,7 @@ static uint32_t openrisc_load_fdt(Or1ksimState *state, hwaddr load_start,
     }
 
     /* We put fdt right after the kernel and/or initrd. */
-    fdt_addr = ROUND_UP(load_start, 4);
+    fdt_addr = TARGET_PAGE_ALIGN(load_start);
 
     ret = fdt_pack(fdt);
     /* Should only fail if we've built a corrupted tree */
-- 
2.35.1



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

* [OpenRISC] [PATCH] hw/openrisc: page-align FDT address
@ 2022-04-28 10:35 ` Jason A. Donenfeld
  0 siblings, 0 replies; 4+ messages in thread
From: Jason A. Donenfeld @ 2022-04-28 10:35 UTC (permalink / raw)
  To: openrisc

The QEMU-provided FDT was only being recognized by the kernel when it
was used in conjunction with -initrd. Without it, the magic bytes
wouldn't be there and the kernel couldn't load it. This patch fixes the
issue by page aligning the provided FDT.

Cc: Stafford Horne <shorne@gmail.com>
Cc: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
 hw/openrisc/openrisc_sim.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/openrisc/openrisc_sim.c b/hw/openrisc/openrisc_sim.c
index 8184caa60b..99b14940f4 100644
--- a/hw/openrisc/openrisc_sim.c
+++ b/hw/openrisc/openrisc_sim.c
@@ -356,7 +356,7 @@ static uint32_t openrisc_load_fdt(Or1ksimState *state, hwaddr load_start,
     }
 
     /* We put fdt right after the kernel and/or initrd. */
-    fdt_addr = ROUND_UP(load_start, 4);
+    fdt_addr = TARGET_PAGE_ALIGN(load_start);
 
     ret = fdt_pack(fdt);
     /* Should only fail if we've built a corrupted tree */
-- 
2.35.1


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

* Re: [PATCH] hw/openrisc: page-align FDT address
  2022-04-28 10:35 ` [OpenRISC] " Jason A. Donenfeld
@ 2022-04-28 12:01   ` Stafford Horne
  -1 siblings, 0 replies; 4+ messages in thread
From: Stafford Horne @ 2022-04-28 12:01 UTC (permalink / raw)
  To: Jason A. Donenfeld; +Cc: Peter Maydell, openrisc, qemu-devel

On Thu, Apr 28, 2022 at 12:35:16PM +0200, Jason A. Donenfeld wrote:
> The QEMU-provided FDT was only being recognized by the kernel when it
> was used in conjunction with -initrd. Without it, the magic bytes
> wouldn't be there and the kernel couldn't load it. This patch fixes the
> issue by page aligning the provided FDT.
> 
> Cc: Stafford Horne <shorne@gmail.com>
> Cc: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
> ---
>  hw/openrisc/openrisc_sim.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/openrisc/openrisc_sim.c b/hw/openrisc/openrisc_sim.c
> index 8184caa60b..99b14940f4 100644
> --- a/hw/openrisc/openrisc_sim.c
> +++ b/hw/openrisc/openrisc_sim.c
> @@ -356,7 +356,7 @@ static uint32_t openrisc_load_fdt(Or1ksimState *state, hwaddr load_start,
>      }
>  
>      /* We put fdt right after the kernel and/or initrd. */
> -    fdt_addr = ROUND_UP(load_start, 4);
> +    fdt_addr = TARGET_PAGE_ALIGN(load_start);
>  
>      ret = fdt_pack(fdt);
>      /* Should only fail if we've built a corrupted tree */
> -- 
> 2.35.1

This looks OK to me, just for clarity we currently are loading:
  - 0x100        - Kernel
  - page aligned - Initrd
  - word aligned - FDT

In the absense of the initrd we need to ensure the FDT is page aligned.

If someone else wants to pick this up to push to qemu if would help, I don't
have anything planned at the moment.

If not I will start a queue in a few days.

Acked-by: Stafford Horne <shorne@gmail.com>


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

* [OpenRISC] [PATCH] hw/openrisc: page-align FDT address
@ 2022-04-28 12:01   ` Stafford Horne
  0 siblings, 0 replies; 4+ messages in thread
From: Stafford Horne @ 2022-04-28 12:01 UTC (permalink / raw)
  To: openrisc

On Thu, Apr 28, 2022 at 12:35:16PM +0200, Jason A. Donenfeld wrote:
> The QEMU-provided FDT was only being recognized by the kernel when it
> was used in conjunction with -initrd. Without it, the magic bytes
> wouldn't be there and the kernel couldn't load it. This patch fixes the
> issue by page aligning the provided FDT.
> 
> Cc: Stafford Horne <shorne@gmail.com>
> Cc: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
> ---
>  hw/openrisc/openrisc_sim.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/openrisc/openrisc_sim.c b/hw/openrisc/openrisc_sim.c
> index 8184caa60b..99b14940f4 100644
> --- a/hw/openrisc/openrisc_sim.c
> +++ b/hw/openrisc/openrisc_sim.c
> @@ -356,7 +356,7 @@ static uint32_t openrisc_load_fdt(Or1ksimState *state, hwaddr load_start,
>      }
>  
>      /* We put fdt right after the kernel and/or initrd. */
> -    fdt_addr = ROUND_UP(load_start, 4);
> +    fdt_addr = TARGET_PAGE_ALIGN(load_start);
>  
>      ret = fdt_pack(fdt);
>      /* Should only fail if we've built a corrupted tree */
> -- 
> 2.35.1

This looks OK to me, just for clarity we currently are loading:
  - 0x100        - Kernel
  - page aligned - Initrd
  - word aligned - FDT

In the absense of the initrd we need to ensure the FDT is page aligned.

If someone else wants to pick this up to push to qemu if would help, I don't
have anything planned at the moment.

If not I will start a queue in a few days.

Acked-by: Stafford Horne <shorne@gmail.com>

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

end of thread, other threads:[~2022-04-28 12:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-28 10:35 [PATCH] hw/openrisc: page-align FDT address Jason A. Donenfeld
2022-04-28 10:35 ` [OpenRISC] " Jason A. Donenfeld
2022-04-28 12:01 ` Stafford Horne
2022-04-28 12:01   ` [OpenRISC] " Stafford Horne

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.