[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[qemu-s390x] [PULL 28/33] s390x/tcg: Provide probe_write_access helper
From: |
Cornelia Huck |
Subject: |
[qemu-s390x] [PULL 28/33] s390x/tcg: Provide probe_write_access helper |
Date: |
Mon, 11 Mar 2019 10:03:17 +0100 |
From: David Hildenbrand <address@hidden>
Instead of checking e.g. the first access on every touched page, we should
check the actual access, otherwise we might get false positives when Low
Address Protection (LAP) is active. As probe_write() can only deal with
accesses to one page, we have to loop.
Use i64 for the length, although not needed - easier to reuse
TCG temps we already have in the translation functions where this will
be used. Also allow it to be used from other helpers.
Signed-off-by: David Hildenbrand <address@hidden>
Message-Id: <address@hidden>
[CH: add missing page_check_range()]
Reviewed-by: Richard Henderson <address@hidden>
Signed-off-by: Cornelia Huck <address@hidden>
---
target/s390x/helper.h | 1 +
target/s390x/internal.h | 2 ++
target/s390x/mem_helper.c | 26 ++++++++++++++++++++++++++
3 files changed, 29 insertions(+)
diff --git a/target/s390x/helper.h b/target/s390x/helper.h
index 577edb384fe6..e2710f4fb33b 100644
--- a/target/s390x/helper.h
+++ b/target/s390x/helper.h
@@ -123,6 +123,7 @@ DEF_HELPER_4(cu42, i32, env, i32, i32, i32)
DEF_HELPER_5(msa, i32, env, i32, i32, i32, i32)
DEF_HELPER_FLAGS_1(stpt, TCG_CALL_NO_RWG, i64, env)
DEF_HELPER_FLAGS_1(stck, TCG_CALL_NO_RWG_SE, i64, env)
+DEF_HELPER_FLAGS_3(probe_write_access, TCG_CALL_NO_WG, void, env, i64, i64)
/* === Vector Support Instructions === */
DEF_HELPER_FLAGS_4(vll, TCG_CALL_NO_WG, void, env, ptr, i64, i64)
diff --git a/target/s390x/internal.h b/target/s390x/internal.h
index 07b69b8ea000..3b4855c17502 100644
--- a/target/s390x/internal.h
+++ b/target/s390x/internal.h
@@ -349,6 +349,8 @@ void ioinst_handle_sal(S390CPU *cpu, uint64_t reg1,
uintptr_t ra);
/* mem_helper.c */
target_ulong mmu_real2abs(CPUS390XState *env, target_ulong raddr);
+void probe_write_access(CPUS390XState *env, uint64_t addr, uint64_t len,
+ uintptr_t ra);
/* mmu_helper.c */
diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c
index a506d9ef99f7..3f76a8abfd37 100644
--- a/target/s390x/mem_helper.c
+++ b/target/s390x/mem_helper.c
@@ -2623,3 +2623,29 @@ uint32_t HELPER(cu42)(CPUS390XState *env, uint32_t r1,
uint32_t r2, uint32_t m3)
return convert_unicode(env, r1, r2, m3, GETPC(),
decode_utf32, encode_utf16);
}
+
+void probe_write_access(CPUS390XState *env, uint64_t addr, uint64_t len,
+ uintptr_t ra)
+{
+#ifdef CONFIG_USER_ONLY
+ if (!h2g_valid(addr) || !h2g_valid(addr + len - 1) ||
+ page_check_range(addr, len, PAGE_WRITE) < 0) {
+ s390_program_interrupt(env, PGM_ADDRESSING, ILEN_AUTO, ra);
+ }
+#else
+ /* test the actual access, not just any access to the page due to LAP */
+ while (len) {
+ const uint64_t pagelen = -(addr | -TARGET_PAGE_MASK);
+ const uint64_t curlen = MIN(pagelen, len);
+
+ probe_write(env, addr, curlen, cpu_mmu_index(env, false), ra);
+ addr = wrap_address(env, addr + curlen);
+ len -= curlen;
+ }
+#endif
+}
+
+void HELPER(probe_write_access)(CPUS390XState *env, uint64_t addr, uint64_t
len)
+{
+ probe_write_access(env, addr, len, GETPC());
+}
--
2.17.2
- [qemu-s390x] [PULL 16/33] s390x/tcg: Implement VECTOR LOAD VR ELEMENT FROM GR, (continued)
- [qemu-s390x] [PULL 16/33] s390x/tcg: Implement VECTOR LOAD VR ELEMENT FROM GR, Cornelia Huck, 2019/03/11
- [qemu-s390x] [PULL 19/33] s390x/tcg: Implement VECTOR MERGE (HIGH|LOW), Cornelia Huck, 2019/03/11
- [qemu-s390x] [PULL 20/33] s390x/tcg: Implement VECTOR PACK *, Cornelia Huck, 2019/03/11
- [qemu-s390x] [PULL 21/33] s390x/tcg: Implement VECTOR PERMUTE, Cornelia Huck, 2019/03/11
- [qemu-s390x] [PULL 22/33] s390x/tcg: Implement VECTOR PERMUTE DOUBLEWORD IMMEDIATE, Cornelia Huck, 2019/03/11
- [qemu-s390x] [PULL 23/33] s390x/tcg: Implement VECTOR REPLICATE, Cornelia Huck, 2019/03/11
- [qemu-s390x] [PULL 25/33] s390x/tcg: Implement VECTOR SCATTER ELEMENT, Cornelia Huck, 2019/03/11
- [qemu-s390x] [PULL 24/33] s390x/tcg: Implement VECTOR REPLICATE IMMEDIATE, Cornelia Huck, 2019/03/11
- [qemu-s390x] [PULL 26/33] s390x/tcg: Implement VECTOR SELECT, Cornelia Huck, 2019/03/11
- [qemu-s390x] [PULL 27/33] s390x/tcg: Implement VECTOR SIGN EXTEND TO DOUBLEWORD, Cornelia Huck, 2019/03/11
- [qemu-s390x] [PULL 28/33] s390x/tcg: Provide probe_write_access helper,
Cornelia Huck <=
- [qemu-s390x] [PULL 29/33] s390x/tcg: Implement VECTOR STORE, Cornelia Huck, 2019/03/11
- [qemu-s390x] [PULL 31/33] s390x/tcg: Implement VECTOR STORE MULTIPLE, Cornelia Huck, 2019/03/11
- [qemu-s390x] [PULL 30/33] s390x/tcg: Implement VECTOR STORE ELEMENT, Cornelia Huck, 2019/03/11
- [qemu-s390x] [PULL 33/33] s390x/tcg: Implement VECTOR UNPACK *, Cornelia Huck, 2019/03/11
- [qemu-s390x] [PULL 32/33] s390x/tcg: Implement VECTOR STORE WITH LENGTH, Cornelia Huck, 2019/03/11
- [qemu-s390x] [PULL 18/33] s390x/tcg: Implement VECTOR LOAD WITH LENGTH, Cornelia Huck, 2019/03/11
- Re: [qemu-s390x] [Qemu-devel] [PULL 00/33] final s390x patches for 4.0 soft freeze, no-reply, 2019/03/11
- Re: [qemu-s390x] [PULL 00/33] final s390x patches for 4.0 soft freeze, Peter Maydell, 2019/03/11