zpci detangling
v5 cover zpci detangling
Hopefully should be close now...
v4->v5:
- dropped "s390x/kvm: msi route fixup for non-pci"
- reworked "s390x/sclp: properly guard pci-specific functions": the configure/deconfigure stuff is about I/O adapters, we were missing checks, and I used an incorrect return code -- please review
- collected more r-bs
Cornelia Huck (9):
9pfs: fix dependencies
kvm: remove hard dependency on pci s390x/pci: add stubs
s390x: chsc nt2 events are pci-only s390x/pci: do not advertise pci on non-pci builds s390x/ccw: create s390 phb conditionally s390x/sclp: properly guard pci-specific functions s390x/pci: fence off instructions for non-pci
s390x: refine pci dependencies
accel/kvm/kvm-all.c | 6 ++-- default-configs/s390x-softmmu.mak | 2 +- fsdev/Makefile.objs | 9 ++--- hw/9pfs/Makefile.objs | 2 +- hw/Makefile.objs | 2 +- hw/pci/pci-stub.c | 16 ++++++++- hw/pci/pci.c | 2 ++ hw/s390x/Makefile.objs | 3 +- hw/s390x/s390-pci-bus.c | 18 +++------- hw/s390x/s390-pci-bus.h | 12 ++----- hw/s390x/s390-pci-stub.c | 76 +++++++++++++++++++++++++++++++++++++++ hw/s390x/s390-virtio-ccw.c | 14 ++++---- hw/s390x/sclp.c | 39 +++++++++++++++++--- include/hw/pci/pci.h | 2 ++ include/hw/s390x/sclp.h | 17 ++++++--- target/s390x/ioinst.c | 16 +++++++++ target/s390x/kvm.c | 58 ++++++++++++++++++++++-------- 17 files changed, 227 insertions(+), 67 deletions(-) create mode 100644 hw/s390x/s390-pci-stub.c
Signature · 1 line
2.13.5
PATCH v5 1/9 9pfs: fix dependencies
Nothing in fsdev/ or hw/9pfs/ depends on pci; it should rather depend on CONFIG_VIRTFS and CONFIG_VIRTIO/CONFIG_XEN only.
--- fsdev/Makefile.objs | 9 +++------ hw/9pfs/Makefile.objs | 2 +- hw/Makefile.objs | 2 +- 3 files changed, 5 insertions(+), 8 deletions(-)
fsdev/Makefile.objs +3 -6
@@ -1,10 +1,7 @@ -ifeq ($(CONFIG_VIRTIO)$(CONFIG_VIRTFS)$(CONFIG_PCI),yyy) # Lots of the fsdev/9pcode is pulled in by vl.c via qemu_fsdev_add. -# only pull in the actual virtio-9p device if we also enabled virtio. -common-obj-y = qemu-fsdev.o 9p-marshal.o 9p-iov-marshal.o -else -common-obj-y = qemu-fsdev-dummy.o -endif +# only pull in the actual 9p backend if we also enabled virtio or xen. +common-obj-$(call land,$(CONFIG_VIRTFS),$(call lor,$(CONFIG_VIRTIO),$(CONFIG_XEN))) = qemu-fsdev.o 9p-marshal.o 9p-iov-marshal.o +common-obj-$(call lnot,$(call land,$(CONFIG_VIRTFS),$(call lor,$(CONFIG_VIRTIO),$(CONFIG_XEN)))) = qemu-fsdev-dummy.o common-obj-y += qemu-fsdev-opts.o qemu-fsdev-throttle.o # Toplevel always builds this; targets without virtio will put it in
hw/9pfs/Makefile.objs +1 -1
@@ -7,4 +7,4 @@ common-obj-$(CONFIG_OPEN_BY_HANDLE) += 9p-handle.o common-obj-y += 9p-proxy.o common-obj-$(CONFIG_XEN) += xen-9p-backend.o -obj-y += virtio-9p-device.o +obj-$(CONFIG_VIRTIO) += virtio-9p-device.o
hw/Makefile.objs +1 -1
@@ -1,4 +1,4 @@ -devices-dirs-$(call land, $(CONFIG_VIRTIO),$(call land,$(CONFIG_VIRTFS),$(CONFIG_PCI))) += 9pfs/ +devices-dirs-$(call land,$(CONFIG_VIRTFS),$(call lor,$(CONFIG_VIRTIO),$(CONFIG_XEN))) += 9pfs/ devices-dirs-$(CONFIG_SOFTMMU) += acpi/ devices-dirs-$(CONFIG_SOFTMMU) += adc/ devices-dirs-$(CONFIG_SOFTMMU) += audio/
Signature · 1 line
2.13.5
PATCH v5 2/9 kvm: remove hard dependency on pci
In reply to Cornelia HuckThe msi routing code in kvm calls some pci functions: provide some stubs to enable builds without pci.
Also, to make this more obvious, guard them via a pci_available boolean (which also can be reused in other places).
--- accel/kvm/kvm-all.c | 6 +++--- hw/pci/pci-stub.c | 16 +++++++++++++++- hw/pci/pci.c | 2 ++ include/hw/pci/pci.h | 2 ++ 4 files changed, 22 insertions(+), 4 deletions(-)
accel/kvm/kvm-all.c +3 -3
@@ -1248,7 +1248,7 @@ int kvm_irqchip_add_msi_route(KVMState *s, int vector, PCIDevice *dev)int virq;MSIMessage msg = {0 ,0 }; -if (dev) { +if (pci_available && dev) { msg =pci_get_msi_message (dev, vector); }
@@ -1271,7 +1271,7 @@ int kvm_irqchip_add_msi_route(KVMState *s, int vector, PCIDevice *dev) 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_msi_devid_required ()) { +if (pci_available &&kvm_msi_devid_required ()) { kroute.flags =KVM_MSI_VALID_DEVID ; kroute.u.msi.devid =pci_requester_id (dev); }
@@ -1309,7 +1309,7 @@ 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_msi_devid_required ()) { +if (pci_available &&kvm_msi_devid_required ()) { kroute.flags =KVM_MSI_VALID_DEVID ; kroute.u.msi.devid =pci_requester_id (dev); }
hw/pci/pci-stub.c +15 -1
@@ -23,10 +23,11 @@#include "monitor/monitor.h" #include "qapi/qmp/qerror.h" #include "hw/pci/pci.h" -#include "qmp-commands.h" #include "hw/pci/msi.h" +#include "qmp-commands.h" bool msi_nonbroken; +bool pci_available;PciInfoList *qmp_query_pci (Error **errp) {
@@ -38,3 +39,16 @@ void hmp_pcie_aer_inject_error(Monitor *mon, const QDict *qdict) {monitor_printf (mon,"PCI devices not supported\n" ); } + +/* kvm-all wants this */ +MSIMessage pci_get_msi_message (PCIDevice *dev,int vector) +{ +g_assert (false); +return (MSIMessage ){}; +} + +uint16_t pci_requester_id (PCIDevice *dev) +{ +g_assert (false); +return 0 ; +}
hw/pci/pci.c +2 -0
@@ -49,6 +49,8 @@# define PCI_DPRINTF (format, ...) do { } while (0)#endif +bool pci_available = true; +static void pcibus_dev_print (Monitor *mon,DeviceState *dev,int indent);static char *pcibus_get_dev_path (DeviceState *dev);static char *pcibus_get_fw_dev_path (DeviceState *dev);
include/hw/pci/pci.h +2 -0
@@ -10,6 +10,8 @@#include "hw/pci/pcie.h" +extern bool pci_available; +/* PCI bus */ #define PCI_DEVFN (slot, func) ((((slot) & 0x1f) << 3) | ((func) & 0x07))
Signature · 1 line
2.13.5
PATCH v5 3/9 s390x/pci: add stubs
In reply to Cornelia HuckSome non-pci code calls into zpci code. Provide some stubs for builds without pci.
--- hw/s390x/Makefile.objs | 3 +- hw/s390x/s390-pci-stub.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 hw/s390x/s390-pci-stub.c
hw/s390x/Makefile.objs +2 -1
@@ -11,7 +11,8 @@ obj-y += 3270-ccw.o obj-y += virtio-ccw.o obj-y += css-bridge.o obj-y += ccw-device.o -obj-y += s390-pci-bus.o s390-pci-inst.o +obj-$(CONFIG_PCI) += s390-pci-bus.o s390-pci-inst.o +obj-$(call lnot,$(CONFIG_PCI)) += s390-pci-stub.o obj-y += s390-skeys.o obj-y += s390-stattrib.o obj-$(CONFIG_KVM) += s390-skeys-kvm.o
hw/s390x/s390-pci-stub.c new file +74 -0
74 lines not on this page · raw message
Signature · 1 line
2.13.5
PATCH v5 4/9 s390x: chsc nt2 events are pci-only
In reply to Cornelia HuckThe nt2 event class is pci-only - don't look for events if pci is not in the active cpu model.
--- hw/s390x/s390-pci-bus.c | 4 ++-- hw/s390x/s390-pci-bus.h | 4 ++-- hw/s390x/s390-pci-stub.c | 4 ++-- target/s390x/ioinst.c | 16 ++++++++++++++++ 4 files changed, 22 insertions(+), 6 deletions(-)
hw/s390x/s390-pci-bus.c +2 -2
@@ -47,7 +47,7 @@ S390pciState *s390_get_phb(void)return phb; } -int chsc_sei_nt2_get_event (void *res) +int pci_chsc_sei_nt2_get_event (void *res) {ChscSeiNt2Res *nt2_res = (ChscSeiNt2Res *)res;PciCcdfAvail *accdf;
@@ -87,7 +87,7 @@ int chsc_sei_nt2_get_event(void *res)return rc; } -int chsc_sei_nt2_have_event (void ) +int pci_chsc_sei_nt2_have_event (void ) {S390pciState *s =s390_get_phb ();
hw/s390x/s390-pci-bus.h +2 -2
@@ -319,8 +319,8 @@ typedef struct S390pciState { } S390pciState;S390pciState *s390_get_phb (void ); -int chsc_sei_nt2_get_event (void *res); -int chsc_sei_nt2_have_event (void ); +int pci_chsc_sei_nt2_get_event (void *res); +int pci_chsc_sei_nt2_have_event (void );void s390_pci_sclp_configure (SCCB *sccb);void s390_pci_sclp_deconfigure (SCCB *sccb);void s390_pci_iommu_enable (S390PCIIOMMU *iommu);
hw/s390x/s390-pci-stub.c +2 -2
@@ -7,12 +7,12 @@#include "s390-pci-bus.h" /* target/s390x/ioinst.c */ -int chsc_sei_nt2_get_event (void *res) +int pci_chsc_sei_nt2_get_event (void *res) {return 1 ; } -int chsc_sei_nt2_have_event (void ) +int pci_chsc_sei_nt2_have_event (void ) {return 0 ; }
target/s390x/ioinst.c +16 -0
@@ -599,6 +599,22 @@ static int chsc_sei_nt0_have_event(void)return 0 ; } +static int chsc_sei_nt2_get_event (void *res) +{ +if (s390_has_feat (S390_FEAT_ZPCI )) { +return pci_chsc_sei_nt2_get_event (res); + } +return 1 ; +} + +static int chsc_sei_nt2_have_event (void ) +{ +if (s390_has_feat (S390_FEAT_ZPCI )) { +return pci_chsc_sei_nt2_have_event (); + } +return 0 ; +} +#define CHSC_SEI_NT0 (1ULL << 63)#define CHSC_SEI_NT2 (1ULL << 61)static void ioinst_handle_chsc_sei (ChscReq *req,ChscResp *res)
Signature · 1 line
2.13.5
PATCH v5 5/9 s390x/pci: do not advertise pci on non-pci builds
In reply to Cornelia HuckOnly set the zpci feature bit on builds that actually support pci.
--- target/s390x/kvm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
target/s390x/kvm.c +3 -1
@@ -2662,7 +2662,9 @@ void kvm_s390_get_host_cpu_model(S390CPUModel *model, Error **errp) }/* We emulate a zPCI bus and AEN, therefore we don't need HW support */ -set_bit (S390_FEAT_ZPCI , model->features); +if (pci_available) { +set_bit (S390_FEAT_ZPCI , model->features); + }set_bit (S390_FEAT_ADAPTER_EVENT_NOTIFICATION , model->features);if (s390_known_cpu_type (cpu_type)) {
Signature · 1 line
2.13.5
PATCH v5 6/9 s390x/ccw: create s390 phb conditionally
In reply to Cornelia HuckDon't create the s390 pci host bridge if we do not provide the zpci facility.
--- hw/s390x/s390-virtio-ccw.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
hw/s390x/s390-virtio-ccw.c +8 -6
@@ -118,12 +118,11 @@ static void ccw_init(MachineState *machine) {int ret;VirtualCssBus *css_bus; -DeviceState *dev;s390_sclp_init ();s390_memory_init (machine->ram_size); -/* init CPUs */ +/* init CPUs (incl. CPU model) early so s390_has_feature() works */ s390_init_cpus (machine);s390_flic_init ();
@@ -134,10 +133,13 @@ static void ccw_init(MachineState *machine) machine->initrd_filename,"s390-ccw.img" , "s390-netboot.img", true); - 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); +if (s390_has_feat (S390_FEAT_ZPCI )) { +DeviceState *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 ();
Signature · 1 line
2.13.5
PATCH v5 7/9 s390x/sclp: properly guard pci-specific functions
In reply to Cornelia HuckIf we do not provide zpci, pci reconfiguration via sclp is not available either. I/O adapter configuration, however, should always be present.
Rename the values that refer to I/O adapter configuration (instead of only pci) to make things clearer.
Move length checking of the sccb for I/O adapter configuration into the common sclp code (out of the pci code). This also fixes an issue that the pci code would refer to a field in the sccb before checking whether it was actually long enough.
Check for the adapter type in the sccb and return unrecognized adapter type if the guest tries to issue I/O adapter configure/deconfigure for a type other than pci or for pci if the zpci facility is not provided.
--- hw/s390x/s390-pci-bus.c | 14 ++------------ hw/s390x/s390-pci-bus.h | 8 -------- hw/s390x/s390-pci-stub.c | 2 ++ hw/s390x/sclp.c | 39 ++++++++++++++++++++++++++++++++++----- include/hw/s390x/sclp.h | 17 +++++++++++++---- 5 files changed, 51 insertions(+), 29 deletions(-)
hw/s390x/s390-pci-bus.c +2 -12
@@ -122,16 +122,11 @@ S390PCIBusDevice *s390_pci_find_dev_by_fid(S390pciState *s, uint32_t fid)void s390_pci_sclp_configure (SCCB *sccb) { -PciCfgSccb *psccb = (PciCfgSccb *)sccb; +IoaCfgSccb *psccb = (IoaCfgSccb *)sccb;S390PCIBusDevice *pbdev =s390_pci_find_dev_by_fid (s390_get_phb (),be32_to_cpu (psccb->aid));uint16_t rc; -if (be16_to_cpu (sccb->h.length) <16 ) { - rc =SCLP_RC_INSUFFICIENT_SCCB_LENGTH ; - goto out; - } -if (!pbdev) {DPRINTF ("sclp config no dev found\n" ); rc =SCLP_RC_ADAPTER_ID_NOT_RECOGNIZED ;
@@ -155,16 +150,11 @@ out:void s390_pci_sclp_deconfigure (SCCB *sccb) { -PciCfgSccb *psccb = (PciCfgSccb *)sccb; +IoaCfgSccb *psccb = (IoaCfgSccb *)sccb;S390PCIBusDevice *pbdev =s390_pci_find_dev_by_fid (s390_get_phb (),be32_to_cpu (psccb->aid));uint16_t rc; -if (be16_to_cpu (sccb->h.length) <16 ) { - rc =SCLP_RC_INSUFFICIENT_SCCB_LENGTH ; - goto out; - } -if (!pbdev) {DPRINTF ("sclp deconfig no dev found\n" ); rc =SCLP_RC_ADAPTER_ID_NOT_RECOGNIZED ;
hw/s390x/s390-pci-bus.h +0 -8
@@ -244,14 +244,6 @@ typedef struct ChscSeiNt2Res {uint8_t ccdf[4016 ]; }QEMU_PACKED ChscSeiNt2Res; -typedef struct PciCfgSccb { -SCCBHeader header; -uint8_t atype; -uint8_t reserved1; -uint16_t reserved2; -uint32_t aid; -} QEMU_PACKED PciCfgSccb; - typedef struct S390MsixInfo { bool available; uint8_t table_bar;
hw/s390x/s390-pci-stub.c +2 -0
@@ -20,10 +20,12 @@ int pci_chsc_sei_nt2_have_event(void)/* hw/s390x/sclp.c */ void s390_pci_sclp_configure (SCCB *sccb) { + sccb->h.response_code =cpu_to_be16 (SCLP_RC_ADAPTER_TYPE_NOT_RECOGNIZED ); }void s390_pci_sclp_deconfigure (SCCB *sccb) { + sccb->h.response_code =cpu_to_be16 (SCLP_RC_ADAPTER_TYPE_NOT_RECOGNIZED ); }/* target/s390x/kvm.c */
hw/s390x/sclp.c +34 -5
@@ -80,7 +80,7 @@ static void read_SCP_info(SCLPDevice *sclp, SCCB *sccb)prepare_cpu_entries (sclp, read_info->entries, cpu_count); read_info->facilities =cpu_to_be64 (SCLP_HAS_CPU_INFO | -SCLP_HAS_PCI_RECONFIG ); +SCLP_HAS_IOA_RECONFIG );/* Memory Hotplug is only supported for the ccw machine type */ if (mhd) {
@@ -354,6 +354,35 @@ static void sclp_read_cpu_info(SCLPDevice *sclp, SCCB *sccb) sccb->h.response_code =cpu_to_be16 (SCLP_RC_NORMAL_READ_COMPLETION ); } +static void sclp_configure_io_adapter (SCLPDevice *sclp,SCCB *sccb, +bool configure) +{ +int rc; + +if (be16_to_cpu (sccb->h.length) <16 ) { + rc =SCLP_RC_INSUFFICIENT_SCCB_LENGTH ; + goto out_err; + } + +switch (((IoaCfgSccb *)sccb)->atype) { +case SCLP_RECONFIG_PCI_ATYPE : +if (s390_has_feat (S390_FEAT_ZPCI )) { +if (configure) { +s390_pci_sclp_configure (sccb); + }else { +s390_pci_sclp_deconfigure (sccb); + } +return ; + } +/* fallthrough */ +default : + rc =SCLP_RC_ADAPTER_TYPE_NOT_RECOGNIZED ; + } + + out_err: + sccb->h.response_code =cpu_to_be16 (rc); +} +static void sclp_execute (SCLPDevice *sclp,SCCB *sccb,uint32_t code) {SCLPDeviceClass *sclp_c =SCLP_GET_CLASS (sclp);
@@ -384,11 +413,11 @@ static void sclp_execute(SCLPDevice *sclp, SCCB *sccb, uint32_t code)case SCLP_UNASSIGN_STORAGE : sclp_c->unassign_storage (sclp, sccb);break ; -case SCLP_CMDW_CONFIGURE_PCI : -s390_pci_sclp_configure (sccb); +case SCLP_CMDW_CONFIGURE_IOA : +sclp_configure_io_adapter (sclp, sccb, true);break ; -case SCLP_CMDW_DECONFIGURE_PCI : -s390_pci_sclp_deconfigure (sccb); +case SCLP_CMDW_DECONFIGURE_IOA : +sclp_configure_io_adapter (sclp, sccb, false);break ;default : efc->command_handler (ef, sccb, code);
include/hw/s390x/sclp.h +13 -4
@@ -44,10 +44,10 @@#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 +#define SCLP_HAS_IOA_RECONFIG 0x0000000040000000ULL +#define SCLP_CMDW_CONFIGURE_IOA 0x001a0001 +#define SCLP_CMDW_DECONFIGURE_IOA 0x001b0001 +#define SCLP_RECONFIG_PCI_ATYPE 2/* SCLP response codes */ #define SCLP_RC_NORMAL_READ_COMPLETION 0x0010
@@ -59,6 +59,7 @@#define SCLP_RC_INSUFFICIENT_SCCB_LENGTH 0x0300#define SCLP_RC_STANDBY_READ_COMPLETION 0x0410#define SCLP_RC_ADAPTER_IN_RESERVED_STATE 0x05f0 +#define SCLP_RC_ADAPTER_TYPE_NOT_RECOGNIZED 0x06f0#define SCLP_RC_ADAPTER_ID_NOT_RECOGNIZED 0x09f0#define SCLP_RC_INVALID_FUNCTION 0x40f0#define SCLP_RC_NO_EVENT_BUFFERS_STORED 0x60f0
@@ -167,6 +168,14 @@ typedef struct AssignStorage {uint16_t rn; }QEMU_PACKED AssignStorage; +typedef struct IoaCfgSccb { +SCCBHeader header; +uint8_t atype; +uint8_t reserved1; +uint16_t reserved2; +uint32_t aid; +} QEMU_PACKED IoaCfgSccb; + typedef struct SCCB { SCCBHeader h; char data[SCCB_DATA_LEN];
Signature · 1 line
2.13.5
PATCH v5 8/9 s390x/pci: fence off instructions for non-pci
In reply to Cornelia HuckIf a guest running on a machine without zpci issues a pci instruction, throw them an exception.
--- target/s390x/kvm.c | 54 +++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 41 insertions(+), 13 deletions(-)
target/s390x/kvm.c +41 -13
@@ -1191,7 +1191,11 @@ static int kvm_clp_service_call(S390CPU *cpu, struct kvm_run *run) {uint8_t r2 = (run->s390_sieic.ipb &0x000f0000 ) >>16 ; -return clp_service_call (cpu, r2); +if (s390_has_feat (S390_FEAT_ZPCI )) { +return clp_service_call (cpu, r2); + }else { +return -1 ; + } }static int kvm_pcilg_service_call (S390CPU *cpu,struct kvm_run *run)
@@ -1199,7 +1203,11 @@ static int kvm_pcilg_service_call(S390CPU *cpu, struct kvm_run *run)uint8_t r1 = (run->s390_sieic.ipb &0x00f00000 ) >>20 ;uint8_t r2 = (run->s390_sieic.ipb &0x000f0000 ) >>16 ; -return pcilg_service_call (cpu, r1, r2); +if (s390_has_feat (S390_FEAT_ZPCI )) { +return pcilg_service_call (cpu, r1, r2); + }else { +return -1 ; + } }static int kvm_pcistg_service_call (S390CPU *cpu,struct kvm_run *run)
@@ -1207,7 +1215,11 @@ static int kvm_pcistg_service_call(S390CPU *cpu, struct kvm_run *run)uint8_t r1 = (run->s390_sieic.ipb &0x00f00000 ) >>20 ;uint8_t r2 = (run->s390_sieic.ipb &0x000f0000 ) >>16 ; -return pcistg_service_call (cpu, r1, r2); +if (s390_has_feat (S390_FEAT_ZPCI )) { +return pcistg_service_call (cpu, r1, r2); + }else { +return -1 ; + } }static int kvm_stpcifc_service_call (S390CPU *cpu,struct kvm_run *run)
@@ -1216,10 +1228,14 @@ static int kvm_stpcifc_service_call(S390CPU *cpu, struct kvm_run *run)uint64_t fiba;uint8_t ar; -cpu_synchronize_state (CPU (cpu)); - fiba =get_base_disp_rxy (cpu, run, &ar); +if (s390_has_feat (S390_FEAT_ZPCI )) { +cpu_synchronize_state (CPU (cpu)); + fiba =get_base_disp_rxy (cpu, run, &ar); -return stpcifc_service_call (cpu, r1, fiba, ar); +return stpcifc_service_call (cpu, r1, fiba, ar); + }else { +return -1 ; + } }static int kvm_sic_service_call (S390CPU *cpu,struct kvm_run *run)
@@ -1247,7 +1263,11 @@ static int kvm_rpcit_service_call(S390CPU *cpu, struct kvm_run *run)uint8_t r1 = (run->s390_sieic.ipb &0x00f00000 ) >>20 ;uint8_t r2 = (run->s390_sieic.ipb &0x000f0000 ) >>16 ; -return rpcit_service_call (cpu, r1, r2); +if (s390_has_feat (S390_FEAT_ZPCI )) { +return rpcit_service_call (cpu, r1, r2); + }else { +return -1 ; + } }static int kvm_pcistb_service_call (S390CPU *cpu,struct kvm_run *run)
@@ -1257,10 +1277,14 @@ static int kvm_pcistb_service_call(S390CPU *cpu, struct kvm_run *run)uint64_t gaddr;uint8_t ar; -cpu_synchronize_state (CPU (cpu)); - gaddr =get_base_disp_rsy (cpu, run, &ar); +if (s390_has_feat (S390_FEAT_ZPCI )) { +cpu_synchronize_state (CPU (cpu)); + gaddr =get_base_disp_rsy (cpu, run, &ar); -return pcistb_service_call (cpu, r1, r3, gaddr, ar); +return pcistb_service_call (cpu, r1, r3, gaddr, ar); + }else { +return -1 ; + } }static int kvm_mpcifc_service_call (S390CPU *cpu,struct kvm_run *run)
@@ -1269,10 +1293,14 @@ static int kvm_mpcifc_service_call(S390CPU *cpu, struct kvm_run *run)uint64_t fiba;uint8_t ar; -cpu_synchronize_state (CPU (cpu)); - fiba =get_base_disp_rxy (cpu, run, &ar); +if (s390_has_feat (S390_FEAT_ZPCI )) { +cpu_synchronize_state (CPU (cpu)); + fiba =get_base_disp_rxy (cpu, run, &ar); -return mpcifc_service_call (cpu, r1, fiba, ar); +return mpcifc_service_call (cpu, r1, fiba, ar); + }else { +return -1 ; + } }static int handle_b9 (S390CPU *cpu,struct kvm_run *run,uint8_t ipa1)
Signature · 1 line
2.13.5
PATCH v5 9/9 s390x: refine pci dependencies
In reply to Cornelia HuckVIRTIO_PCI should properly depend on CONFIG_PCI. With this change, we can switch off pci for s390x by removing 'CONFIG_PCI=y' from the default config.
--- default-configs/s390x-softmmu.mak | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
default-configs/s390x-softmmu.mak +1 -1
@@ -1,5 +1,5 @@ CONFIG_PCI=y -CONFIG_VIRTIO_PCI=y +CONFIG_VIRTIO_PCI=$(CONFIG_PCI) CONFIG_VHOST_USER_SCSI=$(and $(CONFIG_VHOST_USER),$(CONFIG_LINUX)) CONFIG_VIRTIO=y CONFIG_SCLPCONSOLE=y
Signature · 1 line
2.13.5
Re: [Qemu-devel] [PATCH v5 7/9] s390x/sclp: properly guard pci-specific functions
In reply to Cornelia HuckQuoted 198 lines · Cornelia Huck
If we do not provide zpci, pci reconfiguration via sclp is not available either. I/O adapter configuration, however, should always be present.
Rename the values that refer to I/O adapter configuration (instead of only pci) to make things clearer.
Move length checking of the sccb for I/O adapter configuration into the common sclp code (out of the pci code). This also fixes an issue that the pci code would refer to a field in the sccb before checking whether it was actually long enough.
Check for the adapter type in the sccb and return unrecognized adapter type if the guest tries to issue I/O adapter configure/deconfigure for a type other than pci or for pci if the zpci facility is not provided.
Signed-off-by Cornelia Huck <[email protected]>--- hw/s390x/s390-pci-bus.c | 14 ++------------ hw/s390x/s390-pci-bus.h | 8 -------- hw/s390x/s390-pci-stub.c | 2 ++ hw/s390x/sclp.c | 39 ++++++++++++++++++++++++++++++++++----- include/hw/s390x/sclp.h | 17 +++++++++++++---- 5 files changed, 51 insertions(+), 29 deletions(-)hw/s390x/s390-pci-bus.c +2
-12@@ -122,16 +122,11 @@ S390PCIBusDevice *s390_pci_find_dev_by_fid(S390pciState *s, uint32_t fid)void s390_pci_sclp_configure (SCCB *sccb) { -PciCfgSccb *psccb = (PciCfgSccb *)sccb; +IoaCfgSccb *psccb = (IoaCfgSccb *)sccb;S390PCIBusDevice *pbdev =s390_pci_find_dev_by_fid (s390_get_phb (),be32_to_cpu (psccb->aid));uint16_t rc; -if (be16_to_cpu (sccb->h.length) <16 ) { - rc =SCLP_RC_INSUFFICIENT_SCCB_LENGTH ; - goto out; - } -if (!pbdev) {DPRINTF ("sclp config no dev found\n" ); rc =SCLP_RC_ADAPTER_ID_NOT_RECOGNIZED ;@@ -155,16 +150,11 @@ out:void s390_pci_sclp_deconfigure (SCCB *sccb) { -PciCfgSccb *psccb = (PciCfgSccb *)sccb; +IoaCfgSccb *psccb = (IoaCfgSccb *)sccb;S390PCIBusDevice *pbdev =s390_pci_find_dev_by_fid (s390_get_phb (),be32_to_cpu (psccb->aid));uint16_t rc; -if (be16_to_cpu (sccb->h.length) <16 ) { - rc =SCLP_RC_INSUFFICIENT_SCCB_LENGTH ; - goto out; - } -if (!pbdev) {DPRINTF ("sclp deconfig no dev found\n" ); rc =SCLP_RC_ADAPTER_ID_NOT_RECOGNIZED ;hw/s390x/s390-pci-bus.h +0
-8@@ -244,14 +244,6 @@ typedef struct ChscSeiNt2Res {uint8_t ccdf[4016 ]; }QEMU_PACKED ChscSeiNt2Res; -typedef struct PciCfgSccb { -SCCBHeader header; -uint8_t atype; -uint8_t reserved1; -uint16_t reserved2; -uint32_t aid; -} QEMU_PACKED PciCfgSccb; - typedef struct S390MsixInfo { bool available; uint8_t table_bar;hw/s390x/s390-pci-stub.c +2
-0@@ -20,10 +20,12 @@ int pci_chsc_sei_nt2_have_event(void)/* hw/s390x/sclp.c */ void s390_pci_sclp_configure (SCCB *sccb) { + sccb->h.response_code =cpu_to_be16 (SCLP_RC_ADAPTER_TYPE_NOT_RECOGNIZED ); }void s390_pci_sclp_deconfigure (SCCB *sccb) { + sccb->h.response_code =cpu_to_be16 (SCLP_RC_ADAPTER_TYPE_NOT_RECOGNIZED ); }/* target/s390x/kvm.c */ hw/s390x/sclp.c +34
-5@@ -80,7 +80,7 @@ static void read_SCP_info(SCLPDevice *sclp, SCCB *sccb)prepare_cpu_entries (sclp, read_info->entries, cpu_count); read_info->facilities =cpu_to_be64 (SCLP_HAS_CPU_INFO | -SCLP_HAS_PCI_RECONFIG ); +SCLP_HAS_IOA_RECONFIG );/* Memory Hotplug is only supported for the ccw machine type */ if (mhd) {@@ -354,6 +354,35 @@ static void sclp_read_cpu_info(SCLPDevice *sclp, SCCB *sccb) sccb->h.response_code =cpu_to_be16 (SCLP_RC_NORMAL_READ_COMPLETION ); } +static void sclp_configure_io_adapter (SCLPDevice *sclp,SCCB *sccb, +bool configure) +{ +int rc; + +if (be16_to_cpu (sccb->h.length) <16 ) { + rc =SCLP_RC_INSUFFICIENT_SCCB_LENGTH ; + goto out_err; + } + +switch (((IoaCfgSccb *)sccb)->atype) { +case SCLP_RECONFIG_PCI_ATYPE : +if (s390_has_feat (S390_FEAT_ZPCI )) { +if (configure) { +s390_pci_sclp_configure (sccb); + }else { +s390_pci_sclp_deconfigure (sccb); + } +return ; + } +/* fallthrough */ +default : + rc =SCLP_RC_ADAPTER_TYPE_NOT_RECOGNIZED ; + } + + out_err: + sccb->h.response_code =cpu_to_be16 (rc); +} +static void sclp_execute (SCLPDevice *sclp,SCCB *sccb,uint32_t code) {SCLPDeviceClass *sclp_c =SCLP_GET_CLASS (sclp);@@ -384,11 +413,11 @@ static void sclp_execute(SCLPDevice *sclp, SCCB *sccb, uint32_t code)case SCLP_UNASSIGN_STORAGE : sclp_c->unassign_storage (sclp, sccb);break ; -case SCLP_CMDW_CONFIGURE_PCI : -s390_pci_sclp_configure (sccb); +case SCLP_CMDW_CONFIGURE_IOA : +sclp_configure_io_adapter (sclp, sccb, true);break ; -case SCLP_CMDW_DECONFIGURE_PCI : -s390_pci_sclp_deconfigure (sccb); +case SCLP_CMDW_DECONFIGURE_IOA : +sclp_configure_io_adapter (sclp, sccb, false);break ;default : efc->command_handler (ef, sccb, code);include/hw/s390x/sclp.h +6
-4@@ -44,10 +44,10 @@#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 +#define SCLP_HAS_IOA_RECONFIG 0x0000000040000000ULL +#define SCLP_CMDW_CONFIGURE_IOA 0x001a0001 +#define SCLP_CMDW_DECONFIGURE_IOA 0x001b0001 +#define SCLP_RECONFIG_PCI_ATYPE 2/* SCLP response codes */ #define SCLP_RC_NORMAL_READ_COMPLETION 0x0010@@ -59,6 +59,7 @@#define SCLP_RC_INSUFFICIENT_SCCB_LENGTH 0x0300#define SCLP_RC_STANDBY_READ_COMPLETION 0x0410#define SCLP_RC_ADAPTER_IN_RESERVED_STATE 0x05f0 +#define SCLP_RC_ADAPTER_TYPE_NOT_RECOGNIZED 0x06f0#define SCLP_RC_ADAPTER_ID_NOT_RECOGNIZED 0x09f0#define SCLP_RC_INVALID_FUNCTION 0x40f0#define SCLP_RC_NO_EVENT_BUFFERS_STORED 0x60f0@@ -167,6 +168,14 @@ typedef struct AssignStorage {uint16_t rn; }QEMU_PACKED AssignStorage; +typedef struct IoaCfgSccb {
include/hw/s390x/sclp.h typedef struct AssignStorage { · line 181
Quoted 10 lines
include/hw/s390x/sclp.h +7
-0+SCCBHeader header; +uint8_t atype; +uint8_t reserved1; +uint16_t reserved2; +uint32_t aid; +}QEMU_PACKED IoaCfgSccb; + typedef struct SCCB { SCCBHeader h; char data[SCCB_DATA_LEN];
LGTM and
I could also test the all serie on the hardware (sure is sure) :) with VFIO and virtio PCI... so
Signature · 2 lines
Pierre Morel Linux/KVM/QEMU in Böblingen - Germany
Re: [Qemu-devel] [PATCH v5 2/9] kvm: remove hard dependency on pci
In reply to Cornelia HuckQuoted 53 lines · Cornelia Huck
The msi routing code in kvm calls some pci functions: provide some stubs to enable builds without pci.
Also, to make this more obvious, guard them via a
pci_availableboolean (which also can be reused in other places).Fixes e1d4fb2de ("kvm-irqchip: x86: add msi route notify fn")Fixes 767a554a0 ("kvm-all: Pass requester ID to MSI routing functions")Reviewed-by Pierre Morel <[email protected]>Signed-off-by Cornelia Huck <[email protected]>--- accel/kvm/kvm-all.c | 6 +++--- hw/pci/pci-stub.c | 16 +++++++++++++++- hw/pci/pci.c | 2 ++ include/hw/pci/pci.h | 2 ++ 4 files changed, 22 insertions(+), 4 deletions(-)accel/kvm/kvm-all.c +3
-3@@ -1248,7 +1248,7 @@ int kvm_irqchip_add_msi_route(KVMState *s, int vector, PCIDevice *dev)int virq;MSIMessage msg = {0 ,0 }; -if (dev) { +if (pci_available && dev) { msg =pci_get_msi_message (dev, vector); }@@ -1271,7 +1271,7 @@ int kvm_irqchip_add_msi_route(KVMState *s, int vector, PCIDevice *dev) 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_msi_devid_required ()) { +if (pci_available &&kvm_msi_devid_required ()) { kroute.flags =KVM_MSI_VALID_DEVID ; kroute.u.msi.devid =pci_requester_id (dev); }@@ -1309,7 +1309,7 @@ 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_msi_devid_required ()) { +if (pci_available &&kvm_msi_devid_required ()) { kroute.flags =KVM_MSI_VALID_DEVID ; kroute.u.msi.devid =pci_requester_id (dev); }hw/pci/pci-stub.c +0
-0
hw/pci/pci-stub.c line 27
Quoted 6 lines
hw/pci/pci-stub.c +1
-1@@ -23,10 +23,11 @@#include "monitor/monitor.h" #include "qapi/qmp/qerror.h" #include "hw/pci/pci.h" -#include "qmp-commands.h" #include "hw/pci/msi.h" +#include "qmp-commands.h"
Nit: Unnecessary movement of the #include statement.
If you fix that:
Re: [Qemu-devel] [PATCH v5 3/9] s390x/pci: add stubs
In reply to Cornelia HuckQuoted 48 lines · Cornelia Huck
Some non-pci code calls into zpci code. Provide some stubs for builds without pci.
Reviewed-by Thomas Huth <[email protected]>Signed-off-by Cornelia Huck <[email protected]>--- hw/s390x/Makefile.objs | 3 +- hw/s390x/s390-pci-stub.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 hw/s390x/s390-pci-stub.chw/s390x/Makefile.objs +2
-1@@ -11,7 +11,8 @@ obj-y += 3270-ccw.o obj-y += virtio-ccw.o obj-y += css-bridge.o obj-y += ccw-device.o -obj-y += s390-pci-bus.o s390-pci-inst.o +obj-$(CONFIG_PCI) += s390-pci-bus.o s390-pci-inst.o +obj-$(call lnot,$(CONFIG_PCI)) += s390-pci-stub.o obj-y += s390-skeys.o obj-y += s390-stattrib.o obj-$(CONFIG_KVM) += s390-skeys-kvm.ohw/s390x/s390-pci-stub.c new file +17
-0@@ -0,0 +1,74 @@ +/* stubs for non-pci builds */ + +#include "qemu/osdep.h" +#include "qemu-common.h" +#include "cpu.h" +#include "s390-pci-inst.h" +#include "s390-pci-bus.h" + +/* target/s390x/ioinst.c */ +int chsc_sei_nt2_get_event (void *res) +{ +return 1 ; +} + +int chsc_sei_nt2_have_event (void ) +{ +return 0 ;
hw/s390x/s390-pci-stub.c line 27
Quoted 10 lines
hw/s390x/s390-pci-stub.c new file +10
-0+} + +/* hw/s390x/sclp.c */ +void s390_pci_sclp_configure (SCCB *sccb) +{ +} + +void s390_pci_sclp_deconfigure (SCCB *sccb) +{ +}
shouldnt these function set an error code in the sccb, e.g. something like
sccb->h.response_code = cpu_to_be16(SCLP_RC_INVALID_SCLP_COMMAND);
Re: [Qemu-devel] [PATCH v5 3/9] s390x/pci: add stubs
Quoted 65 lines · Christian Borntraeger
Quoted 48 lines · Cornelia Huck
Some non-pci code calls into zpci code. Provide some stubs for builds without pci.
Reviewed-by Thomas Huth <[email protected]>Signed-off-by Cornelia Huck <[email protected]>--- hw/s390x/Makefile.objs | 3 +- hw/s390x/s390-pci-stub.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 hw/s390x/s390-pci-stub.chw/s390x/Makefile.objs +2
-1@@ -11,7 +11,8 @@ obj-y += 3270-ccw.o obj-y += virtio-ccw.o obj-y += css-bridge.o obj-y += ccw-device.o -obj-y += s390-pci-bus.o s390-pci-inst.o +obj-$(CONFIG_PCI) += s390-pci-bus.o s390-pci-inst.o +obj-$(call lnot,$(CONFIG_PCI)) += s390-pci-stub.o obj-y += s390-skeys.o obj-y += s390-stattrib.o obj-$(CONFIG_KVM) += s390-skeys-kvm.ohw/s390x/s390-pci-stub.c new file +17
-0@@ -0,0 +1,74 @@ +/* stubs for non-pci builds */ + +#include "qemu/osdep.h" +#include "qemu-common.h" +#include "cpu.h" +#include "s390-pci-inst.h" +#include "s390-pci-bus.h" + +/* target/s390x/ioinst.c */ +int chsc_sei_nt2_get_event (void *res) +{ +return 1 ; +} + +int chsc_sei_nt2_have_event (void ) +{ +return 0 ;hw/s390x/s390-pci-stub.c line 27
Quoted 10 lines
hw/s390x/s390-pci-stub.c new file +10
-0+} + +/* hw/s390x/sclp.c */ +void s390_pci_sclp_configure (SCCB *sccb) +{ +} + +void s390_pci_sclp_deconfigure (SCCB *sccb) +{ +}shouldnt these function set an error code in the sccb, e.g. something like
Quoted 4 lines
sccb->h.response_code = cpu_to_be16(SCLP_RC_INVALID_SCLP_COMMAND);
Oh you have something like that in patch 7. Maybe move?
As there are only minor things left,
whole series
Quoted 40 lines · Cornelia Huck
Hopefully should be close now...
v4->v5:
- dropped "s390x/kvm: msi route fixup for non-pci"
- reworked "s390x/sclp: properly guard pci-specific functions": the configure/deconfigure stuff is about I/O adapters, we were missing checks, and I used an incorrect return code -- please review
- collected more r-bsCornelia Huck (9):
9pfs: fix dependencies
kvm: remove hard dependency on pci s390x/pci: add stubs
s390x: chsc nt2 events are pci-only s390x/pci: do not advertise pci on non-pci builds s390x/ccw: create s390 phb conditionally s390x/sclp: properly guard pci-specific functions s390x/pci: fence off instructions for non-pci
s390x: refine pci dependenciesaccel/kvm/kvm-all.c | 6 ++-- default-configs/s390x-softmmu.mak | 2 +- fsdev/Makefile.objs | 9 ++--- hw/9pfs/Makefile.objs | 2 +- hw/Makefile.objs | 2 +- hw/pci/pci-stub.c | 16 ++++++++- hw/pci/pci.c | 2 ++ hw/s390x/Makefile.objs | 3 +- hw/s390x/s390-pci-bus.c | 18 +++------- hw/s390x/s390-pci-bus.h | 12 ++----- hw/s390x/s390-pci-stub.c | 76 +++++++++++++++++++++++++++++++++++++++ hw/s390x/s390-virtio-ccw.c | 14 ++++---- hw/s390x/sclp.c | 39 +++++++++++++++++--- include/hw/pci/pci.h | 2 ++ include/hw/s390x/sclp.h | 17 ++++++--- target/s390x/ioinst.c | 16 +++++++++ target/s390x/kvm.c | 58 ++++++++++++++++++++++-------- 17 files changed, 227 insertions(+), 67 deletions(-) create mode 100644 hw/s390x/s390-pci-stub.c
Re: [Qemu-devel] [PATCH v5 7/9] s390x/sclp: properly guard pci-specific functions
In reply to Pierre MorelQuoted 25 lines · On Wed, 23 Aug 2017 18:25:05 +0200 Pierre Morel <[email protected]>…
Quoted 15 lines · Cornelia Huck
If we do not provide zpci, pci reconfiguration via sclp is not available either. I/O adapter configuration, however, should always be present.
Rename the values that refer to I/O adapter configuration (instead of only pci) to make things clearer.
Move length checking of the sccb for I/O adapter configuration into the common sclp code (out of the pci code). This also fixes an issue that the pci code would refer to a field in the sccb before checking whether it was actually long enough.
Check for the adapter type in the sccb and return unrecognized adapter type if the guest tries to issue I/O adapter configure/deconfigure for a type other than pci or for pci if the zpci facility is not provided.
Quoted 8 lines
Signed-off-by Cornelia Huck <[email protected]>--- hw/s390x/s390-pci-bus.c | 14 ++------------ hw/s390x/s390-pci-bus.h | 8 -------- hw/s390x/s390-pci-stub.c | 2 ++ hw/s390x/sclp.c | 39 ++++++++++++++++++++++++++++++++++----- include/hw/s390x/sclp.h | 17 +++++++++++++---- 5 files changed, 51 insertions(+), 29 deletions(-)
Quoted 5 lines
LGTM and
I could also test the all serie on the hardware (sure is sure) :) with VFIO and virtio PCI... soReviewed-by Pierre Morel <[email protected]>
Cool, thanks!
Re: [Qemu-devel] [PATCH v5 2/9] kvm: remove hard dependency on pci
In reply to Thomas HuthQuoted 18 lines · On Thu, 24 Aug 2017 03:13:46 +0200 Thomas Huth <[email protected]> wrote:
Quoted 16 lines · Cornelia Huck
The msi routing code in kvm calls some pci functions: provide some stubs to enable builds without pci.
Also, to make this more obvious, guard them via a
pci_availableboolean (which also can be reused in other places).Fixes e1d4fb2de ("kvm-irqchip: x86: add msi route notify fn")Fixes 767a554a0 ("kvm-all: Pass requester ID to MSI routing functions")Reviewed-by Pierre Morel <[email protected]>Signed-off-by Cornelia Huck <[email protected]>--- accel/kvm/kvm-all.c | 6 +++--- hw/pci/pci-stub.c | 16 +++++++++++++++- hw/pci/pci.c | 2 ++ include/hw/pci/pci.h | 2 ++ 4 files changed, 22 insertions(+), 4 deletions(-)
Quoted 13 lines
hw/pci/pci-stub.c line 27
Quoted 11 lines
hw/pci/pci-stub.c +1
-1@@ -23,10 +23,11 @@#include "monitor/monitor.h" #include "qapi/qmp/qerror.h" #include "hw/pci/pci.h" -#include "qmp-commands.h" #include "hw/pci/msi.h" +#include "qmp-commands.h" Nit: Unnecessary movement of the #include statement.
Seems to have slipped in during the various rebases. Fixed.
Quoted 4 lines
If you fix that:
Reviewed-by Thomas Huth <[email protected]>
Thanks!
Re: [Qemu-devel] [PATCH v5 3/9] s390x/pci: add stubs
In reply to Christian BorntraegerQuoted 27 lines · On Thu, 24 Aug 2017 09:43:48 +0200 Christian Borntraeger…
Quoted 26 lines · Christian Borntraeger
Quoted 11 lines · Cornelia Huck
Some non-pci code calls into zpci code. Provide some stubs for builds without pci.
Reviewed-by Thomas Huth <[email protected]>Signed-off-by Cornelia Huck <[email protected]>--- hw/s390x/Makefile.objs | 3 +- hw/s390x/s390-pci-stub.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 hw/s390x/s390-pci-stub.chw/s390x/s390-pci-stub.c line 27
Quoted 8 lines
hw/s390x/s390-pci-stub.c new file +8
-0+/* hw/s390x/sclp.c */ +void s390_pci_sclp_configure (SCCB *sccb) +{ +} + +void s390_pci_sclp_deconfigure (SCCB *sccb) +{ +}shouldnt these function set an error code in the sccb, e.g. something like
Quoted 6 lines
Quoted 4 lines
sccb->h.response_code = cpu_to_be16(SCLP_RC_INVALID_SCLP_COMMAND);Oh you have something like that in patch 7. Maybe move?
Does not really change anything in practice, but I can move it.
Re: [Qemu-devel] [PATCH v5 7/9] s390x/sclp: properly guard pci-specific functions
In reply to Cornelia HuckQuoted 114 lines · Cornelia Huck
If we do not provide zpci, pci reconfiguration via sclp is not available either. I/O adapter configuration, however, should always be present.
Rename the values that refer to I/O adapter configuration (instead of only pci) to make things clearer.
Move length checking of the sccb for I/O adapter configuration into the common sclp code (out of the pci code). This also fixes an issue that the pci code would refer to a field in the sccb before checking whether it was actually long enough.
Check for the adapter type in the sccb and return unrecognized adapter type if the guest tries to issue I/O adapter configure/deconfigure for a type other than pci or for pci if the zpci facility is not provided.
Signed-off-by Cornelia Huck <[email protected]>--- hw/s390x/s390-pci-bus.c | 14 ++------------ hw/s390x/s390-pci-bus.h | 8 -------- hw/s390x/s390-pci-stub.c | 2 ++ hw/s390x/sclp.c | 39 ++++++++++++++++++++++++++++++++++----- include/hw/s390x/sclp.h | 17 +++++++++++++---- 5 files changed, 51 insertions(+), 29 deletions(-)hw/s390x/s390-pci-bus.c +2
-12@@ -122,16 +122,11 @@ S390PCIBusDevice *s390_pci_find_dev_by_fid(S390pciState *s, uint32_t fid)void s390_pci_sclp_configure (SCCB *sccb) { -PciCfgSccb *psccb = (PciCfgSccb *)sccb; +IoaCfgSccb *psccb = (IoaCfgSccb *)sccb;S390PCIBusDevice *pbdev =s390_pci_find_dev_by_fid (s390_get_phb (),be32_to_cpu (psccb->aid));uint16_t rc; -if (be16_to_cpu (sccb->h.length) <16 ) { - rc =SCLP_RC_INSUFFICIENT_SCCB_LENGTH ; - goto out; - } -if (!pbdev) {DPRINTF ("sclp config no dev found\n" ); rc =SCLP_RC_ADAPTER_ID_NOT_RECOGNIZED ;@@ -155,16 +150,11 @@ out:void s390_pci_sclp_deconfigure (SCCB *sccb) { -PciCfgSccb *psccb = (PciCfgSccb *)sccb; +IoaCfgSccb *psccb = (IoaCfgSccb *)sccb;S390PCIBusDevice *pbdev =s390_pci_find_dev_by_fid (s390_get_phb (),be32_to_cpu (psccb->aid));uint16_t rc; -if (be16_to_cpu (sccb->h.length) <16 ) { - rc =SCLP_RC_INSUFFICIENT_SCCB_LENGTH ; - goto out; - } -if (!pbdev) {DPRINTF ("sclp deconfig no dev found\n" ); rc =SCLP_RC_ADAPTER_ID_NOT_RECOGNIZED ;hw/s390x/s390-pci-bus.h +0
-8@@ -244,14 +244,6 @@ typedef struct ChscSeiNt2Res {uint8_t ccdf[4016 ]; }QEMU_PACKED ChscSeiNt2Res; -typedef struct PciCfgSccb { -SCCBHeader header; -uint8_t atype; -uint8_t reserved1; -uint16_t reserved2; -uint32_t aid; -} QEMU_PACKED PciCfgSccb; - typedef struct S390MsixInfo { bool available; uint8_t table_bar;hw/s390x/s390-pci-stub.c +2
-0@@ -20,10 +20,12 @@ int pci_chsc_sei_nt2_have_event(void)/* hw/s390x/sclp.c */ void s390_pci_sclp_configure (SCCB *sccb) { + sccb->h.response_code =cpu_to_be16 (SCLP_RC_ADAPTER_TYPE_NOT_RECOGNIZED ); }void s390_pci_sclp_deconfigure (SCCB *sccb) { + sccb->h.response_code =cpu_to_be16 (SCLP_RC_ADAPTER_TYPE_NOT_RECOGNIZED ); }/* target/s390x/kvm.c */ hw/s390x/sclp.c +1
-1@@ -80,7 +80,7 @@ static void read_SCP_info(SCLPDevice *sclp, SCCB *sccb)prepare_cpu_entries (sclp, read_info->entries, cpu_count); read_info->facilities =cpu_to_be64 (SCLP_HAS_CPU_INFO | -SCLP_HAS_PCI_RECONFIG ); +SCLP_HAS_IOA_RECONFIG );/* Memory Hotplug is only supported for the ccw machine type */ if (mhd) {
hw/s390x/sclp.c static void sclp_read_cpu_info(SCLPDevice *sclp, SCCB *sccb) · line 358
Quoted 5 lines
hw/s390x/sclp.c +2
-0@@ -354,6 +354,35 @@ static void sclp_read_cpu_info(SCLPDevice *sclp, SCCB *sccb) sccb->h.response_code =cpu_to_be16 (SCLP_RC_NORMAL_READ_COMPLETION ); } +static void sclp_configure_io_adapter (SCLPDevice *sclp,SCCB *sccb, +bool configure)
Just an idea. This could be called reconfigure instead of configure (that's sclp_reconfigure_io_adapter) as the facility providing both conf and deconf is called reconf.
It ain't important. Patch looks good!
Re: [Qemu-devel] [PATCH v5 7/9] s390x/sclp: properly guard pci-specific functions
Quoted 42 lines · On Thu, 24 Aug 2017 11:29:47 +0200 Halil Pasic <[email protected]> wrote:
Quoted 41 lines · Cornelia Huck
If we do not provide zpci, pci reconfiguration via sclp is not available either. I/O adapter configuration, however, should always be present.
Rename the values that refer to I/O adapter configuration (instead of only pci) to make things clearer.
Move length checking of the sccb for I/O adapter configuration into the common sclp code (out of the pci code). This also fixes an issue that the pci code would refer to a field in the sccb before checking whether it was actually long enough.
Check for the adapter type in the sccb and return unrecognized adapter type if the guest tries to issue I/O adapter configure/deconfigure for a type other than pci or for pci if the zpci facility is not provided.
Signed-off-by Cornelia Huck <[email protected]>--- hw/s390x/s390-pci-bus.c | 14 ++------------ hw/s390x/s390-pci-bus.h | 8 -------- hw/s390x/s390-pci-stub.c | 2 ++ hw/s390x/sclp.c | 39 ++++++++++++++++++++++++++++++++++----- include/hw/s390x/sclp.h | 17 +++++++++++++---- 5 files changed, 51 insertions(+), 29 deletions(-)hw/s390x/sclp.c +1
-1@@ -80,7 +80,7 @@ static void read_SCP_info(SCLPDevice *sclp, SCCB *sccb)prepare_cpu_entries (sclp, read_info->entries, cpu_count); read_info->facilities =cpu_to_be64 (SCLP_HAS_CPU_INFO | -SCLP_HAS_PCI_RECONFIG ); +SCLP_HAS_IOA_RECONFIG );/* Memory Hotplug is only supported for the ccw machine type */ if (mhd) {@@ -354,6 +354,35 @@ static void sclp_read_cpu_info(SCLPDevice *sclp, SCCB *sccb) sccb->h.response_code =cpu_to_be16 (SCLP_RC_NORMAL_READ_COMPLETION ); }
Quoted 8 lines
hw/s390x/sclp.c static void sclp_read_cpu_info(SCLPDevice *sclp, SCCB *sccb) · line 358
Quoted 2 lines
hw/s390x/sclp.c +2
-0+static void sclp_configure_io_adapter (SCLPDevice *sclp,SCCB *sccb, +bool configure)Just an idea. This could be called reconfigure instead of configure (that's
sclp_reconfigure_io_adapter) as the facility providing both conf and deconf is called reconf.It ain't important. Patch looks good!
So I'll just keep it as-is :)
Quoted 2 lines
Reviewed-by Halil Pasic <[email protected]>
Thanks!
Halil Pasic
Acked-byRe: [Qemu-devel] [PATCH v5 3/9] s390x/pci: add stubs
In reply to Cornelia HuckQuoted 30 lines · Cornelia Huck
Quoted 27 lines · On Thu, 24 Aug 2017 09:43:48 +0200 Christian Borntraeger…
Quoted 26 lines · Christian Borntraeger
Quoted 11 lines · Cornelia Huck
Some non-pci code calls into zpci code. Provide some stubs for builds without pci.
Reviewed-by Thomas Huth <[email protected]>Signed-off-by Cornelia Huck <[email protected]>--- hw/s390x/Makefile.objs | 3 +- hw/s390x/s390-pci-stub.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 hw/s390x/s390-pci-stub.chw/s390x/s390-pci-stub.c line 27
Quoted 8 lines
hw/s390x/s390-pci-stub.c new file +8
-0+/* hw/s390x/sclp.c */ +void s390_pci_sclp_configure (SCCB *sccb) +{ +} + +void s390_pci_sclp_deconfigure (SCCB *sccb) +{ +}shouldnt these function set an error code in the sccb, e.g. something like
Quoted 9 lines
Quoted 6 lines
Quoted 4 lines
sccb->h.response_code = cpu_to_be16(SCLP_RC_INVALID_SCLP_COMMAND);Oh you have something like that in patch 7. Maybe move?
Does not really change anything in practice, but I can move it.
You mean these stubs are not supposed to be reachable and are just for making the linker happy, or? If that's the case I would prefer having that expressed by something like assert(false) or even #define NOT_REACHABLE assert(false).
Otherwise patch looks good, but I did not a full review on it, so let's try this:
Re: [Qemu-devel] [PATCH v5 3/9] s390x/pci: add stubs
Quoted 38 lines · On Thu, 24 Aug 2017 11:50:54 +0200 Halil Pasic <[email protected]> wrote:
Quoted 37 lines · Cornelia Huck
Quoted 33 lines · On Thu, 24 Aug 2017 09:43:48 +0200 Christian Borntraeger…
Quoted 26 lines · Christian Borntraeger
Quoted 11 lines · Cornelia Huck
Some non-pci code calls into zpci code. Provide some stubs for builds without pci.
Reviewed-by Thomas Huth <[email protected]>Signed-off-by Cornelia Huck <[email protected]>--- hw/s390x/Makefile.objs | 3 +- hw/s390x/s390-pci-stub.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 hw/s390x/s390-pci-stub.chw/s390x/s390-pci-stub.c line 27
Quoted 8 lines
hw/s390x/s390-pci-stub.c new file +8
-0+/* hw/s390x/sclp.c */ +void s390_pci_sclp_configure (SCCB *sccb) +{ +} + +void s390_pci_sclp_deconfigure (SCCB *sccb) +{ +}shouldnt these function set an error code in the sccb, e.g. something like
Quoted 4 lines
sccb->h.response_code = cpu_to_be16(SCLP_RC_INVALID_SCLP_COMMAND);Oh you have something like that in patch 7. Maybe move?
Quoted 7 lines
Quoted 2 lines
Does not really change anything in practice, but I can move it.
You mean these stubs are not supposed to be reachable and are just for making the linker happy, or? If that's the case I would prefer having that expressed by something like assert(false) or even #define
NOT_REACHABLEassert(false).
Without the last patch that makes virtio-pci depend on pci for s390x, you can't compile without pci anyway ;)
Quoted 5 lines
Otherwise patch looks good, but I did not a full review on it, so let's try this:
Acked-by Halil Pasic <[email protected]>
Thanks!
Cornelia Huck
AppliedQuoted 4 lines · On Thu, 24 Aug 2017 09:49:18 +0200 Christian Borntraeger…
As there are only minor things left,
whole series
Thanks.
I've applied this to s390-next.