From: Andrew Jones <drjones@redhat.com>
To: kvm@vger.kernel.org
Cc: rkrcmar@redhat.com, pbonzini@redhat.com, lvivier@redhat.com,
thuth@redhat.com
Subject: [PATCH kvm-unit-tests 08/15] x86: import initrd
Date: Fri, 13 Jan 2017 19:15:26 +0100 [thread overview]
Message-ID: <20170113181533.15145-9-drjones@redhat.com> (raw)
In-Reply-To: <20170113181533.15145-1-drjones@redhat.com>
If an initrd is provided on the qemu command line, then set a
pointer to it during setup.
Signed-off-by: Andrew Jones <drjones@redhat.com>
---
x86/Makefile.common | 1 +
lib/x86/setup.c | 31 +++++++++++++++++++++++++++++++
x86/cstart.S | 2 ++
x86/cstart64.S | 6 ++++--
4 files changed, 38 insertions(+), 2 deletions(-)
create mode 100644 lib/x86/setup.c
diff --git a/x86/Makefile.common b/x86/Makefile.common
index 1dad18ba26e1..fbab82c85c00 100644
--- a/x86/Makefile.common
+++ b/x86/Makefile.common
@@ -4,6 +4,7 @@ all: test_cases
cflatobjs += lib/pci.o
cflatobjs += lib/pci-edu.o
+cflatobjs += lib/x86/setup.o
cflatobjs += lib/x86/io.o
cflatobjs += lib/x86/smp.o
cflatobjs += lib/x86/vm.o
diff --git a/lib/x86/setup.c b/lib/x86/setup.c
new file mode 100644
index 000000000000..e5df6ce95b64
--- /dev/null
+++ b/lib/x86/setup.c
@@ -0,0 +1,31 @@
+/*
+ * Initialize machine setup information
+ *
+ * Copyright (C) 2017, Red Hat Inc, Andrew Jones <drjones@redhat.com>
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2.
+ */
+#include "libcflat.h"
+
+#define MBI_MODS_COUNT 20
+#define MBI_MODS_ADDR 24
+#define MB_MOD_START 0
+#define MB_MOD_END 4
+
+char *initrd;
+u32 initrd_size;
+
+void setup_get_initrd(u8 *bootinfo)
+{
+ u32 *mods_addr, *mod_start, *mod_end;
+
+ if (*((u32 *)&bootinfo[MBI_MODS_COUNT]) != 1)
+ return;
+
+ mods_addr = (u32 *)&bootinfo[MBI_MODS_ADDR];
+ mod_start = (u32 *)(ulong)(*mods_addr + MB_MOD_START);
+ mod_end = (u32 *)(ulong)(*mods_addr + MB_MOD_END);
+
+ initrd = (char *)(ulong)*mod_start;
+ initrd_size = *mod_end - *mod_start;
+}
diff --git a/x86/cstart.S b/x86/cstart.S
index 3dc8e710925a..7ab99cd20b7f 100644
--- a/x86/cstart.S
+++ b/x86/cstart.S
@@ -94,6 +94,8 @@ MSR_GS_BASE = 0xc0000101
.globl start
start:
+ push %ebx
+ call setup_get_initrd
mov mb_cmdline(%ebx), %eax
mov %eax, __args
call __setup_args
diff --git a/x86/cstart64.S b/x86/cstart64.S
index 0240507519cd..1c5182043703 100644
--- a/x86/cstart64.S
+++ b/x86/cstart64.S
@@ -197,8 +197,10 @@ start64:
call enable_apic
call smp_init
call enable_x2apic
- mov mb_boot_info(%rip), %rax
- mov mb_cmdline(%rax), %eax
+ mov mb_boot_info(%rip), %rbx
+ mov %rbx, %rdi
+ call setup_get_initrd
+ mov mb_cmdline(%rbx), %eax
mov %rax, __args(%rip)
call __setup_args
mov __argc(%rip), %edi
--
2.9.3
next prev parent reply other threads:[~2017-01-13 18:15 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-13 18:15 [PATCH kvm-unit-tests 00/15] Introduce an errata framework Andrew Jones
2017-01-13 18:15 ` [PATCH kvm-unit-tests 01/15] devicetree: improve dt_get_bootargs interface Andrew Jones
2017-01-13 18:15 ` [PATCH kvm-unit-tests 02/15] devicetree: introduce dt_get_initrd Andrew Jones
2017-01-13 18:15 ` [PATCH kvm-unit-tests 03/15] arm/arm64: better document setup Andrew Jones
2017-01-13 18:15 ` [PATCH kvm-unit-tests 04/15] powerpc: " Andrew Jones
2017-01-13 18:15 ` [PATCH kvm-unit-tests 05/15] arm/arm64: import initrd Andrew Jones
2017-01-13 18:15 ` [PATCH kvm-unit-tests 06/15] powerpc: " Andrew Jones
2017-01-13 18:15 ` [PATCH kvm-unit-tests 07/15] x86_64: mbi-cmdline is a 4 byte addr Andrew Jones
2017-01-13 18:15 ` Andrew Jones [this message]
2017-01-13 18:15 ` [PATCH kvm-unit-tests 09/15] lib/argv: fix coding style Andrew Jones
2017-01-13 18:15 ` [PATCH kvm-unit-tests 10/15] lib/argv: introduce setup_env and getenv Andrew Jones
2017-01-13 18:15 ` [PATCH kvm-unit-tests 11/15] arm/arm64: enable environ Andrew Jones
2017-01-13 18:15 ` [PATCH kvm-unit-tests 12/15] powerpc: " Andrew Jones
2017-01-13 18:15 ` [PATCH kvm-unit-tests 13/15] x86: " Andrew Jones
2017-01-13 18:15 ` [PATCH kvm-unit-tests 14/15] README: reserve some environment variables Andrew Jones
2017-01-13 18:15 ` [PATCH kvm-unit-tests 15/15] Introduce lib/errata.h Andrew Jones
2017-03-03 14:40 ` Radim Krčmář
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=20170113181533.15145-9-drjones@redhat.com \
--to=drjones@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=lvivier@redhat.com \
--cc=pbonzini@redhat.com \
--cc=rkrcmar@redhat.com \
--cc=thuth@redhat.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).