[PATCH] RISC-V: KVM: Flush VS-stage TLB before reusing a host CPU
Ze Huang
ze.huang at oss.qualcomm.com
Tue Nov 24 08:05:28 PST 2026
On Wed Oct 21, 2026 at 5:32 PM CST, BillXiang wrote:
> On 10/10/2026 5:06 PM, guoyaxing wrote:
>>
[ ... ]
>> In other words, I am not sure this case is covered by a full guest TLB
>> flush to all VCPUs on the mapping update. Guest shootdown looks
>> mm_cpumask-based, and host pCPU migration of a vCPU does not by itself
>> add other vCPUs that never ran the mm into that mask.
>>
>> The earlier RFC note has a bit more detail on the flow we observed:
>> https://lore.kernel.org/kvm/0d15b098-b8f7-4080-9f33-
>> e8c49c2331e1 at bosc.ac.cn/
>>
>> Please let me know if I misunderstood the intended invalidation path here.
>>
>> Thanks,
>> Yaxing
>>
>
> Hi Yaxing,
>
> Thanks for your work. To help review and validate this patch, I am
> sharing the two programs below, which were generated with the help of an
> AI assistant. I reviewed the code and ran it on my test system: without
> this patch the reproducer triggers the stale VS-stage TLB entry, and
> with the patch applied it no longer does.
>
[ ... ]
> --- 8< --- end --- 8< ---
>
> Tested-by: BillXiang <xiangwencheng at lanxincomputing.com>
>
Thanks Bill.
I reproduced the same failure on SpacemiT K3 and V100, adapted from your
reproducer: the guest side drives the same four phases over the console
instead of TCP, so it also runs from an initramfs on a bare board.
Platform | Host kernel | Iters | Hits
--------------+----------------------------+-------+----------
SpacemiT K3 | v7.4-rc1, unpatched | 19 | 15
SpacemiT K3 | v7.4-rc1 + fix | 20 | 0
SpacemiT v100 | Ubuntu 7.0.0-30, untouched | 42 | 36 (86%)
Code and notes:
https://github.com/Sutter099/llscripts/tree/main/work/vstlb-repro
Tested-by: Ze Huang <ze.huang at oss.qualcomm.com>
More information about the kvm-riscv
mailing list