Skip to contentSkip to conversation

target/hppa: Check for page crossings in use_goto_tb

PATCH In review Richard Henderson 2 participants 3 messages Mar 8, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target/hppa: Check for page crossings in use_goto_tb

We got away with eliding this check when target/hppa was user-only, but missed adding this check when adding system support.

Fixes an early crash in the HP-UX 11 installer.

---
 target/hppa/translate.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
target/hppa/translate.c +4 -6
index dc5636fe94..6c815e05c2 100644
@@ -816,12 +816,10 @@ static bool gen_illegal(DisasContext *ctx)
 
 static bool use_goto_tb(DisasContext *ctx, target_ureg dest)
 {
-    /* Suppress goto_tb in the case of single-steping and IO.  */
-    if ((tb_cflags(ctx->base.tb) & CF_LAST_IO)
-        || ctx->base.singlestep_enabled) {
-        return false;
-    }
-    return true;
+    /* Suppress goto_tb for page crossing, IO, or single-steping.  */
+    return !(((ctx->base.pc_first ^ dest) & TARGET_PAGE_MASK)
+             || (tb_cflags(ctx->base.tb) & CF_LAST_IO)
+             || ctx->base.singlestep_enabled);
 }
 
 /* If the next insn is to be nullified, and it's on the same page,
Signature · 1 line
2.17.2
#1 lore raw
Quoted 17 lines · Richard Henderson

We got away with eliding this check when target/hppa was user-only, but missed adding this check when adding system support.

Fixes an early crash in the HP-UX 11 installer.

---
 target/hppa/translate.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
target/hppa/translate.c +0 -0
index dc5636fe94..6c815e05c2 100644

target/hppa/translate.c static bool gen_illegal(DisasContext *ctx) · line 819

Quoted 10 lines
target/hppa/translate.c +1 -6
@@ -816,12 +816,10 @@ static bool gen_illegal(DisasContext *ctx)
 
 static bool use_goto_tb(DisasContext *ctx, target_ureg dest)
 {
-    /* Suppress goto_tb in the case of single-steping and IO.  */
-    if ((tb_cflags(ctx->base.tb) & CF_LAST_IO)
-        || ctx->base.singlestep_enabled) {
-        return false;
-    }
-    return true;
+    /* Suppress goto_tb for page crossing, IO, or single-steping.  */

"stepping"

target/hppa/translate.c static bool gen_illegal(DisasContext *ctx) · line 823

Quoted 4 lines
target/hppa/translate.c +3 -0
+    return !(((ctx->base.pc_first ^ dest) & TARGET_PAGE_MASK)
+             || (tb_cflags(ctx->base.tb) & CF_LAST_IO)
+             || ctx->base.singlestep_enabled);
 }

I note that (a) this isn't the way every other port phrases the "same page" check -- they generally use something like
(ctx->base.tb->pc & TARGET_PAGE_MASK) == (dest & TARGET_PAGE_MASK)
and (b) the other ports generally keep that check inside an ifndef CONFIG_USER_ONLY.

Quoted 4 lines
target/hppa/translate.c +0 -1
 /* If the next insn is to be nullified, and it's on the same page,
--

2.17.2

thanks
-- PMM

#2 lore raw
Quoted 20 lines · Peter Maydell
Quoted 18 lines · Richard Henderson

We got away with eliding this check when target/hppa was user-only, but missed adding this check when adding system support.

Fixes an early crash in the HP-UX 11 installer.

---
 target/hppa/translate.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
target/hppa/translate.c +0 -0
index dc5636fe94..6c815e05c2 100644
@@ -816,12 +816,10 @@ static bool gen_illegal(DisasContext *ctx)
 
Quoted 11 lines

target/hppa/translate.c static bool gen_illegal(DisasContext *ctx) · line 819

Quoted 9 lines
target/hppa/translate.c +1 -6
 static bool use_goto_tb(DisasContext *ctx, target_ureg dest)
 {
-    /* Suppress goto_tb in the case of single-steping and IO.  */
-    if ((tb_cflags(ctx->base.tb) & CF_LAST_IO)
-        || ctx->base.singlestep_enabled) {
-        return false;
-    }
-    return true;
+    /* Suppress goto_tb for page crossing, IO, or single-steping.  */

"stepping"

Oops.

Quoted 8 lines

target/hppa/translate.c static bool gen_illegal(DisasContext *ctx) · line 823

Quoted 4 lines
target/hppa/translate.c +3 -0
+    return !(((ctx->base.pc_first ^ dest) & TARGET_PAGE_MASK)
+             || (tb_cflags(ctx->base.tb) & CF_LAST_IO)
+             || ctx->base.singlestep_enabled);
 }

I note that (a) this isn't the way every other port phrases the "same page" check -- they generally use something like
(ctx->base.tb->pc & TARGET_PAGE_MASK) == (dest & TARGET_PAGE_MASK)

This should be the same result.

ctx->base.pc_first was initialized from tb->pc. I find the xor expression more compact and usually fits on a line, where repeating TARGET_PAGE_MASK doesn't.

Quoted 2 lines

and (b) the other ports generally keep that check inside an ifndef CONFIG_USER_ONLY.

I've wondered about that. It certainly works for normal executables, but I wonder if there are jit-like cases that fail when eliding that check.

Here, I think I was just a bit lazy.

Thoughts?

r~