Blame 0011-arm-add-fw_cfg-to-virt-board.patch

391fb8
From 892602338db279204d11212034bc9f359dc4c1c4 Mon Sep 17 00:00:00 2001
391fb8
From: Laszlo Ersek <lersek@redhat.com>
391fb8
Date: Mon, 22 Dec 2014 13:11:42 +0100
391fb8
Subject: [PATCH 11/15] arm: add fw_cfg to "virt" board
391fb8
391fb8
fw_cfg already supports exposure over MMIO (used in ppc/mac_newworld.c,
391fb8
ppc/mac_oldworld.c, sparc/sun4m.c); we can easily add it to the "virt"
391fb8
board.
391fb8
391fb8
Because MMIO access is slow on ARM KVM, we enable the guest, with
391fb8
fw_cfg_init_mem_wide(), to transfer up to 8 bytes with a single access.
391fb8
This has been measured to speed up transfers up to 7.5-fold, relative to
391fb8
single byte data access, on both ARM KVM and x86_64 TCG.
391fb8
391fb8
The MMIO register block of fw_cfg is advertized in the device tree. As
391fb8
base address we pick 0x09020000, which conforms to the comment preceding
391fb8
"a15memmap": it falls in the miscellaneous device I/O range 128MB..256MB,
391fb8
and it is aligned at 64KB. The DTB properties follow the documentation in
391fb8
the Linux source file "Documentation/devicetree/bindings/arm/fw-cfg.txt".
391fb8
391fb8
fw_cfg automatically exports a number of files to the guest; for example,
391fb8
"bootorder" (see fw_cfg_machine_reset()).
391fb8
391fb8
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
391fb8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
391fb8
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
391fb8
Message-id: 1419250305-31062-9-git-send-email-pbonzini@redhat.com
391fb8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
391fb8
(cherry picked from commit 578f3c7b083514b4fec0bf8fa0617934cdbdf826)
391fb8
---
391fb8
 hw/arm/virt.c | 21 +++++++++++++++++++++
391fb8
 1 file changed, 21 insertions(+)
391fb8
391fb8
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
391fb8
index 314e55b..8af4aa0 100644
391fb8
--- a/hw/arm/virt.c
391fb8
+++ b/hw/arm/virt.c
391fb8
@@ -68,6 +68,7 @@ enum {
391fb8
     VIRT_UART,
391fb8
     VIRT_MMIO,
391fb8
     VIRT_RTC,
391fb8
+    VIRT_FW_CFG,
391fb8
 };
391fb8
 
391fb8
 typedef struct MemMapEntry {
391fb8
@@ -107,6 +108,7 @@ static const MemMapEntry a15memmap[] = {
391fb8
     [VIRT_GIC_CPU] =    { 0x08010000, 0x00010000 },
391fb8
     [VIRT_UART] =       { 0x09000000, 0x00001000 },
391fb8
     [VIRT_RTC] =        { 0x09010000, 0x00001000 },
391fb8
+    [VIRT_FW_CFG] =     { 0x09020000, 0x0000000a },
391fb8
     [VIRT_MMIO] =       { 0x0a000000, 0x00000200 },
391fb8
     /* ...repeating for a total of NUM_VIRTIO_TRANSPORTS, each of that size */
391fb8
     /* 0x10000000 .. 0x40000000 reserved for PCI */
391fb8
@@ -519,6 +521,23 @@ static void create_flash(const VirtBoardInfo *vbi)
391fb8
     g_free(nodename);
391fb8
 }
391fb8
 
391fb8
+static void create_fw_cfg(const VirtBoardInfo *vbi)
391fb8
+{
391fb8
+    hwaddr base = vbi->memmap[VIRT_FW_CFG].base;
391fb8
+    hwaddr size = vbi->memmap[VIRT_FW_CFG].size;
391fb8
+    char *nodename;
391fb8
+
391fb8
+    fw_cfg_init_mem_wide(base + 8, base, 8);
391fb8
+
391fb8
+    nodename = g_strdup_printf("/fw-cfg@%" PRIx64, base);
391fb8
+    qemu_fdt_add_subnode(vbi->fdt, nodename);
391fb8
+    qemu_fdt_setprop_string(vbi->fdt, nodename,
391fb8
+                            "compatible", "qemu,fw-cfg-mmio");
391fb8
+    qemu_fdt_setprop_sized_cells(vbi->fdt, nodename, "reg",
391fb8
+                                 2, base, 2, size);
391fb8
+    g_free(nodename);
391fb8
+}
391fb8
+
391fb8
 static void *machvirt_dtb(const struct arm_boot_info *binfo, int *fdt_size)
391fb8
 {
391fb8
     const VirtBoardInfo *board = (const VirtBoardInfo *)binfo;
391fb8
@@ -604,6 +623,8 @@ static void machvirt_init(MachineState *machine)
391fb8
      */
391fb8
     create_virtio_devices(vbi, pic);
391fb8
 
391fb8
+    create_fw_cfg(vbi);
391fb8
+
391fb8
     vbi->bootinfo.ram_size = machine->ram_size;
391fb8
     vbi->bootinfo.kernel_filename = machine->kernel_filename;
391fb8
     vbi->bootinfo.kernel_cmdline = machine->kernel_cmdline;
391fb8
-- 
391fb8
2.1.0
391fb8