target/s390x/tcg: SPX: check validity of new prefix
PATCH v2 1/1 target/s390x/tcg: SPX: check validity of new prefix
According to the architecture, SET PREFIX must try to access the new prefix area and recognize an addressing exception if the area is not accessible.
For qemu this check prevents a crash in cpu_map_lowcore after an inaccessible prefix area has been set.
--- target/s390x/tcg/misc_helper.c | 7 +++++++ 1 file changed, 7 insertions(+)
target/s390x/tcg/misc_helper.c +7 -0
@@ -158,6 +158,13 @@ void HELPER(spx)(CPUS390XState *env, uint64_t a1)if (prefix == old_prefix) {return ; } +/* +* Since prefix got aligned to 8k and memory increments are a multiple of +* 8k checking the first page is sufficient +*/ +if (!mmu_absolute_addr_valid (prefix, true)) { +tcg_s390_program_interrupt (env,PGM_ADDRESSING ,GETPC ()); + } env->psa = prefix;HELPER_LOG ("prefix: %#x\n" , prefix);
base-commit: 3a821c52e1a30ecd9a436f2c67cc66b5628c829f
Signature · 1 line
2.36.1
Quoted 20 lines · Janis Schoetterl-Glausch
According to the architecture, SET PREFIX must try to access the new prefix area and recognize an addressing exception if the area is not accessible.
For qemu this check prevents a crash incpu_map_lowcoreafter an inaccessible prefix area has been set.Signed-off-by Janis Schoetterl-Glausch <[email protected]>Reviewed-by David Hildenbrand <[email protected]>--- target/s390x/tcg/misc_helper.c | 7 +++++++ 1 file changed, 7 insertions(+)target/s390x/tcg/misc_helper.c +0
-0@@ -158,6 +158,13 @@ void HELPER(spx)(CPUS390XState *env, uint64_t a1)if (prefix == old_prefix) {return ; }
target/s390x/tcg/misc_helper.c void HELPER(spx)(CPUS390XState *env, uint64_t a1) · line 170
Quoted 10 lines
target/s390x/tcg/misc_helper.c +7
-0+/* +* Since prefix got aligned to 8k and memory increments are a multiple of +* 8k checking the first page is sufficient +*/ +if (!mmu_absolute_addr_valid (prefix, true)) { +tcg_s390_program_interrupt (env,PGM_ADDRESSING ,GETPC ()); + } env->psa = prefix;HELPER_LOG ("prefix: %#x\n" , prefix);
Thanks, queued to my s390x-next branch now:
https://gitlab.com/thuth/qemu/-/commits/s390x-next
Thomas