summaryrefslogtreecommitdiff
path: root/target/s390x/mem_helper.c
diff options
context:
space:
mode:
authorDavid Hildenbrand <david@redhat.com>2018-01-12 13:54:52 +0100
committerCornelia Huck <cohuck@redhat.com>2018-01-22 11:04:52 +0100
commitb5e85329026115b5a679849f45e7c19c2714e4fd (patch)
tree4e1b8e2008a670e87e2b4c65b50c9c4ab301788a /target/s390x/mem_helper.c
parent46fa893355e0bd88f3c59b886f0d75cbd5f0bbbe (diff)
downloadqemu-b5e85329026115b5a679849f45e7c19c2714e4fd.tar.gz
s390x/tcg: fixup TEST PROTECTION
CC == 2 can only happen due to a protection exception, not if memory is not available (PGM_ADDRESSING). So all PGM_ADDRESSING exceptions have to be forwarded to the guest. Since the initial definition of TEST PROTECTION, we now read globals (e.g. PSW mask), so we have to correctly mark the instruction (otherwise, e.g. booting fedora 27 fails). Also, the architecture explicitly specifies which exceptions are forwarded to the guest, this makes the code a little nicer. Signed-off-by: David Hildenbrand <david@redhat.com> Message-Id: <20180112125452.8569-1-david@redhat.com> Signed-off-by: Cornelia Huck <cohuck@redhat.com>
Diffstat (limited to 'target/s390x/mem_helper.c')
-rw-r--r--target/s390x/mem_helper.c41
1 files changed, 19 insertions, 22 deletions
diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c
index 359e446c6f..c957febc6d 100644
--- a/target/s390x/mem_helper.c
+++ b/target/s390x/mem_helper.c
@@ -1730,34 +1730,31 @@ uint32_t HELPER(tprot)(CPUS390XState *env, uint64_t a1, uint64_t a2)
/* Fetching permitted; storing permitted */
return 0;
}
+
+ if (env->int_pgm_code == PGM_PROTECTION) {
+ /* retry if reading is possible */
+ cs->exception_index = 0;
+ if (!s390_cpu_virt_mem_check_read(cpu, a1, 0, 1)) {
+ /* Fetching permitted; storing not permitted */
+ return 1;
+ }
+ }
+
switch (env->int_pgm_code) {
case PGM_PROTECTION:
- /* Fetching permitted; storing not permitted */
- cs->exception_index = 0;
- return 1;
- case PGM_ADDRESSING:
/* Fetching not permitted; storing not permitted */
cs->exception_index = 0;
return 2;
- case PGM_ASCE_TYPE:
- case PGM_REG_FIRST_TRANS:
- case PGM_REG_SEC_TRANS:
- case PGM_REG_THIRD_TRANS:
- case PGM_SEGMENT_TRANS:
- case PGM_PAGE_TRANS:
- case PGM_ALET_SPEC:
- case PGM_ALEN_SPEC:
- case PGM_ALE_SEQ:
- case PGM_ASTE_VALID:
- case PGM_ASTE_SEQ:
- case PGM_EXT_AUTH:
- /* Translation not available */
- cs->exception_index = 0;
- return 3;
+ case PGM_ADDRESSING:
+ case PGM_TRANS_SPEC:
+ /* exceptions forwarded to the guest */
+ s390_cpu_virt_mem_handle_exc(cpu, GETPC());
+ return 0;
}
- /* any other exception is forwarded to the guest */
- s390_cpu_virt_mem_handle_exc(cpu, GETPC());
- return 0;
+
+ /* Translation not available */
+ cs->exception_index = 0;
+ return 3;
}
/* insert storage key extended */