From: sashiko-bot@kernel.org
To: "Wang Yechao" <wang.yechao255@zte.com.cn>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH 2/2] RISC-V: KVM: Separate req and fallback_req masks in make_xfence_request
Date: Tue, 07 Jul 2026 11:47:54 +0000 [thread overview]
Message-ID: <20260707114755.0D1A41F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260707113715.413265-3-wang.yechao255@zte.com.cn>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The patch series silently drops FENCE.I requests by introducing an early return when `data` is NULL, breaking guest I-cache synchronization.
--
--- Patch [2]: [PATCH 2/2] RISC-V: KVM: Separate req and fallback_req masks in make_xfence_request ---
commit dc6a1097782a407911f8597843403d3a551a9225
Author: Wang Yechao <wang.yechao255@zte.com.cn>
RISC-V: KVM: Separate req and fallback_req masks in make_xfence_request
This commit modifies make_xfence_request() to maintain separate bitmaps
for vCPUs that successfully enqueue hfence data and those that require
fallback requests. It then applies the appropriate request to each group
separately.
> diff --git a/arch/riscv/kvm/tlb.c b/arch/riscv/kvm/tlb.c
> index a67b44a4d1d7a..916e2b1e0b366 100644
> --- a/arch/riscv/kvm/tlb.c
> +++ b/arch/riscv/kvm/tlb.c
> @@ -332,13 +332,14 @@ static void make_xfence_request(struct kvm *kvm,
> {
> unsigned long i;
> struct kvm_vcpu *vcpu;
> - unsigned int actual_req = req;
> - DECLARE_BITMAP(vcpu_mask, KVM_MAX_VCPUS);
> + DECLARE_BITMAP(req_vcpu_mask, KVM_MAX_VCPUS);
> + DECLARE_BITMAP(fallback_req_vcpu_mask, KVM_MAX_VCPUS);
>
> if (!data || !data->type)
> return;
[Severity: High]
Does this early return unconditionally abort the function when data is NULL,
preventing KVM_REQ_FENCE_I from ever being processed and skipping the vCPU
mask creation?
Looking at kvm_riscv_fence_i() in arch/riscv/kvm/tlb.c, it explicitly passes
NULL for data:
void kvm_riscv_fence_i(struct kvm *kvm,
unsigned long hbase, unsigned long hmask)
{
make_xfence_request(kvm, hbase, hmask, KVM_REQ_FENCE_I,
KVM_REQ_FENCE_I, NULL);
}
When a guest triggers SBI_EXT_RFENCE_REMOTE_FENCE_I, it invokes
kvm_riscv_fence_i(). Because data is NULL, make_xfence_request() returns
immediately without setting the KVM_REQ_FENCE_I bit or kicking the target
vCPUs.
Can this missing I-cache flush cause a guest to execute stale instructions,
leading to unpredictable guest behavior, kernel panics, or data corruption?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260707113715.413265-1-wang.yechao255@zte.com.cn?part=2
prev parent reply other threads:[~2026-07-07 11:47 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-07 11:37 [PATCH 0/2] RISC-V: KVM: Optimize hfence request handling for SMP guests Wang Yechao
2026-07-07 11:37 ` Wang Yechao
2026-07-07 11:37 ` Wang Yechao
2026-07-07 11:37 ` [PATCH 1/2] RISC-V: KVM: Move hfence type check out of loop Wang Yechao
2026-07-07 11:37 ` Wang Yechao
2026-07-07 11:37 ` Wang Yechao
2026-07-07 11:45 ` sashiko-bot
2026-07-07 11:37 ` [PATCH 2/2] RISC-V: KVM: Separate req and fallback_req masks in make_xfence_request Wang Yechao
2026-07-07 11:37 ` Wang Yechao
2026-07-07 11:37 ` Wang Yechao
2026-07-07 11:47 ` 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=20260707114755.0D1A41F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=wang.yechao255@zte.com.cn \
/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.