aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Rosato <mjrosato@linux.ibm.com>2020-12-17 17:16:37 -0500
committerCornelia Huck <cohuck@redhat.com>2020-12-21 18:11:33 +0100
commitb3834073dad120a7ffddc22fd860acf967b62150 (patch)
tree2275ac13477bafdbc6652b410d6834f5c3d19e50
parent704d7a2304d890a570b722e20bd66e5e6303b7d9 (diff)
downloadqemu-b3834073dad120a7ffddc22fd860acf967b62150.zip
qemu-b3834073dad120a7ffddc22fd860acf967b62150.tar.gz
qemu-b3834073dad120a7ffddc22fd860acf967b62150.tar.bz2
s390x/pci: Fix memory_region_access_valid call
In pcistb_service_handler, a call is made to validate that the memory region can be accessed. However, the call is made using the entire length of the pcistb operation, which can be larger than the allowed memory access size (8). Since we already know that the provided buffer is a multiple of 8, fix the call to memory_region_access_valid to iterate over the memory region in the same way as the subsequent call to memory_region_dispatch_write. Fixes: 863f6f52b7 ("s390: implement pci instructions") Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Acked-by: Pierre Morel <pmorel@linux.ibm.com> Message-Id: <1608243397-29428-3-git-send-email-mjrosato@linux.ibm.com> Signed-off-by: Cornelia Huck <cohuck@redhat.com>
-rw-r--r--hw/s390x/s390-pci-inst.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c
index e230293..76b08a3 100644
--- a/hw/s390x/s390-pci-inst.c
+++ b/hw/s390x/s390-pci-inst.c
@@ -821,10 +821,12 @@ int pcistb_service_call(S390CPU *cpu, uint8_t r1, uint8_t r3, uint64_t gaddr,
mr = s390_get_subregion(mr, offset, len);
offset -= mr->addr;
- if (!memory_region_access_valid(mr, offset, len, true,
- MEMTXATTRS_UNSPECIFIED)) {
- s390_program_interrupt(env, PGM_OPERAND, ra);
- return 0;
+ for (i = 0; i < len; i += 8) {
+ if (!memory_region_access_valid(mr, offset + i, 8, true,
+ MEMTXATTRS_UNSPECIFIED)) {
+ s390_program_interrupt(env, PGM_OPERAND, ra);
+ return 0;
+ }
}
if (s390_cpu_virt_mem_read(cpu, gaddr, ar, buffer, len)) {