qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: wang.yechao255@zte.com.cn, palmer@dabbelt.com,
	alistair.francis@wdc.com, liwei1518@gmail.com,
	dbarboza@ventanamicro.com, zhiwei_liu@linux.alibaba.com
Cc: qemu-riscv@nongnu.org, qemu-devel@nongnu.org
Subject: Re: [PATCH] target/riscv: Flush the TLB entry for the specified address
Date: Tue, 30 Sep 2025 12:04:23 +0200	[thread overview]
Message-ID: <a9cb3275-4707-4476-84e5-e42711e89116@linaro.org> (raw)
In-Reply-To: <20250930174849833XG1Q1ETbNvg66WU2UVBTV@zte.com.cn>

Hi,

On 30/9/25 11:48, wang.yechao255@zte.com.cn wrote:
> From: yechao-w <wang.yechao255@zte.com.cn>
> 
> When the guest executes sfence/svinval with an address parameter,
> invalidating only the specific TLB entry for that address rather
> than the entire TLB enhances TCG performance.
> 
> Signed-off-by: yechao-w <wang.yechao255@zte.com.cn>
> ---
>   target/riscv/helper.h                          | 2 +-
>   target/riscv/insn_trans/trans_privileged.c.inc | 4 +++-
>   target/riscv/insn_trans/trans_svinval.c.inc    | 4 +++-
>   target/riscv/op_helper.c                       | 8 ++++++--
>   4 files changed, 13 insertions(+), 5 deletions(-)


> diff --git a/target/riscv/op_helper.c b/target/riscv/op_helper.c
> index 110292e84d..0fe5fcb3ac 100644
> --- a/target/riscv/op_helper.c
> +++ b/target/riscv/op_helper.c
> @@ -555,7 +555,7 @@ void helper_wrs_nto(CPURISCVState *env)
>       }
>   }
> 
> -void helper_tlb_flush(CPURISCVState *env)
> +void helper_tlb_flush(CPURISCVState *env, target_ulong addr)
>   {
>       CPUState *cs = env_cpu(env);
>       if (!env->virt_enabled &&
> @@ -566,7 +566,11 @@ void helper_tlb_flush(CPURISCVState *env)
>                  (env->priv == PRV_U || get_field(env->hstatus, HSTATUS_VTVM))) {
>           riscv_raise_exception(env, RISCV_EXCP_VIRT_INSTRUCTION_FAULT, GETPC());
>       } else {
> -        tlb_flush(cs);
> +        if (addr) {
> +            tlb_flush_page(cs, addr);

I suspect tlb_flush_page(cs, addr) is the right thing to do,
even for addr=0.

Can you point at the doc?

> +        } else {
> +            tlb_flush(cs);
> +        }
>       }
>   }
> 


  reply	other threads:[~2025-09-30 10:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-30  9:48 [PATCH] target/riscv: Flush the TLB entry for the specified address wang.yechao255
2025-09-30 10:04 ` Philippe Mathieu-Daudé [this message]
2025-10-09  2:49   ` wang.yechao255

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=a9cb3275-4707-4476-84e5-e42711e89116@linaro.org \
    --to=philmd@linaro.org \
    --cc=alistair.francis@wdc.com \
    --cc=dbarboza@ventanamicro.com \
    --cc=liwei1518@gmail.com \
    --cc=palmer@dabbelt.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-riscv@nongnu.org \
    --cc=wang.yechao255@zte.com.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).