qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] target/arm: Fix sve_probe_page
@ 2023-01-04 19:00 Richard Henderson
  2023-01-04 19:36 ` Philippe Mathieu-Daudé
  2023-01-06 16:07 ` Peter Maydell
  0 siblings, 2 replies; 3+ messages in thread
From: Richard Henderson @ 2023-01-04 19:00 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-arm, idan.horowitz, qemu-stable

Don't dereference CPUTLBEntryFull until we verify that
the page is valid.  Move the other user-only info field
updates after the valid check to match.

Cc: qemu-stable@nongnu.org
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1412
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 target/arm/sve_helper.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c
index 1afeadf9c8..521fc9b969 100644
--- a/target/arm/sve_helper.c
+++ b/target/arm/sve_helper.c
@@ -5354,15 +5354,10 @@ bool sve_probe_page(SVEHostPage *info, bool nofault, CPUARMState *env,
 #ifdef CONFIG_USER_ONLY
     flags = probe_access_flags(env, addr, access_type, mmu_idx, nofault,
                                &info->host, retaddr);
-    memset(&info->attrs, 0, sizeof(info->attrs));
-    /* Require both ANON and MTE; see allocation_tag_mem(). */
-    info->tagged = (flags & PAGE_ANON) && (flags & PAGE_MTE);
 #else
     CPUTLBEntryFull *full;
     flags = probe_access_full(env, addr, access_type, mmu_idx, nofault,
                               &info->host, &full, retaddr);
-    info->attrs = full->attrs;
-    info->tagged = full->pte_attrs == 0xf0;
 #endif
     info->flags = flags;
 
@@ -5371,6 +5366,15 @@ bool sve_probe_page(SVEHostPage *info, bool nofault, CPUARMState *env,
         return false;
     }
 
+#ifdef CONFIG_USER_ONLY
+    memset(&info->attrs, 0, sizeof(info->attrs));
+    /* Require both ANON and MTE; see allocation_tag_mem(). */
+    info->tagged = (flags & PAGE_ANON) && (flags & PAGE_MTE);
+#else
+    info->attrs = full->attrs;
+    info->tagged = full->pte_attrs == 0xf0;
+#endif
+
     /* Ensure that info->host[] is relative to addr, not addr + mem_off. */
     info->host -= mem_off;
     return true;
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] target/arm: Fix sve_probe_page
  2023-01-04 19:00 [PATCH] target/arm: Fix sve_probe_page Richard Henderson
@ 2023-01-04 19:36 ` Philippe Mathieu-Daudé
  2023-01-06 16:07 ` Peter Maydell
  1 sibling, 0 replies; 3+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-01-04 19:36 UTC (permalink / raw)
  To: Richard Henderson, qemu-devel; +Cc: qemu-arm, idan.horowitz, qemu-stable

On 4/1/23 20:00, Richard Henderson wrote:
> Don't dereference CPUTLBEntryFull until we verify that
> the page is valid.  Move the other user-only info field
> updates after the valid check to match.

Easy one :)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>

> Cc: qemu-stable@nongnu.org
> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1412
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>   target/arm/sve_helper.c | 14 +++++++++-----
>   1 file changed, 9 insertions(+), 5 deletions(-)


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] target/arm: Fix sve_probe_page
  2023-01-04 19:00 [PATCH] target/arm: Fix sve_probe_page Richard Henderson
  2023-01-04 19:36 ` Philippe Mathieu-Daudé
@ 2023-01-06 16:07 ` Peter Maydell
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Maydell @ 2023-01-06 16:07 UTC (permalink / raw)
  To: Richard Henderson; +Cc: qemu-devel, qemu-arm, idan.horowitz, qemu-stable

On Wed, 4 Jan 2023 at 19:01, Richard Henderson
<richard.henderson@linaro.org> wrote:
>
> Don't dereference CPUTLBEntryFull until we verify that
> the page is valid.  Move the other user-only info field
> updates after the valid check to match.
>
> Cc: qemu-stable@nongnu.org
> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1412
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>  target/arm/sve_helper.c | 14 +++++++++-----



Applied to target-arm.next, thanks.

-- PMM


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-01-06 16:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-04 19:00 [PATCH] target/arm: Fix sve_probe_page Richard Henderson
2023-01-04 19:36 ` Philippe Mathieu-Daudé
2023-01-06 16:07 ` Peter Maydell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).