qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: Ilya Leoshkevich <iii@linux.ibm.com>,
	David Hildenbrand <david@redhat.com>,
	Thomas Huth <thuth@redhat.com>
Cc: qemu-devel@nongnu.org, qemu-s390x@nongnu.org,
	Nina Schoetterl-Glausch <nsg@linux.ibm.com>
Subject: Re: [PATCH 1/2] target/s390x: Fix EXECUTE of relative branches
Date: Thu, 27 Apr 2023 13:38:34 +0100	[thread overview]
Message-ID: <5d1f7e80-adeb-f15a-bae2-c71c26450d93@linaro.org> (raw)
In-Reply-To: <20230426235813.198183-2-iii@linux.ibm.com>

On 4/27/23 00:58, Ilya Leoshkevich wrote:
> Fix a problem similar to the one fixed by commit 703d03a4aaf3
> ("target/s390x: Fix EXECUTE of relative long instructions"), but now
> for relative branches.
> 
> Reported-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
> Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
> ---
>   target/s390x/tcg/translate.c | 81 ++++++++++++++++++++++++++----------
>   1 file changed, 58 insertions(+), 23 deletions(-)
> 
> diff --git a/target/s390x/tcg/translate.c b/target/s390x/tcg/translate.c
> index 46b874e94da..2a681428af1 100644
> --- a/target/s390x/tcg/translate.c
> +++ b/target/s390x/tcg/translate.c
> @@ -1534,18 +1534,51 @@ static DisasJumpType op_bal(DisasContext *s, DisasOps *o)
>       }
>   }
>   
> +/*
> + * Disassemble the target of a branch. The results are returned in a form
> + * suitable for passing into help_branch():
> + *
> + * - bool IS_IMM reflects whether the target is fixed or computed. Non-EXECUTEd
> + *   branches, whose DisasContext *S contains the relative immediate field RI,
> + *   are considered fixed. All the other branches are considered computed.
> + * - int IMM is the value of RI.
> + * - TCGv_i64 CDEST is the address of the computed target.
> + */
> +#define disas_jdest(s, ri, is_imm, imm, cdest) do {                            \
> +    if (have_field(s, ri)) {                                                   \
> +        if (unlikely(s->ex_value)) {                                           \
> +            cdest = tcg_temp_new_i64();                                        \
> +            tcg_gen_ld_i64(cdest, cpu_env, offsetof(CPUS390XState, ex_target));\
> +            tcg_gen_addi_i64(cdest, cdest, (int64_t)get_field(s, ri) * 2);     \
> +            is_imm = false;                                                    \
> +        } else {                                                               \
> +            is_imm = true;                                                     \
> +        }                                                                      \
> +    } else {                                                                   \
> +        is_imm = false;                                                        \
> +    }                                                                          \
> +    imm = is_imm ? get_field(s, ri) : 0;                                       \
> +} while (false)

I'm not especially fond of the macro, but given the variable field, I don't know how else 
to structure it.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~


  reply	other threads:[~2023-04-27 12:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-26 23:58 [PATCH 0/2] target/s390x: Fix EXECUTE of relative branches Ilya Leoshkevich
2023-04-26 23:58 ` [PATCH 1/2] " Ilya Leoshkevich
2023-04-27 12:38   ` Richard Henderson [this message]
2023-04-26 23:58 ` [PATCH 2/2] tests/tcg/s390x: Test " Ilya Leoshkevich
2023-04-27 12:40   ` Richard Henderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5d1f7e80-adeb-f15a-bae2-c71c26450d93@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=david@redhat.com \
    --cc=iii@linux.ibm.com \
    --cc=nsg@linux.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-s390x@nongnu.org \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).