qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] target/hppa: Check for page crossings in use_goto_tb
@ 2019-03-08 18:59 Richard Henderson
  2019-03-08 19:04 ` Peter Maydell
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Henderson @ 2019-03-08 18:59 UTC (permalink / raw)
  To: qemu-devel; +Cc: svens

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.

Reported-by: Sven Schnelle <svens@stackframe.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 target/hppa/translate.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/target/hppa/translate.c b/target/hppa/translate.c
index dc5636fe94..6c815e05c2 100644
--- a/target/hppa/translate.c
+++ b/target/hppa/translate.c
@@ -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,
-- 
2.17.2

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

* Re: [Qemu-devel] [PATCH] target/hppa: Check for page crossings in use_goto_tb
  2019-03-08 18:59 [Qemu-devel] [PATCH] target/hppa: Check for page crossings in use_goto_tb Richard Henderson
@ 2019-03-08 19:04 ` Peter Maydell
  2019-03-08 19:15   ` Richard Henderson
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Maydell @ 2019-03-08 19:04 UTC (permalink / raw)
  To: Richard Henderson; +Cc: QEMU Developers, Sven Schnelle

On Fri, 8 Mar 2019 at 19:00, Richard Henderson
<richard.henderson@linaro.org> wrote:
>
> 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.
>
> Reported-by: Sven Schnelle <svens@stackframe.org>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>  target/hppa/translate.c | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/target/hppa/translate.c b/target/hppa/translate.c
> index dc5636fe94..6c815e05c2 100644
> --- a/target/hppa/translate.c
> +++ b/target/hppa/translate.c
> @@ -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"

> +    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.

>
>  /* If the next insn is to be nullified, and it's on the same page,
> --
> 2.17.2

thanks
-- PMM

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

* Re: [Qemu-devel] [PATCH] target/hppa: Check for page crossings in use_goto_tb
  2019-03-08 19:04 ` Peter Maydell
@ 2019-03-08 19:15   ` Richard Henderson
  0 siblings, 0 replies; 3+ messages in thread
From: Richard Henderson @ 2019-03-08 19:15 UTC (permalink / raw)
  To: Peter Maydell; +Cc: QEMU Developers, Sven Schnelle

On 3/8/19 11:04 AM, Peter Maydell wrote:
> On Fri, 8 Mar 2019 at 19:00, Richard Henderson
> <richard.henderson@linaro.org> wrote:
>>
>> 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.
>>
>> Reported-by: Sven Schnelle <svens@stackframe.org>
>> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
>> ---
>>  target/hppa/translate.c | 10 ++++------
>>  1 file changed, 4 insertions(+), 6 deletions(-)
>>
>> diff --git a/target/hppa/translate.c b/target/hppa/translate.c
>> index dc5636fe94..6c815e05c2 100644
>> --- a/target/hppa/translate.c
>> +++ b/target/hppa/translate.c
>> @@ -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"

Oops.

>> +    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.

> 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~

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

end of thread, other threads:[~2019-03-08 19:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-03-08 18:59 [Qemu-devel] [PATCH] target/hppa: Check for page crossings in use_goto_tb Richard Henderson
2019-03-08 19:04 ` Peter Maydell
2019-03-08 19:15   ` Richard Henderson

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).