s390x: zPCI detangling
v3 cover s390x: zPCI detangling
Next version, now without RFC. The goals are still the same:
- Being able to disable PCI support in a build completely.
- Properly fencing off PCI if the relevant facility bit is not provided.
Changes v2->v3:
- Only enable the zpci bit conditionally, keep the aen bit always on. Use a method that actually works...
- Some reordering in the msi route patch to keep the change small.
- Collected some r-bs.
Branch is still git://github.com/cohuck/qemu no-zpci-cpumodel
Likely 2.11 material, even though the 'fence off if facility bit is not set' part could count as bugfixes. Thoughts?
Cornelia Huck (9):
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/kvm: msi route fixup for non-pci
s390x: refine pci dependencies
default-configs/s390x-softmmu.mak | 2 +- hw/pci/pci-stub.c | 12 ++++++ hw/s390x/Makefile.objs | 3 +- hw/s390x/s390-pci-bus.c | 9 ++++- hw/s390x/s390-pci-bus.h | 5 ++- hw/s390x/s390-pci-stub.c | 78 +++++++++++++++++++++++++++++++++++++++ hw/s390x/s390-virtio-ccw.c | 12 +++--- hw/s390x/sclp.c | 19 ++++++++-- target/s390x/ioinst.c | 16 ++++++++ target/s390x/kvm.c | 61 +++++++++++++++++++++++------- 10 files changed, 188 insertions(+), 29 deletions(-) create mode 100644 hw/s390x/s390-pci-stub.c
Signature · 1 line
2.13.3
PATCH v3 1/9 kvm: remove hard dependency on pci
The msi routing code in kvm calls some pci functions: provide some stubs to enable builds without pci.
--- hw/pci/pci-stub.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
hw/pci/pci-stub.c +12 -0
@@ -23,6 +23,7 @@#include "monitor/monitor.h" #include "qapi/qmp/qerror.h" #include "hw/pci/pci.h" +#include "hw/pci/msi.h" #include "qmp-commands.h" #include "hw/pci/msi.h"
@@ -38,3 +39,14 @@ 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) +{ +assert (false); +} + +uint16_t pci_requester_id (PCIDevice *dev) +{ +assert (false); +}
Signature · 1 line
2.13.3
PATCH v3 2/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.3
PATCH v3 3/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.3
PATCH v3 4/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.
--- hw/s390x/s390-pci-bus.c | 5 +++++ hw/s390x/s390-pci-bus.h | 1 + hw/s390x/s390-pci-stub.c | 4 ++++ target/s390x/kvm.c | 2 +- 4 files changed, 11 insertions(+), 1 deletion(-)
hw/s390x/s390-pci-bus.c +5 -0
@@ -34,6 +34,11 @@ } \ }while (0 ) +void pci_enable_zpci_feature(S390CPUModel *model) +{ +set_bit (S390_FEAT_ZPCI , model->features); +} +S390pciState *s390_get_phb (void ) {static S390pciState *phb;
hw/s390x/s390-pci-bus.h +1 -0
@@ -333,4 +333,5 @@ S390PCIBusDevice *s390_pci_find_dev_by_fid(S390pciState *s, uint32_t fid);S390PCIBusDevice *s390_pci_find_next_avail_dev (S390pciState *s,S390PCIBusDevice *pbdev); +void pci_enable_zpci_feature (S390CPUModel *model);#endif
hw/s390x/s390-pci-stub.c +4 -0
@@ -72,3 +72,7 @@ S390PCIBusDevice *s390_pci_find_dev_by_idx(S390pciState *s, uint32_t idx) {return NULL ; } + +void pci_enable_zpci_feature (S390CPUModel *model) +{ +}
target/s390x/kvm.c +1 -1
@@ -2662,7 +2662,7 @@ 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); +pci_enable_zpci_feature (model);set_bit (S390_FEAT_ADAPTER_EVENT_NOTIFICATION , model->features);if (s390_known_cpu_type (cpu_type)) {
Signature · 1 line
2.13.3
PATCH v3 5/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 | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
hw/s390x/s390-virtio-ccw.c +7 -5
@@ -118,7 +118,6 @@ static void ccw_init(MachineState *machine) {int ret;VirtualCssBus *css_bus; -DeviceState *dev;s390_sclp_init ();s390_memory_init (machine->ram_size);
@@ -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.3
PATCH v3 6/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. Don't indicate it in the sclp facilities and return an invalid command if the guest tries to issue pci configure/deconfigure.
--- hw/s390x/sclp.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-)
hw/s390x/sclp.c +15 -4
@@ -59,6 +59,7 @@ static void read_SCP_info(SCLPDevice *sclp, SCCB *sccb)int rnsize, rnmax;int slots =MIN (machine->ram_slots,s390_get_memslot_count (kvm_state));IplParameterBlock *ipib =s390_ipl_get_iplb (); +uint64_t sclp_facilities =SCLP_HAS_CPU_INFO ;CPU_FOREACH (cpu) { cpu_count++;
@@ -79,8 +80,10 @@ 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 ); +if (s390_has_feat (S390_FEAT_ZPCI )) { + sclp_facilities |=SCLP_HAS_PCI_RECONFIG ; + } + read_info->facilities =cpu_to_be64 (sclp_facilities);/* Memory Hotplug is only supported for the ccw machine type */ if (mhd) {
@@ -385,10 +388,18 @@ static void sclp_execute(SCLPDevice *sclp, SCCB *sccb, uint32_t code) sclp_c->unassign_storage (sclp, sccb);break ;case SCLP_CMDW_CONFIGURE_PCI : -s390_pci_sclp_configure (sccb); +if (s390_has_feat (S390_FEAT_ZPCI )) { +s390_pci_sclp_configure (sccb); + }else { + sccb->h.response_code =cpu_to_be16 (SCLP_RC_INVALID_SCLP_COMMAND ); + }break ;case SCLP_CMDW_DECONFIGURE_PCI : -s390_pci_sclp_deconfigure (sccb); +if (s390_has_feat (S390_FEAT_ZPCI )) { +s390_pci_sclp_deconfigure (sccb); + }else { + sccb->h.response_code =cpu_to_be16 (SCLP_RC_INVALID_SCLP_COMMAND ); + }break ;default : efc->command_handler (ef, sccb, code);
Signature · 1 line
2.13.3
PATCH v3 7/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.3
PATCH v3 8/9 s390x/kvm: msi route fixup for non-pci
In reply to Cornelia HuckIf we don't provide pci, we cannot have a pci device for which we have to translate to adapter routes: just return -ENODEV.
--- target/s390x/kvm.c | 5 +++++ 1 file changed, 5 insertions(+)
target/s390x/kvm.c +5 -0
@@ -2424,6 +2424,11 @@ int kvm_arch_fixup_msi_route(struct kvm_irq_routing_entry *route,uint32_t idx = data >>ZPCI_MSI_VEC_BITS ;uint32_t vec = data &ZPCI_MSI_VEC_MASK ; +if (!s390_has_feat (S390_FEAT_ZPCI )) { +DPRINTF ("fixup_msi_route on non-pci machine?!\n" ); +return -ENODEV ; + } + pbdev =s390_pci_find_dev_by_idx (s390_get_phb (), idx);if (!pbdev) {DPRINTF ("add_msi_route no dev\n" );
Signature · 1 line
2.13.3
PATCH v3 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=$(CONFIG_LINUX) CONFIG_VIRTIO=y CONFIG_SCLPCONSOLE=y
Signature · 1 line
2.13.3
Re: [Qemu-devel] [PATCH v3 4/9] s390x/pci: do not advertise pci on non-pci builds
In reply to Cornelia HuckQuoted 3 lines · Cornelia Huck
Only set the zpci feature bit on builds that actually support pci.
Signed-off-by Cornelia Huck <[email protected]>
I like this variant.
Quoted 59 lines
--- hw/s390x/s390-pci-bus.c | 5 +++++ hw/s390x/s390-pci-bus.h | 1 + hw/s390x/s390-pci-stub.c | 4 ++++ target/s390x/kvm.c | 2 +- 4 files changed, 11 insertions(+), 1 deletion(-)hw/s390x/s390-pci-bus.c +5
-0@@ -34,6 +34,11 @@ } \ }while (0 ) +void pci_enable_zpci_feature(S390CPUModel *model) +{ +set_bit (S390_FEAT_ZPCI , model->features); +} +S390pciState *s390_get_phb (void ) {static S390pciState *phb;hw/s390x/s390-pci-bus.h +1
-0@@ -333,4 +333,5 @@ S390PCIBusDevice *s390_pci_find_dev_by_fid(S390pciState *s, uint32_t fid);S390PCIBusDevice *s390_pci_find_next_avail_dev (S390pciState *s,S390PCIBusDevice *pbdev); +void pci_enable_zpci_feature (S390CPUModel *model);#endif hw/s390x/s390-pci-stub.c +4
-0@@ -72,3 +72,7 @@ S390PCIBusDevice *s390_pci_find_dev_by_idx(S390pciState *s, uint32_t idx) {return NULL ; } + +void pci_enable_zpci_feature (S390CPUModel *model) +{ +}target/s390x/kvm.c +1
-1@@ -2662,7 +2662,7 @@ 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); +pci_enable_zpci_feature (model);set_bit (S390_FEAT_ADAPTER_EVENT_NOTIFICATION , model->features);if (s390_known_cpu_type (cpu_type)) {
Re: [Qemu-devel] [PATCH v3 1/9] kvm: remove hard dependency on pci
In reply to Cornelia HuckQuoted 27 lines · Cornelia Huck
The msi routing code in kvm calls some pci functions: provide some stubs to enable builds without pci.
Fixes e1d4fb2de ("kvm-irqchip: x86: add msi route notify fn")Fixes 767a554a0 ("kvm-all: Pass requester ID to MSI routing functions")Signed-off-by Cornelia Huck <[email protected]>--- hw/pci/pci-stub.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)hw/pci/pci-stub.c +2
-0@@ -23,6 +23,7 @@#include "monitor/monitor.h" #include "qapi/qmp/qerror.h" #include "hw/pci/pci.h" +#include "hw/pci/msi.h" #include "qmp-commands.h" #include "hw/pci/msi.h" @@ -38,3 +39,14 @@ void hmp_pcie_aer_inject_error(Monitor *mon, const QDict *qdict) {monitor_printf (mon,"PCI devices not supported\n" ); } +
hw/pci/pci-stub.c void hmp_pcie_aer_inject_error(Monitor *mon, const QDict *qdict) · line 52
Quoted 10 lines
hw/pci/pci-stub.c +10
-0+/* kvm-all wants this */ +MSIMessage pci_get_msi_message (PCIDevice *dev,int vector) +{ +assert (false); +} + +uint16_t pci_requester_id (PCIDevice *dev) +{ +assert (false); +}
Since this missed the 2.10 freeze anyway and we've got some more time to discuss it: I still think it would be much cleaner to move the functions from kvm-all.c that use these PCI functions into a separate file kvm-pci.c instead and compile that only with CONFIG_PCI=y. That way we likely also could prevent that more dependencies on CONFIG_PCI creep into kvm-all.c again at later points in time.
I've now had a closer look, and it seems like the only affected functions are kvm_irqchip_add_msi_route() and kvm_irqchip_update_msi_route() ... and these seems only to be used in code we would not care about on s390x with CONFIG_PCI=n. So could you please have at least a try to move these two functions (and other related msi functions) to a new file kvm-pci.c instead to see whether that would work, too?
Thanks,
Thomas
Re: [Qemu-devel] [PATCH v3 3/9] s390x: chsc nt2 events are pci-only
In reply to Cornelia HuckQuoted 80 lines · Cornelia Huck
The nt2 event class is pci-only - don't look for events if pci is not in the active cpu model.
Signed-off-by Cornelia Huck <[email protected]>--- 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 +5
-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); + }
target/s390x/ioinst.c static int chsc_sei_nt0_have_event(void) · line 616
Quoted 10 lines
target/s390x/ioinst.c +10
-0+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 ; +}
Not sure whether it is nicer/better, but you could also do the check only once in ioinst_handle_chsc_sei() and then get along without these wrapper functions?
Thomas
Re: [Qemu-devel] [PATCH v3 4/9] s390x/pci: do not advertise pci on non-pci builds
In reply to Cornelia HuckQuoted 53 lines · Cornelia Huck
Only set the zpci feature bit on builds that actually support pci.
Signed-off-by Cornelia Huck <[email protected]>--- hw/s390x/s390-pci-bus.c | 5 +++++ hw/s390x/s390-pci-bus.h | 1 + hw/s390x/s390-pci-stub.c | 4 ++++ target/s390x/kvm.c | 2 +- 4 files changed, 11 insertions(+), 1 deletion(-)hw/s390x/s390-pci-bus.c +5
-0@@ -34,6 +34,11 @@ } \ }while (0 ) +void pci_enable_zpci_feature(S390CPUModel *model) +{ +set_bit (S390_FEAT_ZPCI , model->features); +} +S390pciState *s390_get_phb (void ) {static S390pciState *phb;hw/s390x/s390-pci-bus.h +1
-0@@ -333,4 +333,5 @@ S390PCIBusDevice *s390_pci_find_dev_by_fid(S390pciState *s, uint32_t fid);S390PCIBusDevice *s390_pci_find_next_avail_dev (S390pciState *s,S390PCIBusDevice *pbdev); +void pci_enable_zpci_feature (S390CPUModel *model);#endif hw/s390x/s390-pci-stub.c +4
-0@@ -72,3 +72,7 @@ S390PCIBusDevice *s390_pci_find_dev_by_idx(S390pciState *s, uint32_t idx) {return NULL ; } + +void pci_enable_zpci_feature (S390CPUModel *model) +{ +}target/s390x/kvm.c +0
-0
target/s390x/kvm.c void kvm_s390_get_host_cpu_model(S390CPUModel *model, Error **errp) · line 2668
Quoted 8 lines
target/s390x/kvm.c +1
-1@@ -2662,7 +2662,7 @@ 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); +pci_enable_zpci_feature (model);set_bit (S390_FEAT_ADAPTER_EVENT_NOTIFICATION , model->features);if (s390_known_cpu_type (cpu_type)) {
Re: [Qemu-devel] [PATCH v3 8/9] s390x/kvm: msi route fixup for non-pci
In reply to Cornelia HuckQuoted 15 lines · Cornelia Huck
If we don't provide pci, we cannot have a pci device for which we have to translate to adapter routes: just return
-ENODEV.Signed-off-by Cornelia Huck <[email protected]>--- target/s390x/kvm.c | 5 +++++ 1 file changed, 5 insertions(+)target/s390x/kvm.c +0
-0@@ -2424,6 +2424,11 @@ int kvm_arch_fixup_msi_route(struct kvm_irq_routing_entry *route,uint32_t idx = data >>ZPCI_MSI_VEC_BITS ;
target/s390x/kvm.c int kvm_arch_fixup_msi_route(struct kvm_irq_routing_entry *route, · line 2434
Quoted 10 lines
target/s390x/kvm.c +5
-0uint32_t vec = data &ZPCI_MSI_VEC_MASK ; +if (!s390_has_feat (S390_FEAT_ZPCI )) { +DPRINTF ("fixup_msi_route on non-pci machine?!\n" ); +return -ENODEV ; + } + pbdev =s390_pci_find_dev_by_idx (s390_get_phb (), idx);if (!pbdev) {DPRINTF ("add_msi_route no dev\n" );
Is this additional check really needed here? I'd rather expect s390_pci_find_dev_by_idx() to return NULL here already, so we should already be fine, shouldn't we?
Thomas
Re: [Qemu-devel] [PATCH v3 3/9] s390x: chsc nt2 events are pci-only
In reply to Thomas HuthQuoted 31 lines · On Wed, 26 Jul 2017 08:59:10 +0200 Thomas Huth <[email protected]> wrote:
Quoted 30 lines · Cornelia Huck
The nt2 event class is pci-only - don't look for events if pci is not in the active cpu model.
Signed-off-by Cornelia Huck <[email protected]>--- 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(-)target/s390x/ioinst.c +11
-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 )) {
Quoted 8 lines
target/s390x/ioinst.c static int chsc_sei_nt0_have_event(void) · line 616
Quoted 4 lines
target/s390x/ioinst.c +4
-0+return pci_chsc_sei_nt2_have_event (); + } +return 0 ; +}Not sure whether it is nicer/better, but you could also do the check only once in
ioinst_handle_chsc_sei()and then get along without these wrapper functions?
I prefer the wrapper functions, as it mirrors the nt0 wrappers and nicely contains the fact that nt2 is pci specific.
Re: [Qemu-devel] [PATCH v3 8/9] s390x/kvm: msi route fixup for non-pci
In reply to Thomas HuthQuoted 17 lines · On Wed, 26 Jul 2017 09:09:06 +0200 Thomas Huth <[email protected]> wrote:
Quoted 16 lines · Cornelia Huck
If we don't provide pci, we cannot have a pci device for which we have to translate to adapter routes: just return
-ENODEV.Signed-off-by Cornelia Huck <[email protected]>--- target/s390x/kvm.c | 5 +++++ 1 file changed, 5 insertions(+)target/s390x/kvm.c +0
-0@@ -2424,6 +2424,11 @@ int kvm_arch_fixup_msi_route(struct kvm_irq_routing_entry *route,uint32_t idx = data >>ZPCI_MSI_VEC_BITS ;uint32_t vec = data &ZPCI_MSI_VEC_MASK ;
Quoted 13 lines
target/s390x/kvm.c int kvm_arch_fixup_msi_route(struct kvm_irq_routing_entry *route, · line 2434
Quoted 9 lines
target/s390x/kvm.c +5
-0+if (!s390_has_feat (S390_FEAT_ZPCI )) { +DPRINTF ("fixup_msi_route on non-pci machine?!\n" ); +return -ENODEV ; + } + pbdev =s390_pci_find_dev_by_idx (s390_get_phb (), idx);if (!pbdev) {DPRINTF ("add_msi_route no dev\n" );Is this additional check really needed here? I'd rather expect
s390_pci_find_dev_by_idx()to return NULL here already, so we should already be fine, shouldn't we?
Yes, the end result is the same, but (1) better safe than sorry and (2) I can add a debug print here.
I had actually considered throwing an error here, as this function really should not be called for !pci. Opinions?
Re: [Qemu-devel] [PATCH v3 8/9] s390x/kvm: msi route fixup for non-pci
Quoted 34 lines · Cornelia Huck
Quoted 17 lines · On Wed, 26 Jul 2017 09:09:06 +0200 Thomas Huth <[email protected]> wrote:
Quoted 16 lines · Cornelia Huck
If we don't provide pci, we cannot have a pci device for which we have to translate to adapter routes: just return
-ENODEV.Signed-off-by Cornelia Huck <[email protected]>--- target/s390x/kvm.c | 5 +++++ 1 file changed, 5 insertions(+)target/s390x/kvm.c +0
-0@@ -2424,6 +2424,11 @@ int kvm_arch_fixup_msi_route(struct kvm_irq_routing_entry *route,uint32_t idx = data >>ZPCI_MSI_VEC_BITS ;uint32_t vec = data &ZPCI_MSI_VEC_MASK ;Quoted 13 lines
target/s390x/kvm.c int kvm_arch_fixup_msi_route(struct kvm_irq_routing_entry *route, · line 2434
Quoted 9 lines
target/s390x/kvm.c +5
-0+if (!s390_has_feat (S390_FEAT_ZPCI )) { +DPRINTF ("fixup_msi_route on non-pci machine?!\n" ); +return -ENODEV ; + } + pbdev =s390_pci_find_dev_by_idx (s390_get_phb (), idx);if (!pbdev) {DPRINTF ("add_msi_route no dev\n" );Is this additional check really needed here? I'd rather expect
s390_pci_find_dev_by_idx()to return NULL here already, so we should already be fine, shouldn't we?
Quoted 5 lines
Yes, the end result is the same, but (1) better safe than sorry and (2) I can add a debug print here.
I had actually considered throwing an error here, as this function really should not be called for !pci. Opinions?
At least the current DPRINTF will go unnoticed in 99% of all cases since it is not compiled in by default. So I'd say either do a proper error_report() or even g_assert() here, or simply drop the patch.
Thomas
Re: [Qemu-devel] [PATCH v3 1/9] kvm: remove hard dependency on pci
In reply to Thomas HuthQuoted 46 lines · On Wed, 26 Jul 2017 08:52:44 +0200 Thomas Huth <[email protected]> wrote:
Quoted 27 lines · Cornelia Huck
The msi routing code in kvm calls some pci functions: provide some stubs to enable builds without pci.
Fixes e1d4fb2de ("kvm-irqchip: x86: add msi route notify fn")Fixes 767a554a0 ("kvm-all: Pass requester ID to MSI routing functions")Signed-off-by Cornelia Huck <[email protected]>--- hw/pci/pci-stub.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)hw/pci/pci-stub.c +2
-0@@ -23,6 +23,7 @@#include "monitor/monitor.h" #include "qapi/qmp/qerror.h" #include "hw/pci/pci.h" +#include "hw/pci/msi.h" #include "qmp-commands.h" #include "hw/pci/msi.h" @@ -38,3 +39,14 @@ void hmp_pcie_aer_inject_error(Monitor *mon, const QDict *qdict) {monitor_printf (mon,"PCI devices not supported\n" ); } +hw/pci/pci-stub.c void hmp_pcie_aer_inject_error(Monitor *mon, const QDict *qdict) · line 52
Quoted 10 lines
hw/pci/pci-stub.c +10
-0+/* kvm-all wants this */ +MSIMessage pci_get_msi_message (PCIDevice *dev,int vector) +{ +assert (false); +} + +uint16_t pci_requester_id (PCIDevice *dev) +{ +assert (false); +}Since this missed the 2.10 freeze anyway and we've got some more time to discuss it: I still think it would be much cleaner to move the functions from
kvm-all.cthat use these PCI functions into a separate filekvm-pci.cinstead and compile that only withCONFIG_PCI=y. That way we likely also could prevent that more dependencies onCONFIG_PCIcreep intokvm-all.cagain at later points in time.
Quoted 7 lines
I've now had a closer look, and it seems like the only affected functions are
kvm_irqchip_add_msi_route()andkvm_irqchip_update_msi_route()... and these seems only to be used in code we would not care about on s390x withCONFIG_PCI=n. So could you please have at least a try to move these two functions (and other related msi functions) to a new filekvm-pci.cinstead to see whether that would work, too?
I can try, as this missed the 2.10 boat anyway.
The code contains some parts that are not relevant in all cases (msi routes if we don't use pci, adapter routes for anything not s390x, ...), but I don't think trying to rip this out would be much of an improvement. I'll try the minimal (well, not quite as minimal as this patch) route instead.
Re: [Qemu-devel] [PATCH v3 8/9] s390x/kvm: msi route fixup for non-pci
In reply to Thomas HuthQuoted 38 lines · Thomas Huth
Quoted 37 lines · Cornelia Huck
Quoted 17 lines · On Wed, 26 Jul 2017 09:09:06 +0200 Thomas Huth <[email protected]> wrote:
Quoted 16 lines · Cornelia Huck
If we don't provide pci, we cannot have a pci device for which we have to translate to adapter routes: just return
-ENODEV.Signed-off-by Cornelia Huck <[email protected]>--- target/s390x/kvm.c | 5 +++++ 1 file changed, 5 insertions(+)target/s390x/kvm.c +0
-0@@ -2424,6 +2424,11 @@ int kvm_arch_fixup_msi_route(struct kvm_irq_routing_entry *route,uint32_t idx = data >>ZPCI_MSI_VEC_BITS ;uint32_t vec = data &ZPCI_MSI_VEC_MASK ;Quoted 13 lines
target/s390x/kvm.c int kvm_arch_fixup_msi_route(struct kvm_irq_routing_entry *route, · line 2434
Quoted 9 lines
target/s390x/kvm.c +5
-0+if (!s390_has_feat (S390_FEAT_ZPCI )) { +DPRINTF ("fixup_msi_route on non-pci machine?!\n" ); +return -ENODEV ; + } + pbdev =s390_pci_find_dev_by_idx (s390_get_phb (), idx);if (!pbdev) {DPRINTF ("add_msi_route no dev\n" );Is this additional check really needed here? I'd rather expect
s390_pci_find_dev_by_idx()to return NULL here already, so we should already be fine, shouldn't we?Yes, the end result is the same, but (1) better safe than sorry and (2) I can add a debug print here.
Quoted 9 lines
Quoted 2 lines
I had actually considered throwing an error here, as this function really should not be called for !pci. Opinions?
At least the current DPRINTF will go unnoticed in 99% of all cases since it is not compiled in by default. So I'd say either do a proper
error_report()or eveng_assert()here, or simply drop the patch.Thomas
I'd vote for g_assert() or simply dropping it.
Signature · 3 lines
Thanks, David
Re: [Qemu-devel] [PATCH v3 4/9] s390x/pci: do not advertise pci on non-pci builds
In reply to Cornelia HuckGood. This patch resolves the problem I mentioned in previous verion.
Thanks for your work.
Quoted 61 lines · Cornelia Huck
Only set the zpci feature bit on builds that actually support pci.
Signed-off-by Cornelia Huck <[email protected]>--- hw/s390x/s390-pci-bus.c | 5 +++++ hw/s390x/s390-pci-bus.h | 1 + hw/s390x/s390-ci-stub.c | 4 ++++ target/s390x/kvm.c | 2 +- 4 files changed, 11 insertions(+), 1 deletion(-)hw/s390x/s390-pci-bus.c +5
-0@@ -34,6 +34,11 @@ } \ }while (0 ) +void pci_enable_zpci_feature(S390CPUModel *model) +{ +set_bit (S390_FEAT_ZPCI , model->features); +} +S390pciState *s390_get_phb (void ) {static S390pciState *phb;hw/s390x/s390-pci-bus.h +1
-0@@ -333,4 +333,5 @@ S390PCIBusDevice *s390_pci_find_dev_by_fid(S390pciState *s, uint32_t fid);S390PCIBusDevice *s390_pci_find_next_avail_dev (S390pciState *s,S390PCIBusDevice *pbdev); +void pci_enable_zpci_feature (S390CPUModel *model);#endif hw/s390x/s390-pci-stub.c +4
-0@@ -72,3 +72,7 @@ S390PCIBusDevice *s390_pci_find_dev_by_idx(S390pciState *s, uint32_t idx) {return NULL ; } + +void pci_enable_zpci_feature (S390CPUModel *model) +{ +}target/s390x/kvm.c +1
-1@@ -2662,7 +2662,7 @@ 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); +pci_enable_zpci_feature (model);set_bit (S390_FEAT_ADAPTER_EVENT_NOTIFICATION , model->features);if (s390_known_cpu_type (cpu_type)) {
Quoted 10 lines · Cornelia Huck
Next version, now without RFC. The goals are still the same:
- Being able to disable PCI support in a build completely.
- Properly fencing off PCI if the relevant facility bit is not provided.Changes
v2->v3:
- Only enable the zpci bit conditionally, keep the aen bit always on. Use a method that actually works...
- Some reordering in the msi route patch to keep the change small.
- Collected some r-bs.
Quoted 4 lines
Branch is still
git://github.com/cohuck/qemuno-zpci-cpumodelLikely 2.11 material, even though the 'fence off if facility bit is not set' part could count as bugfixes. Thoughts?
In general, this series looks pretty good already, but I would prefer to have it in 2.11. The PCI code now seems to work ok for passthrough devices and this change would certainly require some retesting.
I think it would stretch things too far to consider the fencing a must have bug fix.
Quoted 25 lines
Cornelia Huck (9):
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/kvm: msi route fixup for non-pci
s390x: refine pci dependenciesdefault-configs/s390x-softmmu.mak | 2 +- hw/pci/pci-stub.c | 12 ++++++ hw/s390x/Makefile.objs | 3 +- hw/s390x/s390-pci-bus.c | 9 ++++- hw/s390x/s390-pci-bus.h | 5 ++- hw/s390x/s390-pci-stub.c | 78 +++++++++++++++++++++++++++++++++++++++ hw/s390x/s390-virtio-ccw.c | 12 +++--- hw/s390x/sclp.c | 19 ++++++++-- target/s390x/ioinst.c | 16 ++++++++ target/s390x/kvm.c | 61 +++++++++++++++++++++++------- 10 files changed, 188 insertions(+), 29 deletions(-) create mode 100644 hw/s390x/s390-pci-stub.c
Re: [Qemu-devel] [PATCH v3 4/9] s390x/pci: do not advertise pci on non-pci builds
In reply to Cornelia HuckQuoted 53 lines · Cornelia Huck
Only set the zpci feature bit on builds that actually support pci.
Signed-off-by Cornelia Huck <[email protected]>--- hw/s390x/s390-pci-bus.c | 5 +++++ hw/s390x/s390-pci-bus.h | 1 + hw/s390x/s390-pci-stub.c | 4 ++++ target/s390x/kvm.c | 2 +- 4 files changed, 11 insertions(+), 1 deletion(-)hw/s390x/s390-pci-bus.c +5
-0@@ -34,6 +34,11 @@ } \ }while (0 ) +void pci_enable_zpci_feature(S390CPUModel *model) +{ +set_bit (S390_FEAT_ZPCI , model->features); +} +S390pciState *s390_get_phb (void ) {static S390pciState *phb;hw/s390x/s390-pci-bus.h +1
-0@@ -333,4 +333,5 @@ S390PCIBusDevice *s390_pci_find_dev_by_fid(S390pciState *s, uint32_t fid);S390PCIBusDevice *s390_pci_find_next_avail_dev (S390pciState *s,S390PCIBusDevice *pbdev); +void pci_enable_zpci_feature (S390CPUModel *model);#endif hw/s390x/s390-pci-stub.c +4
-0@@ -72,3 +72,7 @@ S390PCIBusDevice *s390_pci_find_dev_by_idx(S390pciState *s, uint32_t idx) {return NULL ; } + +void pci_enable_zpci_feature (S390CPUModel *model) +{ +}target/s390x/kvm.c +0
-0
target/s390x/kvm.c void kvm_s390_get_host_cpu_model(S390CPUModel *model, Error **errp) · line 2665
Quoted 5 lines
target/s390x/kvm.c +1
-1@@ -2662,7 +2662,7 @@ 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); +pci_enable_zpci_feature (model);
While I see how this solves the problem, I don't really like it. If there is a function "save_the_world()" I expect it to save the world in all scenarios ;)
What about the same approach but rather
if(pci_configured())
set_bit(S390_FEAT_ZPCI, model->features);
Or of course zpci_configured(), pci_zpci_bus_available() ...
Quoted 4 lines
target/s390x/kvm.c +0
-0set_bit (S390_FEAT_ADAPTER_EVENT_NOTIFICATION , model->features);if (s390_known_cpu_type (cpu_type)) {
Signature · 3 lines
Thanks, David
Re: [Qemu-devel] [PATCH v3 8/9] s390x/kvm: msi route fixup for non-pci
In reply to David HildenbrandQuoted 42 lines · On Wed, 26 Jul 2017 10:37:12 +0200 David Hildenbrand <[email protected]> wrote:
Quoted 41 lines · Thomas Huth
Quoted 39 lines · Cornelia Huck
Quoted 17 lines · On Wed, 26 Jul 2017 09:09:06 +0200 Thomas Huth <[email protected]> wrote:
Quoted 16 lines · Cornelia Huck
If we don't provide pci, we cannot have a pci device for which we have to translate to adapter routes: just return
-ENODEV.Signed-off-by Cornelia Huck <[email protected]>--- target/s390x/kvm.c | 5 +++++ 1 file changed, 5 insertions(+)target/s390x/kvm.c +0
-0@@ -2424,6 +2424,11 @@ int kvm_arch_fixup_msi_route(struct kvm_irq_routing_entry *route,uint32_t idx = data >>ZPCI_MSI_VEC_BITS ;uint32_t vec = data &ZPCI_MSI_VEC_MASK ;Quoted 13 lines
target/s390x/kvm.c int kvm_arch_fixup_msi_route(struct kvm_irq_routing_entry *route, · line 2434
Quoted 9 lines
target/s390x/kvm.c +5
-0+if (!s390_has_feat (S390_FEAT_ZPCI )) { +DPRINTF ("fixup_msi_route on non-pci machine?!\n" ); +return -ENODEV ; + } + pbdev =s390_pci_find_dev_by_idx (s390_get_phb (), idx);if (!pbdev) {DPRINTF ("add_msi_route no dev\n" );Is this additional check really needed here? I'd rather expect
s390_pci_find_dev_by_idx()to return NULL here already, so we should already be fine, shouldn't we?Yes, the end result is the same, but (1) better safe than sorry and (2) I can add a debug print here.
I had actually considered throwing an error here, as this function really should not be called for !pci. Opinions?
Quoted 9 lines
Quoted 6 lines
At least the current DPRINTF will go unnoticed in 99% of all cases since it is not compiled in by default. So I'd say either do a proper
error_report()or eveng_assert()here, or simply drop the patch.Thomas
I'd vote for
g_assert()or simply dropping it.
I don't like dropping the check. I'll go for g_assert().
Re: [Qemu-devel] [PATCH v3 4/9] s390x/pci: do not advertise pci on non-pci builds
In reply to David HildenbrandQuoted 56 lines · On Wed, 26 Jul 2017 11:28:17 +0200 David Hildenbrand <[email protected]> wrote:
Quoted 55 lines · Cornelia Huck
Only set the zpci feature bit on builds that actually support pci.
Signed-off-by Cornelia Huck <[email protected]>--- hw/s390x/s390-pci-bus.c | 5 +++++ hw/s390x/s390-pci-bus.h | 1 + hw/s390x/s390-pci-stub.c | 4 ++++ target/s390x/kvm.c | 2 +- 4 files changed, 11 insertions(+), 1 deletion(-)hw/s390x/s390-pci-bus.c +5
-0@@ -34,6 +34,11 @@ } \ }while (0 ) +void pci_enable_zpci_feature(S390CPUModel *model) +{ +set_bit (S390_FEAT_ZPCI , model->features); +} +S390pciState *s390_get_phb (void ) {static S390pciState *phb;hw/s390x/s390-pci-bus.h +1
-0@@ -333,4 +333,5 @@ S390PCIBusDevice *s390_pci_find_dev_by_fid(S390pciState *s, uint32_t fid);S390PCIBusDevice *s390_pci_find_next_avail_dev (S390pciState *s,S390PCIBusDevice *pbdev); +void pci_enable_zpci_feature (S390CPUModel *model);#endif hw/s390x/s390-pci-stub.c +4
-0@@ -72,3 +72,7 @@ S390PCIBusDevice *s390_pci_find_dev_by_idx(S390pciState *s, uint32_t idx) {return NULL ; } + +void pci_enable_zpci_feature (S390CPUModel *model) +{ +}target/s390x/kvm.c +0
-0@@ -2662,7 +2662,7 @@ void kvm_s390_get_host_cpu_model(S390CPUModel *model, Error **errp) }
Quoted 7 lines
target/s390x/kvm.c void kvm_s390_get_host_cpu_model(S390CPUModel *model, Error **errp) · line 2665
Quoted 3 lines
target/s390x/kvm.c +1
-1/* We emulate a zPCI bus and AEN, therefore we don't need HW support */ -set_bit (S390_FEAT_ZPCI , model->features); +pci_enable_zpci_feature (model);While I see how this solves the problem, I don't really like it. If there is a function "
save_the_world()" I expect it to save the world in all scenarios ;)
What, you did not read the fine print? ;)
Quoted 7 lines
What about the same approach but rather
if(pci_configured())
set_bit(S390_FEAT_ZPCI, model->features);Or of course
zpci_configured(),pci_zpci_bus_available()...
I'm not sure that would help with readability. OTOH, it would be usable to check for pci support in other places as well...
I can play with this a bit.
Quoted 7 lines
Quoted 5 lines
target/s390x/kvm.c +0
-0set_bit (S390_FEAT_ADAPTER_EVENT_NOTIFICATION , model->features);if (s390_known_cpu_type (cpu_type)) {
Re: [Qemu-devel] [PATCH v3 5/9] s390x/ccw: create s390 phb conditionally
In reply to Cornelia HuckQuoted 5 lines · Cornelia Huck
Don't create the s390 pci host bridge if we do not provide the zpci facility.
Reviewed-by Thomas Huth <[email protected]>Signed-off-by Cornelia Huck <[email protected]>
Quoted 35 lines
--- hw/s390x/s390-virtio-ccw.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)hw/s390x/s390-virtio-ccw.c +7
-5@@ -118,7 +118,6 @@ static void ccw_init(MachineState *machine) {int ret;VirtualCssBus *css_bus; -DeviceState *dev;s390_sclp_init ();s390_memory_init (machine->ram_size);@@ -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 ();
Re: [Qemu-devel] [PATCH v3 4/9] s390x/pci: do not advertise pci on non-pci builds
In reply to David HildenbrandQuoted 64 lines · David Hildenbrand
Quoted 53 lines · Cornelia Huck
Only set the zpci feature bit on builds that actually support pci.
Signed-off-by Cornelia Huck <[email protected]>--- hw/s390x/s390-pci-bus.c | 5 +++++ hw/s390x/s390-pci-bus.h | 1 + hw/s390x/s390-pci-stub.c | 4 ++++ target/s390x/kvm.c | 2 +- 4 files changed, 11 insertions(+), 1 deletion(-)hw/s390x/s390-pci-bus.c +5
-0@@ -34,6 +34,11 @@ } \ }while (0 ) +void pci_enable_zpci_feature(S390CPUModel *model) +{ +set_bit (S390_FEAT_ZPCI , model->features); +} +S390pciState *s390_get_phb (void ) {static S390pciState *phb;hw/s390x/s390-pci-bus.h +1
-0@@ -333,4 +333,5 @@ S390PCIBusDevice *s390_pci_find_dev_by_fid(S390pciState *s, uint32_t fid);S390PCIBusDevice *s390_pci_find_next_avail_dev (S390pciState *s,S390PCIBusDevice *pbdev); +void pci_enable_zpci_feature (S390CPUModel *model);#endif hw/s390x/s390-pci-stub.c +4
-0@@ -72,3 +72,7 @@ S390PCIBusDevice *s390_pci_find_dev_by_idx(S390pciState *s, uint32_t idx) {return NULL ; } + +void pci_enable_zpci_feature (S390CPUModel *model) +{ +}target/s390x/kvm.c +0
-0target/s390x/kvm.c void kvm_s390_get_host_cpu_model(S390CPUModel *model, Error **errp) · line 2665
Quoted 5 lines
target/s390x/kvm.c +1
-1@@ -2662,7 +2662,7 @@ 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); +pci_enable_zpci_feature (model);While I see how this solves the problem, I don't really like it. If there is a function "
save_the_world()" I expect it to save the world in all scenarios ;)
Quoted 4 lines
What about the same approach but rather
if(pci_configured())
set_bit(S390_FEAT_ZPCI, model->features);
Or maybe something like this (without introducing new functions):
if (object_class_by_name(TYPE_S390_PCI_HOST_BRIDGE)) {
set_bit(S390_FEAT_ZPCI, model->features);
}?
I haven't tested this, though, but I think it should work since the S390_PCI classes are only compiled in if CONFIG_PCI=y.
Thomas
Re: [Qemu-devel] [PATCH v3 1/9] kvm: remove hard dependency on pci
In reply to Cornelia HuckQuoted 18 lines · On Wed, 26 Jul 2017 10:26:23 +0200 Cornelia Huck <[email protected]> wrote:
Quoted 7 lines · On Wed, 26 Jul 2017 08:52:44 +0200 Thomas Huth <[email protected]> wrote:
Since this missed the 2.10 freeze anyway and we've got some more time to discuss it: I still think it would be much cleaner to move the functions from
kvm-all.cthat use these PCI functions into a separate filekvm-pci.cinstead and compile that only withCONFIG_PCI=y. That way we likely also could prevent that more dependencies onCONFIG_PCIcreep intokvm-all.cagain at later points in time.Quoted 7 lines
I've now had a closer look, and it seems like the only affected functions are
kvm_irqchip_add_msi_route()andkvm_irqchip_update_msi_route()... and these seems only to be used in code we would not care about on s390x withCONFIG_PCI=n. So could you please have at least a try to move these two functions (and other related msi functions) to a new filekvm-pci.cinstead to see whether that would work, too?
Quoted 7 lines
I can try, as this missed the 2.10 boat anyway.
The code contains some parts that are not relevant in all cases (msi routes if we don't use pci, adapter routes for anything not s390x, ...), but I don't think trying to rip this out would be much of an improvement. I'll try the minimal (well, not quite as minimal as this patch) route instead.
I tried this; but it turned out to be one of those cases where you pull on a stick and then find half a tree attached to it... Much of the code is used by all routing variants, and I ended up exposing so many functions that it was just ugly and unreadable.
The variant I'm now going with is keeping the original approach and adding a pci_available variable, which I also use in the patch that exposes the zpci facility patch only when pci is compiled in. I'll try to post this after lunch.