diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c index ef20f7645e..b7de23c7d2 100644 --- a/hw/s390x/s390-pci-inst.c +++ b/hw/s390x/s390-pci-inst.c @@ -770,10 +770,16 @@ int rpcit_service_call(S390CPU *cpu, uint8_t r1, uint8_t r2, uintptr_t ra) goto err; } - if (end < iommu->pba || start > iommu->pal) { + if (end < start || end < iommu->pba || start > iommu->pal) { error = ERR_EVENT_OORANGE; goto err; } + /* + * If the specified range at least partially overlaps the registered + * aperture, clamp the request to the aperture and ignore the rest. + */ + sstart = MAX(start, iommu->pba); + end = MIN(end, iommu->pal + 1); retry: start = sstart;