Assorted pseries fixes and updates
cover Assorted pseries fixes and updates
Hi Alex,
I'm now back from vacation, and have more or less got back on top of my qemu tree. Here's my first batch of new patches, an assortment of fairly simple fixes and cleanups for the pseries code.
Please apply.
PATCH 1/5 pseries: Update SLOF
This patch updates the SLOF version, introducing a number of fixes:
* add proper graphics support
* fix bugs with graphical terminal under grub2
* fix bugs in handling of 64-bit unit addresses
* fix VSCSI representation to be closer to PowerVM
* fix bugs which caused grub2 to crash
--- pc-bios/README | 2 +- pc-bios/slof.bin | Bin 880496 -> 878088 bytes roms/SLOF | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-)
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-20120217. + built from git tag qemu-slof-20120719. - 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 d153364253548d6cd91403711f84996e6a7dab31 +Subproject commit 7279655af2eba855bd2df61303d25abd1eeb2300
Signature · 1 line
1.7.10.4
PATCH 2/5 pseries: Instantiate USB if requested
In reply to David GibsonThe pseries machine currently ignores the -usb command line option. This patch corrects the problem by having it instantiate a PCI OHCI USB host controller when -usb is specified.
--- hw/spapr.c | 7 +++++++ 1 file changed, 7 insertions(+)
hw/spapr.c +7 -0
@@ -45,6 +45,7 @@#include "kvm.h" #include "kvm_ppc.h" #include "pci.h" +#include "usb.h" #include "exec-memory.h"
@@ -710,6 +711,12 @@ static void ppc_spapr_init(ram_addr_t ram_size,spapr_vscsi_create (spapr->vio_bus); } +/* USB */ +if (usb_enabled) { +pci_create_simple (QLIST_FIRST (&spapr->phbs)->host_state.bus, +-1 ,"pci-ohci" ); + } +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 );
Signature · 1 line
1.7.10.4
Re: [Qemu-devel] [PATCH 2/5] pseries: Instantiate USB if requested
Quoted 5 lines · David Gibson
The pseries machine currently ignores the -usb command line option. This patch corrects the problem by having it instantiate a PCI OHCI USB host controller when -usb is specified.
Signed-off-by David Gibson <[email protected]>
Same comment as the -vga patch, Li's been dealing with that lately, Li, can you update us on the status of those patches ?
Cheers,
Ben.
Quoted 29 lines
--- hw/spapr.c | 7 +++++++ 1 file changed, 7 insertions(+)hw/spapr.c +7
-0@@ -45,6 +45,7 @@#include "kvm.h" #include "kvm_ppc.h" #include "pci.h" +#include "usb.h" #include "exec-memory.h" @@ -710,6 +711,12 @@ static void ppc_spapr_init(ram_addr_t ram_size,spapr_vscsi_create (spapr->vio_bus); } +/* USB */ +if (usb_enabled) { +pci_create_simple (QLIST_FIRST (&spapr->phbs)->host_state.bus, +-1 ,"pci-ohci" ); + } +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 );
Re: [Qemu-devel] [PATCH 2/5] pseries: Instantiate USB if requested
Quoted 9 lines · Benjamin Herrenschmidt
Quoted 5 lines · David Gibson
The pseries machine currently ignores the -usb command line option. This patch corrects the problem by having it instantiate a PCI OHCI USB host controller when -usb is specified.
Signed-off-by David Gibson <[email protected]>Same comment as the -vga patch, Li's been dealing with that lately, Li, can you update us on the status of those patches ?
Sorry to miss this mail.
I send out the v6 version. -:)
Quoted 35 lines
Cheers,
Ben.Quoted 29 lines
--- hw/spapr.c | 7 +++++++ 1 file changed, 7 insertions(+)hw/spapr.c +7
-0@@ -45,6 +45,7 @@#include "kvm.h" #include "kvm_ppc.h" #include "pci.h" +#include "usb.h" #include "exec-memory.h" @@ -710,6 +711,12 @@ static void ppc_spapr_init(ram_addr_t ram_size,spapr_vscsi_create (spapr->vio_bus); } +/* USB */ +if (usb_enabled) { +pci_create_simple (QLIST_FIRST (&spapr->phbs)->host_state.bus, +-1 ,"pci-ohci" ); + } +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 );
Signature · 2 lines
Best Regards -Li
Re: [Qemu-devel] [PATCH 2/5] pseries: Instantiate USB if requested
In reply to David GibsonQuoted 5 lines · David Gibson
The pseries machine currently ignores the -usb command line option. This patch corrects the problem by having it instantiate a PCI OHCI USB host controller when -usb is specified.
Signed-off-by David Gibson <[email protected]>
Li Zhang <[email protected]> has been owning that patch for a while and I believe has a better version.
Li, what's the status with it ? Alex ?
Cheers,
Ben.
Quoted 29 lines
--- hw/spapr.c | 7 +++++++ 1 file changed, 7 insertions(+)hw/spapr.c +7
-0@@ -45,6 +45,7 @@#include "kvm.h" #include "kvm_ppc.h" #include "pci.h" +#include "usb.h" #include "exec-memory.h" @@ -710,6 +711,12 @@ static void ppc_spapr_init(ram_addr_t ram_size,spapr_vscsi_create (spapr->vio_bus); } +/* USB */ +if (usb_enabled) { +pci_create_simple (QLIST_FIRST (&spapr->phbs)->host_state.bus, +-1 ,"pci-ohci" ); + } +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 );
PATCH 3/5 pseries: Add support for -vga option
In reply to David GibsonFrom: Ben Herrenschmidt <[email protected]>
Also instantiate the USB keyboard and mouse when that option is used (you can still use -device to create individual devices without all the defaults)
--- hw/spapr.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-)
hw/spapr.c +49 -1
@@ -46,6 +46,7 @@#include "kvm_ppc.h" #include "pci.h" #include "usb.h" +#include "pc.h" #include "exec-memory.h"
@@ -83,6 +84,7 @@#define PHANDLE_XICP 0x00001111sPAPREnvironment *spapr; +static bool spapr_has_graphics;qemu_irq spapr_allocate_irq (uint32_t hint,uint32_t *irq_num,enum xics_irq_type type)
@@ -258,6 +260,9 @@ static void *spapr_create_fdt_skel(const char *cpu_model,_FDT ((fdt_property (fdt,"qemu,boot-kernel" , &kprop,sizeof (kprop)))); }_FDT ((fdt_property_string (fdt,"qemu,boot-device" , boot_device))); +_FDT ((fdt_property_cell (fdt,"qemu,graphic-width" , graphic_width))); +_FDT ((fdt_property_cell (fdt,"qemu,graphic-height" , graphic_height))); +_FDT ((fdt_property_cell (fdt,"qemu,graphic-depth" , graphic_depth)));_FDT ((fdt_end_node (fdt)));
@@ -504,7 +509,9 @@ static void spapr_finalize_fdt(sPAPREnvironment *spapr, } } -spapr_populate_chosen_stdout (fdt, spapr->vio_bus); +if (!spapr_has_graphics) { +spapr_populate_chosen_stdout (fdt, spapr->vio_bus); + }_FDT ((fdt_pack (fdt)));
@@ -557,6 +564,37 @@ static void spapr_cpu_reset(void *opaque)cpu_reset (CPU (cpu)); } +static bool spapr_vga_init (sPAPREnvironment *spapr) +{ +PCIBus *pci_bus =QLIST_FIRST (&spapr->phbs)->host_state.bus; + +if (!pci_bus && (vga_interface_type !=VGA_NONE )) { +fprintf (stderr,"Can't instantiate VGA interface without a PCI bus\n" ); +exit (1 ); + } + +/* Default is nothing */ +#if 0 /* Enable this once we merge a SLOF which works with Cirrus */ +if (cirrus_vga_enabled) { +pci_cirrus_vga_init (pci_bus); + } else +#endif +if (vmsvga_enabled) { +fprintf (stderr,"Warning: vmware_vga not available," +" using standard VGA instead\n" ); +pci_vga_init (pci_bus); +#ifdef CONFIG_SPICE + }else if (qxl_enabled) { +pci_create_simple (pci_bus,-1 ,"qxl-vga" ); +#endif + }else if (std_vga_enabled) { +pci_vga_init (pci_bus); + }else { +return false; + } +return true; +} +/* pSeries LPAR / sPAPR hardware init */ static void ppc_spapr_init(ram_addr_t ram_size, const char *boot_device,
@@ -711,10 +749,20 @@ static void ppc_spapr_init(ram_addr_t ram_size,spapr_vscsi_create (spapr->vio_bus); } +/* Graphics */ +if (spapr_vga_init (spapr)) { + spapr_has_graphics = true; + usb_enabled =1 ; + } +/* USB */ if (usb_enabled) {pci_create_simple (QLIST_FIRST (&spapr->phbs)->host_state.bus,-1 ,"pci-ohci" ); +if (spapr_has_graphics) { +usbdevice_create ("keyboard" ); +usbdevice_create ("mouse" ); + } }if (rma_size < (MIN_RMA_SLOF <<20 )) {
Signature · 1 line
1.7.10.4
PATCH 4/5 pseries: Remove extraneous prints
In reply to David GibsonThe pseries machine prints several messages to stderr whenever it starts up and another whenever the vm is reset. It's not normal for qemu machines to do this though, so this patch removes them. We can put them back conditional on a DEBUG symbol if we really need them in future.
--- hw/spapr.c | 18 ------------------ 1 file changed, 18 deletions(-)
hw/spapr.c +0 -18
@@ -540,8 +540,6 @@ static void spapr_reset(void *opaque) {sPAPREnvironment *spapr = (sPAPREnvironment *)opaque; -fprintf (stderr,"sPAPR reset\n" ); -/* flush out the hash table */ memset (spapr->htab,0 , spapr->htab_size);
@@ -771,14 +769,6 @@ static void ppc_spapr_init(ram_addr_t ram_size,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 ;
@@ -794,8 +784,6 @@ static void ppc_spapr_init(ram_addr_t ram_size, 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) {
@@ -810,8 +798,6 @@ static void ppc_spapr_init(ram_addr_t ram_size, 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 ;
@@ -825,10 +811,6 @@ static void ppc_spapr_init(ram_addr_t ram_size,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 ;
Signature · 1 line
1.7.10.4
PATCH 5/5 pseries: Add support for new KVM hash table control call
In reply to David GibsonFrom: Ben Herrenschmidt <[email protected]>
This adds support for then new "reset htab" ioctl which allows qemu to properly cleanup the MMU hash table when the guest is reset. With the corresponding kernel support, reset of a guest now works properly.
This also paves the way for indicating a different size hash table to the kernel and for the kernel to be able to impose limits on the requested size.
--- hw/spapr.c | 294 ++++++++++++++++++++++++++++++-------------------- hw/spapr.h | 4 +- target-ppc/kvm.c | 51 +++++++-- target-ppc/kvm_ppc.h | 20 ++++ 4 files changed, 243 insertions(+), 126 deletions(-)
hw/spapr.c +180 -114
@@ -83,6 +83,8 @@#define PHANDLE_XICP 0x00001111 +#define HTAB_SIZE (spapr) (1ULL << ((spapr)->htab_shift)) +sPAPREnvironment *spapr;static bool spapr_has_graphics;
@@ -111,12 +113,13 @@ qemu_irq spapr_allocate_irq(uint32_t hint, uint32_t *irq_num,return qirq; } -static int spapr_set_associativity (void *fdt,sPAPREnvironment *spapr) +static int spapr_fixup_cpu_dt (void *fdt,sPAPREnvironment *spapr) {int ret =0 , offset;CPUPPCState *env;char cpu_model[32 ];int smt =kvmppc_smt_threads (); +uint32_t pft_size_prop[] = {0 ,cpu_to_be32 (spapr->htab_shift)};assert (spapr->cpu_model);
@@ -140,8 +143,16 @@ static int spapr_set_associativity(void *fdt, sPAPREnvironment *spapr)return offset; } - ret =fdt_setprop (fdt, offset,"ibm,associativity" , associativity, -sizeof (associativity)); +if (nb_numa_nodes >1 ) { + ret =fdt_setprop (fdt, offset,"ibm,associativity" , associativity, +sizeof (associativity)); +if (ret <0 ) { +return ret; + } + } + + ret =fdt_setprop (fdt, offset,"ibm,pft-size" , + pft_size_prop,sizeof (pft_size_prop));if (ret <0 ) {return ret; }
@@ -183,45 +194,36 @@ static size_t create_page_sizes_prop(CPUPPCState *env, uint32_t *prop,return (p - prop) *sizeof (uint32_t ); } +#define _FDT (exp) \ + do { \ + int ret = (exp); \ + if (ret < 0) { \ + fprintf(stderr, "qemu: error creating device tree: %s: %s\n", \ + #exp, fdt_strerror(ret)); \ + exit(1); \ + } \ + } while (0) + +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) +const char *kernel_cmdline) {void *fdt;CPUPPCState *env; -uint64_t mem_reg_property[2 ];uint32_t start_prop =cpu_to_be32 (initrd_base);uint32_t end_prop =cpu_to_be32 (initrd_base + initrd_size); -uint32_t pft_size_prop[] = {0 ,cpu_to_be32 (hash_shift)};char hypertas_prop[] ="hcall-pft\0hcall-term\0hcall-dabr\0hcall-interrupt" "\0hcall-tce\0hcall-vio\0hcall-splpar\0hcall-bulk" ;char qemu_hypertas_prop[] ="hcall-memop1" ; +uint32_t refpoints[] = {cpu_to_be32 (0x4 ),cpu_to_be32 (0x4 )};uint32_t interrupt_server_ranges_prop[] = {0 ,cpu_to_be32 (smp_cpus)}; -int i;char *modelname; -int smt =kvmppc_smt_threads (); +int i, smt =kvmppc_smt_threads ();unsigned char vec5[] = {0x0 ,0x0 ,0x0 ,0x0 ,0x0 ,0x80 }; -uint32_t refpoints[] = {cpu_to_be32 (0x4 ),cpu_to_be32 (0x4 )}; -uint32_t associativity[] = {cpu_to_be32 (0x4 ),cpu_to_be32 (0x0 ), -cpu_to_be32 (0x0 ),cpu_to_be32 (0x0 ), -cpu_to_be32 (0x0 )}; -char mem_name[32 ]; -target_phys_addr_t node0_size, mem_start; - -#define _FDT (exp) \ - do { \ - int ret = (exp); \ - if (ret < 0) { \ - fprintf(stderr, "qemu: error creating device tree: %s: %s\n", \ - #exp, fdt_strerror(ret)); \ - exit(1); \ - } \ - } while (0) fdt =g_malloc0 (FDT_MAX_SIZE );_FDT ((fdt_create (fdt,FDT_MAX_SIZE )));
@@ -266,55 +268,6 @@ static void *spapr_create_fdt_skel(const char *cpu_model,_FDT ((fdt_end_node (fdt))); -/* memory node(s) */ - node0_size = (nb_numa_nodes >1 ) ? node_mem[0 ] : ram_size; -if (rma_size > node0_size) { - rma_size = node0_size; - } - -/* RMA */ - mem_reg_property[0 ] =0 ; - mem_reg_property[1 ] =cpu_to_be64 (rma_size); -_FDT ((fdt_begin_node (fdt,"memory@0" ))); -_FDT ((fdt_property_string (fdt,"device_type" ,"memory" ))); -_FDT ((fdt_property (fdt,"reg" , mem_reg_property, -sizeof (mem_reg_property)))); -_FDT ((fdt_property (fdt,"ibm,associativity" , associativity, -sizeof (associativity)))); -_FDT ((fdt_end_node (fdt))); - -/* RAM: Node 0 */ -if (node0_size > rma_size) { - mem_reg_property[0 ] =cpu_to_be64 (rma_size); - mem_reg_property[1 ] =cpu_to_be64 (node0_size - rma_size); - -sprintf (mem_name,"memory@" TARGET_FMT_lx, rma_size); -_FDT ((fdt_begin_node (fdt, mem_name))); -_FDT ((fdt_property_string (fdt,"device_type" ,"memory" ))); -_FDT ((fdt_property (fdt,"reg" , mem_reg_property, -sizeof (mem_reg_property)))); -_FDT ((fdt_property (fdt,"ibm,associativity" , associativity, -sizeof (associativity)))); -_FDT ((fdt_end_node (fdt))); - } - -/* RAM: Node 1 and beyond */ - mem_start = node0_size; -for (i =1 ; i < nb_numa_nodes; i++) { - mem_reg_property[0 ] =cpu_to_be64 (mem_start); - mem_reg_property[1 ] =cpu_to_be64 (node_mem[i]); - associativity[3 ] = associativity[4 ] =cpu_to_be32 (i); -sprintf (mem_name,"memory@" TARGET_FMT_lx, mem_start); -_FDT ((fdt_begin_node (fdt, mem_name))); -_FDT ((fdt_property_string (fdt,"device_type" ,"memory" ))); -_FDT ((fdt_property (fdt,"reg" , mem_reg_property, -sizeof (mem_reg_property)))); -_FDT ((fdt_property (fdt,"ibm,associativity" , associativity, -sizeof (associativity)))); -_FDT ((fdt_end_node (fdt))); - mem_start += node_mem[i]; - } -/* cpus */ _FDT ((fdt_begin_node (fdt,"cpus" )));
@@ -366,8 +319,6 @@ static void *spapr_create_fdt_skel(const char *cpu_model,_FDT ((fdt_property_cell (fdt,"timebase-frequency" , tbfreq)));_FDT ((fdt_property_cell (fdt,"clock-frequency" , cpufreq)));_FDT ((fdt_property_cell (fdt,"ibm,slb-size" , env->slb_nr))); -_FDT ((fdt_property (fdt,"ibm,pft-size" , - pft_size_prop,sizeof (pft_size_prop))));_FDT ((fdt_property_string (fdt,"status" ,"okay" )));_FDT ((fdt_property (fdt,"64-bit" ,NULL ,0 )));
@@ -466,6 +417,68 @@ static void *spapr_create_fdt_skel(const char *cpu_model,return fdt; } +static int spapr_populate_memory (sPAPREnvironment *spapr,void *fdt) +{ +uint32_t associativity[] = {cpu_to_be32 (0x4 ),cpu_to_be32 (0x0 ), +cpu_to_be32 (0x0 ),cpu_to_be32 (0x0 ), +cpu_to_be32 (0x0 )}; +char mem_name[32 ]; +target_phys_addr_t node0_size, mem_start; +uint64_t mem_reg_property[2 ]; +int i, off; + +/* memory node(s) */ + node0_size = (nb_numa_nodes >1 ) ? node_mem[0 ] : ram_size; +if (spapr->rma_size > node0_size) { + spapr->rma_size = node0_size; + } + +/* RMA */ + mem_reg_property[0 ] =0 ; + mem_reg_property[1 ] =cpu_to_be64 (spapr->rma_size); + off =fdt_add_subnode (fdt,0 ,"memory@0" ); +_FDT (off); +_FDT ((fdt_setprop_string (fdt, off,"device_type" ,"memory" ))); +_FDT ((fdt_setprop (fdt, off,"reg" , mem_reg_property, +sizeof (mem_reg_property)))); +_FDT ((fdt_setprop (fdt, off,"ibm,associativity" , associativity, +sizeof (associativity)))); + +/* RAM: Node 0 */ +if (node0_size > spapr->rma_size) { + mem_reg_property[0 ] =cpu_to_be64 (spapr->rma_size); + mem_reg_property[1 ] =cpu_to_be64 (node0_size - spapr->rma_size); + +sprintf (mem_name,"memory@" TARGET_FMT_lx, spapr->rma_size); + off =fdt_add_subnode (fdt,0 , mem_name); +_FDT (off); +_FDT ((fdt_setprop_string (fdt, off,"device_type" ,"memory" ))); +_FDT ((fdt_setprop (fdt, off,"reg" , mem_reg_property, +sizeof (mem_reg_property)))); +_FDT ((fdt_setprop (fdt, off,"ibm,associativity" , associativity, +sizeof (associativity)))); + } + +/* RAM: Node 1 and beyond */ + mem_start = node0_size; +for (i =1 ; i < nb_numa_nodes; i++) { + mem_reg_property[0 ] =cpu_to_be64 (mem_start); + mem_reg_property[1 ] =cpu_to_be64 (node_mem[i]); + associativity[3 ] = associativity[4 ] =cpu_to_be32 (i); +sprintf (mem_name,"memory@" TARGET_FMT_lx, mem_start); + off =fdt_add_subnode (fdt,0 , mem_name); +_FDT (off); +_FDT ((fdt_setprop_string (fdt, off,"device_type" ,"memory" ))); +_FDT ((fdt_setprop (fdt, off,"reg" , mem_reg_property, +sizeof (mem_reg_property)))); +_FDT ((fdt_setprop (fdt, off,"ibm,associativity" , associativity, +sizeof (associativity)))); + mem_start += node_mem[i]; + } + +return 0 ; +} + static void spapr_finalize_fdt(sPAPREnvironment *spapr, target_phys_addr_t fdt_addr, target_phys_addr_t rtas_addr,
@@ -480,6 +493,12 @@ static void spapr_finalize_fdt(sPAPREnvironment *spapr,/* open out the base tree into a temp buffer for the final tweaks */ _FDT ((fdt_open_into (spapr->fdt_skel, fdt,FDT_MAX_SIZE ))); + ret =spapr_populate_memory (spapr, fdt); +if (ret <0 ) { +fprintf (stderr,"couldn't setup memory nodes in fdt\n" ); +exit (1 ); + } + ret =spapr_populate_vdevice (spapr->vio_bus, fdt);if (ret <0 ) {fprintf (stderr,"couldn't setup vio devices in fdt\n" );
@@ -502,11 +521,9 @@ static void spapr_finalize_fdt(sPAPREnvironment *spapr, }/* Advertise NUMA via ibm,associativity */ -if (nb_numa_nodes >1 ) { - ret =spapr_set_associativity (fdt, spapr); -if (ret <0 ) { -fprintf (stderr,"Couldn't set up NUMA device tree properties\n" ); - } + ret =spapr_fixup_cpu_dt (fdt, spapr); +if (ret <0 ) { +fprintf (stderr,"Couldn't finalize CPU device tree properties\n" ); }if (!spapr_has_graphics) {
@@ -536,30 +553,74 @@ static void emulate_spapr_hypercall(CPUPPCState *env) env->gpr[3 ] =spapr_hypercall (env, env->gpr[3 ], &env->gpr[4 ]); } +static void spapr_reset_htab (sPAPREnvironment *spapr) +{ +long shift; + +/* allocate hash page table. For now we always make this 16mb, +* later we should probably make it scale to the size of guest +* RAM */ + + shift =kvmppc_reset_htab (spapr->htab_shift); + +if (shift >0 ) { +/* Kernel handles htab, we don't need to allocate one */ + spapr->htab_shift = shift; + }else { +if (!spapr->htab) { +/* Allocate an htab if we don't yet have one */ + spapr->htab =qemu_memalign (HTAB_SIZE (spapr),HTAB_SIZE (spapr)); + } + +/* And clear it */ +memset (spapr->htab,0 ,HTAB_SIZE (spapr)); + } + +/* Update the RMA size if necessary */ +if (spapr->vrma_adjust) { + spapr->rma_size =kvmppc_rma_size (ram_size, spapr->htab_shift); + } +} +static void spapr_reset (void *opaque) {sPAPREnvironment *spapr = (sPAPREnvironment *)opaque; -/* flush out the hash table */ -memset (spapr->htab,0 , spapr->htab_size); +/* Reset the hash table & recalc the RMA */ +spapr_reset_htab (spapr);/* Load the fdt */ spapr_finalize_fdt (spapr, spapr->fdt_addr, spapr->rtas_addr, spapr->rtas_size); - -/* Set up the entry state */ - first_cpu->gpr[3 ] = spapr->fdt_addr; - first_cpu->gpr[5 ] =0 ; - first_cpu->halted =0 ; - first_cpu->nip = spapr->entry_point; - }static void spapr_cpu_reset (void *opaque) {PowerPCCPU *cpu = opaque; +CPUPPCState *env = &cpu->env;cpu_reset (CPU (cpu)); + + env->external_htab = spapr->htab; + env->htab_base =-1 ; + env->htab_mask =HTAB_SIZE (spapr) -1 ; + + env->spr[SPR_SDR1 ] = (unsigned long )spapr->htab | + (spapr->htab_shift -18 ); + +if (kvm_enabled ()) { +kvmppc_update_sdr1 (env); + } + +/* Set up the entry state */ +if (env == first_cpu) { + env->gpr[3 ] = spapr->fdt_addr; + env->gpr[5 ] =0 ; + env->halted =0 ; + env->nip = spapr->entry_point; + } + +tb_flush (env); }static bool spapr_vga_init (sPAPREnvironment *spapr)
@@ -606,11 +667,10 @@ static void ppc_spapr_init(ram_addr_t ram_size,int i;MemoryRegion *sysmem =get_system_memory ();MemoryRegion *ram =g_new (MemoryRegion,1 ); -target_phys_addr_t rma_alloc_size, rma_size; +target_phys_addr_t rma_alloc_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; spapr =g_malloc0 (sizeof (*spapr));
@@ -625,20 +685,41 @@ static void ppc_spapr_init(ram_addr_t ram_size,hw_error ("qemu: Unable to create RMA\n" );exit (1 ); } +if (rma_alloc_size && (rma_alloc_size < ram_size)) { - rma_size = rma_alloc_size; + spapr->rma_size = rma_alloc_size; }else { - rma_size = ram_size; + spapr->rma_size = ram_size; + +/* With KVM, we don't actually know whether KVM supports an +* unbounded RMA (PR KVM) or is limited by the hash table size +* (HV KVM using VRMA), so we always assume the latter +* +* In that case, we also limit the initial allocations for RTAS +* etc... to 256M since we have no way to know what the VRMA size +* is going to be as it depends on the size of the hash table +* isn't determined yet. +*/ +if (kvm_enabled ()) { + spapr->vrma_adjust =1 ; + spapr->rma_size =MIN (spapr->rma_size,0x10000000 ); + } }/* 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 */ - rtas_limit =MIN (rma_size,0x80000000 ); + rtas_limit =MIN (spapr->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 ; +/* For now, always aim for a 16MB hash table */ +/* FIXME: we should change this default based on RAM size */ + spapr->htab_shift =24 ; + +qemu_register_reset (spapr_reset, spapr); +/* init CPUs */ if (cpu_model ==NULL ) { cpu_model =kvm_enabled () ?"host" :"POWER7" ;
@@ -671,20 +752,8 @@ static void ppc_spapr_init(ram_addr_t ram_size,memory_region_add_subregion (sysmem, nonrma_base, ram); } -/* allocate hash page table. For now we always make this 16mb, -* later we should probably make it scale to the size of guest -* RAM */ - spapr->htab_size =1ULL << (pteg_shift +7 ); - spapr->htab =qemu_memalign (spapr->htab_size, spapr->htab_size); -for (env = first_cpu; env !=NULL ; env = env->next_cpu) { - env->external_htab = spapr->htab; - env->htab_base =-1 ; - env->htab_mask = spapr->htab_size -1 ; -/* Tell KVM that we're in PAPR mode */ - env->spr[SPR_SDR1 ] = (unsigned long )spapr->htab | - ((pteg_shift +7 ) -18 ); env->spr[SPR_HIOR ] =0 ;if (kvm_enabled ()) {
@@ -763,7 +832,7 @@ static void ppc_spapr_init(ram_addr_t ram_size, } } -if (rma_size < (MIN_RMA_SLOF <<20 )) { +if (spapr->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 );
@@ -820,14 +889,11 @@ static void ppc_spapr_init(ram_addr_t ram_size, }/* Prepare the device tree */ - spapr->fdt_skel =spapr_create_fdt_skel (cpu_model, rma_size, + spapr->fdt_skel =spapr_create_fdt_skel (cpu_model, initrd_base, initrd_size, kernel_size, - boot_device, kernel_cmdline, - pteg_shift +7 ); + boot_device, kernel_cmdline);assert (spapr->fdt_skel !=NULL ); - -qemu_register_reset (spapr_reset, spapr); }static QEMUMachine spapr_machine = {
hw/spapr.h +3 -1
@@ -15,7 +15,9 @@ typedef struct sPAPREnvironment {target_phys_addr_t ram_limit;void *htab; -long htab_size; +long htab_shift; +target_phys_addr_t rma_size; +int vrma_adjust;target_phys_addr_t fdt_addr, rtas_addr;long rtas_size;void *fdt_skel;
target-ppc/kvm.c +40 -11
82 lines not on this page · raw message
target-ppc/kvm_ppc.h +20 -0
@@ -27,6 +27,9 @@ int kvmppc_smt_threads(void);off_t kvmppc_alloc_rma (const char *name,MemoryRegion *sysmem);void *kvmppc_create_spapr_tce (uint32_t liobn,uint32_t window_size,int *pfd);int kvmppc_remove_spapr_tce (void *table,int pfd,uint32_t window_size); +int kvmppc_reset_htab (int shift_hint); +uint64_t kvmppc_rma_size (uint64_t current_size,unsigned int hash_shift); +int kvmppc_update_sdr1 (CPUPPCState *env);#endif /* !CONFIG_USER_ONLY */ const ppc_def_t *kvmppc_host_cpu_def (void );int kvmppc_fixup_cpu (CPUPPCState *env);
@@ -94,6 +97,23 @@ static inline int kvmppc_remove_spapr_tce(void *table, int pfd, {return -1 ; } + +static inline int kvmppc_reset_htab (int shift_hint) +{ +return -1 ; +} + +static inline uint64_t kvmppc_rma_size (uint64_t current_size, +unsigned int hash_shift) +{ +return ram_size; +} + +static inline int kvmppc_update_sdr1 (CPUPPCState *env) +{ +return 0 ; +} +#endif /* !CONFIG_USER_ONLY */ static inline const ppc_def_t *kvmppc_host_cpu_def (void )
Signature · 1 line
1.7.10.4