ppc patch queue 2012-01-21
Hi Anthony / Aurelien / Blue,
This is my current patch queue for ppc. Please pull.
Alex
The following changes since commit 515689235c4c3d9c3f0406ddcdd21ed8da77062b:
Anthony Liguori (1):
Merge remote-tracking branch 'spice/spice.v47' into staging
are available in the git repository at:
git://repo.or.cz/qemu/agraf.git for-upstream
Alexander Graf (14):
PPC: 440EP: Initialize timer
PPC: Bamboo: Register CPU reset
PPC: Bamboo: Set initial TLB entry
PPC: 440: Ignore invalid PCI IRQs
PPC: Bamboo: recompile device tree
PPC: 440: Default to 440EP CPU
PPC: Enable 440EP CPU target
PPC: bamboo: remove old machine descriptions
PPC: bamboo: fix whitespace
PPC: 4xx: Qdevify the 440 PCI host controller
PPC: Bamboo: fold ppc440.c and ppc440_bamboo.c into a single file
PPC: Bamboo: Integrate SoC instatiation, use qdev for PCI
virtio: change memcpy to guest reads
PPC: Pseries: Check for PCI boundaries
Andreas Färber (4):
MAINTAINERS: Add qemu-ppc to all ppc target stuff
MAINTAINERS: Add PCI host bridge files to CHRP machines
MAINTAINERS: Add PCI-PCI bridge to New World Mac machine
grackle_pci: Clean up qdev names
Benjamin Herrenschmidt (5):
virtio-pci: Fix endianness of virtio config load_image_targphys() should enforce the max size Fix dirty logging with 32-bit qemu & 64-bit guests
pseries: Support PCI extended config space in RTAS calls
pseries: SLOF PCI flag day
David Gibson (3):
Update gitignore file
Correct types in bmdma_addr_{read,write}
pseries: Use correct dispatcher for PCI config space accesses
.gitignore | 4 + MAINTAINERS | 8 ++ Makefile.target | 2 +- exec.c | 14 ++++ hw/grackle_pci.c | 17 +++- hw/ide/pci.c | 4 +- hw/loader.c | 6 +- hw/ppc440.c | 106 -------------------------- hw/ppc440.h | 21 ----- hw/ppc440_bamboo.c | 154 ++++++++++++++++++++++++++++++--------- hw/ppc4xx_pci.c | 129 +++++++++++++++++--------------- hw/spapr.c | 135 ++++++++++++++++++++++----------- hw/spapr_pci.c | 173 +++++++++++-------------------------------- hw/virtex_ml507.c | 1 - hw/virtio-pci.c | 28 +++++++- hw/virtio.c | 12 ++-- kvm-all.c | 3 +- pc-bios/README | 2 +- pc-bios/bamboo.dtb | Bin 3179 -> 3211 bytes pc-bios/bamboo.dts | 128 ++++++++++++-------------------- pc-bios/slof.bin | Bin 738744 -> 869584 bytes roms/SLOF | 2 +- target-ppc/translate_init.c | 16 +--- 23 files changed, 458 insertions(+), 507 deletions(-) delete mode 100644 hw/ppc440.c delete mode 100644 hw/ppc440.h
PATCH 1/26 PPC: 440EP: Initialize timer
When using TCG with a BookE PowerPC core, we need to explicitly initialize the BookE timers with the correct frequencies.
This was missing for 440EP, since that code came from KVM and was never used with TCG.
--- hw/ppc440.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
hw/ppc440.c +1 -0
@@ -56,6 +56,7 @@ CPUState *ppc440ep_init(MemoryRegion *address_space_mem, ram_addr_t *ram_size,exit (1 ); } +ppc_booke_timers_init (env,400000000 ,0 );ppc_dcr_init (env,NULL ,NULL );/* interrupt controller */
Signature · 1 line
1.6.0.2
PATCH 2/26 PPC: Bamboo: Register CPU reset
In reply to Alexander GrafTo be able to support CPU reset, we need to put all register initialization and initial state into a CPU reset hook instead of a function that is only called once on bootup.
This is a preparation step for the initial TLB setting code and brings bamboo more in line with what e500 and virtex already do.
--- hw/ppc440_bamboo.c | 19 +++++++++++++------ 1 files changed, 13 insertions(+), 6 deletions(-)
hw/ppc440_bamboo.c +13 -6
@@ -32,6 +32,8 @@#define FDT_ADDR 0x1800000#define RAMDISK_ADDR 0x1900000 +static target_phys_addr_t entry; + static int bamboo_load_device_tree(target_phys_addr_t addr, uint32_t ramsize, target_phys_addr_t initrd_base,
@@ -101,6 +103,16 @@ out:return ret; } +static void main_cpu_reset (void *opaque) +{ +CPUState *env = opaque; + +cpu_reset (env); + env->gpr[1 ] = (16 <<20 ) -8 ; + env->gpr[3 ] =FDT_ADDR ; + env->nip = entry; +} + static void bamboo_init(ram_addr_t ram_size, const char *boot_device, const char *kernel_filename,
@@ -114,7 +126,6 @@ static void bamboo_init(ram_addr_t ram_size,CPUState *env;uint64_t elf_entry;uint64_t elf_lowaddr; -target_phys_addr_t entry =0 ;target_phys_addr_t loadaddr =0 ;target_long initrd_size =0 ;int success;
@@ -123,6 +134,7 @@ static void bamboo_init(ram_addr_t ram_size,/* Setup CPU. */ env =ppc440ep_init (address_space_mem, &ram_size, &pcibus, pci_irq_nrs,1 , cpu_model); +qemu_register_reset (main_cpu_reset, env);if (pcibus) {/* Register network interfaces. */
@@ -169,11 +181,6 @@ static void bamboo_init(ram_addr_t ram_size,fprintf (stderr,"couldn't load device tree\n" );exit (1 ); } - -/* Set initial guest state. */ - env->gpr[1 ] = (16 <<20 ) -8 ; - 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
PATCH 3/26 PPC: Bamboo: Set initial TLB entry
In reply to Alexander GrafBack in the day when the bamboo target got introduced, the initial TLB was dictated by KVM. TCG has been missing initial TLB values ever since, rendering the target unusable for TCG usage.
This patch adds linear TLB maps the way Linux expects them, making the target work.
--- hw/ppc440_bamboo.c | 27 ++++++++++++++++++++++++++- 1 files changed, 26 insertions(+), 1 deletions(-)
hw/ppc440_bamboo.c +26 -1
@@ -103,6 +103,29 @@ out:return ret; } +/* Create reset TLB entries for BookE, spanning the 32bit addr space. */ +static void mmubooke_create_initial_mapping (CPUState *env, +target_ulong va, +target_phys_addr_t pa) +{ +ppcemb_tlb_t *tlb = &env->tlb.tlbe[0 ]; + + tlb->attr =0 ; + tlb->prot =PAGE_VALID | ((PAGE_READ |PAGE_WRITE |PAGE_EXEC ) <<4 ); + tlb->size =1 <<31 ;/* up to 0x80000000 */ + tlb->EPN = va &TARGET_PAGE_MASK ; + tlb->RPN = pa &TARGET_PAGE_MASK ; + tlb->PID =0 ; + + tlb = &env->tlb.tlbe[1 ]; + tlb->attr =0 ; + tlb->prot =PAGE_VALID | ((PAGE_READ |PAGE_WRITE |PAGE_EXEC ) <<4 ); + tlb->size =1 <<31 ;/* up to 0xffffffff */ + tlb->EPN =0x80000000 &TARGET_PAGE_MASK ; + tlb->RPN =0x80000000 &TARGET_PAGE_MASK ; + tlb->PID =0 ; +} +static void main_cpu_reset (void *opaque) {CPUState *env = opaque;
@@ -111,6 +134,9 @@ static void main_cpu_reset(void *opaque) env->gpr[1 ] = (16 <<20 ) -8 ; env->gpr[3 ] =FDT_ADDR ; env->nip = entry; + +/* Create a mapping for the kernel. */ +mmubooke_create_initial_mapping (env,0 ,0 ); } static void bamboo_init(ram_addr_t ram_size,
@@ -181,7 +207,6 @@ static void bamboo_init(ram_addr_t ram_size,fprintf (stderr,"couldn't load device tree\n" );exit (1 ); } -/* XXX we currently depend on KVM to create some initial TLB entries. */ }if (kvm_enabled ())
Signature · 1 line
1.6.0.2
PATCH 4/26 PPC: 440: Ignore invalid PCI IRQs
In reply to Alexander GrafWhen running a 440 target, we currently get invalid irq_num values (-1) which completely confuse the IRQ setting code.
This is most likely due to the missing qdev conversion.
While this shouldn't happen in the first place and should really rather be fixed by converting the target, I dislike segfaults. So for now, let's just print a warning and ignore invalid irq_num values.
--- hw/ppc4xx_pci.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
hw/ppc4xx_pci.c +4 -0
@@ -275,6 +275,10 @@ static void ppc4xx_pci_set_irq(void *opaque, int irq_num, int level)qemu_irq *pci_irqs = opaque;DPRINTF ("%s: PCI irq %d\n" , __func__, irq_num); +if (irq_num <0 ) { +fprintf (stderr,"%s: PCI irq %d\n" , __func__, irq_num); +return ; + }qemu_set_irq (pci_irqs[irq_num], level); }
Signature · 1 line
1.6.0.2
PATCH 5/26 PPC: Bamboo: recompile device tree
In reply to Alexander GrafRecent dtc doesn't compile our dts anymore. Change all hex numbers to have 0x prefixes, indicate the old version and recompile using recent dtc.
This doesn't change any semantics in the device tree.
--- pc-bios/bamboo.dtb | Bin 3179 -> 3211 bytes pc-bios/bamboo.dts | 128 +++++++++++++++++++--------------------------------- 2 files changed, 47 insertions(+), 81 deletions(-)
pc-bios/bamboo.dtb binary +0 -0
pc-bios/bamboo.dts +47 -81
245 lines not on this page · raw message
Signature · 1 line
1.6.0.2
PATCH 6/26 PPC: 440: Default to 440EP CPU
In reply to Alexander GrafToday we're exposing a Virtex 440 CPU to the guest despite the fact that we're telling the guest that we're running on a 440EP one in the device tree.
So let's better default to a real 440EP to make things synced again.
--- hw/ppc440.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
hw/ppc440.c +1 -1
@@ -48,7 +48,7 @@ CPUState *ppc440ep_init(MemoryRegion *address_space_mem, ram_addr_t *ram_size,qemu_irq *pci_irqs;if (cpu_model ==NULL ) { - cpu_model ="440-Xilinx" ;// XXX: should be 440EP + cpu_model ="440EP" ; } env =cpu_init (cpu_model);if (!env) {
Signature · 1 line
1.6.0.2
PATCH 7/26 PPC: Enable 440EP CPU target
In reply to Alexander GrafNow that we have 440 TLB emulation, we can also support running the 440EP CPU target in system emulation mode.
--- target-ppc/translate_init.c | 16 +++++----------- 1 files changed, 5 insertions(+), 11 deletions(-)
target-ppc/translate_init.c +5 -11
@@ -3516,6 +3516,9 @@ static void init_proc_405 (CPUPPCState *env)/* PowerPC 440 EP */ #define POWERPC_INSNS_440EP (PPC_INSNS_BASE | PPC_STRING | \ + PPC_FLOAT | PPC_FLOAT_FRES | PPC_FLOAT_FSEL | \ + PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE | \ + PPC_FLOAT_STFIWX | \ PPC_DCR | PPC_WRTEE | PPC_RFMCI | \ PPC_CACHE | PPC_CACHE_ICBI | \ PPC_CACHE_DCBZ | PPC_CACHE_DCBA | \
@@ -3523,7 +3526,7 @@ static void init_proc_405 (CPUPPCState *env) PPC_BOOKE | PPC_4xx_COMMON | PPC_405_MAC | \ PPC_440_SPEC)#define POWERPC_INSNS2_440EP (PPC_NONE) -#define POWERPC_MSRM_440EP (0x000000000006D630ULL) +#define POWERPC_MSRM_440EP (0x000000000006FF30ULL)#define POWERPC_MMU_440EP (POWERPC_MMU_BOOKE)#define POWERPC_EXCP_440EP (POWERPC_EXCP_BOOKE)#define POWERPC_INPUT_440EP (PPC_FLAGS_INPUT_BookE)
@@ -3532,7 +3535,6 @@ static void init_proc_405 (CPUPPCState *env) POWERPC_FLAG_DE | POWERPC_FLAG_BUS_CLK)#define check_pow_440EP check_pow_nocheck -__attribute__ (( unused ))static void init_proc_440EP (CPUPPCState *env) {/* Time base */
@@ -3593,7 +3595,7 @@ static void init_proc_440EP (CPUPPCState *env)init_excp_BookE (env); env->dcache_line_size =32 ; env->icache_line_size =32 ; -/* XXX: TODO: allocate internal IRQ controller */ +ppc40x_irq_init (env);SET_FIT_PERIOD (12 ,16 ,20 ,24 );SET_WDT_PERIOD (20 ,24 ,28 ,32 );
@@ -7869,22 +7871,14 @@ static const ppc_def_t ppc_defs[] = { POWERPC_DEF("440H6", CPU_POWERPC_440H6, 440Gx5), #endif/* PowerPC 440 microcontrolers */ -#if defined(TODO_USER_ONLY )/* PowerPC 440 EP */ POWERPC_DEF("440EP", CPU_POWERPC_440EP, 440EP), -#endif -#if defined(TODO_USER_ONLY )/* PowerPC 440 EPa */ POWERPC_DEF("440EPa", CPU_POWERPC_440EPa, 440EP), -#endif -#if defined(TODO_USER_ONLY )/* PowerPC 440 EPb */ POWERPC_DEF("440EPb", CPU_POWERPC_440EPb, 440EP), -#endif -#if defined(TODO_USER_ONLY )/* PowerPC 440 EPX */ POWERPC_DEF("440EPX", CPU_POWERPC_440EPX, 440EP), -#endif #if defined(TODO_USER_ONLY) /* PowerPC 440 GP */ POWERPC_DEF("440GP", CPU_POWERPC_440GP, 440GP),
Signature · 1 line
1.6.0.2
PATCH 8/26 PPC: bamboo: remove old machine descriptions
In reply to Alexander GrafNobody needs to run bamboo in 0.12 compat mode. Remove the machine.
--- hw/ppc440_bamboo.c | 22 +--------------------- 1 files changed, 1 insertions(+), 21 deletions(-)
hw/ppc440_bamboo.c +1 -21
@@ -214,34 +214,14 @@ static void bamboo_init(ram_addr_t ram_size, }static QEMUMachine bamboo_machine = { - .name ="bamboo-0.13" , - .alias ="bamboo" , + .name ="bamboo" , .desc ="bamboo" , .init = bamboo_init, }; -static QEMUMachine bamboo_machine_v0_12 = { - .name ="bamboo-0.12" , - .desc ="bamboo" , - .init = bamboo_init, - .compat_props = (GlobalProperty []) { - { - .driver ="virtio-serial-pci" , - .property ="max_ports" , - .value =stringify (1 ), - },{ - .driver ="virtio-serial-pci" , - .property ="vectors" , - .value =stringify (0 ), - }, - {/* end of list */ } - }, -}; -static void bamboo_machine_init (void ) {qemu_register_machine (&bamboo_machine); -qemu_register_machine (&bamboo_machine_v0_12); }machine_init (bamboo_machine_init);
Signature · 1 line
1.6.0.2
PATCH 9/26 PPC: bamboo: fix whitespace
In reply to Alexander GrafTabs followed by spaces are a no-go. My editor shows it red, distracting me from actual work! :)
--- hw/ppc440_bamboo.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
hw/ppc440_bamboo.c +3 -3
@@ -3,9 +3,9 @@* * Copyright 2007 IBM Corporation. * Authors: -* Jerone Young <[email protected]> -* Christian Ehrhardt <[email protected]> -* Hollis Blanchard <[email protected]> +* Jerone Young <[email protected]> +* Christian Ehrhardt <[email protected]> +* Hollis Blanchard <[email protected]> * * This work is licensed under the GNU GPL license version 2 or later. *
Signature · 1 line
1.6.0.2
PATCH 10/26 PPC: 4xx: Qdevify the 440 PCI host controller
In reply to Alexander GrafDue to popular demand, this qdevifies the PCI host controller of 4xx SoCs the same way as e500.
We have to introduce a small stub function for pci init that will be removed in a later patch, once we qdev'ified the board, to keep the build working.
--- hw/ppc440_bamboo.c | 9 ++++ hw/ppc4xx_pci.c | 125 +++++++++++++++++++++++++++------------------------- 2 files changed, 74 insertions(+), 60 deletions(-)
hw/ppc440_bamboo.c +9 -0
@@ -34,6 +34,15 @@static target_phys_addr_t entry; +static PCIBus *ppc4xx_pci_init (CPUState *env,qemu_irq pci_irqs[4 ], +target_phys_addr_t config_space, +target_phys_addr_t int_ack, +target_phys_addr_t special_cycle, +target_phys_addr_t registers) +{ +return NULL ; +} + static int bamboo_load_device_tree(target_phys_addr_t addr, uint32_t ramsize, target_phys_addr_t initrd_base,
hw/ppc4xx_pci.c +65 -60
153 lines not on this page · raw message
Signature · 1 line
1.6.0.2
PATCH 11/26 PPC: Bamboo: fold ppc440.c and ppc440_bamboo.c into a single file
In reply to Alexander GrafThe separation of ppc440 and ppc440_bamboo makes some sense, since ppc440 is the SoC while ppc440_bamboo is the actual board. But the separation makes things harder for us for no good reason, so let's just fold them in together with each other.
--- Makefile.target | 2 +- hw/ppc440.c | 107 ---------------------------------------------------- hw/ppc440.h | 21 ---------- hw/ppc440_bamboo.c | 90 +++++++++++++++++++++++++++++++++++++++++++- hw/virtex_ml507.c | 1 - 5 files changed, 90 insertions(+), 131 deletions(-) delete mode 100644 hw/ppc440.c delete mode 100644 hw/ppc440.h
Makefile.target +1 -1
@@ -250,7 +250,7 @@ obj-ppc-$(CONFIG_PSERIES) += xics.o spapr_vty.o spapr_llan.o spapr_vscsi.o obj-ppc-$(CONFIG_PSERIES) += spapr_pci.o device-hotplug.o pci-hotplug.o # PowerPC 4xx boards obj-ppc-y += ppc4xx_devs.o ppc4xx_pci.o ppc405_uc.o ppc405_boards.o -obj-ppc-y += ppc440.o ppc440_bamboo.o +obj-ppc-y += ppc440_bamboo.o # PowerPC E500 boards obj-ppc-y += ppce500_mpc8544ds.o mpc8544_guts.o ppce500_spin.o # PowerPC 440 Xilinx ML507 reference board.
hw/ppc440.c deleted +0 -107
107 lines not on this page · raw message
hw/ppc440.h deleted +0 -21
@@ -1,21 +0,0 @@ -/* -* Qemu PowerPC 440 board emualtion -* -* Copyright 2007 IBM Corporation. -* Authors: Jerone Young <[email protected]> -* Christian Ehrhardt <[email protected]> -* -* This work is licensed under the GNU GPL licence version 2 or later -* -*/ - -#ifndef QEMU_PPC440_H -#define QEMU_PPC440_H - -#include "hw.h" - -CPUState *ppc440ep_init (MemoryRegion *address_space,ram_addr_t *ram_size, -PCIBus **pcip,const unsigned int pci_irq_nrs[4 ], -int do_init,const char *cpu_model); - -#endif
hw/ppc440_bamboo.c +89 -1
114 lines not on this page · raw message
hw/virtex_ml507.c +0 -1
@@ -38,7 +38,6 @@#include "ppc.h" #include "ppc4xx.h" -#include "ppc440.h" #include "ppc405.h" #include "blockdev.h"
Signature · 1 line
1.6.0.2
PATCH 12/26 PPC: Bamboo: Integrate SoC instatiation, use qdev for PCI
In reply to Alexander GrafNow that we have the SoC init function in the same file, let's integrate it with the board initialization.
While at it, also make use of the newly qdev'ified PCI host controller.
--- hw/ppc440_bamboo.c | 143 ++++++++++++++++++++++------------------------------ 1 files changed, 60 insertions(+), 83 deletions(-)
hw/ppc440_bamboo.c +60 -83
@@ -27,6 +27,7 @@#include "ppc.h" #include "ppc405.h" #include "sysemu.h" +#include "sysbus.h" #define BINARY_DEVICE_TREE_FILE "bamboo.dtb"
@@ -50,87 +51,6 @@ static const unsigned int ppc440ep_sdram_bank_sizes[] = {static target_phys_addr_t entry; -static PCIBus *ppc4xx_pci_init (CPUState *env,qemu_irq pci_irqs[4 ], -target_phys_addr_t config_space, -target_phys_addr_t int_ack, -target_phys_addr_t special_cycle, -target_phys_addr_t registers) -{ -return NULL ; -} - -CPUState *ppc440ep_init (MemoryRegion *address_space_mem,ram_addr_t *ram_size, -PCIBus **pcip,const unsigned int pci_irq_nrs[4 ], -int do_init,const char *cpu_model) -{ -MemoryRegion *ram_memories - =g_malloc (PPC440EP_SDRAM_NR_BANKS *sizeof (*ram_memories)); -target_phys_addr_t ram_bases[PPC440EP_SDRAM_NR_BANKS ]; -target_phys_addr_t ram_sizes[PPC440EP_SDRAM_NR_BANKS ]; -CPUState *env; -qemu_irq *pic; -qemu_irq *irqs; -qemu_irq *pci_irqs; - -if (cpu_model ==NULL ) { - cpu_model ="440EP" ; - } - env =cpu_init (cpu_model); -if (!env) { -fprintf (stderr,"Unable to initialize CPU!\n" ); -exit (1 ); - } - -ppc_booke_timers_init (env,400000000 ,0 ); -ppc_dcr_init (env,NULL ,NULL ); - -/* interrupt controller */ - irqs =g_malloc0 (sizeof (qemu_irq) *PPCUIC_OUTPUT_NB ); - irqs[PPCUIC_OUTPUT_INT ] = ((qemu_irq *)env->irq_inputs)[PPC40x_INPUT_INT]; - irqs[PPCUIC_OUTPUT_CINT ] = ((qemu_irq *)env->irq_inputs)[PPC40x_INPUT_CINT]; - pic =ppcuic_init (env, irqs,0x0C0 ,0 ,1 ); - -/* SDRAM controller */ -memset (ram_bases,0 ,sizeof (ram_bases)); -memset (ram_sizes,0 ,sizeof (ram_sizes)); - *ram_size =ppc4xx_sdram_adjust (*ram_size,PPC440EP_SDRAM_NR_BANKS , - ram_memories, - ram_bases, ram_sizes, - ppc440ep_sdram_bank_sizes); -/* XXX 440EP's ECC interrupts are on UIC1, but we've only created UIC0. */ -ppc4xx_sdram_init (env, pic[14 ],PPC440EP_SDRAM_NR_BANKS , ram_memories, - ram_bases, ram_sizes, do_init); - -/* PCI */ - pci_irqs =g_malloc (sizeof (qemu_irq) *4 ); - pci_irqs[0 ] = pic[pci_irq_nrs[0 ]]; - pci_irqs[1 ] = pic[pci_irq_nrs[1 ]]; - pci_irqs[2 ] = pic[pci_irq_nrs[2 ]]; - pci_irqs[3 ] = pic[pci_irq_nrs[3 ]]; - *pcip =ppc4xx_pci_init (env, pci_irqs, -PPC440EP_PCI_CONFIG , -PPC440EP_PCI_INTACK , -PPC440EP_PCI_SPECIAL , -PPC440EP_PCI_REGS ); -if (!*pcip) -printf ("couldn't create PCI controller!\n" ); - -isa_mmio_init (PPC440EP_PCI_IO ,PPC440EP_PCI_IOLEN ); - -if (serial_hds[0 ] !=NULL ) { -serial_mm_init (address_space_mem,0xef600300 ,0 , pic[0 ], -PPC_SERIAL_MM_BAUDBASE , serial_hds[0 ], -DEVICE_BIG_ENDIAN ); - } -if (serial_hds[1 ] !=NULL ) { -serial_mm_init (address_space_mem,0xef600400 ,0 , pic[1 ], -PPC_SERIAL_MM_BAUDBASE , serial_hds[1 ], -DEVICE_BIG_ENDIAN ); - } - -return env; -} - static int bamboo_load_device_tree(target_phys_addr_t addr, uint32_t ramsize, target_phys_addr_t initrd_base,
@@ -245,19 +165,76 @@ static void bamboo_init(ram_addr_t ram_size, {unsigned int pci_irq_nrs[4 ] = {28 ,27 ,26 ,25 };MemoryRegion *address_space_mem =get_system_memory (); +MemoryRegion *ram_memories + =g_malloc (PPC440EP_SDRAM_NR_BANKS *sizeof (*ram_memories)); +target_phys_addr_t ram_bases[PPC440EP_SDRAM_NR_BANKS ]; +target_phys_addr_t ram_sizes[PPC440EP_SDRAM_NR_BANKS ]; +qemu_irq *pic; +qemu_irq *irqs;PCIBus *pcibus;CPUState *env;uint64_t elf_entry;uint64_t elf_lowaddr;target_phys_addr_t loadaddr =0 ;target_long initrd_size =0 ; +DeviceState *dev;int success;int i;/* Setup CPU. */ - env =ppc440ep_init (address_space_mem, &ram_size, &pcibus, - pci_irq_nrs,1 , cpu_model); +if (cpu_model ==NULL ) { + cpu_model ="440EP" ; + } + env =cpu_init (cpu_model); +if (!env) { +fprintf (stderr,"Unable to initialize CPU!\n" ); +exit (1 ); + } +qemu_register_reset (main_cpu_reset, env); +ppc_booke_timers_init (env,400000000 ,0 ); +ppc_dcr_init (env,NULL ,NULL ); + +/* interrupt controller */ + irqs =g_malloc0 (sizeof (qemu_irq) *PPCUIC_OUTPUT_NB ); + irqs[PPCUIC_OUTPUT_INT ] = ((qemu_irq *)env->irq_inputs)[PPC40x_INPUT_INT]; + irqs[PPCUIC_OUTPUT_CINT ] = ((qemu_irq *)env->irq_inputs)[PPC40x_INPUT_CINT]; + pic =ppcuic_init (env, irqs,0x0C0 ,0 ,1 ); + +/* SDRAM controller */ +memset (ram_bases,0 ,sizeof (ram_bases)); +memset (ram_sizes,0 ,sizeof (ram_sizes)); + ram_size =ppc4xx_sdram_adjust (ram_size,PPC440EP_SDRAM_NR_BANKS , + ram_memories, + ram_bases, ram_sizes, + ppc440ep_sdram_bank_sizes); +/* XXX 440EP's ECC interrupts are on UIC1, but we've only created UIC0. */ +ppc4xx_sdram_init (env, pic[14 ],PPC440EP_SDRAM_NR_BANKS , ram_memories, + ram_bases, ram_sizes,1 ); + +/* PCI */ + dev =sysbus_create_varargs ("ppc4xx-pcihost" ,PPC440EP_PCI_CONFIG , + pic[pci_irq_nrs[0 ]], pic[pci_irq_nrs[1 ]], + pic[pci_irq_nrs[2 ]], pic[pci_irq_nrs[3 ]], +NULL ); + pcibus = (PCIBus *)qdev_get_child_bus (dev,"pci.0" ); +if (!pcibus) { +fprintf (stderr,"couldn't create PCI controller!\n" ); +exit (1 ); + } + +isa_mmio_init (PPC440EP_PCI_IO ,PPC440EP_PCI_IOLEN ); + +if (serial_hds[0 ] !=NULL ) { +serial_mm_init (address_space_mem,0xef600300 ,0 , pic[0 ], +PPC_SERIAL_MM_BAUDBASE , serial_hds[0 ], +DEVICE_BIG_ENDIAN ); + } +if (serial_hds[1 ] !=NULL ) { +serial_mm_init (address_space_mem,0xef600400 ,0 , pic[1 ], +PPC_SERIAL_MM_BAUDBASE , serial_hds[1 ], +DEVICE_BIG_ENDIAN ); + }if (pcibus) {/* Register network interfaces. */
Signature · 1 line
1.6.0.2
PATCH 13/26 virtio-pci: Fix endianness of virtio config
In reply to Alexander GrafFrom: Benjamin Herrenschmidt <[email protected]>
The virtio config area in PIO space is a bit special. The initial header is little endian but the rest (device specific) is guest native endian.
The PIO accessors for PCI on machines that don't have native IO ports assume that all PIO is little endian, which works fine for everything except the above.
A complicated way to fix it would be to split the BAR into two memory regions with different endianess settings, but this isn't practical to do, besides, the PIO code doesn't honor region endianness anyway (I have a patch for that too but it isn't necessary at this stage).
So I decided to go for the quick fix instead which consists of reverting the swap in virtio-pci in selected places, hoping that when we eventually do a "v2" of the virtio protocols, we sort that out once and for all using a fixed endian setting for everything.
[agraf: keep virtio in libhw and determine endianness through a
helper function in exec.c]
--- exec.c | 14 ++++++++++++++ hw/virtio-pci.c | 28 ++++++++++++++++++++++++++-- 2 files changed, 40 insertions(+), 2 deletions(-)
exec.c +14 -0
@@ -4390,6 +4390,20 @@ tb_page_addr_t get_page_addr_code(CPUState *env1, target_ulong addr)return qemu_ram_addr_from_host_nofail (p); } +/* +* A helper function for the _utterly broken_ virtio device model to find out if +* it's running on a big endian machine. Don't do this at home kids! +*/ +bool virtio_is_big_endian (void ); +bool virtio_is_big_endian (void ) +{ +#if defined(TARGET_WORDS_BIGENDIAN ) +return true; +#else +return false; +#endif +} +#define MMUSUFFIX _cmmu#undef GETPC#define GETPC () NULL
hw/virtio-pci.c +26 -2
@@ -91,6 +91,9 @@*/ #define wmb () do { } while (0) +/* HACK for virtio to determine if it's running a big endian guest */ +bool virtio_is_big_endian (void ); +/* virtio device */ static void virtio_pci_notify (void *opaque,uint16_t vector)
@@ -414,20 +417,35 @@ static uint32_t virtio_pci_config_readw(void *opaque, uint32_t addr) {VirtIOPCIProxy *proxy = opaque;uint32_t config =VIRTIO_PCI_CONFIG (&proxy->pci_dev); +uint16_t val;if (addr < config)return virtio_ioport_read (proxy, addr); addr -= config; -return virtio_config_readw (proxy->vdev, addr); + val =virtio_config_readw (proxy->vdev, addr); +if (virtio_is_big_endian ()) { +/* +* virtio is odd, ioports are LE but config space is target native +* endian. However, in qemu, all PIO is LE, so we need to re-swap +* on BE targets +*/ + val =bswap16 (val); + } +return val; }static uint32_t virtio_pci_config_readl (void *opaque,uint32_t addr) {VirtIOPCIProxy *proxy = opaque;uint32_t config =VIRTIO_PCI_CONFIG (&proxy->pci_dev); +uint32_t val;if (addr < config)return virtio_ioport_read (proxy, addr); addr -= config; -return virtio_config_readl (proxy->vdev, addr); + val =virtio_config_readl (proxy->vdev, addr); +if (virtio_is_big_endian ()) { + val =bswap32 (val); + } +return val; }static void virtio_pci_config_writeb (void *opaque,uint32_t addr,uint32_t val)
@@ -451,6 +469,9 @@ static void virtio_pci_config_writew(void *opaque, uint32_t addr, uint32_t val)return ; } addr -= config; +if (virtio_is_big_endian ()) { + val =bswap16 (val); + }virtio_config_writew (proxy->vdev, addr, val); }
@@ -463,6 +484,9 @@ static void virtio_pci_config_writel(void *opaque, uint32_t addr, uint32_t val)return ; } addr -= config; +if (virtio_is_big_endian ()) { + val =bswap32 (val); + }virtio_config_writel (proxy->vdev, addr, val); }
Signature · 1 line
1.6.0.2
PATCH 14/26 virtio: change memcpy to guest reads
In reply to Alexander GrafWhen accessing the device specific virtio config space, we memcpy the data into a variable in QEMU. At that point we're basically pulling host endianness into the game which is a really bad idea.
So instead, let's use the target specific load/store helpers for memory pointers which fetch things in target endianness. The whole array is already populated in target endianness anyways (see virtio-blk).
--- hw/virtio.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-)
hw/virtio.c +6 -6
@@ -539,7 +539,7 @@ uint32_t virtio_config_readb(VirtIODevice *vdev, uint32_t addr)if (addr > (vdev->config_len -sizeof (val)))return (uint32_t )-1 ; -memcpy (&val, vdev->config + addr,sizeof (val)); + val =ldub_p (vdev->config + addr);return val; }
@@ -552,7 +552,7 @@ uint32_t virtio_config_readw(VirtIODevice *vdev, uint32_t addr)if (addr > (vdev->config_len -sizeof (val)))return (uint32_t )-1 ; -memcpy (&val, vdev->config + addr,sizeof (val)); + val =lduw_p (vdev->config + addr);return val; }
@@ -565,7 +565,7 @@ uint32_t virtio_config_readl(VirtIODevice *vdev, uint32_t addr)if (addr > (vdev->config_len -sizeof (val)))return (uint32_t )-1 ; -memcpy (&val, vdev->config + addr,sizeof (val)); + val =ldl_p (vdev->config + addr);return val; }
@@ -576,7 +576,7 @@ void virtio_config_writeb(VirtIODevice *vdev, uint32_t addr, uint32_t data)if (addr > (vdev->config_len -sizeof (val)))return ; -memcpy (vdev->config + addr, &val,sizeof (val)); +stb_p (vdev->config + addr, val);if (vdev->set_config) vdev->set_config (vdev, vdev->config);
@@ -589,7 +589,7 @@ void virtio_config_writew(VirtIODevice *vdev, uint32_t addr, uint32_t data)if (addr > (vdev->config_len -sizeof (val)))return ; -memcpy (vdev->config + addr, &val,sizeof (val)); +stw_p (vdev->config + addr, val);if (vdev->set_config) vdev->set_config (vdev, vdev->config);
@@ -602,7 +602,7 @@ void virtio_config_writel(VirtIODevice *vdev, uint32_t addr, uint32_t data)if (addr > (vdev->config_len -sizeof (val)))return ; -memcpy (vdev->config + addr, &val,sizeof (val)); +stl_p (vdev->config + addr, val);if (vdev->set_config) vdev->set_config (vdev, vdev->config);
Signature · 1 line
1.6.0.2
PATCH 15/26 load_image_targphys() should enforce the max size
In reply to Alexander GrafFrom: Benjamin Herrenschmidt <[email protected]>
load_image_targphys() gets passed a max size for the file, but doesn't enforce it at all. Add a check and return -1 (error) if the file is too big, without loading it. Fix the bracing style in the function while we're at it.
--- hw/loader.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-)
hw/loader.c +5 -1
@@ -108,8 +108,12 @@ int load_image_targphys(const char *filename,int size; size =get_image_size (filename); -if (size >0 ) +if (size > max_sz) { +return -1 ; + } +if (size >0 ) {rom_add_file_fixed (filename, addr,-1 ); + }return size; }
Signature · 1 line
1.6.0.2
PATCH 16/26 Fix dirty logging with 32-bit qemu & 64-bit guests
In reply to Alexander GrafFrom: Benjamin Herrenschmidt <[email protected]>
The kvm_get_dirty_pages_log_range() function uses two address variables to step through the monitored memory region to update the dirty log. However, these variables have type unsigned long, which can overflow if running a 64-bit guest with a 32-bit qemu binary.
This patch changes these to target_phys_addr_t which will have the correct size.
--- kvm-all.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
kvm-all.c +2 -1
@@ -344,7 +344,8 @@ static int kvm_get_dirty_pages_log_range(MemoryRegionSection *section, unsigned long *bitmap) {unsigned int i, j; -unsigned long page_number, addr, addr1, c; +unsigned long page_number, c; +target_phys_addr_t addr, addr1;unsigned int len = ((section->size /TARGET_PAGE_SIZE ) +HOST_LONG_BITS -1 ) /HOST_LONG_BITS ;/*
Signature · 1 line
1.6.0.2
PATCH 17/26 Update gitignore file
In reply to Alexander GrafFrom: David Gibson <[email protected]>
This patch adds several auto-generated files to .gitignore which were previously missing.
--- .gitignore | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
.gitignore +4 -0
@@ -42,6 +42,10 @@ qemu-ga qemu-monitor.texi QMP/qmp-commands.txt test-coroutine +test-qmp-input-visitor +test-qmp-output-visitor +fsdev/virtfs-proxy-helper.1 +fsdev/virtfs-proxy-helper.pod .gdbinit *.a *.aux
Signature · 1 line
1.6.0.2
PATCH 18/26 Correct types in bmdma_addr_{read, write}
In reply to Alexander GrafFrom: David Gibson <[email protected]>
Back when I made patches introducing dma_addr_t and various PCI DMA wrapper functions, I made a mistake. The bmdma_addr_{read,write} functions need to take target_phys_addr_t not dma_addr_t, since they are assigned to MemoryRegionOps callbacks.
This patch corrects my error.
--- hw/ide/pci.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
hw/ide/pci.c +2 -2
@@ -327,7 +327,7 @@ void bmdma_cmd_writeb(BMDMAState *bm, uint32_t val) bm->cmd = val &0x09 ; } -static uint64_t bmdma_addr_read (void *opaque,dma_addr_t addr, +static uint64_t bmdma_addr_read (void *opaque,target_phys_addr_t addr,unsigned width) {BMDMAState *bm = opaque;
@@ -341,7 +341,7 @@ static uint64_t bmdma_addr_read(void *opaque, dma_addr_t addr,return data; } -static void bmdma_addr_write (void *opaque,dma_addr_t addr, +static void bmdma_addr_write (void *opaque,target_phys_addr_t addr,uint64_t data,unsigned width) {BMDMAState *bm = opaque;
Signature · 1 line
1.6.0.2
PATCH 19/26 pseries: Support PCI extended config space in RTAS calls
In reply to Alexander GrafFrom: Benjamin Herrenschmidt <[email protected]>
On the pseries machine (which expexts a paravirtualized guest), guest access to PCI config space is via host-provided RTAS functions. This patch extends these RTAS functions to permit access to PCI extended config space, as specified in PAPR.
--- hw/spapr_pci.c | 14 ++++++++++---- 1 files changed, 10 insertions(+), 4 deletions(-)
hw/spapr_pci.c +10 -4
@@ -62,6 +62,11 @@ static PCIDevice *find_dev(sPAPREnvironment *spapr,return NULL ; } +static uint32_t rtas_pci_cfgaddr (uint32_t arg) +{ +return ((arg >>20 ) &0xf00 ) | (arg &0xff ); +} + static void rtas_ibm_read_pci_config(sPAPREnvironment *spapr, uint32_t token, uint32_t nargs, target_ulong args,
@@ -76,7 +81,7 @@ static void rtas_ibm_read_pci_config(sPAPREnvironment *spapr,return ; } size =rtas_ld (args,3 ); - addr =rtas_ld (args,0 ) &0xFF ; + addr =rtas_pci_cfgaddr (rtas_ld (args,0 )); val =pci_default_read_config (dev, addr, size);rtas_st (rets,0 ,0 );rtas_st (rets,1 , val);
@@ -95,7 +100,7 @@ static void rtas_read_pci_config(sPAPREnvironment *spapr,return ; } size =rtas_ld (args,1 ); - addr =rtas_ld (args,0 ) &0xFF ; + addr =rtas_pci_cfgaddr (rtas_ld (args,0 )); val =pci_default_read_config (dev, addr, size);rtas_st (rets,0 ,0 );rtas_st (rets,1 , val);
@@ -116,7 +121,7 @@ static void rtas_ibm_write_pci_config(sPAPREnvironment *spapr, } val =rtas_ld (args,4 ); size =rtas_ld (args,3 ); - addr =rtas_ld (args,0 ) &0xFF ; + addr =rtas_pci_cfgaddr (rtas_ld (args,0 ));pci_default_write_config (dev, addr, val, size);rtas_st (rets,0 ,0 ); }
@@ -135,7 +140,7 @@ static void rtas_write_pci_config(sPAPREnvironment *spapr, } val =rtas_ld (args,2 ); size =rtas_ld (args,1 ); - addr =rtas_ld (args,0 ) &0xFF ; + addr =rtas_pci_cfgaddr (rtas_ld (args,0 ));pci_default_write_config (dev, addr, val, size);rtas_st (rets,0 ,0 ); }
@@ -394,6 +399,7 @@ int spapr_populate_pci_devices(sPAPRPHBState *phb,_FDT (fdt_setprop (fdt, bus_off,"reg" , &bus_reg,sizeof (bus_reg)));_FDT (fdt_setprop (fdt, bus_off,"interrupt-map-mask" , &interrupt_map_mask,sizeof (interrupt_map_mask))); +_FDT (fdt_setprop_cell (fdt, bus_off,"ibm,pci-config-space-type" ,0x1 ));/* Populate PCI devices and allocate IRQs */ devices =0 ;
Signature · 1 line
1.6.0.2
PATCH 20/26 pseries: Use correct dispatcher for PCI config space accesses
In reply to Alexander GrafFrom: David Gibson <[email protected]>
The pseries machine expects a para-virtualized guest and so supplies RTAS functions (via a hypercall) for performing PCI config space access. Currently the implementation of these calls into pci_default_{read,write}_config(). However this would be incorrect for any PCI device which overrides the default config read/write functions. AFAICT there's only one such device today, but we should still get it right. In addition the pci_host_config_{read,write}_common() functions which do correctly do this dispatch, perform bounds checking on the config space address, lack of which currently leads to an exploitable bug.
This patch corrects the problem.
--- hw/spapr_pci.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
hw/spapr_pci.c +4 -4
@@ -82,7 +82,7 @@ static void rtas_ibm_read_pci_config(sPAPREnvironment *spapr, } size =rtas_ld (args,3 ); addr =rtas_pci_cfgaddr (rtas_ld (args,0 )); - val =pci_default_read_config (dev, addr, size); + val =pci_host_config_read_common (dev, addr,pci_config_size (dev), size);rtas_st (rets,0 ,0 );rtas_st (rets,1 , val); }
@@ -101,7 +101,7 @@ static void rtas_read_pci_config(sPAPREnvironment *spapr, } size =rtas_ld (args,1 ); addr =rtas_pci_cfgaddr (rtas_ld (args,0 )); - val =pci_default_read_config (dev, addr, size); + val =pci_host_config_read_common (dev, addr,pci_config_size (dev), size);rtas_st (rets,0 ,0 );rtas_st (rets,1 , val); }
@@ -122,7 +122,7 @@ static void rtas_ibm_write_pci_config(sPAPREnvironment *spapr, val =rtas_ld (args,4 ); size =rtas_ld (args,3 ); addr =rtas_pci_cfgaddr (rtas_ld (args,0 )); -pci_default_write_config (dev, addr, val, size); +pci_host_config_write_common (dev, addr,pci_config_size (dev), val, size);rtas_st (rets,0 ,0 ); }
@@ -141,7 +141,7 @@ static void rtas_write_pci_config(sPAPREnvironment *spapr, val =rtas_ld (args,2 ); size =rtas_ld (args,1 ); addr =rtas_pci_cfgaddr (rtas_ld (args,0 )); -pci_default_write_config (dev, addr, val, size); +pci_host_config_write_common (dev, addr,pci_config_size (dev), val, size);rtas_st (rets,0 ,0 ); }
Signature · 1 line
1.6.0.2
PATCH 21/26 pseries: SLOF PCI flag day
In reply to Alexander GrafFrom: Benjamin Herrenschmidt <[email protected]>
Currently on the pseries machine the SLOF firmware is used normally, but we bypass it when -kernel is specified. Having these two
different boot paths can cause some confusion.
In particular at present we need to "probe" the (emulated) PCI bus and produce device tree nodes for the PCI devices in qemu, for the -kernel case. In the SLOF case, it takes the device tree from qemu adds some stuff to it then passes it on to the kernel.
It's been decided that a better approach is to always boot through SLOF, even when using -kernel. WIth this approach we can leave PCI probing and device node creation to SLOF in all cases which removes a bunch of code in qemu, and avoids iterating the PCI devices from the machine specific init code which we're not supposed to do.
This patch changes qemu to always boot through SLOF, and not to create PCI nodes. Simultaneously it updates the included version of SLOF (submodule and binary image) to one which supports (and requires) the new approach.
The new SLOF version also includes a number of unrelated enhancements:
support for booting from virtio-pci devices and e1000, greatly improved FCode support and many bugfixes. It also makes SLOF ready to be used even when specifying a kernel on the qemu command line.
--- hw/spapr.c | 135 ++++++++++++++++++++++++++++++++++++------------------ hw/spapr_pci.c | 134 +++++------------------------------------------------ pc-bios/README | 2 +- pc-bios/slof.bin | Bin 738744 -> 869584 bytes roms/SLOF | 2 +- 5 files changed, 105 insertions(+), 168 deletions(-)
hw/spapr.c +91 -44
@@ -50,19 +50,29 @@#include <libfdt.h> -#define KERNEL_LOAD_ADDR 0x00000000 -#define INITRD_LOAD_ADDR 0x02800000 +/* SLOF memory layout: +* +* SLOF raw image loaded at 0, copies its romfs right below the flat +* device-tree, then position SLOF itself 31M below that +* +* So we set FW_OVERHEAD to 40MB which should account for all of that +* and more +* +* We load our kernel at 4M, leaving space for SLOF initial image +*/ #define FDT_MAX_SIZE 0x10000#define RTAS_MAX_SIZE 0x10000#define FW_MAX_SIZE 0x400000#define FW_FILE_NAME "slof.bin" +#define FW_OVERHEAD 0x2800000 +#define KERNEL_LOAD_ADDR FW_MAX_SIZE -#define MIN_RMA_SLOF 128UL +#define MIN_RMA_SLOF 128UL#define TIMEBASE_FREQ 512000000ULL#define MAX_CPUS 256 -#define XICS_IRQS 1024 +#define XICS_IRQS 1024#define SPAPR_PCI_BUID 0x800000020000001ULL#define SPAPR_PCI_MEM_WIN_ADDR (0x10000000000ULL + 0xA0000000)
@@ -139,6 +149,7 @@ static void *spapr_create_fdt_skel(const char *cpu_model,target_phys_addr_t rma_size, target_phys_addr_t initrd_base, target_phys_addr_t initrd_size, + target_phys_addr_t kernel_size, const char *boot_device, const char *kernel_cmdline, long hash_shift)
@@ -176,6 +187,12 @@ static void *spapr_create_fdt_skel(const char *cpu_model, fdt =g_malloc0 (FDT_MAX_SIZE );_FDT ((fdt_create (fdt,FDT_MAX_SIZE ))); +if (kernel_size) { +_FDT ((fdt_add_reservemap_entry (fdt,KERNEL_LOAD_ADDR , kernel_size))); + } +if (initrd_size) { +_FDT ((fdt_add_reservemap_entry (fdt, initrd_base, initrd_size))); + }_FDT ((fdt_finish_reservemap (fdt)));/* Root node */
@@ -197,15 +214,13 @@ static void *spapr_create_fdt_skel(const char *cpu_model, &start_prop, sizeof(start_prop))));_FDT ((fdt_property (fdt,"linux,initrd-end" , &end_prop,sizeof (end_prop)))); -_FDT ((fdt_property_string (fdt,"qemu,boot-device" , boot_device))); +if (kernel_size) { +uint64_t kprop[2 ] = {cpu_to_be64 (KERNEL_LOAD_ADDR ), +cpu_to_be64 (kernel_size) }; -/* -* Because we don't always invoke any firmware, we can't rely on -* that to do BAR allocation. Long term, we should probably do -* that ourselves, but for now, this setting (plus advertising the -* current BARs as 0) causes sufficiently recent kernels to to the -* BAR assignment themselves */ -_FDT ((fdt_property_cell (fdt,"linux,pci-probe-only" ,0 ))); +_FDT ((fdt_property (fdt,"qemu,boot-kernel" , &kprop,sizeof (kprop)))); + } +_FDT ((fdt_property_string (fdt,"qemu,boot-device" , boot_device)));_FDT ((fdt_end_node (fdt)));
@@ -445,6 +460,12 @@ static void spapr_finalize_fdt(sPAPREnvironment *spapr,_FDT ((fdt_pack (fdt))); +if (fdt_totalsize (fdt) >FDT_MAX_SIZE ) { +hw_error ("FDT too big ! 0x%x bytes (max is 0x%x)\n" , +fdt_totalsize (fdt),FDT_MAX_SIZE ); +exit (1 ); + } +cpu_physical_memory_write (fdt_addr, fdt,fdt_totalsize (fdt));g_free (fdt);
@@ -494,8 +515,9 @@ static void ppc_spapr_init(ram_addr_t ram_size,MemoryRegion *sysmem =get_system_memory ();MemoryRegion *ram =g_new (MemoryRegion,1 );target_phys_addr_t rma_alloc_size, rma_size; -uint32_t initrd_base; -long kernel_size, initrd_size, fw_size; +uint32_t initrd_base =0 ; +long kernel_size =0 , initrd_size =0 ; +long load_limit, rtas_limit, fw_size;long pteg_shift =17 ;char *filename;
@@ -517,11 +539,13 @@ static void ppc_spapr_init(ram_addr_t ram_size, rma_size = ram_size; } -/* We place the device tree just below either the top of the RMA, +/* We place the device tree and RTAS just below either the top of the RMA, * or just below 2GB, whichever is lowere, so that it can be * processed with 32-bit real mode code if necessary */ - spapr->fdt_addr =MIN (rma_size,0x80000000 ) -FDT_MAX_SIZE ; - spapr->rtas_addr = spapr->fdt_addr -RTAS_MAX_SIZE ; + rtas_limit =MIN (rma_size,0x80000000 ); + spapr->rtas_addr = rtas_limit -RTAS_MAX_SIZE ; + spapr->fdt_addr = spapr->rtas_addr -FDT_MAX_SIZE ; + load_limit = spapr->fdt_addr -FW_OVERHEAD ;/* init CPUs */ if (cpu_model ==NULL ) {
@@ -577,13 +601,19 @@ static void ppc_spapr_init(ram_addr_t ram_size, filename =qemu_find_file (QEMU_FILE_TYPE_BIOS ,"spapr-rtas.bin" ); spapr->rtas_size =load_image_targphys (filename, spapr->rtas_addr, - ram_size - spapr->rtas_addr); + rtas_limit - spapr->rtas_addr);if (spapr->rtas_size <0 ) {hw_error ("qemu: could not load LPAR rtas '%s'\n" , filename);exit (1 ); } +if (spapr->rtas_size >RTAS_MAX_SIZE ) { +hw_error ("RTAS too big ! 0x%lx bytes (max is 0x%x)\n" , + spapr->rtas_size,RTAS_MAX_SIZE ); +exit (1 ); + }g_free (filename); +/* Set up Interrupt Controller */ spapr->icp =xics_system_init (XICS_IRQS ); spapr->next_irq =16 ;
@@ -622,6 +652,20 @@ static void ppc_spapr_init(ram_addr_t ram_size,spapr_vscsi_create (spapr->vio_bus,0x2000 + i); } +if (rma_size < (MIN_RMA_SLOF <<20 )) { +fprintf (stderr,"qemu: pSeries SLOF firmware requires >= " +"%ldM guest RMA (Real Mode Area memory)\n" ,MIN_RMA_SLOF ); +exit (1 ); + } + +fprintf (stderr,"sPAPR memory map:\n" ); +fprintf (stderr,"RTAS : 0x%08lx..%08lx\n" , + (unsigned long )spapr->rtas_addr, + (unsigned long )(spapr->rtas_addr + spapr->rtas_size -1 )); +fprintf (stderr,"FDT : 0x%08lx..%08lx\n" , + (unsigned long )spapr->fdt_addr, + (unsigned long )(spapr->fdt_addr +FDT_MAX_SIZE -1 )); +if (kernel_filename) {uint64_t lowaddr =0 ;
@@ -630,57 +674,60 @@ static void ppc_spapr_init(ram_addr_t ram_size,if (kernel_size <0 ) { kernel_size =load_image_targphys (kernel_filename,KERNEL_LOAD_ADDR , - ram_size -KERNEL_LOAD_ADDR ); + load_limit -KERNEL_LOAD_ADDR ); }if (kernel_size <0 ) {fprintf (stderr,"qemu: could not load kernel '%s'\n" , kernel_filename);exit (1 ); } +fprintf (stderr,"Kernel : 0x%08x..%08lx\n" , +KERNEL_LOAD_ADDR ,KERNEL_LOAD_ADDR + kernel_size -1 );/* load initrd */ if (initrd_filename) { - initrd_base =INITRD_LOAD_ADDR ; +/* Try to locate the initrd in the gap between the kernel +* and the firmware. Add a bit of space just in case +*/ + initrd_base = (KERNEL_LOAD_ADDR + kernel_size +0x1ffff ) & ~0xffff ; initrd_size =load_image_targphys (initrd_filename, initrd_base, - ram_size - initrd_base); + load_limit - initrd_base);if (initrd_size <0 ) {fprintf (stderr,"qemu: could not load initial ram disk '%s'\n" , initrd_filename);exit (1 ); } +fprintf (stderr,"Ramdisk : 0x%08lx..%08lx\n" , + (long )initrd_base, (long )(initrd_base + initrd_size -1 )); }else { initrd_base =0 ; initrd_size =0 ; } + } - spapr->entry_point =KERNEL_LOAD_ADDR ; - }else { -if (rma_size < (MIN_RMA_SLOF <<20 )) { -fprintf (stderr,"qemu: pSeries SLOF firmware requires >= " -"%ldM guest RMA (Real Mode Area memory)\n" ,MIN_RMA_SLOF ); -exit (1 ); - } - filename =qemu_find_file (QEMU_FILE_TYPE_BIOS ,FW_FILE_NAME ); - fw_size =load_image_targphys (filename,0 ,FW_MAX_SIZE ); -if (fw_size <0 ) { -hw_error ("qemu: could not load LPAR rtas '%s'\n" , filename); -exit (1 ); - } -g_free (filename); - spapr->entry_point =0x100 ; - initrd_base =0 ; - initrd_size =0 ; - -/* SLOF will startup the secondary CPUs using RTAS, -rather than expecting a kexec() style entry */ -for (env = first_cpu; env !=NULL ; env = env->next_cpu) { - env->halted =1 ; - } + filename =qemu_find_file (QEMU_FILE_TYPE_BIOS ,FW_FILE_NAME ); + fw_size =load_image_targphys (filename,0 ,FW_MAX_SIZE ); +if (fw_size <0 ) { +hw_error ("qemu: could not load LPAR rtas '%s'\n" , filename); +exit (1 ); + } +g_free (filename); +fprintf (stderr,"Firmware load : 0x%08x..%08lx\n" , +0 , fw_size); +fprintf (stderr,"Firmware runtime : 0x%08lx..%08lx\n" , + load_limit, (unsigned long )spapr->fdt_addr); + + spapr->entry_point =0x100 ; + +/* SLOF will startup the secondary CPUs using RTAS */ +for (env = first_cpu; env !=NULL ; env = env->next_cpu) { + env->halted =1 ; }/* Prepare the device tree */ spapr->fdt_skel =spapr_create_fdt_skel (cpu_model, rma_size, initrd_base, initrd_size, + kernel_size, boot_device, kernel_cmdline, pteg_shift +7 );assert (spapr->fdt_skel !=NULL );
hw/spapr_pci.c +12 -122
168 lines not on this page · raw message
pc-bios/README +1 -1
@@ -17,7 +17,7 @@ - SLOF (Slimline Open Firmware) is a free IEEE 1275 Open Firmware implementation for certain IBM POWER hardware. The sources are at https://github.com/dgibson/SLOF, and the image currently in qemu is - built from git tag qemu-slof-20111013. + built from git tag qemu-slof-20120111.1. - sgabios (the Serial Graphics Adapter option ROM) provides a means for legacy x86 software to communicate with an attached serial console as
pc-bios/slof.bin binary +0 -0
roms/SLOF +1 -1
@@ -1 +1 @@ -Subproject commit 32e3430c018ceb8413cb808477449d1968c42497 +Subproject commit ab062ff3b37c39649f2b0d94ed607adc6f6b3c7d
Signature · 1 line
1.6.0.2
PATCH 22/26 MAINTAINERS: Add qemu-ppc to all ppc target stuff
In reply to Alexander GrafFrom: Andreas Färber <[email protected]>
--- MAINTAINERS | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
MAINTAINERS +5 -0
@@ -93,6 +93,7 @@ F: target-mips/ PowerPC M: Alexander Graf <[email protected]> +L: [email protected] S: Maintained F: target-ppc/
@@ -290,21 +291,25 @@ PowerPC Machines ---------------- 405 M: Alexander Graf <[email protected]> +L: [email protected] S: Maintained F: hw/ppc405_boards.c New World M: Alexander Graf <[email protected]> +L: [email protected] S: Maintained F: hw/ppc_newworld.c Old World M: Alexander Graf <[email protected]> +L: [email protected] S: Maintained F: hw/ppc_oldworld.c PReP M: Andreas Färber <[email protected]> +L: [email protected] S: Odd Fixes F: hw/ppc_prep.c
Signature · 1 line
1.6.0.2
Re: [Qemu-devel] [PATCH 22/26] MAINTAINERS: Add qemu-ppc to all ppc target stuff
Am 21.01.2012 05:19, schrieb Alexander Graf:
Quoted 5 lines
From: Andreas Färber <[email protected]>
Signed-off-by Andreas Färber <[email protected]>Cc Alexander Graf <[email protected]>Signed-off-by Alexander Graf <[email protected]>
Patches 22, 23 and 26 have a "duplicate" Cc: line. You may want to fix on your branch.
Andreas
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
PATCH 23/26 MAINTAINERS: Add PCI host bridge files to CHRP machines
In reply to Alexander GrafFrom: Andreas Färber <[email protected]>
Just like prep_pci.c, these were not associated with any MAINTAINERS section, including PCI.
--- MAINTAINERS | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
MAINTAINERS +2 -0
@@ -300,12 +300,14 @@ M: Alexander Graf <[email protected]> L: [email protected] S: Maintained F: hw/ppc_newworld.c +F: hw/unin_pci.c Old World M: Alexander Graf <[email protected]> L: [email protected] S: Maintained F: hw/ppc_oldworld.c +F: hw/grackle_pci.c PReP M: Andreas Färber <[email protected]>
Signature · 1 line
1.6.0.2
PATCH 24/26 PPC: Pseries: Check for PCI boundaries
In reply to Alexander GrafWe call pci_host_config_{read,write}_common() which perform PCI config accesses. However they don't do all limit checking the way we expect it to.
So let's introduce a small wrapper around them, making them behave the way we would without touching generic code.
This patch is based on a patch by David Gibson which put this logic into the generic code.
--- hw/spapr_pci.c | 27 +++++++++++++++++++++++---- 1 files changed, 23 insertions(+), 4 deletions(-)
hw/spapr_pci.c +23 -4
@@ -67,6 +67,25 @@ static uint32_t rtas_pci_cfgaddr(uint32_t arg)return ((arg >>20 ) &0xf00 ) | (arg &0xff ); } +static uint32_t rtas_read_pci_config_do (PCIDevice *pci_dev,uint32_t addr, +uint32_t limit,uint32_t len) +{ +if ((addr + len) <= limit) { +return pci_host_config_read_common (pci_dev, addr, limit, len); + }else { +return ~0x0 ; + } +} + +static void rtas_write_pci_config_do (PCIDevice *pci_dev,uint32_t addr, +uint32_t limit,uint32_t val, +uint32_t len) +{ +if ((addr + len) <= limit) { +pci_host_config_write_common (pci_dev, addr, limit, val, len); + } +} + static void rtas_ibm_read_pci_config(sPAPREnvironment *spapr, uint32_t token, uint32_t nargs, target_ulong args,
@@ -82,7 +101,7 @@ static void rtas_ibm_read_pci_config(sPAPREnvironment *spapr, } size =rtas_ld (args,3 ); addr =rtas_pci_cfgaddr (rtas_ld (args,0 )); - val =pci_host_config_read_common (dev, addr,pci_config_size (dev), size); + val =rtas_read_pci_config_do (dev, addr,pci_config_size (dev), size);rtas_st (rets,0 ,0 );rtas_st (rets,1 , val); }
@@ -101,7 +120,7 @@ static void rtas_read_pci_config(sPAPREnvironment *spapr, } size =rtas_ld (args,1 ); addr =rtas_pci_cfgaddr (rtas_ld (args,0 )); - val =pci_host_config_read_common (dev, addr,pci_config_size (dev), size); + val =rtas_read_pci_config_do (dev, addr,pci_config_size (dev), size);rtas_st (rets,0 ,0 );rtas_st (rets,1 , val); }
@@ -122,7 +141,7 @@ static void rtas_ibm_write_pci_config(sPAPREnvironment *spapr, val =rtas_ld (args,4 ); size =rtas_ld (args,3 ); addr =rtas_pci_cfgaddr (rtas_ld (args,0 )); -pci_host_config_write_common (dev, addr,pci_config_size (dev), val, size); +rtas_write_pci_config_do (dev, addr,pci_config_size (dev), val, size);rtas_st (rets,0 ,0 ); }
@@ -141,7 +160,7 @@ static void rtas_write_pci_config(sPAPREnvironment *spapr, val =rtas_ld (args,2 ); size =rtas_ld (args,1 ); addr =rtas_pci_cfgaddr (rtas_ld (args,0 )); -pci_host_config_write_common (dev, addr,pci_config_size (dev), val, size); +rtas_write_pci_config_do (dev, addr,pci_config_size (dev), val, size);rtas_st (rets,0 ,0 ); }
Signature · 1 line
1.6.0.2
PATCH 25/26 MAINTAINERS: Add PCI-PCI bridge to New World Mac machine
In reply to Alexander GrafFrom: Andreas Färber <[email protected]>
--- MAINTAINERS | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
MAINTAINERS +1 -0
@@ -301,6 +301,7 @@ L: [email protected] S: Maintained F: hw/ppc_newworld.c F: hw/unin_pci.c +F: hw/dec_pci.[hc] Old World M: Alexander Graf <[email protected]>
Signature · 1 line
1.6.0.2
PATCH 26/26 grackle_pci: Clean up qdev names
In reply to Alexander GrafFrom: Andreas Färber <[email protected]>
Rename SysBus device from 'grackle' to 'grackle-pcihost' to resolve a name conflict.
Also mark both devices as no_user.
--- hw/grackle_pci.c | 17 ++++++++++++----- 1 files changed, 12 insertions(+), 5 deletions(-)
hw/grackle_pci.c +12 -5
@@ -71,7 +71,7 @@ PCIBus *pci_grackle_init(uint32_t base, qemu_irq *pic,SysBusDevice *s;GrackleState *d; - dev =qdev_create (NULL ,"grackle" ); + dev =qdev_create (NULL ,"grackle-pcihost" );qdev_init_nofail (dev); s =sysbus_from_qdev (dev); d =FROM_SYSBUS (GrackleState, s);
@@ -121,9 +121,10 @@ static int grackle_pci_host_init(PCIDevice *d)return 0 ; } -static PCIDeviceInfo grackle_pci_host_info = { +static PCIDeviceInfo grackle_pci_info = { .qdev.name ="grackle" , .qdev.size =sizeof (PCIDevice), + .qdev.no_user =1 , .init = grackle_pci_host_init, .vendor_id =PCI_VENDOR_ID_MOTOROLA , .device_id =PCI_DEVICE_ID_MOTOROLA_MPC106 ,
@@ -131,11 +132,17 @@ static PCIDeviceInfo grackle_pci_host_info = { .class_id = PCI_CLASS_BRIDGE_HOST, }; +static SysBusDeviceInfo grackle_pci_host_info = { + .qdev.name ="grackle-pcihost" , + .qdev.size =sizeof (GrackleState), + .qdev.no_user =1 , + .init = pci_grackle_init_device, +}; +static void grackle_register_devices (void ) { -sysbus_register_dev ("grackle" ,sizeof (GrackleState), - pci_grackle_init_device); -pci_qdev_register (&grackle_pci_host_info); +sysbus_register_withprop (&grackle_pci_host_info); +pci_qdev_register (&grackle_pci_info); }device_init (grackle_register_devices)
Signature · 1 line
1.6.0.2
Quoted 3 lines · Alexander Graf
Hi Anthony / Aurelien / Blue,
This is my current patch queue for ppc. Please pull.
Thanks, pulled.
Quoted 71 lines
Alex
The following changes since commit
515689235c4c3d9c3f0406ddcdd21ed8da77062b:
Anthony Liguori (1):
Merge remote-tracking branch 'spice/spice.v47' into stagingare available in the git repository at:
git://repo.or.cz/qemu/agraf.git for-upstream
Alexander Graf (14):
PPC: 440EP: Initialize timer
PPC: Bamboo: Register CPU reset
PPC: Bamboo: Set initial TLB entry
PPC: 440: Ignore invalid PCI IRQs
PPC: Bamboo: recompile device tree
PPC: 440: Default to 440EP CPU
PPC: Enable 440EP CPU target
PPC: bamboo: remove old machine descriptions
PPC: bamboo: fix whitespace
PPC: 4xx: Qdevify the 440 PCI host controller
PPC: Bamboo: foldppc440.candppc440_bamboo.cinto a single file
PPC: Bamboo: Integrate SoC instatiation, use qdev for PCI
virtio: change memcpy to guest reads
PPC: Pseries: Check for PCI boundariesAndreas Färber (4):
MAINTAINERS: Add qemu-ppc to all ppc target stuff
MAINTAINERS: Add PCI host bridge files to CHRP machines
MAINTAINERS: Add PCI-PCI bridge to New World Mac machine
grackle_pci: Clean up qdev namesBenjamin Herrenschmidt (5):
virtio-pci: Fix endianness of virtio configload_image_targphys()should enforce the max size Fix dirty logging with 32-bit qemu & 64-bit guests
pseries: Support PCI extended config space in RTAS calls
pseries: SLOF PCI flag dayDavid Gibson (3):
Update gitignore file
Correct types in bmdma_addr_{read,write}
pseries: Use correct dispatcher for PCI config space accesses.gitignore | 4 +
MAINTAINERS | 8 ++
Makefile.target | 2 +-
exec.c | 14 ++++
hw/grackle_pci.c | 17 +++-hw/ide/pci.c | 4 +- hw/loader.c | 6 +- hw/ppc440.c | 106 -------------------------- hw/ppc440.h | 21 -----hw/ppc440_bamboo.c | 154 ++++++++++++++++++++++++++++++---------
hw/ppc4xx_pci.c| 129 +++++++++++++++++---------------hw/spapr.c| 135 ++++++++++++++++++++++-----------hw/spapr_pci.c| 173 +++++++++++--------------------------------hw/virtex_ml507.c| 1 -
hw/virtio-pci.c | 28 +++++++-
hw/virtio.c | 12 ++--
kvm-all.c | 3 +-
pc-bios/README | 2 +-
pc-bios/bamboo.dtb | Bin 3179 -> 3211 bytespc-bios/bamboo.dts| 128 ++++++++++++-------------------- pc-bios/slof.bin | Bin 738744 -> 869584 bytes roms/SLOF | 2 +-
target-ppc/translate_init.c | 16 +---23 files changed, 458 insertions(+), 507 deletions(-)delete mode 100644
hw/ppc440.c
delete mode 100644hw/ppc440.h