Re: [PATCH v2 1/3] RISC-V: KVM: Order writes to the SBI STA shared structure
From: Andrew Jones
Date: Sun Nov 22 2026 - 06:58:41 EST
On Sun, Nov 22, 2026 at 02:35:24AM +0900, Koichiro Den wrote:
> The guest checks the sequence before and after reading steal time. If
> the final even sequence becomes visible before the updated steal time,
> the guest can accept a stale value. CSR accesses are weakly ordered;
> toggling sstatus.SUM in get_user() and put_user() does not guarantee
> that the guest observes those stores in order.
>
> Pair the read barriers in pv_time_steal_clock() with write barriers.
>
> Fixes: e9f12b5fff8a ("RISC-V: KVM: Implement SBI STA extension")
> Signed-off-by: Koichiro Den <den@xxxxxxxxxxxxx>
> ---
> Changes since v1:
> - New patch. Split the write barriers out of v1 patch #1 into a
> separate fix. (Andrew)
>
> arch/riscv/kvm/vcpu_sbi_sta.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
Reviewed-by: Andrew Jones <andrew.jones@xxxxxxxxx>