From: sashiko-bot@kernel.org
To: "Qi Zhang" <marsy12010123@gmail.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH] KVM: x86: Protect virtualization-enable VM walks with RCU
Date: Tue, 04 Aug 2026 12:51:09 +0000 [thread overview]
Message-ID: <20260804125109.B20491F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260804123243.2213854-1-marsy12010123@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Data race on `vcpu->arch.tsc_offset_adjustment` during CPU hotplug can lead to guest timekeeping corruption.
--
--- Patch [1]: [PATCH] KVM: x86: Protect virtualization-enable VM walks with RCU ---
commit ff5afc2b0cb8750aad6e3a35f5b08c17dc92aca8
Author: Chengfeng Ye <nicoyip.dev@gmail.com>
KVM: x86: Protect virtualization-enable VM walks with RCU
This commit protects the vm_list walks in kvm_arch_enable_virtualization_cpu()
with RCU. It publishes and removes VMs using RCU list operations to prevent
use-after-free bugs during CPU hotplug concurrent with VM teardown.
Cc: stable@vger.kernel.org
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index afcac1042947a..fb1c14d7dc4b4 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
[ ... ]
> @@ -13192,7 +13193,7 @@ int kvm_arch_enable_virtualization_cpu(void)
> */
> if (backwards_tsc) {
> u64 delta_cyc = max_tsc - local_tsc;
> - list_for_each_entry(kvm, &vm_list, vm_list) {
> + list_for_each_entry_rcu(kvm, &vm_list, vm_list) {
> kvm->arch.backwards_tsc_observed = true;
> kvm_for_each_vcpu(i, vcpu, kvm) {
> vcpu->arch.tsc_offset_adjustment += delta_cyc;
[Severity: High]
This is a pre-existing issue, but can this lockless addition race with a
concurrent kvm_arch_vcpu_load() on a running VM?
During CPU hotplug, the hotplug thread iterates over all vCPUs and modifies
tsc_offset_adjustment here locklessly. Concurrently, if the VM is scheduled
on another active CPU, kvm_arch_vcpu_load() could read and clear
vcpu->arch.tsc_offset_adjustment to 0.
Could this data race result in a lost or corrupted TSC adjustment,
potentially warping the guest's timekeeping?
> }
> }
>
> }
> + rcu_read_unlock();
> return 0;
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260804123243.2213854-1-marsy12010123@gmail.com?part=1
prev parent reply other threads:[~2026-08-04 12:51 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-04 12:32 [PATCH] KVM: x86: Protect virtualization-enable VM walks with RCU Qi Zhang
2026-08-04 12:51 ` sashiko-bot [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=20260804125109.B20491F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=marsy12010123@gmail.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.