[PATCH 02/16] hw/arm/boot: let a board preset initrd_start

Kyle Fox <[email protected]>
Newsgroups org.nongnu.qemu-arm,org.nongnu.qemu-devel
Message-ID <[email protected]>
Allow a board to place the initrd itself (honour a pre-set
info->initrd_start) so a board with a reserved-memory carveout can keep
the initrd clear of it.

Signed-off-by: Kyle Fox <[email protected]>
---
 hw/arm/boot.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/hw/arm/boot.c b/hw/arm/boot.c
index 9b7553dde5e..4bfb0d8264b 100644
--- a/hw/arm/boot.c
+++ b/hw/arm/boot.c
@@ -997,8 +997,16 @@ static void arm_setup_direct_kernel_boot(ARMCPU *cpu,
      * don't tell us their exact size (eg self-decompressing 32-bit kernels)
      * we might still make a bad choice here.
      */
-    info->initrd_start = info->loader_start +
-        MIN(info->ram_size / 2, 128 * MiB);
+    /*
+     * Boards may preset info->initrd_start to force a placement (e.g. to
+     * dodge a guest reserved-memory carveout that happens to sit where the
+     * default heuristic would land the initrd). Only compute a default when
+     * the board left it unset.
+     */
+    if (!info->initrd_start) {
+        info->initrd_start = info->loader_start +
+            MIN(info->ram_size / 2, 128 * MiB);
+    }
     if (image_high_addr) {
         info->initrd_start = MAX(info->initrd_start, image_high_addr);
     }
-- 
2.34.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.