All of lore.kernel.org
 help / color / mirror / Atom feed
From: Shawn Anastasio <sanastasio@raptorengineering.com>
To: xen-devel@lists.xenproject.org
Cc: tpearson@raptorengineering.com, Jan Beulich <jbeulich@suse.com>,
	Shawn Anastasio <sanastasio@raptorengineering.com>,
	Stefano Stabellini <sstabellini@kernel.org>,
	Julien Grall <julien@xen.org>,
	Bertrand Marquis <bertrand.marquis@arm.com>,
	Michal Orzel <michal.orzel@amd.com>,
	Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
Subject: [PATCH v3 7/9] xen/ppc: Enable bootfdt and boot allocator
Date: Thu, 14 Mar 2024 17:15:45 -0500	[thread overview]
Message-ID: <adebcaa145af5e3de7fba07dc84b0993866e98ac.1710443965.git.sanastasio@raptorengineering.com> (raw)
In-Reply-To: <cover.1710443965.git.sanastasio@raptorengineering.com>

Enable usage of bootfdt for populating the boot info struct from the
firmware-provided device tree.  Also enable the Xen boot page allocator.

Includes minor changes to bootfdt.c's boot_fdt_info() to tolerate the
scenario in which the FDT overlaps a reserved memory region, as is the
case on PPC when booted directly from skiboot.

Signed-off-by: Shawn Anastasio <sanastasio@raptorengineering.com>
---
 xen/arch/ppc/include/asm/setup.h |  5 +++++
 xen/arch/ppc/setup.c             | 21 ++++++++++++++++++++-
 xen/common/device-tree/bootfdt.c | 11 +++++++++--
 3 files changed, 34 insertions(+), 3 deletions(-)

diff --git a/xen/arch/ppc/include/asm/setup.h b/xen/arch/ppc/include/asm/setup.h
index 1b2d29c5b6..fe27f61fc3 100644
--- a/xen/arch/ppc/include/asm/setup.h
+++ b/xen/arch/ppc/include/asm/setup.h
@@ -115,4 +115,9 @@ const char *boot_module_kind_as_string(bootmodule_kind kind);
 struct bootcmdline *boot_cmdline_find_by_kind(bootmodule_kind kind);
 void populate_boot_allocator(void);
 
+/*
+ * bootfdt.c
+ */
+size_t boot_fdt_info(const void *fdt, paddr_t paddr);
+
 #endif /* __ASM_PPC_SETUP_H__ */
diff --git a/xen/arch/ppc/setup.c b/xen/arch/ppc/setup.c
index 101bdd8bb6..946167a56f 100644
--- a/xen/arch/ppc/setup.c
+++ b/xen/arch/ppc/setup.c
@@ -1,12 +1,14 @@
 /* SPDX-License-Identifier: GPL-2.0-or-later */
 #include <xen/init.h>
 #include <xen/lib.h>
+#include <xen/libfdt/libfdt.h>
 #include <xen/mm.h>
 #include <public/version.h>
 #include <asm/boot.h>
 #include <asm/early_printk.h>
 #include <asm/mm.h>
 #include <asm/processor.h>
+#include <asm/setup.h>
 
 /* Xen stack for bringing up the first CPU. */
 unsigned char __initdata cpu0_boot_stack[STACK_SIZE] __aligned(STACK_SIZE);
@@ -24,6 +26,9 @@ void __init noreturn start_xen(unsigned long r3, unsigned long r4,
                                unsigned long r5, unsigned long r6,
                                unsigned long r7)
 {
+    void *boot_fdt;
+    struct bootmodule *xen_bootmodule;
+
     if ( r5 )
     {
         /* Unsupported OpenFirmware boot protocol */
@@ -32,11 +37,25 @@ void __init noreturn start_xen(unsigned long r3, unsigned long r4,
     else
     {
         /* kexec boot protocol */
-        boot_opal_init((void *)r3);
+        boot_fdt = (void *)r3;
+        boot_opal_init(boot_fdt);
     }
 
     setup_exceptions();
 
+    device_tree_flattened = boot_fdt;
+    boot_fdt_info(boot_fdt, r3);
+
+    /*
+     * Xen relocates itself at the ppc64 entrypoint, so we need to manually mark
+     * the kernel module.
+     */
+    xen_bootmodule = add_boot_module(BOOTMOD_XEN, __pa(_start),
+                                     PAGE_ALIGN(__pa(_end)), false);
+    BUG_ON(!xen_bootmodule);
+
+    populate_boot_allocator();
+
     setup_initial_pagetables();
 
     early_printk("Hello, ppc64le!\n");
diff --git a/xen/common/device-tree/bootfdt.c b/xen/common/device-tree/bootfdt.c
index 35dbdf3384..1985648b31 100644
--- a/xen/common/device-tree/bootfdt.c
+++ b/xen/common/device-tree/bootfdt.c
@@ -543,12 +543,19 @@ size_t __init boot_fdt_info(const void *fdt, paddr_t paddr)
     if ( ret < 0 )
         panic("No valid device tree\n");
 
-    add_boot_module(BOOTMOD_FDT, paddr, fdt_totalsize(fdt), false);
-
     ret = device_tree_for_each_node(fdt, 0, early_scan_node, NULL);
     if ( ret )
         panic("Early FDT parsing failed (%d)\n", ret);
 
+    /*
+     * Add module for the FDT itself after the device tree has been parsed. This
+     * is required on ppc64le where the device tree passed to Xen may have been
+     * allocated by skiboot, in which case it will exist within a reserved
+     * region and this call will fail. This is fine, however, since either way
+     * the allocator will know not to step on the device tree.
+     */
+    add_boot_module(BOOTMOD_FDT, paddr, fdt_totalsize(fdt), false);
+
     /*
      * On Arm64 setup_directmap_mappings() expects to be called with the lowest
      * bank in memory first. There is no requirement that the DT will provide
-- 
2.30.2



  parent reply	other threads:[~2024-03-14 22:16 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-14 22:15 [PATCH v3 0/9] Early Boot Allocation on Power Shawn Anastasio
2024-03-14 22:15 ` [PATCH v3 1/9] EFI: Introduce inline stub for efi_enabled on !X86 && !ARM Shawn Anastasio
2024-03-21 17:30   ` Julien Grall
2024-03-22  8:01   ` Jan Beulich
2024-03-22 13:14     ` Julien Grall
2024-03-14 22:15 ` [PATCH v3 2/9] xen/asm-generic: Introduce generic acpi.h Shawn Anastasio
2024-03-25 15:19   ` Jan Beulich
2024-04-04 22:11     ` Shawn Anastasio
2024-03-14 22:15 ` [PATCH v3 3/9] xen/ppc: Introduce stub asm/static-shmem.h Shawn Anastasio
2024-03-25 15:24   ` Jan Beulich
2024-04-09 23:35     ` Shawn Anastasio
2024-04-17 13:03       ` Jan Beulich
2024-03-14 22:15 ` [PATCH v3 4/9] xen/ppc: Update setup.h with required definitions for bootfdt Shawn Anastasio
2024-03-15  8:59   ` Luca Fancellu
2024-03-21 17:37   ` Julien Grall
2024-03-22  8:04   ` Jan Beulich
2024-03-14 22:15 ` [PATCH v3 5/9] xen/device-tree: Move Arm's setup.c bootinfo functions to common Shawn Anastasio
2024-03-15  9:16   ` Jan Beulich
2024-03-20 18:07     ` Shawn Anastasio
2024-03-21  7:42       ` Jan Beulich
2024-03-21 17:39         ` Julien Grall
2024-03-21 17:47   ` Julien Grall
2024-03-22  7:55     ` Jan Beulich
2024-03-22 13:14       ` Julien Grall
2024-04-12  2:43     ` Shawn Anastasio
2024-03-21 17:53   ` Julien Grall
2024-04-12  2:54     ` Shawn Anastasio
2024-03-14 22:15 ` [PATCH v3 6/9] xen/common: Move Arm's bootfdt.c " Shawn Anastasio
2024-03-21 17:50   ` Julien Grall
2024-04-12  2:53     ` Shawn Anastasio
2024-04-17 17:24       ` Julien Grall
2024-03-14 22:15 ` Shawn Anastasio [this message]
2024-03-21 18:03   ` [PATCH v3 7/9] xen/ppc: Enable bootfdt and boot allocator Julien Grall
2024-03-14 22:15 ` [PATCH v3 8/9] xen/ppc: mm-radix: Replace debug printing code with printk Shawn Anastasio
2024-03-25 15:29   ` Jan Beulich
2024-04-12  2:47     ` Shawn Anastasio
2024-03-14 22:15 ` [PATCH v3 9/9] xen/ppc: mm-radix: Allocate all paging structures at runtime Shawn Anastasio
2024-03-20 18:03   ` Shawn Anastasio
2024-03-25 15:39   ` Jan Beulich
2024-04-12  3:19     ` Shawn Anastasio
2024-04-17 13:19       ` Jan Beulich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=adebcaa145af5e3de7fba07dc84b0993866e98ac.1710443965.git.sanastasio@raptorengineering.com \
    --to=sanastasio@raptorengineering.com \
    --cc=Volodymyr_Babchuk@epam.com \
    --cc=bertrand.marquis@arm.com \
    --cc=jbeulich@suse.com \
    --cc=julien@xen.org \
    --cc=michal.orzel@amd.com \
    --cc=sstabellini@kernel.org \
    --cc=tpearson@raptorengineering.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.