[PATCH v2] target/s390x/tcg: SPX: check validity of new prefix

Janis Schoetterl-Glausch posted 1 patch 3 years, 7 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20220630094340.3646279-1-scgl@linux.ibm.com
Maintainers: Richard Henderson <richard.henderson@linaro.org>, David Hildenbrand <david@redhat.com>, Cornelia Huck <cohuck@redhat.com>, Thomas Huth <thuth@redhat.com>
target/s390x/tcg/misc_helper.c | 7 +++++++
1 file changed, 7 insertions(+)
[PATCH v2] target/s390x/tcg: SPX: check validity of new prefix
Posted by Janis Schoetterl-Glausch 3 years, 7 months ago
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.

Signed-off-by: Janis Schoetterl-Glausch <scgl@linux.ibm.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
---
 target/s390x/tcg/misc_helper.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/target/s390x/tcg/misc_helper.c b/target/s390x/tcg/misc_helper.c
index aab9c47747..10dadb002a 100644
--- a/target/s390x/tcg/misc_helper.c
+++ b/target/s390x/tcg/misc_helper.c
@@ -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
-- 
2.36.1
Re: [PATCH v2] target/s390x/tcg: SPX: check validity of new prefix
Posted by Thomas Huth 3 years, 7 months ago
On 30/06/2022 11.43, Janis Schoetterl-Glausch wrote:
> 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.
> 
> Signed-off-by: Janis Schoetterl-Glausch <scgl@linux.ibm.com>
> Reviewed-by: David Hildenbrand <david@redhat.com>
> ---
>   target/s390x/tcg/misc_helper.c | 7 +++++++
>   1 file changed, 7 insertions(+)
> 
> diff --git a/target/s390x/tcg/misc_helper.c b/target/s390x/tcg/misc_helper.c
> index aab9c47747..10dadb002a 100644
> --- a/target/s390x/tcg/misc_helper.c
> +++ b/target/s390x/tcg/misc_helper.c
> @@ -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);

Thanks, queued to my s390x-next branch now:

  https://gitlab.com/thuth/qemu/-/commits/s390x-next

  Thomas