add PCI support for the s390 platform
cover add PCI support for the s390 platform
This set of patches implemets PCI support for the s390 platform. Now it is possible to run virtio-net-pci and potentially all virtual pci devices conforming to s390 platform constrains.
V1 added lot of feedback from Alex Graf
fixed tons of endian issues
Please review and consider for integration into 2.3
Thanks,
Frank
Frank Blaschka (3):
s390: Add PCI bus support
s390: implement pci instructions
kvm: extend kvm_irqchip_add_msi_route to work on s390
default-configs/s390x-softmmu.mak | 1 + hw/s390x/Makefile.objs | 1 + hw/s390x/css.c | 5 + hw/s390x/css.h | 1 + hw/s390x/s390-pci-bus.c | 554 +++++++++++++++++++++++++++++ hw/s390x/s390-pci-bus.h | 217 ++++++++++++ hw/s390x/s390-pci-inst.c | 711 ++++++++++++++++++++++++++++++++++++++ hw/s390x/s390-pci-inst.h | 287 +++++++++++++++ hw/s390x/s390-virtio-ccw.c | 7 + hw/s390x/sclp.c | 10 +- include/hw/s390x/sclp.h | 8 + include/sysemu/kvm.h | 4 + kvm-all.c | 7 + target-arm/kvm.c | 6 + target-i386/kvm.c | 6 + target-mips/kvm.c | 6 + target-ppc/kvm.c | 6 + target-s390x/ioinst.c | 52 +++ target-s390x/ioinst.h | 1 + target-s390x/kvm.c | 174 ++++++++++ 20 files changed, 2063 insertions(+), 1 deletion(-) create mode 100644 hw/s390x/s390-pci-bus.c create mode 100644 hw/s390x/s390-pci-bus.h create mode 100644 hw/s390x/s390-pci-inst.c create mode 100644 hw/s390x/s390-pci-inst.h
Signature · 1 line
1.8.5.5
PATCH 1/3 s390: Add PCI bus support
From: Frank Blaschka <[email protected]>
This patch implements a pci bus for s390x together with infrastructure to generate and handle hotplug events, to configure/unconfigure via sclp instruction, to do iommu translations and provide s390 support for MSI/MSI-X notification processing.
--- default-configs/s390x-softmmu.mak | 1 + hw/s390x/Makefile.objs | 1 + hw/s390x/css.c | 5 + hw/s390x/css.h | 1 + hw/s390x/s390-pci-bus.c | 554 ++++++++++++++++++++++++++++++++++++++ hw/s390x/s390-pci-bus.h | 217 +++++++++++++++ hw/s390x/s390-virtio-ccw.c | 7 + hw/s390x/sclp.c | 10 +- include/hw/s390x/sclp.h | 8 + target-s390x/ioinst.c | 52 ++++ target-s390x/ioinst.h | 1 + 11 files changed, 856 insertions(+), 1 deletion(-) create mode 100644 hw/s390x/s390-pci-bus.c create mode 100644 hw/s390x/s390-pci-bus.h
default-configs/s390x-softmmu.mak +1 -0
@@ -1,3 +1,4 @@ +include pci.mak CONFIG_VIRTIO=y CONFIG_SCLPCONSOLE=y CONFIG_S390_FLIC=y
hw/s390x/Makefile.objs +1 -0
@@ -8,3 +8,4 @@ obj-y += ipl.o obj-y += css.o obj-y += s390-virtio-ccw.o obj-y += virtio-ccw.o +obj-y += s390-pci-bus.o
hw/s390x/css.c +5 -0
@@ -1299,6 +1299,11 @@ void css_generate_chp_crws(uint8_t cssid, uint8_t chpid)/* TODO */ } +void css_generate_css_crws (uint8_t cssid) +{ +css_queue_crw (CRW_RSC_CSS ,0 ,0 ,0 ); +} +int css_enable_mcsse (void ) {trace_css_enable_facility ("mcsse" );
hw/s390x/css.h +1 -0
@@ -101,6 +101,7 @@ void css_queue_crw(uint8_t rsc, uint8_t erc, int chain, uint16_t rsid);void css_generate_sch_crws (uint8_t cssid,uint8_t ssid,uint16_t schid,int hotplugged,int add);void css_generate_chp_crws (uint8_t cssid,uint8_t chpid); +void css_generate_css_crws (uint8_t cssid);void css_adapter_interrupt (uint8_t isc);#define CSS_IO_ADAPTER_VIRTIO 1
hw/s390x/s390-pci-bus.c new file +554 -0
554 lines not on this page · raw message
hw/s390x/s390-pci-bus.h new file +217 -0
217 lines not on this page · raw message
hw/s390x/s390-virtio-ccw.c +7 -0
@@ -18,6 +18,7 @@#include "css.h" #include "virtio-ccw.h" #include "qemu/config-file.h" +#include "s390-pci-bus.h" #define TYPE_S390_CCW_MACHINE "s390-ccw-machine"
@@ -91,6 +92,7 @@ static void ccw_init(MachineState *machine)uint8_t *storage_keys;int ret;VirtualCssBus *css_bus; +DeviceState *dev;QemuOpts *opts =qemu_opts_find (qemu_find_opts ("memory" ),NULL );ram_addr_t pad_size =0 ;ram_addr_t maxmem =qemu_opt_get_size (opts,"maxmem" , my_ram_size);
@@ -127,6 +129,11 @@ static void ccw_init(MachineState *machine) machine->initrd_filename, "s390-ccw.img");s390_flic_init (); + dev =qdev_create (NULL ,TYPE_S390_PCI_HOST_BRIDGE ); +object_property_add_child (qdev_get_machine (),TYPE_S390_PCI_HOST_BRIDGE , +OBJECT (dev),NULL ); +qdev_init_nofail (dev); +/* register hypercalls */ virtio_ccw_register_hcalls ();
hw/s390x/sclp.c +9 -1
@@ -20,6 +20,7 @@#include "qemu/config-file.h" #include "hw/s390x/sclp.h" #include "hw/s390x/event-facility.h" +#include "hw/s390x/s390-pci-bus.h" static inline SCLPEventFacility *get_event_facility (void ) {
@@ -62,7 +63,8 @@ static void read_SCP_info(SCCB *sccb) read_info->entries[i].type =0 ; } - read_info->facilities =cpu_to_be64 (SCLP_HAS_CPU_INFO ); + read_info->facilities =cpu_to_be64 (SCLP_HAS_CPU_INFO | +SCLP_HAS_PCI_RECONFIG );/* * The storage increment size is a multiple of 1M and is a power of 2.
@@ -350,6 +352,12 @@ static void sclp_execute(SCCB *sccb, uint32_t code)case SCLP_UNASSIGN_STORAGE :unassign_storage (sccb);break ; +case SCLP_CMDW_CONFIGURE_PCI : +s390_pci_sclp_configure (1 , sccb); +break ; +case SCLP_CMDW_DECONFIGURE_PCI : +s390_pci_sclp_configure (0 , sccb); +break ;default : efc->command_handler (ef, sccb, code);break ;
include/hw/s390x/sclp.h +8 -0
@@ -43,14 +43,22 @@#define SCLP_CMDW_CONFIGURE_CPU 0x00110001#define SCLP_CMDW_DECONFIGURE_CPU 0x00100001 +/* SCLP PCI codes */ +#define SCLP_HAS_PCI_RECONFIG 0x0000000040000000ULL +#define SCLP_CMDW_CONFIGURE_PCI 0x001a0001 +#define SCLP_CMDW_DECONFIGURE_PCI 0x001b0001 +#define SCLP_RECONFIG_PCI_ATPYE 2 +/* SCLP response codes */ #define SCLP_RC_NORMAL_READ_COMPLETION 0x0010#define SCLP_RC_NORMAL_COMPLETION 0x0020#define SCLP_RC_SCCB_BOUNDARY_VIOLATION 0x0100 +#define SCLP_RC_NO_ACTION_REQUIRED 0x0120#define SCLP_RC_INVALID_SCLP_COMMAND 0x01f0#define SCLP_RC_CONTAINED_EQUIPMENT_CHECK 0x0340#define SCLP_RC_INSUFFICIENT_SCCB_LENGTH 0x0300#define SCLP_RC_STANDBY_READ_COMPLETION 0x0410 +#define SCLP_RC_ADAPTER_ID_NOT_RECOGNIZED 0x09f0#define SCLP_RC_INVALID_FUNCTION 0x40f0#define SCLP_RC_NO_EVENT_BUFFERS_STORED 0x60f0#define SCLP_RC_INVALID_SELECTION_MASK 0x70f0
target-s390x/ioinst.c +52 -0
76 lines not on this page · raw message
target-s390x/ioinst.h +1 -0
@@ -204,6 +204,7 @@ typedef struct CRW {#define CRW_RSC_SUBCH 0x3#define CRW_RSC_CHP 0x4 +#define CRW_RSC_CSS 0xb/* I/O interruption code */ typedef struct IOIntCode {
Signature · 1 line
1.8.5.5
PATCH 2/3 s390: implement pci instructions
In reply to Frank BlaschkaFrom: Frank Blaschka <[email protected]>
This patch implements the s390 pci instructions in qemu. It allows to access and drive pci devices attached to the s390 pci bus. Because of platform constrains devices using IO BARs are not supported. Also a device has to support MSI/MSI-X to run on s390.
--- hw/s390x/Makefile.objs | 2 +- hw/s390x/s390-pci-inst.c | 711 +++++++++++++++++++++++++++++++++++++++++++++++ hw/s390x/s390-pci-inst.h | 287 +++++++++++++++++++ target-s390x/kvm.c | 148 ++++++++++ 4 files changed, 1147 insertions(+), 1 deletion(-) create mode 100644 hw/s390x/s390-pci-inst.c create mode 100644 hw/s390x/s390-pci-inst.h
hw/s390x/Makefile.objs +1 -1
@@ -8,4 +8,4 @@ obj-y += ipl.o obj-y += css.o obj-y += s390-virtio-ccw.o obj-y += virtio-ccw.o -obj-y += s390-pci-bus.o +obj-y += s390-pci-bus.o s390-pci-inst.o
hw/s390x/s390-pci-inst.c new file +711 -0
711 lines not on this page · raw message
hw/s390x/s390-pci-inst.h new file +287 -0
287 lines not on this page · raw message
target-s390x/kvm.c +148 -0
197 lines not on this page · raw message
Signature · 1 line
1.8.5.5
PATCH 3/3 kvm: extend kvm_irqchip_add_msi_route to work on s390
In reply to Frank BlaschkaFrom: Frank Blaschka <[email protected]>
on s390 MSI-X irqs are presented as thin or adapter interrupts for this we have to reorganize the routing entry to contain valid information for the adapter interrupt code on s390. To minimize impact on existing code we introduce an architecture function to fixup the routing entry.
--- include/sysemu/kvm.h | 4 ++++ kvm-all.c | 7 +++++++ target-arm/kvm.c | 6 ++++++ target-i386/kvm.c | 6 ++++++ target-mips/kvm.c | 6 ++++++ target-ppc/kvm.c | 6 ++++++ target-s390x/kvm.c | 26 ++++++++++++++++++++++++++ 7 files changed, 61 insertions(+)
include/sysemu/kvm.h +4 -0
@@ -148,6 +148,7 @@ extern bool kvm_readonly_mem_allowed;struct kvm_run ;struct kvm_lapic_state ; +struct kvm_irq_routing_entry ; typedef struct KVMCapabilityInfo { const char *name;
@@ -259,6 +260,9 @@ int kvm_arch_on_sigbus(int code, void *addr);void kvm_arch_init_irq_routing (KVMState *s); +int kvm_arch_fixup_msi_route (struct kvm_irq_routing_entry *route, +uint64_t address,uint32_t data); +int kvm_set_irq (KVMState *s,int irq,int level);int kvm_irqchip_send_msi (KVMState *s,MSIMessage msg);
kvm-all.c +7 -0
@@ -1208,6 +1208,10 @@ int kvm_irqchip_add_msi_route(KVMState *s, MSIMessage msg) kroute.u.msi.address_lo = (uint32_t )msg.address; kroute.u.msi.address_hi = msg.address >>32 ; kroute.u.msi.data =le32_to_cpu (msg.data); +if (kvm_arch_fixup_msi_route (&kroute, msg.address, msg.data)) { +kvm_irqchip_release_virq (s, virq); +return -EINVAL ; + }kvm_add_routing_entry (s, &kroute);kvm_irqchip_commit_routes (s);
@@ -1233,6 +1237,9 @@ int kvm_irqchip_update_msi_route(KVMState *s, int virq, MSIMessage msg) kroute.u.msi.address_lo = (uint32_t )msg.address; kroute.u.msi.address_hi = msg.address >>32 ; kroute.u.msi.data =le32_to_cpu (msg.data); +if (kvm_arch_fixup_msi_route (&kroute, msg.address, msg.data)) { +return -EINVAL ; + }return kvm_update_routing_entry (s, &kroute); }
target-arm/kvm.c +6 -0
@@ -441,3 +441,9 @@ int kvm_arch_irqchip_create(KVMState *s)return 0 ; } + +int kvm_arch_fixup_msi_route (struct kvm_irq_routing_entry *route, +uint64_t address,uint32_t data) +{ +return 0 ; +}
target-i386/kvm.c +6 -0
@@ -2707,3 +2707,9 @@ int kvm_device_msix_deassign(KVMState *s, uint32_t dev_id)return kvm_deassign_irq_internal (s, dev_id,KVM_DEV_IRQ_GUEST_MSIX |KVM_DEV_IRQ_HOST_MSIX ); } + +int kvm_arch_fixup_msi_route (struct kvm_irq_routing_entry *route, +uint64_t address,uint32_t data) +{ +return 0 ; +}
target-mips/kvm.c +6 -0
@@ -688,3 +688,9 @@ int kvm_arch_get_registers(CPUState *cs)return ret; } + +int kvm_arch_fixup_msi_route (struct kvm_irq_routing_entry *route, +uint64_t address,uint32_t data) +{ +return 0 ; +}
target-ppc/kvm.c +6 -0
@@ -2388,3 +2388,9 @@ out_close: error_out:return ; } + +int kvm_arch_fixup_msi_route (struct kvm_irq_routing_entry *route, +uint64_t address,uint32_t data) +{ +return 0 ; +}
target-s390x/kvm.c +26 -0
@@ -41,6 +41,7 @@#include "trace.h" #include "qapi-event.h" #include "hw/s390x/s390-pci-inst.h" +#include "hw/s390x/s390-pci-bus.h" /* #define DEBUG_KVM */
@@ -1510,3 +1511,28 @@ int kvm_s390_set_cpu_state(S390CPU *cpu, uint8_t cpu_state)return ret; } + +int kvm_arch_fixup_msi_route (struct kvm_irq_routing_entry *route, +uint64_t address,uint32_t data) +{ +S390PCIBusDevice *pbdev; +uint32_t fid = data >>ZPCI_MSI_VEC_BITS ; +uint32_t vec = data &ZPCI_MSI_VEC_MASK ; + + pbdev =s390_pci_find_dev_by_fid (fid); +if (!pbdev) { +DPRINTF ("add_msi_route no dev\n" ); +return -ENODEV ; + } + + pbdev->routes.adapter.ind_offset = vec; + + route->type =KVM_IRQ_ROUTING_S390_ADAPTER ; + route->flags =0 ; + route->u.adapter.summary_addr = pbdev->routes.adapter.summary_addr; + route->u.adapter.ind_addr = pbdev->routes.adapter.ind_addr; + route->u.adapter.summary_offset = pbdev->routes.adapter.summary_offset; + route->u.adapter.ind_offset = pbdev->routes.adapter.ind_offset; + route->u.adapter.adapter_id = pbdev->routes.adapter.adapter_id; +return 0 ; +}
Signature · 1 line
1.8.5.5
Quoted 8 lines · On Wed, 26 Nov 2014 10:05:10 +0100 Frank Blaschka…
This set of patches implemets PCI support for the s390 platform. Now it is possible to run virtio-net-pci and potentially all virtual pci devices conforming to s390 platform constrains.
V1 added lot of feedback from Alex Graf
fixed tons of endian issuesPlease review and consider for integration into 2.3
Looks good; added to my s390-next queue.
Alex: Any chance of some r-bs from you?
Cornelia Huck
Acked-by Christian BorntraegerQuoted 7 lines · On Wed, 3 Dec 2014 13:52:36 +0100 Cornelia Huck <[email protected]>…
Quoted 4 lines · On Wed, 26 Nov 2014 10:05:10 +0100 Frank Blaschka…
This set of patches implemets PCI support for the s390 platform. Now it is possible to run virtio-net-pci and potentially all virtual pci devices conforming to s390 platform constrains.
Quoted 8 lines
Quoted 4 lines
V1 added lot of feedback from Alex Graf
fixed tons of endian issuesPlease review and consider for integration into 2.3
Looks good; added to my s390-next queue.
Alex: Any chance of some r-bs from you?
We'll also need a MAINTAINERS update, added the patch below to s390-next.
Alex: I'd still be happy about acks :)
commit 370f303fc6aebd570a341d8bc9fe14bab9f299cd
Author: Cornelia Huck <[email protected]> Date: Wed Dec 10 12:41:25 2014 +0100
s390x: update MAINTAINERS
Make sure the new pci support is sorted to the right maintainers.
MAINTAINERS +2 -0
@@ -534,6 +534,7 @@ S390 Virtio M: Alexander Graf <[email protected]> S: Maintained F: hw/s390x/s390-*.c +X: hw/s390x/*pci*.[hc] S390 Virtio-ccw M: Cornelia Huck <[email protected]>
@@ -544,6 +545,7 @@ F: hw/s390x/s390-virtio-ccw.c F: hw/s390x/css.[hc] F: hw/s390x/sclp*.[hc] F: hw/s390x/ipl*.[hc] +F: hw/s390x/*pci*.[hc] F: include/hw/s390x/ F: pc-bios/s390-ccw/ T: git git://github.com/cohuck/qemu virtio-ccw-upstr