1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-22 13:41:26 +00:00

qemu-riscv: update to qemu-2.11.92pre60378_f733c7b5f

This obsoletes two of the included patches, one of them RISC-V specific,
since they've been picked up by upstream.

This build has been confirmed as being able to build and run an (extremely
recent) RISC-V Fedora 28 Rawhide image, available from:

    https://fedorapeople.org/groups/risc-v/disk-images/

Signed-off-by: Austin Seipp <aseipp@pobox.com>
This commit is contained in:
Austin Seipp 2018-04-07 22:16:18 -05:00
parent 584270e397
commit 4b7f2dd622
2 changed files with 12 additions and 107 deletions

View file

@ -1,98 +0,0 @@
From 44b0f612499764dad425d467aadacb01fbd4a920 Mon Sep 17 00:00:00 2001
From: Shea Levy <shea@shealevy.com>
Date: Tue, 20 Feb 2018 07:59:43 -0500
Subject: [PATCH] riscv: Respect the -initrd flag.
Logic for initrd start address borrowed from arm/boot.c
---
hw/riscv/virt.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 46 insertions(+), 3 deletions(-)
diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
index 46d95b2b79..5c7d191a3f 100644
--- a/hw/riscv/virt.c
+++ b/hw/riscv/virt.c
@@ -77,7 +77,35 @@ static uint64_t load_kernel(const char *kernel_filename)
return kernel_entry;
}
-static void create_fdt(RISCVVirtState *s, const struct MemmapEntry *memmap,
+static hwaddr load_initrd(const char *filename, uint64_t mem_size,
+ uint64_t kernel_entry, hwaddr *start)
+{
+ int size;
+
+ /* We want to put the initrd far enough into RAM that when the
+ * kernel is uncompressed it will not clobber the initrd. However
+ * on boards without much RAM we must ensure that we still leave
+ * enough room for a decent sized initrd, and on boards with large
+ * amounts of RAM we must avoid the initrd being so far up in RAM
+ * that it is outside lowmem and inaccessible to the kernel.
+ * So for boards with less than 256MB of RAM we put the initrd
+ * halfway into RAM, and for boards with 256MB of RAM or more we put
+ * the initrd at 128MB.
+ */
+ *start = kernel_entry + MIN(mem_size / 2, 128 * 1024 * 1024);
+
+ size = load_ramdisk(filename, *start, mem_size - *start);
+ if (size == -1) {
+ size = load_image_targphys(filename, *start, mem_size - *start);
+ if (size == -1) {
+ error_report("qemu: could not load ramdisk '%s'", filename);
+ exit(1);
+ }
+ }
+ return *start + size;
+}
+
+static void *create_fdt(RISCVVirtState *s, const struct MemmapEntry *memmap,
uint64_t mem_size, const char *cmdline)
{
void *fdt;
@@ -233,6 +261,8 @@ static void create_fdt(RISCVVirtState *s, const struct MemmapEntry *memmap,
qemu_fdt_setprop_string(fdt, "/chosen", "stdout-path", nodename);
qemu_fdt_setprop_string(fdt, "/chosen", "bootargs", cmdline);
g_free(nodename);
+
+ return fdt;
}
static void riscv_virt_board_init(MachineState *machine)
@@ -246,6 +276,7 @@ static void riscv_virt_board_init(MachineState *machine)
char *plic_hart_config;
size_t plic_hart_config_len;
int i;
+ void *fdt;
/* Initialize SOC */
object_initialize(&s->soc, sizeof(s->soc), TYPE_RISCV_HART_ARRAY);
@@ -265,7 +296,8 @@ static void riscv_virt_board_init(MachineState *machine)
main_mem);
/* create device tree */
- create_fdt(s, memmap, machine->ram_size, machine->kernel_cmdline);
+ fdt = create_fdt(s, memmap, machine->ram_size,
+ machine->kernel_cmdline);
/* boot rom */
memory_region_init_ram(boot_rom, NULL, "riscv_virt_board.bootrom",
@@ -273,7 +305,18 @@ static void riscv_virt_board_init(MachineState *machine)
memory_region_add_subregion(system_memory, 0x0, boot_rom);
if (machine->kernel_filename) {
- load_kernel(machine->kernel_filename);
+ uint64_t kernel_entry = load_kernel(machine->kernel_filename);
+
+ if (machine->initrd_filename) {
+ hwaddr start;
+ hwaddr end = load_initrd(machine->initrd_filename,
+ machine->ram_size, kernel_entry,
+ &start);
+ qemu_fdt_setprop_cell(fdt, "/chosen",
+ "linux,initrd-start", start);
+ qemu_fdt_setprop_cell(fdt, "/chosen", "linux,initrd-end",
+ end);
+ }
}
/* reset vector */

View file

@ -1,22 +1,25 @@
{ qemu, fetchFromGitHub, lib }: let
src = fetchFromGitHub {
owner = "riscv";
repo = "riscv-qemu";
rev = "af435b709d4a5de3ec2e59ff4dcd05b0b295a730";
sha256 = "1kqcsn8yfdg3zyd991i4v5dxznd1l4a4hjry9304lvsm3sz2wllw";
owner = "riscv";
repo = "riscv-qemu";
rev = "f733c7b5f86147216e14aff90c03ccdd76056bef";
sha256 = "1ppr9qqwi7qqh8m6dgk1hrzg8zri240il27l67vfayd8ijagb9zq";
fetchSubmodules = true;
};
version = "2.11.50";
revCount = "58771";
shortRev = "af435b709d";
version = "2.11.92";
revCount = "60378";
shortRev = builtins.substring 0 9 src.rev;
targets = [ "riscv32-linux-user" "riscv32-softmmu"
"riscv64-linux-user" "riscv64-softmmu"
];
in lib.overrideDerivation qemu (orig: {
name = "${(builtins.parseDrvName qemu.name).name}-${version}pre${revCount}_${shortRev}";
inherit src;
# https://github.com/riscv/riscv-qemu/pull/109
patches = orig.patches ++ [ ./riscv-initrd.patch ];
# The pulseaudio and statfs patches are in 2.12.0+, which this is based on
patches = [
./force-uid0-on-9p.patch
./no-etc-install.patch
];
configureFlags = orig.configureFlags ++ [ "--target-list=${lib.concatStringsSep "," targets}" ];
postInstall = null;
})