s390x/pci: some small fixes
v3 cover s390x/pci: some small fixes
A collection of small fixes for s390x PCI (not urgent). The first 3 are fixes related to always using the host-provided CLP value when provided vs a hard-coded value. The last patch adds logic for QEMU to report a proper DTSM clp response rather than just 0s (guest linux doesn't look at this field today).
Changes for v3:
- Actually fix patch 4 this time (Pierre)
Matthew Rosato (4):
s390x/pci: use a reserved ID for the default PCI group s390x/pci: don't use hard-coded dma range in reg_ioat s390x/pci: use the passthrough measurement update interval s390x/pci: add supported DT information to clp response
hw/s390x/s390-pci-bus.c | 1 + hw/s390x/s390-pci-inst.c | 15 +++++++++------ hw/s390x/s390-pci-vfio.c | 1 + include/hw/s390x/s390-pci-bus.h | 3 ++- include/hw/s390x/s390-pci-clp.h | 3 ++- 5 files changed, 15 insertions(+), 8 deletions(-)
Signature · 1 line
2.27.0
PATCH v3 1/4 s390x/pci: use a reserved ID for the default PCI group
The current default PCI group being used can technically collide with a real group ID passed from a hostdev. Let's instead use a group ID that comes from a special pool (0xF0-0xFF) that is architected to be reserved for simulated devices.
--- include/hw/s390x/s390-pci-bus.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/hw/s390x/s390-pci-bus.h +1 -1
@@ -313,7 +313,7 @@ typedef struct ZpciFmb { } ZpciFmb;QEMU_BUILD_BUG_MSG (offsetof(ZpciFmb , fmt0) !=48 ,"padding in ZpciFmb" ); -#define ZPCI_DEFAULT_FN_GRP 0x20 +#define ZPCI_DEFAULT_FN_GRP 0xFF typedef struct S390PCIGroup { ClpRspQueryPciGrp zpci_group; int id;
Signature · 1 line
2.27.0
PATCH v3 2/4 s390x/pci: don't use hard-coded dma range in reg_ioat
In reply to Matthew RosatoInstead use the values from clp info, they will either be the hard-coded values or what came from the host driver via vfio.
--- hw/s390x/s390-pci-inst.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
hw/s390x/s390-pci-inst.c +5 -4
@@ -916,9 +916,10 @@ int pci_dereg_irqs(S390PCIBusDevice *pbdev)return 0 ; } -static int reg_ioat (CPUS390XState *env,S390PCIIOMMU *iommu,ZpciFib fib, +static int reg_ioat (CPUS390XState *env,S390PCIBusDevice *pbdev,ZpciFib fib,uintptr_t ra) { +S390PCIIOMMU *iommu = pbdev->iommu;uint64_t pba =ldq_p (&fib.pba);uint64_t pal =ldq_p (&fib.pal);uint64_t g_iota =ldq_p (&fib.iota);
@@ -927,7 +928,7 @@ static int reg_ioat(CPUS390XState *env, S390PCIIOMMU *iommu, ZpciFib fib, pba &= ~0xfff ; pal |=0xfff ; -if (pba > pal || pba <ZPCI_SDMA_ADDR || pal >ZPCI_EDMA_ADDR ) { +if (pba > pal || pba < pbdev->zpci_fn.sdma || pal > pbdev->zpci_fn.edma) {s390_program_interrupt (env,PGM_OPERAND , ra);return -EINVAL ; }
@@ -1125,7 +1126,7 @@ int mpcifc_service_call(S390CPU *cpu, uint8_t r1, uint64_t fiba, uint8_t ar, }else if (pbdev->iommu->enabled) { cc =ZPCI_PCI_LS_ERR ;s390_set_status_code (env, r1,ZPCI_MOD_ST_SEQUENCE ); - }else if (reg_ioat (env, pbdev->iommu, fib, ra)) { + }else if (reg_ioat (env, pbdev, fib, ra)) { cc =ZPCI_PCI_LS_ERR ;s390_set_status_code (env, r1,ZPCI_MOD_ST_INSUF_RES ); }
@@ -1150,7 +1151,7 @@ int mpcifc_service_call(S390CPU *cpu, uint8_t r1, uint64_t fiba, uint8_t ar,s390_set_status_code (env, r1,ZPCI_MOD_ST_SEQUENCE ); }else {pci_dereg_ioat (pbdev->iommu); -if (reg_ioat (env, pbdev->iommu, fib, ra)) { +if (reg_ioat (env, pbdev, fib, ra)) { cc =ZPCI_PCI_LS_ERR ;s390_set_status_code (env, r1,ZPCI_MOD_ST_INSUF_RES ); }
Signature · 1 line
2.27.0
PATCH v3 3/4 s390x/pci: use the passthrough measurement update interval
In reply to Matthew RosatoWe may have gotten a measurement update interval from the underlying host via vfio -- Use it to set the interval via which we update the function measurement block.
--- hw/s390x/s390-pci-inst.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
hw/s390x/s390-pci-inst.c +3 -2
@@ -1046,7 +1046,7 @@ static void fmb_update(void *opaque) sizeof(pbdev->fmb.last_update))) {return ; } -timer_mod (pbdev->fmb_timer, t +DEFAULT_MUI ); +timer_mod (pbdev->fmb_timer, t + pbdev->pci_group->zpci_group.mui); } int mpcifc_service_call(S390CPU *cpu, uint8_t r1, uint64_t fiba, uint8_t ar,
@@ -1204,7 +1204,8 @@ int mpcifc_service_call(S390CPU *cpu, uint8_t r1, uint64_t fiba, uint8_t ar, } pbdev->fmb_addr = fmb_addr;timer_mod (pbdev->fmb_timer, -qemu_clock_get_ms (QEMU_CLOCK_VIRTUAL ) +DEFAULT_MUI ); +qemu_clock_get_ms (QEMU_CLOCK_VIRTUAL ) + + pbdev->pci_group->zpci_group.mui);break ; }default :
Signature · 1 line
2.27.0
PATCH v3 4/4 s390x/pci: add supported DT information to clp response
In reply to Matthew RosatoThe DTSM is a mask that specifies which I/O Address Translation designation types are supported. Today QEMU only supports DT=1.
--- hw/s390x/s390-pci-bus.c | 1 + hw/s390x/s390-pci-inst.c | 1 + hw/s390x/s390-pci-vfio.c | 1 + include/hw/s390x/s390-pci-bus.h | 1 + include/hw/s390x/s390-pci-clp.h | 3 ++- 5 files changed, 6 insertions(+), 1 deletion(-)
hw/s390x/s390-pci-bus.c +1 -0
@@ -782,6 +782,7 @@ static void s390_pci_init_default_group(void) resgrp->i =128 ; resgrp->maxstbl =128 ; resgrp->version =0 ; + resgrp->dtsm =ZPCI_DTSM ; }static void set_pbdev_info (S390PCIBusDevice *pbdev)
hw/s390x/s390-pci-inst.c +1 -0
@@ -329,6 +329,7 @@ int clp_service_call(S390CPU *cpu, uint8_t r2, uintptr_t ra)stw_p (&resgrp->i, group->zpci_group.i);stw_p (&resgrp->maxstbl, group->zpci_group.maxstbl); resgrp->version = group->zpci_group.version; + resgrp->dtsm = group->zpci_group.dtsm;stw_p (&resgrp->hdr.rsp,CLP_RC_OK );break ; }
hw/s390x/s390-pci-vfio.c +1 -0
@@ -160,6 +160,7 @@ static void s390_pci_read_group(S390PCIBusDevice *pbdev, resgrp->i = cap->noi; resgrp->maxstbl = cap->maxstbl; resgrp->version = cap->version; + resgrp->dtsm =ZPCI_DTSM ; } }
include/hw/s390x/s390-pci-bus.h +1 -0
@@ -37,6 +37,7 @@#define ZPCI_MAX_UID 0xffff#define UID_UNDEFINED 0#define UID_CHECKING_ENABLED 0x01 +#define ZPCI_DTSM 0x40 OBJECT_DECLARE_SIMPLE_TYPE(S390pciState, S390_PCI_HOST_BRIDGE)OBJECT_DECLARE_SIMPLE_TYPE (S390PCIBus,S390_PCI_BUS )
include/hw/s390x/s390-pci-clp.h +2 -1
@@ -163,7 +163,8 @@ typedef struct ClpRspQueryPciGrp {uint8_t fr;uint16_t maxstbl;uint16_t mui; -uint64_t reserved3; +uint8_t dtsm; +uint8_t reserved3[7 ];uint64_t dasm;/* dma address space mask */ uint64_t msia;/* MSI address */ uint64_t reserved4;
Signature · 1 line
2.27.0
Re: [PATCH v3 4/4] s390x/pci: add supported DT information to clp response
Quoted 66 lines · Matthew Rosato
The DTSM is a mask that specifies which I/O Address Translation designation types are supported. Today QEMU only supports DT=1.
Signed-off-by Matthew Rosato <[email protected]>--- hw/s390x/s390-pci-bus.c | 1 + hw/s390x/s390-pci-inst.c | 1 + hw/s390x/s390-pci-vfio.c | 1 + include/hw/s390x/s390-pci-bus.h | 1 + include/hw/s390x/s390-pci-clp.h | 3 ++- 5 files changed, 6 insertions(+), 1 deletion(-)hw/s390x/s390-pci-bus.c +1
-0@@ -782,6 +782,7 @@ static void s390_pci_init_default_group(void) resgrp->i =128 ; resgrp->maxstbl =128 ; resgrp->version =0 ; + resgrp->dtsm =ZPCI_DTSM ; }static void set_pbdev_info (S390PCIBusDevice *pbdev)hw/s390x/s390-pci-inst.c +1
-0@@ -329,6 +329,7 @@ int clp_service_call(S390CPU *cpu, uint8_t r2, uintptr_t ra)stw_p (&resgrp->i, group->zpci_group.i);stw_p (&resgrp->maxstbl, group->zpci_group.maxstbl); resgrp->version = group->zpci_group.version; + resgrp->dtsm = group->zpci_group.dtsm;stw_p (&resgrp->hdr.rsp,CLP_RC_OK );break ; }hw/s390x/s390-pci-vfio.c +1
-0@@ -160,6 +160,7 @@ static void s390_pci_read_group(S390PCIBusDevice *pbdev, resgrp->i = cap->noi; resgrp->maxstbl = cap->maxstbl; resgrp->version = cap->version; + resgrp->dtsm =ZPCI_DTSM ; } }include/hw/s390x/s390-pci-bus.h +1
-0@@ -37,6 +37,7 @@#define ZPCI_MAX_UID 0xffff#define UID_UNDEFINED 0#define UID_CHECKING_ENABLED 0x01 +#define ZPCI_DTSM 0x40 OBJECT_DECLARE_SIMPLE_TYPE(S390pciState, S390_PCI_HOST_BRIDGE)OBJECT_DECLARE_SIMPLE_TYPE (S390PCIBus,S390_PCI_BUS )include/hw/s390x/s390-pci-clp.h +0
-0
include/hw/s390x/s390-pci-clp.h typedef struct ClpRspQueryPciGrp { · line 170
Quoted 9 lines
include/hw/s390x/s390-pci-clp.h +2
-1@@ -163,7 +163,8 @@ typedef struct ClpRspQueryPciGrp {uint8_t fr;uint16_t maxstbl;uint16_t mui; -uint64_t reserved3; +uint8_t dtsm; +uint8_t reserved3[7 ];uint64_t dasm;/* dma address space mask */ uint64_t msia;/* MSI address */ uint64_t reserved4;
Signature · 2 lines
Pierre Morel IBM Lab Boeblingen
Re: [PATCH v3 4/4] s390x/pci: add supported DT information to clp response
In reply to Matthew RosatoQuoted 5 lines · Matthew Rosato
The DTSM is a mask that specifies which I/O Address Translation designation
types are supported. Today QEMU only supports DT=1.Signed-off-by Matthew Rosato <[email protected]>
Quoted 74 lines
--- hw/s390x/s390-pci-bus.c | 1 + hw/s390x/s390-pci-inst.c | 1 + hw/s390x/s390-pci-vfio.c | 1 + include/hw/s390x/s390-pci-bus.h | 1 + include/hw/s390x/s390-pci-clp.h | 3 ++- 5 files changed, 6 insertions(+), 1 deletion(-)hw/s390x/s390-pci-bus.c +1
-0@@ -782,6 +782,7 @@ static void s390_pci_init_default_group(void) resgrp->i =128 ; resgrp->maxstbl =128 ; resgrp->version =0 ; + resgrp->dtsm =ZPCI_DTSM ; }static void set_pbdev_info (S390PCIBusDevice *pbdev)hw/s390x/s390-pci-inst.c +1
-0@@ -329,6 +329,7 @@ int clp_service_call(S390CPU *cpu, uint8_t r2, uintptr_t ra) stw_p(&resgrp->i, group->zpci_group.i);stw_p (&resgrp->maxstbl, group->zpci_group.maxstbl); resgrp->version = group->zpci_group.version; + resgrp->dtsm = group->zpci_group.dtsm;stw_p (&resgrp->hdr.rsp,CLP_RC_OK );break ;}hw/s390x/s390-pci-vfio.c +1
-0@@ -160,6 +160,7 @@ static void s390_pci_read_group(S390PCIBusDevice *pbdev, resgrp->i = cap->noi; resgrp->maxstbl = cap->maxstbl; resgrp->version = cap->version; + resgrp->dtsm =ZPCI_DTSM ; } }include/hw/s390x/s390- renamed from include/hw/s390x/s390-pci-bus.h +0
-0
pci-bus.h
index2727e7bdef..da3cde2bb4100644include/hw/s390x/s390-pci-bus.h +1
-0@@ -37,6 +37,7 @@#define ZPCI_MAX_UID 0xffff#define UID_UNDEFINED 0#define UID_CHECKING_ENABLED 0x01 +#define ZPCI_DTSM 0x40 OBJECT_DECLARE_SIMPLE_TYPE(S390pciState, S390_PCI_HOST_BRIDGE)OBJECT_DECLARE_SIMPLE_TYPE (S390PCIBus,S390_PCI_BUS )include/hw/s390x/s390- renamed from include/hw/s390x/s390-pci-clp.h +0
-0
pci-clp.h
index96b8e3f133..cc8c8662b8100644include/hw/s390x/s390-pci-clp.h +2
-1@@ -163,7 +163,8 @@ typedef struct ClpRspQueryPciGrp {uint8_t fr;uint16_t maxstbl;uint16_t mui; -uint64_t reserved3; +uint8_t dtsm; +uint8_t reserved3[7 ];uint64_t dasm;/* dma address space mask */ uint64_t msia;/* MSI address */ uint64_t reserved4;
Quoted 15 lines · Matthew Rosato
A collection of small fixes for s390x PCI (not urgent). The first 3 are fixes related to always using the host-provided CLP value when provided vs a hard-coded value. The last patch adds logic for QEMU to report a proper DTSM clp response rather than just 0s (guest linux doesn't look at this field today).
Changes for v3:
- Actually fix patch 4 this time (Pierre)Matthew Rosato (4):
s390x/pci: use a reserved ID for the default PCI group s390x/pci: don't use hard-coded dma range inreg_ioats390x/pci: use the passthrough measurement update interval s390x/pci: add supported DT information to clp response
Quoted 6 lines
hw/s390x/s390-pci-bus.c | 1 + hw/s390x/s390-pci-inst.c | 15 +++++++++------ hw/s390x/s390-pci-vfio.c | 1 + include/hw/s390x/s390-pci-bus.h | 3 ++- include/hw/s390x/s390-pci-clp.h | 3 ++- 5 files changed, 15 insertions(+), 8 deletions(-)
Thanks, I've queued the patches to my s390x-next branch now:
https://gitlab.com/thuth/qemu/-/commits/s390x-next/
Thomas