Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: Ben Zong-You Xie <ben717@andestech.com>
To: "Radim Krčmář" <rkrcmar@ventanamicro.com>
Cc: <anup@brainfault.org>, <atish.patra@linux.dev>, <pjw@kernel.org>,
	<palmer@dabbelt.com>, <aou@eecs.berkeley.edu>, <alex@ghiti.fr>,
	<liujingqi@lanxincomputing.com>, <kvm@vger.kernel.org>,
	<kvm-riscv@lists.infradead.org>,
	<linux-riscv@lists.infradead.org>, <linux-kernel@vger.kernel.org>,
	<tim609@andestech.com>,
	Hui Min Mina Chou <minachou@andestech.com>,
	linux-riscv <linux-riscv-bounces@lists.infradead.org>
Subject: Re: [PATCH] RISC-V: KVM: flush VS-stage TLB after VCPU migration to prevent stale entries
Date: Thu, 9 Oct 2025 18:15:51 +0800	[thread overview]
Message-ID: <aOeLVwXW/sF4NBUJ@atctrx.andestech.com> (raw)
In-Reply-To: <DDDKX1VNCCVS.2KVYNU4WBEOVI@ventanamicro.com>

Hi Radim,

Thanks for the review and the detailed comments.

> What RISC-V implementation are you using?  (And does the implementation
> have the same memory access performance in V=0 and V=1 modes, even
> though the latter has two levels of TLBs?)
> 

The issue is found when validating our new AndesCore AX66.
The address translation performance is the same for U and VU-mode when the uTLB is hit.

> > To fix this, kvm_riscv_gstage_vmid_sanitize() is extended to flush both
> > G-stage and VS-stage TLBs whenever a VCPU migrates to a different Host CPU.
> > This ensures that no stale VS-stage mappings remain after VCPU migration.
> >
> > Fixes: b79bf2025dbc ("RISC-V: KVM: Rename and move kvm_riscv_local_tlb_sanitize()")
> 
> b79bf2025dbc does not change behavior.
> The bug must have been introduced earlier.
> 

Will fix the incorrect Fixes tag in the next version.
Thanks for pointing that out, we'll change to the following:

    Fixes: 92e450507d56 ("RISC-V: KVM: Cleanup stale TLB entries when host CPU changes")

> > Signed-off-by: Hui Min Mina Chou <minachou@andestech.com>
> > Signed-off-by: Ben Zong-You Xie <ben717@andestech.com>
> > ---
> > diff --git a/arch/riscv/kvm/vmid.c b/arch/riscv/kvm/vmid.c
> > @@ -146,4 +146,10 @@ void kvm_riscv_gstage_vmid_sanitize(struct kvm_vcpu *vcpu)
> 
> The function is now doing more that sanitizing gstage.
> Maybe we can again call it kvm_riscv_local_tlb_sanitize()?
> 

As for the naming, your suggestion makes sense.
We’re also considering whether it should be moved back from vmid.c to tlb.c,
and we’d like to hear other maintainers’ opinions before doing so.

Thanks again for your feedback.

Best regards,
Ben

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

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-02  3:34 [PATCH] RISC-V: KVM: flush VS-stage TLB after VCPU migration to prevent stale entries Ben Zong-You Xie
2025-10-09  6:31 ` Radim Krčmář
2025-10-09 10:15   ` Ben Zong-You Xie [this message]

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=aOeLVwXW/sF4NBUJ@atctrx.andestech.com \
    --to=ben717@andestech.com \
    --cc=alex@ghiti.fr \
    --cc=anup@brainfault.org \
    --cc=aou@eecs.berkeley.edu \
    --cc=atish.patra@linux.dev \
    --cc=kvm-riscv@lists.infradead.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv-bounces@lists.infradead.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=liujingqi@lanxincomputing.com \
    --cc=minachou@andestech.com \
    --cc=palmer@dabbelt.com \
    --cc=pjw@kernel.org \
    --cc=rkrcmar@ventanamicro.com \
    --cc=tim609@andestech.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