qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: Weiwei Li <liweiwei@iscas.ac.cn>,
	qemu-riscv@nongnu.org, qemu-devel@nongnu.org
Cc: palmer@dabbelt.com, alistair.francis@wdc.com,
	bin.meng@windriver.com, dbarboza@ventanamicro.com,
	zhiwei_liu@linux.alibaba.com, wangjunqiang@iscas.ac.cn,
	lazyparser@gmail.com
Subject: Re: [PATCH v4 4/8] target/riscv: Add support for PC-relative translation
Date: Fri, 31 Mar 2023 18:14:50 -0700	[thread overview]
Message-ID: <ebba64fa-6a73-0662-0677-c3a0524d2946@linaro.org> (raw)
In-Reply-To: <20230331150609.114401-5-liweiwei@iscas.ac.cn>

On 3/31/23 08:06, Weiwei Li wrote:
> Add a base save_pc For PC-relative translation(CF_PCREL).
> Diable the directly sync pc from tb by riscv_cpu_synchronize_from_tb.
> Sync pc before it's used or updated from tb related pc:
>     real_pc = (old)env->pc + target_pc(from tb) - ctx->save_pc
> 
> Signed-off-by: Weiwei Li <liweiwei@iscas.ac.cn>
> Signed-off-by: Junqiang Wang <wangjunqiang@iscas.ac.cn>
> ---
>   target/riscv/cpu.c                      | 29 +++++++++-----
>   target/riscv/insn_trans/trans_rvi.c.inc | 24 +++++++++--
>   target/riscv/translate.c                | 53 +++++++++++++++++++++----
>   3 files changed, 85 insertions(+), 21 deletions(-)

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

>   static bool trans_auipc(DisasContext *ctx, arg_auipc *a)
>   {
> -    gen_set_gpri(ctx, a->rd, a->imm + ctx->base.pc_next);
> +    assert(ctx->pc_save != -1);
> +    if (tb_cflags(ctx->base.tb) & CF_PCREL) {
> +        TCGv target_pc = dest_gpr(ctx, a->rd);
> +        tcg_gen_addi_tl(target_pc, cpu_pc, a->imm + ctx->base.pc_next -
> +                                           ctx->pc_save);

Could use gen_get_target_pc.

> @@ -68,7 +76,14 @@ static bool trans_jalr(DisasContext *ctx, arg_jalr *a)
>           tcg_gen_brcondi_tl(TCG_COND_NE, t0, 0x0, misaligned);
>       }
>   
> -    gen_set_gpri(ctx, a->rd, ctx->pc_succ_insn);
> +    if (tb_cflags(ctx->base.tb) & CF_PCREL) {
> +        TCGv succ_pc = dest_gpr(ctx, a->rd);
> +        tcg_gen_addi_tl(succ_pc, cpu_pc, ctx->pc_succ_insn - ctx->pc_save);
> +        gen_set_gpr(ctx, a->rd, succ_pc);

Likewise.


r~


  reply	other threads:[~2023-04-01  1:15 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-31 15:06 [PATCH v4 0/8] target/riscv: Fix pointer mask related support Weiwei Li
2023-03-31 15:06 ` [PATCH v4 1/8] target/riscv: Fix pointer mask transformation for vector address Weiwei Li
2023-03-31 15:06 ` [PATCH v4 2/8] target/riscv: Update cur_pmmask/base when xl changes Weiwei Li
2023-03-31 15:06 ` [PATCH v4 3/8] target/riscv: Fix target address to update badaddr Weiwei Li
2023-04-01  1:06   ` Richard Henderson
2023-03-31 15:06 ` [PATCH v4 4/8] target/riscv: Add support for PC-relative translation Weiwei Li
2023-04-01  1:14   ` Richard Henderson [this message]
2023-03-31 15:06 ` [PATCH v4 5/8] accel/tcg: Fix overwrite problems of tcg_cflags Weiwei Li
2023-04-01  1:18   ` Richard Henderson
2023-04-01  1:33     ` Richard Henderson
2023-04-01  1:38       ` Richard Henderson
2023-03-31 15:06 ` [PATCH v4 6/8] accel/tcg: Fix tb mis-matched problem when CF_PCREL is enabled Weiwei Li
2023-04-01  1:26   ` Richard Henderson
2023-04-01  1:52     ` Richard Henderson
2023-03-31 15:06 ` [PATCH v4 7/8] target/riscv: Enable PC-relative translation in system mode Weiwei Li
2023-04-01  1:53   ` Richard Henderson
2023-03-31 15:06 ` [PATCH v4 8/8] target/riscv: Add pointer mask support for instruction fetch Weiwei Li
2023-04-01  1:54   ` 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=ebba64fa-6a73-0662-0677-c3a0524d2946@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=alistair.francis@wdc.com \
    --cc=bin.meng@windriver.com \
    --cc=dbarboza@ventanamicro.com \
    --cc=lazyparser@gmail.com \
    --cc=liweiwei@iscas.ac.cn \
    --cc=palmer@dabbelt.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-riscv@nongnu.org \
    --cc=wangjunqiang@iscas.ac.cn \
    --cc=zhiwei_liu@linux.alibaba.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).