ppc-for-2.8 queue 20161028
The following changes since commit 835f3d24b42fcbeca5c49048994a4e5d0fe905c5:
Merge remote-tracking branch 'remotes/kraxel/tags/pull-audio-20161027-1' into staging (2016-10-27 17:24:29 +0100)
are available in the git repository at:
git://github.com/dgibson/qemu.git tags/ppc-for-2.8-20161028
for you to fetch changes up to 10c21b5c20bf3d20b7b0ad279db37ae89cc7937d:
ppc: allow certain HV interrupts to be delivered to guests (2016-10-28 11:17:35 +1100)
----------------------------------------------------------------
ppc patch queue 2016-10-28
This pull request supersedes and extends the one from 2016-10-26 (which had a build bug).
Highlights:
* SLOF (pseries guest firmware) update
* Enable a number of extra testcases on ppc / pseries
* Added the 'powernv' machine type
- Almost enough to be minimally usable
- But still missing necessary interrupt controller updates
* Cleanup and consolidation of NVRAM handling on several platforms with related firmware
* Substantial cleanup to device tree construction
* Some more POWER9 instruction emulation
* Cleanup to handling of pseries option vectors and CAS reboot handling (host/guest feature negotiation mechanism)
* Significant cleanups to handling of PCI devices in test cases
* New hotplug event infrastructure
* Memory hot unplug support for pseries
* Several bug fixes
The NVRAM cleanup affects some Sun sparc platforms as well as ppc ones, but have been tested by the sparc maintainer (Mark Cave-Ayland).
The test additions also include substantial general changes to the test framework that aren't strictly ppc related. They don't seem to break tests on other platforms, they're for the benefit of enabling tests on ppc and there isn't a specific maintainer for them, so they're included in this tree.
----------------------------------------------------------------
Alexey Kardashevskiy (2):
pseries: Update SLOF firmware image to 20161019
configure, ppc64: Copy skiboot.lid to build directory when configuring
Benjamin Herrenschmidt (4):
ppc/xics: Add xics to the monitor "info pic" command
ppc: Fix single step with gdb stub
ppc/pnv: add skeleton PowerNV platform ppc/pnv: add a LPC controller
Bharata B Rao (2):
spapr: Add DRC count indexed hotplug identifier type
spapr: Memory hot-unplug support
Cédric Le Goater (11):
ppc/xics: add a xics_set_nr_servers common routine ppc/xics: add a XICSState backlink in ICPState
ppc/xics: change the icp_ routines API to use an 'ICPState *' argument
ppc: add skiboot firmware for the pnv platform
ppc/pnv: add a PnvChip object
ppc/pnv: add a core mask to PnvChip
ppc/pnv: add a PIR handler to PnvChip
ppc/pnv: add a PnvCore object
ppc/pnv: add XSCOM infrastructure
ppc/pnv: add XSCOM handlers to PnvCore
ppc/pnv: add a ISA bus
David Gibson (26):
pseries: Remove unused callbacks from sPAPR VIO bus state
pseries: Split device tree construction from device tree load
pseries: Remove rtas_addr and fdt_addr fields from machinestate
pseries: Make spapr_create_fdt_skel() get information from machine state
pseries: Move adding of fdt reserve map entries
pseries: Consolidate RTAS loading
pseries: Move construction of /interrupt-controller fdt node
pseries: Consolidate construction of /chosen device tree node
pseries: Consolidate construction of /rtas device tree node
pseries: Move /event-sources construction to spapr_build_fdt()
pseries: Move /hypervisor node construction to fdt_build_fdt()
pseries: Consolidate construction of /vdevice device tree node
pseries: Remove spapr_create_fdt_skel()
libqos: Give qvirtio_config_read*() consistent semantics
libqos: Handle PCI IO de-multiplexing in common code
libqos: Move BAR assignment to common code
libqos: Better handling of PCI legacy IO
tests: Adjust tco-test to use qpci_legacy_iomap()
libqos: Add streaming accessors for PCI MMIO
libqos: Implement mmio accessors in terms of mem{read,write}
tests: Clean up IO handling in ide-test
libqos: Add 64-bit PCI IO accessors
tests: Use qpci_mem{read,write} in ivshmem-test
tests: Don't assume structure of PCI IO base in ahci-test
libqos: Change PCI accessors to take opaque BAR handle
tests: Add pseries machine to the prom-env-test, too
Hervé Poussineau (1):
adb: change handler only when recognized
Laurent Vivier (6):
tests: fix memory leak in virtio-scsi-test
tests: don't check if qtest_spapr_boot() returns NULL
tests: move QVirtioBus pointer into QVirtioDevice
tests: rename target_big_endian() as qvirtio_is_big_endian()
tests: use qtest_pc_boot()/qtest_shutdown() in virtio tests
tests: enable virtio tests on SPAPR
Michael Roth (9):
spapr_pci: advertise explicit numa IDs even when there's 1 node
spapr_ovec: initial implementation of option vector helpers
spapr_hcall: use spapr_ovec_* interfaces for CAS options
spapr: add option vector handling in CAS-generated resets
spapr: improve ibm,architecture-vec-5 property handling
spapr: update spapr hotplug documentation
spapr_events: add support for dedicated hotplug event source
spapr: add hotplug interrupt machine options
spapr: use count+index for memory hotplug
Nicholas Piggin (2):
ppc: fix MSR_ME handling for system reset interrupt
ppc: allow certain HV interrupts to be delivered to guests
Nikunj A Dadhania (2):
target-ppc: implement vnegw/d instructions
target-ppc: implement xxbr[qdwh] instruction
Sandipan Das (1):
target-ppc: add xscmp[eq,gt,ge,ne]dp instructions
Swapnil Bokade (1):
target-ppc: Add xvcmpnesp, xvcmpnedp instructions
Thomas Huth (5):
nvram: Introduce helper functions for CHRP "system" and "free space" partitions
sparc: Use the new common NVRAM functions for system and free space partition
nvram: Move the remaining CHRP NVRAM related code to chrp_nvram.[ch]
nvram: Rename openbios_firmware_abi.h into sun_nvram.h
spapr_nvram: Pre-initialize the NVRAM to support the -prom-env parameter
Vasant Hegde (1):
target-ppc: add vmul10[u,eu,cu,ecu]q instructions
.gitmodules | 3 +
MAINTAINERS | 1 +
Makefile | 2 +-
configure | 1 +
default-configs/ppc64-softmmu.mak | 1 +
docs/specs/ppc-spapr-hotplug.txt | 55 +-
hw/input/adb.c | 26 +-
hw/intc/xics.c | 99 ++-
hw/intc/xics_kvm.c | 13 +-
hw/intc/xics_spapr.c | 53 +-
hw/nvram/Makefile.objs | 1 +
hw/nvram/chrp_nvram.c | 85 +++
hw/nvram/mac_nvram.c | 49 +-
hw/nvram/spapr_nvram.c | 6 +
hw/ppc/Makefile.objs | 4 +-
hw/ppc/pnv.c | 819 +++++++++++++++++++++
hw/ppc/pnv_core.c | 232 ++++++
hw/ppc/pnv_lpc.c | 471 ++++++++++++
hw/ppc/pnv_xscom.c | 275 +++++++
hw/ppc/spapr.c | 791 ++++++++++++--------
hw/ppc/spapr_cpu_core.c | 2 +-
hw/ppc/spapr_drc.c | 17 +
hw/ppc/spapr_events.c | 279 +++++--
hw/ppc/spapr_hcall.c | 70 +-
hw/ppc/spapr_ovec.c | 242 ++++++
hw/ppc/spapr_pci.c | 8 +-
hw/ppc/spapr_rtas.c | 91 +--
hw/ppc/spapr_vio.c | 40 +-
hw/sparc/sun4m.c | 35 +-
hw/sparc64/sun4u.c | 35 +-
include/hw/nvram/chrp_nvram.h | 54 ++
.../nvram/{openbios_firmware_abi.h => sun_nvram.h} | 47 +-
include/hw/ppc/pnv.h | 129 ++++
include/hw/ppc/pnv_core.h | 50 ++
include/hw/ppc/pnv_lpc.h | 67 ++
include/hw/ppc/pnv_xscom.h | 78 ++
include/hw/ppc/spapr.h | 27 +-
include/hw/ppc/spapr_ovec.h | 67 ++
include/hw/ppc/spapr_vio.h | 6 +-
include/hw/ppc/xics.h | 11 +-
pc-bios/README | 7 +-
pc-bios/skiboot.lid | Bin 0 -> 983893 bytes
pc-bios/slof.bin | Bin 923832 -> 898232 bytes
roms/Makefile | 8 +-
roms/SLOF | 2 +-
roms/skiboot | 1 +
target-ppc/excp_helper.c | 34 +-
target-ppc/fpu_helper.c | 71 +-
target-ppc/helper.h | 8 +
target-ppc/int_helper.c | 12 +
target-ppc/translate.c | 34 +-
target-ppc/translate/vmx-impl.inc.c | 74 ++
target-ppc/translate/vmx-ops.inc.c | 10 +-
target-ppc/translate/vsx-impl.inc.c | 83 +++
target-ppc/translate/vsx-ops.inc.c | 14 +
tests/Makefile.include | 3 +-
tests/ahci-test.c | 13 +-
tests/e1000e-test.c | 7 +-
tests/ide-test.c | 177 +++--
tests/ivshmem-test.c | 47 +-
tests/libqos/ahci.c | 4 +-
tests/libqos/ahci.h | 7 +-
tests/libqos/libqos.c | 2 +
tests/libqos/pci-pc.c | 187 ++---
tests/libqos/pci-spapr.c | 194 ++---
tests/libqos/pci.c | 194 ++++-
tests/libqos/pci.h | 66 +-
tests/libqos/usb.c | 6 +-
tests/libqos/usb.h | 2 +-
tests/libqos/virtio-mmio.c | 17 +-
tests/libqos/virtio-pci.c | 146 ++--
tests/libqos/virtio-pci.h | 2 +-
tests/libqos/virtio.c | 78 +-
tests/libqos/virtio.h | 57 +-
tests/libqtest.h | 10 -
tests/postcopy-test.c | 8 +-
tests/prom-env-test.c | 20 +-
tests/rtas-test.c | 1 -
tests/rtl8139-test.c | 10 +-
tests/tco-test.c | 80 +-
tests/usb-hcd-ehci-test.c | 5 +-
tests/vhost-user-test.c | 33 +-
tests/virtio-9p-test.c | 73 +-
tests/virtio-blk-test.c | 342 ++++-----
tests/virtio-net-test.c | 106 +--
tests/virtio-rng-test.c | 7 +-
tests/virtio-scsi-test.c | 93 ++-
87 files changed, 4983 insertions(+), 1714 deletions(-)
create mode 100644 hw/nvram/chrp_nvram.c
create mode 100644 hw/ppc/pnv.c
create mode 100644 hw/ppc/pnv_core.c
create mode 100644 hw/ppc/pnv_lpc.c
create mode 100644 hw/ppc/pnv_xscom.c
create mode 100644 hw/ppc/spapr_ovec.c
create mode 100644 include/hw/nvram/chrp_nvram.h
rename include/hw/nvram/{openbios_firmware_abi.h => sun_nvram.h} (50%)
create mode 100644 include/hw/ppc/pnv.h
create mode 100644 include/hw/ppc/pnv_core.h
create mode 100644 include/hw/ppc/pnv_lpc.h
create mode 100644 include/hw/ppc/pnv_xscom.h
create mode 100644 include/hw/ppc/spapr_ovec.h
create mode 100644 pc-bios/skiboot.lid
create mode 160000 roms/skiboot[Qemu-devel] [PULL 05/73] tests: move QVirtioBus pointer into QVirtioDevice
From: Laurent Vivier <[email protected]>
This allows to not have to pass bus and device for every virtio functions.
--- tests/libqos/virtio-mmio.c | 1 + tests/libqos/virtio-pci.c | 2 + tests/libqos/virtio.c | 78 +++++++++++------------- tests/libqos/virtio.h | 51 +++++++--------- tests/vhost-user-test.c | 33 +++++----- tests/virtio-9p-test.c | 15 +++-- tests/virtio-blk-test.c | 147 ++++++++++++++++++++------------------------- tests/virtio-net-test.c | 59 +++++++++--------- tests/virtio-scsi-test.c | 17 +++--- 9 files changed, 186 insertions(+), 217 deletions(-)
tests/libqos/virtio-mmio.c +1 -0
@@ -199,6 +199,7 @@ QVirtioMMIODevice *qvirtio_mmio_init_device(uint64_t addr, uint32_t page_size) dev->addr = addr; dev->page_size = page_size; dev->vdev.device_type =readl (addr +QVIRTIO_MMIO_DEVICE_ID ); + dev->vdev.bus = &qvirtio_mmio;writel (addr +QVIRTIO_MMIO_GUEST_PAGE_SIZE , page_size);
tests/libqos/virtio-pci.c +2 -0
@@ -286,6 +286,8 @@ QVirtioPCIDevice *qvirtio_pci_device_find(QPCIBus *bus, uint16_t device_type)QVirtioPCIDevice *dev =NULL ;qvirtio_pci_foreach (bus, device_type, qvirtio_pci_assign_device, &dev); + dev->vdev.bus = &qvirtio_pci; +return dev; }
tests/libqos/virtio.c +35 -43
163 lines not on this page · raw message
tests/libqos/virtio.h +23 -28
86 lines not on this page · raw message
tests/vhost-user-test.c +16 -17
@@ -172,15 +172,15 @@ static void init_virtio_dev(TestServer *s)g_assert_nonnull (dev);qvirtio_pci_device_enable (dev); -qvirtio_reset (&qvirtio_pci, &dev->vdev); -qvirtio_set_acknowledge (&qvirtio_pci, &dev->vdev); -qvirtio_set_driver (&qvirtio_pci, &dev->vdev); +qvirtio_reset (&dev->vdev); +qvirtio_set_acknowledge (&dev->vdev); +qvirtio_set_driver (&dev->vdev); - features =qvirtio_get_features (&qvirtio_pci, &dev->vdev); + features =qvirtio_get_features (&dev->vdev); features = features &VIRTIO_NET_F_MAC ; -qvirtio_set_features (&qvirtio_pci, &dev->vdev, features); +qvirtio_set_features (&dev->vdev, features); -qvirtio_set_driver_ok (&qvirtio_pci, &dev->vdev); +qvirtio_set_driver_ok (&dev->vdev); }static void wait_for_fds (TestServer *s)
@@ -847,24 +847,24 @@ static QVirtioPCIDevice *virtio_net_pci_init(QPCIBus *bus, int slot) g_assert_cmphex(dev->vdev.device_type, ==, VIRTIO_ID_NET);qvirtio_pci_device_enable (dev); -qvirtio_reset (&qvirtio_pci, &dev->vdev); -qvirtio_set_acknowledge (&qvirtio_pci, &dev->vdev); -qvirtio_set_driver (&qvirtio_pci, &dev->vdev); +qvirtio_reset (&dev->vdev); +qvirtio_set_acknowledge (&dev->vdev); +qvirtio_set_driver (&dev->vdev);return dev; } -static void driver_init (const QVirtioBus *bus,QVirtioDevice *dev) +static void driver_init (QVirtioDevice *dev) {uint32_t features; - features =qvirtio_get_features (bus, dev); + features =qvirtio_get_features (dev); features = features & ~(QVIRTIO_F_BAD_FEATURE | (1u <<VIRTIO_RING_F_INDIRECT_DESC ) | (1u <<VIRTIO_RING_F_EVENT_IDX )); -qvirtio_set_features (bus, dev, features); +qvirtio_set_features (dev, features); -qvirtio_set_driver_ok (bus, dev); +qvirtio_set_driver_ok (dev); }#define PCI_SLOT 0x04
@@ -896,16 +896,15 @@ static void test_multiqueue(void) alloc =pc_alloc_init ();for (i =0 ; i < queues *2 ; i++) { - vq[i] = (QVirtQueuePCI *)qvirtqueue_setup (&qvirtio_pci, &dev->vdev, - alloc, i); + vq[i] = (QVirtQueuePCI *)qvirtqueue_setup (&dev->vdev, alloc, i); } -driver_init (&qvirtio_pci, &dev->vdev); +driver_init (&dev->vdev);wait_for_rings_started (s, queues *2 );/* End test */ for (i =0 ; i < queues *2 ; i++) { -qvirtqueue_cleanup (&qvirtio_pci, &vq[i]->vq, alloc); +qvirtqueue_cleanup (dev->vdev.bus, &vq[i]->vq, alloc); }pc_alloc_uninit (alloc);qvirtio_pci_device_disable (dev);
tests/virtio-9p-test.c +7 -8
@@ -71,17 +71,17 @@ static QVirtIO9P *qvirtio_9p_pci_init(void) v9p->dev = (QVirtioDevice *) dev;qvirtio_pci_device_enable (dev); -qvirtio_reset (&qvirtio_pci, v9p->dev); -qvirtio_set_acknowledge (&qvirtio_pci, v9p->dev); -qvirtio_set_driver (&qvirtio_pci, v9p->dev); +qvirtio_reset (v9p->dev); +qvirtio_set_acknowledge (v9p->dev); +qvirtio_set_driver (v9p->dev); - v9p->vq =qvirtqueue_setup (&qvirtio_pci, v9p->dev, v9p->alloc,0 ); + v9p->vq =qvirtqueue_setup (v9p->dev, v9p->alloc,0 );return v9p; }static void qvirtio_9p_pci_free (QVirtIO9P *v9p) { -qvirtqueue_cleanup (&qvirtio_pci, v9p->vq, v9p->alloc); +qvirtqueue_cleanup (v9p->dev->bus, v9p->vq, v9p->alloc);pc_alloc_uninit (v9p->alloc);qvirtio_pci_device_disable (container_of (v9p->dev, QVirtioPCIDevice, vdev));g_free (v9p->dev);
@@ -101,15 +101,14 @@ static void pci_basic_config(void) v9p =qvirtio_9p_pci_init (); addr = ((QVirtioPCIDevice *) v9p->dev)->addr +VIRTIO_PCI_CONFIG_OFF (false); - tag_len =qvirtio_config_readw (&qvirtio_pci, v9p->dev, + tag_len =qvirtio_config_readw (v9p->dev, (uint64_t )(uintptr_t )addr); g_assert_cmpint(tag_len, ==, strlen(mount_tag)); addr +=sizeof (uint16_t ); tag =g_malloc (tag_len);for (i =0 ; i < tag_len; i++) { - tag[i] =qvirtio_config_readb (&qvirtio_pci, v9p->dev, - (uint64_t )(uintptr_t )addr + i); + tag[i] =qvirtio_config_readb (v9p->dev, (uint64_t )(uintptr_t )addr + i); }g_assert_cmpmem (tag, tag_len, mount_tag, tag_len);g_free (tag);
tests/virtio-blk-test.c +66 -81
360 lines not on this page · raw message
tests/virtio-net-test.c +28 -31
151 lines not on this page · raw message
tests/virtio-scsi-test.c +8 -9
@@ -58,7 +58,7 @@ static void qvirtio_scsi_pci_free(QVirtIOSCSI *vs)int i;for (i =0 ; i < vs->num_queues +2 ; i++) { -qvirtqueue_cleanup (&qvirtio_pci, vs->vq[i], vs->alloc); +qvirtqueue_cleanup (vs->dev->bus, vs->vq[i], vs->alloc); }pc_alloc_uninit (vs->alloc);qvirtio_pci_device_disable (container_of (vs->dev, QVirtioPCIDevice, vdev));
@@ -119,8 +119,8 @@ static uint8_t virtio_scsi_do_command(QVirtIOSCSI *vs, const uint8_t *cdb,qvirtqueue_add (vq, data_in_addr, data_in_len, true, false); } -qvirtqueue_kick (&qvirtio_pci, vs->dev, vq, free_head); -qvirtio_wait_queue_isr (&qvirtio_pci, vs->dev, vq,QVIRTIO_SCSI_TIMEOUT_US ); +qvirtqueue_kick (vs->dev, vq, free_head); +qvirtio_wait_queue_isr (vs->dev, vq,QVIRTIO_SCSI_TIMEOUT_US ); response =readb (resp_addr + offsetof(struct virtio_scsi_cmd_resp , response));
@@ -155,18 +155,17 @@ static QVirtIOSCSI *qvirtio_scsi_pci_init(int slot) g_assert_cmphex(vs->dev->device_type, ==, VIRTIO_ID_SCSI);qvirtio_pci_device_enable (dev); -qvirtio_reset (&qvirtio_pci, vs->dev); -qvirtio_set_acknowledge (&qvirtio_pci, vs->dev); -qvirtio_set_driver (&qvirtio_pci, vs->dev); +qvirtio_reset (vs->dev); +qvirtio_set_acknowledge (vs->dev); +qvirtio_set_driver (vs->dev); addr = dev->addr +VIRTIO_PCI_CONFIG_OFF (false); - vs->num_queues =qvirtio_config_readl (&qvirtio_pci, vs->dev, - (uint64_t )(uintptr_t )addr); + vs->num_queues =qvirtio_config_readl (vs->dev, (uint64_t )(uintptr_t )addr); g_assert_cmpint(vs->num_queues, <, MAX_NUM_QUEUES);for (i =0 ; i < vs->num_queues +2 ; i++) { - vs->vq[i] =qvirtqueue_setup (&qvirtio_pci, vs->dev, vs->alloc, i); + vs->vq[i] =qvirtqueue_setup (vs->dev, vs->alloc, i); }/* Clear the POWER ON OCCURRED unit attention */
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 11/73] sparc: Use the new common NVRAM functions for system and free space partition
In reply to David GibsonFrom: Thomas Huth <[email protected]>
The system and free space NVRAM partitions (for OpenBIOS) are created in exactly the same way as the Mac-style CHRP NVRAM partitions, so we can use the new common helper functions to do this job here, too.
--- hw/sparc/sun4m.c | 33 ++++++--------------------------- hw/sparc64/sun4u.c | 33 ++++++--------------------------- 2 files changed, 12 insertions(+), 54 deletions(-)
hw/sparc/sun4m.c +6 -27
@@ -39,6 +39,7 @@#include "hw/scsi/esp.h" #include "hw/i386/pc.h" #include "hw/isa/isa.h" +#include "hw/nvram/chrp_nvram.h" #include "hw/nvram/fw_cfg.h" #include "hw/char/escc.h" #include "hw/empty_slot.h"
@@ -117,39 +118,17 @@ static void nvram_init(Nvram *nvram, uint8_t *macaddr, int nvram_machine_id, const char *arch) {unsigned int i; -uint32_t start, end; +int sysp_end;uint8_t image[0x1ff0 ]; -struct OpenBIOS_nvpart_v1 *part_header;NvramClass *k =NVRAM_GET_CLASS (nvram);memset (image,'\0' ,sizeof (image)); - start =0 ; +/* OpenBIOS nvram variables partition */ + sysp_end =chrp_nvram_create_system_partition (image,0 ); -// OpenBIOS nvram variables -// Variable partition - part_header = (struct OpenBIOS_nvpart_v1 *)&image[start]; - part_header->signature =OPENBIOS_PART_SYSTEM ; -pstrcpy (part_header->name,sizeof (part_header->name),"system" ); - - end = start +sizeof (struct OpenBIOS_nvpart_v1 ); -for (i =0 ; i < nb_prom_envs; i++) - end =OpenBIOS_set_var (image, end, prom_envs[i]); - -// End marker - image[end++] ='\0' ; - - end = start + ((end - start +15 ) & ~15 ); -OpenBIOS_finish_partition (part_header, end - start); - -// free partition - start = end; - part_header = (struct OpenBIOS_nvpart_v1 *)&image[start]; - part_header->signature =OPENBIOS_PART_FREE ; -pstrcpy (part_header->name,sizeof (part_header->name),"free" ); - - end =0x1fd0 ; -OpenBIOS_finish_partition (part_header, end - start); +/* Free space partition */ +chrp_nvram_create_free_partition (&image[sysp_end],0x1fd0 - sysp_end);Sun_init_header ((struct Sun_nvram *)&image[0x1fd8 ], macaddr, nvram_machine_id);
hw/sparc64/sun4u.c +6 -27
@@ -37,6 +37,7 @@#include "sysemu/sysemu.h" #include "hw/boards.h" #include "hw/nvram/openbios_firmware_abi.h" +#include "hw/nvram/chrp_nvram.h" #include "hw/nvram/fw_cfg.h" #include "hw/sysbus.h" #include "hw/ide.h"
@@ -124,39 +125,17 @@ static int sun4u_NVRAM_set_params(Nvram *nvram, uint16_t NVRAM_size, const uint8_t *macaddr) {unsigned int i; -uint32_t start, end; +int sysp_end;uint8_t image[0x1ff0 ]; -struct OpenBIOS_nvpart_v1 *part_header;NvramClass *k =NVRAM_GET_CLASS (nvram);memset (image,'\0' ,sizeof (image)); - start =0 ; +/* OpenBIOS nvram variables partition */ + sysp_end =chrp_nvram_create_system_partition (image,0 ); -// OpenBIOS nvram variables -// Variable partition - part_header = (struct OpenBIOS_nvpart_v1 *)&image[start]; - part_header->signature =OPENBIOS_PART_SYSTEM ; -pstrcpy (part_header->name,sizeof (part_header->name),"system" ); - - end = start +sizeof (struct OpenBIOS_nvpart_v1 ); -for (i =0 ; i < nb_prom_envs; i++) - end =OpenBIOS_set_var (image, end, prom_envs[i]); - -// End marker - image[end++] ='\0' ; - - end = start + ((end - start +15 ) & ~15 ); -OpenBIOS_finish_partition (part_header, end - start); - -// free partition - start = end; - part_header = (struct OpenBIOS_nvpart_v1 *)&image[start]; - part_header->signature =OPENBIOS_PART_FREE ; -pstrcpy (part_header->name,sizeof (part_header->name),"free" ); - - end =0x1fd0 ; -OpenBIOS_finish_partition (part_header, end - start); +/* Free space partition */ +chrp_nvram_create_free_partition (&image[sysp_end],0x1fd0 - sysp_end);Sun_init_header ((struct Sun_nvram *)&image[0x1fd8 ], macaddr,0x80 );
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 14/73] target-ppc: implement vnegw/d instructions
In reply to David GibsonFrom: Nikunj A Dadhania <[email protected]>
Vector Integer Negate Instructions:
vnegw: Vector Negate Word
vnegd: Vector Negate Doubleword
--- target-ppc/helper.h | 2 ++ target-ppc/int_helper.c | 12 ++++++++++++ target-ppc/translate/vmx-impl.inc.c | 2 ++ target-ppc/translate/vmx-ops.inc.c | 2 ++ 4 files changed, 18 insertions(+)
target-ppc/helper.h +2 -0
@@ -272,6 +272,8 @@ DEF_HELPER_2(vextsh2w, void, avr, avr) DEF_HELPER_2(vextsb2d, void, avr, avr) DEF_HELPER_2(vextsh2d, void, avr, avr) DEF_HELPER_2(vextsw2d, void, avr, avr) +DEF_HELPER_2(vnegw, void, avr, avr) +DEF_HELPER_2(vnegd, void, avr, avr) DEF_HELPER_2(vupkhpx, void, avr, avr) DEF_HELPER_2(vupklpx, void, avr, avr)DEF_HELPER_2 (vupkhsb, void, avr, avr)
target-ppc/int_helper.c +12 -0
@@ -1949,6 +1949,18 @@ VEXT_SIGNED(vextsh2d, s64, UINT16_MAX, int16_t, int64_t) VEXT_SIGNED(vextsw2d, s64, UINT32_MAX, int32_t, int64_t)#undef VEXT_SIGNED +#define VNEG (name, element) \ +void helper_##name(ppc_avr_t *r, ppc_avr_t *b) \ +{ \ + int i; \ + VECTOR_FOR_INORDER_I(i, element) { \ + r->element[i] = -b->element[i]; \ + } \ +} +VNEG(vnegw, s32) +VNEG(vnegd, s64) +#undef VNEG +#define VSPLTI (suffix, element, splat_type) \ void helper_vspltis##suffix(ppc_avr_t *r, uint32_t splat) \ { \
target-ppc/translate/vmx-impl.inc.c +2 -0
@@ -815,6 +815,8 @@ GEN_VXFORM_NOA(vclzb, 1, 28) GEN_VXFORM_NOA(vclzh, 1, 29) GEN_VXFORM_NOA(vclzw, 1, 30) GEN_VXFORM_NOA(vclzd, 1, 31) +GEN_VXFORM_NOA_2(vnegw, 1, 24, 6) +GEN_VXFORM_NOA_2(vnegd, 1, 24, 7) GEN_VXFORM_NOA_2(vextsb2w, 1, 24, 16) GEN_VXFORM_NOA_2(vextsh2w, 1, 24, 17)GEN_VXFORM_NOA_2 (vextsb2d,1 ,24 ,24 )
target-ppc/translate/vmx-ops.inc.c +2 -0
@@ -215,6 +215,8 @@ GEN_VXFORM_DUAL_INV(vspltish, vinserth, 6, 13, 0x00000000, 0x100000,GEN_VXFORM_DUAL_INV (vspltisw, vinsertw,6 ,14 ,0x00000000 ,0x100000 ,PPC_ALTIVEC ),GEN_VXFORM_300_EXT (vinsertd,6 ,15 ,0x100000 ), +GEN_VXFORM_300_EO (vnegw,0x01 ,0x18 ,0x06 ), +GEN_VXFORM_300_EO (vnegd,0x01 ,0x18 ,0x07 ),GEN_VXFORM_300_EO (vextsb2w,0x01 ,0x18 ,0x10 ),GEN_VXFORM_300_EO (vextsh2w,0x01 ,0x18 ,0x11 ), GEN_VXFORM_300_EO(vextsb2d, 0x01, 0x18, 0x18),
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 16/73] ppc/xics: add a xics_set_nr_servers common routine
In reply to David GibsonFrom: Cédric Le Goater <[email protected]>
xics_spapr and xics_kvm nearly define the same 'set_nr_servers' handler. Only the type of the ICP differs. So let's make a common one to remove some duplicated code.
--- hw/intc/xics.c | 24 +++++++++++++++++++++--- hw/intc/xics_kvm.c | 13 +------------ hw/intc/xics_spapr.c | 13 +------------ include/hw/ppc/xics.h | 2 ++ 4 files changed, 25 insertions(+), 27 deletions(-)
hw/intc/xics.c +21 -3
@@ -183,6 +183,24 @@ static void xics_prop_set_nr_irqs(Object *obj, Visitor *v, const char *name, info->set_nr_irqs (xics, value, errp); } +void xics_set_nr_servers (XICSState *xics,uint32_t nr_servers, +const char *typename,Error **errp) +{ +int i; + + xics->nr_servers = nr_servers; + + xics->ss =g_malloc0 (xics->nr_servers *sizeof (ICPState)); +for (i =0 ; i < xics->nr_servers; i++) { +char name[32 ]; +ICPState *icp = &xics->ss[i]; + +object_initialize (icp,sizeof (*icp), typename); +snprintf (name,sizeof (name),"icp[%d]" , i); +object_property_add_child (OBJECT (xics), name,OBJECT (icp), errp); + } +} +static void xics_prop_get_nr_servers (Object *obj,Visitor *v,const char *name,void *opaque,Error **errp)
@@ -198,7 +216,7 @@ static void xics_prop_set_nr_servers(Object *obj, Visitor *v, Error **errp) {XICSState *xics =XICS_COMMON (obj); -XICSStateClass *info =XICS_COMMON_GET_CLASS (xics); +XICSStateClass *xsc =XICS_COMMON_GET_CLASS (xics);Error *error =NULL ;int64_t value;
@@ -213,8 +231,8 @@ static void xics_prop_set_nr_servers(Object *obj, Visitor *v,return ; } -assert (info->set_nr_servers); - info->set_nr_servers (xics, value, errp); +assert (xsc->set_nr_servers); + xsc->set_nr_servers (xics, value, errp); }static void xics_common_initfn (Object *obj)
hw/intc/xics_kvm.c +1 -12
@@ -373,18 +373,7 @@ static void xics_kvm_set_nr_irqs(XICSState *xics, uint32_t nr_irqs,static void xics_kvm_set_nr_servers (XICSState *xics,uint32_t nr_servers,Error **errp) { -int i; - - xics->nr_servers = nr_servers; - - xics->ss =g_malloc0 (xics->nr_servers *sizeof (ICPState)); -for (i =0 ; i < xics->nr_servers; i++) { -char buffer[32 ]; -object_initialize (&xics->ss[i],sizeof (xics->ss[i]),TYPE_KVM_ICP ); -snprintf (buffer,sizeof (buffer),"icp[%d]" , i); -object_property_add_child (OBJECT (xics), buffer,OBJECT (&xics->ss[i]), - errp); - } +xics_set_nr_servers (xics, nr_servers,TYPE_KVM_ICP , errp); } static void rtas_dummy(PowerPCCPU *cpu, sPAPRMachineState *spapr,
hw/intc/xics_spapr.c +1 -12
@@ -249,18 +249,7 @@ static void xics_spapr_set_nr_irqs(XICSState *xics, uint32_t nr_irqs,static void xics_spapr_set_nr_servers (XICSState *xics,uint32_t nr_servers,Error **errp) { -int i; - - xics->nr_servers = nr_servers; - - xics->ss =g_malloc0 (xics->nr_servers *sizeof (ICPState)); -for (i =0 ; i < xics->nr_servers; i++) { -char buffer[32 ]; -object_initialize (&xics->ss[i],sizeof (xics->ss[i]),TYPE_ICP ); -snprintf (buffer,sizeof (buffer),"icp[%d]" , i); -object_property_add_child (OBJECT (xics), buffer,OBJECT (&xics->ss[i]), - errp); - } +xics_set_nr_servers (xics, nr_servers,TYPE_ICP , errp); }static void xics_spapr_realize (DeviceState *dev,Error **errp)
include/hw/ppc/xics.h +2 -0
@@ -188,6 +188,8 @@ void xics_spapr_free(XICSState *icp, int irq, int num);void xics_cpu_setup (XICSState *icp,PowerPCCPU *cpu);void xics_cpu_destroy (XICSState *icp,PowerPCCPU *cpu); +void xics_set_nr_servers (XICSState *xics,uint32_t nr_servers, +const char *typename,Error **errp);/* Internal XICS interfaces */ int xics_get_cpu_index_by_dt_id (int cpu_dt_id);
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 02/73] ppc/xics: Add xics to the monitor "info pic" command
In reply to David GibsonFrom: Benjamin Herrenschmidt <[email protected]>
Useful to debug interrupt problems.
[clg: - updated for qemu-2.7
- added a test on ->irqs as it is not necessarily allocated (PHB3_MSI)
- removed static variable g_xics and replace with a loop on all children to find the xics objects.
- rebased on InterruptStatsProvider interface ]
--- hw/intc/xics.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+)
hw/intc/xics.c +49 -0
@@ -35,6 +35,8 @@#include "hw/ppc/xics.h" #include "qemu/error-report.h" #include "qapi/visitor.h" +#include "monitor/monitor.h" +#include "hw/intc/intc.h" int xics_get_cpu_index_by_dt_id (int cpu_dt_id) {
@@ -90,6 +92,47 @@ void xics_cpu_setup(XICSState *xics, PowerPCCPU *cpu) } } +static void xics_common_pic_print_info (InterruptStatsProvider *obj, +Monitor *mon) +{ +XICSState *xics =XICS_COMMON (obj); +ICSState *ics; +uint32_t i; + +for (i =0 ; i < xics->nr_servers; i++) { +ICPState *icp = &xics->ss[i]; + +if (!icp->output) { +continue ; + } +monitor_printf (mon,"CPU %d XIRR=%08x (%p) PP=%02x MFRR=%02x\n" , + i, icp->xirr, icp->xirr_owner, + icp->pending_priority, icp->mfrr); + } + + QLIST_FOREACH(ics, &xics->ics, list) { +monitor_printf (mon,"ICS %4x..%4x %p\n" , + ics->offset, ics->offset + ics->nr_irqs -1 , ics); + +if (!ics->irqs) { +continue ; + } + +for (i =0 ; i < ics->nr_irqs; i++) { +ICSIRQState *irq = ics->irqs + i; + +if (!(irq->flags &XICS_FLAGS_IRQ_MASK )) { +continue ; + } +monitor_printf (mon," %4x %s %02x %02x\n" , + ics->offset + i, + (irq->flags &XICS_FLAGS_IRQ_LSI ) ? +"LSI" :"MSI" , + irq->priority, irq->status); + } + } +} +/* * XICS Common class - parent for emulated XICS and KVM-XICS */
@@ -190,8 +233,10 @@ static void xics_common_initfn(Object *obj)static void xics_common_class_init (ObjectClass *oc,void *data) {DeviceClass *dc =DEVICE_CLASS (oc); +InterruptStatsProviderClass *ic =INTERRUPT_STATS_PROVIDER_CLASS (oc); dc->reset = xics_common_reset; + ic->print_info = xics_common_pic_print_info; }static const TypeInfo xics_common_info = {
@@ -201,6 +246,10 @@ static const TypeInfo xics_common_info = { .class_size = sizeof(XICSStateClass), .instance_init = xics_common_initfn, .class_init = xics_common_class_init, + .interfaces = (InterfaceInfo []) { + {TYPE_INTERRUPT_STATS_PROVIDER }, + { } + }, };/*
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 03/73] tests: fix memory leak in virtio-scsi-test
In reply to David GibsonFrom: Laurent Vivier <[email protected]>
vs is allocated in qvirtio_scsi_pci_init() and never freed.
--- tests/virtio-scsi-test.c | 1 + 1 file changed, 1 insertion(+)
tests/virtio-scsi-test.c +1 -0
@@ -64,6 +64,7 @@ static void qvirtio_scsi_pci_free(QVirtIOSCSI *vs)qvirtio_pci_device_disable (container_of (vs->dev, QVirtioPCIDevice, vdev));g_free (vs->dev);qpci_free_pc (vs->bus); +g_free (vs); } static uint64_t qvirtio_scsi_alloc(QVirtIOSCSI *vs, size_t alloc_size,
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 04/73] tests: don't check if qtest_spapr_boot() returns NULL
In reply to David GibsonFrom: Laurent Vivier <[email protected]>
qtest_spapr_boot()/qtest_pc_boot()/qtest_boot() call qtest_vboot() and qtest_vboot() calls g_malloc(),
and g_malloc() never fails:
if memory allocation fails, the application is terminated.
--- tests/libqos/libqos.c | 2 ++ tests/rtas-test.c | 1 - 2 files changed, 2 insertions(+), 1 deletion(-)
tests/libqos/libqos.c +2 -0
@@ -10,6 +10,8 @@/** * Launch QEMU with the given command line, * and then set up interrupts and our guest malloc interface. +* Never returns NULL: +* Terminates the application in case an error is encountered. */ QOSState *qtest_vboot (QOSOps *ops,const char *cmdline_fmt,va_list ap) {
tests/rtas-test.c +0 -1
@@ -14,7 +14,6 @@ static void test_rtas_get_time_of_day(void)time_t t1, t2; qs =qtest_spapr_boot ("-machine pseries" ); -g_assert (qs !=NULL ); t1 =time (NULL ); ret =qrtas_get_time_of_day (qs->alloc, &tm, &ns);
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 08/73] tests: enable virtio tests on SPAPR
In reply to David GibsonFrom: Laurent Vivier <[email protected]>
but disable MSI-X tests on SPAPR as we can't check the result (the memory region used on PC is not readable on SPAPR).
--- tests/Makefile.include | 3 ++- tests/libqos/virtio-pci.c | 24 ++++++++++++++++++++++-- tests/virtio-9p-test.c | 12 +++++++++++- tests/virtio-blk-test.c | 25 ++++++++++++++++++++----- tests/virtio-net-test.c | 18 ++++++++++++++++-- tests/virtio-rng-test.c | 7 ++++++- tests/virtio-scsi-test.c | 12 +++++++++++- 7 files changed, 88 insertions(+), 13 deletions(-)
tests/Makefile.include +2 -1
@@ -282,6 +282,7 @@ check-qtest-ppc64-y += tests/usb-hcd-uhci-test$(EXESUF) gcov-files-ppc64-y += hw/usb/hcd-uhci.c check-qtest-ppc64-y += tests/usb-hcd-xhci-test$(EXESUF) gcov-files-ppc64-y += hw/usb/hcd-xhci.c +check-qtest-ppc64-y += $(check-qtest-virtio-y) check-qtest-sh4-y = tests/endianness-test$(EXESUF)
@@ -615,7 +616,7 @@ libqos-pc-obj-y += tests/libqos/ahci.o libqos-omap-obj-y = $(libqos-obj-y) tests/libqos/i2c-omap.o libqos-imx-obj-y = $(libqos-obj-y) tests/libqos/i2c-imx.o libqos-usb-obj-y = $(libqos-spapr-obj-y) $(libqos-pc-obj-y) tests/libqos/usb.o -libqos-virtio-obj-y = $(libqos-pc-obj-y) tests/libqos/virtio.o tests/libqos/virtio-pci.o tests/libqos/virtio-mmio.o tests/libqos/malloc-generic.o +libqos-virtio-obj-y = $(libqos-spapr-obj-y) $(libqos-pc-obj-y) tests/libqos/virtio.o tests/libqos/virtio-pci.o tests/libqos/virtio-mmio.o tests/libqos/malloc-generic.o tests/device-introspect-test$(EXESUF): tests/device-introspect-test.o tests/rtc-test$(EXESUF): tests/rtc-test.o
tests/libqos/virtio-pci.c +22 -2
@@ -68,16 +68,36 @@ static uint8_t qvirtio_pci_config_readb(QVirtioDevice *d, uint64_t addr)return qpci_io_readb (dev->pdev, (void *)(uintptr_t )addr); } +/* PCI is always read in little-endian order +* but virtio ( < 1.0) is in guest order +* so with a big-endian guest the order has been reversed, +* reverse it again +* virtio-1.0 is always little-endian, like PCI, but this +* case will be managed inside qvirtio_is_big_endian() +*/ +static uint16_t qvirtio_pci_config_readw (QVirtioDevice *d,uint64_t addr) {QVirtioPCIDevice *dev = (QVirtioPCIDevice *)d; -return qpci_io_readw (dev->pdev, (void *)(uintptr_t )addr); +uint16_t value; + + value =qpci_io_readw (dev->pdev, (void *)(uintptr_t )addr); +if (qvirtio_is_big_endian (d)) { + value =bswap16 (value); + } +return value; }static uint32_t qvirtio_pci_config_readl (QVirtioDevice *d,uint64_t addr) {QVirtioPCIDevice *dev = (QVirtioPCIDevice *)d; -return qpci_io_readl (dev->pdev, (void *)(uintptr_t )addr); +uint32_t value; + + value =qpci_io_readl (dev->pdev, (void *)(uintptr_t )addr); +if (qvirtio_is_big_endian (d)) { + value =bswap32 (value); + } +return value; }static uint64_t qvirtio_pci_config_readq (QVirtioDevice *d,uint64_t addr)
tests/virtio-9p-test.c +11 -1
@@ -11,6 +11,7 @@#include "libqtest.h" #include "qemu-common.h" #include "libqos/libqos-pc.h" +#include "libqos/libqos-spapr.h" #include "libqos/virtio.h" #include "libqos/virtio-pci.h" #include "standard-headers/linux/virtio_ids.h"
@@ -22,13 +23,22 @@ static char *test_share;static QOSState *qvirtio_9p_start (void ) { +const char *arch =qtest_get_arch ();const char *cmd ="-fsdev local,id=fsdev0,security_model=none,path=%s " "-device virtio-9p-pci,fsdev=fsdev0,mount_tag=%s" ; test_share =g_strdup ("/tmp/qtest.XXXXXX" );g_assert_nonnull (mkdtemp (test_share)); -return qtest_pc_boot (cmd, test_share, mount_tag); +if (strcmp (arch,"i386" ) ==0 ||strcmp (arch,"x86_64" ) ==0 ) { +return qtest_pc_boot (cmd, test_share, mount_tag); + } +if (strcmp (arch,"ppc64" ) ==0 ) { +return qtest_spapr_boot (cmd, test_share, mount_tag); + } + +g_printerr ("virtio-9p tests are only available on x86 or ppc64\n" ); +exit (EXIT_FAILURE ); }static void qvirtio_9p_stop (QOSState *qs)
tests/virtio-blk-test.c +20 -5
@@ -11,6 +11,7 @@#include "qemu/osdep.h" #include "libqtest.h" #include "libqos/libqos-pc.h" +#include "libqos/libqos-spapr.h" #include "libqos/virtio.h" #include "libqos/virtio-pci.h" #include "libqos/virtio-mmio.h"
@@ -59,6 +60,7 @@ static char *drive_create(void)static QOSState *pci_test_start (void ) {QOSState *qs; +const char *arch =qtest_get_arch ();char *tmp_path;const char *cmd ="-drive if=none,id=drive0,file=%s,format=raw " "-drive if=none,id=drive1,file=/dev/null,format=raw "
@@ -67,7 +69,14 @@ static QOSState *pci_test_start(void) tmp_path =drive_create (); - qs =qtest_pc_boot (cmd, tmp_path,PCI_SLOT ,PCI_FN ); +if (strcmp (arch,"i386" ) ==0 ||strcmp (arch,"x86_64" ) ==0 ) { + qs =qtest_pc_boot (cmd, tmp_path,PCI_SLOT ,PCI_FN ); + }else if (strcmp (arch,"ppc64" ) ==0 ) { + qs =qtest_spapr_boot (cmd, tmp_path,PCI_SLOT ,PCI_FN ); + }else { +g_printerr ("virtio-blk tests are only available on x86 or ppc64\n" ); +exit (EXIT_FAILURE ); + }unlink (tmp_path);g_free (tmp_path);return qs;
@@ -659,6 +668,7 @@ static void pci_hotplug(void) {QVirtioPCIDevice *dev;QOSState *qs; +const char *arch =qtest_get_arch (); qs =pci_test_start ();
@@ -672,7 +682,9 @@ static void pci_hotplug(void)g_free (dev);/* unplug secondary disk */ -qpci_unplug_acpi_device_test ("drv1" ,PCI_SLOT_HP ); +if (strcmp (arch,"i386" ) ==0 ||strcmp (arch,"x86_64" ) ==0 ) { +qpci_unplug_acpi_device_test ("drv1" ,PCI_SLOT_HP ); + }qtest_shutdown (qs); }
@@ -720,12 +732,15 @@ int main(int argc, char **argv)g_test_init (&argc, &argv,NULL ); -if (strcmp (arch,"i386" ) ==0 ||strcmp (arch,"x86_64" ) ==0 ) { +if (strcmp (arch,"i386" ) ==0 ||strcmp (arch,"x86_64" ) ==0 || +strcmp (arch,"ppc64" ) ==0 ) {qtest_add_func ("/virtio/blk/pci/basic" , pci_basic);qtest_add_func ("/virtio/blk/pci/indirect" , pci_indirect);qtest_add_func ("/virtio/blk/pci/config" , pci_config); -qtest_add_func ("/virtio/blk/pci/msix" , pci_msix); -qtest_add_func ("/virtio/blk/pci/idx" , pci_idx); +if (strcmp (arch,"i386" ) ==0 ||strcmp (arch,"x86_64" ) ==0 ) { +qtest_add_func ("/virtio/blk/pci/msix" , pci_msix); +qtest_add_func ("/virtio/blk/pci/idx" , pci_idx); + }qtest_add_func ("/virtio/blk/pci/hotplug" , pci_hotplug); }else if (strcmp (arch,"arm" ) ==0 ) {qtest_add_func ("/virtio/blk/mmio/basic" , mmio_basic);
tests/virtio-net-test.c +16 -2
@@ -13,6 +13,7 @@#include "qemu/sockets.h" #include "qemu/iov.h" #include "libqos/libqos-pc.h" +#include "libqos/libqos-spapr.h" #include "libqos/virtio.h" #include "libqos/virtio-pci.h" #include "qemu/bswap.h"
@@ -52,10 +53,18 @@ static QVirtioPCIDevice *virtio_net_pci_init(QPCIBus *bus, int slot)static QOSState *pci_test_start (int socket) { +const char *arch =qtest_get_arch ();const char *cmd ="-netdev socket,fd=%d,id=hs0 -device " "virtio-net-pci,netdev=hs0" ; -return qtest_pc_boot (cmd, socket); +if (strcmp (arch,"i386" ) ==0 ||strcmp (arch,"x86_64" ) ==0 ) { +return qtest_pc_boot (cmd, socket); + } +if (strcmp (arch,"ppc64" ) ==0 ) { +return qtest_spapr_boot (cmd, socket); + } +g_printerr ("virtio-net tests are only available on x86 or ppc64\n" ); +exit (EXIT_FAILURE ); }static void driver_init (QVirtioDevice *dev)
@@ -232,10 +241,15 @@ static void pci_basic(gconstpointer data)static void hotplug (void ) { +const char *arch =qtest_get_arch (); +qtest_start ("-device virtio-net-pci" );qpci_plug_device_test ("virtio-net-pci" ,"net1" ,PCI_SLOT_HP ,NULL ); -qpci_unplug_acpi_device_test ("net1" ,PCI_SLOT_HP ); + +if (strcmp (arch,"i386" ) ==0 ||strcmp (arch,"x86_64" ) ==0 ) { +qpci_unplug_acpi_device_test ("net1" ,PCI_SLOT_HP ); + }test_end (); }
tests/virtio-rng-test.c +6 -1
@@ -20,8 +20,13 @@ static void pci_nop(void)static void hotplug (void ) { +const char *arch =qtest_get_arch (); +qpci_plug_device_test ("virtio-rng-pci" ,"rng1" ,PCI_SLOT_HP ,NULL ); -qpci_unplug_acpi_device_test ("rng1" ,PCI_SLOT_HP ); + +if (strcmp (arch,"i386" ) ==0 ||strcmp (arch,"x86_64" ) ==0 ) { +qpci_unplug_acpi_device_test ("rng1" ,PCI_SLOT_HP ); + } }int main (int argc,char **argv)
tests/virtio-scsi-test.c +11 -1
@@ -12,6 +12,7 @@#include "libqtest.h" #include "block/scsi.h" #include "libqos/libqos-pc.h" +#include "libqos/libqos-spapr.h" #include "libqos/virtio.h" #include "libqos/virtio-pci.h" #include "standard-headers/linux/virtio_ids.h"
@@ -33,11 +34,20 @@ typedef struct {static QOSState *qvirtio_scsi_start (const char *extra_opts) { +const char *arch =qtest_get_arch ();const char *cmd ="-drive id=drv0,if=none,file=/dev/null,format=raw " "-device virtio-scsi-pci,id=vs0 " "-device scsi-hd,bus=vs0.0,drive=drv0 %s" ; -return qtest_pc_boot (cmd, extra_opts ? :"" ); +if (strcmp (arch,"i386" ) ==0 ||strcmp (arch,"x86_64" ) ==0 ) { +return qtest_pc_boot (cmd, extra_opts ? :"" ); + } +if (strcmp (arch,"ppc64" ) ==0 ) { +return qtest_spapr_boot (cmd, extra_opts ? :"" ); + } + +g_printerr ("virtio-scsi tests are only available on x86 or ppc64\n" ); +exit (EXIT_FAILURE ); }static void qvirtio_scsi_stop (QOSState *qs)
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 09/73] spapr_pci: advertise explicit numa IDs even when there's 1 node
In reply to David GibsonFrom: Michael Roth <[email protected]>
With the addition of "numa_node" properties for PHBs we began advertising NUMA affinity in cases where nb_numa_nodes > 1.
Since the default on the guest side is to make no assumptions about PHB NUMA affinity (defaulting to -1), there is still a valid use-case for explicitly defining a PHB's NUMA affinity even when there's just one node. In particular, some workloads make faulty assumptions about /sys/bus/pci/<devid>/numa_node being >= 0, warranting the use of this property as a workaround even if there's just 1 PHB or NUMA node.
Enable this use-case by always advertising the PHB's NUMA affinity if "numa_node" has been explicitly set.
We could achieve this by relaxing the check to simply be nb_numa_nodes > 0, but even safer would be to check numa_info[nodeid].present explicitly, and to fail at start time for cases where it does not exist.
This has an additional affect of no longer advertising PHB NUMA affinity unconditionally if nb_numa_nodes > 1 and "numa_node" property is unset/-1, but since the default value on the guest side for each PHB is also -1, the behavior should be the same for that situation. We could still retain the old behavior if desired, but the decision seems arbitrary, so we take the simpler route.
--- hw/ppc/spapr_pci.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
hw/ppc/spapr_pci.c +7 -1
@@ -1392,6 +1392,12 @@ static void spapr_phb_realize(DeviceState *dev, Error **errp)return ; } +if (sphb->numa_node !=-1 && + (sphb->numa_node >=MAX_NODES || !numa_info[sphb->numa_node].present)) { +error_setg (errp,"Invalid NUMA node ID for PCI host bridge" ); +return ; + } + sphb->dtbusname =g_strdup_printf ("pci@%" PRIx64, sphb->buid); namebuf =alloca (strlen (sphb->dtbusname) +32 );
@@ -1880,7 +1886,7 @@ int spapr_populate_pci_dt(sPAPRPHBState *phb, }/* Advertise NUMA via ibm,associativity */ -if (nb_numa_nodes >1 ) { +if (phb->numa_node !=-1 ) {_FDT (fdt_setprop (fdt, bus_off,"ibm,associativity" , associativity,sizeof (associativity))); }
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 19/73] ppc: fix MSR_ME handling for system reset interrupt
In reply to David GibsonFrom: Nicholas Piggin <[email protected]>
Power ISA specifies ME bit handling for system reset interrupt:
if the interrupt occurred while the thread was in power-saving mode, set to 1; otherwise not altered
Power ISA 3.0, section 6.5 "Interrupt Definitions", Figure 64.
--- target-ppc/excp_helper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
target-ppc/excp_helper.c +2 -2
@@ -385,11 +385,11 @@ static inline void powerpc_excp(PowerPCCPU *cpu, int excp_model, int excp) srr1 =SPR_BOOKE_CSRR1 ;break ;case POWERPC_EXCP_RESET :/* System reset exception */ +/* A power-saving exception sets ME, otherwise it is unchanged */ if (msr_pow) {/* indicate that we resumed from power save mode */ msr |=0x10000 ; - }else { - new_msr &= ~((target_ulong )1 <<MSR_ME ); + new_msr |= ((target_ulong )1 <<MSR_ME ); } new_msr |= (target_ulong )MSR_HVB ;
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 24/73] ppc/pnv: add skeleton PowerNV platform
In reply to David GibsonFrom: Benjamin Herrenschmidt <[email protected]>
The goal is to emulate a PowerNV system at the level of the skiboot firmware, which loads the OS and provides some runtime services. Power Systems have a lower firmware (HostBoot) that does low level system initialization, like DRAM training. This is beyond the scope of what qemu will address in a PowerNV guest.
No devices yet, not even an interrupt controller. Just to get started, some RAM to load the skiboot firmware, the kernel and initrd. The device tree is fully created in the machine reset op.
[clg: - updated for qemu-2.7
- replaced fprintf by error_report
- used a common definition of _FDT macro
- removed VMStateDescription as migration is not yet supported
- added IBM Copyright statements
- reworked kernel_filename handling
- merged PnvSystem and sPowerNVMachineState
- removed PHANDLE_XICP
- added ppc_create_page_sizes_prop helper
- removed nmi support
- removed kvm support
- updated powernv machine to version 2.8
- removed chips and cpus, They will be provided in another patches
- added a machine reset routine to initialize the device tree (also)
- french has a squelette and english a skeleton.
- improved commit log.
- reworked prototypes parameters
- added a check on the ram size (thanks to Michael Ellerman)
- fixed chip-id cell
- changed MAX_CPUS to 2048
- simplified memory node creation to one node only
- removed machine version
- rewrote the device tree creation with the fdt "rw" routines
- s/sPowerNVMachineState/PnvMachineState/
- etc.]
--- default-configs/ppc64-softmmu.mak | 1 + hw/ppc/Makefile.objs | 2 + hw/ppc/pnv.c | 226 ++++++++++++++++++++++++++++++++++++++ include/hw/ppc/pnv.h | 38 +++++++ 4 files changed, 267 insertions(+) create mode 100644 hw/ppc/pnv.c create mode 100644 include/hw/ppc/pnv.h
default-configs/ppc64-softmmu.mak +1 -0
@@ -39,6 +39,7 @@ CONFIG_I8259=y CONFIG_XILINX=y CONFIG_XILINX_ETHLITE=y CONFIG_PSERIES=y +CONFIG_POWERNV=y CONFIG_PREP=y CONFIG_MAC=y CONFIG_E500=y
hw/ppc/Makefile.objs +2 -0
@@ -5,6 +5,8 @@ obj-$(CONFIG_PSERIES) += spapr.o spapr_vio.o spapr_events.o obj-$(CONFIG_PSERIES) += spapr_hcall.o spapr_iommu.o spapr_rtas.o obj-$(CONFIG_PSERIES) += spapr_pci.o spapr_rtc.o spapr_drc.o spapr_rng.o obj-$(CONFIG_PSERIES) += spapr_cpu_core.o +# IBM PowerNV +obj-$(CONFIG_POWERNV) += pnv.o ifeq ($(CONFIG_PCI)$(CONFIG_PSERIES)$(CONFIG_LINUX), yyy) obj-y += spapr_pci_vfio.o endif
hw/ppc/pnv.c new file +226 -0
226 lines not on this page · raw message
include/hw/ppc/pnv.h new file +38 -0
@@ -0,0 +1,38 @@ +/* +* QEMU PowerPC PowerNV various definitions +* +* Copyright (c) 2014-2016 BenH, IBM Corporation. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, see <http://www.gnu.org/licenses/>. +*/ +#ifndef _PPC_PNV_H +#define _PPC_PNV_H + +#include "hw/boards.h" + +#define TYPE_POWERNV_MACHINE MACHINE_TYPE_NAME("powernv") +#define POWERNV_MACHINE (obj) \ + OBJECT_CHECK(PnvMachineState, (obj), TYPE_POWERNV_MACHINE) + +typedef struct PnvMachineState { +/*< private >*/ +MachineState parent_obj; + +uint32_t initrd_base; +long initrd_size; +}PnvMachineState ; + +#define PNV_FDT_ADDR 0x01000000 + +#endif /* _PPC_PNV_H */
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 10/73] nvram: Introduce helper functions for CHRP "system" and "free space" partitions
In reply to David GibsonFrom: Thomas Huth <[email protected]>
The "system partition" and "free space" partition layouts are defined by the CHRP and LoPAPR specification, and used by OpenBIOS and SLOF. We can re-use this code for other machines that use OpenBIOS and SLOF, too. So let's make this code independent from the MAC NVRAM environment and put it into two proper helper functions.
--- hw/nvram/Makefile.objs | 1 + hw/nvram/chrp_nvram.c | 76 +++++++++++++++++++++++++++++++++++++++++++ hw/nvram/mac_nvram.c | 40 +++++------------------ include/hw/nvram/chrp_nvram.h | 24 ++++++++++++++ 4 files changed, 109 insertions(+), 32 deletions(-) create mode 100644 hw/nvram/chrp_nvram.c create mode 100644 include/hw/nvram/chrp_nvram.h
hw/nvram/Makefile.objs +1 -0
@@ -1,5 +1,6 @@ common-obj-$(CONFIG_DS1225Y) += ds1225y.o common-obj-y += eeprom93xx.o common-obj-y += fw_cfg.o +common-obj-y += chrp_nvram.o common-obj-$(CONFIG_MAC_NVRAM) += mac_nvram.o obj-$(CONFIG_PSERIES) += spapr_nvram.o
hw/nvram/chrp_nvram.c new file +76 -0
76 lines not on this page · raw message
hw/nvram/mac_nvram.c +8 -32
@@ -25,7 +25,7 @@#include "qemu/osdep.h" #include "hw/hw.h" #include "hw/nvram/openbios_firmware_abi.h" -#include "sysemu/sysemu.h" +#include "hw/nvram/chrp_nvram.h" #include "hw/ppc/mac.h" #include "qemu/cutils.h" #include <zlib.h>
@@ -146,38 +146,14 @@ static void macio_nvram_register_types(void)static void pmac_format_nvram_partition_of (MacIONVRAMState *nvr,int off,int len) { -unsigned int i; -uint32_t start = off, end; -struct OpenBIOS_nvpart_v1 *part_header; +int sysp_end; + +/* OpenBIOS nvram variables partition */ + sysp_end =chrp_nvram_create_system_partition (&nvr->data[off], +DEF_SYSTEM_SIZE ) + off; -// OpenBIOS nvram variables -// Variable partition - part_header = (struct OpenBIOS_nvpart_v1 *)&nvr->data[start]; - part_header->signature =OPENBIOS_PART_SYSTEM ; -pstrcpy (part_header->name,sizeof (part_header->name),"system" ); - - end = start +sizeof (struct OpenBIOS_nvpart_v1 ); -for (i =0 ; i < nb_prom_envs; i++) - end =OpenBIOS_set_var (nvr->data, end, prom_envs[i]); - -// End marker - nvr->data[end++] ='\0' ; - - end = start + ((end - start +15 ) & ~15 ); -/* XXX: OpenBIOS is not able to grow up a partition. Leave some space for -new variables. */ -if (end <DEF_SYSTEM_SIZE ) - end =DEF_SYSTEM_SIZE ; -OpenBIOS_finish_partition (part_header, end - start); - -// free partition - start = end; - part_header = (struct OpenBIOS_nvpart_v1 *)&nvr->data[start]; - part_header->signature =OPENBIOS_PART_FREE ; -pstrcpy (part_header->name,sizeof (part_header->name),"free" ); - - end = len; -OpenBIOS_finish_partition (part_header, end - start); +/* Free space partition */ +chrp_nvram_create_free_partition (&nvr->data[sysp_end], len - sysp_end); }#define OSX_NVRAM_SIGNATURE (0x5A)
include/hw/nvram/chrp_nvram.h new file +24 -0
@@ -0,0 +1,24 @@ +/* +* Common Hardware Reference Platform NVRAM functions. +* +* This code is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published +* by the Free Software Foundation; either version 2 of the License, +* or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef CHRP_NVRAM_H +#define CHRP_NVRAM_H + +int chrp_nvram_create_system_partition (uint8_t *data,int min_len); +int chrp_nvram_create_free_partition (uint8_t *data,int len); + +#endif
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 26/73] ppc/pnv: add a core mask to PnvChip
In reply to David GibsonFrom: Cédric Le Goater <[email protected]>
This will be used to build real HW ids for the cores and enforce some limits on the available cores per chip.
--- hw/ppc/pnv.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++- include/hw/ppc/pnv.h | 4 +++ 2 files changed, 76 insertions(+), 1 deletion(-)
hw/ppc/pnv.c +72 -1
@@ -238,11 +238,38 @@ static void ppc_powernv_init(MachineState *machine)object_property_add_child (OBJECT (pnv), chip_name, chip, &error_fatal);object_property_set_int (chip,PNV_CHIP_HWID (i),"chip-id" , &error_fatal); +object_property_set_int (chip, smp_cores,"nr-cores" , &error_fatal);object_property_set_bool (chip, true,"realized" , &error_fatal); }g_free (chip_typename); } +/* Allowed core identifiers on a POWER8 Processor Chip : +* +* <EX0 reserved> +* EX1 - Venice only +* EX2 - Venice only +* EX3 - Venice only +* EX4 +* EX5 +* EX6 +* <EX7,8 reserved> <reserved> +* EX9 - Venice only +* EX10 - Venice only +* EX11 - Venice only +* EX12 +* EX13 +* EX14 +* <EX15 reserved> +*/ +#define POWER8E_CORE_MASK (0x7070ull) +#define POWER8_CORE_MASK (0x7e7eull) + +/* +* POWER9 has 24 cores, ids starting at 0x20 +*/ +#define POWER9_CORE_MASK (0xffffff00000000ull) +static void pnv_chip_power8e_class_init (ObjectClass *klass,void *data) {DeviceClass *dc =DEVICE_CLASS (klass);
@@ -251,6 +278,7 @@ static void pnv_chip_power8e_class_init(ObjectClass *klass, void *data) k->cpu_model ="POWER8E" ; k->chip_type =PNV_CHIP_POWER8E ; k->chip_cfam_id =0x221ef04980000000ull ;/* P8 Murano DD2.1 */ + k->cores_mask =POWER8E_CORE_MASK ; dc->desc ="PowerNV Chip POWER8E" ; }
@@ -269,6 +297,7 @@ static void pnv_chip_power8_class_init(ObjectClass *klass, void *data) k->cpu_model ="POWER8" ; k->chip_type =PNV_CHIP_POWER8 ; k->chip_cfam_id =0x220ea04980000000ull ;/* P8 Venice DD2.0 */ + k->cores_mask =POWER8_CORE_MASK ; dc->desc ="PowerNV Chip POWER8" ; }
@@ -287,6 +316,7 @@ static void pnv_chip_power8nvl_class_init(ObjectClass *klass, void *data) k->cpu_model ="POWER8NVL" ; k->chip_type =PNV_CHIP_POWER8NVL ; k->chip_cfam_id =0x120d304980000000ull ;/* P8 Naples DD1.0 */ + k->cores_mask =POWER8_CORE_MASK ; dc->desc ="PowerNV Chip POWER8NVL" ; }
@@ -305,6 +335,7 @@ static void pnv_chip_power9_class_init(ObjectClass *klass, void *data) k->cpu_model ="POWER9" ; k->chip_type =PNV_CHIP_POWER9 ; k->chip_cfam_id =0x100d104980000000ull ;/* P9 Nimbus DD1.0 */ + k->cores_mask =POWER9_CORE_MASK ; dc->desc ="PowerNV Chip POWER9" ; }
@@ -315,15 +346,55 @@ static const TypeInfo pnv_chip_power9_info = { .class_init = pnv_chip_power9_class_init, }; +static void pnv_chip_core_sanitize (PnvChip *chip,Error **errp) +{ +PnvChipClass *pcc =PNV_CHIP_GET_CLASS (chip); +int cores_max; + +/* +* No custom mask for this chip, let's use the default one from * +* the chip class +*/ +if (!chip->cores_mask) { + chip->cores_mask = pcc->cores_mask; + } + +/* filter alien core ids ! some are reserved */ +if ((chip->cores_mask & pcc->cores_mask) != chip->cores_mask) { +error_setg (errp,"warning: invalid core mask for chip Ox%" PRIx64" !" , + chip->cores_mask); +return ; + } + chip->cores_mask &= pcc->cores_mask; + +/* now that we have a sane layout, let check the number of cores */ + cores_max =hweight_long (chip->cores_mask); +if (chip->nr_cores > cores_max) { +error_setg (errp,"warning: too many cores for chip ! Limit is %d" , + cores_max); +return ; + } +} +static void pnv_chip_realize (DeviceState *dev,Error **errp) { -/* left purposely empty */ +PnvChip *chip =PNV_CHIP (dev); +Error *error =NULL ; + +/* Early checks on the core settings */ +pnv_chip_core_sanitize (chip, &error); +if (error) { +error_propagate (errp, error); +return ; + } }static Property pnv_chip_properties[] = {DEFINE_PROP_UINT32 ("chip-id" , PnvChip, chip_id,0 ),DEFINE_PROP_UINT64 ("ram-start" , PnvChip, ram_start,0 ),DEFINE_PROP_UINT64 ("ram-size" , PnvChip, ram_size,0 ), +DEFINE_PROP_UINT32 ("nr-cores" , PnvChip, nr_cores,1 ), +DEFINE_PROP_UINT64 ("cores-mask" , PnvChip, cores_mask,0x0 ),DEFINE_PROP_END_OF_LIST (), };
include/hw/ppc/pnv.h +4 -0
@@ -44,6 +44,9 @@ typedef struct PnvChip {uint32_t chip_id;uint64_t ram_start;uint64_t ram_size; + +uint32_t nr_cores; +uint64_t cores_mask; } PnvChip; typedef struct PnvChipClass {
@@ -54,6 +57,7 @@ typedef struct PnvChipClass {const char *cpu_model;PnvChipType chip_type;uint64_t chip_cfam_id; +uint64_t cores_mask; } PnvChipClass;#define TYPE_PNV_CHIP_POWER8E TYPE_PNV_CHIP "-POWER8E"
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 15/73] target-ppc: implement xxbr[qdwh] instruction
In reply to David GibsonFrom: Nikunj A Dadhania <[email protected]>
Add required helpers (GEN_XX2FORM_EO) for supporting this instruction.
xxbrh: VSX Vector Byte-Reverse Halfword
xxbrw: VSX Vector Byte-Reverse Word
xxbrd: VSX Vector Byte-Reverse Doubleword
xxbrq: VSX Vector Byte-Reverse Quadword
--- target-ppc/translate.c | 32 +++++++++++++++ target-ppc/translate/vsx-impl.inc.c | 77 +++++++++++++++++++++++++++++++++++++ target-ppc/translate/vsx-ops.inc.c | 8 ++++ 3 files changed, 117 insertions(+)
target-ppc/translate.c +32 -0
@@ -376,6 +376,9 @@ GEN_OPCODE2(name, onam, opc1, opc2, opc3, inval, type, type2)#define GEN_HANDLER_E_2 (name, opc1, opc2, opc3, opc4, inval, type, type2) \ GEN_OPCODE3(name, opc1, opc2, opc3, opc4, inval, type, type2) +#define GEN_HANDLER2_E_2 (name, onam, opc1, opc2, opc3, opc4, inval, typ, typ2) \ +GEN_OPCODE4(name, onam, opc1, opc2, opc3, opc4, inval, typ, typ2) + typedef struct opcode_t { unsigned char opc1, opc2, opc3, opc4; #if HOST_LONG_BITS == 64 /* Explicitly align to 64 bits */
@@ -662,6 +665,21 @@ EXTRACT_HELPER(IMM8, 11, 8); }, \ .oname = stringify(name), \ } +#define GEN_OPCODE4 (name, onam, op1, op2, op3, op4, invl, _typ, _typ2) \ +{ \ + .opc1 = op1, \ + .opc2 = op2, \ + .opc3 = op3, \ + .opc4 = op4, \ + .handler = { \ + .inval1 = invl, \ + .type = _typ, \ + .type2 = _typ2, \ + .handler = &gen_##name, \ + .oname = onam, \ + }, \ + .oname = onam, \ +}#else #define GEN_OPCODE (name, op1, op2, op3, invl, _typ, _typ2) \ { \
@@ -720,6 +738,20 @@ EXTRACT_HELPER(IMM8, 11, 8); }, \ .oname = stringify(name), \ } +#define GEN_OPCODE4 (name, onam, op1, op2, op3, op4, invl, _typ, _typ2) \ +{ \ + .opc1 = op1, \ + .opc2 = op2, \ + .opc3 = op3, \ + .opc4 = op4, \ + .handler = { \ + .inval1 = invl, \ + .type = _typ, \ + .type2 = _typ2, \ + .handler = &gen_##name, \ + }, \ + .oname = onam, \ +}#endif /* SPR load/store helpers */
target-ppc/translate/vsx-impl.inc.c +77 -0
89 lines not on this page · raw message
target-ppc/translate/vsx-ops.inc.c +8 -0
@@ -39,6 +39,10 @@ GEN_HANDLER2_E(name, #name, 0x3C, opc2 | 1, opc3, 0, PPC_NONE, fl2) GEN_HANDLER2_E(name, #name, 0x3C, opc2 | 0, opc3, 0, PPC_NONE, fl2), \ GEN_HANDLER2_E(name, #name, 0x3C, opc2 | 1, opc3, 0, PPC_NONE, fl2) +#define GEN_XX2FORM_EO (name, opc2, opc3, opc4, fl2) \ +GEN_HANDLER2_E_2(name, #name, 0x3C, opc2 | 0, opc3, opc4, 0, PPC_NONE, fl2), \ +GEN_HANDLER2_E_2(name, #name, 0x3C, opc2 | 1, opc3, opc4, 0, PPC_NONE, fl2) +#define GEN_XX3FORM (name, opc2, opc3, fl2) \ GEN_HANDLER2_E(name, #name, 0x3C, opc2 | 0, opc3, 0, PPC_NONE, fl2), \ GEN_HANDLER2_E(name, #name, 0x3C, opc2 | 1, opc3, 0, PPC_NONE, fl2), \
@@ -222,6 +226,10 @@ GEN_XX2FORM(xvrspic, 0x16, 0x0A, PPC2_VSX),GEN_XX2FORM (xvrspim,0x12 ,0x0B ,PPC2_VSX ),GEN_XX2FORM (xvrspip,0x12 ,0x0A ,PPC2_VSX ),GEN_XX2FORM (xvrspiz,0x12 ,0x09 ,PPC2_VSX ), +GEN_XX2FORM_EO (xxbrh,0x16 ,0x1D ,0x07 ,PPC2_ISA300 ), +GEN_XX2FORM_EO (xxbrw,0x16 ,0x1D ,0x0F ,PPC2_ISA300 ), +GEN_XX2FORM_EO (xxbrd,0x16 ,0x1D ,0x17 ,PPC2_ISA300 ), +GEN_XX2FORM_EO (xxbrq,0x16 ,0x1D ,0x1F ,PPC2_ISA300 ), #define VSX_LOGICAL(name, opc2, opc3, fl2) \GEN_XX3FORM (name, opc2, opc3, fl2)
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 06/73] tests: rename target_big_endian() as qvirtio_is_big_endian()
In reply to David GibsonFrom: Laurent Vivier <[email protected]>
Move the definition to libqos/virtio.h as it must be used only with virtio functions.
Add a QVirtioDevice parameter as it will be needed to know if the virtio device is using virtio 1.0 specification and thus is always little-endian (to do)
--- tests/libqos/virtio-pci.c | 2 +- tests/libqos/virtio.h | 6 ++++++ tests/libqtest.h | 10 ---------- tests/virtio-blk-test.c | 36 ++++++++++++++++++------------------ 4 files changed, 25 insertions(+), 29 deletions(-)
tests/libqos/virtio-pci.c +1 -1
@@ -86,7 +86,7 @@ static uint64_t qvirtio_pci_config_readq(QVirtioDevice *d, uint64_t addr)int i;uint64_t u64 =0 ; -if (target_big_endian ()) { +if (qvirtio_is_big_endian (d)) {for (i =0 ; i <8 ; ++i) { u64 |= (uint64_t )qpci_io_readb (dev->pdev, (void *)(uintptr_t )addr + i) << (7 - i) *8 ;
tests/libqos/virtio.h +6 -0
@@ -89,6 +89,12 @@ struct QVirtioBus {void (*virtqueue_kick)(QVirtioDevice *d,QVirtQueue *vq); }; +static inline bool qvirtio_is_big_endian (QVirtioDevice *d) +{ +/* FIXME: virtio 1.0 is always little-endian */ +return qtest_big_endian (global_qtest); +} +static inline uint32_t qvring_size (uint32_t num,uint32_t align) { return ((sizeof(struct vring_desc) * num + sizeof(uint16_t) * (3 + num)
tests/libqtest.h +0 -10
@@ -881,16 +881,6 @@ static inline int64_t clock_set(int64_t val)return qtest_clock_set (global_qtest, val); } -/** -* target_big_endian: -* -* Returns: True if the architecture under test has a big endian configuration. -*/ -static inline bool target_big_endian (void ) -{ -return qtest_big_endian (global_qtest); -} -QDict *qmp_fd_receive (int fd);void qmp_fd_sendv (int fd,const char *fmt,va_list ap);void qmp_fd_send (int fd,const char *fmt, ...);
tests/virtio-blk-test.c +18 -18
@@ -117,23 +117,23 @@ static QVirtioPCIDevice *virtio_blk_pci_init(QPCIBus *bus, int slot)return dev; } -static inline void virtio_blk_fix_request (QVirtioBlkReq *req) +static inline void virtio_blk_fix_request (QVirtioDevice *d,QVirtioBlkReq *req) {#ifdef HOST_WORDS_BIGENDIAN -bool host_endian = true; +const bool host_is_big_endian = true;#else -bool host_endian = false; +const bool host_is_big_endian = false;#endif -if (target_big_endian () != host_endian) { +if (qvirtio_is_big_endian (d) != host_is_big_endian) { req->type =bswap32 (req->type); req->ioprio =bswap32 (req->ioprio); req->sector =bswap64 (req->sector); } } -static uint64_t virtio_blk_request (QGuestAllocator *alloc,QVirtioBlkReq *req, -uint64_t data_size) +static uint64_t virtio_blk_request (QGuestAllocator *alloc,QVirtioDevice *d, +QVirtioBlkReq *req,uint64_t data_size) {uint64_t addr;uint8_t status =0xFF ;
@@ -141,7 +141,7 @@ static uint64_t virtio_blk_request(QGuestAllocator *alloc, QVirtioBlkReq *req, g_assert_cmpuint(data_size % 512, ==, 0); addr =guest_alloc (alloc,sizeof (*req) + data_size); -virtio_blk_fix_request (req); +virtio_blk_fix_request (d, req);memwrite (addr, req,16 );memwrite (addr +16 , req->data, data_size);
@@ -182,7 +182,7 @@ static void test_basic(QVirtioDevice *dev, QGuestAllocator *alloc, req.data =g_malloc0 (512 );strcpy (req.data,"TEST" ); - req_addr =virtio_blk_request (alloc, &req,512 ); + req_addr =virtio_blk_request (alloc, dev, &req,512 );g_free (req.data);
@@ -204,7 +204,7 @@ static void test_basic(QVirtioDevice *dev, QGuestAllocator *alloc, req.sector =0 ; req.data =g_malloc0 (512 ); - req_addr =virtio_blk_request (alloc, &req,512 ); + req_addr =virtio_blk_request (alloc, dev, &req,512 );g_free (req.data);
@@ -234,7 +234,7 @@ static void test_basic(QVirtioDevice *dev, QGuestAllocator *alloc, req.data =g_malloc0 (512 );strcpy (req.data,"TEST" ); - req_addr =virtio_blk_request (alloc, &req,512 ); + req_addr =virtio_blk_request (alloc, dev, &req,512 );g_free (req.data);
@@ -254,7 +254,7 @@ static void test_basic(QVirtioDevice *dev, QGuestAllocator *alloc, req.sector =1 ; req.data =g_malloc0 (512 ); - req_addr =virtio_blk_request (alloc, &req,512 ); + req_addr =virtio_blk_request (alloc, dev, &req,512 );g_free (req.data);
@@ -348,7 +348,7 @@ static void pci_indirect(void) req.data =g_malloc0 (512 );strcpy (req.data,"TEST" ); - req_addr =virtio_blk_request (alloc, &req,512 ); + req_addr =virtio_blk_request (alloc, &dev->vdev, &req,512 );g_free (req.data);
@@ -373,7 +373,7 @@ static void pci_indirect(void) req.data =g_malloc0 (512 );strcpy (req.data,"TEST" ); - req_addr =virtio_blk_request (alloc, &req,512 ); + req_addr =virtio_blk_request (alloc, &dev->vdev, &req,512 );g_free (req.data);
@@ -495,7 +495,7 @@ static void pci_msix(void) req.data =g_malloc0 (512 );strcpy (req.data,"TEST" ); - req_addr =virtio_blk_request (alloc, &req,512 ); + req_addr =virtio_blk_request (alloc, &dev->vdev, &req,512 );g_free (req.data);
@@ -518,7 +518,7 @@ static void pci_msix(void) req.sector =0 ; req.data =g_malloc0 (512 ); - req_addr =virtio_blk_request (alloc, &req,512 ); + req_addr =virtio_blk_request (alloc, &dev->vdev, &req,512 );g_free (req.data);
@@ -600,7 +600,7 @@ static void pci_idx(void) req.data =g_malloc0 (512 );strcpy (req.data,"TEST" ); - req_addr =virtio_blk_request (alloc, &req,512 ); + req_addr =virtio_blk_request (alloc, &dev->vdev, &req,512 );g_free (req.data);
@@ -618,7 +618,7 @@ static void pci_idx(void) req.data =g_malloc0 (512 );strcpy (req.data,"TEST" ); - req_addr =virtio_blk_request (alloc, &req,512 ); + req_addr =virtio_blk_request (alloc, &dev->vdev, &req,512 );g_free (req.data);
@@ -643,7 +643,7 @@ static void pci_idx(void) req.sector =1 ; req.data =g_malloc0 (512 ); - req_addr =virtio_blk_request (alloc, &req,512 ); + req_addr =virtio_blk_request (alloc, &dev->vdev, &req,512 );g_free (req.data);
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 12/73] nvram: Move the remaining CHRP NVRAM related code to chrp_nvram.[ch]
In reply to David GibsonFrom: Thomas Huth <[email protected]>
Everything that is related to CHRP NVRAM should rather reside in chrp_nvram.c / chrp_nvram.h instead of openbios_firmware_abi.h.
--- hw/nvram/chrp_nvram.c | 31 +++++++++++++++--------- hw/nvram/mac_nvram.c | 7 +++--- include/hw/nvram/chrp_nvram.h | 30 +++++++++++++++++++++++ include/hw/nvram/openbios_firmware_abi.h | 41 -------------------------------- tests/postcopy-test.c | 8 +++---- 5 files changed, 57 insertions(+), 60 deletions(-)
hw/nvram/chrp_nvram.c +20 -11
@@ -23,26 +23,35 @@#include "qemu/cutils.h" #include "hw/hw.h" #include "hw/nvram/chrp_nvram.h" -#include "hw/nvram/openbios_firmware_abi.h" #include "sysemu/sysemu.h" +static int chrp_nvram_set_var (uint8_t *nvram,int addr,const char *str) +{ +int len; + + len =strlen (str) +1 ; +memcpy (&nvram[addr], str, len); + +return addr + len; +} +/** * Create a "system partition", used for the Open Firmware * environment variables. */ int chrp_nvram_create_system_partition (uint8_t *data,int min_len) { -struct OpenBIOS_nvpart_v1 *part_header; +ChrpNvramPartHdr *part_header;unsigned int i;int end; - part_header = (struct OpenBIOS_nvpart_v1 *)data; - part_header->signature =OPENBIOS_PART_SYSTEM ; + part_header = (ChrpNvramPartHdr *)data; + part_header->signature =CHRP_NVPART_SYSTEM ;pstrcpy (part_header->name,sizeof (part_header->name),"system" ); - end =sizeof (struct OpenBIOS_nvpart_v1 ); + end =sizeof (ChrpNvramPartHdr);for (i =0 ; i < nb_prom_envs; i++) { - end =OpenBIOS_set_var (data, end, prom_envs[i]); + end =chrp_nvram_set_var (data, end, prom_envs[i]); }/* End marker */
@@ -54,7 +63,7 @@ int chrp_nvram_create_system_partition(uint8_t *data, int min_len)if (end < min_len) { end = min_len; } -OpenBIOS_finish_partition (part_header, end); +chrp_nvram_finish_partition (part_header, end);return end; }
@@ -64,13 +73,13 @@ int chrp_nvram_create_system_partition(uint8_t *data, int min_len)*/ int chrp_nvram_create_free_partition (uint8_t *data,int len) { -struct OpenBIOS_nvpart_v1 *part_header; +ChrpNvramPartHdr *part_header; - part_header = (struct OpenBIOS_nvpart_v1 *)data; - part_header->signature =OPENBIOS_PART_FREE ; + part_header = (ChrpNvramPartHdr *)data; + part_header->signature =CHRP_NVPART_FREE ;pstrcpy (part_header->name,sizeof (part_header->name),"free" ); -OpenBIOS_finish_partition (part_header, len); +chrp_nvram_finish_partition (part_header, len);return len; }
hw/nvram/mac_nvram.c +3 -4
@@ -24,7 +24,6 @@*/ #include "qemu/osdep.h" #include "hw/hw.h" -#include "hw/nvram/openbios_firmware_abi.h" #include "hw/nvram/chrp_nvram.h" #include "hw/ppc/mac.h" #include "qemu/cutils.h"
@@ -163,15 +162,15 @@ static void pmac_format_nvram_partition_osx(MacIONVRAMState *nvr, int off, int len) {uint32_t start = off; -struct OpenBIOS_nvpart_v1 *part_header; +ChrpNvramPartHdr *part_header;unsigned char *data = &nvr->data[start];/* empty partition */ - part_header = (struct OpenBIOS_nvpart_v1 *)data; + part_header = (ChrpNvramPartHdr *)data; part_header->signature =OSX_NVRAM_SIGNATURE ;pstrcpy (part_header->name,sizeof (part_header->name),"wwwwwwwwwwww" ); -OpenBIOS_finish_partition (part_header, len); +chrp_nvram_finish_partition (part_header, len);/* Generation */ stl_be_p (&data[20 ],2 );
include/hw/nvram/chrp_nvram.h +30 -0
@@ -18,6 +18,36 @@#ifndef CHRP_NVRAM_H #define CHRP_NVRAM_H +/* OpenBIOS NVRAM partition */ +typedef struct { +uint8_t signature; +uint8_t checksum; +uint16_t len;/* Big endian, length divided by 16 */ +char name[12 ]; +}ChrpNvramPartHdr ; + +#define CHRP_NVPART_SYSTEM 0x70 +#define CHRP_NVPART_FREE 0x7f + +static inline void +chrp_nvram_finish_partition (ChrpNvramPartHdr *header,uint32_t size) +{ +unsigned int i, sum; +uint8_t *tmpptr; + +/* Length divided by 16 */ + header->len =cpu_to_be16 (size >>4 ); + +/* Checksum */ + tmpptr = (uint8_t *)header; + sum = *tmpptr; +for (i =0 ; i <14 ; i++) { + sum += tmpptr[2 + i]; + sum = (sum + ((sum &0xff00 ) >>8 )) &0xff ; + } + header->checksum = sum &0xff ; +} +int chrp_nvram_create_system_partition (uint8_t *data,int min_len);int chrp_nvram_create_free_partition (uint8_t *data,int len);
include/hw/nvram/openbios_firmware_abi.h +0 -41
47 lines not on this page · raw message
tests/postcopy-test.c +4 -4
@@ -18,7 +18,7 @@#include "qemu/sockets.h" #include "sysemu/char.h" #include "sysemu/sysemu.h" -#include "hw/nvram/openbios_firmware_abi.h" +#include "hw/nvram/chrp_nvram.h" #define MIN_NVRAM_SIZE 8192/* from spapr_nvram.c */
@@ -137,15 +137,15 @@ static void init_bootfile_ppc(const char *bootpath) {FILE *bootfile;char buf[MIN_NVRAM_SIZE ]; -struct OpenBIOS_nvpart_v1 *header = (struct OpenBIOS_nvpart_v1 *)buf; +ChrpNvramPartHdr *header = (ChrpNvramPartHdr *)buf;memset (buf,0 ,MIN_NVRAM_SIZE );/* Create a "common" partition in nvram to store boot-command property */ - header->signature =OPENBIOS_PART_SYSTEM ; + header->signature =CHRP_NVPART_SYSTEM ;memcpy (header->name,"common" ,6 ); -OpenBIOS_finish_partition (header,MIN_NVRAM_SIZE ); +chrp_nvram_finish_partition (header,MIN_NVRAM_SIZE );/* FW_MAX_SIZE is 4MB, but slof.bin is only 900KB, * so let's modify memory between 1MB and 100MB
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 20/73] pseries: Remove unused callbacks from sPAPR VIO bus state
In reply to David GibsonThe original QOMification of the spapr VIO devices in 3954d33 "spapr:
convert to QEMU Object Model (v2)" moved some callbacks from the VIOsPAPRBus structure to the VIOsPAPRDeviceClass. Except, that it forgot to actually remove them from the VIOsPAPRBus structure (which still exists, though it doesn't fulfill quite the same function as it did pre-QOM).
This patch removes those now unused callback fields.
--- include/hw/ppc/spapr_vio.h | 2 -- 1 file changed, 2 deletions(-)
include/hw/ppc/spapr_vio.h +0 -2
@@ -76,8 +76,6 @@ struct VIOsPAPRDevice {struct VIOsPAPRBus {BusState bus;uint32_t next_reg; -int (*init)(VIOsPAPRDevice *dev); -int (*devnode)(VIOsPAPRDevice *dev,void *fdt,int node_off); };extern VIOsPAPRBus *spapr_vio_bus_init (void );
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 13/73] nvram: Rename openbios_firmware_abi.h into sun_nvram.h
In reply to David GibsonFrom: Thomas Huth <[email protected]>
The header now only contains inline functions related to the Sun NVRAM, so the a name like sun_nvram.h seems to be more appropriate now.
---
hw/sparc/sun4m.c | 2 +-
hw/sparc64/sun4u.c | 2 +-
include/hw/nvram/{openbios_firmware_abi.h => sun_nvram.h} | 6 +++---
3 files changed, 5 insertions(+), 5 deletions(-)
rename include/hw/nvram/{openbios_firmware_abi.h => sun_nvram.h} (90%)hw/sparc/sun4m.c +1 -1
@@ -35,10 +35,10 @@#include "sysemu/sysemu.h" #include "net/net.h" #include "hw/boards.h" -#include "hw/nvram/openbios_firmware_abi.h" #include "hw/scsi/esp.h" #include "hw/i386/pc.h" #include "hw/isa/isa.h" +#include "hw/nvram/sun_nvram.h" #include "hw/nvram/chrp_nvram.h" #include "hw/nvram/fw_cfg.h" #include "hw/char/escc.h"
hw/sparc64/sun4u.c +1 -1
@@ -36,7 +36,7 @@#include "qemu/timer.h" #include "sysemu/sysemu.h" #include "hw/boards.h" -#include "hw/nvram/openbios_firmware_abi.h" +#include "hw/nvram/sun_nvram.h" #include "hw/nvram/chrp_nvram.h" #include "hw/nvram/fw_cfg.h" #include "hw/sysbus.h"
include/hw/nvram/sun_nvram.h renamed from include/hw/nvram/openbios_firmware_abi.h +3 -3
@@ -1,5 +1,5 @@ -#ifndef OPENBIOS_FIRMWARE_ABI_H -#define OPENBIOS_FIRMWARE_ABI_H +#ifndef SUN_NVRAM_H +#define SUN_NVRAM_H /* Sun IDPROM structure at the end of NVRAM */ /* from http://www.squirrel.com/squirrel/sun-nvram-hostid.faq.html */
@@ -31,4 +31,4 @@ Sun_init_header(struct Sun_nvram *header, const uint8_t *macaddr, int machine_id header->checksum = tmp; } -#endif /* OPENBIOS_FIRMWARE_ABI_H */ +#endif /* SUN_NVRAM_H */
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 27/73] ppc/pnv: add a PIR handler to PnvChip
In reply to David GibsonFrom: Cédric Le Goater <[email protected]>
The Processor Identification Register (PIR) is a register that holds a processor identifier which is used for bus transactions (XSCOM) and for processor differentiation in multiprocessor systems. It also used in the interrupt vector entries (IVE) to identify the thread serving the interrupts.
P9 and P8 have some differences in the CPU PIR encoding.
--- hw/ppc/pnv.c | 30 ++++++++++++++++++++++++++++++ include/hw/ppc/pnv.h | 2 ++ 2 files changed, 32 insertions(+)
hw/ppc/pnv.c +30 -0
@@ -244,6 +244,32 @@ static void ppc_powernv_init(MachineState *machine)g_free (chip_typename); } +/* +* 0:21 Reserved - Read as zeros +* 22:24 Chip ID +* 25:28 Core number +* 29:31 Thread ID +*/ +static uint32_t pnv_chip_core_pir_p8 (PnvChip *chip,uint32_t core_id) +{ +return (chip->chip_id <<7 ) | (core_id <<3 ); +} + +/* +* 0:48 Reserved - Read as zeroes +* 49:52 Node ID +* 53:55 Chip ID +* 56 Reserved - Read as zero +* 57:61 Core number +* 62:63 Thread ID +* +* We only care about the lower bits. uint32_t is fine for the moment. +*/ +static uint32_t pnv_chip_core_pir_p9 (PnvChip *chip,uint32_t core_id) +{ +return (chip->chip_id <<8 ) | (core_id <<2 ); +} +/* Allowed core identifiers on a POWER8 Processor Chip : * * <EX0 reserved>
@@ -279,6 +305,7 @@ static void pnv_chip_power8e_class_init(ObjectClass *klass, void *data) k->chip_type =PNV_CHIP_POWER8E ; k->chip_cfam_id =0x221ef04980000000ull ;/* P8 Murano DD2.1 */ k->cores_mask =POWER8E_CORE_MASK ; + k->core_pir = pnv_chip_core_pir_p8; dc->desc ="PowerNV Chip POWER8E" ; }
@@ -298,6 +325,7 @@ static void pnv_chip_power8_class_init(ObjectClass *klass, void *data) k->chip_type =PNV_CHIP_POWER8 ; k->chip_cfam_id =0x220ea04980000000ull ;/* P8 Venice DD2.0 */ k->cores_mask =POWER8_CORE_MASK ; + k->core_pir = pnv_chip_core_pir_p8; dc->desc ="PowerNV Chip POWER8" ; }
@@ -317,6 +345,7 @@ static void pnv_chip_power8nvl_class_init(ObjectClass *klass, void *data) k->chip_type =PNV_CHIP_POWER8NVL ; k->chip_cfam_id =0x120d304980000000ull ;/* P8 Naples DD1.0 */ k->cores_mask =POWER8_CORE_MASK ; + k->core_pir = pnv_chip_core_pir_p8; dc->desc ="PowerNV Chip POWER8NVL" ; }
@@ -336,6 +365,7 @@ static void pnv_chip_power9_class_init(ObjectClass *klass, void *data) k->chip_type =PNV_CHIP_POWER9 ; k->chip_cfam_id =0x100d104980000000ull ;/* P9 Nimbus DD1.0 */ k->cores_mask =POWER9_CORE_MASK ; + k->core_pir = pnv_chip_core_pir_p9; dc->desc ="PowerNV Chip POWER9" ; }
include/hw/ppc/pnv.h +2 -0
@@ -58,6 +58,8 @@ typedef struct PnvChipClass {PnvChipType chip_type;uint64_t chip_cfam_id;uint64_t cores_mask; + +uint32_t (*core_pir)(PnvChip *chip,uint32_t core_id); } PnvChipClass;#define TYPE_PNV_CHIP_POWER8E TYPE_PNV_CHIP "-POWER8E"
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 18/73] ppc/xics: change the icp_ routines API to use an 'ICPState *' argument
In reply to David GibsonFrom: Cédric Le Goater <[email protected]>
The routines :
void icp_set_cppr(ICPState *icp, uint8_t cppr); void icp_set_mfrr(ICPState *icp, uint8_t mfrr); void icp_eoi(ICPState *icp, uint32_t xirr);
now use one 'ICPState *icp' argument instead of a 'XICSState *' and a server arguments. The backlink on XICSState* is used whenever needed.
--- hw/intc/xics.c | 25 ++++++++++--------------- hw/intc/xics_spapr.c | 18 +++++++++++------- include/hw/ppc/xics.h | 6 +++--- 3 files changed, 24 insertions(+), 25 deletions(-)
hw/intc/xics.c +10 -15
@@ -326,22 +326,20 @@ static void icp_check_ipi(ICPState *ss)qemu_irq_raise (ss->output); } -static void icp_resend (XICSState *xics,int server) +static void icp_resend (ICPState *ss) { -ICPState *ss = xics->ss + server;ICSState *ics;if (ss->mfrr <CPPR (ss)) {icp_check_ipi (ss); } - QLIST_FOREACH(ics, &xics->ics, list) { + QLIST_FOREACH(ics, &ss->xics->ics, list) {ics_resend (ics); } } -void icp_set_cppr (XICSState *xics,int server,uint8_t cppr) +void icp_set_cppr (ICPState *ss,uint8_t cppr) { -ICPState *ss = xics->ss + server;uint8_t old_cppr;uint32_t old_xisr;
@@ -361,15 +359,13 @@ void icp_set_cppr(XICSState *xics, int server, uint8_t cppr) } }else {if (!XISR (ss)) { -icp_resend (xics, server); +icp_resend (ss); } } } -void icp_set_mfrr (XICSState *xics,int server,uint8_t mfrr) +void icp_set_mfrr (ICPState *ss,uint8_t mfrr) { -ICPState *ss = xics->ss + server; - ss->mfrr = mfrr;if (mfrr <CPPR (ss)) {icp_check_ipi (ss);
@@ -398,23 +394,22 @@ uint32_t icp_ipoll(ICPState *ss, uint32_t *mfrr)return ss->xirr; } -void icp_eoi (XICSState *xics,int server,uint32_t xirr) +void icp_eoi (ICPState *ss,uint32_t xirr) { -ICPState *ss = xics->ss + server;ICSState *ics;uint32_t irq;/* Send EOI -> ICS */ ss->xirr = (ss->xirr & ~CPPR_MASK ) | (xirr &CPPR_MASK ); -trace_xics_icp_eoi (server, xirr, ss->xirr); +trace_xics_icp_eoi (ss->cs->cpu_index, xirr, ss->xirr); irq = xirr &XISR_MASK ; - QLIST_FOREACH(ics, &xics->ics, list) { + QLIST_FOREACH(ics, &ss->xics->ics, list) {if (ics_valid_irq (ics, irq)) {ics_eoi (ics, irq); } }if (!XISR (ss)) { -icp_resend (xics, server); +icp_resend (ss); } }
@@ -673,7 +668,7 @@ static int ics_simple_post_load(ICSState *ics, int version_id)int i;for (i =0 ; i < ics->xics->nr_servers; i++) { -icp_resend (ics->xics, i); +icp_resend (&ics->xics->ss[i]); }return 0 ;
hw/intc/xics_spapr.c +11 -7
@@ -43,9 +43,10 @@ static target_ulong h_cppr(PowerPCCPU *cpu, sPAPRMachineState *spapr, target_ulong opcode, target_ulong *args) { CPUState *cs = CPU(cpu); +ICPState *icp = &spapr->xics->ss[cs->cpu_index];target_ulong cppr = args[0 ]; -icp_set_cppr (spapr->xics, cs->cpu_index, cppr); +icp_set_cppr (icp, cppr);return H_SUCCESS ; }
@@ -59,7 +60,7 @@ static target_ulong h_ipi(PowerPCCPU *cpu, sPAPRMachineState *spapr,return H_PARAMETER ; } -icp_set_mfrr (spapr->xics, server, mfrr); +icp_set_mfrr (spapr->xics->ss + server, mfrr);return H_SUCCESS ; }
@@ -67,7 +68,8 @@ static target_ulong h_xirr(PowerPCCPU *cpu, sPAPRMachineState *spapr, target_ulong opcode, target_ulong *args) { CPUState *cs = CPU(cpu); -uint32_t xirr =icp_accept (spapr->xics->ss + cs->cpu_index); +ICPState *icp = &spapr->xics->ss[cs->cpu_index]; +uint32_t xirr =icp_accept (icp); args[0 ] = xirr;return H_SUCCESS ;
@@ -77,8 +79,8 @@ static target_ulong h_xirr_x(PowerPCCPU *cpu, sPAPRMachineState *spapr, target_ulong opcode, target_ulong *args) { CPUState *cs = CPU(cpu); -ICPState *ss = &spapr->xics->ss[cs->cpu_index]; -uint32_t xirr =icp_accept (ss); +ICPState *icp = &spapr->xics->ss[cs->cpu_index]; +uint32_t xirr =icp_accept (icp); args[0 ] = xirr; args[1 ] =cpu_get_host_ticks ();
@@ -89,9 +91,10 @@ static target_ulong h_eoi(PowerPCCPU *cpu, sPAPRMachineState *spapr, target_ulong opcode, target_ulong *args) { CPUState *cs = CPU(cpu); +ICPState *icp = &spapr->xics->ss[cs->cpu_index];target_ulong xirr = args[0 ]; -icp_eoi (spapr->xics, cs->cpu_index, xirr); +icp_eoi (icp, xirr);return H_SUCCESS ; }
@@ -99,8 +102,9 @@ static target_ulong h_ipoll(PowerPCCPU *cpu, sPAPRMachineState *spapr, target_ulong opcode, target_ulong *args) { CPUState *cs = CPU(cpu); +ICPState *icp = &spapr->xics->ss[cs->cpu_index];uint32_t mfrr; -uint32_t xirr =icp_ipoll (spapr->xics->ss + cs->cpu_index, &mfrr); +uint32_t xirr =icp_ipoll (icp, &mfrr); args[0 ] = xirr; args[1 ] = mfrr;
include/hw/ppc/xics.h +3 -3
@@ -196,11 +196,11 @@ void xics_set_nr_servers(XICSState *xics, uint32_t nr_servers,/* Internal XICS interfaces */ int xics_get_cpu_index_by_dt_id (int cpu_dt_id); -void icp_set_cppr (XICSState *icp,int server,uint8_t cppr); -void icp_set_mfrr (XICSState *icp,int server,uint8_t mfrr); +void icp_set_cppr (ICPState *icp,uint8_t cppr); +void icp_set_mfrr (ICPState *icp,uint8_t mfrr);uint32_t icp_accept (ICPState *ss);uint32_t icp_ipoll (ICPState *ss,uint32_t *mfrr); -void icp_eoi (XICSState *icp,int server,uint32_t xirr); +void icp_eoi (ICPState *icp,uint32_t xirr);void ics_simple_write_xive (ICSState *ics,int nr,int server,uint8_t priority,uint8_t saved_priority);
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 07/73] tests: use qtest_pc_boot()/qtest_shutdown() in virtio tests
In reply to David GibsonFrom: Laurent Vivier <[email protected]>
This patch replaces calls to qtest_start() and qtest_end() by calls to qtest_pc_boot() and qtest_shutdown().
This allows to initialize memory allocator and PCI interface functions. This will ease to enable virtio tests on other architectures by only adding a specific qtest_XXX_boot() (like qtest_spapr_boot()).
--- tests/virtio-9p-test.c | 50 +++++++--------- tests/virtio-blk-test.c | 148 ++++++++++++++++++++--------------------------- tests/virtio-net-test.c | 39 +++++-------- tests/virtio-scsi-test.c | 67 ++++++++++----------- 4 files changed, 128 insertions(+), 176 deletions(-)
tests/virtio-9p-test.c +22 -28
@@ -10,62 +10,57 @@#include "qemu/osdep.h" #include "libqtest.h" #include "qemu-common.h" -#include "libqos/pci-pc.h" +#include "libqos/libqos-pc.h" #include "libqos/virtio.h" #include "libqos/virtio-pci.h" -#include "libqos/malloc.h" -#include "libqos/malloc-pc.h" #include "standard-headers/linux/virtio_ids.h" #include "standard-headers/linux/virtio_pci.h" static const char mount_tag[] ="qtest" ;static char *test_share; -static void qvirtio_9p_start (void ) + +static QOSState *qvirtio_9p_start (void ) { -char *args; +const char *cmd ="-fsdev local,id=fsdev0,security_model=none,path=%s " +"-device virtio-9p-pci,fsdev=fsdev0,mount_tag=%s" ; test_share =g_strdup ("/tmp/qtest.XXXXXX" );g_assert_nonnull (mkdtemp (test_share)); - args =g_strdup_printf ("-fsdev local,id=fsdev0,security_model=none,path=%s " -"-device virtio-9p-pci,fsdev=fsdev0,mount_tag=%s" , - test_share, mount_tag); - -qtest_start (args); -g_free (args); +return qtest_pc_boot (cmd, test_share, mount_tag); } -static void qvirtio_9p_stop (void ) +static void qvirtio_9p_stop (QOSState *qs) { -qtest_end (); +qtest_shutdown (qs);rmdir (test_share);g_free (test_share); }static void pci_nop (void ) { -qvirtio_9p_start (); -qvirtio_9p_stop (); +QOSState *qs; + + qs =qvirtio_9p_start (); +qvirtio_9p_stop (qs); }typedef struct {QVirtioDevice *dev; -QGuestAllocator *alloc; -QPCIBus *bus; +QOSState *qs;QVirtQueue *vq; }QVirtIO9P ; -static QVirtIO9P *qvirtio_9p_pci_init (void ) +static QVirtIO9P *qvirtio_9p_pci_init (QOSState *qs) {QVirtIO9P *v9p;QVirtioPCIDevice *dev; v9p =g_new0 (QVirtIO9P,1 ); - v9p->alloc =pc_alloc_init (); - v9p->bus =qpci_init_pc (NULL ); - dev =qvirtio_pci_device_find (v9p->bus,VIRTIO_ID_9P ); + v9p->qs = qs; + dev =qvirtio_pci_device_find (v9p->qs->pcibus,VIRTIO_ID_9P );g_assert_nonnull (dev); g_assert_cmphex(dev->vdev.device_type, ==, VIRTIO_ID_9P); v9p->dev = (QVirtioDevice *) dev;
@@ -75,17 +70,15 @@ static QVirtIO9P *qvirtio_9p_pci_init(void)qvirtio_set_acknowledge (v9p->dev);qvirtio_set_driver (v9p->dev); - v9p->vq =qvirtqueue_setup (v9p->dev, v9p->alloc,0 ); + v9p->vq =qvirtqueue_setup (v9p->dev, v9p->qs->alloc,0 );return v9p; }static void qvirtio_9p_pci_free (QVirtIO9P *v9p) { -qvirtqueue_cleanup (v9p->dev->bus, v9p->vq, v9p->alloc); -pc_alloc_uninit (v9p->alloc); +qvirtqueue_cleanup (v9p->dev->bus, v9p->vq, v9p->qs->alloc);qvirtio_pci_device_disable (container_of (v9p->dev, QVirtioPCIDevice, vdev));g_free (v9p->dev); -qpci_free_pc (v9p->bus);g_free (v9p); }
@@ -96,9 +89,10 @@ static void pci_basic_config(void)size_t tag_len;char *tag;int i; +QOSState *qs; -qvirtio_9p_start (); - v9p =qvirtio_9p_pci_init (); + qs =qvirtio_9p_start (); + v9p =qvirtio_9p_pci_init (qs); addr = ((QVirtioPCIDevice *) v9p->dev)->addr +VIRTIO_PCI_CONFIG_OFF (false); tag_len = qvirtio_config_readw(v9p->dev,
@@ -114,7 +108,7 @@ static void pci_basic_config(void)g_free (tag);qvirtio_9p_pci_free (v9p); -qvirtio_9p_stop (); +qvirtio_9p_stop (qs); }int main (int argc,char **argv)
tests/virtio-blk-test.c +63 -85
387 lines not on this page · raw message
tests/virtio-net-test.c +14 -25
@@ -12,12 +12,9 @@#include "qemu-common.h" #include "qemu/sockets.h" #include "qemu/iov.h" -#include "libqos/pci-pc.h" +#include "libqos/libqos-pc.h" #include "libqos/virtio.h" #include "libqos/virtio-pci.h" -#include "libqos/malloc.h" -#include "libqos/malloc-pc.h" -#include "libqos/malloc-generic.h" #include "qemu/bswap.h" #include "hw/virtio/virtio-net.h" #include "standard-headers/linux/virtio_ids.h"
@@ -53,16 +50,12 @@ static QVirtioPCIDevice *virtio_net_pci_init(QPCIBus *bus, int slot)return dev; } -static QPCIBus *pci_test_start (int socket) +static QOSState *pci_test_start (int socket) { -char *cmdline; +const char *cmd ="-netdev socket,fd=%d,id=hs0 -device " +"virtio-net-pci,netdev=hs0" ; - cmdline =g_strdup_printf ("-netdev socket,fd=%d,id=hs0 -device " -"virtio-net-pci,netdev=hs0" , socket); -qtest_start (cmdline); -g_free (cmdline); - -return qpci_init_pc (NULL ); +return qtest_pc_boot (cmd, socket); }static void driver_init (QVirtioDevice *dev)
@@ -205,9 +198,8 @@ static void stop_cont_test(QVirtioDevice *dev,static void pci_basic (gconstpointer data) {QVirtioPCIDevice *dev; -QPCIBus *bus; +QOSState *qs;QVirtQueuePCI *tx, *rx; -QGuestAllocator *alloc; void (*func) (QVirtioDevice *dev, QGuestAllocator *alloc, QVirtQueue *rvq,
@@ -218,26 +210,23 @@ static void pci_basic(gconstpointer data) ret =socketpair (PF_UNIX ,SOCK_STREAM ,0 , sv); g_assert_cmpint(ret, !=, -1); - bus =pci_test_start (sv[1 ]); - dev =virtio_net_pci_init (bus,PCI_SLOT ); + qs =pci_test_start (sv[1 ]); + dev =virtio_net_pci_init (qs->pcibus,PCI_SLOT ); - alloc =pc_alloc_init (); - rx = (QVirtQueuePCI *)qvirtqueue_setup (&dev->vdev, alloc,0 ); - tx = (QVirtQueuePCI *)qvirtqueue_setup (&dev->vdev, alloc,1 ); + rx = (QVirtQueuePCI *)qvirtqueue_setup (&dev->vdev, qs->alloc,0 ); + tx = (QVirtQueuePCI *)qvirtqueue_setup (&dev->vdev, qs->alloc,1 );driver_init (&dev->vdev); -func (&dev->vdev, alloc, &rx->vq, &tx->vq, sv[0 ]); +func (&dev->vdev, qs->alloc, &rx->vq, &tx->vq, sv[0 ]);/* End test */ close (sv[0 ]); -qvirtqueue_cleanup (dev->vdev.bus, &tx->vq, alloc); -qvirtqueue_cleanup (dev->vdev.bus, &rx->vq, alloc); -pc_alloc_uninit (alloc); +qvirtqueue_cleanup (dev->vdev.bus, &tx->vq, qs->alloc); +qvirtqueue_cleanup (dev->vdev.bus, &rx->vq, qs->alloc);qvirtio_pci_device_disable (dev);g_free (dev->pdev);g_free (dev); -qpci_free_pc (bus); - test_end(); + qtest_shutdown(qs); }#endif
tests/virtio-scsi-test.c +29 -38
153 lines not on this page · raw message
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 17/73] ppc/xics: add a XICSState backlink in ICPState
In reply to David GibsonFrom: Cédric Le Goater <[email protected]>
The link will be used to change the API of the icp_* routines which are still using an XICSState as an argument.
--- hw/intc/xics.c | 1 + include/hw/ppc/xics.h | 2 ++ 2 files changed, 3 insertions(+)
hw/intc/xics.c +1 -0
@@ -198,6 +198,7 @@ void xics_set_nr_servers(XICSState *xics, uint32_t nr_servers,object_initialize (icp,sizeof (*icp), typename);snprintf (name,sizeof (name),"icp[%d]" , i);object_property_add_child (OBJECT (xics), name,OBJECT (icp), errp); + icp->xics = xics; } }
include/hw/ppc/xics.h +2 -0
@@ -117,6 +117,8 @@ struct ICPState {uint8_t mfrr;qemu_irq output;bool cap_irq_xics_enabled; + +XICSState *xics; };#define TYPE_ICS_BASE "ics-base"
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 23/73] configure, ppc64: Copy skiboot.lid to build directory when configuring
In reply to David GibsonFrom: Alexey Kardashevskiy <[email protected]>
When configured to compile out of tree, the configure script copies BIOS blobs to the build directory. However since the PPC64 powernv machine ROM has .lid extension, it is ignored and "make check" fails when trying the powernv machine.
This adds *.lid to the list of copied blobs.
--- configure | 1 + 1 file changed, 1 insertion(+)
configure +1 -0
@@ -6131,6 +6131,7 @@ FILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile" FILES="$FILES pc-bios/qemu-icon.bmp" for bios_file in \ $source_path/pc-bios/*.bin \ + $source_path/pc-bios/*.lid \ $source_path/pc-bios/*.aml \ $source_path/pc-bios/*.rom \ $source_path/pc-bios/*.dtb \
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 25/73] ppc/pnv: add a PnvChip object
In reply to David GibsonFrom: Cédric Le Goater <[email protected]>
This is is an abstraction of a POWER8 chip which is a set of cores plus other 'units', like the pervasive unit, the interrupt controller, the memory controller, the on-chip microcontroller, etc. The whole can be seen as a socket. It depends on a cpu model and its characteristics:
max cores and specific inits are defined in a PnvChipClass.
We start with an near empty PnvChip with only a few cpu constants which we will grow in the subsequent patches with the controllers required to run the system.
The Chip CFAM (Common FRU Access Module) ID gives the model of the chip and its version number. It is generally the first thing firmwares fetch, available at XSCOM PCB address 0xf000f, to start initialization.
--- hw/ppc/pnv.c | 213 +++++++++++++++++++++++++++++++++++++++++++++++++-- include/hw/ppc/pnv.h | 63 +++++++++++++++ 2 files changed, 271 insertions(+), 5 deletions(-)
hw/ppc/pnv.c +208 -5
@@ -30,6 +30,7 @@#include "hw/loader.h" #include "exec/address-spaces.h" #include "qemu/cutils.h" +#include "qapi/visitor.h" #include <libfdt.h>
@@ -74,6 +75,14 @@ static void powernv_populate_memory_node(void *fdt, int chip_id, hwaddr start,_FDT ((fdt_setprop_cell (fdt, off,"ibm,chip-id" , chip_id))); } +static void powernv_populate_chip (PnvChip *chip,void *fdt) +{ +if (chip->ram_size) { +powernv_populate_memory_node (fdt, chip->chip_id, chip->ram_start, + chip->ram_size); + } +} +static void *powernv_create_fdt (MachineState *machine) {const char plat_compat[] ="qemu,powernv\0ibm,powernv" ;
@@ -81,6 +90,7 @@ static void *powernv_create_fdt(MachineState *machine)void *fdt;char *buf;int off; +int i; fdt =g_malloc0 (FDT_MAX_SIZE );_FDT ((fdt_create_empty_tree (fdt,FDT_MAX_SIZE )));
@@ -116,11 +126,10 @@ static void *powernv_create_fdt(MachineState *machine) &end_prop, sizeof(end_prop)))); } -/* TODO: put all the memory in one node on chip 0 until we find a -* way to specify different ranges for each chip -*/ -powernv_populate_memory_node (fdt,0 ,0 , machine->ram_size); - +/* Populate device tree for each chip */ +for (i =0 ; i < pnv->num_chips; i++) { +powernv_populate_chip (pnv->chips[i], fdt); + }return fdt; }
@@ -145,6 +154,8 @@ static void ppc_powernv_init(MachineState *machine)MemoryRegion *ram;char *fw_filename;long fw_size; +int i; +char *chip_typename;/* allocate RAM */ if (machine->ram_size < (1 *G_BYTE )) {
@@ -194,6 +205,190 @@ static void ppc_powernv_init(MachineState *machine)exit (1 ); } } + +/* We need some cpu model to instantiate the PnvChip class */ +if (machine->cpu_model ==NULL ) { + machine->cpu_model ="POWER8" ; + } + +/* Create the processor chips */ + chip_typename =g_strdup_printf (TYPE_PNV_CHIP "-%s" , machine->cpu_model); +if (!object_class_by_name (chip_typename)) { +error_report ("qemu: invalid CPU model '%s' for %s machine" , + machine->cpu_model,MACHINE_GET_CLASS (machine)->name); +exit (1 ); + } + + pnv->chips = g_new0(PnvChip *, pnv->num_chips); +for (i =0 ; i < pnv->num_chips; i++) { +char chip_name[32 ]; +Object *chip =object_new (chip_typename); + + pnv->chips[i] =PNV_CHIP (chip); + +/* TODO: put all the memory in one node on chip 0 until we find a +* way to specify different ranges for each chip +*/ +if (i ==0 ) { +object_property_set_int (chip, machine->ram_size,"ram-size" , + &error_fatal); + } + +snprintf (chip_name,sizeof (chip_name),"chip[%d]" ,PNV_CHIP_HWID (i)); +object_property_add_child (OBJECT (pnv), chip_name, chip, &error_fatal); +object_property_set_int (chip,PNV_CHIP_HWID (i),"chip-id" , + &error_fatal); +object_property_set_bool (chip, true,"realized" , &error_fatal); + } +g_free (chip_typename); +} + +static void pnv_chip_power8e_class_init (ObjectClass *klass,void *data) +{ +DeviceClass *dc =DEVICE_CLASS (klass); +PnvChipClass *k =PNV_CHIP_CLASS (klass); + + k->cpu_model ="POWER8E" ; + k->chip_type =PNV_CHIP_POWER8E ; + k->chip_cfam_id =0x221ef04980000000ull ;/* P8 Murano DD2.1 */ + dc->desc ="PowerNV Chip POWER8E" ; +} + +static const TypeInfo pnv_chip_power8e_info = { + .name =TYPE_PNV_CHIP_POWER8E , + .parent =TYPE_PNV_CHIP , + .instance_size =sizeof (PnvChip), + .class_init = pnv_chip_power8e_class_init, +}; + +static void pnv_chip_power8_class_init (ObjectClass *klass,void *data) +{ +DeviceClass *dc =DEVICE_CLASS (klass); +PnvChipClass *k =PNV_CHIP_CLASS (klass); + + k->cpu_model ="POWER8" ; + k->chip_type =PNV_CHIP_POWER8 ; + k->chip_cfam_id =0x220ea04980000000ull ;/* P8 Venice DD2.0 */ + dc->desc ="PowerNV Chip POWER8" ; +} + +static const TypeInfo pnv_chip_power8_info = { + .name =TYPE_PNV_CHIP_POWER8 , + .parent =TYPE_PNV_CHIP , + .instance_size =sizeof (PnvChip), + .class_init = pnv_chip_power8_class_init, +}; + +static void pnv_chip_power8nvl_class_init (ObjectClass *klass,void *data) +{ +DeviceClass *dc =DEVICE_CLASS (klass); +PnvChipClass *k =PNV_CHIP_CLASS (klass); + + k->cpu_model ="POWER8NVL" ; + k->chip_type =PNV_CHIP_POWER8NVL ; + k->chip_cfam_id =0x120d304980000000ull ;/* P8 Naples DD1.0 */ + dc->desc ="PowerNV Chip POWER8NVL" ; +} + +static const TypeInfo pnv_chip_power8nvl_info = { + .name =TYPE_PNV_CHIP_POWER8NVL , + .parent =TYPE_PNV_CHIP , + .instance_size =sizeof (PnvChip), + .class_init = pnv_chip_power8nvl_class_init, +}; + +static void pnv_chip_power9_class_init (ObjectClass *klass,void *data) +{ +DeviceClass *dc =DEVICE_CLASS (klass); +PnvChipClass *k =PNV_CHIP_CLASS (klass); + + k->cpu_model ="POWER9" ; + k->chip_type =PNV_CHIP_POWER9 ; + k->chip_cfam_id =0x100d104980000000ull ;/* P9 Nimbus DD1.0 */ + dc->desc ="PowerNV Chip POWER9" ; +} + +static const TypeInfo pnv_chip_power9_info = { + .name =TYPE_PNV_CHIP_POWER9 , + .parent =TYPE_PNV_CHIP , + .instance_size =sizeof (PnvChip), + .class_init = pnv_chip_power9_class_init, +}; + +static void pnv_chip_realize (DeviceState *dev,Error **errp) +{ +/* left purposely empty */ +} + +static Property pnv_chip_properties[] = { +DEFINE_PROP_UINT32 ("chip-id" , PnvChip, chip_id,0 ), +DEFINE_PROP_UINT64 ("ram-start" , PnvChip, ram_start,0 ), +DEFINE_PROP_UINT64 ("ram-size" , PnvChip, ram_size,0 ), +DEFINE_PROP_END_OF_LIST (), +}; + +static void pnv_chip_class_init (ObjectClass *klass,void *data) +{ +DeviceClass *dc =DEVICE_CLASS (klass); + + dc->realize = pnv_chip_realize; + dc->props = pnv_chip_properties; + dc->desc ="PowerNV Chip" ; +} + +static const TypeInfo pnv_chip_info = { + .name =TYPE_PNV_CHIP , + .parent =TYPE_SYS_BUS_DEVICE , + .class_init = pnv_chip_class_init, + .class_size =sizeof (PnvChipClass), + .abstract = true, +}; + +static void pnv_get_num_chips (Object *obj,Visitor *v,const char *name, +void *opaque,Error **errp) +{ +visit_type_uint32 (v, name, &POWERNV_MACHINE (obj)->num_chips, errp); +} + +static void pnv_set_num_chips (Object *obj,Visitor *v,const char *name, +void *opaque,Error **errp) +{ +PnvMachineState *pnv =POWERNV_MACHINE (obj); +uint32_t num_chips; +Error *local_err =NULL ; + +visit_type_uint32 (v, name, &num_chips, &local_err); +if (local_err) { +error_propagate (errp, local_err); +return ; + } + +/* +* TODO: should we decide on how many chips we can create based +* on #cores and Venice vs. Murano vs. Naples chip type etc..., +*/ +if (!is_power_of_2 (num_chips) || num_chips >4 ) { +error_setg (errp,"invalid number of chips: '%d'" , num_chips); +return ; + } + + pnv->num_chips = num_chips; +} + +static void powernv_machine_initfn (Object *obj) +{ +PnvMachineState *pnv =POWERNV_MACHINE (obj); + pnv->num_chips =1 ; +} + +static void powernv_machine_class_props_init (ObjectClass *oc) +{ +object_class_property_add (oc,"num-chips" ,"uint32_t" , + pnv_get_num_chips, pnv_set_num_chips, +NULL ,NULL ,NULL ); +object_class_property_set_description (oc,"num-chips" , +"Specifies the number of processor chips" , +NULL ); }static void powernv_machine_class_init (ObjectClass *oc,void *data)
@@ -209,18 +404,26 @@ static void powernv_machine_class_init(ObjectClass *oc, void *data) mc->no_parallel =1 ; mc->default_boot_order =NULL ; mc->default_ram_size =1 *G_BYTE ; + +powernv_machine_class_props_init (oc); }static const TypeInfo powernv_machine_info = { .name =TYPE_POWERNV_MACHINE , .parent =TYPE_MACHINE , .instance_size =sizeof (PnvMachineState), + .instance_init = powernv_machine_initfn, .class_init = powernv_machine_class_init, };static void powernv_machine_register_types (void ) {type_register_static (&powernv_machine_info); +type_register_static (&pnv_chip_info); +type_register_static (&pnv_chip_power8e_info); +type_register_static (&pnv_chip_power8_info); +type_register_static (&pnv_chip_power8nvl_info); +type_register_static (&pnv_chip_power9_info); }type_init (powernv_machine_register_types)
include/hw/ppc/pnv.h +63 -0
75 lines not on this page · raw message
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 34/73] pseries: Split device tree construction from device tree load
In reply to David Gibsonspapr_finalize_fdt() both finishes building the device tree for the guest and loads it into guest memory. For future cleanups, it's going to be more convenient to do these two things separately. The loading portion is pretty trivial, so we move it inline into the caller, ppc_spapr_reset().
We also rename spapr_finalize_fdt(), because the current name is going to become inaccurate.
--- hw/ppc/spapr.c | 42 +++++++++++++++++++++++------------------- hw/ppc/spapr_cpu_core.c | 2 +- 2 files changed, 24 insertions(+), 20 deletions(-)
hw/ppc/spapr.c +23 -19
@@ -900,10 +900,9 @@ int spapr_h_cas_compose_response(sPAPRMachineState *spapr,return 0 ; } -static void spapr_finalize_fdt (sPAPRMachineState *spapr, -hwaddr fdt_addr, -hwaddr rtas_addr, -hwaddr rtas_size) +static void *spapr_build_fdt (sPAPRMachineState *spapr, +hwaddr rtas_addr, +hwaddr rtas_size) {MachineState *machine =MACHINE (qdev_get_machine ());MachineClass *mc =MACHINE_GET_CLASS (machine);
@@ -999,19 +998,8 @@ static void spapr_finalize_fdt(sPAPRMachineState *spapr, } } -_FDT ((fdt_pack (fdt))); - -if (fdt_totalsize (fdt) >FDT_MAX_SIZE ) { -error_report ("FDT too big ! 0x%x bytes (max is 0x%x)" , -fdt_totalsize (fdt),FDT_MAX_SIZE ); -exit (1 ); - } - -qemu_fdt_dumpdtb (fdt,fdt_totalsize (fdt)); -cpu_physical_memory_write (fdt_addr, fdt,fdt_totalsize (fdt)); -g_free (bootlist); -g_free (fdt); +return fdt; }static uint64_t translate_kernel_address (void *opaque,uint64_t addr)
@@ -1147,6 +1135,8 @@ static void ppc_spapr_reset(void)sPAPRMachineState *spapr =SPAPR_MACHINE (machine);PowerPCCPU *first_ppc_cpu;uint32_t rtas_limit; +void *fdt; +int rc;/* Check for unknown sysbus devices */ foreach_dynamic_sysbus_device (find_unknown_sysbus_device,NULL );
@@ -1173,14 +1163,28 @@ static void ppc_spapr_reset(void) spapr->rtas_addr = rtas_limit -RTAS_MAX_SIZE ; spapr->fdt_addr = spapr->rtas_addr -FDT_MAX_SIZE ; -/* Load the fdt */ -spapr_finalize_fdt (spapr, spapr->fdt_addr, spapr->rtas_addr, - spapr->rtas_size); + fdt =spapr_build_fdt (spapr, spapr->rtas_addr, spapr->rtas_size);/* Copy RTAS over */ cpu_physical_memory_write (spapr->rtas_addr, spapr->rtas_blob, spapr->rtas_size); + rc =fdt_pack (fdt); + +/* Should only fail if we've built a corrupted tree */ +assert (rc ==0 ); + +if (fdt_totalsize (fdt) >FDT_MAX_SIZE ) { +error_report ("FDT too big ! 0x%x bytes (max is 0x%x)" , +fdt_totalsize (fdt),FDT_MAX_SIZE ); +exit (1 ); + } + +/* Load the fdt */ +qemu_fdt_dumpdtb (fdt,fdt_totalsize (fdt)); +cpu_physical_memory_write (spapr->fdt_addr, fdt,fdt_totalsize (fdt)); +g_free (fdt); +/* Set up the entry state */ first_ppc_cpu =POWERPC_CPU (first_cpu); first_ppc_cpu->env.gpr[3 ] = spapr->fdt_addr;
hw/ppc/spapr_cpu_core.c +1 -1
@@ -184,7 +184,7 @@ void spapr_core_plug(HotplugHandler *hotplug_dev, DeviceState *dev,/* * Setup CPU DT entries only for hotplugged CPUs. For boot time or -* coldplugged CPUs DT entries are setup in spapr_finalize_fdt(). +* coldplugged CPUs DT entries are setup in spapr_build_fdt(). */ if (dev->hotplugged) { fdt =spapr_populate_hotplug_cpu_dt (cs, &fdt_offset, spapr);
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 40/73] pseries: Consolidate construction of /chosen device tree node
In reply to David GibsonFor historical reasons, building the /chosen node in the guest device tree is split across several places and includes both parts which write the DT sequentially and others which use random access functions.
This patch consolidates construction of the node into one place, using random access functions throughout.
--- hw/ppc/spapr.c | 131 ++++++++++++++++++++++----------------------- hw/ppc/spapr_vio.c | 17 ++---- include/hw/ppc/spapr_vio.h | 2 +- 3 files changed, 70 insertions(+), 80 deletions(-)
hw/ppc/spapr.c +65 -66
@@ -273,14 +273,10 @@ static void add_str(GString *s, const gchar *s1)static void *spapr_create_fdt_skel (sPAPRMachineState *spapr) { -MachineState *machine =MACHINE (spapr);void *fdt; -uint32_t start_prop =cpu_to_be32 (spapr->initrd_base); -uint32_t end_prop =cpu_to_be32 (spapr->initrd_base + spapr->initrd_size);GString *hypertas =g_string_sized_new (256 );GString *qemu_hypertas =g_string_sized_new (256 );uint32_t refpoints[] = {cpu_to_be32 (0x4 ),cpu_to_be32 (0x4 )}; -unsigned char vec5[] = {0x0 ,0x0 ,0x0 ,0x0 ,0x0 ,0x80 };char *buf;add_str (hypertas,"hcall-pft" );
@@ -337,35 +333,6 @@ static void *spapr_create_fdt_skel(sPAPRMachineState *spapr)_FDT ((fdt_property_cell (fdt,"#address-cells" ,0x2 )));_FDT ((fdt_property_cell (fdt,"#size-cells" ,0x2 ))); -/* /chosen */ -_FDT ((fdt_begin_node (fdt,"chosen" ))); - -/* Set Form1_affinity */ -_FDT ((fdt_property (fdt,"ibm,architecture-vec-5" , vec5,sizeof (vec5)))); - -_FDT ((fdt_property_string (fdt,"bootargs" , machine->kernel_cmdline))); -_FDT ((fdt_property (fdt,"linux,initrd-start" , - &start_prop,sizeof (start_prop)))); -_FDT ((fdt_property (fdt,"linux,initrd-end" , - &end_prop,sizeof (end_prop)))); -if (spapr->kernel_size) { -uint64_t kprop[2 ] = {cpu_to_be64 (KERNEL_LOAD_ADDR ), -cpu_to_be64 (spapr->kernel_size) }; - -_FDT ((fdt_property (fdt,"qemu,boot-kernel" , &kprop,sizeof (kprop)))); -if (spapr->kernel_le) { -_FDT ((fdt_property (fdt,"qemu,boot-kernel-le" ,NULL ,0 ))); - } - } -if (boot_menu) { -_FDT ((fdt_property_cell (fdt,"qemu,boot-menu" , boot_menu))); - } -_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))); -/* RTAS */ _FDT ((fdt_begin_node (fdt,"rtas" )));
@@ -873,6 +840,68 @@ int spapr_h_cas_compose_response(sPAPRMachineState *spapr,return 0 ; } +static void spapr_dt_chosen (sPAPRMachineState *spapr,void *fdt) +{ +MachineState *machine =MACHINE (spapr); +int chosen; +const char *boot_device = machine->boot_order; +char *stdout_path =spapr_vio_stdout_path (spapr->vio_bus); +size_t cb =0 ; +char *bootlist =get_boot_devices_list (&cb, true); +unsigned char vec5[] = {0x0 ,0x0 ,0x0 ,0x0 ,0x0 ,0x80 }; + +_FDT (chosen =fdt_add_subnode (fdt,0 ,"chosen" )); + +/* Set Form1_affinity */ +_FDT (fdt_setprop (fdt, chosen,"ibm,architecture-vec-5" , + vec5,sizeof (vec5))); + +_FDT (fdt_setprop_string (fdt, chosen,"bootargs" , machine->kernel_cmdline)); +_FDT (fdt_setprop_cell (fdt, chosen,"linux,initrd-start" , + spapr->initrd_base)); +_FDT (fdt_setprop_cell (fdt, chosen,"linux,initrd-end" , + spapr->initrd_base + spapr->initrd_size)); + +if (spapr->kernel_size) { +uint64_t kprop[2 ] = {cpu_to_be64 (KERNEL_LOAD_ADDR ), +cpu_to_be64 (spapr->kernel_size) }; + +_FDT (fdt_setprop (fdt, chosen,"qemu,boot-kernel" , + &kprop,sizeof (kprop))); +if (spapr->kernel_le) { +_FDT (fdt_setprop (fdt, chosen,"qemu,boot-kernel-le" ,NULL ,0 )); + } + } +if (boot_menu) { +_FDT ((fdt_setprop_cell (fdt, chosen,"qemu,boot-menu" , boot_menu))); + } +_FDT (fdt_setprop_cell (fdt, chosen,"qemu,graphic-width" , graphic_width)); +_FDT (fdt_setprop_cell (fdt, chosen,"qemu,graphic-height" , graphic_height)); +_FDT (fdt_setprop_cell (fdt, chosen,"qemu,graphic-depth" , graphic_depth)); + +if (cb && bootlist) { +int i; + +for (i =0 ; i < cb; i++) { +if (bootlist[i] =='\n' ) { + bootlist[i] =' ' ; + } + } +_FDT (fdt_setprop_string (fdt, chosen,"qemu,boot-list" , bootlist)); + } + +if (boot_device &&strlen (boot_device)) { +_FDT (fdt_setprop_string (fdt, chosen,"qemu,boot-device" , boot_device)); + } + +if (!spapr->has_graphics && stdout_path) { +_FDT (fdt_setprop_string (fdt, chosen,"linux,stdout-path" , stdout_path)); + } + +g_free (stdout_path); +g_free (bootlist); +} +static void *spapr_build_fdt (sPAPRMachineState *spapr,hwaddr rtas_addr,hwaddr rtas_size)
@@ -880,10 +909,7 @@ static void *spapr_build_fdt(sPAPRMachineState *spapr,MachineState *machine =MACHINE (qdev_get_machine ());MachineClass *mc =MACHINE_GET_CLASS (machine);sPAPRMachineClass *smc =SPAPR_MACHINE_GET_CLASS (machine); -const char *boot_device = machine->boot_order; -int ret, i; -size_t cb =0 ; -char *bootlist; +int ret;void *fdt;sPAPRPHBState *phb;
@@ -932,34 +958,6 @@ static void *spapr_build_fdt(sPAPRMachineState *spapr,/* cpus */ spapr_populate_cpus_dt_node (fdt, spapr); - bootlist =get_boot_devices_list (&cb, true); -if (cb && bootlist) { -int offset =fdt_path_offset (fdt,"/chosen" ); -if (offset <0 ) { -exit (1 ); - } -for (i =0 ; i < cb; i++) { -if (bootlist[i] =='\n' ) { - bootlist[i] =' ' ; - } - - } - ret =fdt_setprop_string (fdt, offset,"qemu,boot-list" , bootlist); - } - -if (boot_device &&strlen (boot_device)) { -int offset =fdt_path_offset (fdt,"/chosen" ); - -if (offset <0 ) { -exit (1 ); - } -fdt_setprop_string (fdt, offset,"qemu,boot-device" , boot_device); - } - -if (!spapr->has_graphics) { -spapr_populate_chosen_stdout (fdt, spapr->vio_bus); - } -if (smc->dr_lmb_enabled) {_FDT (spapr_drc_populate_dt (fdt,0 ,NULL ,SPAPR_DR_CONNECTOR_TYPE_LMB )); }
@@ -974,7 +972,8 @@ static void *spapr_build_fdt(sPAPRMachineState *spapr, } } -g_free (bootlist); +/* /chosen */ +spapr_dt_chosen (spapr, fdt);/* Build memory reserve map */ if (spapr->kernel_size) {
hw/ppc/spapr_vio.c +4 -13
@@ -665,28 +665,19 @@ out:return ret; } -int spapr_populate_chosen_stdout (void *fdt,VIOsPAPRBus *bus) +gchar *spapr_vio_stdout_path (VIOsPAPRBus *bus) {VIOsPAPRDevice *dev;char *name, *path; -int ret, offset; dev =spapr_vty_get_default (bus); -if (!dev) -return 0 ; - - offset =fdt_path_offset (fdt,"/chosen" ); -if (offset <0 ) { -return offset; +if (!dev) { +return NULL ; } name =spapr_vio_get_dev_name (DEVICE (dev)); path =g_strdup_printf ("/vdevice/%s" , name); - ret =fdt_setprop_string (fdt, offset,"linux,stdout-path" , path); -g_free (name); -g_free (path); - -return ret; +return path; }
include/hw/ppc/spapr_vio.h +1 -1
@@ -81,7 +81,7 @@ struct VIOsPAPRBus {extern VIOsPAPRBus *spapr_vio_bus_init (void );extern VIOsPAPRDevice *spapr_vio_find_by_reg (VIOsPAPRBus *bus,uint32_t reg);extern int spapr_populate_vdevice (VIOsPAPRBus *bus,void *fdt); -extern int spapr_populate_chosen_stdout (void *fdt,VIOsPAPRBus *bus); +extern gchar *spapr_vio_stdout_path (VIOsPAPRBus *bus);static inline qemu_irq spapr_vio_qirq (VIOsPAPRDevice *dev) {
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 46/73] spapr_ovec: initial implementation of option vector helpers
In reply to David GibsonFrom: Michael Roth <[email protected]>
PAPR guests advertise their capabilities to the platform by passing an ibm,architecture-vec structure via an ibm,client-architecture-support hcall as described by LoPAPR v11, B.6.2.3. during early boot.
Using this information, the platform enables the capabilities it supports, then encodes a subset of those enabled capabilities (the 5th option vector of the ibm,architecture-vec structure passed to ibm,client-architecture-support) into the guest device tree via "/chosen/ibm,architecture-vec-5".
The logical format of these these option vectors is a bit-vector, where individual bits are addressed/documented based on the byte-wise offset from the beginning of the bit-vector, followed by the bit-wise index starting from the byte-wise offset. Thus the bits of each of these bytes are stored in reverse order. Additionally, the first byte of each option vector is encodes the length of the option vector, so byte offsets begin at 1, and bit offset at 0.
This is not very intuitive for the purposes of mapping these bits to a particular documented capability, so this patch introduces a set of abstractions that encapsulate the work of parsing/encoding these options vectors and testing for individual capabilities.
[dwg: Tweaked double-include protection to not trigger a checkpatch
false positive]
--- hw/ppc/Makefile.objs | 2 +- hw/ppc/spapr_ovec.c | 242 ++++++++++++++++++++++++++++++++++++++++++++ include/hw/ppc/spapr_ovec.h | 62 ++++++++++++ 3 files changed, 305 insertions(+), 1 deletion(-) create mode 100644 hw/ppc/spapr_ovec.c create mode 100644 include/hw/ppc/spapr_ovec.h
hw/ppc/Makefile.objs +1 -1
@@ -4,7 +4,7 @@ obj-y += ppc.o ppc_booke.o fdt.o obj-$(CONFIG_PSERIES) += spapr.o spapr_vio.o spapr_events.o obj-$(CONFIG_PSERIES) += spapr_hcall.o spapr_iommu.o spapr_rtas.o obj-$(CONFIG_PSERIES) += spapr_pci.o spapr_rtc.o spapr_drc.o spapr_rng.o -obj-$(CONFIG_PSERIES) += spapr_cpu_core.o +obj-$(CONFIG_PSERIES) += spapr_cpu_core.o spapr_ovec.o # IBM PowerNV obj-$(CONFIG_POWERNV) += pnv.o pnv_xscom.o pnv_core.o pnv_lpc.o ifeq ($(CONFIG_PCI)$(CONFIG_PSERIES)$(CONFIG_LINUX), yyy)
hw/ppc/spapr_ovec.c new file +242 -0
242 lines not on this page · raw message
include/hw/ppc/spapr_ovec.h new file +62 -0
62 lines not on this page · raw message
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 28/73] ppc/pnv: add a PnvCore object
In reply to David GibsonFrom: Cédric Le Goater <[email protected]>
This is largy inspired by sPAPRCPUCore with some simplification, no hotplug for instance. A set of PnvCore objects is added to the PnvChip and the device tree is populated looping on these cores.
Real HW cpu ids are now generated depending on the chip cpu model, the chip id and a core mask. The id is propagated to the CPU object, using properties, to set the SPR_PIR (Processor Identification Register)
--- hw/ppc/Makefile.objs | 2 +- hw/ppc/pnv.c | 189 +++++++++++++++++++++++++++++++++++++++++++++- hw/ppc/pnv_core.c | 182 ++++++++++++++++++++++++++++++++++++++++++++ include/hw/ppc/pnv.h | 2 + include/hw/ppc/pnv_core.h | 48 ++++++++++++ 5 files changed, 421 insertions(+), 2 deletions(-) create mode 100644 hw/ppc/pnv_core.c create mode 100644 include/hw/ppc/pnv_core.h
hw/ppc/Makefile.objs +1 -1
@@ -6,7 +6,7 @@ obj-$(CONFIG_PSERIES) += spapr_hcall.o spapr_iommu.o spapr_rtas.o obj-$(CONFIG_PSERIES) += spapr_pci.o spapr_rtc.o spapr_drc.o spapr_rng.o obj-$(CONFIG_PSERIES) += spapr_cpu_core.o # IBM PowerNV -obj-$(CONFIG_POWERNV) += pnv.o +obj-$(CONFIG_POWERNV) += pnv.o pnv_core.o ifeq ($(CONFIG_PCI)$(CONFIG_PSERIES)$(CONFIG_LINUX), yyy) obj-y += spapr_pci_vfio.o endif
hw/ppc/pnv.c +188 -1
219 lines not on this page · raw message
hw/ppc/pnv_core.c new file +182 -0
182 lines not on this page · raw message
include/hw/ppc/pnv.h +2 -0
@@ -47,6 +47,7 @@ typedef struct PnvChip {uint32_t nr_cores;uint64_t cores_mask; +void *cores; } PnvChip; typedef struct PnvChipClass {
@@ -103,5 +104,6 @@ typedef struct PnvMachineState { } PnvMachineState;#define PNV_FDT_ADDR 0x01000000 +#define PNV_TIMEBASE_FREQ 512000000ULL#endif /* _PPC_PNV_H */
include/hw/ppc/pnv_core.h new file +48 -0
48 lines not on this page · raw message
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 41/73] pseries: Consolidate construction of /rtas device tree node
In reply to David GibsonFor historical reasons construction of the /rtas node in the device tree (amongst others) is split into several places. In particular it's split between spapr_create_fdt_skel(), spapr_build_fdt() and spapr_rtas_device_tree_setup().
In fact, as well as adding the actual RTAS tokens to the device tree, spapr_rtas_device_tree_setup() just adds the ibm,lrdr-capacity property, which despite going in the /rtas node, doesn't have a lot to do with RTAS.
This patch consolidates the code constructing /rtas together into a new spapr_dt_rtas() function. spapr_rtas_device_tree_setup() is renamed to spapr_dt_rtas_tokens() and now only adds the token properties.
--- hw/ppc/spapr.c | 130 +++++++++++++++++++++++++++---------------------- hw/ppc/spapr_rtas.c | 33 ++----------- include/hw/ppc/spapr.h | 3 +- 3 files changed, 76 insertions(+), 90 deletions(-)
hw/ppc/spapr.c +72 -58
@@ -274,25 +274,8 @@ static void add_str(GString *s, const gchar *s1)static void *spapr_create_fdt_skel (sPAPRMachineState *spapr) {void *fdt; -GString *hypertas =g_string_sized_new (256 ); -GString *qemu_hypertas =g_string_sized_new (256 ); -uint32_t refpoints[] = {cpu_to_be32 (0x4 ),cpu_to_be32 (0x4 )};char *buf; -add_str (hypertas,"hcall-pft" ); -add_str (hypertas,"hcall-term" ); -add_str (hypertas,"hcall-dabr" ); -add_str (hypertas,"hcall-interrupt" ); -add_str (hypertas,"hcall-tce" ); -add_str (hypertas,"hcall-vio" ); -add_str (hypertas,"hcall-splpar" ); -add_str (hypertas,"hcall-bulk" ); -add_str (hypertas,"hcall-set-mode" ); -add_str (hypertas,"hcall-sprg0" ); -add_str (hypertas,"hcall-copy" ); -add_str (hypertas,"hcall-debug" ); -add_str (qemu_hypertas,"hcall-memop1" ); - fdt =g_malloc0 (FDT_MAX_SIZE );_FDT ((fdt_create (fdt,FDT_MAX_SIZE )));
@@ -333,41 +316,6 @@ static void *spapr_create_fdt_skel(sPAPRMachineState *spapr)_FDT ((fdt_property_cell (fdt,"#address-cells" ,0x2 )));_FDT ((fdt_property_cell (fdt,"#size-cells" ,0x2 ))); -/* RTAS */ -_FDT ((fdt_begin_node (fdt,"rtas" ))); - -if (!kvm_enabled () ||kvmppc_spapr_use_multitce ()) { -add_str (hypertas,"hcall-multi-tce" ); - } -_FDT ((fdt_property (fdt,"ibm,hypertas-functions" , hypertas->str, - hypertas->len))); -g_string_free (hypertas, TRUE); -_FDT ((fdt_property (fdt,"qemu,hypertas-functions" , qemu_hypertas->str, - qemu_hypertas->len))); -g_string_free (qemu_hypertas, TRUE); - -_FDT ((fdt_property (fdt,"ibm,associativity-reference-points" , - refpoints,sizeof (refpoints)))); - -_FDT ((fdt_property_cell (fdt,"rtas-error-log-max" ,RTAS_ERROR_LOG_MAX ))); -_FDT ((fdt_property_cell (fdt,"rtas-event-scan-rate" , -RTAS_EVENT_SCAN_RATE ))); - -if (msi_nonbroken) { -_FDT ((fdt_property (fdt,"ibm,change-msix-capable" ,NULL ,0 ))); - } - -/* -* According to PAPR, rtas ibm,os-term does not guarantee a return -* back to the guest cpu. -* -* While an additional ibm,extended-os-term property indicates that -* rtas call return will always occur. Set this property. -*/ -_FDT ((fdt_property (fdt,"ibm,extended-os-term" ,NULL ,0 ))); - -_FDT ((fdt_end_node (fdt))); -/* vdevice */ _FDT ((fdt_begin_node (fdt,"vdevice" )));
@@ -840,6 +788,75 @@ int spapr_h_cas_compose_response(sPAPRMachineState *spapr,return 0 ; } +static void spapr_dt_rtas (sPAPRMachineState *spapr,void *fdt) +{ +int rtas; +GString *hypertas =g_string_sized_new (256 ); +GString *qemu_hypertas =g_string_sized_new (256 ); +uint32_t refpoints[] = {cpu_to_be32 (0x4 ),cpu_to_be32 (0x4 ) }; +uint64_t max_hotplug_addr = spapr->hotplug_memory.base + +memory_region_size (&spapr->hotplug_memory.mr); +uint32_t lrdr_capacity[] = { +cpu_to_be32 (max_hotplug_addr >>32 ), +cpu_to_be32 (max_hotplug_addr &0xffffffff ), +0 ,cpu_to_be32 (SPAPR_MEMORY_BLOCK_SIZE ), +cpu_to_be32 (max_cpus / smp_threads), + }; + +_FDT (rtas =fdt_add_subnode (fdt,0 ,"rtas" )); + +/* hypertas */ +add_str (hypertas,"hcall-pft" ); +add_str (hypertas,"hcall-term" ); +add_str (hypertas,"hcall-dabr" ); +add_str (hypertas,"hcall-interrupt" ); +add_str (hypertas,"hcall-tce" ); +add_str (hypertas,"hcall-vio" ); +add_str (hypertas,"hcall-splpar" ); +add_str (hypertas,"hcall-bulk" ); +add_str (hypertas,"hcall-set-mode" ); +add_str (hypertas,"hcall-sprg0" ); +add_str (hypertas,"hcall-copy" ); +add_str (hypertas,"hcall-debug" ); +add_str (qemu_hypertas,"hcall-memop1" ); + +if (!kvm_enabled () ||kvmppc_spapr_use_multitce ()) { +add_str (hypertas,"hcall-multi-tce" ); + } +_FDT (fdt_setprop (fdt, rtas,"ibm,hypertas-functions" , + hypertas->str, hypertas->len)); +g_string_free (hypertas, TRUE); +_FDT (fdt_setprop (fdt, rtas,"qemu,hypertas-functions" , + qemu_hypertas->str, qemu_hypertas->len)); +g_string_free (qemu_hypertas, TRUE); + +_FDT (fdt_setprop (fdt, rtas,"ibm,associativity-reference-points" , + refpoints,sizeof (refpoints))); + +_FDT (fdt_setprop_cell (fdt, rtas,"rtas-error-log-max" , +RTAS_ERROR_LOG_MAX )); +_FDT (fdt_setprop_cell (fdt, rtas,"rtas-event-scan-rate" , +RTAS_EVENT_SCAN_RATE )); + +if (msi_nonbroken) { +_FDT (fdt_setprop (fdt, rtas,"ibm,change-msix-capable" ,NULL ,0 )); + } + +/* +* According to PAPR, rtas ibm,os-term does not guarantee a return +* back to the guest cpu. +* +* While an additional ibm,extended-os-term property indicates +* that rtas call return will always occur. Set this property. +*/ +_FDT (fdt_setprop (fdt, rtas,"ibm,extended-os-term" ,NULL ,0 )); + +_FDT (fdt_setprop (fdt, rtas,"ibm,lrdr-capacity" , + lrdr_capacity,sizeof (lrdr_capacity))); + +spapr_dt_rtas_tokens (fdt, rtas); +} +static void spapr_dt_chosen (sPAPRMachineState *spapr,void *fdt) {MachineState *machine =MACHINE (spapr);
@@ -949,12 +966,6 @@ static void *spapr_build_fdt(sPAPRMachineState *spapr, } } -/* RTAS */ - ret =spapr_rtas_device_tree_setup (fdt, rtas_addr, rtas_size); -if (ret <0 ) { -error_report ("Couldn't set up RTAS device tree properties" ); - } -/* cpus */ spapr_populate_cpus_dt_node (fdt, spapr);
@@ -972,6 +983,9 @@ static void *spapr_build_fdt(sPAPRMachineState *spapr, } } +/* /rtas */ +spapr_dt_rtas (spapr, fdt); +/* /chosen */ spapr_dt_chosen (spapr, fdt);
hw/ppc/spapr_rtas.c +3 -30
@@ -46,6 +46,7 @@#include "hw/ppc/spapr_drc.h" #include "qemu/cutils.h" #include "trace.h" +#include "hw/ppc/fdt.h" static sPAPRConfigureConnectorState *spapr_ccs_find (sPAPRMachineState *spapr,uint32_t drc_index)
@@ -710,16 +711,9 @@ void spapr_rtas_register(int token, const char *name, spapr_rtas_fn fn) rtas_table[token].fn = fn; } -int spapr_rtas_device_tree_setup (void *fdt,hwaddr rtas_addr, -hwaddr rtas_size) +void spapr_dt_rtas_tokens (void *fdt,int rtas) { -int ret;int i; -uint32_t lrdr_capacity[5 ]; -MachineState *machine =MACHINE (qdev_get_machine ()); -sPAPRMachineState *spapr =SPAPR_MACHINE (machine); -uint64_t max_hotplug_addr = spapr->hotplug_memory.base + -memory_region_size (&spapr->hotplug_memory.mr);for (i =0 ; i <RTAS_TOKEN_MAX -RTAS_TOKEN_BASE ; i++) {struct rtas_call *call = &rtas_table[i];
@@ -728,29 +722,8 @@ int spapr_rtas_device_tree_setup(void *fdt, hwaddr rtas_addr,continue ; } - ret =qemu_fdt_setprop_cell (fdt,"/rtas" , call->name, - i +RTAS_TOKEN_BASE ); -if (ret <0 ) { -error_report ("Couldn't add rtas token for %s: %s" , - call->name,fdt_strerror (ret)); -return ret; - } - +_FDT (fdt_setprop_cell (fdt, rtas, call->name, i +RTAS_TOKEN_BASE )); } - - lrdr_capacity[0 ] =cpu_to_be32 (max_hotplug_addr >>32 ); - lrdr_capacity[1 ] =cpu_to_be32 (max_hotplug_addr &0xffffffff ); - lrdr_capacity[2 ] =0 ; - lrdr_capacity[3 ] =cpu_to_be32 (SPAPR_MEMORY_BLOCK_SIZE ); - lrdr_capacity[4 ] =cpu_to_be32 (max_cpus/smp_threads); - ret =qemu_fdt_setprop (fdt,"/rtas" ,"ibm,lrdr-capacity" , lrdr_capacity, -sizeof (lrdr_capacity)); -if (ret <0 ) { -error_report ("Couldn't add ibm,lrdr-capacity rtas property" ); -return ret; - } - -return 0 ; }void spapr_load_rtas (sPAPRMachineState *spapr,void *fdt,hwaddr addr)
include/hw/ppc/spapr.h +1 -2
@@ -530,8 +530,7 @@ void spapr_rtas_register(int token, const char *name, spapr_rtas_fn fn);target_ulong spapr_rtas_call (PowerPCCPU *cpu,sPAPRMachineState *sm,uint32_t token,uint32_t nargs,target_ulong args,uint32_t nret,target_ulong rets); -int spapr_rtas_device_tree_setup (void *fdt,hwaddr rtas_addr, -hwaddr rtas_size); +void spapr_dt_rtas_tokens (void *fdt,int rtas);void spapr_load_rtas (sPAPRMachineState *spapr,void *fdt,hwaddr addr);#define SPAPR_TCE_PAGE_SHIFT 12
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 38/73] pseries: Consolidate RTAS loading
In reply to David GibsonAt each system reset, the pseries machine needs to load RTAS (the runtime portion of the guest firmware) into the VM. This means copying the actual RTAS code into guest memory, and also updating the device tree so that the guest OS and boot firmware can locate it.
For historical reasons the copy and update to the device tree were in different parts of the code. This cleanup brings them both together in an spapr_load_rtas() function.
--- hw/ppc/spapr.c | 3 +-- hw/ppc/spapr_rtas.c | 72 ++++++++++++++++++++++++++++---------------------- include/hw/ppc/spapr.h | 1 + 3 files changed, 43 insertions(+), 33 deletions(-)
hw/ppc/spapr.c +1 -2
@@ -1165,8 +1165,7 @@ static void ppc_spapr_reset(void) fdt =spapr_build_fdt (spapr, rtas_addr, spapr->rtas_size); -/* Copy RTAS over */ -cpu_physical_memory_write (rtas_addr, spapr->rtas_blob, spapr->rtas_size); +spapr_load_rtas (spapr, fdt, rtas_addr); rc =fdt_pack (fdt);
hw/ppc/spapr_rtas.c +41 -31
84 lines not on this page · raw message
include/hw/ppc/spapr.h +1 -0
@@ -532,6 +532,7 @@ target_ulong spapr_rtas_call(PowerPCCPU *cpu, sPAPRMachineState *sm, uint32_t nret, target_ulong rets);int spapr_rtas_device_tree_setup (void *fdt,hwaddr rtas_addr,hwaddr rtas_size); +void spapr_load_rtas (sPAPRMachineState *spapr,void *fdt,hwaddr addr);#define SPAPR_TCE_PAGE_SHIFT 12#define SPAPR_TCE_PAGE_SIZE (1ULL << SPAPR_TCE_PAGE_SHIFT)
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 44/73] pseries: Consolidate construction of /vdevice device tree node
In reply to David GibsonConstruction of the /vdevice node (and its children) is divided between spapr_create_fdt_skel() (at init time), which creates the base node, and spapr_populate_vdevice() (at reset time) which creates the nodes for each individual virtual device.
This consolidates both into a single function called from spapr_build_fdt().
--- hw/ppc/spapr.c | 19 ++----------------- hw/ppc/spapr_vio.c | 23 ++++++++++++++++------- include/hw/ppc/spapr_vio.h | 2 +- 3 files changed, 19 insertions(+), 25 deletions(-)
hw/ppc/spapr.c +2 -17
@@ -316,18 +316,6 @@ static void *spapr_create_fdt_skel(sPAPRMachineState *spapr)_FDT ((fdt_property_cell (fdt,"#address-cells" ,0x2 )));_FDT ((fdt_property_cell (fdt,"#size-cells" ,0x2 ))); -/* vdevice */ -_FDT ((fdt_begin_node (fdt,"vdevice" ))); - -_FDT ((fdt_property_string (fdt,"device_type" ,"vdevice" ))); -_FDT ((fdt_property_string (fdt,"compatible" ,"IBM,vdevice" ))); -_FDT ((fdt_property_cell (fdt,"#address-cells" ,0x1 ))); -_FDT ((fdt_property_cell (fdt,"#size-cells" ,0x0 ))); -_FDT ((fdt_property_cell (fdt,"#interrupt-cells" ,0x2 ))); -_FDT ((fdt_property (fdt,"interrupt-controller" ,NULL ,0 ))); - -_FDT ((fdt_end_node (fdt))); -_FDT ((fdt_end_node (fdt)));/* close root node */ _FDT ((fdt_finish (fdt)));
@@ -943,11 +931,8 @@ static void *spapr_build_fdt(sPAPRMachineState *spapr,exit (1 ); } - ret =spapr_populate_vdevice (spapr->vio_bus, fdt); -if (ret <0 ) { -error_report ("couldn't setup vio devices in fdt" ); -exit (1 ); - } +/* /vdevice */ +spapr_dt_vdevice (spapr->vio_bus, fdt);if (object_resolve_path_type ("" ,TYPE_SPAPR_RNG ,NULL )) { ret =spapr_rng_populate_dt (fdt);
hw/ppc/spapr_vio.c +16 -7
@@ -36,6 +36,7 @@#include "hw/ppc/spapr.h" #include "hw/ppc/spapr_vio.h" #include "hw/ppc/xics.h" +#include "hw/ppc/fdt.h" #include "trace.h" #include <libfdt.h>
@@ -624,11 +625,21 @@ static int compare_reg(const void *p1, const void *p2)return 1 ; } -int spapr_populate_vdevice (VIOsPAPRBus *bus,void *fdt) +void spapr_dt_vdevice (VIOsPAPRBus *bus,void *fdt) {DeviceState *qdev, **qdevs;BusChild *kid;int i, num, ret =0 ; +int node; + +_FDT (node =fdt_add_subnode (fdt,0 ,"vdevice" )); + +_FDT (fdt_setprop_string (fdt, node,"device_type" ,"vdevice" )); +_FDT (fdt_setprop_string (fdt, node,"compatible" ,"IBM,vdevice" )); +_FDT (fdt_setprop_cell (fdt, node,"#address-cells" ,1 )); +_FDT (fdt_setprop_cell (fdt, node,"#size-cells" ,0 )); +_FDT (fdt_setprop_cell (fdt, node,"#interrupt-cells" ,2 )); +_FDT (fdt_setprop (fdt, node,"interrupt-controller" ,NULL ,0 ));/* Count qdevs on the bus list */ num =0 ;
@@ -650,19 +661,17 @@ int spapr_populate_vdevice(VIOsPAPRBus *bus, void *fdt)* to know that will mean they are in forward order in the tree. */ for (i = num -1 ; i >=0 ; i--) {VIOsPAPRDevice *dev = (VIOsPAPRDevice *)(qdevs[i]); +VIOsPAPRDeviceClass *vdc =VIO_SPAPR_DEVICE_GET_CLASS (dev); ret =vio_make_devnode (dev, fdt); -if (ret <0 ) { - goto out; +error_report ("Couldn't create device node /vdevice/%s@%" PRIx32, + vdc->dt_name, dev->reg); +exit (1 ); } } - ret =0 ; -out:g_free (qdevs); - -return ret; }gchar *spapr_vio_stdout_path (VIOsPAPRBus *bus)
include/hw/ppc/spapr_vio.h +1 -1
@@ -80,7 +80,7 @@ struct VIOsPAPRBus {extern VIOsPAPRBus *spapr_vio_bus_init (void );extern VIOsPAPRDevice *spapr_vio_find_by_reg (VIOsPAPRBus *bus,uint32_t reg); -extern int spapr_populate_vdevice (VIOsPAPRBus *bus,void *fdt); +void spapr_dt_vdevice (VIOsPAPRBus *bus,void *fdt);extern gchar *spapr_vio_stdout_path (VIOsPAPRBus *bus);static inline qemu_irq spapr_vio_qirq (VIOsPAPRDevice *dev)
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 21/73] ppc: Fix single step with gdb stub
In reply to David GibsonFrom: Benjamin Herrenschmidt <[email protected]>
--- target-ppc/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target-ppc/translate.c +1 -1
@@ -322,7 +322,7 @@ static void gen_debug_exception(DisasContext *ctx)*/ if ((ctx->exception !=POWERPC_EXCP_BRANCH ) && (ctx->exception !=POWERPC_EXCP_SYNC )) { -gen_update_nip (ctx, ctx->nip -4 ); +gen_update_nip (ctx, ctx->nip); } t0 =tcg_const_i32 (EXCP_DEBUG );gen_helper_raise_exception (cpu_env, t0);
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 35/73] pseries: Remove rtas_addr and fdt_addr fields from machinestate
In reply to David GibsonThese values are used only within ppc_spapr_reset(), so just change them to local variables.
--- hw/ppc/spapr.c | 14 +++++++------- include/hw/ppc/spapr.h | 1 - 2 files changed, 7 insertions(+), 8 deletions(-)
hw/ppc/spapr.c +7 -7
@@ -1135,6 +1135,7 @@ static void ppc_spapr_reset(void)sPAPRMachineState *spapr =SPAPR_MACHINE (machine);PowerPCCPU *first_ppc_cpu;uint32_t rtas_limit; +hwaddr rtas_addr, fdt_addr;void *fdt;int rc;
@@ -1160,14 +1161,13 @@ static void ppc_spapr_reset(void)* processed with 32-bit real mode code if necessary */ rtas_limit =MIN (spapr->rma_size,RTAS_MAX_ADDR ); - spapr->rtas_addr = rtas_limit -RTAS_MAX_SIZE ; - spapr->fdt_addr = spapr->rtas_addr -FDT_MAX_SIZE ; + rtas_addr = rtas_limit -RTAS_MAX_SIZE ; + fdt_addr = rtas_addr -FDT_MAX_SIZE ; - fdt =spapr_build_fdt (spapr, spapr->rtas_addr, spapr->rtas_size); + fdt =spapr_build_fdt (spapr, rtas_addr, spapr->rtas_size);/* Copy RTAS over */ -cpu_physical_memory_write (spapr->rtas_addr, spapr->rtas_blob, - spapr->rtas_size); +cpu_physical_memory_write (rtas_addr, spapr->rtas_blob, spapr->rtas_size); rc =fdt_pack (fdt);
@@ -1182,12 +1182,12 @@ static void ppc_spapr_reset(void)/* Load the fdt */ qemu_fdt_dumpdtb (fdt,fdt_totalsize (fdt)); -cpu_physical_memory_write (spapr->fdt_addr, fdt,fdt_totalsize (fdt)); +cpu_physical_memory_write (fdt_addr, fdt,fdt_totalsize (fdt));g_free (fdt);/* Set up the entry state */ first_ppc_cpu =POWERPC_CPU (first_cpu); - first_ppc_cpu->env.gpr[3 ] = spapr->fdt_addr; + first_ppc_cpu->env.gpr[3 ] = fdt_addr; first_ppc_cpu->env.gpr[5 ] =0 ; first_cpu->halted =0 ; first_ppc_cpu->env.nip =SPAPR_ENTRY_POINT ;
include/hw/ppc/spapr.h +0 -1
@@ -63,7 +63,6 @@ struct sPAPRMachineState {uint32_t htab_shift;hwaddr rma_size;int vrma_adjust; -hwaddr fdt_addr, rtas_addr;ssize_t rtas_size;void *rtas_blob;void *fdt_skel;
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 42/73] pseries: Move /event-sources construction to spapr_build_fdt()
In reply to David GibsonThe /event-sources device tree node is built from spapr_create_fdt_skel(). As part of consolidating device tree construction to reset time, this moves it to spapr_build_fdt().
--- hw/ppc/spapr.c | 6 +++--- hw/ppc/spapr_events.c | 21 ++++++++++----------- include/hw/ppc/spapr.h | 2 +- 3 files changed, 14 insertions(+), 15 deletions(-)
hw/ppc/spapr.c +3 -3
@@ -328,9 +328,6 @@ static void *spapr_create_fdt_skel(sPAPRMachineState *spapr)_FDT ((fdt_end_node (fdt))); -/* event-sources */ -spapr_events_fdt_skel (fdt, spapr->check_exception_irq); -/* /hypervisor node */ if (kvm_enabled ()) {uint8_t hypercall[16 ];
@@ -983,6 +980,9 @@ static void *spapr_build_fdt(sPAPRMachineState *spapr, } } +/* /event-sources */ +spapr_dt_events (fdt, spapr->check_exception_irq); +/* /rtas */ spapr_dt_rtas (spapr, fdt);
hw/ppc/spapr_events.c +10 -11
@@ -211,23 +211,22 @@ struct hp_log_full {#define EVENT_MASK_HOTPLUG 0x10000000#define EVENT_MASK_IO 0x08000000 -void spapr_events_fdt_skel (void *fdt,uint32_t check_exception_irq) +void spapr_dt_events (void *fdt,uint32_t check_exception_irq) { +int event_sources, epow_events;uint32_t irq_ranges[] = {cpu_to_be32 (check_exception_irq),cpu_to_be32 (1 )};uint32_t interrupts[] = {cpu_to_be32 (check_exception_irq),0 }; -_FDT ((fdt_begin_node (fdt,"event-sources" ))); +_FDT (event_sources =fdt_add_subnode (fdt,0 ,"event-sources" )); -_FDT ((fdt_property (fdt,"interrupt-controller" ,NULL ,0 ))); -_FDT ((fdt_property_cell (fdt,"#interrupt-cells" ,2 ))); -_FDT ((fdt_property (fdt,"interrupt-ranges" , - irq_ranges,sizeof (irq_ranges)))); +_FDT (fdt_setprop (fdt, event_sources,"interrupt-controller" ,NULL ,0 )); +_FDT (fdt_setprop_cell (fdt, event_sources,"#interrupt-cells" ,2 )); +_FDT (fdt_setprop (fdt, event_sources,"interrupt-ranges" , + irq_ranges,sizeof (irq_ranges))); -_FDT ((fdt_begin_node (fdt,"epow-events" ))); -_FDT ((fdt_property (fdt,"interrupts" , interrupts,sizeof (interrupts)))); -_FDT ((fdt_end_node (fdt))); - -_FDT ((fdt_end_node (fdt))); +_FDT (epow_events =fdt_add_subnode (fdt, event_sources,"epow-events" )); +_FDT (fdt_setprop (fdt, epow_events,"interrupts" , + interrupts,sizeof (interrupts))); }static void rtas_event_log_queue (int log_type,void *data,bool exception)
include/hw/ppc/spapr.h +1 -1
@@ -581,7 +581,7 @@ struct sPAPREventLogEntry { };void spapr_events_init (sPAPRMachineState *sm); -void spapr_events_fdt_skel (void *fdt,uint32_t epow_irq); +void spapr_dt_events (void *fdt,uint32_t check_exception_irq);int spapr_h_cas_compose_response (sPAPRMachineState *sm,target_ulong addr,target_ulong size,bool cpu_update,bool memory_update);
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 36/73] pseries: Make spapr_create_fdt_skel() get information from machine state
In reply to David GibsonCurrently spapr_create_fdt_skel() takes a bunch of individual parameters for various things it will put in the device tree. Some of these can already be taken directly from sPAPRMachineState. This patch alters it so that all of them can be taken from there, which will allow this code to be moved away from its current caller in future.
--- hw/ppc/spapr.c | 81 ++++++++++++++++++++++---------------------------- include/hw/ppc/spapr.h | 4 +++ 2 files changed, 40 insertions(+), 45 deletions(-)
hw/ppc/spapr.c +36 -45
@@ -271,16 +271,12 @@ static void add_str(GString *s, const gchar *s1)g_string_append_len (s, s1,strlen (s1) +1 ); } -static void *spapr_create_fdt_skel (hwaddr initrd_base, -hwaddr initrd_size, -hwaddr kernel_size, -bool little_endian, -const char *kernel_cmdline, -uint32_t epow_irq) +static void *spapr_create_fdt_skel (sPAPRMachineState *spapr) { +MachineState *machine =MACHINE (spapr);void *fdt; -uint32_t start_prop =cpu_to_be32 (initrd_base); -uint32_t end_prop =cpu_to_be32 (initrd_base + initrd_size); +uint32_t start_prop =cpu_to_be32 (spapr->initrd_base); +uint32_t end_prop =cpu_to_be32 (spapr->initrd_base + spapr->initrd_size);GString *hypertas =g_string_sized_new (256 );GString *qemu_hypertas =g_string_sized_new (256 );uint32_t refpoints[] = {cpu_to_be32 (0x4 ),cpu_to_be32 (0x4 )};
@@ -305,11 +301,13 @@ static void *spapr_create_fdt_skel(hwaddr initrd_base, fdt =g_malloc0 (FDT_MAX_SIZE );_FDT ((fdt_create (fdt,FDT_MAX_SIZE ))); -if (kernel_size) { -_FDT ((fdt_add_reservemap_entry (fdt,KERNEL_LOAD_ADDR , kernel_size))); +if (spapr->kernel_size) { +_FDT ((fdt_add_reservemap_entry (fdt,KERNEL_LOAD_ADDR , + spapr->kernel_size))); } -if (initrd_size) { -_FDT ((fdt_add_reservemap_entry (fdt, initrd_base, initrd_size))); +if (spapr->initrd_size) { +_FDT ((fdt_add_reservemap_entry (fdt, spapr->initrd_base, + spapr->initrd_size))); }_FDT ((fdt_finish_reservemap (fdt)));
@@ -354,17 +352,17 @@ static void *spapr_create_fdt_skel(hwaddr initrd_base,/* Set Form1_affinity */ _FDT ((fdt_property (fdt,"ibm,architecture-vec-5" , vec5,sizeof (vec5)))); -_FDT ((fdt_property_string (fdt,"bootargs" , kernel_cmdline))); +_FDT ((fdt_property_string (fdt,"bootargs" , machine->kernel_cmdline)));_FDT ((fdt_property (fdt,"linux,initrd-start" , &start_prop,sizeof (start_prop))));_FDT ((fdt_property (fdt,"linux,initrd-end" , &end_prop,sizeof (end_prop)))); -if (kernel_size) { +if (spapr->kernel_size) {uint64_t kprop[2 ] = {cpu_to_be64 (KERNEL_LOAD_ADDR ), -cpu_to_be64 (kernel_size) }; +cpu_to_be64 (spapr->kernel_size) };_FDT ((fdt_property (fdt,"qemu,boot-kernel" , &kprop,sizeof (kprop)))); -if (little_endian) { +if (spapr->kernel_le) {_FDT ((fdt_property (fdt,"qemu,boot-kernel-le" ,NULL ,0 ))); } }
@@ -441,7 +439,7 @@ static void *spapr_create_fdt_skel(hwaddr initrd_base,_FDT ((fdt_end_node (fdt)));/* event-sources */ -spapr_events_fdt_skel (fdt, epow_irq); +spapr_events_fdt_skel (fdt, spapr->check_exception_irq);/* /hypervisor node */ if (kvm_enabled ()) {
@@ -1686,7 +1684,6 @@ static void ppc_spapr_init(MachineState *machine)MachineClass *mc =MACHINE_GET_CLASS (machine);sPAPRMachineClass *smc =SPAPR_MACHINE_GET_CLASS (machine);const char *kernel_filename = machine->kernel_filename; -const char *kernel_cmdline = machine->kernel_cmdline;const char *initrd_filename = machine->initrd_filename;PCIHostState *phb;int i;
@@ -1696,10 +1693,7 @@ static void ppc_spapr_init(MachineState *machine)void *rma =NULL ;hwaddr rma_alloc_size;hwaddr node0_size =spapr_node0_size (); -uint32_t initrd_base =0 ; -long kernel_size =0 , initrd_size =0 ;long load_limit, fw_size; -bool kernel_le = false;char *filename;int smt =kvmppc_smt_threads ();int spapr_cores = smp_cpus / smp_threads;
@@ -1972,19 +1966,19 @@ static void ppc_spapr_init(MachineState *machine)if (kernel_filename) {uint64_t lowaddr =0 ; - kernel_size =load_elf (kernel_filename, translate_kernel_address,NULL , -NULL , &lowaddr,NULL ,1 ,PPC_ELF_MACHINE , -0 ,0 ); -if (kernel_size ==ELF_LOAD_WRONG_ENDIAN ) { - kernel_size =load_elf (kernel_filename, - translate_kernel_address,NULL , -NULL , &lowaddr,NULL ,0 ,PPC_ELF_MACHINE , -0 ,0 ); - kernel_le = kernel_size >0 ; - } -if (kernel_size <0 ) { -error_report ("error loading %s: %s" , - kernel_filename,load_elf_strerror (kernel_size)); + spapr->kernel_size =load_elf (kernel_filename, translate_kernel_address, +NULL ,NULL , &lowaddr,NULL ,1 , +PPC_ELF_MACHINE ,0 ,0 ); +if (spapr->kernel_size ==ELF_LOAD_WRONG_ENDIAN ) { + spapr->kernel_size =load_elf (kernel_filename, + translate_kernel_address,NULL ,NULL , + &lowaddr,NULL ,0 ,PPC_ELF_MACHINE , +0 ,0 ); + spapr->kernel_le = spapr->kernel_size >0 ; + } +if (spapr->kernel_size <0 ) { +error_report ("error loading %s: %s" , kernel_filename, +load_elf_strerror (spapr->kernel_size));exit (1 ); }
@@ -1993,17 +1987,17 @@ static void ppc_spapr_init(MachineState *machine)/* Try to locate the initrd in the gap between the kernel * and the firmware. Add a bit of space just in case */ - initrd_base = (KERNEL_LOAD_ADDR + kernel_size +0x1ffff ) & ~0xffff ; - initrd_size =load_image_targphys (initrd_filename, initrd_base, - load_limit - initrd_base); -if (initrd_size <0 ) { + spapr->initrd_base = (KERNEL_LOAD_ADDR + spapr->kernel_size + +0x1ffff ) & ~0xffff ; + spapr->initrd_size =load_image_targphys (initrd_filename, + spapr->initrd_base, + load_limit + - spapr->initrd_base); +if (spapr->initrd_size <0 ) {error_report ("could not load initial ram disk '%s'" , initrd_filename);exit (1 ); } - }else { - initrd_base =0 ; - initrd_size =0 ; } }
@@ -2030,10 +2024,7 @@ static void ppc_spapr_init(MachineState *machine) &savevm_htab_handlers, spapr);/* Prepare the device tree */ - spapr->fdt_skel =spapr_create_fdt_skel (initrd_base, initrd_size, - kernel_size, kernel_le, - kernel_cmdline, - spapr->check_exception_irq); + spapr->fdt_skel =spapr_create_fdt_skel (spapr);assert (spapr->fdt_skel !=NULL );/* used by RTAS */
include/hw/ppc/spapr.h +4 -0
@@ -65,6 +65,10 @@ struct sPAPRMachineState {int vrma_adjust;ssize_t rtas_size;void *rtas_blob; +long kernel_size; +bool kernel_le; +uint32_t initrd_base; +long initrd_size;void *fdt_skel;uint64_t rtc_offset;/* Now used only during incoming migration */ struct PPCTimebase tb;
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 29/73] ppc/pnv: add XSCOM infrastructure
In reply to David GibsonFrom: Cédric Le Goater <[email protected]>
On a real POWER8 system, the Pervasive Interconnect Bus (PIB) serves as a backbone to connect different units of the system. The host firmware connects to the PIB through a bridge unit, the Alter-Display-Unit (ADU), which gives him access to all the chiplets on the PCB network (Pervasive Connect Bus), the PIB acting as the root of this network.
XSCOM (serial communication) is the interface to the sideband bus provided by the POWER8 pervasive unit to read and write to chiplets resources. This is needed by the host firmware, OPAL and to a lesser extent, Linux. This is among others how the PCI Host bridges get configured at boot or how the LPC bus is accessed.
To represent the ADU of a real system, we introduce a specific AddressSpace to dispatch XSCOM accesses to the targeted chiplets. The translation of an XSCOM address into a PCB register address is slightly different between the P9 and the P8. This is handled before the dispatch using a 8byte alignment for all.
To customize the device tree, a QOM InterfaceClass, PnvXScomInterface, is provided with a populate() handler. The chip populates the device tree by simply looping on its children. Therefore, each model needing custom nodes should not forget to declare itself as a child at instantiation time.
Based on previous work done by :
Benjamin Herrenschmidt <[email protected]>
--- hw/ppc/Makefile.objs | 2 +- hw/ppc/pnv.c | 25 +++++ hw/ppc/pnv_xscom.c | 275 +++++++++++++++++++++++++++++++++++++++++++++ include/hw/ppc/pnv.h | 15 +++ include/hw/ppc/pnv_xscom.h | 56 +++++++++ 5 files changed, 372 insertions(+), 1 deletion(-) create mode 100644 hw/ppc/pnv_xscom.c create mode 100644 include/hw/ppc/pnv_xscom.h
hw/ppc/Makefile.objs +1 -1
@@ -6,7 +6,7 @@ obj-$(CONFIG_PSERIES) += spapr_hcall.o spapr_iommu.o spapr_rtas.o obj-$(CONFIG_PSERIES) += spapr_pci.o spapr_rtc.o spapr_drc.o spapr_rng.o obj-$(CONFIG_PSERIES) += spapr_cpu_core.o # IBM PowerNV -obj-$(CONFIG_POWERNV) += pnv.o pnv_core.o +obj-$(CONFIG_POWERNV) += pnv.o pnv_xscom.o pnv_core.o ifeq ($(CONFIG_PCI)$(CONFIG_PSERIES)$(CONFIG_LINUX), yyy) obj-y += spapr_pci_vfio.o endif
hw/ppc/pnv.c +25 -0
@@ -33,6 +33,8 @@#include "qemu/cutils.h" #include "qapi/visitor.h" +#include "hw/ppc/pnv_xscom.h" +#include <libfdt.h> #define FDT_MAX_SIZE 0x00100000
@@ -219,6 +221,8 @@ static void powernv_populate_chip(PnvChip *chip, void *fdt)size_t typesize =object_type_get_instance_size (typename);int i; +pnv_xscom_populate (chip, fdt,0 ); +for (i =0 ; i < chip->nr_cores; i++) {PnvCore *pnv_core =PNV_CORE (chip->cores + i * typesize);
@@ -455,6 +459,7 @@ static void pnv_chip_power8e_class_init(ObjectClass *klass, void *data) k->chip_cfam_id =0x221ef04980000000ull ;/* P8 Murano DD2.1 */ k->cores_mask =POWER8E_CORE_MASK ; k->core_pir = pnv_chip_core_pir_p8; + k->xscom_base =0x003fc0000000000ull ; dc->desc ="PowerNV Chip POWER8E" ; }
@@ -475,6 +480,7 @@ static void pnv_chip_power8_class_init(ObjectClass *klass, void *data) k->chip_cfam_id =0x220ea04980000000ull ;/* P8 Venice DD2.0 */ k->cores_mask =POWER8_CORE_MASK ; k->core_pir = pnv_chip_core_pir_p8; + k->xscom_base =0x003fc0000000000ull ; dc->desc ="PowerNV Chip POWER8" ; }
@@ -495,6 +501,7 @@ static void pnv_chip_power8nvl_class_init(ObjectClass *klass, void *data) k->chip_cfam_id =0x120d304980000000ull ;/* P8 Naples DD1.0 */ k->cores_mask =POWER8_CORE_MASK ; k->core_pir = pnv_chip_core_pir_p8; + k->xscom_base =0x003fc0000000000ull ; dc->desc ="PowerNV Chip POWER8NVL" ; }
@@ -515,6 +522,7 @@ static void pnv_chip_power9_class_init(ObjectClass *klass, void *data) k->chip_cfam_id =0x100d104980000000ull ;/* P9 Nimbus DD1.0 */ k->cores_mask =POWER9_CORE_MASK ; k->core_pir = pnv_chip_core_pir_p9; + k->xscom_base =0x00603fc00000000ull ; dc->desc ="PowerNV Chip POWER9" ; }
@@ -555,6 +563,14 @@ static void pnv_chip_core_sanitize(PnvChip *chip, Error **errp) } } +static void pnv_chip_init (Object *obj) +{ +PnvChip *chip =PNV_CHIP (obj); +PnvChipClass *pcc =PNV_CHIP_GET_CLASS (chip); + + chip->xscom_base = pcc->xscom_base; +} +static void pnv_chip_realize (DeviceState *dev,Error **errp) {PnvChip *chip =PNV_CHIP (dev);
@@ -569,6 +585,14 @@ 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) {
@@ -628,6 +652,7 @@ static const TypeInfo pnv_chip_info = { .name = TYPE_PNV_CHIP, .parent = TYPE_SYS_BUS_DEVICE, .class_init = pnv_chip_class_init, + .instance_init = pnv_chip_init, .class_size = sizeof(PnvChipClass), .abstract = true, };
hw/ppc/pnv_xscom.c new file +275 -0
275 lines not on this page · raw message
include/hw/ppc/pnv.h +15 -0
@@ -21,6 +21,7 @@#include "hw/boards.h" #include "hw/sysbus.h" +#include "hw/ppc/pnv_xscom.h" #define TYPE_PNV_CHIP "powernv-chip"#define PNV_CHIP (obj) OBJECT_CHECK(PnvChip, (obj), TYPE_PNV_CHIP)
@@ -48,6 +49,11 @@ typedef struct PnvChip {uint32_t nr_cores;uint64_t cores_mask;void *cores; + +hwaddr xscom_base; +MemoryRegion xscom_mmio; +MemoryRegion xscom; +AddressSpace xscom_as; } PnvChip; typedef struct PnvChipClass {
@@ -60,6 +66,8 @@ typedef struct PnvChipClass {uint64_t chip_cfam_id;uint64_t cores_mask; +hwaddr xscom_base; +uint32_t (*core_pir)(PnvChip *chip,uint32_t core_id); } PnvChipClass;
@@ -106,4 +114,11 @@ typedef struct PnvMachineState {#define PNV_FDT_ADDR 0x01000000#define PNV_TIMEBASE_FREQ 512000000ULL +/* +* POWER8 MMIO base addresses +*/ +#define PNV_XSCOM_SIZE 0x800000000ull +#define PNV_XSCOM_BASE (chip) \ + (chip->xscom_base + ((uint64_t)(chip)->chip_id) * PNV_XSCOM_SIZE) +#endif /* _PPC_PNV_H */
include/hw/ppc/pnv_xscom.h new file +56 -0
56 lines not on this page · raw message
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 30/73] ppc/pnv: add XSCOM handlers to PnvCore
In reply to David GibsonFrom: Cédric Le Goater <[email protected]>
Now that we are using real HW ids for the cores in PowerNV chips, we can route the XSCOM accesses to them. We just need to attach a specific XSCOM memory region to each core in the appropriate window for the core number.
To start with, let's install the DTS (Digital Thermal Sensor) handlers which should return 38°C for each core.
--- hw/ppc/pnv.c | 4 ++++ hw/ppc/pnv_core.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++ include/hw/ppc/pnv_core.h | 2 ++ include/hw/ppc/pnv_xscom.h | 19 ++++++++++++++++++ 4 files changed, 75 insertions(+)
hw/ppc/pnv.c +4 -0
@@ -625,6 +625,10 @@ static void pnv_chip_realize(DeviceState *dev, Error **errp)object_property_set_bool (OBJECT (pnv_core), true,"realized" , &error_fatal);object_unref (OBJECT (pnv_core)); + +/* Each core has an XSCOM MMIO region */ +pnv_xscom_add_subregion (chip,PNV_XSCOM_EX_CORE_BASE (core_hwid), + &PNV_CORE (pnv_core)->xscom_regs); i++; }g_free (typename);
hw/ppc/pnv_core.c +50 -0
68 lines not on this page · raw message
include/hw/ppc/pnv_core.h +2 -0
@@ -36,6 +36,8 @@ typedef struct PnvCore {/*< public >*/ void *threads;uint32_t pir; + +MemoryRegion xscom_regs; } PnvCore; typedef struct PnvCoreClass {
include/hw/ppc/pnv_xscom.h +19 -0
@@ -41,6 +41,25 @@ typedef struct PnvXScomInterfaceClass {int (*populate)(PnvXScomInterface *dev,void *fdt,int offset); } PnvXScomInterfaceClass; +/* +* Layout of the XSCOM PCB addresses of EX core 1 +* +* GPIO 0x1100xxxx +* SCOM 0x1101xxxx +* OHA 0x1102xxxx +* CLOCK CTL 0x1103xxxx +* FIR 0x1104xxxx +* THERM 0x1105xxxx +* <reserved> 0x1106xxxx +* .. +* 0x110Exxxx +* PCB SLAVE 0x110Fxxxx +*/ + +#define PNV_XSCOM_EX_BASE 0x10000000 +#define PNV_XSCOM_EX_CORE_BASE (i) (PNV_XSCOM_EX_BASE | (((uint64_t)i) << 24)) +#define PNV_XSCOM_EX_CORE_SIZE 0x100000 +extern void pnv_xscom_realize (PnvChip *chip,Error **errp);extern int pnv_xscom_populate (PnvChip *chip,void *fdt,int offset);
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 31/73] ppc/pnv: add a LPC controller
In reply to David GibsonFrom: Benjamin Herrenschmidt <[email protected]>
The LPC (Low Pin Count) interface on a POWER8 is made accessible to the system through the ADU (XSCOM interface). This interface is part of set of units connected together via a local OPB (On-Chip Peripheral Bus) which act as a bridge between the ADU and the off chip LPC endpoints, like external flash modules.
The most important units of this OPB are :
- OPB Master: contains the ADU slave logic, a set of internal registers and the logic to control the OPB.
- LPCHC (LPC HOST Controller): which implements a OPB Slave, a set of internal registers and the LPC HOST Controller to control the LPC interface.
Four address spaces are provided to the ADU :
- LPC Bus Firmware Memory
- LPC Bus Memory
- LPC Bus I/O (ISA bus)
- and the registers for the OPB Master and the LPC Host Controller
On POWER8, an intermediate hop is necessary to reach the OPB, through a unit called the ECCB. OPB commands are simply mangled in ECCB write commands.
On POWER9, the OPB master address space can be accessed via MMIO. The logic is same but the code will be simpler as the XSCOM and ECCB hops are not necessary anymore.
This version of the LPC controller model doesn't yet implement support for the SerIRQ deserializer present in the Naples version of the chip though some preliminary work is there.
[clg: - updated for qemu-2.7
- ported on latest PowerNV patchset
- changed the XSCOM interface to fit new model
- QOMified the model
- moved the ISA hunks in another patch
- removed printf logging
- added a couple of UNIMP logging
- rewrote commit log ]
--- hw/ppc/Makefile.objs | 2 +- hw/ppc/pnv.c | 8 + hw/ppc/pnv_lpc.c | 471 +++++++++++++++++++++++++++++++++++++++++++++ include/hw/ppc/pnv.h | 3 + include/hw/ppc/pnv_lpc.h | 67 +++++++ include/hw/ppc/pnv_xscom.h | 3 + 6 files changed, 553 insertions(+), 1 deletion(-) create mode 100644 hw/ppc/pnv_lpc.c create mode 100644 include/hw/ppc/pnv_lpc.h
hw/ppc/Makefile.objs +1 -1
@@ -6,7 +6,7 @@ obj-$(CONFIG_PSERIES) += spapr_hcall.o spapr_iommu.o spapr_rtas.o obj-$(CONFIG_PSERIES) += spapr_pci.o spapr_rtc.o spapr_drc.o spapr_rng.o obj-$(CONFIG_PSERIES) += spapr_cpu_core.o # IBM PowerNV -obj-$(CONFIG_POWERNV) += pnv.o pnv_xscom.o pnv_core.o +obj-$(CONFIG_POWERNV) += pnv.o pnv_xscom.o pnv_core.o pnv_lpc.o ifeq ($(CONFIG_PCI)$(CONFIG_PSERIES)$(CONFIG_LINUX), yyy) obj-y += spapr_pci_vfio.o endif
hw/ppc/pnv.c +8 -0
@@ -569,6 +569,9 @@ static void pnv_chip_init(Object *obj)PnvChipClass *pcc =PNV_CHIP_GET_CLASS (chip); chip->xscom_base = pcc->xscom_base; + +object_initialize (&chip->lpc,sizeof (chip->lpc),TYPE_PNV_LPC ); +object_property_add_child (obj,"lpc" ,OBJECT (&chip->lpc),NULL ); }static void pnv_chip_realize (DeviceState *dev,Error **errp)
@@ -632,6 +635,11 @@ static void pnv_chip_realize(DeviceState *dev, Error **errp) i++; }g_free (typename); + +/* Create LPC controller */ +object_property_set_bool (OBJECT (&chip->lpc), true,"realized" , + &error_fatal); +pnv_xscom_add_subregion (chip,PNV_XSCOM_LPC_BASE , &chip->lpc.xscom_regs); }static Property pnv_chip_properties[] = {
hw/ppc/pnv_lpc.c new file +471 -0
471 lines not on this page · raw message
include/hw/ppc/pnv.h +3 -0
@@ -22,6 +22,7 @@#include "hw/boards.h" #include "hw/sysbus.h" #include "hw/ppc/pnv_xscom.h" +#include "hw/ppc/pnv_lpc.h" #define TYPE_PNV_CHIP "powernv-chip"#define PNV_CHIP (obj) OBJECT_CHECK(PnvChip, (obj), TYPE_PNV_CHIP)
@@ -54,6 +55,8 @@ typedef struct PnvChip {MemoryRegion xscom_mmio;MemoryRegion xscom;AddressSpace xscom_as; + +PnvLpcController lpc; } PnvChip; typedef struct PnvChipClass {
include/hw/ppc/pnv_lpc.h new file +67 -0
67 lines not on this page · raw message
include/hw/ppc/pnv_xscom.h +3 -0
@@ -60,6 +60,9 @@ typedef struct PnvXScomInterfaceClass {#define PNV_XSCOM_EX_CORE_BASE (i) (PNV_XSCOM_EX_BASE | (((uint64_t)i) << 24))#define PNV_XSCOM_EX_CORE_SIZE 0x100000 +#define PNV_XSCOM_LPC_BASE 0xb0020 +#define PNV_XSCOM_LPC_SIZE 0x4 +extern void pnv_xscom_realize (PnvChip *chip,Error **errp);extern int pnv_xscom_populate (PnvChip *chip,void *fdt,int offset);
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 32/73] ppc/pnv: add a ISA bus
In reply to David GibsonFrom: Cédric Le Goater <[email protected]>
As Qemu only supports a single instance of the ISA bus, we use the LPC controller of chip 0 to create one and plug in a couple of useful devices, like an UART and RTC. An IPMI BT device, which is also an ISA device, can be defined on the command line to connect an external BMC. That is for later.
The PowerNV machine now has a console. Skiboot should load a kernel and jump into it but execution will stop quite early because we lack a model for the native XICS controller for the moment :
[ 0.000000] NR_IRQS:512 nr_irqs:512 16
[ 0.000000] XICS: Cannot find a Presentation Controller !
[ 0.000000] ------------[ cut here ]------------
[ 0.000000] WARNING: at arch/powerpc/platforms/powernv/setup.c:81
...
[ 0.000000] NIP [c00000000079d65c] pnv_init_IRQ+0x30/0x44You can still do a few things under xmon.
Based on previous work from :
Benjamin Herrenschmidt <[email protected]>
--- hw/ppc/pnv.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++ include/hw/ppc/pnv.h | 2 ++ 2 files changed, 67 insertions(+)
hw/ppc/pnv.c +65 -0
@@ -35,6 +35,10 @@#include "hw/ppc/pnv_xscom.h" +#include "hw/isa/isa.h" +#include "hw/char/serial.h" +#include "hw/timer/mc146818rtc.h" +#include <libfdt.h> #define FDT_MAX_SIZE 0x00100000
@@ -301,6 +305,58 @@ static void ppc_powernv_reset(void)cpu_physical_memory_write (PNV_FDT_ADDR , fdt,fdt_totalsize (fdt)); } +/* If we don't use the built-in LPC interrupt deserializer, we need +* to provide a set of qirqs for the ISA bus or things will go bad. +* +* Most machines using pre-Naples chips (without said deserializer) +* have a CPLD that will collect the SerIRQ and shoot them as a +* single level interrupt to the P8 chip. So let's setup a hook +* for doing just that. +* +* Note: The actual interrupt input isn't emulated yet, this will +* come with the PSI bridge model. +*/ +static void pnv_lpc_isa_irq_handler_cpld (void *opaque,int n,int level) +{ +/* We don't yet emulate the PSI bridge which provides the external +* interrupt, so just drop interrupts on the floor +*/ +} + +static void pnv_lpc_isa_irq_handler (void *opaque,int n,int level) +{ +/* XXX TODO */ +} + +static ISABus *pnv_isa_create (PnvChip *chip) +{ +PnvLpcController *lpc = &chip->lpc; +ISABus *isa_bus; +qemu_irq *irqs; +PnvChipClass *pcc =PNV_CHIP_GET_CLASS (chip); + +/* let isa_bus_new() create its own bridge on SysBus otherwise +* devices speficied on the command line won't find the bus and +* will fail to create. +*/ + isa_bus =isa_bus_new (NULL , &lpc->isa_mem, &lpc->isa_io, + &error_fatal); + +/* Not all variants have a working serial irq decoder. If not, +* handling of LPC interrupts becomes a platform issue (some +* platforms have a CPLD to do it). +*/ +if (pcc->chip_type ==PNV_CHIP_POWER8NVL ) { + irqs =qemu_allocate_irqs (pnv_lpc_isa_irq_handler, chip,ISA_NUM_IRQS ); + }else { + irqs =qemu_allocate_irqs (pnv_lpc_isa_irq_handler_cpld, chip, +ISA_NUM_IRQS ); + } + +isa_bus_irqs (isa_bus, irqs); +return isa_bus; +} +static void ppc_powernv_init (MachineState *machine) {PnvMachineState *pnv =POWERNV_MACHINE (machine);
@@ -395,6 +451,15 @@ static void ppc_powernv_init(MachineState *machine)object_property_set_bool (chip, true,"realized" , &error_fatal); }g_free (chip_typename); + +/* Instantiate ISA bus on chip 0 */ + pnv->isa_bus =pnv_isa_create (pnv->chips[0 ]); + +/* Create serial port */ +serial_hds_isa_init (pnv->isa_bus,0 ,MAX_SERIAL_PORTS ); + +/* Create an RTC ISA device too */ +rtc_init (pnv->isa_bus,2000 ,NULL ); }/*
include/hw/ppc/pnv.h +2 -0
@@ -112,6 +112,8 @@ typedef struct PnvMachineState {uint32_t num_chips;PnvChip **chips; + +ISABus *isa_bus; } PnvMachineState;#define PNV_FDT_ADDR 0x01000000
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 45/73] pseries: Remove spapr_create_fdt_skel()
In reply to David GibsonFor historical reasons construction of the guest device tree in spapr is divided between spapr_create_fdt_skel() which is called at init time, and spapr_build_fdt() which runs at reset time. Over time, more and more things have needed to be moved to reset time.
Previous cleanups mean the only things left in spapr_create_fdt_skel() are the properties of the root node itself. Finish consolidating these two parts of device tree construction, by moving this to the start of spapr_build_fdt(), and removing spapr_create_fdt_skel() entirely.
--- hw/ppc/spapr.c | 94 +++++++++++++++++++------------------------------- include/hw/ppc/spapr.h | 1 - 2 files changed, 36 insertions(+), 59 deletions(-)
hw/ppc/spapr.c +36 -58
@@ -271,57 +271,6 @@ static void add_str(GString *s, const gchar *s1)g_string_append_len (s, s1,strlen (s1) +1 ); } -static void *spapr_create_fdt_skel (sPAPRMachineState *spapr) -{ -void *fdt; -char *buf; - - fdt =g_malloc0 (FDT_MAX_SIZE ); -_FDT ((fdt_create (fdt,FDT_MAX_SIZE ))); - -_FDT ((fdt_finish_reservemap (fdt))); - -/* Root node */ -_FDT ((fdt_begin_node (fdt,"" ))); -_FDT ((fdt_property_string (fdt,"device_type" ,"chrp" ))); -_FDT ((fdt_property_string (fdt,"model" ,"IBM pSeries (emulated by qemu)" ))); -_FDT ((fdt_property_string (fdt,"compatible" ,"qemu,pseries" ))); - -/* -* Add info to guest to indentify which host is it being run on -* and what is the uuid of the guest -*/ -if (kvmppc_get_host_model (&buf)) { -_FDT ((fdt_property_string (fdt,"host-model" , buf))); -g_free (buf); - } -if (kvmppc_get_host_serial (&buf)) { -_FDT ((fdt_property_string (fdt,"host-serial" , buf))); -g_free (buf); - } - - buf =qemu_uuid_unparse_strdup (&qemu_uuid); - -_FDT ((fdt_property_string (fdt,"vm,uuid" , buf))); -if (qemu_uuid_set) { -_FDT ((fdt_property_string (fdt,"system-id" , buf))); - } -g_free (buf); - -if (qemu_get_vm_name ()) { -_FDT ((fdt_property_string (fdt,"ibm,partition-name" , -qemu_get_vm_name ()))); - } - -_FDT ((fdt_property_cell (fdt,"#address-cells" ,0x2 ))); -_FDT ((fdt_property_cell (fdt,"#size-cells" ,0x2 ))); - -_FDT ((fdt_end_node (fdt)));/* close root node */ -_FDT ((fdt_finish (fdt))); - -return fdt; -} -static int spapr_populate_memory_node (void *fdt,int nodeid,hwaddr start,hwaddr size) {
@@ -916,11 +865,44 @@ static void *spapr_build_fdt(sPAPRMachineState *spapr,int ret;void *fdt;sPAPRPHBState *phb; +char *buf; - fdt =g_malloc (FDT_MAX_SIZE ); + fdt =g_malloc0 (FDT_MAX_SIZE ); +_FDT ((fdt_create_empty_tree (fdt,FDT_MAX_SIZE ))); -/* open out the base tree into a temp buffer for the final tweaks */ -_FDT ((fdt_open_into (spapr->fdt_skel, fdt,FDT_MAX_SIZE ))); +/* Root node */ +_FDT (fdt_setprop_string (fdt,0 ,"device_type" ,"chrp" )); +_FDT (fdt_setprop_string (fdt,0 ,"model" ,"IBM pSeries (emulated by qemu)" )); +_FDT (fdt_setprop_string (fdt,0 ,"compatible" ,"qemu,pseries" )); + +/* +* Add info to guest to indentify which host is it being run on +* and what is the uuid of the guest +*/ +if (kvmppc_get_host_model (&buf)) { +_FDT (fdt_setprop_string (fdt,0 ,"host-model" , buf)); +g_free (buf); + } +if (kvmppc_get_host_serial (&buf)) { +_FDT (fdt_setprop_string (fdt,0 ,"host-serial" , buf)); +g_free (buf); + } + + buf =qemu_uuid_unparse_strdup (&qemu_uuid); + +_FDT (fdt_setprop_string (fdt,0 ,"vm,uuid" , buf)); +if (qemu_uuid_set) { +_FDT (fdt_setprop_string (fdt,0 ,"system-id" , buf)); + } +g_free (buf); + +if (qemu_get_vm_name ()) { +_FDT (fdt_setprop_string (fdt,0 ,"ibm,partition-name" , +qemu_get_vm_name ())); + } + +_FDT (fdt_setprop_cell (fdt,0 ,"#address-cells" ,2 )); +_FDT (fdt_setprop_cell (fdt,0 ,"#size-cells" ,2 ));/* /interrupt controller */ spapr_dt_xics (spapr->xics, fdt,PHANDLE_XICP );
@@ -2014,10 +1996,6 @@ static void ppc_spapr_init(MachineState *machine)register_savevm_live (NULL ,"spapr/htab" ,-1 ,1 , &savevm_htab_handlers, spapr); -/* Prepare the device tree */ - spapr->fdt_skel =spapr_create_fdt_skel (spapr); -assert (spapr->fdt_skel !=NULL ); -/* used by RTAS */ QTAILQ_INIT (&spapr->ccs_list);qemu_register_reset (spapr_ccs_reset_hook, spapr);
include/hw/ppc/spapr.h +0 -1
@@ -69,7 +69,6 @@ struct sPAPRMachineState {bool kernel_le;uint32_t initrd_base;long initrd_size; -void *fdt_skel;uint64_t rtc_offset;/* Now used only during incoming migration */ struct PPCTimebase tb;bool has_graphics;
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 39/73] pseries: Move construction of /interrupt-controller fdt node
In reply to David GibsonCurrently the device tree node for the XICS interrupt controller is in spapr_create_fdt_skel(). As part of consolidating device tree construction to reset time, this moves it to a function called from spapr_build_fdt().
In addition we move the actual code into hw/intc/xics_spapr.c with the rest of the PAPR specific interrupt controller code.
--- hw/intc/xics_spapr.c | 22 ++++++++++++++++++++++ hw/ppc/spapr.c | 20 +++----------------- include/hw/ppc/xics.h | 1 + 3 files changed, 26 insertions(+), 17 deletions(-)
hw/intc/xics_spapr.c +22 -0
@@ -32,6 +32,7 @@#include "qemu/timer.h" #include "hw/ppc/spapr.h" #include "hw/ppc/xics.h" +#include "hw/ppc/fdt.h" #include "qapi/visitor.h" #include "qapi/error.h"
@@ -449,6 +450,27 @@ void xics_spapr_free(XICSState *xics, int irq, int num) } } +void spapr_dt_xics (XICSState *xics,void *fdt,uint32_t phandle) +{ +uint32_t interrupt_server_ranges_prop[] = { +0 ,cpu_to_be32 (xics->nr_servers), + }; +int node; + +_FDT (node =fdt_add_subnode (fdt,0 ,"interrupt-controller" )); + +_FDT (fdt_setprop_string (fdt, node,"device_type" , +"PowerPC-External-Interrupt-Presentation" )); +_FDT (fdt_setprop_string (fdt, node,"compatible" ,"IBM,ppc-xicp" )); +_FDT (fdt_setprop (fdt, node,"interrupt-controller" ,NULL ,0 )); +_FDT (fdt_setprop (fdt, node,"ibm,interrupt-server-ranges" , + interrupt_server_ranges_prop, +sizeof (interrupt_server_ranges_prop))); +_FDT (fdt_setprop_cell (fdt, node,"#interrupt-cells" ,2 )); +_FDT (fdt_setprop_cell (fdt, node,"linux,phandle" , phandle)); +_FDT (fdt_setprop_cell (fdt, node,"phandle" , phandle)); +} +static void xics_spapr_register_types (void ) {type_register_static (&xics_spapr_info);
hw/ppc/spapr.c +3 -17
@@ -280,7 +280,6 @@ static void *spapr_create_fdt_skel(sPAPRMachineState *spapr)GString *hypertas =g_string_sized_new (256 );GString *qemu_hypertas =g_string_sized_new (256 );uint32_t refpoints[] = {cpu_to_be32 (0x4 ),cpu_to_be32 (0x4 )}; -uint32_t interrupt_server_ranges_prop[] = {0 ,cpu_to_be32 (max_cpus)};unsigned char vec5[] = {0x0 ,0x0 ,0x0 ,0x0 ,0x0 ,0x80 };char *buf;
@@ -402,22 +401,6 @@ static void *spapr_create_fdt_skel(sPAPRMachineState *spapr)_FDT ((fdt_end_node (fdt))); -/* interrupt controller */ -_FDT ((fdt_begin_node (fdt,"interrupt-controller" ))); - -_FDT ((fdt_property_string (fdt,"device_type" , -"PowerPC-External-Interrupt-Presentation" ))); -_FDT ((fdt_property_string (fdt,"compatible" ,"IBM,ppc-xicp" ))); -_FDT ((fdt_property (fdt,"interrupt-controller" ,NULL ,0 ))); -_FDT ((fdt_property (fdt,"ibm,interrupt-server-ranges" , - interrupt_server_ranges_prop, -sizeof (interrupt_server_ranges_prop)))); -_FDT ((fdt_property_cell (fdt,"#interrupt-cells" ,2 ))); -_FDT ((fdt_property_cell (fdt,"linux,phandle" ,PHANDLE_XICP ))); -_FDT ((fdt_property_cell (fdt,"phandle" ,PHANDLE_XICP ))); - -_FDT ((fdt_end_node (fdt))); -/* vdevice */ _FDT ((fdt_begin_node (fdt,"vdevice" )));
@@ -909,6 +892,9 @@ static void *spapr_build_fdt(sPAPRMachineState *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 ))); +/* /interrupt controller */ +spapr_dt_xics (spapr->xics, fdt,PHANDLE_XICP ); + ret =spapr_populate_memory (spapr, fdt);if (ret <0 ) {error_report ("couldn't setup memory nodes in fdt" );
include/hw/ppc/xics.h +1 -0
@@ -187,6 +187,7 @@ int xics_spapr_alloc(XICSState *icp, int irq_hint, bool lsi, Error **errp);int xics_spapr_alloc_block (XICSState *icp,int num,bool lsi,bool align,Error **errp);void xics_spapr_free (XICSState *icp,int irq,int num); +void spapr_dt_xics (XICSState *xics,void *fdt,uint32_t phandle);void xics_cpu_setup (XICSState *icp,PowerPCCPU *cpu);void xics_cpu_destroy (XICSState *icp,PowerPCCPU *cpu);
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 33/73] target-ppc: add vmul10[u, eu, cu, ecu]q instructions
In reply to David GibsonFrom: Vasant Hegde <[email protected]>
vmul10uq : Vector Multiply-by-10 Unsigned Quadword VX-form
vmul10euq : Vector Multiply-by-10 Extended Unsigned Quadword VX-form vmul10cuq : Vector Multiply-by-10 & write Carry Unsigned Quadword VX-form
vmul10ecuq: Vector Multiply-by-10 Extended & write Carry Unsigned Quadword VX-form
--- target-ppc/translate/vmx-impl.inc.c | 72 +++++++++++++++++++++++++++++++++++++ target-ppc/translate/vmx-ops.inc.c | 8 ++--- 2 files changed, 76 insertions(+), 4 deletions(-)
target-ppc/translate/vmx-impl.inc.c +72 -0
@@ -182,6 +182,52 @@ static void gen_mtvscr(DisasContext *ctx)tcg_temp_free_ptr (p); } +#define GEN_VX_VMUL10 (name, add_cin, ret_carry) \ +static void glue(gen_, name)(DisasContext *ctx) \ +{ \ + TCGv_i64 t0 = tcg_temp_new_i64(); \ + TCGv_i64 t1 = tcg_temp_new_i64(); \ + TCGv_i64 t2 = tcg_temp_new_i64(); \ + TCGv_i64 ten, z; \ + \ + if (unlikely(!ctx->altivec_enabled)) { \ + gen_exception(ctx, POWERPC_EXCP_VPU); \ + return; \ + } \ + \ + ten = tcg_const_i64(10); \ + z = tcg_const_i64(0); \ + \ + if (add_cin) { \ + tcg_gen_mulu2_i64(t0, t1, cpu_avrl[rA(ctx->opcode)], ten); \ + tcg_gen_andi_i64(t2, cpu_avrl[rB(ctx->opcode)], 0xF); \ + tcg_gen_add2_i64(cpu_avrl[rD(ctx->opcode)], t2, t0, t1, t2, z); \ + } else { \ + tcg_gen_mulu2_i64(cpu_avrl[rD(ctx->opcode)], t2, \ + cpu_avrl[rA(ctx->opcode)], ten); \ + } \ + \ + if (ret_carry) { \ + tcg_gen_mulu2_i64(t0, t1, cpu_avrh[rA(ctx->opcode)], ten); \ + tcg_gen_add2_i64(t0, cpu_avrl[rD(ctx->opcode)], t0, t1, t2, z); \ + tcg_gen_movi_i64(cpu_avrh[rD(ctx->opcode)], 0); \ + } else { \ + tcg_gen_mul_i64(t0, cpu_avrh[rA(ctx->opcode)], ten); \ + tcg_gen_add_i64(cpu_avrh[rD(ctx->opcode)], t0, t2); \ + } \ + \ + tcg_temp_free_i64(t0); \ + tcg_temp_free_i64(t1); \ + tcg_temp_free_i64(t2); \ + tcg_temp_free_i64(ten); \ + tcg_temp_free_i64(z); \ +} \ + +GEN_VX_VMUL10 (vmul10uq,0 ,0 ); +GEN_VX_VMUL10 (vmul10euq,1 ,0 ); +GEN_VX_VMUL10 (vmul10cuq,0 ,1 ); +GEN_VX_VMUL10 (vmul10ecuq,1 ,1 ); +/* Logical operations */ #define GEN_VX_LOGICAL (name, tcg_op, opc2, opc3) \ static void glue(gen_, name)(DisasContext *ctx) \
@@ -276,8 +322,30 @@ static void glue(gen_, name0##_##name1)(DisasContext *ctx) \ } \ } +/* Adds support to provide invalid mask */ +#define GEN_VXFORM_DUAL_EXT (name0, flg0, flg2_0, inval0, \ + name1, flg1, flg2_1, inval1) \ +static void glue(gen_, name0##_##name1)(DisasContext *ctx) \ +{ \ + if ((Rc(ctx->opcode) == 0) && \ + ((ctx->insns_flags & flg0) || (ctx->insns_flags2 & flg2_0)) && \ + !(ctx->opcode & inval0)) { \ + gen_##name0(ctx); \ + } else if ((Rc(ctx->opcode) == 1) && \ + ((ctx->insns_flags & flg1) || (ctx->insns_flags2 & flg2_1)) && \ + !(ctx->opcode & inval1)) { \ + gen_##name1(ctx); \ + } else { \ + gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL); \ + } \ +} +GEN_VXFORM (vaddubm,0 ,0 ); +GEN_VXFORM_DUAL_EXT (vaddubm,PPC_ALTIVEC ,PPC_NONE ,0 , \ + vmul10cuq, PPC_NONE, PPC2_ISA300, 0x0000F800)GEN_VXFORM (vadduhm,0 ,1 ); +GEN_VXFORM_DUAL (vadduhm,PPC_ALTIVEC ,PPC_NONE , \ + vmul10ecuq, PPC_NONE, PPC2_ISA300)GEN_VXFORM (vadduwm,0 ,2 );GEN_VXFORM (vaddudm,0 ,3 );GEN_VXFORM (vsububm,0 ,16 );
@@ -390,7 +458,11 @@ GEN_VXFORM(vsro, 6, 17);GEN_VXFORM (vaddcuw,0 ,6 );GEN_VXFORM (vsubcuw,0 ,22 );GEN_VXFORM_ENV (vaddubs,0 ,8 ); +GEN_VXFORM_DUAL_EXT (vaddubs,PPC_ALTIVEC ,PPC_NONE ,0 , \ + vmul10uq, PPC_NONE, PPC2_ISA300, 0x0000F800)GEN_VXFORM_ENV (vadduhs,0 ,9 ); +GEN_VXFORM_DUAL (vadduhs,PPC_ALTIVEC ,PPC_NONE , \ + vmul10euq, PPC_NONE, PPC2_ISA300)GEN_VXFORM_ENV (vadduws,0 ,10 );GEN_VXFORM_ENV (vaddsbs,0 ,12 );GEN_VXFORM_ENV (vaddshs,0 ,13 );
target-ppc/translate/vmx-ops.inc.c +4 -4
@@ -55,8 +55,8 @@ GEN_HANDLER_E(name0##_##name1, 0x4, opc2, opc3, 0x00000000, type0, type1) GEN_HANDLER_E(name0##_##name1, 0x4, opc2, opc3, 0x00000000, tp0, tp1), \ GEN_HANDLER_E(name0##_##name1, 0x4, opc2, (opc3 | 0x10), 0x00000000, tp0, tp1), -GEN_VXFORM (vaddubm,0 ,0 ), -GEN_VXFORM (vadduhm,0 ,1 ), +GEN_VXFORM_DUAL (vaddubm, vmul10cuq,0 ,0 ,PPC_ALTIVEC ,PPC_NONE ), +GEN_VXFORM_DUAL (vadduhm, vmul10ecuq,0 ,1 ,PPC_ALTIVEC ,PPC_NONE ),GEN_VXFORM (vadduwm,0 ,2 ),GEN_VXFORM_207 (vaddudm,0 ,3 ), GEN_VXFORM_DUAL(vsububm, bcdadd, 0, 16, PPC_ALTIVEC, PPC_NONE),
@@ -123,8 +123,8 @@ GEN_VXFORM(vslo, 6, 16),GEN_VXFORM (vsro,6 ,17 ),GEN_VXFORM (vaddcuw,0 ,6 ),GEN_VXFORM (vsubcuw,0 ,22 ), -GEN_VXFORM (vaddubs,0 ,8 ), -GEN_VXFORM (vadduhs,0 ,9 ), +GEN_VXFORM_DUAL (vaddubs, vmul10uq,0 ,8 ,PPC_ALTIVEC ,PPC_NONE ), +GEN_VXFORM_DUAL (vadduhs, vmul10euq,0 ,9 ,PPC_ALTIVEC ,PPC_NONE ),GEN_VXFORM (vadduws,0 ,10 ),GEN_VXFORM (vaddsbs,0 ,12 ), GEN_VXFORM(vaddshs, 0, 13),
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 37/73] pseries: Move adding of fdt reserve map entries
In reply to David GibsonThe flattened device tree passed to pseries guests contains a list of reserved memory areas. Currently we construct this list early in spapr_create_fdt_skel() as we sequentially write the fdt.
This will be inconvenient for upcoming cleanups, so this patch moves the reserve map changes to the end of fdt construction. This changes fdt_add_reservemap_entry() calls - which work when writing the fdt sequentially to fdt_add_mem_rsv() calls used when altering the fdt in random access mode.
--- hw/ppc/spapr.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
hw/ppc/spapr.c +9 -8
@@ -301,14 +301,6 @@ static void *spapr_create_fdt_skel(sPAPRMachineState *spapr) fdt =g_malloc0 (FDT_MAX_SIZE );_FDT ((fdt_create (fdt,FDT_MAX_SIZE ))); -if (spapr->kernel_size) { -_FDT ((fdt_add_reservemap_entry (fdt,KERNEL_LOAD_ADDR , - spapr->kernel_size))); - } -if (spapr->initrd_size) { -_FDT ((fdt_add_reservemap_entry (fdt, spapr->initrd_base, - spapr->initrd_size))); - }_FDT ((fdt_finish_reservemap (fdt)));/* Root node */
@@ -997,6 +989,15 @@ static void *spapr_build_fdt(sPAPRMachineState *spapr, }g_free (bootlist); + +/* Build memory reserve map */ +if (spapr->kernel_size) { +_FDT ((fdt_add_mem_rsv (fdt,KERNEL_LOAD_ADDR , spapr->kernel_size))); + } +if (spapr->initrd_size) { +_FDT ((fdt_add_mem_rsv (fdt, spapr->initrd_base, spapr->initrd_size))); + } +return fdt; }
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 43/73] pseries: Move /hypervisor node construction to fdt_build_fdt()
In reply to David GibsonCurrently the /hypervisor device tree node is constructed in spapr_create_fdt_skel(). As part of consolidating device tree construction to reset time, move it to a function called from spapr_build_fdt().
--- hw/ppc/spapr.c | 49 ++++++++++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 21 deletions(-)
hw/ppc/spapr.c +28 -21
@@ -328,27 +328,6 @@ static void *spapr_create_fdt_skel(sPAPRMachineState *spapr)_FDT ((fdt_end_node (fdt))); -/* /hypervisor node */ -if (kvm_enabled ()) { -uint8_t hypercall[16 ]; - -/* indicate KVM hypercall interface */ -_FDT ((fdt_begin_node (fdt,"hypervisor" ))); -_FDT ((fdt_property_string (fdt,"compatible" ,"linux,kvm" ))); -if (kvmppc_has_cap_fixup_hcalls ()) { -/* -* Older KVM versions with older guest kernels were broken with the -* magic page, don't allow the guest to map it. -*/ -if (!kvmppc_get_hypercall (first_cpu->env_ptr, hypercall, -sizeof (hypercall))) { -_FDT ((fdt_property (fdt,"hcall-instructions" , hypercall, -sizeof (hypercall)))); - } - } -_FDT ((fdt_end_node (fdt))); - } -_FDT ((fdt_end_node (fdt)));/* close root node */ _FDT ((fdt_finish (fdt)));
@@ -916,6 +895,29 @@ static void spapr_dt_chosen(sPAPRMachineState *spapr, void *fdt)g_free (bootlist); } +static void spapr_dt_hypervisor (sPAPRMachineState *spapr,void *fdt) +{ +/* The /hypervisor node isn't in PAPR - this is a hack to allow PR +* KVM to work under pHyp with some guest co-operation */ +int hypervisor; +uint8_t hypercall[16 ]; + +_FDT (hypervisor =fdt_add_subnode (fdt,0 ,"hypervisor" )); +/* indicate KVM hypercall interface */ +_FDT (fdt_setprop_string (fdt, hypervisor,"compatible" ,"linux,kvm" )); +if (kvmppc_has_cap_fixup_hcalls ()) { +/* +* Older KVM versions with older guest kernels were broken +* with the magic page, don't allow the guest to map it. +*/ +if (!kvmppc_get_hypercall (first_cpu->env_ptr, hypercall, +sizeof (hypercall))) { +_FDT (fdt_setprop (fdt, hypervisor,"hcall-instructions" , + hypercall,sizeof (hypercall))); + } + } +} +static void *spapr_build_fdt (sPAPRMachineState *spapr,hwaddr rtas_addr,hwaddr rtas_size)
@@ -989,6 +991,11 @@ static void *spapr_build_fdt(sPAPRMachineState *spapr,/* /chosen */ spapr_dt_chosen (spapr, fdt); +/* /hypervisor */ +if (kvm_enabled ()) { +spapr_dt_hypervisor (spapr, fdt); + } +/* Build memory reserve map */ if (spapr->kernel_size) {_FDT ((fdt_add_mem_rsv (fdt,KERNEL_LOAD_ADDR , spapr->kernel_size)));
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 55/73] tests: Adjust tco-test to use qpci_legacy_iomap()
In reply to David GibsonAvoid tco-test making assumptions about the internal format of the address tokens passed to PCI IO accessors, by using the new qpci_legacy_iomap() function.
--- tests/tco-test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tests/tco-test.c +1 -1
@@ -70,7 +70,7 @@ static void test_init(TestData *d)/* set Root Complex BAR */ qpci_config_writel (d->dev,ICH9_LPC_RCBA ,RCBA_BASE_ADDR |0x1 ); - d->tco_io_base = (void *)((uintptr_t )PM_IO_BASE_ADDR +0x60 ); + d->tco_io_base =qpci_legacy_iomap (d->dev,PM_IO_BASE_ADDR +0x60 ); }static void stop_tco (const TestData *d)
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 65/73] target-ppc: add xscmp[eq, gt, ge, ne]dp instructions
In reply to David GibsonFrom: Sandipan Das <[email protected]>
xscmpeqdp: VSX Scalar Compare Equal Double-Precision
xscmpgedp: VSX Scalar Compare Greater Than or Equal Double-Precision
xscmpgtdp: VSX Scalar Compare Greater Than Double-Precision
xscmpnedp: VSX Scalar Compare Not Equal Double-Precision
--- target-ppc/fpu_helper.c | 52 +++++++++++++++++++++++++++++++++++++ target-ppc/helper.h | 4 +++ target-ppc/translate/vsx-impl.inc.c | 4 +++ target-ppc/translate/vsx-ops.inc.c | 4 +++ 4 files changed, 64 insertions(+)
target-ppc/fpu_helper.c +52 -0
@@ -2362,6 +2362,58 @@ VSX_MADD(xvnmaddmsp, 4, float32, VsrW(i), NMADD_FLGS, 0, 0, 0) VSX_MADD(xvnmsubasp, 4, float32, VsrW(i), NMSUB_FLGS, 1, 0, 0)VSX_MADD (xvnmsubmsp,4 , float32,VsrW (i),NMSUB_FLGS ,0 ,0 ,0 ) +/* VSX_SCALAR_CMP_DP - VSX scalar floating point compare double precision +* op - instruction mnemonic +* cmp - comparison operation +* exp - expected result of comparison +* svxvc - set VXVC bit + */ +#define VSX_SCALAR_CMP_DP (op, cmp, exp, svxvc) \ +void helper_##op(CPUPPCState *env, uint32_t opcode) \ +{ \ + ppc_vsr_t xt, xa, xb; \ + bool vxsnan_flag = false, vxvc_flag = false, vex_flag = false; \ + \ + getVSR(xA(opcode), &xa, env); \ + getVSR(xB(opcode), &xb, env); \ + getVSR(xT(opcode), &xt, env); \ + \ + if (float64_is_signaling_nan(xa.VsrD(0), &env->fp_status) || \ + float64_is_signaling_nan(xb.VsrD(0), &env->fp_status)) { \ + vxsnan_flag = true; \ + if (fpscr_ve == 0 && svxvc) { \ + vxvc_flag = true; \ + } \ + } else if (svxvc) { \ + vxvc_flag = float64_is_quiet_nan(xa.VsrD(0), &env->fp_status) || \ + float64_is_quiet_nan(xb.VsrD(0), &env->fp_status); \ + } \ + if (vxsnan_flag) { \ + float_invalid_op_excp(env, POWERPC_EXCP_FP_VXSNAN, 0); \ + } \ + if (vxvc_flag) { \ + float_invalid_op_excp(env, POWERPC_EXCP_FP_VXVC, 0); \ + } \ + vex_flag = fpscr_ve && (vxvc_flag || vxsnan_flag); \ + \ + if (!vex_flag) { \ + if (float64_##cmp(xb.VsrD(0), xa.VsrD(0), &env->fp_status) == exp) { \ + xt.VsrD(0) = -1; \ + xt.VsrD(1) = 0; \ + } else { \ + xt.VsrD(0) = 0; \ + xt.VsrD(1) = 0; \ + } \ + } \ + putVSR(xT(opcode), &xt, env); \ + helper_float_check_status(env); \ +} + +VSX_SCALAR_CMP_DP(xscmpeqdp, eq, 1, 0) +VSX_SCALAR_CMP_DP(xscmpgedp, le, 1, 1) +VSX_SCALAR_CMP_DP(xscmpgtdp, lt, 1, 1) +VSX_SCALAR_CMP_DP(xscmpnedp, eq, 0, 0) +#define VSX_SCALAR_CMP (op, ordered) \ void helper_##op(CPUPPCState *env, uint32_t opcode) \ { \
target-ppc/helper.h +4 -0
@@ -389,6 +389,10 @@ DEF_HELPER_2(xsnmaddadp, void, env, i32) DEF_HELPER_2(xsnmaddmdp, void, env, i32) DEF_HELPER_2(xsnmsubadp, void, env, i32) DEF_HELPER_2(xsnmsubmdp, void, env, i32) +DEF_HELPER_2(xscmpeqdp, void, env, i32) +DEF_HELPER_2(xscmpgtdp, void, env, i32) +DEF_HELPER_2(xscmpgedp, void, env, i32) +DEF_HELPER_2(xscmpnedp, void, env, i32) DEF_HELPER_2(xscmpodp, void, env, i32) DEF_HELPER_2(xscmpudp, void, env, i32)DEF_HELPER_2 (xsmaxdp, void, env, i32)
target-ppc/translate/vsx-impl.inc.c +4 -0
@@ -620,6 +620,10 @@ GEN_VSX_HELPER_2(xsnmaddadp, 0x04, 0x14, 0, PPC2_VSX) GEN_VSX_HELPER_2(xsnmaddmdp, 0x04, 0x15, 0, PPC2_VSX) GEN_VSX_HELPER_2(xsnmsubadp, 0x04, 0x16, 0, PPC2_VSX) GEN_VSX_HELPER_2(xsnmsubmdp, 0x04, 0x17, 0, PPC2_VSX) +GEN_VSX_HELPER_2(xscmpeqdp, 0x0C, 0x00, 0, PPC2_ISA300) +GEN_VSX_HELPER_2(xscmpgtdp, 0x0C, 0x01, 0, PPC2_ISA300) +GEN_VSX_HELPER_2(xscmpgedp, 0x0C, 0x02, 0, PPC2_ISA300) +GEN_VSX_HELPER_2(xscmpnedp, 0x0C, 0x03, 0, PPC2_ISA300) GEN_VSX_HELPER_2(xscmpodp, 0x0C, 0x05, 0, PPC2_VSX) GEN_VSX_HELPER_2(xscmpudp, 0x0C, 0x04, 0, PPC2_VSX)GEN_VSX_HELPER_2 (xsmaxdp,0x00 ,0x14 ,0 ,PPC2_VSX )
target-ppc/translate/vsx-ops.inc.c +4 -0
@@ -114,6 +114,10 @@ GEN_XX3FORM(xsnmaddadp, 0x04, 0x14, PPC2_VSX),GEN_XX3FORM (xsnmaddmdp,0x04 ,0x15 ,PPC2_VSX ),GEN_XX3FORM (xsnmsubadp,0x04 ,0x16 ,PPC2_VSX ),GEN_XX3FORM (xsnmsubmdp,0x04 ,0x17 ,PPC2_VSX ), +GEN_XX3FORM (xscmpeqdp,0x0C ,0x00 ,PPC2_ISA300 ), +GEN_XX3FORM (xscmpgtdp,0x0C ,0x01 ,PPC2_ISA300 ), +GEN_XX3FORM (xscmpgedp,0x0C ,0x02 ,PPC2_ISA300 ), +GEN_XX3FORM (xscmpnedp,0x0C ,0x03 ,PPC2_ISA300 ),GEN_XX2IFORM (xscmpodp,0x0C ,0x05 ,PPC2_VSX ),GEN_XX2IFORM (xscmpudp,0x0C ,0x04 ,PPC2_VSX ), GEN_XX3FORM(xsmaxdp, 0x00, 0x14, PPC2_VSX),
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 71/73] spapr: use count+index for memory hotplug
In reply to David GibsonFrom: Michael Roth <[email protected]>
Commit 0a417869:
spapr: Move memory hotplug to RTAS_LOG_V6_HP_ID_DRC_COUNT type
dropped per-DRC/per-LMB hotplugs event in favor of a bulk add via a single LMB count value. This was to avoid overrunning the guest EPOW event queue with hotplug events. This works fine, but relies on the guest exhaustively scanning for pluggable LMBs to satisfy the requested count by issuing rtas-get-sensor(DR_ENTITY_SENSE, ...) calls until all the LMBs associated with the DIMM are identified.
With newer support for dedicated hotplug event source, this queue exhaustion is no longer as much of an issue due to implementation details on the guest side, but we still try to avoid excessive hotplug events by now supporting both a count and a starting index to avoid unecessary work. This patch makes use of that approach when the capability is available.
--- hw/ppc/spapr.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-)
hw/ppc/spapr.c +18 -4
@@ -2202,14 +2202,16 @@ static void spapr_nmi(NMIState *n, int cpu_index, Error **errp) } } -static void spapr_add_lmbs (DeviceState *dev,uint64_t addr,uint64_t size, -uint32_t node,Error **errp) +static void spapr_add_lmbs (DeviceState *dev,uint64_t addr_start,uint64_t size, +uint32_t node,bool dedicated_hp_event_source, +Error **errp) {sPAPRDRConnector *drc;sPAPRDRConnectorClass *drck;uint32_t nr_lmbs = size/SPAPR_MEMORY_BLOCK_SIZE ;int i, fdt_offset, fdt_size;void *fdt; +uint64_t addr = addr_start;for (i =0 ; i < nr_lmbs; i++) { drc = spapr_dr_connector_by_id(SPAPR_DR_CONNECTOR_TYPE_LMB,
@@ -2228,7 +2230,17 @@ static void spapr_add_lmbs(DeviceState *dev, uint64_t addr, uint64_t size,* guest only in case of hotplugged memory */ if (dev->hotplugged) { -spapr_hotplug_req_add_by_count (SPAPR_DR_CONNECTOR_TYPE_LMB , nr_lmbs); +if (dedicated_hp_event_source) { + drc =spapr_dr_connector_by_id (SPAPR_DR_CONNECTOR_TYPE_LMB , + addr_start /SPAPR_MEMORY_BLOCK_SIZE ); + drck =SPAPR_DR_CONNECTOR_GET_CLASS (drc); +spapr_hotplug_req_add_by_count_indexed (SPAPR_DR_CONNECTOR_TYPE_LMB , + nr_lmbs, + drck->get_index (drc)); + }else { +spapr_hotplug_req_add_by_count (SPAPR_DR_CONNECTOR_TYPE_LMB , + nr_lmbs); + } } }
@@ -2261,7 +2273,9 @@ static void spapr_memory_plug(HotplugHandler *hotplug_dev, DeviceState *dev, goto out; } -spapr_add_lmbs (dev, addr, size, node, &error_abort); +spapr_add_lmbs (dev, addr, size, node, +spapr_ovec_test (ms->ov5_cas,OV5_HP_EVT ), + &error_abort); out:error_propagate (errp, local_err);
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 58/73] tests: Clean up IO handling in ide-test
In reply to David Gibsonide-test uses many explicit inb() / outb() operations for its IO, which means it's not portable to non-x86 platforms. This cleans it up to use the libqos PCI accessors instead.
--- tests/ide-test.c | 179 ++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 118 insertions(+), 61 deletions(-)
tests/ide-test.c +118 -61
@@ -137,7 +137,7 @@ static void ide_test_quit(void)qtest_end (); } -static QPCIDevice *get_pci_device (uint16_t *bmdma_base) +static QPCIDevice *get_pci_device (void **bmdma_base,void **ide_base) {QPCIDevice *dev;uint16_t vendor_id, device_id;
@@ -156,7 +156,9 @@ static QPCIDevice *get_pci_device(uint16_t *bmdma_base)g_assert (device_id ==PCI_DEVICE_ID_INTEL_82371SB_1 );/* Map bmdma BAR */ - *bmdma_base = (uint16_t )(uintptr_t )qpci_iomap (dev,4 ,NULL ); + *bmdma_base =qpci_iomap (dev,4 ,NULL ); + + *ide_base =qpci_legacy_iomap (dev,IDE_BASE );qpci_device_enable (dev);
@@ -179,17 +181,19 @@ typedef struct PrdtEntry {static int send_dma_request (int cmd,uint64_t sector,int nb_sectors,PrdtEntry *prdt,int prdt_entries, -void (*post_exec)(uint64_t sector,int nb_sectors)) +void (*post_exec)(QPCIDevice *dev,void *ide_base, +uint64_t sector,int nb_sectors)) {QPCIDevice *dev; -uint16_t bmdma_base; +void *bmdma_base; +void *ide_base;uintptr_t guest_prdt;size_t len;bool from_dev;uint8_t status;int flags; - dev =get_pci_device (&bmdma_base); + dev =get_pci_device (&bmdma_base, &ide_base); flags = cmd & ~0xff ; cmd &=0xff ;
@@ -214,59 +218,60 @@ static int send_dma_request(int cmd, uint64_t sector, int nb_sectors, }/* Select device 0 */ -outb (IDE_BASE + reg_device,0 |LBA ); +qpci_io_writeb (dev, ide_base + reg_device,0 |LBA );/* Stop any running transfer, clear any pending interrupt */ -outb (bmdma_base + bmreg_cmd,0 ); -outb (bmdma_base + bmreg_status,BM_STS_INTR ); +qpci_io_writeb (dev, bmdma_base + bmreg_cmd,0 ); +qpci_io_writeb (dev, bmdma_base + bmreg_status,BM_STS_INTR );/* Setup PRDT */ len =sizeof (*prdt) * prdt_entries; guest_prdt =guest_alloc (guest_malloc, len);memwrite (guest_prdt, prdt, len); -outl (bmdma_base + bmreg_prdt, guest_prdt); +qpci_io_writel (dev, bmdma_base + bmreg_prdt, guest_prdt);/* ATA DMA command */ if (cmd ==CMD_PACKET ) {/* Enables ATAPI DMA; otherwise PIO is attempted */ -outb (IDE_BASE + reg_feature,0x01 ); +qpci_io_writeb (dev, ide_base + reg_feature,0x01 ); }else { -outb (IDE_BASE + reg_nsectors, nb_sectors); -outb (IDE_BASE + reg_lba_low, sector &0xff ); -outb (IDE_BASE + reg_lba_middle, (sector >>8 ) &0xff ); -outb (IDE_BASE + reg_lba_high, (sector >>16 ) &0xff ); +qpci_io_writeb (dev, ide_base + reg_nsectors, nb_sectors); +qpci_io_writeb (dev, ide_base + reg_lba_low, sector &0xff ); +qpci_io_writeb (dev, ide_base + reg_lba_middle, (sector >>8 ) &0xff ); +qpci_io_writeb (dev, ide_base + reg_lba_high, (sector >>16 ) &0xff ); } -outb (IDE_BASE + reg_command, cmd); +qpci_io_writeb (dev, ide_base + reg_command, cmd);if (post_exec) { -post_exec (sector, nb_sectors); +post_exec (dev, ide_base, sector, nb_sectors); }/* Start DMA transfer */ -outb (bmdma_base + bmreg_cmd,BM_CMD_START | (from_dev ?BM_CMD_WRITE :0 )); +qpci_io_writeb (dev, bmdma_base + bmreg_cmd, +BM_CMD_START | (from_dev ?BM_CMD_WRITE :0 ));if (flags &CMDF_ABORT ) { -outb (bmdma_base + bmreg_cmd,0 ); +qpci_io_writeb (dev, bmdma_base + bmreg_cmd,0 ); }/* Wait for the DMA transfer to complete */ do { - status =inb (bmdma_base + bmreg_status); + status =qpci_io_readb (dev, bmdma_base + bmreg_status); }while ((status & (BM_STS_ACTIVE |BM_STS_INTR )) ==BM_STS_ACTIVE ); g_assert_cmpint(get_irq(IDE_PRIMARY_IRQ), ==, !!(status & BM_STS_INTR));/* Check IDE status code */ -assert_bit_set (inb (IDE_BASE + reg_status),DRDY ); -assert_bit_clear (inb (IDE_BASE + reg_status),BSY |DRQ ); +assert_bit_set (qpci_io_readb (dev, ide_base + reg_status),DRDY ); +assert_bit_clear (qpci_io_readb (dev, ide_base + reg_status),BSY |DRQ );/* Reading the status register clears the IRQ */ g_assert (!get_irq (IDE_PRIMARY_IRQ ));/* Stop DMA transfer if still active */ if (status &BM_STS_ACTIVE ) { -outb (bmdma_base + bmreg_cmd,0 ); +qpci_io_writeb (dev, bmdma_base + bmreg_cmd,0 ); }free_pci_device (dev);
@@ -276,6 +281,8 @@ static int send_dma_request(int cmd, uint64_t sector, int nb_sectors,static void test_bmdma_simple_rw (void ) { +QPCIDevice *dev; +void *bmdma_base, *ide_base;uint8_t status;uint8_t *buf;uint8_t *cmpbuf;
@@ -289,6 +296,8 @@ static void test_bmdma_simple_rw(void) }, }; + dev =get_pci_device (&bmdma_base, &ide_base); + buf =g_malloc (len); cmpbuf =g_malloc (len);
@@ -299,7 +308,7 @@ static void test_bmdma_simple_rw(void) status =send_dma_request (CMD_WRITE_DMA ,0 ,1 , prdt,ARRAY_SIZE (prdt),NULL ); g_assert_cmphex(status, ==, BM_STS_INTR); -assert_bit_clear (inb (IDE_BASE + reg_status),DF |ERR ); +assert_bit_clear (qpci_io_readb (dev, ide_base + reg_status),DF |ERR );/* Write 0xaa pattern to sector 1 */ memset (buf,0xaa , len);
@@ -308,14 +317,14 @@ static void test_bmdma_simple_rw(void) status =send_dma_request (CMD_WRITE_DMA ,1 ,1 , prdt,ARRAY_SIZE (prdt),NULL ); g_assert_cmphex(status, ==, BM_STS_INTR); -assert_bit_clear (inb (IDE_BASE + reg_status),DF |ERR ); +assert_bit_clear (qpci_io_readb (dev, ide_base + reg_status),DF |ERR );/* Read and verify 0x55 pattern in sector 0 */ memset (cmpbuf,0x55 , len); status =send_dma_request (CMD_READ_DMA ,0 ,1 , prdt,ARRAY_SIZE (prdt),NULL ); g_assert_cmphex(status, ==, BM_STS_INTR); -assert_bit_clear (inb (IDE_BASE + reg_status),DF |ERR ); +assert_bit_clear (qpci_io_readb (dev, ide_base + reg_status),DF |ERR );memread (guest_buf, buf, len);g_assert (memcmp (buf, cmpbuf, len) ==0 );
@@ -325,7 +334,7 @@ static void test_bmdma_simple_rw(void) status =send_dma_request (CMD_READ_DMA ,1 ,1 , prdt,ARRAY_SIZE (prdt),NULL ); g_assert_cmphex(status, ==, BM_STS_INTR); -assert_bit_clear (inb (IDE_BASE + reg_status),DF |ERR ); +assert_bit_clear (qpci_io_readb (dev, ide_base + reg_status),DF |ERR );memread (guest_buf, buf, len);g_assert (memcmp (buf, cmpbuf, len) ==0 );
@@ -337,6 +346,8 @@ static void test_bmdma_simple_rw(void)static void test_bmdma_short_prdt (void ) { +QPCIDevice *dev; +void *bmdma_base, *ide_base;uint8_t status;PrdtEntry prdt[] = {
@@ -346,21 +357,25 @@ static void test_bmdma_short_prdt(void) }, }; + dev =get_pci_device (&bmdma_base, &ide_base); +/* Normal request */ status =send_dma_request (CMD_READ_DMA ,0 ,1 , prdt,ARRAY_SIZE (prdt),NULL ); g_assert_cmphex(status, ==, 0); -assert_bit_clear (inb (IDE_BASE + reg_status),DF |ERR ); +assert_bit_clear (qpci_io_readb (dev, ide_base + reg_status),DF |ERR );/* Abort the request before it completes */ status =send_dma_request (CMD_READ_DMA |CMDF_ABORT ,0 ,1 , prdt,ARRAY_SIZE (prdt),NULL ); g_assert_cmphex(status, ==, 0); -assert_bit_clear (inb (IDE_BASE + reg_status),DF |ERR ); +assert_bit_clear (qpci_io_readb (dev, ide_base + reg_status),DF |ERR ); }static void test_bmdma_one_sector_short_prdt (void ) { +QPCIDevice *dev; +void *bmdma_base, *ide_base;uint8_t status;/* Read 2 sectors but only give 1 sector in PRDT */
@@ -371,21 +386,25 @@ static void test_bmdma_one_sector_short_prdt(void) }, }; + dev =get_pci_device (&bmdma_base, &ide_base); +/* Normal request */ status =send_dma_request (CMD_READ_DMA ,0 ,2 , prdt,ARRAY_SIZE (prdt),NULL ); g_assert_cmphex(status, ==, 0); -assert_bit_clear (inb (IDE_BASE + reg_status),DF |ERR ); +assert_bit_clear (qpci_io_readb (dev, ide_base + reg_status),DF |ERR );/* Abort the request before it completes */ status =send_dma_request (CMD_READ_DMA |CMDF_ABORT ,0 ,2 , prdt,ARRAY_SIZE (prdt),NULL ); g_assert_cmphex(status, ==, 0); -assert_bit_clear (inb (IDE_BASE + reg_status),DF |ERR ); +assert_bit_clear (qpci_io_readb (dev, ide_base + reg_status),DF |ERR ); }static void test_bmdma_long_prdt (void ) { +QPCIDevice *dev; +void *bmdma_base, *ide_base;uint8_t status;PrdtEntry prdt[] = {
@@ -395,23 +414,29 @@ static void test_bmdma_long_prdt(void) }, }; + dev =get_pci_device (&bmdma_base, &ide_base); +/* Normal request */ status =send_dma_request (CMD_READ_DMA ,0 ,1 , prdt,ARRAY_SIZE (prdt),NULL ); g_assert_cmphex(status, ==, BM_STS_ACTIVE | BM_STS_INTR); -assert_bit_clear (inb (IDE_BASE + reg_status),DF |ERR ); +assert_bit_clear (qpci_io_readb (dev, ide_base + reg_status),DF |ERR );/* Abort the request before it completes */ status =send_dma_request (CMD_READ_DMA |CMDF_ABORT ,0 ,1 , prdt,ARRAY_SIZE (prdt),NULL ); g_assert_cmphex(status, ==, BM_STS_INTR); -assert_bit_clear (inb (IDE_BASE + reg_status),DF |ERR ); +assert_bit_clear (qpci_io_readb (dev, ide_base + reg_status),DF |ERR ); }static void test_bmdma_no_busmaster (void ) { +QPCIDevice *dev; +void *bmdma_base, *ide_base;uint8_t status; + dev =get_pci_device (&bmdma_base, &ide_base); +/* No PRDT_EOT, each entry addr 0/size 64k, and in theory qemu shouldn't be * able to access it anyway because the Bus Master bit in the PCI command * register isn't set. This is complete nonsense, but it used to be pretty
@@ -424,7 +449,7 @@ static void test_bmdma_no_busmaster(void)/* Not entirely clear what the expected result is, but this is what we get * in practice. At least we want to be aware of any changes. */ g_assert_cmphex(status, ==, BM_STS_ACTIVE | BM_STS_INTR); -assert_bit_clear (inb (IDE_BASE + reg_status),DF |ERR ); +assert_bit_clear (qpci_io_readb (dev, ide_base + reg_status),DF |ERR ); }static void test_bmdma_setup (void )
@@ -454,6 +479,8 @@ static void string_cpu_to_be16(uint16_t *s, size_t bytes)static void test_identify (void ) { +QPCIDevice *dev; +void *bmdma_base, *ide_base;uint8_t data;uint16_t buf[256 ];int i;
@@ -464,23 +491,25 @@ static void test_identify(void)"-global ide-hd.ver=%s" , tmp_path, "testdisk", "version"); + dev =get_pci_device (&bmdma_base, &ide_base); +/* IDENTIFY command on device 0*/ -outb (IDE_BASE + reg_device,0 ); -outb (IDE_BASE + reg_command,CMD_IDENTIFY ); +qpci_io_writeb (dev, ide_base + reg_device,0 ); +qpci_io_writeb (dev, ide_base + reg_command,CMD_IDENTIFY );/* Read in the IDENTIFY buffer and check registers */ - data =inb (IDE_BASE + reg_device); + data =qpci_io_readb (dev, ide_base + reg_device); g_assert_cmpint(data & DEV, ==, 0);for (i =0 ; i <256 ; i++) { - data =inb (IDE_BASE + reg_status); + data =qpci_io_readb (dev, ide_base + reg_status);assert_bit_set (data,DRDY |DRQ );assert_bit_clear (data,BSY |DF |ERR ); - ((uint16_t *) buf)[i] =inw (IDE_BASE + reg_data); + buf[i] =qpci_io_readw (dev, ide_base + reg_data); } - data =inb (IDE_BASE + reg_status); + data =qpci_io_readb (dev, ide_base + reg_status);assert_bit_set (data,DRDY );assert_bit_clear (data,BSY |DF |ERR |DRQ );
@@ -505,11 +534,15 @@ static void test_identify(void)*/ static void make_dirty (uint8_t device) { +QPCIDevice *dev; +void *bmdma_base, *ide_base;uint8_t status;size_t len =512 ;uintptr_t guest_buf;void * buf; + dev =get_pci_device (&bmdma_base, &ide_base); + guest_buf =guest_alloc (guest_malloc, len); buf =g_malloc (len);g_assert (guest_buf);
@@ -527,19 +560,23 @@ static void make_dirty(uint8_t device) status =send_dma_request (CMD_WRITE_DMA ,1 ,1 , prdt,ARRAY_SIZE (prdt),NULL ); g_assert_cmphex(status, ==, BM_STS_INTR); -assert_bit_clear (inb (IDE_BASE + reg_status),DF |ERR ); +assert_bit_clear (qpci_io_readb (dev, ide_base + reg_status),DF |ERR );g_free (buf); }static void test_flush (void ) { +QPCIDevice *dev; +void *bmdma_base, *ide_base;uint8_t data;ide_test_start ("-drive file=blkdebug::%s,if=ide,cache=writeback,format=raw" , tmp_path); + dev =get_pci_device (&bmdma_base, &ide_base); +qtest_irq_intercept_in (global_qtest,"ioapic" );/* Dirty media so that CMD_FLUSH_CACHE will actually go to disk */
@@ -549,11 +586,11 @@ static void test_flush(void)g_free (hmp ("qemu-io ide0-hd0 \"break flush_to_os A\"" ));/* FLUSH CACHE command on device 0*/ -outb (IDE_BASE + reg_device,0 ); -outb (IDE_BASE + reg_command,CMD_FLUSH_CACHE ); +qpci_io_writeb (dev, ide_base + reg_device,0 ); +qpci_io_writeb (dev, ide_base + reg_command,CMD_FLUSH_CACHE );/* Check status while request is in flight*/ - data =inb (IDE_BASE + reg_status); + data =qpci_io_readb (dev, ide_base + reg_status);assert_bit_set (data,BSY |DRDY );assert_bit_clear (data,DF |ERR |DRQ );
@@ -561,11 +598,11 @@ static void test_flush(void)g_free (hmp ("qemu-io ide0-hd0 \"resume A\"" ));/* Check registers */ - data =inb (IDE_BASE + reg_device); + data =qpci_io_readb (dev, ide_base + reg_device); g_assert_cmpint(data & DEV, ==, 0);do { - data =inb (IDE_BASE + reg_status); + data =qpci_io_readb (dev, ide_base + reg_status); }while (data &BSY );assert_bit_set (data,DRDY );
@@ -576,6 +613,8 @@ static void test_flush(void)static void test_retry_flush (const char *machine) { +QPCIDevice *dev; +void *bmdma_base, *ide_base;uint8_t data;const char *s;
@@ -587,17 +626,19 @@ static void test_retry_flush(const char *machine)"rerror=stop,werror=stop" , debug_path, tmp_path); + dev =get_pci_device (&bmdma_base, &ide_base); +qtest_irq_intercept_in (global_qtest,"ioapic" );/* Dirty media so that CMD_FLUSH_CACHE will actually go to disk */ make_dirty (0 );/* FLUSH CACHE command on device 0*/ -outb (IDE_BASE + reg_device,0 ); -outb (IDE_BASE + reg_command,CMD_FLUSH_CACHE ); +qpci_io_writeb (dev, ide_base + reg_device,0 ); +qpci_io_writeb (dev, ide_base + reg_command,CMD_FLUSH_CACHE );/* Check status while request is in flight*/ - data =inb (IDE_BASE + reg_status); + data =qpci_io_readb (dev, ide_base + reg_status);assert_bit_set (data,BSY |DRDY );assert_bit_clear (data,DF |ERR |DRQ );
@@ -608,11 +649,11 @@ static void test_retry_flush(const char *machine)qmp_discard_response (s);/* Check registers */ - data =inb (IDE_BASE + reg_device); + data =qpci_io_readb (dev, ide_base + reg_device); g_assert_cmpint(data & DEV, ==, 0);do { - data =inb (IDE_BASE + reg_status); + data =qpci_io_readb (dev, ide_base + reg_status); }while (data &BSY );assert_bit_set (data,DRDY );
@@ -623,11 +664,16 @@ static void test_retry_flush(const char *machine)static void test_flush_nodev (void ) { +QPCIDevice *dev; +void *bmdma_base, *ide_base; +ide_test_start ("" ); + dev =get_pci_device (&bmdma_base, &ide_base); +/* FLUSH CACHE command on device 0*/ -outb (IDE_BASE + reg_device,0 ); -outb (IDE_BASE + reg_command,CMD_FLUSH_CACHE ); +qpci_io_writeb (dev, ide_base + reg_device,0 ); +qpci_io_writeb (dev, ide_base + reg_command,CMD_FLUSH_CACHE );/* Just testing that qemu doesn't crash... */
@@ -654,7 +700,8 @@ typedef struct Read10CDB {uint16_t padding; } __attribute__((__packed__)) Read10CDB; -static void send_scsi_cdb_read10 (uint64_t lba,int nblocks) +static void send_scsi_cdb_read10 (QPCIDevice *dev,void *ide_base, +uint64_t lba,int nblocks) {Read10CDB pkt = { .padding =0 };int i;
@@ -670,7 +717,8 @@ static void send_scsi_cdb_read10(uint64_t lba, int nblocks)/* Send Packet */ for (i =0 ; i <sizeof (Read10CDB)/2 ; i++) { -outw (IDE_BASE + reg_data,cpu_to_le16 (((uint16_t *)&pkt)[i])); +qpci_io_writew (dev, ide_base + reg_data, +le16_to_cpu (((uint16_t *)&pkt)[i])); } }
@@ -683,13 +731,17 @@ static void nsleep(int64_t nsecs)static uint8_t ide_wait_clear (uint8_t flag) { +QPCIDevice *dev; +void *bmdma_base, *ide_base;uint8_t data;time_t st; + dev =get_pci_device (&bmdma_base, &ide_base); +/* Wait with a 5 second timeout */ time (&st);while (true) { - data =inb (IDE_BASE + reg_status); + data =qpci_io_readb (dev, ide_base + reg_status);if (!(data & flag)) {return data; }
@@ -723,6 +775,8 @@ static void ide_wait_intr(int irq)static void cdrom_pio_impl (int nblocks) { +QPCIDevice *dev; +void *bmdma_base, *ide_base;FILE *fh;int patt_blocks =MAX (16 , nblocks);size_t patt_len =ATAPI_BLOCK_SIZE * patt_blocks;
@@ -741,13 +795,15 @@ static void cdrom_pio_impl(int nblocks)ide_test_start ("-drive if=none,file=%s,media=cdrom,format=raw,id=sr0,index=0 " "-device ide-cd,drive=sr0,bus=ide.0" , tmp_path); + dev =get_pci_device (&bmdma_base, &ide_base);qtest_irq_intercept_in (global_qtest,"ioapic" );/* PACKET command on device 0 */ -outb (IDE_BASE + reg_device,0 ); -outb (IDE_BASE + reg_lba_middle,BYTE_COUNT_LIMIT &0xFF ); -outb (IDE_BASE + reg_lba_high, (BYTE_COUNT_LIMIT >>8 &0xFF )); -outb (IDE_BASE + reg_command,CMD_PACKET ); +qpci_io_writeb (dev, ide_base + reg_device,0 ); +qpci_io_writeb (dev, ide_base + reg_lba_middle,BYTE_COUNT_LIMIT &0xFF ); +qpci_io_writeb (dev, ide_base + reg_lba_high, + (BYTE_COUNT_LIMIT >>8 &0xFF )); +qpci_io_writeb (dev, ide_base + reg_command,CMD_PACKET );/* HP0: Check_Status_A State */ nsleep (400 ); data =ide_wait_clear (BSY );
@@ -756,7 +812,7 @@ static void cdrom_pio_impl(int nblocks)assert_bit_clear (data,ERR |DF |BSY );/* SCSI CDB (READ10) -- read n*2048 bytes from block 0 */ -send_scsi_cdb_read10 (0 , nblocks); +send_scsi_cdb_read10 (dev, ide_base,0 , nblocks);/* Read data back: occurs in bursts of 'BYTE_COUNT_LIMIT' bytes. * If BYTE_COUNT_LIMIT is odd, we transfer BYTE_COUNT_LIMIT - 1 bytes.
@@ -780,7 +836,8 @@ static void cdrom_pio_impl(int nblocks)/* HP4: Transfer_Data */ for (j =0 ; j <MIN ((limit /2 ), rem); j++) { - rx[offset + j] =le16_to_cpu (inw (IDE_BASE + reg_data)); + rx[offset + j] =cpu_to_le16 (qpci_io_readw (dev, + ide_base + reg_data)); } }
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 66/73] target-ppc: Add xvcmpnesp, xvcmpnedp instructions
In reply to David GibsonFrom: Swapnil Bokade <[email protected]>
xvcmpnedp[.]: VSX Vector Compare Not Equal Double-Precision xvcmpnesp[.]: VSX Vector Compare Not Equal Single-Precision
--- target-ppc/fpu_helper.c | 19 +++++++++++-------- target-ppc/helper.h | 2 ++ target-ppc/translate/vsx-impl.inc.c | 2 ++ target-ppc/translate/vsx-ops.inc.c | 2 ++ 4 files changed, 17 insertions(+), 8 deletions(-)
target-ppc/fpu_helper.c +11 -8
@@ -2497,8 +2497,9 @@ VSX_MAX_MIN(xvminsp, minnum, 4, float32, VsrW(i))* fld - vsr_t field (VsrD(*) or VsrW(*)) * cmp - comparison operation * svxvc - set VXVC bit +* exp - expected result of comparison */ -#define VSX_CMP (op, nels, tp, fld, cmp, svxvc) \ +#define VSX_CMP (op, nels, tp, fld, cmp, svxvc, exp) \ void helper_##op(CPUPPCState *env, uint32_t opcode) \ { \ ppc_vsr_t xt, xa, xb; \
@@ -2523,7 +2524,7 @@ void helper_##op(CPUPPCState *env, uint32_t opcode) \ xt.fld =0 ; \ all_true =0 ; \ }else { \ - if (tp##_##cmp(xb.fld, xa.fld, &env->fp_status) == 1) { \ + if (tp##_##cmp(xb.fld, xa.fld, &env->fp_status) == exp) { \ xt.fld = -1; \ all_false = 0; \ } else { \
@@ -2540,12 +2541,14 @@ void helper_##op(CPUPPCState *env, uint32_t opcode) \float_check_status (env); \ } -VSX_CMP(xvcmpeqdp, 2, float64, VsrD(i), eq, 0) -VSX_CMP(xvcmpgedp, 2, float64, VsrD(i), le, 1) -VSX_CMP(xvcmpgtdp, 2, float64, VsrD(i), lt, 1) -VSX_CMP(xvcmpeqsp, 4, float32, VsrW(i), eq, 0) -VSX_CMP(xvcmpgesp, 4, float32, VsrW(i), le, 1) -VSX_CMP (xvcmpgtsp,4 , float32,VsrW (i), lt,1 ) +VSX_CMP(xvcmpeqdp, 2, float64, VsrD(i), eq, 0, 1) +VSX_CMP(xvcmpgedp, 2, float64, VsrD(i), le, 1, 1) +VSX_CMP(xvcmpgtdp, 2, float64, VsrD(i), lt, 1, 1) +VSX_CMP(xvcmpnedp, 2, float64, VsrD(i), eq, 0, 0) +VSX_CMP(xvcmpeqsp, 4, float32, VsrW(i), eq, 0, 1) +VSX_CMP(xvcmpgesp, 4, float32, VsrW(i), le, 1, 1) +VSX_CMP(xvcmpgtsp, 4, float32, VsrW(i), lt, 1, 1) +VSX_CMP (xvcmpnesp,4 , float32,VsrW (i), eq,0 ,0 )/* VSX_CVT_FP_TO_FP - VSX floating point/floating point conversion * op - instruction mnemonic
target-ppc/helper.h +2 -0
@@ -454,6 +454,7 @@ DEF_HELPER_2(xvmindp, void, env, i32) DEF_HELPER_2(xvcmpeqdp, void, env, i32) DEF_HELPER_2(xvcmpgedp, void, env, i32) DEF_HELPER_2(xvcmpgtdp, void, env, i32) +DEF_HELPER_2(xvcmpnedp, void, env, i32) DEF_HELPER_2(xvcvdpsp, void, env, i32) DEF_HELPER_2(xvcvdpsxds, void, env, i32)DEF_HELPER_2 (xvcvdpsxws, void, env, i32)
@@ -491,6 +492,7 @@ DEF_HELPER_2(xvminsp, void, env, i32) DEF_HELPER_2(xvcmpeqsp, void, env, i32) DEF_HELPER_2(xvcmpgesp, void, env, i32) DEF_HELPER_2(xvcmpgtsp, void, env, i32) +DEF_HELPER_2(xvcmpnesp, void, env, i32) DEF_HELPER_2(xvcvspdp, void, env, i32) DEF_HELPER_2(xvcvspsxds, void, env, i32)DEF_HELPER_2 (xvcvspsxws, void, env, i32)
target-ppc/translate/vsx-impl.inc.c +2 -0
@@ -685,6 +685,7 @@ GEN_VSX_HELPER_2(xvmindp, 0x00, 0x1D, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvcmpeqdp, 0x0C, 0x0C, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvcmpgtdp, 0x0C, 0x0D, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvcmpgedp, 0x0C, 0x0E, 0, PPC2_VSX) +GEN_VSX_HELPER_2(xvcmpnedp, 0x0C, 0x0F, 0, PPC2_ISA300) GEN_VSX_HELPER_2(xvcvdpsp, 0x12, 0x18, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvcvdpsxds, 0x10, 0x1D, 0, PPC2_VSX)GEN_VSX_HELPER_2 (xvcvdpsxws,0x10 ,0x0D ,0 ,PPC2_VSX )
@@ -722,6 +723,7 @@ GEN_VSX_HELPER_2(xvminsp, 0x00, 0x19, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvcmpeqsp, 0x0C, 0x08, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvcmpgtsp, 0x0C, 0x09, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvcmpgesp, 0x0C, 0x0A, 0, PPC2_VSX) +GEN_VSX_HELPER_2(xvcmpnesp, 0x0C, 0x0B, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvcvspdp, 0x12, 0x1C, 0, PPC2_VSX) GEN_VSX_HELPER_2(xvcvspsxds, 0x10, 0x19, 0, PPC2_VSX)GEN_VSX_HELPER_2 (xvcvspsxws,0x10 ,0x09 ,0 ,PPC2_VSX )
target-ppc/translate/vsx-ops.inc.c +2 -0
@@ -179,6 +179,7 @@ GEN_XX3FORM(xvmindp, 0x00, 0x1D, PPC2_VSX),GEN_XX3_RC_FORM (xvcmpeqdp,0x0C ,0x0C ,PPC2_VSX ),GEN_XX3_RC_FORM (xvcmpgtdp,0x0C ,0x0D ,PPC2_VSX ),GEN_XX3_RC_FORM (xvcmpgedp,0x0C ,0x0E ,PPC2_VSX ), +GEN_XX3_RC_FORM (xvcmpnedp,0x0C ,0x0F ,PPC2_ISA300 ),GEN_XX2FORM (xvcvdpsp,0x12 ,0x18 ,PPC2_VSX ),GEN_XX2FORM (xvcvdpsxds,0x10 ,0x1D ,PPC2_VSX ), GEN_XX2FORM(xvcvdpsxws, 0x10, 0x0D, PPC2_VSX),
@@ -216,6 +217,7 @@ GEN_XX3FORM(xvminsp, 0x00, 0x19, PPC2_VSX),GEN_XX3_RC_FORM (xvcmpeqsp,0x0C ,0x08 ,PPC2_VSX ),GEN_XX3_RC_FORM (xvcmpgtsp,0x0C ,0x09 ,PPC2_VSX ),GEN_XX3_RC_FORM (xvcmpgesp,0x0C ,0x0A ,PPC2_VSX ), +GEN_XX3_RC_FORM (xvcmpnesp,0x0C ,0x0B ,PPC2_ISA300 ),GEN_XX2FORM (xvcvspdp,0x12 ,0x1C ,PPC2_VSX ),GEN_XX2FORM (xvcvspsxds,0x10 ,0x19 ,PPC2_VSX ), GEN_XX2FORM(xvcvspsxws, 0x10, 0x09, PPC2_VSX),
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 64/73] tests: Add pseries machine to the prom-env-test, too
In reply to David GibsonNow that we also support the "-prom-env" parameter for the pseries machine, we can enable this test for this machine, too. Since booting with TCG is rather slow with the pseries machine, we also enable the "-nodefaults" parameter for this test now, so that SLOF does not have to check that much devices during boot and thus runs a little bit faster.
[dwg: Don't add -nodefaults to the command line, it causes extra warnings
for the sparc testcases]
--- tests/prom-env-test.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-)
tests/prom-env-test.c +12 -8
@@ -9,11 +9,12 @@* This work is licensed under the terms of the GNU GPL, version 2 * or later. See the COPYING file in the top-level directory. * -* This test is used to check that some OpenBIOS machines can be started -* successfully in TCG mode. To do this, we first put some Forth code into -* the "boot-command" Open Firmware environment variable. This Forth code -* writes a well-known magic value to a known location in memory. Then we -* start the guest so that OpenBIOS can boot and finally run the Forth code. +* This test is used to check that some Open Firmware based machines (i.e. +* OpenBIOS or SLOF) can be started successfully in TCG mode. To do this, we +* first put some Forth code into the "boot-command" Open Firmware environment +* variable. This Forth code writes a well-known magic value to a known location +* in memory. Then we start the guest so that the firmware can boot and finally +* run the Forth code. * The testing code here then can finally check whether the value has been * successfully written into the guest memory. */
@@ -71,13 +72,16 @@ int main(int argc, char *argv[]) {const char *sparc_machines[] = {"SPARCbook" ,"Voyager" ,"SS-20" ,NULL };const char *sparc64_machines[] = {"sun4u" ,"sun4v" ,NULL }; -const char *mac_machines[] = {"mac99" ,"g3beige" ,NULL }; +const char *ppc_machines[] = {"mac99" ,"g3beige" ,NULL }; +const char *ppc64_machines[] = {"mac99" ,"g3beige" ,"pseries" ,NULL };const char *arch =qtest_get_arch ();g_test_init (&argc, &argv,NULL ); -if (!strcmp (arch,"ppc" ) || !strcmp (arch,"ppc64" )) { -add_tests (mac_machines); +if (!strcmp (arch,"ppc" )) { +add_tests (ppc_machines); + }else if (!strcmp (arch,"ppc64" )) { +add_tests (ppc64_machines); }else if (!strcmp (arch,"sparc" )) {add_tests (sparc_machines); }else if (!strcmp (arch,"sparc64" )) {
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 52/73] libqos: Handle PCI IO de-multiplexing in common code
In reply to David GibsonThe PCI IO space (aka PIO, aka legacy IO) and PCI memory space (aka MMIO) are distinct address spaces by the PCI spec (although parts of one might be aliased to parts of the other in some cases).
However, qpci_io_read*() and qpci_io_write*() can perform accesses to either space depending on parameter. That's convenient for test case drivers, since there are a fair few devices which can be controlled via either a PIO or MMIO BAR but with an otherwise identical driver.
This is implemented by having addresses below 64kiB treated as PIO, and those above treated as MMIO. This works because low addresses in memory space are generally reserved for DMA rather than MMIO.
At the moment, this demultiplexing must be handled by each PCI backend (pc and spapr, so far). There's no real reason for this - the current encoding is likely to work for all platforms, and even if it doesn't we can still use a more complex common encoding since the value returned from iomap are semi-opaque.
This patch moves the demultiplexing into the common part of the libqos PCI code, with the backends having simpler, separate accessors for PIO and MMIO space. This also means we have a way of explicitly accessing either space if it's necessary for some special case.
--- tests/libqos/pci-pc.c | 107 ++++++++++++++++++++---------------------- tests/libqos/pci-spapr.c | 118 +++++++++++++++++++++++++---------------------- tests/libqos/pci.c | 49 +++++++++++++++++--- tests/libqos/pci.h | 22 ++++++--- 4 files changed, 170 insertions(+), 126 deletions(-)
tests/libqos/pci-pc.c +50 -57
@@ -36,79 +36,64 @@ typedef struct QPCIBusPCuint16_t pci_iohole_alloc; } QPCIBusPC; -static uint8_t qpci_pc_io_readb (QPCIBus *bus,void *addr) +static uint8_t qpci_pc_pio_readb (QPCIBus *bus,uint32_t addr) { -uintptr_t port = (uintptr_t )addr; -uint8_t value; - -if (port <0x10000 ) { - value =inb (port); - }else { - value =readb (port); - } - -return value; +return inb (addr); } -static uint16_t qpci_pc_io_readw (QPCIBus *bus,void *addr) +static uint8_t qpci_pc_mmio_readb (QPCIBus *bus,uint32_t addr) { -uintptr_t port = (uintptr_t )addr; -uint16_t value; - -if (port <0x10000 ) { - value =inw (port); - }else { - value =readw (port); - } +return readb (addr); +} -return value; +static void qpci_pc_pio_writeb (QPCIBus *bus,uint32_t addr,uint8_t val) +{ +outb (addr, val); } -static uint32_t qpci_pc_io_readl (QPCIBus *bus,void *addr) +static void qpci_pc_mmio_writeb (QPCIBus *bus,uint32_t addr,uint8_t val) { -uintptr_t port = (uintptr_t )addr; -uint32_t value; +writeb (addr, val); +} -if (port <0x10000 ) { - value =inl (port); - }else { - value =readl (port); - } +static uint16_t qpci_pc_pio_readw (QPCIBus *bus,uint32_t addr) +{ +return inw (addr); +} -return value; +static uint16_t qpci_pc_mmio_readw (QPCIBus *bus,uint32_t addr) +{ +return readw (addr); } -static void qpci_pc_io_writeb (QPCIBus *bus,void *addr,uint8_t value) +static void qpci_pc_pio_writew (QPCIBus *bus,uint32_t addr,uint16_t val) { -uintptr_t port = (uintptr_t )addr; +outw (addr, val); +} -if (port <0x10000 ) { -outb (port, value); - }else { -writeb (port, value); - } +static void qpci_pc_mmio_writew (QPCIBus *bus,uint32_t addr,uint16_t val) +{ +writew (addr, val); } -static void qpci_pc_io_writew (QPCIBus *bus,void *addr,uint16_t value) +static uint32_t qpci_pc_pio_readl (QPCIBus *bus,uint32_t addr) { -uintptr_t port = (uintptr_t )addr; +return inl (addr); +} -if (port <0x10000 ) { -outw (port, value); - }else { -writew (port, value); - } +static uint32_t qpci_pc_mmio_readl (QPCIBus *bus,uint32_t addr) +{ +return readl (addr); } -static void qpci_pc_io_writel (QPCIBus *bus,void *addr,uint32_t value) +static void qpci_pc_pio_writel (QPCIBus *bus,uint32_t addr,uint32_t val) { -uintptr_t port = (uintptr_t )addr; +outl (addr, val); +} -if (port <0x10000 ) { -outl (port, value); - }else { -writel (port, value); - } +static void qpci_pc_mmio_writel (QPCIBus *bus,uint32_t addr,uint32_t val) +{ +writel (addr, val); }static uint8_t qpci_pc_config_readb (QPCIBus *bus,int devfn,uint8_t offset)
@@ -218,13 +203,21 @@ QPCIBus *qpci_init_pc(QGuestAllocator *alloc) ret =g_malloc (sizeof (*ret)); - ret->bus.io_readb = qpci_pc_io_readb; - ret->bus.io_readw = qpci_pc_io_readw; - ret->bus.io_readl = qpci_pc_io_readl; + ret->bus.pio_readb = qpci_pc_pio_readb; + ret->bus.pio_readw = qpci_pc_pio_readw; + ret->bus.pio_readl = qpci_pc_pio_readl; + + ret->bus.pio_writeb = qpci_pc_pio_writeb; + ret->bus.pio_writew = qpci_pc_pio_writew; + ret->bus.pio_writel = qpci_pc_pio_writel; + + ret->bus.mmio_readb = qpci_pc_mmio_readb; + ret->bus.mmio_readw = qpci_pc_mmio_readw; + ret->bus.mmio_readl = qpci_pc_mmio_readl; - ret->bus.io_writeb = qpci_pc_io_writeb; - ret->bus.io_writew = qpci_pc_io_writew; - ret->bus.io_writel = qpci_pc_io_writel; + ret->bus.mmio_writeb = qpci_pc_mmio_writeb; + ret->bus.mmio_writew = qpci_pc_mmio_writew; + ret->bus.mmio_writel = qpci_pc_mmio_writel; ret->bus.config_readb = qpci_pc_config_readb; ret->bus.config_readw = qpci_pc_config_readw;
tests/libqos/pci-spapr.c +62 -56
153 lines not on this page · raw message
tests/libqos/pci.c +42 -7
75 lines not on this page · raw message
tests/libqos/pci.h +16 -6
@@ -15,6 +15,8 @@#include "libqtest.h" +#define QPCI_PIO_LIMIT 0x10000 +#define QPCI_DEVFN (dev, fn) (((dev) << 3) | (fn))typedef struct QPCIDevice QPCIDevice ;
@@ -22,13 +24,21 @@ typedef struct QPCIBus QPCIBus;struct QPCIBus { -uint8_t (*io_readb)(QPCIBus *bus,void *addr); -uint16_t (*io_readw)(QPCIBus *bus,void *addr); -uint32_t (*io_readl)(QPCIBus *bus,void *addr); +uint8_t (*pio_readb)(QPCIBus *bus,uint32_t addr); +uint16_t (*pio_readw)(QPCIBus *bus,uint32_t addr); +uint32_t (*pio_readl)(QPCIBus *bus,uint32_t addr); + +uint8_t (*mmio_readb)(QPCIBus *bus,uint32_t addr); +uint16_t (*mmio_readw)(QPCIBus *bus,uint32_t addr); +uint32_t (*mmio_readl)(QPCIBus *bus,uint32_t addr); + +void (*pio_writeb)(QPCIBus *bus,uint32_t addr,uint8_t value); +void (*pio_writew)(QPCIBus *bus,uint32_t addr,uint16_t value); +void (*pio_writel)(QPCIBus *bus,uint32_t addr,uint32_t value); -void (*io_writeb)(QPCIBus *bus,void *addr,uint8_t value); -void (*io_writew)(QPCIBus *bus,void *addr,uint16_t value); -void (*io_writel)(QPCIBus *bus,void *addr,uint32_t value); +void (*mmio_writeb)(QPCIBus *bus,uint32_t addr,uint8_t value); +void (*mmio_writew)(QPCIBus *bus,uint32_t addr,uint16_t value); +void (*mmio_writel)(QPCIBus *bus,uint32_t addr,uint32_t value);uint8_t (*config_readb)(QPCIBus *bus,int devfn,uint8_t offset);uint16_t (*config_readw)(QPCIBus *bus,int devfn,uint8_t offset);
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 56/73] libqos: Add streaming accessors for PCI MMIO
In reply to David GibsonCurrently PCI memory (aka MMIO) space is accessed via a set of readb/writeb style accessors. This is what we want for accessing discrete registers of a certain size. However, there are a few cases where we instead need a "bag of bytes" style streaming interface to PCI MMIO space. This can be either for streaming data style registers or when there's actual memory rather than registers in PCI space, for example frame buffers or ivshmem.
This patch adds backend callbacks, and libqos wrappers for this type of byte address order preserving accesses.
--- tests/libqos/pci-pc.c | 14 ++++++++++++++ tests/libqos/pci-spapr.c | 17 +++++++++++++++++ tests/libqos/pci.c | 16 ++++++++++++++++ tests/libqos/pci.h | 6 ++++++ 4 files changed, 53 insertions(+)
tests/libqos/pci-pc.c +14 -0
@@ -87,6 +87,17 @@ static void qpci_pc_mmio_writel(QPCIBus *bus, uint32_t addr, uint32_t val)writel (addr, val); } +static void qpci_pc_memread (QPCIBus *bus,uint32_t addr,void *buf,size_t len) +{ +memread (addr, buf, len); +} + +static void qpci_pc_memwrite (QPCIBus *bus,uint32_t addr, +const void *buf,size_t len) +{ +memwrite (addr, buf, len); +} +static uint8_t qpci_pc_config_readb (QPCIBus *bus,int devfn,uint8_t offset) {outl (0xcf8 , (1U <<31 ) | (devfn <<8 ) | offset);
@@ -145,6 +156,9 @@ QPCIBus *qpci_init_pc(QGuestAllocator *alloc) ret->bus.mmio_writew = qpci_pc_mmio_writew; ret->bus.mmio_writel = qpci_pc_mmio_writel; + ret->bus.memread = qpci_pc_memread; + ret->bus.memwrite = qpci_pc_memwrite; + ret->bus.config_readb = qpci_pc_config_readb; ret->bus.config_readw = qpci_pc_config_readw; ret->bus.config_readl = qpci_pc_config_readl;
tests/libqos/pci-spapr.c +17 -0
@@ -114,6 +114,20 @@ static void qpci_spapr_mmio32_writel(QPCIBus *bus, uint32_t addr, uint32_t val)writel (s->mmio32_cpu_base + addr,bswap32 (val)); } +static void qpci_spapr_memread (QPCIBus *bus,uint32_t addr, +void *buf,size_t len) +{ +QPCIBusSPAPR *s =container_of (bus, QPCIBusSPAPR, bus); +memread (s->mmio32_cpu_base + addr, buf, len); +} + +static void qpci_spapr_memwrite (QPCIBus *bus,uint32_t addr, +const void *buf,size_t len) +{ +QPCIBusSPAPR *s =container_of (bus, QPCIBusSPAPR, bus); +memwrite (s->mmio32_cpu_base + addr, buf, len); +} +static uint8_t qpci_spapr_config_readb (QPCIBus *bus,int devfn,uint8_t offset) {QPCIBusSPAPR *s =container_of (bus, QPCIBusSPAPR, bus);
@@ -188,6 +202,9 @@ QPCIBus *qpci_init_spapr(QGuestAllocator *alloc) ret->bus.mmio_writew = qpci_spapr_mmio32_writew; ret->bus.mmio_writel = qpci_spapr_mmio32_writel; + ret->bus.memread = qpci_spapr_memread; + ret->bus.memwrite = qpci_spapr_memwrite; + ret->bus.config_readb = qpci_spapr_config_readb; ret->bus.config_readw = qpci_spapr_config_readw; ret->bus.config_readl = qpci_spapr_config_readl;
tests/libqos/pci.c +16 -0
@@ -289,6 +289,22 @@ void qpci_io_writel(QPCIDevice *dev, void *data, uint32_t value) } } +void qpci_memread (QPCIDevice *dev,void *data,void *buf,size_t len) +{ +uintptr_t addr = (uintptr_t )data; + +g_assert (addr >=QPCI_PIO_LIMIT ); + dev->bus->memread (dev->bus, addr, buf, len); +} + +void qpci_memwrite (QPCIDevice *dev,void *data,const void *buf,size_t len) +{ +uintptr_t addr = (uintptr_t )data; + +g_assert (addr >=QPCI_PIO_LIMIT ); + dev->bus->memwrite (dev->bus, addr, buf, len); +} +void *qpci_iomap (QPCIDevice *dev,int barno,uint64_t *sizeptr) {QPCIBus *bus = dev->bus;
tests/libqos/pci.h +6 -0
@@ -39,6 +39,9 @@ struct QPCIBus {void (*mmio_writew)(QPCIBus *bus,uint32_t addr,uint16_t value);void (*mmio_writel)(QPCIBus *bus,uint32_t addr,uint32_t value); +void (*memread)(QPCIBus *bus,uint32_t addr,void *buf,size_t len); +void (*memwrite)(QPCIBus *bus,uint32_t addr,const void *buf,size_t len); +uint8_t (*config_readb)(QPCIBus *bus,int devfn,uint8_t offset);uint16_t (*config_readw)(QPCIBus *bus,int devfn,uint8_t offset);uint32_t (*config_readl)(QPCIBus *bus,int devfn,uint8_t offset);
@@ -92,6 +95,9 @@ void qpci_io_writeb(QPCIDevice *dev, void *data, uint8_t value);void qpci_io_writew (QPCIDevice *dev,void *data,uint16_t value);void qpci_io_writel (QPCIDevice *dev,void *data,uint32_t value); +void qpci_memread (QPCIDevice *bus,void *data,void *buf,size_t len); +void qpci_memwrite (QPCIDevice *bus,void *data,const void *buf,size_t len); +void *qpci_iomap (QPCIDevice *dev,int barno,uint64_t *sizeptr);void qpci_iounmap (QPCIDevice *dev,void *data);void *qpci_legacy_iomap (QPCIDevice *dev,uint16_t addr);
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 47/73] spapr_hcall: use spapr_ovec_* interfaces for CAS options
In reply to David GibsonFrom: Michael Roth <[email protected]>
Currently we access individual bytes of an option vector via ldub_phys() to test for the presence of a particular capability within that byte. Currently this is only done for the "dynamic reconfiguration memory" capability bit. If that bit is present, we pass a boolean value to spapr_h_cas_compose_response() to generate a modified device tree segment with the additional properties required to enable this functionality.
As more capability bits are added, will would need to modify the code to add additional option vector accesses and extend the param list for spapr_h_cas_compose_response() to include similar boolean values for these parameters.
Avoid this by switching to spapr_ovec_* helpers so we can do all the parsing in one shot and then test for these additional bits within spapr_h_cas_compose_response() directly.
--- hw/ppc/spapr.c | 10 ++++++-- hw/ppc/spapr_hcall.c | 56 ++++++++++++--------------------------------- include/hw/ppc/spapr.h | 5 +++- include/hw/ppc/spapr_ovec.h | 3 +++ 4 files changed, 30 insertions(+), 44 deletions(-)
hw/ppc/spapr.c +8 -2
@@ -657,7 +657,7 @@ out:int spapr_h_cas_compose_response (sPAPRMachineState *spapr,target_ulong addr,target_ulong size, -bool cpu_update,bool memory_update) +bool cpu_update) {void *fdt, *fdt_skel;sPAPRDeviceTreeUpdateHeader hdr = { .version_id =1 };
@@ -681,7 +681,8 @@ int spapr_h_cas_compose_response(sPAPRMachineState *spapr, }/* Generate ibm,dynamic-reconfiguration-memory node if required */ -if (memory_update && smc->dr_lmb_enabled) { +if (spapr_ovec_test (spapr->ov5_cas,OV5_DRCONF_MEMORY )) { +g_assert (smc->dr_lmb_enabled);_FDT ((spapr_populate_drconf_memory (spapr, fdt))); }
@@ -1740,7 +1741,12 @@ static void ppc_spapr_init(MachineState *machine)DIV_ROUND_UP (max_cpus * smt, smp_threads), XICS_IRQS_SPAPR, &error_fatal); +/* Set up containers for ibm,client-set-architecture negotiated options */ + spapr->ov5 =spapr_ovec_new (); + spapr->ov5_cas =spapr_ovec_new (); +if (smc->dr_lmb_enabled) { +spapr_ovec_set (spapr->ov5,OV5_DRCONF_MEMORY );spapr_validate_node_memory (machine, &error_fatal); }
hw/ppc/spapr_hcall.c +15 -41
95 lines not on this page · raw message
include/hw/ppc/spapr.h +4 -1
@@ -6,6 +6,7 @@#include "hw/ppc/xics.h" #include "hw/ppc/spapr_drc.h" #include "hw/mem/pc-dimm.h" +#include "hw/ppc/spapr_ovec.h" struct VIOsPAPRBus ;struct sPAPRPHBState ;
@@ -72,6 +73,8 @@ struct sPAPRMachineState {uint64_t rtc_offset;/* Now used only during incoming migration */ struct PPCTimebase tb;bool has_graphics; +sPAPROptionVector *ov5;/* QEMU-supported option vectors */ +sPAPROptionVector *ov5_cas;/* negotiated (via CAS) option vectors */ uint32_t check_exception_irq;Notifier epow_notifier;
@@ -583,7 +586,7 @@ void spapr_events_init(sPAPRMachineState *sm);void spapr_dt_events (void *fdt,uint32_t check_exception_irq);int spapr_h_cas_compose_response (sPAPRMachineState *sm,target_ulong addr,target_ulong size, -bool cpu_update,bool memory_update); +bool cpu_update);sPAPRTCETable *spapr_tce_new_table (DeviceState *owner,uint32_t liobn); void spapr_tce_table_enable(sPAPRTCETable *tcet, uint32_t page_shift, uint64_t bus_offset,
include/hw/ppc/spapr_ovec.h +3 -0
@@ -42,6 +42,9 @@ typedef struct sPAPROptionVector sPAPROptionVector;#define OV_BIT (byte, bit) ((byte - 1) * BITS_PER_BYTE + bit) +/* option vector 5 */ +#define OV5_DRCONF_MEMORY OV_BIT(2, 2) +/* interfaces */ sPAPROptionVector *spapr_ovec_new (void );sPAPROptionVector *spapr_ovec_clone (sPAPROptionVector *ov_orig);
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 49/73] spapr: improve ibm, architecture-vec-5 property handling
In reply to David GibsonFrom: Michael Roth <[email protected]>
ibm,architecture-vec-5 is supposed to encode all option vector 5 bits negotiated between platform/guest. Currently we hardcode this property in the boot-time device tree to advertise a single negotiated capability, "Form 1" NUMA Affinity, regardless of whether or not CAS has been invoked or that capability has actually been negotiated.
Improve this by generating ibm,architecture-vec-5 based on the full set of option vector 5 capabilities negotiated via CAS.
--- hw/ppc/spapr.c | 23 +++++++++++++++++------ include/hw/ppc/spapr_ovec.h | 1 + 2 files changed, 18 insertions(+), 6 deletions(-)
hw/ppc/spapr.c +17 -6
@@ -659,14 +659,28 @@ static int spapr_dt_cas_updates(sPAPRMachineState *spapr, void *fdt, sPAPROptionVector *ov5_updates) {sPAPRMachineClass *smc =SPAPR_MACHINE_GET_CLASS (spapr); -int ret =0 ; +int ret =0 , offset;/* Generate ibm,dynamic-reconfiguration-memory node if required */ if (spapr_ovec_test (ov5_updates,OV5_DRCONF_MEMORY )) {g_assert (smc->dr_lmb_enabled); ret =spapr_populate_drconf_memory (spapr, fdt); +if (ret) { + goto out; + } } + offset =fdt_path_offset (fdt,"/chosen" ); +if (offset <0 ) { + offset =fdt_add_subnode (fdt,0 ,"chosen" ); +if (offset <0 ) { +return offset; + } + } + ret =spapr_ovec_populate_dt (fdt, offset, spapr->ov5_cas, +"ibm,architecture-vec-5" ); + +out:return ret; }
@@ -792,14 +806,9 @@ static void spapr_dt_chosen(sPAPRMachineState *spapr, void *fdt)char *stdout_path =spapr_vio_stdout_path (spapr->vio_bus);size_t cb =0 ;char *bootlist =get_boot_devices_list (&cb, true); -unsigned char vec5[] = {0x0 ,0x0 ,0x0 ,0x0 ,0x0 ,0x80 };_FDT (chosen =fdt_add_subnode (fdt,0 ,"chosen" )); -/* Set Form1_affinity */ -_FDT (fdt_setprop (fdt, chosen,"ibm,architecture-vec-5" , - vec5,sizeof (vec5))); -_FDT (fdt_setprop_string (fdt, chosen,"bootargs" , machine->kernel_cmdline));_FDT (fdt_setprop_cell (fdt, chosen,"linux,initrd-start" , spapr->initrd_base));
@@ -1778,6 +1787,8 @@ static void ppc_spapr_init(MachineState *machine)spapr_validate_node_memory (machine, &error_fatal); } +spapr_ovec_set (spapr->ov5,OV5_FORM1_AFFINITY ); +/* init CPUs */ if (machine->cpu_model ==NULL ) { machine->cpu_model =kvm_enabled () ?"host" : smc->tcg_default_cpu;
include/hw/ppc/spapr_ovec.h +1 -0
@@ -44,6 +44,7 @@ typedef struct sPAPROptionVector sPAPROptionVector;/* option vector 5 */ #define OV5_DRCONF_MEMORY OV_BIT(2, 2) +#define OV5_FORM1_AFFINITY OV_BIT(5, 0)/* interfaces */ sPAPROptionVector *spapr_ovec_new (void );
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 69/73] spapr: add hotplug interrupt machine options
In reply to David GibsonFrom: Michael Roth <[email protected]>
This adds machine options of the form:
-machine pseries,modern-hotplug-events=true
-machine pseries,modern-hotplug-events=false
If false, QEMU will force the use of "legacy" style hotplug events, which are surfaced through EPOW events instead of a dedicated hot plug event source, and lack certain features necessary, mainly, for memory unplug support.
If true, QEMU will enable support for "modern" dedicated hot plug event source. Note that we will still default to "legacy" style unless the guest advertises support for the "modern" hotplug events via ibm,client-architecture-support hcall during early boot.
For pseries-2.7 and earlier we default to false, for newer machine types we default to true.
--- hw/ppc/spapr.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
hw/ppc/spapr.c +28 -0
@@ -2143,16 +2143,41 @@ static void spapr_set_kvm_type(Object *obj, const char *value, Error **errp) spapr->kvm_type =g_strdup (value); } +static bool spapr_get_modern_hotplug_events (Object *obj,Error **errp) +{ +sPAPRMachineState *spapr =SPAPR_MACHINE (obj); + +return spapr->use_hotplug_event_source; +} + +static void spapr_set_modern_hotplug_events (Object *obj,bool value, +Error **errp) +{ +sPAPRMachineState *spapr =SPAPR_MACHINE (obj); + + spapr->use_hotplug_event_source = value; +} +static void spapr_machine_initfn (Object *obj) {sPAPRMachineState *spapr =SPAPR_MACHINE (obj); spapr->htab_fd =-1 ; + spapr->use_hotplug_event_source = true;object_property_add_str (obj,"kvm-type" , spapr_get_kvm_type, spapr_set_kvm_type,NULL );object_property_set_description (obj,"kvm-type" ,"Specifies the KVM virtualization mode (HV, PR)" ,NULL ); +object_property_add_bool (obj,"modern-hotplug-events" , + spapr_get_modern_hotplug_events, + spapr_set_modern_hotplug_events, +NULL ); +object_property_set_description (obj,"modern-hotplug-events" , +"Use dedicated hotplug event mechanism in" +" place of standard EPOW events when possible" +" (required for memory hot-unplug support)" , +NULL ); }static void spapr_machine_finalizefn (Object *obj)
@@ -2599,7 +2624,10 @@ static void phb_placement_2_7(sPAPRMachineState *spapr, uint32_t index,static void spapr_machine_2_7_instance_options (MachineState *machine) { +sPAPRMachineState *spapr =SPAPR_MACHINE (machine); +spapr_machine_2_8_instance_options (machine); + spapr->use_hotplug_event_source = false; }static void spapr_machine_2_7_class_options (MachineClass *mc)
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 48/73] spapr: add option vector handling in CAS-generated resets
In reply to David GibsonFrom: Michael Roth <[email protected]>
In some cases, ibm,client-architecture-support calls can fail. This could happen in the current code for situations where the modified device tree segment exceeds the buffer size provided by the guest via the call parameters. In these cases, QEMU will reset, allowing an opportunity to regenerate the device tree from scratch via boot-time handling. There are potentially other scenarios as well, not currently reachable in the current code, but possible in theory, such as cases where device-tree properties or nodes need to be removed.
We currently don't handle either of these properly for option vector capabilities however. Instead of carrying the negotiated capability beyond the reset and creating the boot-time device tree accordingly, we start from scratch, generating the same boot-time device tree as we did prior to the CAS-generated and the same device tree updates as we did before. This could (in theory) cause us to get stuck in a reset loop. This hasn't been observed, but depending on the extensiveness of CAS-induced device tree updates in the future, could eventually become an issue.
Address this by pulling capability-related device tree updates resulting from CAS calls into a common routine, spapr_dt_cas_updates(), and adding an sPAPROptionVector* parameter that allows us to test for newly-negotiated capabilities. We invoke it as follows:
1) When ibm,client-architecture-support gets called, we call spapr_dt_cas_updates() with the set of capabilities added since the previous call to ibm,client-architecture-support. For the initial boot, or a system reset generated by something other than the CAS call itself, this set will consist of *all* options supported both the platform and the guest. For calls to ibm,client-architecture-support immediately after a CAS-induced reset, we call spapr_dt_cas_updates() with only the set of capabilities added since the previous call, since the other capabilities will have already been addressed by the boot-time device-tree this time around. In the unlikely event that capabilities are *removed* since the previous CAS, we will generate a CAS-induced reset. In the unlikely event that we cannot fit the device-tree updates into the buffer provided by the guest, well generate a CAS-induced reset.
2) When a CAS update results in the need to reset the machine and include the updates in the boot-time device tree, we call the spapr_dt_cas_updates() using the full set of negotiated capabilities as part of the reset path. At initial boot, or after a reset generated by something other than the CAS call itself, this set will be empty, resulting in what should be the same boot-time device-tree as we generated prior to this patch. For CAS-induced reset, this routine will be called with the full set of capabilities negotiated by the platform/guest in the previous CAS call, which should result in CAS updates from previous call being accounted for in the initial boot-time device tree.
--- hw/ppc/spapr.c | 40 ++++++++++++++++++++++++++++++++++------ hw/ppc/spapr_hcall.c | 22 ++++++++++++++++++---- include/hw/ppc/spapr.h | 4 +++- 3 files changed, 55 insertions(+), 11 deletions(-)
hw/ppc/spapr.c +34 -6
@@ -655,13 +655,28 @@ out:return ret; } +static int spapr_dt_cas_updates (sPAPRMachineState *spapr,void *fdt, +sPAPROptionVector *ov5_updates) +{ +sPAPRMachineClass *smc =SPAPR_MACHINE_GET_CLASS (spapr); +int ret =0 ; + +/* Generate ibm,dynamic-reconfiguration-memory node if required */ +if (spapr_ovec_test (ov5_updates,OV5_DRCONF_MEMORY )) { +g_assert (smc->dr_lmb_enabled); + ret =spapr_populate_drconf_memory (spapr, fdt); + } + +return ret; +} +int spapr_h_cas_compose_response (sPAPRMachineState *spapr,target_ulong addr,target_ulong size, -bool cpu_update) +bool cpu_update, +sPAPROptionVector *ov5_updates) {void *fdt, *fdt_skel;sPAPRDeviceTreeUpdateHeader hdr = { .version_id =1 }; -sPAPRMachineClass *smc =SPAPR_MACHINE_GET_CLASS (qdev_get_machine ()); size -=sizeof (hdr);
@@ -680,10 +695,8 @@ int spapr_h_cas_compose_response(sPAPRMachineState *spapr,_FDT ((spapr_fixup_cpu_dt (fdt, spapr))); } -/* Generate ibm,dynamic-reconfiguration-memory node if required */ -if (spapr_ovec_test (spapr->ov5_cas,OV5_DRCONF_MEMORY )) { -g_assert (smc->dr_lmb_enabled); -_FDT ((spapr_populate_drconf_memory (spapr, fdt))); +if (spapr_dt_cas_updates (spapr, fdt, ov5_updates)) { +return -1 ; }/* Pack resulting tree */
@@ -972,6 +985,13 @@ static void *spapr_build_fdt(sPAPRMachineState *spapr,_FDT ((fdt_add_mem_rsv (fdt, spapr->initrd_base, spapr->initrd_size))); } +/* ibm,client-architecture-support updates */ + ret =spapr_dt_cas_updates (spapr, fdt, spapr->ov5_cas); +if (ret <0 ) { +error_report ("couldn't setup CAS properties fdt" ); +exit (1 ); + } +return fdt; }
@@ -1137,6 +1157,13 @@ static void ppc_spapr_reset(void) rtas_addr = rtas_limit -RTAS_MAX_SIZE ; fdt_addr = rtas_addr -FDT_MAX_SIZE ; +/* if this reset wasn't generated by CAS, we should reset our +* negotiated options and start from scratch */ +if (!spapr->cas_reboot) { +spapr_ovec_cleanup (spapr->ov5_cas); + spapr->ov5_cas =spapr_ovec_new (); + } + fdt =spapr_build_fdt (spapr, rtas_addr, spapr->rtas_size);spapr_load_rtas (spapr, fdt, rtas_addr);
@@ -1164,6 +1191,7 @@ static void ppc_spapr_reset(void) first_cpu->halted =0 ; first_ppc_cpu->env.nip =SPAPR_ENTRY_POINT ; + spapr->cas_reboot = false; }static void spapr_create_nvram (sPAPRMachineState *spapr)
hw/ppc/spapr_hcall.c +18 -4
@@ -950,7 +950,7 @@ static target_ulong h_client_architecture_support(PowerPCCPU *cpu_,unsigned compat_lvl =0 , cpu_version =0 ;unsigned max_lvl =get_compat_level (cpu_->max_compat);int counter; -sPAPROptionVector *ov5_guest; +sPAPROptionVector *ov5_guest, *ov5_cas_old, *ov5_updates;/* Parse PVR list */ for (counter =0 ; counter <512 ; ++counter) {
@@ -1013,13 +1013,27 @@ static target_ulong h_client_architecture_support(PowerPCCPU *cpu_,* of guest input. To model these properly we'd want some sort of mask, * but since they only currently apply to memory migration as defined * by LoPAPR 1.1, 14.5.4.8, which QEMU doesn't implement, we don't need -* to worry about this. +* to worry about this for now. */ + ov5_cas_old =spapr_ovec_clone (spapr->ov5_cas); +/* full range of negotiated ov5 capabilities */ spapr_ovec_intersect (spapr->ov5_cas, spapr->ov5, ov5_guest);spapr_ovec_cleanup (ov5_guest); +/* capabilities that have been added since CAS-generated guest reset. +* if capabilities have since been removed, generate another reset +*/ + ov5_updates =spapr_ovec_new (); + spapr->cas_reboot =spapr_ovec_diff (ov5_updates, + ov5_cas_old, spapr->ov5_cas); + +if (!spapr->cas_reboot) { + spapr->cas_reboot = + (spapr_h_cas_compose_response (spapr, args[1 ], args[2 ], cpu_update, + ov5_updates) !=0 ); + } +spapr_ovec_cleanup (ov5_updates); -if (spapr_h_cas_compose_response (spapr, args[1 ], args[2 ], - cpu_update)) { +if (spapr->cas_reboot) {qemu_system_reset_request (); }
include/hw/ppc/spapr.h +3 -1
@@ -75,6 +75,7 @@ struct sPAPRMachineState {bool has_graphics;sPAPROptionVector *ov5;/* QEMU-supported option vectors */ sPAPROptionVector *ov5_cas;/* negotiated (via CAS) option vectors */ +bool cas_reboot;uint32_t check_exception_irq;Notifier epow_notifier;
@@ -586,7 +587,8 @@ void spapr_events_init(sPAPRMachineState *sm);void spapr_dt_events (void *fdt,uint32_t check_exception_irq);int spapr_h_cas_compose_response (sPAPRMachineState *sm,target_ulong addr,target_ulong size, -bool cpu_update); +bool cpu_update, +sPAPROptionVector *ov5_updates);sPAPRTCETable *spapr_tce_new_table (DeviceState *owner,uint32_t liobn); void spapr_tce_table_enable(sPAPRTCETable *tcet, uint32_t page_shift, uint64_t bus_offset,
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 53/73] libqos: Move BAR assignment to common code
In reply to David GibsonThe PCI backends in libqos each supply an iomap() and iounmap() function which is used to set up a specified PCI BAR. But PCI BAR allocation takes place entirely within PCI space, so doesn't really need per-backend versions. For example, Linux includes generic BAR allocation code used on platforms where that isn't done by firmware.
This patch merges the BAR allocation from the two existing backends into a single simplified copy. The back ends just need to set up some parameters describing the window of PCI IO and PCI memory addresses which are available for allocation. Like both the existing versions the new one uses a simple bump allocator.
Note that (again like the existing versions) this doesn't really handle 64-bit memory BARs properly. It is actually used for such a BAR by the ivshmem test, and apparently the 32-bit MMIO BAR logic is close enough to work, as long as the BAR isn't too big. Fixing that to properly handle 64-bit BAR allocation is a problem for another time.
--- tests/libqos/pci-pc.c | 87 ++-------------------------------------------- tests/libqos/pci-spapr.c | 89 ++---------------------------------------------- tests/libqos/pci.c | 56 ++++++++++++++++++++++++++++-- tests/libqos/pci.h | 7 ++-- 4 files changed, 63 insertions(+), 176 deletions(-)
tests/libqos/pci-pc.c +3 -84
@@ -17,7 +17,6 @@#include "hw/pci/pci_regs.h" #include "qemu-common.h" -#include "qemu/host-utils.h" #define ACPI_PCIHP_ADDR 0xae00
@@ -26,14 +25,6 @@typedef struct QPCIBusPC {QPCIBus bus; - -uint32_t pci_hole_start; -uint32_t pci_hole_size; -uint32_t pci_hole_alloc; - -uint16_t pci_iohole_start; -uint16_t pci_iohole_size; -uint16_t pci_iohole_alloc; }QPCIBusPC ;static uint8_t qpci_pc_pio_readb (QPCIBus *bus,uint32_t addr)
@@ -132,71 +123,6 @@ static void qpci_pc_config_writel(QPCIBus *bus, int devfn, uint8_t offset, uint3outl (0xcfc , value); } -static void *qpci_pc_iomap (QPCIBus *bus,QPCIDevice *dev,int barno,uint64_t *sizeptr) -{ -QPCIBusPC *s =container_of (bus, QPCIBusPC, bus); -static const int bar_reg_map[] = { -PCI_BASE_ADDRESS_0 ,PCI_BASE_ADDRESS_1 ,PCI_BASE_ADDRESS_2 , -PCI_BASE_ADDRESS_3 ,PCI_BASE_ADDRESS_4 ,PCI_BASE_ADDRESS_5 , - }; -int bar_reg; -uint32_t addr; -uint64_t size; -uint32_t io_type; - -g_assert (barno >=0 && barno <=5 ); - bar_reg = bar_reg_map[barno]; - -qpci_config_writel (dev, bar_reg,0xFFFFFFFF ); - addr =qpci_config_readl (dev, bar_reg); - - io_type = addr &PCI_BASE_ADDRESS_SPACE ; -if (io_type ==PCI_BASE_ADDRESS_SPACE_IO ) { - addr &=PCI_BASE_ADDRESS_IO_MASK ; - }else { - addr &=PCI_BASE_ADDRESS_MEM_MASK ; - } - - size = (1ULL <<ctzl (addr)); -if (size ==0 ) { -return NULL ; - } -if (sizeptr) { - *sizeptr = size; - } - -if (io_type ==PCI_BASE_ADDRESS_SPACE_IO ) { -uint16_t loc; - -g_assert (QEMU_ALIGN_UP (s->pci_iohole_alloc, size) + size - <= s->pci_iohole_size); - s->pci_iohole_alloc =QEMU_ALIGN_UP (s->pci_iohole_alloc, size); - loc = s->pci_iohole_start + s->pci_iohole_alloc; - s->pci_iohole_alloc += size; - -qpci_config_writel (dev, bar_reg, loc |PCI_BASE_ADDRESS_SPACE_IO ); - -return (void *)(intptr_t )loc; - }else { -uint64_t loc; - -g_assert (QEMU_ALIGN_UP (s->pci_hole_alloc, size) + size - <= s->pci_hole_size); - s->pci_hole_alloc =QEMU_ALIGN_UP (s->pci_hole_alloc, size); - loc = s->pci_hole_start + s->pci_hole_alloc; - s->pci_hole_alloc += size; - -qpci_config_writel (dev, bar_reg, loc); - -return (void *)(intptr_t )loc; - } -} - -static void qpci_pc_iounmap (QPCIBus *bus,void *data) -{ -/* FIXME */ -} -QPCIBus *qpci_init_pc (QGuestAllocator *alloc) {QPCIBusPC *ret;
@@ -227,16 +153,9 @@ QPCIBus *qpci_init_pc(QGuestAllocator *alloc) ret->bus.config_writew = qpci_pc_config_writew; ret->bus.config_writel = qpci_pc_config_writel; - ret->bus.iomap = qpci_pc_iomap; - ret->bus.iounmap = qpci_pc_iounmap; - - ret->pci_hole_start =0xE0000000 ; - ret->pci_hole_size =0x20000000 ; - ret->pci_hole_alloc =0 ; - - ret->pci_iohole_start =0xc000 ; - ret->pci_iohole_size =0x4000 ; - ret->pci_iohole_alloc =0 ; + ret->bus.pio_alloc_ptr =0xc000 ; + ret->bus.mmio_alloc_ptr =0xE0000000 ; + ret->bus.mmio_limit =0x100000000ULL ;return &ret->bus; }
tests/libqos/pci-spapr.c +3 -86
113 lines not on this page · raw message
tests/libqos/pci.c +54 -2
72 lines not on this page · raw message
tests/libqos/pci.h +3 -4
@@ -22,8 +22,7 @@typedef struct QPCIDevice QPCIDevice ;typedef struct QPCIBus QPCIBus ; -struct QPCIBus -{ +struct QPCIBus {uint8_t (*pio_readb)(QPCIBus *bus,uint32_t addr);uint16_t (*pio_readw)(QPCIBus *bus,uint32_t addr);uint32_t (*pio_readl)(QPCIBus *bus,uint32_t addr);
@@ -51,8 +50,8 @@ struct QPCIBusvoid (*config_writel)(QPCIBus *bus,int devfn,uint8_t offset,uint32_t value); -void *(*iomap)(QPCIBus *bus,QPCIDevice *dev,int barno,uint64_t *sizeptr); -void (*iounmap)(QPCIBus *bus,void *data); +uint16_t pio_alloc_ptr; +uint64_t mmio_alloc_ptr, mmio_limit; };struct QPCIDevice
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 70/73] spapr: Add DRC count indexed hotplug identifier type
In reply to David GibsonFrom: Bharata B Rao <[email protected]>
Add support for DRC count indexed hotplug ID type which is primarily needed for memory hot unplug. This type allows for specifying the number of DRs that should be plugged/unplugged starting from a given DRC index.
* updated rtas_event_log_v6_hp to reflect count/index field ordering used in PAPR hotplug ACR
--- hw/ppc/spapr_events.c | 76 ++++++++++++++++++++++++++++++++++++++++---------- include/hw/ppc/spapr.h | 4 +++ 2 files changed, 65 insertions(+), 15 deletions(-)
hw/ppc/spapr_events.c +61 -15
@@ -175,6 +175,16 @@ struct epow_log_full {struct rtas_event_log_v6_epow epow; }QEMU_PACKED ; +union drc_identifier { +uint32_t index; +uint32_t count; +struct { +uint32_t count; +uint32_t index; + } count_indexed; +char name[1 ]; +}QEMU_PACKED ; +struct rtas_event_log_v6_hp {#define RTAS_LOG_V6_SECTION_ID_HOTPLUG 0x4850/* HP */ struct rtas_event_log_v6_section_header hdr;
@@ -191,12 +201,9 @@ struct rtas_event_log_v6_hp {#define RTAS_LOG_V6_HP_ID_DRC_NAME 1#define RTAS_LOG_V6_HP_ID_DRC_INDEX 2#define RTAS_LOG_V6_HP_ID_DRC_COUNT 3 +#define RTAS_LOG_V6_HP_ID_DRC_COUNT_INDEXED 4uint8_t reserved; -union { -uint32_t index; -uint32_t count; -char name[1 ]; - } drc; +union drc_identifier drc_id; }QEMU_PACKED ;struct hp_log_full {
@@ -488,7 +495,7 @@ static void spapr_hotplug_set_signalled(uint32_t drc_index)static void spapr_hotplug_req_event (uint8_t hp_id,uint8_t hp_action,sPAPRDRConnectorType drc_type, -uint32_t drc) +union drc_identifier *drc_id) {sPAPRMachineState *spapr =SPAPR_MACHINE (qdev_get_machine ());struct hp_log_full *new_hp;
@@ -533,7 +540,7 @@ static void spapr_hotplug_req_event(uint8_t hp_id, uint8_t hp_action,case SPAPR_DR_CONNECTOR_TYPE_PCI : hp->hotplug_type =RTAS_LOG_V6_HP_TYPE_PCI ;if (hp->hotplug_action ==RTAS_LOG_V6_HP_ACTION_ADD ) { -spapr_hotplug_set_signalled (drc); +spapr_hotplug_set_signalled (drc_id->index); }break ;case SPAPR_DR_CONNECTOR_TYPE_LMB :
@@ -551,9 +558,18 @@ static void spapr_hotplug_req_event(uint8_t hp_id, uint8_t hp_action, }if (hp_id ==RTAS_LOG_V6_HP_ID_DRC_COUNT ) { - hp->drc.count =cpu_to_be32 (drc); + hp->drc_id.count =cpu_to_be32 (drc_id->count); }else if (hp_id ==RTAS_LOG_V6_HP_ID_DRC_INDEX ) { - hp->drc.index =cpu_to_be32 (drc); + hp->drc_id.index =cpu_to_be32 (drc_id->index); + }else if (hp_id ==RTAS_LOG_V6_HP_ID_DRC_COUNT_INDEXED ) { +/* we should not be using count_indexed value unless the guest +* supports dedicated hotplug event source +*/ +g_assert (spapr_ovec_test (spapr->ov5_cas,OV5_HP_EVT )); + hp->drc_id.count_indexed.count = +cpu_to_be32 (drc_id->count_indexed.count); + hp->drc_id.count_indexed.index = +cpu_to_be32 (drc_id->count_indexed.index); }rtas_event_log_queue (RTAS_LOG_TYPE_HOTPLUG , new_hp, true);
@@ -567,34 +583,64 @@ void spapr_hotplug_req_add_by_index(sPAPRDRConnector *drc) {sPAPRDRConnectorClass *drck =SPAPR_DR_CONNECTOR_GET_CLASS (drc);sPAPRDRConnectorType drc_type = drck->get_type (drc); -uint32_t index = drck->get_index (drc); +union drc_identifier drc_id; + drc_id.index = drck->get_index (drc);spapr_hotplug_req_event (RTAS_LOG_V6_HP_ID_DRC_INDEX , -RTAS_LOG_V6_HP_ACTION_ADD , drc_type, index); +RTAS_LOG_V6_HP_ACTION_ADD , drc_type, &drc_id); }void spapr_hotplug_req_remove_by_index (sPAPRDRConnector *drc) {sPAPRDRConnectorClass *drck =SPAPR_DR_CONNECTOR_GET_CLASS (drc);sPAPRDRConnectorType drc_type = drck->get_type (drc); -uint32_t index = drck->get_index (drc); +union drc_identifier drc_id; + drc_id.index = drck->get_index (drc);spapr_hotplug_req_event (RTAS_LOG_V6_HP_ID_DRC_INDEX , -RTAS_LOG_V6_HP_ACTION_REMOVE , drc_type, index); +RTAS_LOG_V6_HP_ACTION_REMOVE , drc_type, &drc_id); }void spapr_hotplug_req_add_by_count (sPAPRDRConnectorType drc_type,uint32_t count) { +union drc_identifier drc_id; + + drc_id.count = count;spapr_hotplug_req_event (RTAS_LOG_V6_HP_ID_DRC_COUNT , -RTAS_LOG_V6_HP_ACTION_ADD , drc_type, count); +RTAS_LOG_V6_HP_ACTION_ADD , drc_type, &drc_id); }void spapr_hotplug_req_remove_by_count (sPAPRDRConnectorType drc_type,uint32_t count) { +union drc_identifier drc_id; + + drc_id.count = count;spapr_hotplug_req_event (RTAS_LOG_V6_HP_ID_DRC_COUNT , -RTAS_LOG_V6_HP_ACTION_REMOVE , drc_type, count); +RTAS_LOG_V6_HP_ACTION_REMOVE , drc_type, &drc_id); +} + +void spapr_hotplug_req_add_by_count_indexed (sPAPRDRConnectorType drc_type, +uint32_t count,uint32_t index) +{ +union drc_identifier drc_id; + + drc_id.count_indexed.count = count; + drc_id.count_indexed.index = index; +spapr_hotplug_req_event (RTAS_LOG_V6_HP_ID_DRC_COUNT_INDEXED , +RTAS_LOG_V6_HP_ACTION_ADD , drc_type, &drc_id); +} + +void spapr_hotplug_req_remove_by_count_indexed (sPAPRDRConnectorType drc_type, +uint32_t count,uint32_t index) +{ +union drc_identifier drc_id; + + drc_id.count_indexed.count = count; + drc_id.count_indexed.index = index; +spapr_hotplug_req_event (RTAS_LOG_V6_HP_ID_DRC_COUNT_INDEXED , +RTAS_LOG_V6_HP_ACTION_REMOVE , drc_type, &drc_id); } static void check_exception(PowerPCCPU *cpu, sPAPRMachineState *spapr,
include/hw/ppc/spapr.h +4 -0
@@ -610,6 +610,10 @@ void spapr_hotplug_req_add_by_count(sPAPRDRConnectorType drc_type, uint32_t count);void spapr_hotplug_req_remove_by_count (sPAPRDRConnectorType drc_type,uint32_t count); +void spapr_hotplug_req_add_by_count_indexed (sPAPRDRConnectorType drc_type, +uint32_t count,uint32_t index); +void spapr_hotplug_req_remove_by_count_indexed (sPAPRDRConnectorType drc_type, +uint32_t count,uint32_t index);void spapr_cpu_init (sPAPRMachineState *spapr,PowerPCCPU *cpu,Error **errp);void *spapr_populate_hotplug_cpu_dt (CPUState *cs,int *fdt_offset,sPAPRMachineState *spapr);
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 54/73] libqos: Better handling of PCI legacy IO
In reply to David GibsonThe usual model for PCI IO with libqos is to use qpci_iomap() to map a specific BAR for a PCI device, then perform IOs within that BAR using qpci_io_{read,write}*().
However, certain devices also have legacy PCI IO. In this case, instead of (or as well as) being accessed via PCI BARs, the device can be accessed via certain well-known, fixed addresses in PCI IO space.
Two existing tests use legacy PCI IO, and take different flawed approaches to it:
* tco-test manually constructs a tco_io_base value instead of calling qpci_iomap(), which assumes internal knowledge of the structure of the value it shouldn't have
* ide-test uses direct in*() and out*() calls instead of using qpci_io_*() accessors, meaning it's not portable to non-x86 machine types.
This patch implements a new qpci_iomap_legacy() interface which gets a handle in the same format as qpci_iomap() but refers to a region in the legacy PIO space. For a device which has the same registers available both in a BAR and in legacy space (quite common), this allows the same test code to test both options with just a different iomap() at the beginning.
--- tests/libqos/pci.c | 5 +++++ tests/libqos/pci.h | 1 + 2 files changed, 6 insertions(+)
tests/libqos/pci.c +5 -0
@@ -350,6 +350,11 @@ void qpci_iounmap(QPCIDevice *dev, void *data)/* FIXME */ } +void *qpci_legacy_iomap (QPCIDevice *dev,uint16_t addr) +{ +return (void *)(uintptr_t )addr; +} +void qpci_plug_device_test (const char *driver,const char *id,uint8_t slot,const char *opts) {
tests/libqos/pci.h +1 -0
@@ -94,6 +94,7 @@ void qpci_io_writel(QPCIDevice *dev, void *data, uint32_t value);void *qpci_iomap (QPCIDevice *dev,int barno,uint64_t *sizeptr);void qpci_iounmap (QPCIDevice *dev,void *data); +void *qpci_legacy_iomap (QPCIDevice *dev,uint16_t addr);void qpci_plug_device_test (const char *driver,const char *id,uint8_t slot,const char *opts);
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 51/73] libqos: Give qvirtio_config_read*() consistent semantics
In reply to David GibsonThe 'addr' parameter to qvirtio_config_read*() doesn't have a consistent
meaning: when using the virtio-pci versions, it's a full PCI space address, but for virtio-mmio, it's an offset from the device's base mmio address.
This means that the callers need to do different things to calculate the addresses in the two cases, which rather defeats the purpose of function pointer backends.
All the current users of these functions are using them to retrieve variables from the device specific portion of the virtio config space. So, this patch alters the semantics to always be an offset into that device specific config area.
--- tests/libqos/virtio-mmio.c | 16 ++++++++-------- tests/libqos/virtio-pci.c | 25 ++++++++++++++----------- tests/virtio-9p-test.c | 8 ++------ tests/virtio-blk-test.c | 42 +++++++++++------------------------------- tests/virtio-scsi-test.c | 4 +--- 5 files changed, 36 insertions(+), 59 deletions(-)
tests/libqos/virtio-mmio.c +8 -8
@@ -15,28 +15,28 @@#include "libqos/malloc-generic.h" #include "standard-headers/linux/virtio_ring.h" -static uint8_t qvirtio_mmio_config_readb (QVirtioDevice *d,uint64_t addr) +static uint8_t qvirtio_mmio_config_readb (QVirtioDevice *d,uint64_t off) {QVirtioMMIODevice *dev = (QVirtioMMIODevice *)d; -return readb (dev->addr + addr); +return readb (dev->addr +QVIRTIO_MMIO_DEVICE_SPECIFIC + off); } -static uint16_t qvirtio_mmio_config_readw (QVirtioDevice *d,uint64_t addr) +static uint16_t qvirtio_mmio_config_readw (QVirtioDevice *d,uint64_t off) {QVirtioMMIODevice *dev = (QVirtioMMIODevice *)d; -return readw (dev->addr + addr); +return readw (dev->addr +QVIRTIO_MMIO_DEVICE_SPECIFIC + off); } -static uint32_t qvirtio_mmio_config_readl (QVirtioDevice *d,uint64_t addr) +static uint32_t qvirtio_mmio_config_readl (QVirtioDevice *d,uint64_t off) {QVirtioMMIODevice *dev = (QVirtioMMIODevice *)d; -return readl (dev->addr + addr); +return readl (dev->addr +QVIRTIO_MMIO_DEVICE_SPECIFIC + off); } -static uint64_t qvirtio_mmio_config_readq (QVirtioDevice *d,uint64_t addr) +static uint64_t qvirtio_mmio_config_readq (QVirtioDevice *d,uint64_t off) {QVirtioMMIODevice *dev = (QVirtioMMIODevice *)d; -return readq (dev->addr + addr); +return readq (dev->addr +QVIRTIO_MMIO_DEVICE_SPECIFIC + off); }static uint32_t qvirtio_mmio_get_features (QVirtioDevice *d)
tests/libqos/virtio-pci.c +14 -11
@@ -62,10 +62,13 @@ static void qvirtio_pci_assign_device(QVirtioDevice *d, void *data) *vpcidev = (QVirtioPCIDevice *)d; } -static uint8_t qvirtio_pci_config_readb (QVirtioDevice *d,uint64_t addr) +#define CONFIG_BASE (dev) \ + ((dev)->addr + VIRTIO_PCI_CONFIG_OFF((dev)->pdev->msix_enabled)) + +static uint8_t qvirtio_pci_config_readb (QVirtioDevice *d,uint64_t off) {QVirtioPCIDevice *dev = (QVirtioPCIDevice *)d; -return qpci_io_readb (dev->pdev, (void *)(uintptr_t )addr); +return qpci_io_readb (dev->pdev,CONFIG_BASE (dev) + off); }/* PCI is always read in little-endian order
@@ -76,31 +79,31 @@ static uint8_t qvirtio_pci_config_readb(QVirtioDevice *d, uint64_t addr)* case will be managed inside qvirtio_is_big_endian() */ -static uint16_t qvirtio_pci_config_readw (QVirtioDevice *d,uint64_t addr) +static uint16_t qvirtio_pci_config_readw (QVirtioDevice *d,uint64_t off) {QVirtioPCIDevice *dev = (QVirtioPCIDevice *)d;uint16_t value; - value =qpci_io_readw (dev->pdev, (void *)(uintptr_t )addr); + value =qpci_io_readw (dev->pdev,CONFIG_BASE (dev) + off);if (qvirtio_is_big_endian (d)) { value =bswap16 (value); }return value; } -static uint32_t qvirtio_pci_config_readl (QVirtioDevice *d,uint64_t addr) +static uint32_t qvirtio_pci_config_readl (QVirtioDevice *d,uint64_t off) {QVirtioPCIDevice *dev = (QVirtioPCIDevice *)d;uint32_t value; - value =qpci_io_readl (dev->pdev, (void *)(uintptr_t )addr); + value =qpci_io_readl (dev->pdev,CONFIG_BASE (dev) + off);if (qvirtio_is_big_endian (d)) { value =bswap32 (value); }return value; } -static uint64_t qvirtio_pci_config_readq (QVirtioDevice *d,uint64_t addr) +static uint64_t qvirtio_pci_config_readq (QVirtioDevice *d,uint64_t off) {QVirtioPCIDevice *dev = (QVirtioPCIDevice *)d;int i;
@@ -108,13 +111,13 @@ static uint64_t qvirtio_pci_config_readq(QVirtioDevice *d, uint64_t addr)if (qvirtio_is_big_endian (d)) {for (i =0 ; i <8 ; ++i) { - u64 |= (uint64_t )qpci_io_readb (dev->pdev, - (void *)(uintptr_t )addr + i) << (7 - i) *8 ; + u64 |= (uint64_t )qpci_io_readb (dev->pdev,CONFIG_BASE (dev) + + off + i) << (7 - i) *8 ; } }else {for (i =0 ; i <8 ; ++i) { - u64 |= (uint64_t )qpci_io_readb (dev->pdev, - (void *)(uintptr_t )addr + i) << i *8 ; + u64 |= (uint64_t )qpci_io_readb (dev->pdev,CONFIG_BASE (dev) + + off + i) << i *8 ; } }
tests/virtio-9p-test.c +2 -6
@@ -95,7 +95,6 @@ static void qvirtio_9p_pci_free(QVirtIO9P *v9p)static void pci_basic_config (void ) {QVirtIO9P *v9p; -void *addr;size_t tag_len;char *tag;int i;
@@ -104,15 +103,12 @@ static void pci_basic_config(void) qs =qvirtio_9p_start (); v9p =qvirtio_9p_pci_init (qs); - addr = ((QVirtioPCIDevice *) v9p->dev)->addr +VIRTIO_PCI_CONFIG_OFF (false); - tag_len =qvirtio_config_readw (v9p->dev, - (uint64_t )(uintptr_t )addr); + tag_len =qvirtio_config_readw (v9p->dev,0 ); g_assert_cmpint(tag_len, ==, strlen(mount_tag)); - addr +=sizeof (uint16_t ); tag =g_malloc (tag_len);for (i =0 ; i < tag_len; i++) { - tag[i] =qvirtio_config_readb (v9p->dev, (uint64_t )(uintptr_t )addr + i); + tag[i] =qvirtio_config_readb (v9p->dev, i +2 ); }g_assert_cmpmem (tag, tag_len, mount_tag, tag_len);g_free (tag);
tests/virtio-blk-test.c +11 -31
138 lines not on this page · raw message
tests/virtio-scsi-test.c +1 -3
@@ -143,7 +143,6 @@ static QVirtIOSCSI *qvirtio_scsi_pci_init(int slot)QVirtIOSCSI *vs;QVirtioPCIDevice *dev;struct virtio_scsi_cmd_resp resp; -void *addr;int i; vs =g_new0 (QVirtIOSCSI,1 );
@@ -161,8 +160,7 @@ static QVirtIOSCSI *qvirtio_scsi_pci_init(int slot)qvirtio_set_acknowledge (vs->dev);qvirtio_set_driver (vs->dev); - addr = dev->addr +VIRTIO_PCI_CONFIG_OFF (false); - vs->num_queues =qvirtio_config_readl (vs->dev, (uint64_t )(uintptr_t )addr); + vs->num_queues =qvirtio_config_readl (vs->dev,0 ); g_assert_cmpint(vs->num_queues, <, MAX_NUM_QUEUES);
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 62/73] libqos: Change PCI accessors to take opaque BAR handle
In reply to David GibsonThe usual use model for the libqos PCI functions is to map a specific PCI BAR using qpci_iomap() then pass the returned token into IO accessor functions. This, and the fact that iomap() returns a (void *) which actually contains a PCI space address, kind of suggests that the return value from iomap is supposed to be an opaque token.
..except that the callers expect to be able to add offsets to it. Which also assumes the compiler will support pointer arithmetic on a (void *), and treat it as working with byte offsets.
To clarify this situation change iomap() and the IO accessors to take a definitely opaque BAR handle (enforced with a wrapper struct) along with an offset within the BAR. This changes both the functions and all the callers.
There were a number of places that checked if iomap() returned non-NULL, and or initialized it to NULL before hand. Since iomap() already assert()s if it fails to map the BAR, these tests were mostly pointless and are removed.
--- tests/e1000e-test.c | 7 +- tests/ide-test.c | 176 +++++++++++++++++++++++----------------------- tests/ivshmem-test.c | 16 ++--- tests/libqos/ahci.c | 3 +- tests/libqos/ahci.h | 6 +- tests/libqos/pci.c | 149 ++++++++++++++++++--------------------- tests/libqos/pci.h | 46 +++++++----- tests/libqos/usb.c | 6 +- tests/libqos/usb.h | 2 +- tests/libqos/virtio-pci.c | 101 +++++++++++++------------- tests/libqos/virtio-pci.h | 2 +- tests/rtl8139-test.c | 10 ++- tests/tco-test.c | 80 ++++++++++----------- tests/usb-hcd-ehci-test.c | 5 +- 14 files changed, 300 insertions(+), 309 deletions(-)
tests/e1000e-test.c +3 -4
@@ -87,7 +87,7 @@ typedef struct e1000e_device { QPCIDevice *pci_dev; - void *mac_regs; + QPCIBar mac_regs; uint64_t tx_ring; uint64_t rx_ring;
@@ -119,12 +119,12 @@ static QPCIDevice *e1000e_device_find(QPCIBus *bus)static void e1000e_macreg_write (e1000e_device *d,uint32_t reg,uint32_t val) { -qpci_io_writel (d->pci_dev, d->mac_regs + reg, val); +qpci_io_writel (d->pci_dev, d->mac_regs, reg, val); }static uint32_t e1000e_macreg_read (e1000e_device *d,uint32_t reg) { -return qpci_io_readl (d->pci_dev, d->mac_regs + reg); +return qpci_io_readl (d->pci_dev, d->mac_regs, reg); }static void e1000e_device_init (QPCIBus *bus,e1000e_device *d)
@@ -138,7 +138,6 @@ static void e1000e_device_init(QPCIBus *bus, e1000e_device *d)/* Map BAR0 (mac registers) */ d->mac_regs =qpci_iomap (d->pci_dev,0 ,NULL ); -g_assert_nonnull (d->mac_regs);/* Reset the device */ val =e1000e_macreg_read (d,E1000E_CTRL );
tests/ide-test.c +87 -89
522 lines not on this page · raw message
tests/ivshmem-test.c +7 -9
@@ -41,7 +41,7 @@ static QPCIDevice *get_device(QPCIBus *pcibus)typedef struct _IVState {QTestState *qtest; -void *reg_base, *mem_base; +QPCIBar reg_bar, mem_bar;QPCIBus *pcibus;QPCIDevice *dev; }IVState ;
@@ -75,7 +75,7 @@ static inline unsigned in_reg(IVState *s, enum Reg reg)unsigned res; global_qtest = s->qtest; - res =qpci_io_readl (s->dev, s->reg_base + reg); + res =qpci_io_readl (s->dev, s->reg_bar, reg);g_test_message ("*%s -> %x\n" , name, res); global_qtest = qtest;
@@ -89,7 +89,7 @@ static inline void out_reg(IVState *s, enum Reg reg, unsigned v) global_qtest = s->qtest;g_test_message ("%x -> *%s\n" , v, name); -qpci_io_writel (s->dev, s->reg_base + reg, v); +qpci_io_writel (s->dev, s->reg_bar, reg, v); global_qtest = qtest; }
@@ -98,7 +98,7 @@ static inline void read_mem(IVState *s, uint64_t off, void *buf, size_t len)QTestState *qtest = global_qtest; global_qtest = s->qtest; -qpci_memread (s->dev, s->mem_base + off, buf, len); +qpci_memread (s->dev, s->mem_bar, off, buf, len); global_qtest = qtest; }
@@ -108,7 +108,7 @@ static inline void write_mem(IVState *s, uint64_t off,QTestState *qtest = global_qtest; global_qtest = s->qtest; -qpci_memwrite (s->dev, s->mem_base + off, buf, len); +qpci_memwrite (s->dev, s->mem_bar, off, buf, len); global_qtest = qtest; }
@@ -127,16 +127,14 @@ static void setup_vm_cmd(IVState *s, const char *cmd, bool msix) s->pcibus =qpci_init_pc (NULL ); s->dev =get_device (s->pcibus); - s->reg_base =qpci_iomap (s->dev,0 , &barsize); -g_assert_nonnull (s->reg_base); + s->reg_bar =qpci_iomap (s->dev,0 , &barsize); g_assert_cmpuint(barsize, ==, 256);if (msix) {qpci_msix_enable (s->dev); } - s->mem_base =qpci_iomap (s->dev,2 , &barsize); -g_assert_nonnull (s->mem_base); + s->mem_bar =qpci_iomap (s->dev,2 , &barsize); g_assert_cmpuint(barsize, ==, TMPSHMSIZE);qpci_device_enable (s->dev);
tests/libqos/ahci.c +1 -2
@@ -210,8 +210,7 @@ void ahci_pci_enable(AHCIQState *ahci)void start_ahci_device (AHCIQState *ahci) {/* Map AHCI's ABAR (BAR5) */ - ahci->hba_base =qpci_iomap (ahci->dev,5 , &ahci->barsize); -g_assert (ahci->hba_base); + ahci->hba_bar =qpci_iomap (ahci->dev,5 , &ahci->barsize);/* turns on pci.cmd.iose, pci.cmd.mse and pci.cmd.bme */ qpci_device_enable (ahci->dev);
tests/libqos/ahci.h +3 -3
@@ -321,7 +321,7 @@ typedef struct AHCIPortQState { typedef struct AHCIQState { QOSState *parent; QPCIDevice *dev; - void *hba_base; + QPCIBar hba_bar; uint64_t barsize; uint32_t fingerprint; uint32_t cap;
@@ -489,12 +489,12 @@ typedef struct AHCIOpts {static inline uint32_t ahci_mread (AHCIQState *ahci,size_t offset) { -return qpci_io_readl (ahci->dev, ahci->hba_base + offset); +return qpci_io_readl (ahci->dev, ahci->hba_bar, offset); }static inline void ahci_mwrite (AHCIQState *ahci,size_t offset,uint32_t value) { -qpci_io_writel (ahci->dev, ahci->hba_base + offset, value); +qpci_io_writel (ahci->dev, ahci->hba_bar, offset, value); }static inline uint32_t ahci_rreg (AHCIQState *ahci,uint32_t reg_num)
tests/libqos/pci.c +68 -81
276 lines not on this page · raw message
tests/libqos/pci.h +28 -18
69 lines not on this page · raw message
tests/libqos/usb.c +2 -4
@@ -21,14 +21,12 @@ void qusb_pci_init_one(QPCIBus *pcibus, struct qhc *hc, uint32_t devfn, int bar) hc->dev =qpci_device_find (pcibus, devfn);g_assert (hc->dev !=NULL );qpci_device_enable (hc->dev); - hc->base =qpci_iomap (hc->dev, bar,NULL ); -g_assert (hc->base !=NULL ); + hc->bar =qpci_iomap (hc->dev, bar,NULL ); }void uhci_port_test (struct qhc *hc,int port,uint16_t expect) { -void *addr = hc->base +0x10 +2 * port; -uint16_t value =qpci_io_readw (hc->dev, addr); +uint16_t value =qpci_io_readw (hc->dev, hc->bar,0x10 +2 * port);uint16_t mask = ~(UHCI_PORT_WRITE_CLEAR |UHCI_PORT_RSVD1 );g_assert ((value & mask) == (expect & mask));
tests/libqos/usb.h +1 -1
@@ -5,7 +5,7 @@struct qhc {QPCIDevice *dev; -void *base; +QPCIBar bar; }; void qusb_pci_init_one(QPCIBus *pcibus, struct qhc *hc,
tests/libqos/virtio-pci.c +53 -48
228 lines not on this page · raw message
tests/libqos/virtio-pci.h +1 -1
@@ -16,7 +16,7 @@ typedef struct QVirtioPCIDevice { QVirtioDevice vdev; QPCIDevice *pdev; - void *addr; + QPCIBar bar; uint16_t config_msix_entry; uint64_t config_msix_addr; uint32_t config_msix_data;
tests/rtl8139-test.c +4 -6
@@ -22,7 +22,7 @@ static void nop(void)static QPCIBus *pcibus;static QPCIDevice *dev; -static void *dev_base; +static QPCIBar dev_bar;static void save_fn (QPCIDevice *dev,int devfn,void *data) {
@@ -45,14 +45,14 @@ static QPCIDevice *get_device(void)#define PORT (name, len, val) \ static unsigned __attribute__((unused)) in_##name(void) \ { \ - unsigned res = qpci_io_read##len(dev, dev_base+(val)); \ + unsigned res = qpci_io_read##len(dev, dev_bar, (val)); \ g_test_message("*%s -> %x\n", #name, res); \ return res; \ } \ static void out_##name(unsigned v) \ { \ g_test_message("%x -> *%s\n", v, #name); \ - qpci_io_write##len(dev, dev_base+(val), v); \ + qpci_io_write##len(dev, dev_bar, (val), v); \ }PORT (Timer, l,0x48 )
@@ -186,9 +186,7 @@ static void test_init(void) dev =get_device (); - dev_base =qpci_iomap (dev,0 , &barsize); - -g_assert (dev_base !=NULL ); + dev_bar =qpci_iomap (dev,0 , &barsize);qpci_device_enable (dev);
tests/tco-test.c +40 -40
195 lines not on this page · raw message
tests/usb-hcd-ehci-test.c +2 -3
@@ -38,8 +38,7 @@ static void uhci_port_update(struct qhc *hc, int port,static void ehci_port_test (struct qhc *hc,int port,uint32_t expect) { -void *addr = hc->base +0x64 +4 * port; -uint32_t value =qpci_io_readl (hc->dev, addr); +uint32_t value =qpci_io_readl (hc->dev, hc->bar,0x64 +4 * port);uint16_t mask = ~(PORTSC_CSC |PORTSC_PEDC |PORTSC_OCC );#if 0
@@ -91,7 +90,7 @@ static void pci_ehci_port_1(void)static void pci_ehci_config (void ) {/* hands over all ports from companion uhci to ehci */ -qpci_io_writew (ehci1.dev, ehci1.base +0x60 ,1 ); +qpci_io_writew (ehci1.dev, ehci1.bar,0x60 ,1 ); }static void pci_uhci_port_2 (void )
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 22/73] ppc: add skiboot firmware for the pnv platform
In reply to David GibsonFrom: Cédric Le Goater <[email protected]>
This is the initial image of skiboot 5.3.7 (commit 762d0082) for the PowerPC PowerNV (Non-Virtualized) platform. Built from submodule.
--- .gitmodules | 3 +++ MAINTAINERS | 1 + Makefile | 2 +- pc-bios/README | 5 +++++ pc-bios/skiboot.lid | Bin 0 -> 983893 bytes roms/Makefile | 8 +++++++- roms/skiboot | 1 + 7 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 pc-bios/skiboot.lid create mode 160000 roms/skiboot
.gitmodules +3 -0
@@ -31,3 +31,6 @@ [submodule "roms/u-boot"] path = roms/u-boot url = git://git.qemu-project.org/u-boot.git +[submodule "roms/skiboot"] + path = roms/skiboot + url = git://git.qemu.org/skiboot.git
MAINTAINERS +1 -0
@@ -656,6 +656,7 @@ F: include/hw/*/xics* F: pc-bios/spapr-rtas/* F: pc-bios/spapr-rtas.bin F: pc-bios/slof.bin +F: pc-bios/skiboot.lid F: docs/specs/ppc-spapr-hcalls.txt F: docs/specs/ppc-spapr-hotplug.txt F: tests/spapr*
Makefile +1 -1
@@ -421,7 +421,7 @@ qemu-icon.bmp qemu_logo_no_text.svg \ bamboo.dtb petalogix-s3adsp1800.dtb petalogix-ml605.dtb \ multiboot.bin linuxboot.bin linuxboot_dma.bin kvmvapic.bin \ s390-ccw.img \ -spapr-rtas.bin slof.bin \ +spapr-rtas.bin slof.bin skiboot.lid \ palcode-clipper \ u-boot.e500 else
pc-bios/README +5 -0
@@ -42,3 +42,8 @@ it was compiled using the qemu-ppce500 target. A git mirror is available at: git://git.qemu-project.org/u-boot.git The hash used to compile the current version is: 2072e72 + +- Skiboot (https://github.com/open-power/skiboot/) is an OPAL + (OpenPower Abstraction Layer) firmware for OpenPOWER systems. It can + run an hypervisor OS or simply a host OS on the "baremetal" + platform, also known as the PowerNV (Non-Virtualized) platform.
pc-bios/skiboot.lid new file binary +0 -0
roms/Makefile +7 -1
@@ -63,6 +63,7 @@ default: @echo " efirom -- update nic roms (bios+efi, this needs" @echo " the EfiRom utility from edk2 / tianocore)" @echo " slof -- update slof.bin" + @echo " skiboot -- update skiboot.lid" @echo " u-boot.e500 -- update u-boot.e500" bios: build-seabios-config-seabios-128k build-seabios-config-seabios-256k
@@ -103,7 +104,7 @@ build-lgplvgabios: $(MAKE) -C vgabios $(vgabios_targets) -.PHONY: sgabios +.PHONY: sgabios skiboot sgabios: $(MAKE) -C sgabios cp sgabios/sgabios.bin ../pc-bios
@@ -146,6 +147,10 @@ u-boot.e500: $(powerpc_cross_prefix)strip u-boot/build.e500/u-boot -o \ ../pc-bios/u-boot.e500 +skiboot: + $(MAKE) -C skiboot CROSS=$(powerpc64_cross_prefix) + cp skiboot/skiboot.lid ../pc-bios/skiboot.lid + clean: rm -rf seabios/.config seabios/out seabios/builds $(MAKE) -C vgabios clean
@@ -155,3 +160,4 @@ clean: $(MAKE) -C ipxe/src veryclean $(MAKE) -C SLOF clean rm -rf u-boot/build.e500 + $(MAKE) -C skiboot clean
roms/skiboot new file +1 -0
@@ -0,0 +1 @@ +Subproject commit 762d0082f18e4fb921a2d44a1051b02d8b0f6381
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 59/73] libqos: Add 64-bit PCI IO accessors
In reply to David GibsonCurrently the libqos PCI layer includes accessor helpers for 8, 16 and 32 bit reads and writes. It's likely that we'll want 64-bit accesses in the future (plenty of modern peripherals will have 64-bit reigsters). This adds them.
For PIO (not MMIO) accesses on the PC backend, this is implemented as two 32-bit ins or outs. That's not ideal but AFAICT x86 doesn't have 64-bit versions of in and out.
This patch also converts the single current user of 64-bit accesses - virtio-pci.c to use the new mechanism, rather than a sequence of 8 byte reads.
--- tests/libqos/pci-pc.c | 13 +++++++++++++ tests/libqos/pci-spapr.c | 14 ++++++++++++++ tests/libqos/pci.c | 25 +++++++++++++++++++++++++ tests/libqos/pci.h | 4 ++++ tests/libqos/virtio-pci.c | 16 ++++------------ 5 files changed, 60 insertions(+), 12 deletions(-)
tests/libqos/pci-pc.c +13 -0
@@ -57,6 +57,17 @@ static void qpci_pc_pio_writel(QPCIBus *bus, uint32_t addr, uint32_t val)outl (addr, val); } +static uint64_t qpci_pc_pio_readq (QPCIBus *bus,uint32_t addr) +{ +return (uint64_t )inl (addr) + ((uint64_t )inl (addr +4 ) <<32 ); +} + +static void qpci_pc_pio_writeq (QPCIBus *bus,uint32_t addr,uint64_t val) +{ +outl (addr, val &0xffffffff ); +outl (addr +4 , val >>32 ); +} +static void qpci_pc_memread (QPCIBus *bus,uint32_t addr,void *buf,size_t len) {memread (addr, buf, len);
@@ -113,10 +124,12 @@ QPCIBus *qpci_init_pc(QGuestAllocator *alloc) ret->bus.pio_readb = qpci_pc_pio_readb; ret->bus.pio_readw = qpci_pc_pio_readw; ret->bus.pio_readl = qpci_pc_pio_readl; + ret->bus.pio_readq = qpci_pc_pio_readq; ret->bus.pio_writeb = qpci_pc_pio_writeb; ret->bus.pio_writew = qpci_pc_pio_writew; ret->bus.pio_writel = qpci_pc_pio_writel; + ret->bus.pio_writeq = qpci_pc_pio_writeq; ret->bus.memread = qpci_pc_memread; ret->bus.memwrite = qpci_pc_memwrite;
tests/libqos/pci-spapr.c +14 -0
@@ -78,6 +78,18 @@ static void qpci_spapr_pio_writel(QPCIBus *bus, uint32_t addr, uint32_t val)writel (s->pio_cpu_base + addr,bswap32 (val)); } +static uint64_t qpci_spapr_pio_readq (QPCIBus *bus,uint32_t addr) +{ +QPCIBusSPAPR *s =container_of (bus, QPCIBusSPAPR, bus); +return bswap64 (readq (s->pio_cpu_base + addr)); +} + +static void qpci_spapr_pio_writeq (QPCIBus *bus,uint32_t addr,uint64_t val) +{ +QPCIBusSPAPR *s =container_of (bus, QPCIBusSPAPR, bus); +writeq (s->pio_cpu_base + addr,bswap64 (val)); +} +static void qpci_spapr_memread (QPCIBus *bus,uint32_t addr,void *buf,size_t len) {
@@ -153,10 +165,12 @@ QPCIBus *qpci_init_spapr(QGuestAllocator *alloc) ret->bus.pio_readb = qpci_spapr_pio_readb; ret->bus.pio_readw = qpci_spapr_pio_readw; ret->bus.pio_readl = qpci_spapr_pio_readl; + ret->bus.pio_readq = qpci_spapr_pio_readq; ret->bus.pio_writeb = qpci_spapr_pio_writeb; ret->bus.pio_writew = qpci_spapr_pio_writew; ret->bus.pio_writel = qpci_spapr_pio_writel; + ret->bus.pio_writeq = qpci_spapr_pio_writeq; ret->bus.memread = qpci_spapr_memread; ret->bus.memwrite = qpci_spapr_memwrite;
tests/libqos/pci.c +25 -0
@@ -262,6 +262,19 @@ uint32_t qpci_io_readl(QPCIDevice *dev, void *data) } } +uint64_t qpci_io_readq (QPCIDevice *dev,void *data) +{ +uintptr_t addr = (uintptr_t )data; + +if (addr <QPCI_PIO_LIMIT ) { +return dev->bus->pio_readq (dev->bus, addr); + }else { +uint64_t val; + dev->bus->memread (dev->bus, addr, &val,sizeof (val)); +return le64_to_cpu (val); + } +} +void qpci_io_writeb (QPCIDevice *dev,void *data,uint8_t value) {uintptr_t addr = (uintptr_t )data;
@@ -297,6 +310,18 @@ void qpci_io_writel(QPCIDevice *dev, void *data, uint32_t value) } } +void qpci_io_writeq (QPCIDevice *dev,void *data,uint64_t value) +{ +uintptr_t addr = (uintptr_t )data; + +if (addr <QPCI_PIO_LIMIT ) { + dev->bus->pio_writeq (dev->bus, addr, value); + }else { + value =cpu_to_le64 (value); + dev->bus->memwrite (dev->bus, addr, &value,sizeof (value)); + } +} +void qpci_memread (QPCIDevice *dev,void *data,void *buf,size_t len) {uintptr_t addr = (uintptr_t )data;
tests/libqos/pci.h +4 -0
@@ -26,10 +26,12 @@ struct QPCIBus {uint8_t (*pio_readb)(QPCIBus *bus,uint32_t addr);uint16_t (*pio_readw)(QPCIBus *bus,uint32_t addr);uint32_t (*pio_readl)(QPCIBus *bus,uint32_t addr); +uint64_t (*pio_readq)(QPCIBus *bus,uint32_t addr);void (*pio_writeb)(QPCIBus *bus,uint32_t addr,uint8_t value);void (*pio_writew)(QPCIBus *bus,uint32_t addr,uint16_t value);void (*pio_writel)(QPCIBus *bus,uint32_t addr,uint32_t value); +void (*pio_writeq)(QPCIBus *bus,uint32_t addr,uint64_t value);void (*memread)(QPCIBus *bus,uint32_t addr,void *buf,size_t len);void (*memwrite)(QPCIBus *bus,uint32_t addr,const void *buf,size_t len);
@@ -82,10 +84,12 @@ void qpci_config_writel(QPCIDevice *dev, uint8_t offset, uint32_t value);uint8_t qpci_io_readb (QPCIDevice *dev,void *data);uint16_t qpci_io_readw (QPCIDevice *dev,void *data);uint32_t qpci_io_readl (QPCIDevice *dev,void *data); +uint64_t qpci_io_readq (QPCIDevice *dev,void *data);void qpci_io_writeb (QPCIDevice *dev,void *data,uint8_t value);void qpci_io_writew (QPCIDevice *dev,void *data,uint16_t value);void qpci_io_writel (QPCIDevice *dev,void *data,uint32_t value); +void qpci_io_writeq (QPCIDevice *dev,void *data,uint64_t value);void qpci_memread (QPCIDevice *bus,void *data,void *buf,size_t len);void qpci_memwrite (QPCIDevice *bus,void *data,const void *buf,size_t len);
tests/libqos/virtio-pci.c +4 -12
@@ -106,22 +106,14 @@ static uint32_t qvirtio_pci_config_readl(QVirtioDevice *d, uint64_t off)static uint64_t qvirtio_pci_config_readq (QVirtioDevice *d,uint64_t off) {QVirtioPCIDevice *dev = (QVirtioPCIDevice *)d; -int i; -uint64_t u64 =0 ; +uint64_t val; + val =qpci_io_readq (dev->pdev,CONFIG_BASE (dev) + off);if (qvirtio_is_big_endian (d)) { -for (i =0 ; i <8 ; ++i) { - u64 |= (uint64_t )qpci_io_readb (dev->pdev,CONFIG_BASE (dev) - + off + i) << (7 - i) *8 ; - } - }else { -for (i =0 ; i <8 ; ++i) { - u64 |= (uint64_t )qpci_io_readb (dev->pdev,CONFIG_BASE (dev) - + off + i) << i *8 ; - } + val =bswap64 (val); } -return u64; +return val; }static uint32_t qvirtio_pci_get_features (QVirtioDevice *d)
Signature · 1 line
2.7.4