[PATCH kvm-unit-tests 05/15] arm/arm64: import initrd

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If an initrd is provided on the qemu command line, then "import"
it by copying it to a safe location during setup.

Signed-off-by: Andrew Jones <drjones@xxxxxxxxxx>
---
 lib/arm/setup.c | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/lib/arm/setup.c b/lib/arm/setup.c
index dcf25c2f4365..c4d69ae2c143 100644
--- a/lib/arm/setup.c
+++ b/lib/arm/setup.c
@@ -24,6 +24,9 @@ extern unsigned long stacktop;
 extern void io_init(void);
 extern void setup_args_progname(const char *args);
 
+char *initrd;
+u32 initrd_size;
+
 u64 cpus[NR_CPUS] = { [0 ... NR_CPUS-1] = (u64)~0 };
 int nr_cpus;
 
@@ -113,19 +116,21 @@ static void mem_init(phys_addr_t freemem_start)
 void setup(const void *fdt)
 {
 	void *freemem = &stacktop;
-	const char *bootargs;
+	const char *bootargs, *tmp;
 	u32 fdt_size;
 	int ret;
 
 	/*
-	 * Before calling mem_init we need to move the fdt to a safe
-	 * location. We move it above the stack to construct the memory
+	 * Before calling mem_init we need to move the fdt and initrd
+	 * to safe locations. We move them to construct the memory
 	 * map illustrated below:
 	 *
 	 *    +----------------------+   <-- top of physical memory
 	 *    |                      |
 	 *    ~                      ~
 	 *    |                      |
+	 *    +----------------------+   <-- top of initrd
+	 *    |                      |
 	 *    +----------------------+   <-- top of FDT
 	 *    |                      |
 	 *    +----------------------+   <-- top of cpu0's stack
@@ -144,6 +149,14 @@ void setup(const void *fdt)
 	assert(ret == 0);
 	freemem += fdt_size;
 
+	ret = dt_get_initrd(&tmp, &initrd_size);
+	assert(ret == 0 || ret == -FDT_ERR_NOTFOUND);
+	if (ret == 0) {
+		initrd = freemem;
+		memmove(initrd, tmp, initrd_size);
+		freemem += initrd_size;
+	}
+
 	/* call init functions */
 	cpu_init();
 
-- 
2.9.3

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux