Skip to contentSkip to conversation

target/s390x/tcg: SPX: check validity of new prefix

PATCH In review Janis Schoetterl-Glausch 2 participants 2 messages Jun 30, 2022 – Jul 6, 2022

lore
Share & tools
lore
#0 lore raw

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
index aab9c47747..10dadb002a 100644
@@ -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
#1 lore raw
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 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 +0 -0
index aab9c47747..10dadb002a 100644
@@ -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