ppc-for-3.0 queue 20180618
The following changes since commit 2ef2f16781af9dee6ba6517755e9073ba5799fa2:
Merge remote-tracking branch 'remotes/dgilbert/tags/pull-migration-20180615a' into staging (2018-06-15 18:13:35 +0100)
are available in the Git repository at:
git://github.com/dgibson/qemu.git tags/ppc-for-3.0-20180618
for you to fetch changes up to 844afc54ae229515a37f63519855661ad2d01d19:
spapr: fix xics_system_init() error path (2018-06-18 09:43:19 +1000)
----------------------------------------------------------------
ppc patch queue 2018-06-18
Next batch of ppc and spapr related patches for the 3.0 release.
* Improved handling of Spectre/Meltdown mitigations for POWER8
* Numerous Mac machine type cleanups and improvements
* Cleanup to cpu realize/unrealize path for spapr
* Create a place for machine-specific per-cpu information, and start moving some things to it
* Assorted bugfixes
----------------------------------------------------------------
BALATON Zoltan (1):
sm501: Do not clear read only bits when writing registers
Cédric Le Goater (2):
xics_kvm: fix a build break
ppc/pnv: introduce a pnv_chip_core_realize() routine
David Gibson (6):
spapr: Clean up cpu realize/unrealize paths
pnv: Fix some error handling cpu realize()
pnv_core: Allocate cpu thread objects individually
pnv: Clean up cpu realize path
pnv: Add cpu unrealize path
target/ppc, spapr: Move VPA information to machine_data
Greg Kurz (7):
target/ppc: drop empty #if/#endif block
spapr: fix leak in h_client_architecture_support()
spapr_cpu_core: convert last snprintf() to g_strdup_printf()
spapr_cpu_core: fix potential leak in spapr_cpu_core_realize()
spapr_cpu_core: add missing rollback on realization path
spapr_cpu_core: introduce spapr_create_vcpu()
spapr: fix xics_system_init() error path
Mark Cave-Ayland (10):
ppc: introduce Core99MachinesState for the mac99 machine
mac_newworld: add via machine option to control mac99 VIA/ADB configuration
mac_newworld: add gpios to macio devices with PMU enabled
mac_newworld: wire up programmer switch to NMI handler
adb: fix read reg 3 byte ordering
adb: add property to disable direct reg 3 writes
mac_newworld: add PMU device
mos6522: only clear the shift register interrupt upon write
mos6522: remove additional interrupt flag filter from mos6522_update_irq()
mos6522: expose mos6522_update_irq() through MOS6522DeviceClass
Suraj Jitindar Singh (2):
target/ppc: Don't require private l1d cache on POWER8 for cap_ppc_safe_cache ppc/spapr_caps: Don't disable cap_cfpc on POWER8 by default
default-configs/ppc-softmmu.mak | 2 + hw/display/sm501.c | 15 +- hw/input/adb-kbd.c | 29 +- hw/input/adb-mouse.c | 41 +- hw/input/adb.c | 7 + hw/intc/xics_kvm.c | 10 +- hw/misc/macio/Makefile.objs | 2 + hw/misc/macio/gpio.c | 231 +++++++++++ hw/misc/macio/macio.c | 89 +++- hw/misc/macio/pmu.c | 871 ++++++++++++++++++++++++++++++++++++++++ hw/misc/macio/trace-events | 28 ++ hw/misc/mos6522.c | 5 +- hw/ppc/mac.h | 20 + hw/ppc/mac_newworld.c | 84 +++- hw/ppc/pnv.c | 36 +- hw/ppc/pnv_core.c | 93 ++--- hw/ppc/spapr.c | 22 +- hw/ppc/spapr_caps.c | 6 +- hw/ppc/spapr_cpu_core.c | 163 ++++---- hw/ppc/spapr_hcall.c | 78 ++-- include/hw/input/adb.h | 1 + include/hw/misc/macio/gpio.h | 47 +++ include/hw/misc/macio/macio.h | 7 + include/hw/misc/macio/pmu.h | 237 +++++++++++ include/hw/misc/mos6522.h | 1 + include/hw/ppc/pnv_core.h | 2 +- include/hw/ppc/ppc.h | 1 + include/hw/ppc/spapr_cpu_core.h | 11 + target/ppc/cpu.h | 9 +- target/ppc/kvm.c | 58 ++- target/ppc/translate_init.inc.c | 8 - 31 files changed, 1930 insertions(+), 284 deletions(-) create mode 100644 hw/misc/macio/gpio.c create mode 100644 hw/misc/macio/pmu.c create mode 100644 include/hw/misc/macio/gpio.h create mode 100644 include/hw/misc/macio/pmu.h
[Qemu-devel] [PULL 02/28] ppc/spapr_caps: Don't disable cap_cfpc on POWER8 by default
From: Suraj Jitindar Singh <[email protected]>
In default_caps_with_cpu() we set spapr_cap_cfpc to broken for POWER8 processors and before.
Since we no longer require private l1d cache on POWER8 for this cap to be set to workaround change this to default to broken for POWER7 processors and before.
--- hw/ppc/spapr_caps.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
hw/ppc/spapr_caps.c +1 -5
@@ -335,14 +335,10 @@ static sPAPRCapabilities default_caps_with_cpu(sPAPRMachineState *spapr, caps = smc->default_caps; -if (!ppc_check_compat (cpu,CPU_POWERPC_LOGICAL_3_00 , -0 , spapr->max_compat_pvr)) { - caps.caps[SPAPR_CAP_CFPC ] =SPAPR_CAP_BROKEN ; - } -if (!ppc_check_compat (cpu,CPU_POWERPC_LOGICAL_2_07 ,0 , spapr->max_compat_pvr)) { caps.caps[SPAPR_CAP_HTM ] =SPAPR_CAP_OFF ; + caps.caps[SPAPR_CAP_CFPC ] =SPAPR_CAP_BROKEN ; } if (!ppc_check_compat(cpu, CPU_POWERPC_LOGICAL_2_06_PLUS,
Signature · 1 line
2.17.1
[Qemu-devel] [PULL 03/28] target/ppc: drop empty #if/#endif block
In reply to David GibsonFrom: Greg Kurz <[email protected]>
Commit 9d6f106552fa moved the last line in this block to somewhere else, but it forgot to remove the now useless #if/#endif.
--- target/ppc/cpu.h | 2 -- 1 file changed, 2 deletions(-)
target/ppc/cpu.h +0 -2
@@ -1300,8 +1300,6 @@ void ppc_store_ptcr(CPUPPCState *env, target_ulong value);void ppc_store_msr (CPUPPCState *env,target_ulong value);void ppc_cpu_list (FILE *f,fprintf_function cpu_fprintf); -#if defined(TARGET_PPC64 ) -#endif /* Time-base and decrementer management */ #ifndef NO_CPU_IO_DEFS
Signature · 1 line
2.17.1
[Qemu-devel] [PULL 04/28] spapr: fix leak in h_client_architecture_support()
In reply to David GibsonFrom: Greg Kurz <[email protected]>
If the negotiated compat mode can't be set, but raw mode is supported, we decide to ignore the error. An so, we should free it to prevent a memory leak.
--- hw/ppc/spapr_hcall.c | 1 + 1 file changed, 1 insertion(+)
hw/ppc/spapr_hcall.c +1 -0
@@ -1547,6 +1547,7 @@ static target_ulong h_client_architecture_support(PowerPCCPU *cpu,error_report_err (local_err);return H_HARDWARE ; } +error_free (local_err); local_err =NULL ; } }
Signature · 1 line
2.17.1
[Qemu-devel] [PULL 01/28] target/ppc: Don't require private l1d cache on POWER8 for cap_ppc_safe_cache
In reply to David GibsonFrom: Suraj Jitindar Singh <[email protected]>
For cap_ppc_safe_cache to be set to workaround, we require both a l1d cache flush instruction and private l1d cache.
On POWER8 don't require private l1d cache. This means a guest on a POWER8 machine can make use of the cache flush workarounds.
--- target/ppc/kvm.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)
target/ppc/kvm.c +18 -1
@@ -2412,11 +2412,28 @@ bool kvmppc_has_cap_mmu_hash_v3(void)return cap_mmu_hash_v3; } +static bool kvmppc_power8_host (void ) +{ +bool ret = false; +#ifdef TARGET_PPC64 + { +uint32_t base_pvr =CPU_POWERPC_POWER_SERVER_MASK &mfpvr (); + ret = (base_pvr ==CPU_POWERPC_POWER8E_BASE ) || + (base_pvr ==CPU_POWERPC_POWER8NVL_BASE ) || + (base_pvr ==CPU_POWERPC_POWER8_BASE ); + } +#endif /* TARGET_PPC64 */ +return ret; +} +static int parse_cap_ppc_safe_cache (struct kvm_ppc_cpu_char c) { +bool l1d_thread_priv_req = !kvmppc_power8_host (); +if (~c.behaviour & c.behaviour_mask &H_CPU_BEHAV_L1D_FLUSH_PR ) {return 2 ; - }else if ((c.character & c.character_mask &H_CPU_CHAR_L1D_THREAD_PRIV ) && + }else if ((!l1d_thread_priv_req || + c.character & c.character_mask &H_CPU_CHAR_L1D_THREAD_PRIV ) && (c.character & c.character_mask & (H_CPU_CHAR_L1D_FLUSH_ORI30 |H_CPU_CHAR_L1D_FLUSH_TRIG2 ))) {return 1 ;
Signature · 1 line
2.17.1
[Qemu-devel] [PULL 09/28] adb: fix read reg 3 byte ordering
In reply to David GibsonFrom: Mark Cave-Ayland <[email protected]>
According to the Apple ADB documentation, register 3 is a 2-byte register with the device address in the first byte, and the handler ID in the second byte.
This is currently the opposite away to which QEMU returns them so switch the order around.
--- hw/input/adb-kbd.c | 4 ++-- hw/input/adb-mouse.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
hw/input/adb-kbd.c +2 -2
@@ -290,8 +290,8 @@ static int adb_kbd_request(ADBDevice *d, uint8_t *obuf, olen =2 ;break ;case 3 : - obuf[0 ] = d->handler; - obuf[1 ] = d->devaddr; + obuf[0 ] = d->devaddr; + obuf[1 ] = d->handler; olen =2 ;break ; }
hw/input/adb-mouse.c +2 -2
@@ -172,8 +172,8 @@ static int adb_mouse_request(ADBDevice *d, uint8_t *obuf,case 1 :break ;case 3 : - obuf[0 ] = d->handler; - obuf[1 ] = d->devaddr; + obuf[0 ] = d->devaddr; + obuf[1 ] = d->handler; olen =2 ;break ; }
Signature · 1 line
2.17.1
[Qemu-devel] [PULL 13/28] mos6522: only clear the shift register interrupt upon write
In reply to David GibsonFrom: Mark Cave-Ayland <[email protected]>
According to the 6522 datasheet the shift register (SR) interrupt flag is cleared upon write with no mention of any other interrupt flags.
--- hw/misc/mos6522.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/misc/mos6522.c +1 -1
@@ -241,7 +241,7 @@ uint64_t mos6522_read(void *opaque, hwaddr addr, unsigned size)break ;case VIA_REG_SR : val = s->sr; - s->ifr &= ~(SR_INT |CB1_INT |CB2_INT ); + s->ifr &= ~SR_INT ;mos6522_update_irq (s);break ;case VIA_REG_ACR :
Signature · 1 line
2.17.1
[Qemu-devel] [PULL 05/28] ppc: introduce Core99MachinesState for the mac99 machine
In reply to David GibsonFrom: Mark Cave-Ayland <[email protected]>
This is in preparation for adding configuration controlled via machine options.
--- hw/ppc/mac.h | 11 +++++++++++ hw/ppc/mac_newworld.c | 7 +++++++ 2 files changed, 18 insertions(+)
hw/ppc/mac.h +11 -0
@@ -27,6 +27,7 @@#define PPC_MAC_H #include "exec/memory.h" +#include "hw/boards.h" #include "hw/sysbus.h" #include "hw/ide/internal.h" #include "hw/input/adb.h"
@@ -65,6 +66,16 @@#define NEWWORLD_IDE1_IRQ 0xe#define NEWWORLD_IDE1_DMA_IRQ 0x3 +/* Core99 machine */ +#define TYPE_CORE99_MACHINE MACHINE_TYPE_NAME("mac99") +#define CORE99_MACHINE (obj) OBJECT_CHECK(Core99MachineState, (obj), \ + TYPE_CORE99_MACHINE) + +typedef struct Core99MachineState { +/*< private >*/ +MachineState parent; +}Core99MachineState ; +/* MacIO */ #define TYPE_MACIO_IDE "macio-ide"#define MACIO_IDE (obj) OBJECT_CHECK(MACIOIDEState, (obj), TYPE_MACIO_IDE)
hw/ppc/mac_newworld.c +7 -0
@@ -515,10 +515,17 @@ static void core99_machine_class_init(ObjectClass *oc, void *data)#endif } +static void core99_instance_init (Object *obj) +{ +return ; +} +static const TypeInfo core99_machine_info = { .name =MACHINE_TYPE_NAME ("mac99" ), .parent =TYPE_MACHINE , .class_init = core99_machine_class_init, + .instance_init = core99_instance_init, + .instance_size =sizeof (Core99MachineState) };static void mac_machine_register_types (void )
Signature · 1 line
2.17.1
[Qemu-devel] [PULL 08/28] mac_newworld: wire up programmer switch to NMI handler
In reply to David GibsonFrom: Mark Cave-Ayland <[email protected]>
The programmer switch is wired up via an external GPIO pin and can be used to aid debugging Mac guests.
--- hw/misc/macio/gpio.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
hw/misc/macio/gpio.c +13 -0
@@ -28,6 +28,7 @@#include "hw/ppc/mac.h" #include "hw/misc/macio/macio.h" #include "hw/misc/macio/gpio.h" +#include "hw/nmi.h" #include "qemu/log.h" #include "trace.h"
@@ -193,13 +194,21 @@ static void macio_gpio_reset(DeviceState *dev)macio_set_gpio (s,1 , true); } +static void macio_gpio_nmi (NMIState *n,int cpu_index,Error **errp) +{ +macio_set_gpio (MACIO_GPIO (n),9 , true); +macio_set_gpio (MACIO_GPIO (n),9 , false); +} +static void macio_gpio_class_init (ObjectClass *oc,void *data) {DeviceClass *dc =DEVICE_CLASS (oc); +NMIClass *nc =NMI_CLASS (oc); dc->realize = macio_gpio_realize; dc->reset = macio_gpio_reset; dc->vmsd = &vmstate_macio_gpio; + nc->nmi_monitor_handler = macio_gpio_nmi; }static const TypeInfo macio_gpio_init_info = {
@@ -208,6 +217,10 @@ static const TypeInfo macio_gpio_init_info = { .instance_size = sizeof(MacIOGPIOState), .instance_init = macio_gpio_init, .class_init = macio_gpio_class_init, + .interfaces = (InterfaceInfo []) { + {TYPE_NMI }, + { } + }, };static void macio_gpio_register_types (void )
Signature · 1 line
2.17.1
[Qemu-devel] [PULL 10/28] adb: add property to disable direct reg 3 writes
In reply to David GibsonFrom: Mark Cave-Ayland <[email protected]>
MacOS 9 has a bug in its PMU driver whereby after configuring the ADB bus devices it sends another write to reg 3 on both devices resetting them both back to the same address.
Add a new disable_direct_reg3_writes property to ADBDevice to disable these direct writes which can enabled just for the upcoming pmu-adb support.
--- hw/input/adb-kbd.c | 25 ++++++++++++++----------- hw/input/adb-mouse.c | 37 ++++++++++++++++++++----------------- hw/input/adb.c | 7 +++++++ include/hw/input/adb.h | 1 + 4 files changed, 42 insertions(+), 28 deletions(-)
hw/input/adb-kbd.c +14 -11
@@ -261,18 +261,21 @@ static int adb_kbd_request(ADBDevice *d, uint8_t *obuf,trace_adb_kbd_request_change_addr (d->devaddr);break ;default : - d->devaddr = buf[1 ] &0xf ; -/* we support handlers: -* 1: Apple Standard Keyboard -* 2: Apple Extended Keyboard (LShift = RShift) -* 3: Apple Extended Keyboard (LShift != RShift) -*/ -if (buf[2 ] ==1 || buf[2 ] ==2 || buf[2 ] ==3 ) { - d->handler = buf[2 ]; +if (!d->disable_direct_reg3_writes) { + d->devaddr = buf[1 ] &0xf ; + +/* we support handlers: +* 1: Apple Standard Keyboard +* 2: Apple Extended Keyboard (LShift = RShift) +* 3: Apple Extended Keyboard (LShift != RShift) +*/ +if (buf[2 ] ==1 || buf[2 ] ==2 || buf[2 ] ==3 ) { + d->handler = buf[2 ]; + } + +trace_adb_kbd_request_change_addr_and_handler (d->devaddr, + d->handler); } - -trace_adb_kbd_request_change_addr_and_handler (d->devaddr, - d->handler);break ; } }
hw/input/adb-mouse.c +20 -17
@@ -142,24 +142,27 @@ static int adb_mouse_request(ADBDevice *d, uint8_t *obuf,trace_adb_mouse_request_change_addr (d->devaddr);break ;default : - d->devaddr = buf[1 ] &0xf ; -/* we support handlers: -* 0x01: Classic Apple Mouse Protocol / 100 cpi operations -* 0x02: Classic Apple Mouse Protocol / 200 cpi operations -* we don't support handlers (at least): -* 0x03: Mouse systems A3 trackball -* 0x04: Extended Apple Mouse Protocol -* 0x2f: Microspeed mouse -* 0x42: Macally -* 0x5f: Microspeed mouse -* 0x66: Microspeed mouse -*/ -if (buf[2 ] ==1 || buf[2 ] ==2 ) { - d->handler = buf[2 ]; +if (!d->disable_direct_reg3_writes) { + d->devaddr = buf[1 ] &0xf ; + +/* we support handlers: +* 0x01: Classic Apple Mouse Protocol / 100 cpi operations +* 0x02: Classic Apple Mouse Protocol / 200 cpi operations +* we don't support handlers (at least): +* 0x03: Mouse systems A3 trackball +* 0x04: Extended Apple Mouse Protocol +* 0x2f: Microspeed mouse +* 0x42: Macally +* 0x5f: Microspeed mouse +* 0x66: Microspeed mouse +*/ +if (buf[2 ] ==1 || buf[2 ] ==2 ) { + d->handler = buf[2 ]; + } + +trace_adb_mouse_request_change_addr_and_handler ( + d->devaddr, d->handler); } - -trace_adb_mouse_request_change_addr_and_handler (d->devaddr, - d->handler);break ; } }
hw/input/adb.c +7 -0
@@ -113,11 +113,18 @@ static void adb_device_realizefn(DeviceState *dev, Error **errp) bus->devices[bus->nb_devices++] = d; } +static Property adb_device_properties[] = { +DEFINE_PROP_BOOL ("disable-direct-reg3-writes" , ADBDevice, + disable_direct_reg3_writes, false), +DEFINE_PROP_END_OF_LIST (), +}; +static void adb_device_class_init (ObjectClass *oc,void *data) {DeviceClass *dc =DEVICE_CLASS (oc); dc->realize = adb_device_realizefn; + dc->props = adb_device_properties; dc->bus_type =TYPE_ADB_BUS ; }
include/hw/input/adb.h +1 -0
@@ -49,6 +49,7 @@ struct ADBDevice {int devaddr;int handler; +bool disable_direct_reg3_writes; };#define ADB_DEVICE_CLASS (cls) \
Signature · 1 line
2.17.1
[Qemu-devel] [PULL 06/28] mac_newworld: add via machine option to control mac99 VIA/ADB configuration
In reply to David GibsonFrom: Mark Cave-Ayland <[email protected]>
This option allows the VIA configuration to be controlled between 3 different possible setups: cuda, pmu-adb and pmu with USB rather than ADB keyboard/mouse.
For the moment we don't do anything with the configuration except to pass it to the macio device (the via-cuda parent) and also to the firmware via the fw_cfg interface so that it can present the correct device tree.
The default is cuda which is the current default and so will have no change in behaviour.
--- hw/misc/macio/macio.c | 7 ++++ hw/ppc/mac.h | 6 +++ hw/ppc/mac_newworld.c | 69 +++++++++++++++++++++++++++++++---- include/hw/misc/macio/macio.h | 2 + include/hw/ppc/ppc.h | 1 + 5 files changed, 78 insertions(+), 7 deletions(-)
hw/misc/macio/macio.c +7 -0
@@ -399,6 +399,12 @@ static const VMStateDescription vmstate_macio_newworld = { } }; +static Property macio_newworld_properties[] = { +DEFINE_PROP_BOOL ("has-pmu" , NewWorldMacIOState, has_pmu, false), +DEFINE_PROP_BOOL ("has-adb" , NewWorldMacIOState, has_adb, false), +DEFINE_PROP_END_OF_LIST () +}; +static void macio_newworld_class_init (ObjectClass *oc,void *data) {PCIDeviceClass *pdc =PCI_DEVICE_CLASS (oc);
@@ -407,6 +413,7 @@ static void macio_newworld_class_init(ObjectClass *oc, void *data) pdc->realize = macio_newworld_realize; pdc->device_id =PCI_DEVICE_ID_APPLE_UNI_N_KEYL ; dc->vmsd = &vmstate_macio_newworld; + dc->props = macio_newworld_properties; }static Property macio_properties[] = {
hw/ppc/mac.h +6 -0
@@ -71,9 +71,15 @@#define CORE99_MACHINE (obj) OBJECT_CHECK(Core99MachineState, (obj), \ TYPE_CORE99_MACHINE) +#define CORE99_VIA_CONFIG_CUDA 0x0 +#define CORE99_VIA_CONFIG_PMU 0x1 +#define CORE99_VIA_CONFIG_PMU_ADB 0x2 +typedef struct Core99MachineState {/*< private >*/ MachineState parent; + +uint8_t via_config; }Core99MachineState ;/* MacIO */
hw/ppc/mac_newworld.c +62 -7
119 lines not on this page · raw message
include/hw/misc/macio/macio.h +2 -0
@@ -70,6 +70,8 @@ typedef struct NewWorldMacIOState {MacIOState parent_obj;/*< public >*/ +bool has_pmu; +bool has_adb;OpenPICState *pic;MACIOIDEState ide[2 ]; } NewWorldMacIOState;
include/hw/ppc/ppc.h +1 -0
@@ -101,6 +101,7 @@ enum {#define FW_CFG_PPC_NVRAM_ADDR (FW_CFG_ARCH_LOCAL + 0x08)#define FW_CFG_PPC_BUSFREQ (FW_CFG_ARCH_LOCAL + 0x09)#define FW_CFG_PPC_NVRAM_FLAT (FW_CFG_ARCH_LOCAL + 0x0a) +#define FW_CFG_PPC_VIACONFIG (FW_CFG_ARCH_LOCAL + 0x0b)#define PPC_SERIAL_MM_BAUDBASE 399193
Signature · 1 line
2.17.1
[Qemu-devel] [PULL 07/28] mac_newworld: add gpios to macio devices with PMU enabled
In reply to David GibsonFrom: Mark Cave-Ayland <[email protected]>
PMU-enabled New World Macs expose their GPIOs via a separate memory region within the macio device.
--- default-configs/ppc-softmmu.mak | 1 + hw/misc/macio/Makefile.objs | 1 + hw/misc/macio/gpio.c | 218 ++++++++++++++++++++++++++++++++ hw/misc/macio/macio.c | 13 ++ hw/misc/macio/trace-events | 7 + hw/ppc/mac.h | 2 + include/hw/misc/macio/gpio.h | 47 +++++++ include/hw/misc/macio/macio.h | 3 + 8 files changed, 292 insertions(+) create mode 100644 hw/misc/macio/gpio.c create mode 100644 include/hw/misc/macio/gpio.h
default-configs/ppc-softmmu.mak +1 -0
@@ -31,6 +31,7 @@ CONFIG_I2C=y CONFIG_MAC=y CONFIG_ESCC=y CONFIG_MACIO=y +CONFIG_MACIO_GPIO=y CONFIG_SUNGEM=y CONFIG_MOS6522=y CONFIG_CUDA=y
hw/misc/macio/Makefile.objs +1 -0
@@ -1,3 +1,4 @@ common-obj-y += macio.o common-obj-$(CONFIG_CUDA) += cuda.o common-obj-$(CONFIG_MAC_DBDMA) += mac_dbdma.o +common-obj-$(CONFIG_MACIO_GPIO) += gpio.o
hw/misc/macio/gpio.c new file +218 -0
218 lines not on this page · raw message
hw/misc/macio/macio.c +13 -0
@@ -332,6 +332,16 @@ static void macio_newworld_realize(PCIDevice *d, Error **errp)memory_region_init_io (timer_memory,OBJECT (s), &timer_ops,NULL ,"timer" ,0x1000 );memory_region_add_subregion (&s->bar,0x15000 , timer_memory); + +if (ns->has_pmu) { +/* GPIOs */ + sysbus_dev =SYS_BUS_DEVICE (&ns->gpio); +object_property_set_link (OBJECT (&ns->gpio),OBJECT (pic_dev),"pic" , + &error_abort); +memory_region_add_subregion (&s->bar,0x50 , +sysbus_mmio_get_region (sysbus_dev,0 )); +object_property_set_bool (OBJECT (&ns->gpio), true,"realized" , &err); + } }static void macio_newworld_init (Object *obj)
@@ -345,6 +355,9 @@ static void macio_newworld_init(Object *obj) qdev_prop_allow_set_link_before_realize, 0, NULL); +object_initialize (&ns->gpio,sizeof (ns->gpio),TYPE_MACIO_GPIO ); +qdev_set_parent_bus (DEVICE (&ns->gpio),sysbus_get_default ()); +for (i =0 ; i <2 ; i++) {macio_init_ide (s, &ns->ide[i],sizeof (ns->ide[i]), i); }
hw/misc/macio/trace-events +7 -0
@@ -13,3 +13,10 @@ cuda_packet_send_data(int i, const uint8_t data) "[%d] 0x%02x" # hw/misc/macio/macio.c macio_timer_write(uint64_t addr, unsigned len, uint64_t val) "write addr 0x%"PRIx64 " len %d val 0x%"PRIx64 macio_timer_read(uint64_t addr, unsigned len, uint32_t val) "read addr 0x%"PRIx64 " len %d val 0x%"PRIx32 + +# hw/misc/macio/gpio.c +macio_set_gpio(int gpio, bool state) "setting GPIO %d to %d" +macio_gpio_irq_assert(int gpio) "asserting GPIO %d" +macio_gpio_irq_deassert(int gpio) "deasserting GPIO %d" +macio_gpio_write(uint64_t addr, uint64_t val) "addr: 0x%"PRIx64" value: 0x%"PRIx64 +macio_gpio_read(uint64_t addr, uint64_t val) "addr: 0x%"PRIx64" value: 0x%"PRIx64
hw/ppc/mac.h +2 -0
@@ -65,6 +65,8 @@#define NEWWORLD_IDE0_DMA_IRQ 0x2#define NEWWORLD_IDE1_IRQ 0xe#define NEWWORLD_IDE1_DMA_IRQ 0x3 +#define NEWWORLD_EXTING_GPIO1 0x2f +#define NEWWORLD_EXTING_GPIO9 0x37/* Core99 machine */ #define TYPE_CORE99_MACHINE MACHINE_TYPE_NAME("mac99")
include/hw/misc/macio/gpio.h new file +47 -0
47 lines not on this page · raw message
include/hw/misc/macio/macio.h +3 -0
@@ -26,8 +26,10 @@#ifndef MACIO_H #define MACIO_H +#include "hw/char/escc.h" #include "hw/intc/heathrow_pic.h" #include "hw/misc/macio/cuda.h" +#include "hw/misc/macio/gpio.h" #include "hw/ppc/mac_dbdma.h" #include "hw/ppc/openpic.h"
@@ -74,6 +76,7 @@ typedef struct NewWorldMacIOState {bool has_adb;OpenPICState *pic;MACIOIDEState ide[2 ]; + MacIOGPIOState gpio; } NewWorldMacIOState;#endif /* MACIO_H */
Signature · 1 line
2.17.1
[Qemu-devel] [PULL 12/28] xics_kvm: fix a build break
In reply to David GibsonFrom: Cédric Le Goater <[email protected]>
On CentOS 7.5, gcc-4.8.5-28.el7_5.1.ppc64le fails to build QEMU due to :
hw/intc/xics_kvm.c: In function ‘ics_set_kvm_state’:
hw/intc/xics_kvm.c:281:13: error: ‘ret’ may be used uninitialized in this
function [-Werror=maybe-uninitialized]
return ret;Fix the breakage and also remove the extra error reporting as kvm_device_access() already provides a substantial error message.
--- hw/intc/xics_kvm.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
hw/intc/xics_kvm.c +4 -6
@@ -186,8 +186,7 @@ static void ics_get_kvm_state(ICSState *ics)kvm_device_access (kernel_xics_fd,KVM_DEV_XICS_GRP_SOURCES , i + ics->offset, &state, false, &local_err);if (local_err) { -error_report ("Unable to retrieve KVM interrupt controller state" -" for IRQ %d: %s" , i + ics->offset,strerror (errno)); +error_report_err (local_err);exit (1 ); }
@@ -273,11 +272,10 @@ static int ics_set_kvm_state(ICSState *ics, int version_id) state |=KVM_XICS_QUEUED ; } -kvm_device_access (kernel_xics_fd,KVM_DEV_XICS_GRP_SOURCES , - i + ics->offset, &state, true, &local_err); + ret =kvm_device_access (kernel_xics_fd,KVM_DEV_XICS_GRP_SOURCES , + i + ics->offset, &state, true, &local_err);if (local_err) { -error_report ("Unable to restore KVM interrupt controller state" -" for IRQs %d: %s" , i + ics->offset,strerror (errno)); +error_report_err (local_err);return ret; } }
Signature · 1 line
2.17.1
[Qemu-devel] [PULL 14/28] mos6522: remove additional interrupt flag filter from mos6522_update_irq()
In reply to David GibsonFrom: Mark Cave-Ayland <[email protected]>
The datasheet indicates that the interrupt is generated by ANDing the interrupt flags register (IFR) with the interrupt enable register (IER) but currently there is an extra filter for the SR and timer interrupts.
Remove this extra filter to allow interrupts to be generated by external inputs on bits 1 and 2 of ports A and B.
--- hw/misc/mos6522.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/misc/mos6522.c +1 -1
@@ -40,7 +40,7 @@ static void mos6522_timer_update(MOS6522State *s, MOS6522Timer *ti,static void mos6522_update_irq (MOS6522State *s) { -if (s->ifr & s->ier & (SR_INT |T1_INT |T2_INT )) { +if (s->ifr & s->ier) {qemu_irq_raise (s->irq); }else {qemu_irq_lower (s->irq);
Signature · 1 line
2.17.1
[Qemu-devel] [PULL 15/28] mos6522: expose mos6522_update_irq() through MOS6522DeviceClass
In reply to David GibsonFrom: Mark Cave-Ayland <[email protected]>
In the case where we have an interrupt generated externally from inputs to bits 1 and 2 of port A and/or port B, it is necessary to expose mos6522_update_irq() so it can be called by the interrupt source.
--- hw/misc/mos6522.c | 1 + include/hw/misc/mos6522.h | 1 + 2 files changed, 2 insertions(+)
hw/misc/mos6522.c +1 -0
@@ -463,6 +463,7 @@ static void mos6522_class_init(ObjectClass *oc, void *data) mdc->set_sr_int = mos6522_set_sr_int; mdc->portB_write = mos6522_portB_write; mdc->portA_write = mos6522_portA_write; + mdc->update_irq = mos6522_update_irq; mdc->get_timer1_counter_value = mos6522_get_counter_value; mdc->get_timer2_counter_value = mos6522_get_counter_value; mdc->get_timer1_load_time = mos6522_get_load_time;
include/hw/misc/mos6522.h +1 -0
@@ -134,6 +134,7 @@ typedef struct MOS6522DeviceClass {void (*set_sr_int)(MOS6522State *dev);void (*portB_write)(MOS6522State *dev);void (*portA_write)(MOS6522State *dev); +void (*update_irq)(MOS6522State *dev);/* These are used to influence the CUDA MacOS timebase calibration */ uint64_t (*get_timer1_counter_value)(MOS6522State *dev,MOS6522Timer *ti);uint64_t (*get_timer2_counter_value)(MOS6522State *dev,MOS6522Timer *ti);
Signature · 1 line
2.17.1
[Qemu-devel] [PULL 16/28] sm501: Do not clear read only bits when writing registers
In reply to David GibsonFrom: BALATON Zoltan <[email protected]>
When writing registers that have read only bits we have to avoid changing these bits as they may have non zero values. Make sure we use the correct masks to mask out read only and reserved bits when changing registers.
Also remove extra spaces from dram_control and arbitration_control assignments.
--- hw/display/sm501.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
hw/display/sm501.c +9 -6
@@ -836,27 +836,30 @@ static void sm501_system_config_write(void *opaque, hwaddr addr,switch (addr) {case SM501_SYSTEM_CONTROL : - s->system_control = value &0xE300B8F7 ; + s->system_control &=0x10DB0000 ; + s->system_control |= value &0xEF00B8F7 ;break ;case SM501_MISC_CONTROL : - s->misc_control = value &0xFF7FFF20 ; + s->misc_control &=0xEF ; + s->misc_control |= value &0xFF7FFF10 ;break ;case SM501_GPIO31_0_CONTROL : s->gpio_31_0_control = value;break ;case SM501_GPIO63_32_CONTROL : - s->gpio_63_32_control = value; + s->gpio_63_32_control = value &0xFF80FFFF ;break ;case SM501_DRAM_CONTROL : s->local_mem_size_index = (value >>13 ) &0x7 ;/* TODO : check validity of size change */ - s->dram_control |= value &0x7FFFFFC3 ; + s->dram_control &=0x80000000 ; + s->dram_control |= value &0x7FFFFFC3 ;break ;case SM501_ARBTRTN_CONTROL : - s->arbitration_control = value &0x37777777 ; + s->arbitration_control = value &0x37777777 ;break ;case SM501_IRQ_MASK : - s->irq_mask = value; + s->irq_mask = value &0xFFDF3F5F ;break ;case SM501_MISC_TIMING : s->misc_timing = value &0xF31F1FFF ;
Signature · 1 line
2.17.1
[Qemu-devel] [PULL 18/28] pnv: Fix some error handling cpu realize()
In reply to David GibsonIn pnv_core_realize() we call two functions with an Error * parameter in succession, which will go badly if they both cause errors. In fact, a failure in either of them indicates a qemu internal error, so we can just use &error_abort in both cases.
--- hw/ppc/pnv_core.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
hw/ppc/pnv_core.c +2 -5
@@ -172,12 +172,9 @@ static void pnv_core_realize(DeviceState *dev, Error **errp)object_initialize (obj, size, typename);snprintf (name,sizeof (name),"thread[%d]" , i); -object_property_add_child (OBJECT (pc), name, obj, &local_err); +object_property_add_child (OBJECT (pc), name, obj, &error_abort);object_property_add_alias (obj,"core-pir" ,OBJECT (pc), -"pir" , &local_err); -if (local_err) { - goto err; - } +"pir" , &error_abort);object_unref (obj); }
Signature · 1 line
2.17.1
[Qemu-devel] [PULL 21/28] pnv: Add cpu unrealize path
In reply to David GibsonCurrently we don't have any unrealize path for pnv cpu cores. We get away with this because we don't yet support cpu hotplug for pnv.
However, we're going to want it eventually, and in the meantime, it makes it non-obvious why there are a bunch of allocations on the realize() path that don't have matching frees.
So, implement the missing unrealize path.
--- hw/ppc/pnv_core.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
hw/ppc/pnv_core.c +21 -0
@@ -186,6 +186,26 @@ err:error_propagate (errp, local_err); } +static void pnv_unrealize_vcpu (PowerPCCPU *cpu) +{ +qemu_unregister_reset (pnv_cpu_reset, cpu); +object_unparent (cpu->intc); +cpu_remove_sync (CPU (cpu)); +object_unparent (OBJECT (cpu)); +} + +static void pnv_core_unrealize (DeviceState *dev,Error **errp) +{ +PnvCore *pc =PNV_CORE (dev); +CPUCore *cc =CPU_CORE (dev); +int i; + +for (i =0 ; i < cc->nr_threads; i++) { +pnv_unrealize_vcpu (pc->threads[i]); + } +g_free (pc->threads); +} +static Property pnv_core_properties[] = {DEFINE_PROP_UINT32 ("pir" , PnvCore, pir,0 ),DEFINE_PROP_END_OF_LIST (),
@@ -196,6 +216,7 @@ static void pnv_core_class_init(ObjectClass *oc, void *data)DeviceClass *dc =DEVICE_CLASS (oc); dc->realize = pnv_core_realize; + dc->unrealize = pnv_core_unrealize; dc->props = pnv_core_properties; }
Signature · 1 line
2.17.1
[Qemu-devel] [PULL 22/28] spapr_cpu_core: convert last snprintf() to g_strdup_printf()
In reply to David GibsonFrom: Greg Kurz <[email protected]>
Because this is the preferred practice in QEMU.
--- hw/ppc/spapr_cpu_core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
hw/ppc/spapr_cpu_core.c +3 -2
@@ -176,7 +176,7 @@ static void spapr_cpu_core_realize(DeviceState *dev, Error **errp) sc->threads = g_new(PowerPCCPU *, cc->nr_threads);for (i =0 ; i < cc->nr_threads; i++) { -char id[32 ]; +char *id;CPUState *cs;PowerPCCPU *cpu;
@@ -194,8 +194,9 @@ static void spapr_cpu_core_realize(DeviceState *dev, Error **errp)/* Set NUMA node for the threads belonged to core */ cpu->node_id = sc->node_id; -snprintf (id,sizeof (id),"thread[%d]" , i); + id =g_strdup_printf ("thread[%d]" , i);object_property_add_child (OBJECT (sc), id, obj, &local_err); +g_free (id);if (local_err) { goto err; }
Signature · 1 line
2.17.1
[Qemu-devel] [PULL 23/28] spapr_cpu_core: fix potential leak in spapr_cpu_core_realize()
In reply to David GibsonFrom: Greg Kurz <[email protected]>
Commit 94ad93bd97684 (QEMU 2.12) switched to instantiate CPUs separately but it missed to adapt the error path accordingly. If something fails in the CPU creation loop, then the CPU object that was just created is leaked.
The error paths in this function are a bit obfuscated, and adding yet another label to free this CPU object makes it worse. We should move the block of the loop to a separate function, with a proper rollback path, but this is a bigger cleanup.
For now, let's just fix the bug by adding the missing calls to object_unref(). This will allow easier backport to older QEMU versions.
--- hw/ppc/spapr_cpu_core.c | 2 ++ 1 file changed, 2 insertions(+)
hw/ppc/spapr_cpu_core.c +2 -0
@@ -187,6 +187,7 @@ static void spapr_cpu_core_realize(DeviceState *dev, Error **errp) cs->cpu_index = cc->core_id + i;spapr_set_vcpu_id (cpu, cs->cpu_index, &local_err);if (local_err) { +object_unref (obj); goto err; }
@@ -198,6 +199,7 @@ static void spapr_cpu_core_realize(DeviceState *dev, Error **errp)object_property_add_child (OBJECT (sc), id, obj, &local_err);g_free (id);if (local_err) { +object_unref (obj); goto err; }object_unref (obj);
Signature · 1 line
2.17.1
[Qemu-devel] [PULL 24/28] spapr_cpu_core: add missing rollback on realization path
In reply to David GibsonFrom: Greg Kurz <[email protected]>
The spapr_realize_vcpu() function doesn't rollback in case of error. This isn't a problem with coldplugged CPUs because the machine won't start and QEMU will exit. Hotplug is a different story though: the CPU thread is started under object_property_set_bool() and it assumes it can access the CPU object.
If icp_create() fails, we return an error without unregistering the reset handler for this CPU, and we let the underlying QEMU thread for this CPU alive. Since spapr_cpu_core_realize() doesn't care to unrealize already realized CPUs either, but happily frees all of them anyway, the CPU thread crashes instantly:
(qemu) device_add host-spapr-cpu-core,core-id=1,id=gku
GKU: failing icp_create (cpu 0x11497fd0)
^^^^^^^^^^
Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 0x7fffee3feaa0 (LWP 24725)] 0x00000000104c8374 in object_dynamic_cast_assert (obj=0x11497fd0,
^^^^^^^^^^^^^^
pointer to the CPU object
623 trace_object_dynamic_cast_assert(obj ? obj->class->type->name
(gdb) p obj->class->type
$1 = (Type) 0x0
(gdb) p * obj
$2 = {class = 0x10ea9c10, free = 0x11244620,
^^^^^^^^^^
should be g_free
(gdb) p g_free
$3 = {<text variable, no debug info>} 0x7ffff282bef0 <g_free>
obj is a dangling pointer to the CPU that was just destroyed in spapr_cpu_core_realize().
This patch adds proper rollback to both spapr_realize_vcpu() and spapr_cpu_core_realize().
--- hw/ppc/spapr_cpu_core.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
hw/ppc/spapr_cpu_core.c +9 -2
@@ -145,11 +145,14 @@ static void spapr_realize_vcpu(PowerPCCPU *cpu, sPAPRMachineState *spapr, cpu->intc =icp_create (OBJECT (cpu), spapr->icp_type,XICS_FABRIC (spapr), &local_err);if (local_err) { - goto error; + goto error_unregister; }return ; +error_unregister: +qemu_unregister_reset (spapr_cpu_reset, cpu); +cpu_remove_sync (CPU (cpu)); error:error_propagate (errp, local_err); }
@@ -208,11 +211,15 @@ static void spapr_cpu_core_realize(DeviceState *dev, Error **errp)for (j =0 ; j < cc->nr_threads; j++) {spapr_realize_vcpu (sc->threads[j], spapr, &local_err);if (local_err) { - goto err; + goto err_unrealize; } }return ; +err_unrealize: +while (--j >=0 ) { +spapr_unrealize_vcpu (sc->threads[j]); + } err:while (--i >=0 ) { obj =OBJECT (sc->threads[i]);
Signature · 1 line
2.17.1
[Qemu-devel] [PULL 17/28] spapr: Clean up cpu realize/unrealize paths
In reply to David Gibsonspapr_cpu_init() and spapr_cpu_destroy() are only called from the spapr cpu core realize/unrealize paths, and really can only be called from there.
Those are all short functions, so fold the pairs together for simplicity. While we're there rename some functions and change some parameter types for brevity and clarity.
--- hw/ppc/spapr_cpu_core.c | 69 +++++++++++++++-------------------------- 1 file changed, 25 insertions(+), 44 deletions(-)
hw/ppc/spapr_cpu_core.c +25 -44
@@ -83,26 +83,6 @@ void spapr_cpu_set_entry_state(PowerPCCPU *cpu, target_ulong nip, target_ulong rppc_store_lpcr (cpu, env->spr[SPR_LPCR ] | pcc->lpcr_pm); } -static void spapr_cpu_destroy (PowerPCCPU *cpu) -{ -qemu_unregister_reset (spapr_cpu_reset, cpu); -} - -static void spapr_cpu_init (sPAPRMachineState *spapr,PowerPCCPU *cpu, -Error **errp) -{ -CPUPPCState *env = &cpu->env; - -/* Set time-base frequency to 512 MHz */ -cpu_ppc_tb_init (env,SPAPR_TIMEBASE_FREQ ); - -cpu_ppc_set_vhyp (cpu,PPC_VIRTUAL_HYPERVISOR (spapr)); -kvmppc_set_papr (cpu); - -qemu_register_reset (spapr_cpu_reset, cpu); -spapr_cpu_reset (cpu); -} -/* * Return the sPAPR CPU core type for @model which essentially is the CPU * model specified with -cpu cmdline option.
@@ -122,44 +102,47 @@ const char *spapr_get_cpu_core_type(const char *cpu_type)return object_class_get_name (oc); } -static void spapr_cpu_core_unrealizefn (DeviceState *dev,Error **errp) +static void spapr_unrealize_vcpu (PowerPCCPU *cpu) +{ +qemu_unregister_reset (spapr_cpu_reset, cpu); +object_unparent (cpu->intc); +cpu_remove_sync (CPU (cpu)); +object_unparent (OBJECT (cpu)); +} + +static void spapr_cpu_core_unrealize (DeviceState *dev,Error **errp) {sPAPRCPUCore *sc =SPAPR_CPU_CORE (OBJECT (dev));CPUCore *cc =CPU_CORE (dev);int i;for (i =0 ; i < cc->nr_threads; i++) { -Object *obj =OBJECT (sc->threads[i]); -DeviceState *dev =DEVICE (obj); -CPUState *cs =CPU (dev); -PowerPCCPU *cpu =POWERPC_CPU (cs); - -spapr_cpu_destroy (cpu); -object_unparent (cpu->intc); -cpu_remove_sync (cs); -object_unparent (obj); +spapr_unrealize_vcpu (sc->threads[i]); }g_free (sc->threads); } -static void spapr_cpu_core_realize_child (Object *child, -sPAPRMachineState *spapr,Error **errp) +static void spapr_realize_vcpu (PowerPCCPU *cpu,sPAPRMachineState *spapr, +Error **errp) { +CPUPPCState *env = &cpu->env;Error *local_err =NULL ; -CPUState *cs =CPU (child); -PowerPCCPU *cpu =POWERPC_CPU (cs); -object_property_set_bool (child, true,"realized" , &local_err); +object_property_set_bool (OBJECT (cpu), true,"realized" , &local_err);if (local_err) { goto error; } -spapr_cpu_init (spapr, cpu, &local_err); -if (local_err) { - goto error; - } +/* Set time-base frequency to 512 MHz */ +cpu_ppc_tb_init (env,SPAPR_TIMEBASE_FREQ ); + +cpu_ppc_set_vhyp (cpu,PPC_VIRTUAL_HYPERVISOR (spapr)); +kvmppc_set_papr (cpu); - cpu->intc =icp_create (child, spapr->icp_type,XICS_FABRIC (spapr), +qemu_register_reset (spapr_cpu_reset, cpu); +spapr_cpu_reset (cpu); + + cpu->intc =icp_create (OBJECT (cpu), spapr->icp_type,XICS_FABRIC (spapr), &local_err);if (local_err) { goto error;
@@ -220,9 +203,7 @@ static void spapr_cpu_core_realize(DeviceState *dev, Error **errp) }for (j =0 ; j < cc->nr_threads; j++) { - obj =OBJECT (sc->threads[j]); - -spapr_cpu_core_realize_child (obj, spapr, &local_err); +spapr_realize_vcpu (sc->threads[j], spapr, &local_err);if (local_err) { goto err; }
@@ -249,7 +230,7 @@ static void spapr_cpu_core_class_init(ObjectClass *oc, void *data)sPAPRCPUCoreClass *scc =SPAPR_CPU_CORE_CLASS (oc); dc->realize = spapr_cpu_core_realize; - dc->unrealize = spapr_cpu_core_unrealizefn; + dc->unrealize = spapr_cpu_core_unrealize; dc->props = spapr_cpu_core_properties; scc->cpu_type = data; }
Signature · 1 line
2.17.1
[Qemu-devel] [PULL 19/28] pnv_core: Allocate cpu thread objects individually
In reply to David GibsonCurrently, we allocate space for all the cpu objects within a single core in one big block. This was copied from an older version of the spapr code and requires some ugly pointer manipulation to extract the individual objects.
This design was due to a misunderstanding of qemu lifetime conventions and has already been changed in spapr (in 94ad93bd "spapr_cpu_core: instantiate CPUs separately".
Make an equivalent change in pnv_core to get rid of the nasty pointer arithmetic.
--- hw/ppc/pnv.c | 4 ++-- hw/ppc/pnv_core.c | 11 +++++------ include/hw/ppc/pnv_core.h | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-)
hw/ppc/pnv.c +2 -2
@@ -121,9 +121,9 @@ static int get_cpus_node(void *fdt)*/ static void pnv_dt_core (PnvChip *chip,PnvCore *pc,void *fdt) { -CPUState *cs =CPU (DEVICE (pc->threads)); +PowerPCCPU *cpu = pc->threads[0 ]; +CPUState *cs =CPU (cpu);DeviceClass *dc =DEVICE_GET_CLASS (cs); -PowerPCCPU *cpu =POWERPC_CPU (cs);int smt_threads =CPU_CORE (pc)->nr_threads;CPUPPCState *env = &cpu->env;PowerPCCPUClass *pcc =POWERPC_CPU_GET_CLASS (cs);
hw/ppc/pnv_core.c +5 -6
@@ -151,7 +151,6 @@ static void pnv_core_realize(DeviceState *dev, Error **errp)PnvCore *pc =PNV_CORE (OBJECT (dev));CPUCore *cc =CPU_CORE (OBJECT (dev));const char *typename =pnv_core_cpu_typename (pc); -size_t size =object_type_get_instance_size (typename);Error *local_err =NULL ;void *obj;int i, j;
@@ -165,11 +164,11 @@ static void pnv_core_realize(DeviceState *dev, Error **errp)return ; } - pc->threads =g_malloc0 (size * cc->nr_threads); + pc->threads = g_new(PowerPCCPU *, cc->nr_threads);for (i =0 ; i < cc->nr_threads; i++) { - obj = pc->threads + i * size; + obj =object_new (typename); -object_initialize (obj, size, typename); + pc->threads[i] =POWERPC_CPU (obj);snprintf (name,sizeof (name),"thread[%d]" , i);object_property_add_child (OBJECT (pc), name, obj, &error_abort);
@@ -179,7 +178,7 @@ static void pnv_core_realize(DeviceState *dev, Error **errp) }for (j =0 ; j < cc->nr_threads; j++) { - obj = pc->threads + j * size; + obj =OBJECT (pc->threads[j]);pnv_core_realize_child (obj,XICS_FABRIC (xi), &local_err);if (local_err) {
@@ -194,7 +193,7 @@ static void pnv_core_realize(DeviceState *dev, Error **errp) err:while (--i >=0 ) { - obj = pc->threads + i * size; + obj =OBJECT (pc->threads[i]);object_unparent (obj); }g_free (pc->threads);
include/hw/ppc/pnv_core.h +1 -1
@@ -34,7 +34,7 @@ typedef struct PnvCore {CPUCore parent_obj;/*< public >*/ -void *threads; +PowerPCCPU **threads;uint32_t pir;MemoryRegion xscom_regs;
Signature · 1 line
2.17.1
[Qemu-devel] [PULL 20/28] pnv: Clean up cpu realize path
In reply to David Gibsonpnv_cpu_init() is only called from the the pnv cpu core realize path, and really only can be called from there. So fold it into its caller, which we also rename for brevity.
--- hw/ppc/pnv_core.c | 56 ++++++++++++++++++----------------------------- 1 file changed, 21 insertions(+), 35 deletions(-)
hw/ppc/pnv_core.c +21 -35
@@ -54,28 +54,6 @@ static void pnv_cpu_reset(void *opaque) env->msr |=MSR_HVB ;/* Hypervisor mode */ } -static void pnv_cpu_init (PowerPCCPU *cpu,Error **errp) -{ -CPUPPCState *env = &cpu->env; -int core_pir; -int thread_index =0 ;/* TODO: TCG supports only one thread */ -ppc_spr_t *pir = &env->spr_cb[SPR_PIR ]; - - core_pir =object_property_get_uint (OBJECT (cpu),"core-pir" , &error_abort); - -/* -* The PIR of a thread is the core PIR + the thread index. We will -* need to find a way to get the thread index when TCG supports -* more than 1. We could use the object name ? -*/ - pir->default_value = core_pir + thread_index; - -/* Set time-base frequency to 512 MHz */ -cpu_ppc_tb_init (env,PNV_TIMEBASE_FREQ ); - -qemu_register_reset (pnv_cpu_reset, cpu); -} -/* * These values are read by the PowerNV HW monitors under Linux */
@@ -121,29 +99,39 @@ static const MemoryRegionOps pnv_core_xscom_ops = { .endianness = DEVICE_BIG_ENDIAN, }; -static void pnv_core_realize_child (Object *child,XICSFabric *xi,Error **errp) +static void pnv_realize_vcpu (PowerPCCPU *cpu,XICSFabric *xi,Error **errp) { +CPUPPCState *env = &cpu->env; +int core_pir; +int thread_index =0 ;/* TODO: TCG supports only one thread */ +ppc_spr_t *pir = &env->spr_cb[SPR_PIR ];Error *local_err =NULL ; -CPUState *cs =CPU (child); -PowerPCCPU *cpu =POWERPC_CPU (cs); -object_property_set_bool (child, true,"realized" , &local_err); +object_property_set_bool (OBJECT (cpu), true,"realized" , &local_err);if (local_err) {error_propagate (errp, local_err);return ; } - cpu->intc =icp_create (child,TYPE_PNV_ICP , xi, &local_err); + cpu->intc =icp_create (OBJECT (cpu),TYPE_PNV_ICP , xi, &local_err);if (local_err) {error_propagate (errp, local_err);return ; } -pnv_cpu_init (cpu, &local_err); -if (local_err) { -error_propagate (errp, local_err); -return ; - } + core_pir =object_property_get_uint (OBJECT (cpu),"core-pir" , &error_abort); + +/* +* The PIR of a thread is the core PIR + the thread index. We will +* need to find a way to get the thread index when TCG supports +* more than 1. We could use the object name ? +*/ + pir->default_value = core_pir + thread_index; + +/* Set time-base frequency to 512 MHz */ +cpu_ppc_tb_init (env,PNV_TIMEBASE_FREQ ); + +qemu_register_reset (pnv_cpu_reset, cpu); }static void pnv_core_realize (DeviceState *dev,Error **errp)
@@ -178,9 +166,7 @@ static void pnv_core_realize(DeviceState *dev, Error **errp) }for (j =0 ; j < cc->nr_threads; j++) { - obj =OBJECT (pc->threads[j]); - -pnv_core_realize_child (obj,XICS_FABRIC (xi), &local_err); +pnv_realize_vcpu (pc->threads[j],XICS_FABRIC (xi), &local_err);if (local_err) { goto err; }
Signature · 1 line
2.17.1
[Qemu-devel] [PULL 26/28] ppc/pnv: introduce a pnv_chip_core_realize() routine
In reply to David GibsonFrom: Cédric Le Goater <[email protected]>
This extracts from the PvChip realize routine the part creating the cores. On Power9, we will need to create the cores after the Xive interrupt controller is created.
--- hw/ppc/pnv.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-)
hw/ppc/pnv.c +22 -10
@@ -849,9 +849,8 @@ static void pnv_chip_icp_realize(PnvChip *chip, Error **errp) } } -static void pnv_chip_realize (DeviceState *dev,Error **errp) +static void pnv_chip_core_realize (PnvChip *chip,Error **errp) { -PnvChip *chip =PNV_CHIP (dev);Error *error =NULL ;PnvChipClass *pcc =PNV_CHIP_GET_CLASS (chip);const char *typename =pnv_chip_core_typename (chip);
@@ -863,14 +862,6 @@ static void pnv_chip_realize(DeviceState *dev, Error **errp)return ; } -/* XSCOM bridge */ -pnv_xscom_realize (chip, &error); -if (error) { -error_propagate (errp, error); -return ; - } -sysbus_mmio_map (SYS_BUS_DEVICE (chip),0 ,PNV_XSCOM_BASE (chip)); -/* Cores */ pnv_chip_core_sanitize (chip, &error);if (error) {
@@ -918,6 +909,27 @@ static void pnv_chip_realize(DeviceState *dev, Error **errp) &PNV_CORE(pnv_core)->xscom_regs); i++; } +} + +static void pnv_chip_realize (DeviceState *dev,Error **errp) +{ +PnvChip *chip =PNV_CHIP (dev); +Error *error =NULL ; + +/* XSCOM bridge */ +pnv_xscom_realize (chip, &error); +if (error) { +error_propagate (errp, error); +return ; + } +sysbus_mmio_map (SYS_BUS_DEVICE (chip),0 ,PNV_XSCOM_BASE (chip)); + +/* Cores */ +pnv_chip_core_realize (chip, &error); +if (error) { +error_propagate (errp, error); +return ; + }/* Create LPC controller */ object_property_set_bool(OBJECT(&chip->lpc), true, "realized",
Signature · 1 line
2.17.1
[Qemu-devel] [PULL 25/28] spapr_cpu_core: introduce spapr_create_vcpu()
In reply to David GibsonFrom: Greg Kurz <[email protected]>
This moves some code out from spapr_cpu_core_realize() for clarity. No functional change.
--- hw/ppc/spapr_cpu_core.c | 73 +++++++++++++++++++++++++---------------- 1 file changed, 45 insertions(+), 28 deletions(-)
hw/ppc/spapr_cpu_core.c +45 -28
@@ -157,6 +157,49 @@ error:error_propagate (errp, local_err); } +static PowerPCCPU *spapr_create_vcpu (sPAPRCPUCore *sc,int i,Error **errp) +{ +sPAPRCPUCoreClass *scc =SPAPR_CPU_CORE_GET_CLASS (sc); +CPUCore *cc =CPU_CORE (sc); +Object *obj; +char *id; +CPUState *cs; +PowerPCCPU *cpu; +Error *local_err =NULL ; + + obj =object_new (scc->cpu_type); + + cs =CPU (obj); + cpu =POWERPC_CPU (obj); + cs->cpu_index = cc->core_id + i; +spapr_set_vcpu_id (cpu, cs->cpu_index, &local_err); +if (local_err) { + goto err; + } + + cpu->node_id = sc->node_id; + + id =g_strdup_printf ("thread[%d]" , i); +object_property_add_child (OBJECT (sc), id, obj, &local_err); +g_free (id); +if (local_err) { + goto err; + } + +object_unref (obj); +return cpu; + +err: +object_unref (obj); +error_propagate (errp, local_err); +return NULL ; +} + +static void spapr_delete_vcpu (PowerPCCPU *cpu) +{ +object_unparent (OBJECT (cpu)); +} +static void spapr_cpu_core_realize (DeviceState *dev,Error **errp) {/* We don't use SPAPR_MACHINE() in order to exit gracefully if the user
@@ -166,10 +209,8 @@ static void spapr_cpu_core_realize(DeviceState *dev, Error **errp) (sPAPRMachineState *)object_dynamic_cast (qdev_get_machine (),TYPE_SPAPR_MACHINE );sPAPRCPUCore *sc =SPAPR_CPU_CORE (OBJECT (dev)); -sPAPRCPUCoreClass *scc =SPAPR_CPU_CORE_GET_CLASS (OBJECT (dev));CPUCore *cc =CPU_CORE (OBJECT (dev));Error *local_err =NULL ; -Object *obj;int i, j;if (!spapr) {
@@ -179,33 +220,10 @@ static void spapr_cpu_core_realize(DeviceState *dev, Error **errp) sc->threads = g_new(PowerPCCPU *, cc->nr_threads);for (i =0 ; i < cc->nr_threads; i++) { -char *id; -CPUState *cs; -PowerPCCPU *cpu; - - obj =object_new (scc->cpu_type); - - cs =CPU (obj); - cpu = sc->threads[i] =POWERPC_CPU (obj); - cs->cpu_index = cc->core_id + i; -spapr_set_vcpu_id (cpu, cs->cpu_index, &local_err); -if (local_err) { -object_unref (obj); - goto err; - } - - -/* Set NUMA node for the threads belonged to core */ - cpu->node_id = sc->node_id; - - id =g_strdup_printf ("thread[%d]" , i); -object_property_add_child (OBJECT (sc), id, obj, &local_err); -g_free (id); + sc->threads[i] =spapr_create_vcpu (sc, i, &local_err);if (local_err) { -object_unref (obj); goto err; } -object_unref (obj); }for (j =0 ; j < cc->nr_threads; j++) {
@@ -222,8 +240,7 @@ err_unrealize: } err:while (--i >=0 ) { - obj =OBJECT (sc->threads[i]); -object_unparent (obj); +spapr_delete_vcpu (sc->threads[i]); }g_free (sc->threads);error_propagate (errp, local_err);
Signature · 1 line
2.17.1
[Qemu-devel] [PULL 28/28] spapr: fix xics_system_init() error path
In reply to David GibsonFrom: Greg Kurz <[email protected]>
Commit 3d85885a1b1f3 tried to fix error handling, but it actually went into the wrong direction by dropping the local Error *.
In the default KVM case, the rationale is to try the in-kernel XICS first, and if not possible, to fallback to userland XICS. Passing errp everywhere makes this fallback impossible if errp is &error_fatal (which happens to be the case). And anyway, if the caller would pass a regular &local_err, things would be worse: we could possibly pass an already set *errp to error_setg() and crash, or return an error even in case of success.
So we definitely need a local Error * and only propagate it when we're done with the fallback logic. This is what this patch does.
--- hw/ppc/spapr.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-)
hw/ppc/spapr.c +14 -8
@@ -186,27 +186,33 @@ static int xics_max_server_number(sPAPRMachineState *spapr)static void xics_system_init (MachineState *machine,int nr_irqs,Error **errp) {sPAPRMachineState *spapr =SPAPR_MACHINE (machine); +Error *local_err =NULL ;if (kvm_enabled ()) {if (machine_kernel_irqchip_allowed (machine) && - !xics_kvm_init (spapr, errp)) { + !xics_kvm_init (spapr, &local_err)) { spapr->icp_type =TYPE_KVM_ICP ; - spapr->ics =spapr_ics_create (spapr,TYPE_ICS_KVM , nr_irqs, errp); + spapr->ics =spapr_ics_create (spapr,TYPE_ICS_KVM , nr_irqs, + &local_err); }if (machine_kernel_irqchip_required (machine) && !spapr->ics) { -error_prepend (errp,"kernel_irqchip requested but unavailable: " ); -return ; +error_prepend (&local_err, +"kernel_irqchip requested but unavailable: " ); + goto error; } +error_free (local_err); + local_err =NULL ; }if (!spapr->ics) {xics_spapr_init (spapr); spapr->icp_type =TYPE_ICP ; - spapr->ics =spapr_ics_create (spapr,TYPE_ICS_SIMPLE , nr_irqs, errp); -if (!spapr->ics) { -return ; - } + spapr->ics =spapr_ics_create (spapr,TYPE_ICS_SIMPLE , nr_irqs, + &local_err); } + +error: +error_propagate (errp, local_err); } static int spapr_fixup_cpu_smt_dt(void *fdt, int offset, PowerPCCPU *cpu,
Signature · 1 line
2.17.1
[Qemu-devel] [PULL 27/28] target/ppc, spapr: Move VPA information to machine_data
In reply to David GibsonCPUPPCState currently contains a number of fields containing the state of the VPA. The VPA is a PAPR specific concept covering several guest/host shared memory areas used to communicate some information with the hypervisor.
As a PAPR concept this is really machine specific information, although it is per-cpu, so it doesn't really belong in the core CPU state structure.
There's also other information that's per-cpu, but platform/machine specific. So create a (void *)machine_data in PowerPCCPU which can be used by the machine to locate per-cpu data. Intialization, lifetime and cleanup of machine_data is entirely up to the machine type.
--- hw/ppc/spapr_cpu_core.c | 13 ++++++ hw/ppc/spapr_hcall.c | 77 ++++++++++++++++++--------------- include/hw/ppc/spapr_cpu_core.h | 11 +++++ target/ppc/cpu.h | 7 +-- target/ppc/kvm.c | 39 +++++++++-------- target/ppc/translate_init.inc.c | 8 ---- 6 files changed, 88 insertions(+), 67 deletions(-)
hw/ppc/spapr_cpu_core.c +13 -0
@@ -28,6 +28,7 @@ static void spapr_cpu_reset(void *opaque)CPUState *cs =CPU (cpu);CPUPPCState *env = &cpu->env;PowerPCCPUClass *pcc =POWERPC_CPU_GET_CLASS (cpu); +sPAPRCPUState *spapr_cpu =spapr_cpu_state (cpu);target_ulong lpcr;cpu_reset (cs);
@@ -69,6 +70,12 @@ static void spapr_cpu_reset(void *opaque)/* Set a full AMOR so guest can use the AMR as it sees fit */ env->spr[SPR_AMOR ] =0xffffffffffffffffull ; + + spapr_cpu->vpa_addr =0 ; + spapr_cpu->slb_shadow_addr =0 ; + spapr_cpu->slb_shadow_size =0 ; + spapr_cpu->dtl_addr =0 ; + spapr_cpu->dtl_size =0 ; }void spapr_cpu_set_entry_state (PowerPCCPU *cpu,target_ulong nip,target_ulong r3)
@@ -186,6 +193,8 @@ static PowerPCCPU *spapr_create_vcpu(sPAPRCPUCore *sc, int i, Error **errp) goto err; } + cpu->machine_data =g_new0 (sPAPRCPUState,1 ); +object_unref (obj);return cpu;
@@ -197,6 +206,10 @@ err:static void spapr_delete_vcpu (PowerPCCPU *cpu) { +sPAPRCPUState *spapr_cpu =spapr_cpu_state (cpu); + + cpu->machine_data =NULL ; +g_free (spapr_cpu);object_unparent (OBJECT (cpu)); }
hw/ppc/spapr_hcall.c +42 -35
186 lines not on this page · raw message
include/hw/ppc/spapr_cpu_core.h +11 -0
@@ -41,4 +41,15 @@ typedef struct sPAPRCPUCoreClass {const char *spapr_get_cpu_core_type (const char *cpu_type);void spapr_cpu_set_entry_state (PowerPCCPU *cpu,target_ulong nip,target_ulong r3); +typedef struct sPAPRCPUState { +uint64_t vpa_addr; +uint64_t slb_shadow_addr, slb_shadow_size; +uint64_t dtl_addr, dtl_size; +}sPAPRCPUState ; + +static inline sPAPRCPUState *spapr_cpu_state (PowerPCCPU *cpu) +{ +return (sPAPRCPUState *)cpu->machine_data; +} +#endif
target/ppc/cpu.h +1 -6
@@ -1091,12 +1091,6 @@ struct CPUPPCState {target_ulong rmls;#endif -#if defined(TARGET_PPC64 ) && !defined(CONFIG_USER_ONLY ) -uint64_t vpa_addr; -uint64_t slb_shadow_addr, slb_shadow_size; -uint64_t dtl_addr, dtl_size; -#endif /* TARGET_PPC64 */ -int error_code;uint32_t pending_interrupts;#if !defined(CONFIG_USER_ONLY )
@@ -1205,6 +1199,7 @@ struct PowerPCCPU {uint32_t compat_pvr;PPCVirtualHypervisor *vhyp;Object *intc; +void *machine_data;int32_t node_id;/* NUMA node this CPU belongs to */ PPCHash64Options *hash64_opts;
target/ppc/kvm.c +21 -18
@@ -829,22 +829,22 @@ static int kvm_get_fp(CPUState *cs)static int kvm_get_vpa (CPUState *cs) {PowerPCCPU *cpu =POWERPC_CPU (cs); -CPUPPCState *env = &cpu->env; +sPAPRCPUState *spapr_cpu =spapr_cpu_state (cpu);struct kvm_one_reg reg;int ret; reg.id =KVM_REG_PPC_VPA_ADDR ; - reg.addr = (uintptr_t )&env->vpa_addr; + reg.addr = (uintptr_t )&spapr_cpu->vpa_addr; ret =kvm_vcpu_ioctl (cs,KVM_GET_ONE_REG , ®);if (ret <0 ) {DPRINTF ("Unable to get VPA address from KVM: %s\n" ,strerror (errno));return ret; } -assert ((uintptr_t )&env->slb_shadow_size - == ((uintptr_t )&env->slb_shadow_addr +8 )); +assert ((uintptr_t )&spapr_cpu->slb_shadow_size + == ((uintptr_t )&spapr_cpu->slb_shadow_addr +8 )); reg.id =KVM_REG_PPC_VPA_SLB ; - reg.addr = (uintptr_t )&env->slb_shadow_addr; + reg.addr = (uintptr_t )&spapr_cpu->slb_shadow_addr; ret =kvm_vcpu_ioctl (cs,KVM_GET_ONE_REG , ®);if (ret <0 ) { DPRINTF("Unable to get SLB shadow state from KVM: %s\n",
@@ -852,9 +852,10 @@ static int kvm_get_vpa(CPUState *cs)return ret; } -assert ((uintptr_t )&env->dtl_size == ((uintptr_t )&env->dtl_addr +8 )); +assert ((uintptr_t )&spapr_cpu->dtl_size + == ((uintptr_t )&spapr_cpu->dtl_addr +8 )); reg.id =KVM_REG_PPC_VPA_DTL ; - reg.addr = (uintptr_t )&env->dtl_addr; + reg.addr = (uintptr_t )&spapr_cpu->dtl_addr; ret =kvm_vcpu_ioctl (cs,KVM_GET_ONE_REG , ®);if (ret <0 ) { DPRINTF("Unable to get dispatch trace log state from KVM: %s\n",
@@ -868,7 +869,7 @@ static int kvm_get_vpa(CPUState *cs)static int kvm_put_vpa (CPUState *cs) {PowerPCCPU *cpu =POWERPC_CPU (cs); -CPUPPCState *env = &cpu->env; +sPAPRCPUState *spapr_cpu =spapr_cpu_state (cpu);struct kvm_one_reg reg;int ret;
@@ -876,11 +877,12 @@ static int kvm_put_vpa(CPUState *cs)* registered. That means when restoring state, if a VPA *is* * registered, we need to set that up first. If not, we need to * deregister the others before deregistering the master VPA */ -assert (env->vpa_addr || !(env->slb_shadow_addr || env->dtl_addr)); +assert (spapr_cpu->vpa_addr + || !(spapr_cpu->slb_shadow_addr || spapr_cpu->dtl_addr)); -if (env->vpa_addr) { +if (spapr_cpu->vpa_addr) { reg.id =KVM_REG_PPC_VPA_ADDR ; - reg.addr = (uintptr_t )&env->vpa_addr; + reg.addr = (uintptr_t )&spapr_cpu->vpa_addr; ret =kvm_vcpu_ioctl (cs,KVM_SET_ONE_REG , ®);if (ret <0 ) {DPRINTF ("Unable to set VPA address to KVM: %s\n" ,strerror (errno));
@@ -888,19 +890,20 @@ static int kvm_put_vpa(CPUState *cs) } } -assert ((uintptr_t )&env->slb_shadow_size - == ((uintptr_t )&env->slb_shadow_addr +8 )); +assert ((uintptr_t )&spapr_cpu->slb_shadow_size + == ((uintptr_t )&spapr_cpu->slb_shadow_addr +8 )); reg.id =KVM_REG_PPC_VPA_SLB ; - reg.addr = (uintptr_t )&env->slb_shadow_addr; + reg.addr = (uintptr_t )&spapr_cpu->slb_shadow_addr; ret =kvm_vcpu_ioctl (cs,KVM_SET_ONE_REG , ®);if (ret <0 ) {DPRINTF ("Unable to set SLB shadow state to KVM: %s\n" ,strerror (errno));return ret; } -assert ((uintptr_t )&env->dtl_size == ((uintptr_t )&env->dtl_addr +8 )); +assert ((uintptr_t )&spapr_cpu->dtl_size + == ((uintptr_t )&spapr_cpu->dtl_addr +8 )); reg.id =KVM_REG_PPC_VPA_DTL ; - reg.addr = (uintptr_t )&env->dtl_addr; + reg.addr = (uintptr_t )&spapr_cpu->dtl_addr; ret =kvm_vcpu_ioctl (cs,KVM_SET_ONE_REG , ®);if (ret <0 ) { DPRINTF("Unable to set dispatch trace log state to KVM: %s\n",
@@ -908,9 +911,9 @@ static int kvm_put_vpa(CPUState *cs)return ret; } -if (!env->vpa_addr) { +if (!spapr_cpu->vpa_addr) { reg.id =KVM_REG_PPC_VPA_ADDR ; - reg.addr = (uintptr_t )&env->vpa_addr; + reg.addr = (uintptr_t )&spapr_cpu->vpa_addr; ret =kvm_vcpu_ioctl (cs,KVM_SET_ONE_REG , ®);if (ret <0 ) {DPRINTF ("Unable to set VPA address to KVM: %s\n" ,strerror (errno));
target/ppc/translate_init.inc.c +0 -8
@@ -10316,14 +10316,6 @@ static void ppc_cpu_reset(CPUState *s) s->exception_index =POWERPC_EXCP_NONE ; env->error_code =0 ; -#if defined(TARGET_PPC64 ) && !defined(CONFIG_USER_ONLY ) - env->vpa_addr =0 ; - env->slb_shadow_addr =0 ; - env->slb_shadow_size =0 ; - env->dtl_addr =0 ; - env->dtl_size =0 ; -#endif /* TARGET_PPC64 */ -for (i =0 ; i <ARRAY_SIZE (env->spr_cb); i++) {ppc_spr_t *spr = &env->spr_cb[i];
Signature · 1 line
2.17.1
[Qemu-devel] [PULL 11/28] mac_newworld: add PMU device
In reply to David GibsonFrom: Mark Cave-Ayland <[email protected]>
The PMU device supercedes the CUDA device found on older New World Macs and is supported by a larger number of guest OSs from OS 9 to OS X 10.5.
--- default-configs/ppc-softmmu.mak | 1 + hw/misc/macio/Makefile.objs | 1 + hw/misc/macio/macio.c | 69 ++- hw/misc/macio/pmu.c | 871 ++++++++++++++++++++++++++++++++ hw/misc/macio/trace-events | 21 + hw/ppc/mac.h | 1 + hw/ppc/mac_newworld.c | 10 +- include/hw/misc/macio/macio.h | 2 + include/hw/misc/macio/pmu.h | 237 +++++++++ 9 files changed, 1193 insertions(+), 20 deletions(-) create mode 100644 hw/misc/macio/pmu.c create mode 100644 include/hw/misc/macio/pmu.h
default-configs/ppc-softmmu.mak +1 -0
@@ -38,6 +38,7 @@ CONFIG_CUDA=y CONFIG_ADB=y CONFIG_MAC_NVRAM=y CONFIG_MAC_DBDMA=y +CONFIG_MAC_PMU=y CONFIG_HEATHROW_PIC=y CONFIG_GRACKLE_PCI=y CONFIG_UNIN_PCI=y
hw/misc/macio/Makefile.objs +1 -0
@@ -1,4 +1,5 @@ common-obj-y += macio.o common-obj-$(CONFIG_CUDA) += cuda.o +common-obj-$(CONFIG_MAC_PMU) += pmu.o common-obj-$(CONFIG_MAC_DBDMA) += mac_dbdma.o common-obj-$(CONFIG_MACIO_GPIO) += gpio.o
hw/misc/macio/macio.c +50 -19
106 lines not on this page · raw message
hw/misc/macio/pmu.c new file +871 -0
871 lines not on this page · raw message
hw/misc/macio/trace-events +21 -0
@@ -20,3 +20,24 @@ macio_gpio_irq_assert(int gpio) "asserting GPIO %d" macio_gpio_irq_deassert(int gpio) "deasserting GPIO %d" macio_gpio_write(uint64_t addr, uint64_t val) "addr: 0x%"PRIx64" value: 0x%"PRIx64 macio_gpio_read(uint64_t addr, uint64_t val) "addr: 0x%"PRIx64" value: 0x%"PRIx64 + +# hw/misc/macio/pmu.c +pmu_adb_poll(int olen) "ADB autopoll, olen=%d" +pmu_one_sec_timer(void) "PMU one sec..." +pmu_cmd_set_int_mask(int intmask) "Setting PMU int mask to 0x%02x" +pmu_cmd_set_adb_autopoll(int mask) "ADB set autopoll, mask=0x%04x" +pmu_cmd_adb_nobus(void) "ADB PACKET with no ADB bus!" +pmu_cmd_adb_request(int inlen, int indata0, int indata1, int indata2, int indata3, int indata4) "ADB request: len=%d, cmd=0x%02x, pflags=0x%02x, adblen=%d: 0x%02x 0x%02x..." +pmu_cmd_adb_reply(int len) "ADB reply is %d bytes" +pmu_dispatch_cmd(const char *name) "handling command %s" +pmu_dispatch_unknown_cmd(int cmd) "Unknown PMU command 0x%02x" +pmu_debug_protocol_string(const char *str) "%s" +pmu_debug_protocol_resp_size(int size) "sending %d resp bytes" +pmu_debug_protocol_error(int portB) "protocol error! portB=0x%02x" +pmu_debug_protocol_clear_treq(int state) "TREQ cleared, clearing TACK, state: %d" +pmu_debug_protocol_cmd(int cmd, int cmdlen, int rsplen) "Got command byte 0x%02x, clen=%d, rlen=%d" +pmu_debug_protocol_cmdlen(int len) "got cmd length byte: %d" +pmu_debug_protocol_cmd_toobig(int len) "command too big (%d bytes)" +pmu_debug_protocol_cmd_send_resp_size(int len) "sending length byte: %d" +pmu_debug_protocol_cmd_send_resp(int pos, int len) "sending byte: %d/%d" +pmu_debug_protocol_cmd_resp_complete(int ier) "Response send complete. IER=0x%02x"
hw/ppc/mac.h +1 -0
@@ -59,6 +59,7 @@/* New World IRQs */ #define NEWWORLD_CUDA_IRQ 0x19 +#define NEWWORLD_PMU_IRQ 0x19#define NEWWORLD_ESCCB_IRQ 0x24#define NEWWORLD_ESCCA_IRQ 0x25#define NEWWORLD_IDE0_IRQ 0xd
hw/ppc/mac_newworld.c +9 -1
@@ -399,11 +399,19 @@ static void ppc_core99_init(MachineState *machine)macio_ide_init_drives (macio_ide, &hd[MAX_IDE_DEVS ]);if (has_adb) { - dev =DEVICE (object_resolve_path_component (OBJECT (macio),"cuda" )); +if (has_pmu) { + dev =DEVICE (object_resolve_path_component (OBJECT (macio),"pmu" )); + }else { + dev =DEVICE (object_resolve_path_component (OBJECT (macio),"cuda" )); + } + adb_bus =qdev_get_child_bus (dev,"adb.0" ); dev =qdev_create (adb_bus,TYPE_ADB_KEYBOARD ); +qdev_prop_set_bit (dev,"disable-direct-reg3-writes" , has_pmu);qdev_init_nofail (dev); + dev =qdev_create (adb_bus,TYPE_ADB_MOUSE ); +qdev_prop_set_bit (dev,"disable-direct-reg3-writes" , has_pmu);qdev_init_nofail (dev); }
include/hw/misc/macio/macio.h +2 -0
@@ -30,6 +30,7 @@#include "hw/intc/heathrow_pic.h" #include "hw/misc/macio/cuda.h" #include "hw/misc/macio/gpio.h" +#include "hw/misc/macio/pmu.h" #include "hw/ppc/mac_dbdma.h" #include "hw/ppc/openpic.h"
@@ -43,6 +44,7 @@ typedef struct MacIOState {MemoryRegion bar;CUDAState cuda; +PMUState pmu;DBDMAState dbdma;ESCCState escc;uint64_t frequency;
include/hw/misc/macio/pmu.h new file +237 -0
237 lines not on this page · raw message
Signature · 1 line
2.17.1
Peter Maydell
AppliedQuoted 15 lines · David Gibson
The following changes since commit
2ef2f16781af9dee6ba6517755e9073ba5799fa2:Merge remote-tracking branch 'remotes/dgilbert/tags/pull-migration-20180615a' into staging (2018-06-15 18:13:35 +0100)
are available in the Git repository at:
git://github.com/dgibson/qemu.gittags/ppc-for-3.0-20180618for you to fetch changes up to
844afc54ae229515a37f63519855661ad2d01d19:spapr: fix
xics_system_init()error path (2018-06-18 09:43:19 +1000)----------------------------------------------------------------
ppc patch queue 2018-06-18
Quoted 8 lines
Next batch of ppc and spapr related patches for the 3.0 release.
* Improved handling of Spectre/Meltdown mitigations for POWER8
* Numerous Mac machine type cleanups and improvements
* Cleanup to cpu realize/unrealize path for spapr
* Create a place for machine-specific per-cpu information, and start moving some things to it
* Assorted bugfixes
Applied, thanks.
-- PMM