Assorted ppc/pseries cleanups
cover Assorted ppc/pseries cleanups
Andreas,
Here's another batch of pseries patches. 1-3 are cleanups with little to no functionality change. 4 implements automatic address allocation for VIO devices, which makes instantiating them with -device rather easier.
This is about the third small series of patches I have pending for ppc inclusion. Would you prefer me to keep sending them this way, or should I be sending consolidated series with all my pending patches, even if they've been sent before?
PATCH 1/4 target-ppc: Add hooks for handling tcg and kvm limitations
On target-ppc, our table of CPU types and features encodes the features as found on the hardware, regardless of whether these features are actually usable under TCG or KVM. We already have cases where the information from the cpu table must be fixed up to account for limitations in the emulation method we're using. e.g. TCG does not support the DFP and VSX instructions and KVM needs different numbering of the CPUs in order to tell it the correct thread to core mappings.
This patch cleans up these hacks to handle emulation limitations by consolidating them into a pair of functions specifically for the purpose.
--- target-ppc/helper.c | 9 ------- target-ppc/kvm.c | 14 +++++++++++ target-ppc/kvm_ppc.h | 5 ++++ target-ppc/translate_init.c | 51 +++++++++++++++++++++++++++++------------- 4 files changed, 54 insertions(+), 25 deletions(-)
target-ppc/helper.c +0 -9
@@ -3198,15 +3198,6 @@ CPUPPCState *cpu_ppc_init (const char *cpu_model)if (tcg_enabled ()) {ppc_translate_init (); } -/* Adjust cpu index for SMT */ -#if !defined(CONFIG_USER_ONLY ) -if (kvm_enabled ()) { -int smt =kvmppc_smt_threads (); - - env->cpu_index = (env->cpu_index / smp_threads)*smt - + (env->cpu_index % smp_threads); - } -#endif /* !CONFIG_USER_ONLY */ env->cpu_model_str = cpu_model;cpu_ppc_register_internal (env, def);
target-ppc/kvm.c +14 -0
@@ -27,6 +27,7 @@#include "kvm.h" #include "kvm_ppc.h" #include "cpu.h" +#include "cpus.h" #include "device_tree.h" #include "hw/sysbus.h" #include "hw/spapr.h"
@@ -938,6 +939,19 @@ const ppc_def_t *kvmppc_host_cpu_def(void)return spec; } +int kvm_fixup_ppc_env (CPUPPCState *env,const ppc_def_t *def) +{ +int smt; + +/* Adjust cpu index for SMT */ + smt =kvmppc_smt_threads (); + env->cpu_index = (env->cpu_index / smp_threads)*smt + + (env->cpu_index % smp_threads); + +return 0 ; +} + +bool kvm_arch_stop_on_emulation_error (CPUPPCState *env) {return true;
target-ppc/kvm_ppc.h +5 -0
@@ -29,6 +29,7 @@ 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);#endif /* !CONFIG_USER_ONLY */ const ppc_def_t *kvmppc_host_cpu_def (void ); +int kvm_fixup_ppc_env (CPUPPCState *env,const ppc_def_t *def);#else
@@ -95,6 +96,10 @@ static inline const ppc_def_t *kvmppc_host_cpu_def(void) return NULL; } +static inline int kvm_fixup_ppc_env (CPUPPCState *env,const ppc_def_t *def) +{ +return -1 ; +}#endif #ifndef CONFIG_KVM
target-ppc/translate_init.c +35 -16
66 lines not on this page · raw message
Signature · 1 line
1.7.9.1
PATCH 2/4 pseries: Remove unused fields from VIOsPAPRBus structure
In reply to David GibsonThe VIOsPAPRBus structure, used on the pseries machine contains some old fields which are no longer used anywhere. This patch removes them.
--- hw/spapr_vio.h | 2 -- 1 files changed, 0 insertions(+), 2 deletions(-)
hw/spapr_vio.h +0 -2
@@ -89,8 +89,6 @@ struct VIOsPAPRDevice {struct VIOsPAPRBus {BusState bus; -const char *dt_name, *dt_type, *dt_compatible; -target_ulong signal_mask;int (*init)(VIOsPAPRDevice *dev);int (*devnode)(VIOsPAPRDevice *dev,void *fdt,int node_off); };
Signature · 1 line
1.7.9.1
Re: [Qemu-trivial] [PATCH 2/4] pseries: Remove unused fields from VIOsPAPRBus structure
Quoted 9 lines · David Gibson
The VIOsPAPRBus structure, used on the pseries machine contains some old fields which are no longer used anywhere. This patch removes them.
Signed-off-by David Gibson <[email protected]>--- hw/spapr_vio.h | 2 -- 1 files changed, 0 insertions(+), 2 deletions(-)
Leaving for Andreas to apply the whole series to the ppc tree.
Stefan
Andreas Färber
AppliedRe: [Qemu-trivial] [Qemu-ppc] [PATCH 2/4] pseries: Remove unused fields from VIOsPAPRBus structure
In reply to David GibsonAm 04.04.2012 07:02, schrieb David Gibson:
Quoted 7 lines
The VIOsPAPRBus structure, used on the pseries machine contains some old fields which are no longer used anywhere. This patch removes them.
Signed-off-by David Gibson <[email protected]>---
Thanks, applied to ppc-next:
http://repo.or.cz/w/qemu/agraf.git/shortlog/refs/heads/ppc-next
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 3/4 pseries: Consolidate hack for RTAS display-character usage
In reply to David GibsonCurrently the pseries machine contains not one but two somewhat ugly hacks to allow printing of early debug messages before the guest has properly read the device tree.
First, we special case H_PUT_TERM_CHAR so that a vtermno of 0 (usually
invalid) will look for a suitable vty and use that. This supports Linux's
early debug code which will use H_PUT_TERM_CHAR with vtermno==0 before
reading the device tree. Second, we support the RTAS display-character call. This takes no vtermno so we assume the address of the default first VTY.
This patch makes things more consistent by folding the second hack into the first. Now, display-character uses the existing vty_lookup() function to do the same search for a suitable VTY.
--- hw/spapr_rtas.c | 3 +-- hw/spapr_vio.h | 1 + hw/spapr_vty.c | 4 +--- 3 files changed, 3 insertions(+), 5 deletions(-)
hw/spapr_rtas.c +1 -2
@@ -44,8 +44,7 @@ static void rtas_display_character(sPAPREnvironment *spapr, uint32_t nret, target_ulong rets) { uint8_t c = rtas_ld(args, 0); -VIOsPAPRDevice *sdev =spapr_vio_find_by_reg (spapr->vio_bus, -SPAPR_VTY_BASE_ADDRESS ); +VIOsPAPRDevice *sdev =vty_lookup (spapr,0 );if (!sdev) {rtas_st (rets,0 ,-1 );
hw/spapr_vio.h +1 -0
@@ -117,6 +117,7 @@ uint64_t ldq_tce(VIOsPAPRDevice *dev, uint64_t taddr);int spapr_vio_send_crq (VIOsPAPRDevice *dev,uint8_t *crq); +VIOsPAPRDevice *vty_lookup (sPAPREnvironment *spapr,target_ulong reg);void vty_putchars (VIOsPAPRDevice *sdev,uint8_t *buf,int len);void spapr_vty_create (VIOsPAPRBus *bus,uint32_t reg,CharDriverState *chardev);void spapr_vlan_create (VIOsPAPRBus *bus,uint32_t reg,NICInfo *nd);
hw/spapr_vty.c +1 -3
@@ -70,8 +70,6 @@ static int spapr_vty_init(VIOsPAPRDevice *sdev) }/* Forward declaration */ -static VIOsPAPRDevice *vty_lookup (sPAPREnvironment *spapr,target_ulong reg); -static target_ulong h_put_term_char (CPUPPCState *env,sPAPREnvironment *spapr,target_ulong opcode,target_ulong *args) {
@@ -195,7 +193,7 @@ VIOsPAPRDevice *spapr_vty_get_default(VIOsPAPRBus *bus)return selected; } -static VIOsPAPRDevice *vty_lookup (sPAPREnvironment *spapr,target_ulong reg) +VIOsPAPRDevice *vty_lookup (sPAPREnvironment *spapr,target_ulong reg) {VIOsPAPRDevice *sdev;
Signature · 1 line
1.7.9.1
PATCH 4/4 pseries: Implement automatic PAPR VIO address allocation
In reply to David GibsonPAPR virtual IO (VIO) devices require a unique, but otherwise arbitrary, "address" used as a token to the hypercalls which manipulate them.
Currently the pseries machine code does an ok job of allocating these addresses when the legacy -net nic / -serial and so forth options are used but will fail to allocate them properly when using -device.
Specifically, you can use -device if all addresses are explicitly assigned. Without explicit assignment, only one VIO device of each type (network, console, SCSI) will be assigned properly, any further ones will attempt to take the same address leading to a fatal error.
This patch fixes the situation by adding a proper address allocator to the VIO "bus" code. This is used both by -device and the legacy options and default devices. Addresses can still be explicitly assigned with -device options if desired.
This patch changes the (guest visible) numbering of VIO devices, but since their addresses are discovered using the device tree and already differ from the numbering found on existing PowerVM systems, this does not break compatibility.
--- hw/spapr.c | 7 ++--- hw/spapr_llan.c | 5 +-- hw/spapr_vio.c | 74 ++++++++++++++++++++++++++++++++---------------------- hw/spapr_vio.h | 13 ++++----- hw/spapr_vscsi.c | 5 +-- hw/spapr_vty.c | 5 +-- 6 files changed, 59 insertions(+), 50 deletions(-)
hw/spapr.c +3 -4
@@ -631,8 +631,7 @@ static void ppc_spapr_init(ram_addr_t ram_size,for (i =0 ; i <MAX_SERIAL_PORTS ; i++) {if (serial_hds[i]) { -spapr_vty_create (spapr->vio_bus,SPAPR_VTY_BASE_ADDRESS + i, - serial_hds[i]); +spapr_vty_create (spapr->vio_bus, serial_hds[i]); } }
@@ -650,14 +649,14 @@ static void ppc_spapr_init(ram_addr_t ram_size, }if (strcmp (nd->model,"ibmveth" ) ==0 ) { -spapr_vlan_create (spapr->vio_bus,0x1000 + i, nd); +spapr_vlan_create (spapr->vio_bus, nd); }else {pci_nic_init_nofail (&nd_table[i], nd->model,NULL ); } }for (i =0 ; i <=drive_get_max_bus (IF_SCSI ); i++) { -spapr_vscsi_create (spapr->vio_bus,0x2000 + i); +spapr_vscsi_create (spapr->vio_bus); }if (rma_size < (MIN_RMA_SLOF <<20 )) {
hw/spapr_llan.c +2 -3
@@ -195,12 +195,11 @@ static int spapr_vlan_init(VIOsPAPRDevice *sdev)return 0 ; } -void spapr_vlan_create (VIOsPAPRBus *bus,uint32_t reg,NICInfo *nd) +void spapr_vlan_create (VIOsPAPRBus *bus,NICInfo *nd) {DeviceState *dev; dev =qdev_create (&bus->bus,"spapr-vlan" ); -qdev_prop_set_uint32 (dev,"reg" , reg);qdev_set_nic_properties (dev, nd);
@@ -473,7 +472,7 @@ static target_ulong h_multicast_ctrl(CPUPPCState *env, sPAPREnvironment *spapr, }static Property spapr_vlan_properties[] = { -DEFINE_SPAPR_PROPERTIES (VIOsPAPRVLANDevice, sdev,0x1000 ,0x10000000 ), +DEFINE_SPAPR_PROPERTIES (VIOsPAPRVLANDevice, sdev,0x10000000 ),DEFINE_NIC_PROPERTIES (VIOsPAPRVLANDevice, nicconf),DEFINE_PROP_END_OF_LIST (), };
hw/spapr_vio.c +44 -30
102 lines not on this page · raw message
hw/spapr_vio.h +6 -7
@@ -32,8 +32,6 @@ enum VIOsPAPR_TCEAccess { SPAPR_TCE_RW = 3, }; -#define SPAPR_VTY_BASE_ADDRESS 0x30000000 -#define TYPE_VIO_SPAPR_DEVICE "vio-spapr-device"#define VIO_SPAPR_DEVICE (obj) \ OBJECT_CHECK(VIOsPAPRDevice, (obj), TYPE_VIO_SPAPR_DEVICE)
@@ -82,13 +80,14 @@ struct VIOsPAPRDevice {VIOsPAPR_CRQ crq; }; -#define DEFINE_SPAPR_PROPERTIES (type, field, default_reg, default_dma_window) \ - DEFINE_PROP_UINT32("reg", type, field.reg, default_reg), \ +#define DEFINE_SPAPR_PROPERTIES (type, field, default_dma_window) \ + DEFINE_PROP_UINT32("reg", type, field.reg, -1), \ DEFINE_PROP_UINT32("dma-window", type, field.rtce_window_size, \ default_dma_window)struct VIOsPAPRBus {BusState bus; +uint32_t next_reg;int (*init)(VIOsPAPRDevice *dev);int (*devnode)(VIOsPAPRDevice *dev,void *fdt,int node_off); };
@@ -119,9 +118,9 @@ int spapr_vio_send_crq(VIOsPAPRDevice *dev, uint8_t *crq);VIOsPAPRDevice *vty_lookup (sPAPREnvironment *spapr,target_ulong reg);void vty_putchars (VIOsPAPRDevice *sdev,uint8_t *buf,int len); -void spapr_vty_create (VIOsPAPRBus *bus,uint32_t reg,CharDriverState *chardev); -void spapr_vlan_create (VIOsPAPRBus *bus,uint32_t reg,NICInfo *nd); -void spapr_vscsi_create (VIOsPAPRBus *bus,uint32_t reg); +void spapr_vty_create (VIOsPAPRBus *bus,CharDriverState *chardev); +void spapr_vlan_create (VIOsPAPRBus *bus,NICInfo *nd); +void spapr_vscsi_create (VIOsPAPRBus *bus);VIOsPAPRDevice *spapr_vty_get_default (VIOsPAPRBus *bus);
hw/spapr_vscsi.c +2 -3
@@ -920,12 +920,11 @@ static int spapr_vscsi_init(VIOsPAPRDevice *dev)return 0 ; } -void spapr_vscsi_create (VIOsPAPRBus *bus,uint32_t reg) +void spapr_vscsi_create (VIOsPAPRBus *bus) {DeviceState *dev; dev =qdev_create (&bus->bus,"spapr-vscsi" ); -qdev_prop_set_uint32 (dev,"reg" , reg);qdev_init_nofail (dev); }
@@ -948,7 +947,7 @@ static int spapr_vscsi_devnode(VIOsPAPRDevice *dev, void *fdt, int node_off) }static Property spapr_vscsi_properties[] = { -DEFINE_SPAPR_PROPERTIES (VSCSIState, vdev,0x2000 ,0x10000000 ), +DEFINE_SPAPR_PROPERTIES (VSCSIState, vdev,0x10000000 ),DEFINE_PROP_END_OF_LIST (), };
hw/spapr_vty.c +2 -3
@@ -123,18 +123,17 @@ static target_ulong h_get_term_char(CPUPPCState *env, sPAPREnvironment *spapr,return H_SUCCESS ; } -void spapr_vty_create (VIOsPAPRBus *bus,uint32_t reg,CharDriverState *chardev) +void spapr_vty_create (VIOsPAPRBus *bus,CharDriverState *chardev) {DeviceState *dev; dev =qdev_create (&bus->bus,"spapr-vty" ); -qdev_prop_set_uint32 (dev,"reg" , reg);qdev_prop_set_chr (dev,"chardev" , chardev);qdev_init_nofail (dev); }static Property spapr_vty_properties[] = { -DEFINE_SPAPR_PROPERTIES (VIOsPAPRVTYDevice, sdev,SPAPR_VTY_BASE_ADDRESS ,0 ), +DEFINE_SPAPR_PROPERTIES (VIOsPAPRVTYDevice, sdev,0 ),DEFINE_PROP_CHR ("chardev" , VIOsPAPRVTYDevice, chardev),DEFINE_PROP_END_OF_LIST (), };
Signature · 1 line
1.7.9.1