summaryrefslogtreecommitdiff
path: root/arch/riscv/kvm/vcpu_sbi_system.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/riscv/kvm/vcpu_sbi_system.c')
-rw-r--r--arch/riscv/kvm/vcpu_sbi_system.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/arch/riscv/kvm/vcpu_sbi_system.c b/arch/riscv/kvm/vcpu_sbi_system.c
index c6f7e609ac79..6f64a59e5d3c 100644
--- a/arch/riscv/kvm/vcpu_sbi_system.c
+++ b/arch/riscv/kvm/vcpu_sbi_system.c
@@ -35,6 +35,20 @@ static int kvm_sbi_ext_susp_handler(struct kvm_vcpu *vcpu, struct kvm_run *run,
return 0;
}
+ /*
+ * Check that all other vCPUs are stopped before entering
+ * system suspend.
+ *
+ * There is a known TOCTOU race here: a concurrent HSM
+ * HART_START on another vCPU can start a vCPU after it
+ * has already passed this check, violating the invariant.
+ *
+ * We do not fix this because:
+ * 1. Triggering the race requires a pathological guest.
+ * 2. Only guest state is at risk, not host integrity.
+ * 3. Userspace can double-check vCPU states before
+ * proceeding with suspend.
+ */
kvm_for_each_vcpu(i, tmp, vcpu->kvm) {
if (tmp == vcpu)
continue;