From: sashiko-bot@kernel.org
To: "Bibo Mao" <maobibo@loongson.cn>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH v2 5/5] LoongArch: KVM: Enable separate vmid feature
Date: Thu, 06 Aug 2026 02:47:44 +0000 [thread overview]
Message-ID: <20260806024745.44A651F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260806020739.2149268-6-maobibo@loongson.cn>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The `CSR_GTLBC_USEVMID` bit is not cleared when virtualization is disabled, leaking guest TLB hardware state into the host execution environment.
--
--- Patch [5]: [PATCH v2 5/5] LoongArch: KVM: Enable separate vmid feature ---
commit 3bea8b9a7dbd607efeb389e6233ef3a1a4c29bf9
Author: Bibo Mao <maobibo@loongson.cn>
LoongArch: KVM: Enable separate vmid feature
This commit enables the separate VMID feature on LoongArch KVM if
cpu_has_guestid is true when LVZ is enabled and the LVZ version is 2.
It updates cpu-probe to set LOONGARCH_CPU_GUESTID and modifies
kvm_arch_enable_virtualization_cpu() to configure the new bit.
[ ... ]
> diff --git a/arch/loongarch/kvm/main.c b/arch/loongarch/kvm/main.c
> index 72c1d23156e50..712b078db0d54 100644
> --- a/arch/loongarch/kvm/main.c
> +++ b/arch/loongarch/kvm/main.c
> @@ -359,7 +359,7 @@ int kvm_arch_enable_virtualization_cpu(void)
> write_csr_gcfg(0);
> write_csr_gstat(0);
> write_csr_gintc(0);
> - clear_csr_gtlbc(CSR_GTLBC_USETGID | CSR_GTLBC_TOTI);
> + clear_csr_gtlbc(CSR_GTLBC_USETGID | CSR_GTLBC_TOTI | CSR_GTLBC_USEVMID);
[Severity: Medium]
Should CSR_GTLBC_USEVMID also be cleared when virtualization is disabled?
When KVM is unloaded or a CPU is brought offline, the hardware virtualization
state is supposed to be fully restored. While this patch updates
kvm_arch_enable_virtualization_cpu() to clear CSR_GTLBC_USEVMID during
initialization, the corresponding disable function seems to miss it:
arch/loongarch/kvm/main.c:kvm_arch_disable_virtualization_cpu() {
write_csr_gcfg(0);
write_csr_gstat(0);
write_csr_gintc(0);
clear_csr_gtlbc(CSR_GTLBC_USETGID | CSR_GTLBC_TOTI);
...
}
Does this cause the USEVMID configuration to leak into the host execution
environment?
Although the host operates in root mode (VMID 0), leaving hypervisor
hardware features enabled could potentially interfere with kexec or
secondary hypervisor setups.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260806020739.2149268-1-maobibo@loongson.cn?part=5
next prev parent reply other threads:[~2026-08-06 2:47 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-06 2:07 [PATCH v2 0/5] LoongArch: KVM: Add separate vmid support Bibo Mao
2026-08-06 2:07 ` [PATCH v2 1/5] LoongArch: KVM: Add vmid support for stage2 MMU Bibo Mao
2026-08-06 12:20 ` Huacai Chen
2026-08-06 12:39 ` Bibo Mao
2026-08-06 2:07 ` [PATCH v2 2/5] LoongArch: KVM: Add separate vCPU and VM id update function Bibo Mao
2026-08-06 2:07 ` [PATCH v2 3/5] LoongArch: KVM: Add separate vmid feature support Bibo Mao
2026-08-06 2:30 ` sashiko-bot
2026-08-06 12:23 ` Huacai Chen
2026-08-06 12:41 ` Bibo Mao
2026-08-06 2:07 ` [PATCH v2 4/5] LoongArch: KVM: Implement vmid updating logic Bibo Mao
2026-08-06 2:30 ` sashiko-bot
2026-08-06 3:00 ` Bibo Mao
2026-08-06 2:07 ` [PATCH v2 5/5] LoongArch: KVM: Enable separate vmid feature Bibo Mao
2026-08-06 2:47 ` sashiko-bot [this message]
2026-08-06 12:39 ` Huacai Chen
2026-08-06 12:55 ` Bibo Mao
2026-08-06 13:03 ` Huacai Chen
2026-08-07 1:10 ` Bibo Mao
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=20260806024745.44A651F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=maobibo@loongson.cn \
--cc=sashiko-reviews@lists.linux.dev \
/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