Skip to contentSkip to conversation

PPC updates

GIT PULL New Alexander Graf 2 participants 8 messages Aug 26, 2010 Kbuild

lore
Share & tools
lore
#5 lore raw

PATCH 5/6 ppc4xx: don't unregister RAM at reset

In reply to Alexander Graf

From: Hollis Blanchard <[email protected]>

The PowerPC 4xx SDRAM controller emulation unregisters RAM in its reset callback. However, qemu_system_reset() is now called at initialization time, so all RAM is unregistered before starting the guest (!).

---
 hw/ppc4xx_devs.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
hw/ppc4xx_devs.c +0 -1
index be130c4..7f698b8 100644
@@ -619,7 +619,6 @@ static void sdram_reset (void *opaque)
     /* We pre-initialize RAM banks */
     sdram->status = 0x00000000;
     sdram->cfg = 0x00800000;
-    sdram_unmap_bcr(sdram);
 }
 
 void ppc4xx_sdram_init (CPUState *env, qemu_irq irq, int nbanks,
Signature · 1 line
1.6.0.2
#0 lore raw

The following changes since commit 2446333cd5b5c985f6517dee7004e542ecacd21c:
Blue Swirl (1):
Rearrange block headers

are available in the git repository at:

git://repo.or.cz/qemu/agraf.git ppc-next

Alexander Graf (2):
PPC: Add PV hypercall transport through fw_cfg
PPC: Update openbios binary to r859

Hollis Blanchard (4):
Fix "make install" with a cross toolchain
ppc4xx: correct SDRAM controller warning message condition
ppc4xx: don't unregister RAM at reset
ppc4xx: load Bamboo kernel, initrd, and fdt at fixed addresses

 Makefile.target      |    5 ++++-
 configure            |    4 +++-
 hw/ppc.h             |    3 +++
 hw/ppc440_bamboo.c   |   39 ++++++++++++++++++---------------------
 hw/ppc4xx_devs.c     |    3 +--
 hw/ppc_newworld.c    |    7 +++++++
 hw/ppc_oldworld.c    |    7 +++++++
 pc-bios/openbios-ppc |  Bin 320324 -> 320328 bytes
 target-ppc/kvm.c     |   32 ++++++++++++++++++++++++++++++++
 target-ppc/kvm_ppc.h |    1 +
 10 files changed, 76 insertions(+), 25 deletions(-)
#3 lore raw

PATCH 3/6 Fix "make install" with a cross toolchain

From: Hollis Blanchard <[email protected]>

We must be able to use a non-native strip executable, but not all versions of 'install' support the --strip-program option (e.g. OpenBSD). Accordingly, we can't use 'install -s', and we must run strip separately.

---
 Makefile.target |    5 ++++-
 configure       |    4 +++-
 2 files changed, 7 insertions(+), 2 deletions(-)
Makefile.target +4 -1
index c8281e9..18826bb 100644
@@ -329,7 +329,10 @@ clean:
 
 install: all
 ifneq ($(PROGS),)
-	$(INSTALL) -m 755 $(STRIP_OPT) $(PROGS) "$(DESTDIR)$(bindir)"
+	$(INSTALL) -m 755 $(PROGS) "$(DESTDIR)$(bindir)"
+ifneq ($(STRIP),)
+	$(STRIP) $(patsubst %,"$(DESTDIR)$(bindir)/%",$(PROGS))
+endif
 endif
 
 # Include automatically generated dependency files
configure +3 -1
index a20371c..146dac0 100755
@@ -80,6 +80,7 @@ make="make"
 install="install"
 objcopy="objcopy"
 ld="ld"
+strip="strip"
 helper_cflags=""
 libs_softmmu=""
 libs_tools=""
@@ -125,6 +126,7 @@ cc="${cross_prefix}${cc}"
 ar="${cross_prefix}${ar}"
 objcopy="${cross_prefix}${objcopy}"
 ld="${cross_prefix}${ld}"
+strip="${cross_prefix}${strip}"
 
 # default flags for all hosts
 QEMU_CFLAGS="-fno-strict-aliasing $QEMU_CFLAGS"
@@ -2227,7 +2229,7 @@ if test "$debug" = "yes" ; then
   echo "CONFIG_DEBUG_EXEC=y" >> $config_host_mak
 fi
 if test "$strip_opt" = "yes" ; then
-  echo "STRIP_OPT=-s" >> $config_host_mak
+  echo "STRIP=${strip}" >> $config_host_mak
 fi
 if test "$bigendian" = "yes" ; then
   echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
Signature · 1 line
1.6.0.2
#4 lore raw

PATCH 4/6 ppc4xx: correct SDRAM controller warning message condition

In reply to Alexander Graf

From: Hollis Blanchard <[email protected]>

The message "Truncating memory to %d MiB to fit SDRAM controller limits" should be displayed only when a user chooses an amount of RAM which can't be represented by the PPC 4xx SDRAM controller (e.g. 129MB, which would only be valid if the controller supports a bank size of 1MB).

---
 hw/ppc4xx_devs.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
hw/ppc4xx_devs.c +1 -1
index b15db81..be130c4 100644
@@ -684,7 +684,7 @@ ram_addr_t ppc4xx_sdram_adjust(ram_addr_t ram_size, int nr_banks,
     }
 
     ram_size -= size_left;
-    if (ram_size)
+    if (size_left)
         printf("Truncating memory to %d MiB to fit SDRAM controller limits.\n",
                (int)(ram_size >> 20));
 
Signature · 1 line
1.6.0.2
#1 lore raw

PATCH 1/6 PPC: Add PV hypercall transport through fw_cfg

In reply to Alexander Graf

On KVM for PPC we need to tell the guest which instructions to use when doing a hypercall. The clean way to do this is to go through an ioctl from userspace and passing it on to the guest using the device tree.

So let's do the qemu part here: read out the hypercall and pass it on to the guest's fw_cfg so openBIOS can read it out and expose it again.

---
 hw/ppc.h             |    3 +++
 hw/ppc_newworld.c    |    7 +++++++
 hw/ppc_oldworld.c    |    7 +++++++
 target-ppc/kvm.c     |   32 ++++++++++++++++++++++++++++++++
 target-ppc/kvm_ppc.h |    1 +
 5 files changed, 50 insertions(+), 0 deletions(-)
hw/ppc.h +3 -0
index de13092..1251932 100644
@@ -47,5 +47,8 @@ enum {
 #define FW_CFG_PPC_HEIGHT	(FW_CFG_ARCH_LOCAL + 0x01)
 #define FW_CFG_PPC_DEPTH	(FW_CFG_ARCH_LOCAL + 0x02)
 #define FW_CFG_PPC_TBFREQ	(FW_CFG_ARCH_LOCAL + 0x03)
+#define FW_CFG_PPC_IS_KVM       (FW_CFG_ARCH_LOCAL + 0x05)
+#define FW_CFG_PPC_KVM_HC       (FW_CFG_ARCH_LOCAL + 0x06)
+#define FW_CFG_PPC_KVM_PID      (FW_CFG_ARCH_LOCAL + 0x07)
 
 #define PPC_SERIAL_MM_BAUDBASE 399193
hw/ppc_newworld.c +7 -0
index 639dcde..809a1cf 100644
@@ -427,9 +427,16 @@ static void ppc_core99_init (ram_addr_t ram_size,
     fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_HEIGHT, graphic_height);
     fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_DEPTH, graphic_depth);
 
+    fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_IS_KVM, kvm_enabled());
     if (kvm_enabled()) {
 #ifdef CONFIG_KVM
+        uint8_t *hypercall;
+
         fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_TBFREQ, kvmppc_get_tbfreq());
+        hypercall = qemu_malloc(16);
+        kvmppc_get_hypercall(env, hypercall, 16);
+        fw_cfg_add_bytes(fw_cfg, FW_CFG_PPC_KVM_HC, hypercall, 16);
+        fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_KVM_PID, getpid());
 #endif
     } else {
         fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_TBFREQ, get_ticks_per_sec());
hw/ppc_oldworld.c +7 -0
index de6005e..a12a812 100644
@@ -399,9 +399,16 @@ static void ppc_heathrow_init (ram_addr_t ram_size,
     fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_HEIGHT, graphic_height);
     fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_DEPTH, graphic_depth);
 
+    fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_IS_KVM, kvm_enabled());
     if (kvm_enabled()) {
 #ifdef CONFIG_KVM
+        uint8_t *hypercall;
+
         fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_TBFREQ, kvmppc_get_tbfreq());
+        hypercall = qemu_malloc(16);
+        kvmppc_get_hypercall(env, hypercall, 16);
+        fw_cfg_add_bytes(fw_cfg, FW_CFG_PPC_KVM_HC, hypercall, 16);
+        fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_KVM_PID, getpid());
 #endif
     } else {
         fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_TBFREQ, get_ticks_per_sec());
target-ppc/kvm.c +32 -0
index 1079ce1..14d6365 100644
@@ -327,6 +327,38 @@ uint32_t kvmppc_get_tbfreq(void)
     return retval;
 }
 
+int kvmppc_get_hypercall(CPUState *env, uint8_t *buf, int buf_len)
+{
+    uint32_t *hc = (uint32_t*)buf;
+
+#ifdef KVM_CAP_PPC_GET_PVINFO
+    struct kvm_ppc_pvinfo pvinfo;
+
+    if (kvm_check_extension(env->kvm_state, KVM_CAP_PPC_GET_PVINFO) &&
+        !kvm_vm_ioctl(env->kvm_state, KVM_PPC_GET_PVINFO, &pvinfo)) {
+        memcpy(buf, pvinfo.hcall, buf_len);
+
+        return 0;
+    }
+#endif
+
+    /*
+     * Fallback to always fail hypercalls:
+     *
+     *     li r3, -1
+     *     nop
+     *     nop
+     *     nop
+     */
+
+    hc[0] = 0x3860ffff;
+    hc[1] = 0x60000000;
+    hc[2] = 0x60000000;
+    hc[3] = 0x60000000;
+
+    return 0;
+}
+
 bool kvm_arch_stop_on_emulation_error(CPUState *env)
 {
     return true;
target-ppc/kvm_ppc.h +1 -0
index e8d66e8..65e31c9 100644
@@ -15,5 +15,6 @@ int kvmppc_read_host_property(const char *node_path, const char *prop,
                                      void *val, size_t len);
 
 uint32_t kvmppc_get_tbfreq(void);
+int kvmppc_get_hypercall(CPUState *env, uint8_t *buf, int buf_len);
 
 #endif /* __KVM_PPC_H__ */
Signature · 1 line
1.6.0.2
#6 lore raw

PATCH 6/6 ppc4xx: load Bamboo kernel, initrd, and fdt at fixed addresses

In reply to Alexander Graf

From: Hollis Blanchard <[email protected]>

We can't use the return value of load_uimage() for the kernel because it can't account for BSS size, and the PowerPC kernel does not relocate blobs before zeroing BSS.

Instead, we now load at the fixed addresses chosen by u-boot (the normal firmware for the board).

---
 hw/ppc440_bamboo.c |   39 ++++++++++++++++++---------------------
 1 files changed, 18 insertions(+), 21 deletions(-)
hw/ppc440_bamboo.c +18 -21
index d471d5d..34ddf45 100644
@@ -27,6 +27,11 @@
 
 #define BINARY_DEVICE_TREE_FILE "bamboo.dtb"
 
+/* from u-boot */
+#define KERNEL_ADDR  0x1000000
+#define FDT_ADDR     0x1800000
+#define RAMDISK_ADDR 0x1900000
+
 static int bamboo_load_device_tree(target_phys_addr_t addr,
                                      uint32_t ramsize,
                                      target_phys_addr_t initrd_base,
@@ -98,10 +103,8 @@ static void bamboo_init(ram_addr_t ram_size,
     uint64_t elf_lowaddr;
     target_phys_addr_t entry = 0;
     target_phys_addr_t loadaddr = 0;
-    target_long kernel_size = 0;
-    target_ulong initrd_base = 0;
     target_long initrd_size = 0;
-    target_ulong dt_base = 0;
+    int success;
     int i;
 
     /* Setup CPU. */
@@ -118,15 +121,15 @@ static void bamboo_init(ram_addr_t ram_size,
 
     /* Load kernel. */
     if (kernel_filename) {
-        kernel_size = load_uimage(kernel_filename, &entry, &loadaddr, NULL);
-        if (kernel_size < 0) {
-            kernel_size = load_elf(kernel_filename, NULL, NULL, &elf_entry,
-                                   &elf_lowaddr, NULL, 1, ELF_MACHINE, 0);
+        success = load_uimage(kernel_filename, &entry, &loadaddr, NULL);
+        if (success < 0) {
+            success = load_elf(kernel_filename, NULL, NULL, &elf_entry,
+                               &elf_lowaddr, NULL, 1, ELF_MACHINE, 0);
             entry = elf_entry;
             loadaddr = elf_lowaddr;
         }
         /* XXX try again as binary */
-        if (kernel_size < 0) {
+        if (success < 0) {
             fprintf(stderr, "qemu: could not load kernel '%s'\n",
                     kernel_filename);
             exit(1);
@@ -135,26 +138,20 @@ static void bamboo_init(ram_addr_t ram_size,
 
     /* Load initrd. */
     if (initrd_filename) {
-        initrd_base = kernel_size + loadaddr;
-        initrd_size = load_image_targphys(initrd_filename, initrd_base,
-                                          ram_size - initrd_base);
+        initrd_size = load_image_targphys(initrd_filename, RAMDISK_ADDR,
+                                          ram_size - RAMDISK_ADDR);
 
         if (initrd_size < 0) {
-            fprintf(stderr, "qemu: could not load initial ram disk '%s'\n",
-                    initrd_filename);
+            fprintf(stderr, "qemu: could not load ram disk '%s' at %x\n",
+                    initrd_filename, RAMDISK_ADDR);
             exit(1);
         }
     }
 
     /* If we're loading a kernel directly, we must load the device tree too. */
     if (kernel_filename) {
-        if (initrd_base)
-            dt_base = initrd_base + initrd_size;
-        else
-            dt_base = kernel_size + loadaddr;
-
-        if (bamboo_load_device_tree(dt_base, ram_size,
-                        initrd_base, initrd_size, kernel_cmdline) < 0) {
+        if (bamboo_load_device_tree(FDT_ADDR, ram_size, RAMDISK_ADDR,
+                                    initrd_size, kernel_cmdline) < 0) {
             fprintf(stderr, "couldn't load device tree\n");
             exit(1);
         }
@@ -163,7 +160,7 @@ static void bamboo_init(ram_addr_t ram_size,
 
         /* Set initial guest state. */
         env->gpr[1] = (16<<20) - 8;
-        env->gpr[3] = dt_base;
+        env->gpr[3] = FDT_ADDR;
         env->nip = entry;
         /* XXX we currently depend on KVM to create some initial TLB entries. */
     }
Signature · 1 line
1.6.0.2
#2 lore raw

PATCH 2/6 PPC: Update openbios binary to r859

In reply to Alexander Graf

This updates the openBIOS binary to r589, adding support for PPC PV feature pass-through in KVM.

---
 pc-bios/openbios-ppc |  Bin 320324 -> 320328 bytes
 1 files changed, 0 insertions(+), 0 deletions(-)

[...] leaving out all the binary crap - do a pull if you need it.

Signature · 1 line
1.6.0.2
#7 lore raw
In reply to Alexander Graf

Thanks, pulled.

When you update OpenBIOS images, please remember to update the README also.

Quoted 32 lines · Alexander Graf

The following changes since commit 2446333cd5b5c985f6517dee7004e542ecacd21c:
 Blue Swirl (1):
       Rearrange block headers

are available in the git repository at:

 git://repo.or.cz/qemu/agraf.git ppc-next

Alexander Graf (2):
 PPC: Add PV hypercall transport through fw_cfg
 PPC: Update openbios binary to r859

Hollis Blanchard (4):
 Fix "make install" with a cross toolchain
 ppc4xx: correct SDRAM controller warning message condition
 ppc4xx: don't unregister RAM at reset
 ppc4xx: load Bamboo kernel, initrd, and fdt at fixed addresses

 Makefile.target      |    5 ++++-
 configure            |    4 +++-
 hw/ppc.h             |    3 +++
 hw/ppc440_bamboo.c   |   39 ++++++++++++++++++---------------------

 hw/ppc4xx_devs.c     |    3 +--
 hw/ppc_newworld.c    |    7 +++++++
 hw/ppc_oldworld.c    |    7 +++++++
 pc-bios/openbios-ppc |  Bin 320324 -> 320328 bytes
 target-ppc/kvm.c     |   32 ++++++++++++++++++++++++++++++++
 target-ppc/kvm_ppc.h |    1 +
 10 files changed, 76 insertions(+), 25 deletions(-)