From 80b7a265362c870f95fb5ca1f7e7a02c0fa0db3e Mon Sep 17 00:00:00 2001 From: Cornelia Huck Date: Thu, 6 Jul 2017 17:13:14 +0200 Subject: s390x/sclp: properly guard pci-specific functions 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. Reviewed-by: Pierre Morel Reviewed-by: Halil Pasic Acked-by: Christian Borntraeger Signed-off-by: Cornelia Huck --- hw/s390x/s390-pci-bus.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'hw/s390x/s390-pci-bus.c') diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c index c57f6ebae0..0a31a4ae88 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -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; -- cgit v1.2.3