[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 13/14] s390x/pci: Fix memory_region_access_valid call
From: |
Cornelia Huck |
Subject: |
[PULL 13/14] s390x/pci: Fix memory_region_access_valid call |
Date: |
Tue, 22 Dec 2020 11:45:02 +0100 |
From: Matthew Rosato <mjrosato@linux.ibm.com>
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>
---
hw/s390x/s390-pci-inst.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c
index e23029399886..76b08a39a738 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)) {
--
2.26.2
- [PULL 01/14] s390x: pv: Fence additional unavailable SCLP facilities for PV guests, (continued)
- [PULL 01/14] s390x: pv: Fence additional unavailable SCLP facilities for PV guests, Cornelia Huck, 2020/12/22
- [PULL 04/14] target/s390x: Improve cc computation for ADD LOGICAL, Cornelia Huck, 2020/12/22
- [PULL 07/14] target/s390x: Improve SUB LOGICAL WITH BORROW, Cornelia Huck, 2020/12/22
- [PULL 05/14] target/s390x: Improve ADD LOGICAL WITH CARRY, Cornelia Huck, 2020/12/22
- [PULL 06/14] target/s390x: Improve cc computation for SUBTRACT LOGICAL, Cornelia Huck, 2020/12/22
- [PULL 08/14] tests/acceptance: test hot(un)plug of ccw devices, Cornelia Huck, 2020/12/22
- [PULL 09/14] tests/acceptance: Extract the code to clear dmesg and wait for CRW reports, Cornelia Huck, 2020/12/22
- [PULL 11/14] tests/acceptance: Test the virtio-balloon device on s390x, Cornelia Huck, 2020/12/22
- [PULL 10/14] tests/acceptance: Test virtio-rng on s390 via /dev/hwrng, Cornelia Huck, 2020/12/22
- [PULL 12/14] s390x/pci: fix pcistb length, Cornelia Huck, 2020/12/22
- [PULL 13/14] s390x/pci: Fix memory_region_access_valid call,
Cornelia Huck <=
- [PULL 14/14] tests/acceptance: Add a test with the Fedora 31 kernel and initrd, Cornelia Huck, 2020/12/22