Skip to content

Commit 6aba0cb

Browse files
committed
RISC-V: KVM: Fix the size parameter check in SBI SFENCE calls
As-per the SBI specification, an SBI remote fence operation applies to the entire address space if either: 1) start_addr and size are both 0 2) size is equal to 2^XLEN-1 >From the above, only #1 is checked by SBI SFENCE calls so fix the size parameter check in SBI SFENCE calls to cover #2 as well. Fixes: 13acfec ("RISC-V: KVM: Add remote HFENCE functions based on VCPU requests") Reviewed-by: Atish Patra <[email protected]> Signed-off-by: Anup Patel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
1 parent e04c78d commit 6aba0cb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

arch/riscv/kvm/vcpu_sbi_replace.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,15 @@ static int kvm_sbi_ext_rfence_handler(struct kvm_vcpu *vcpu, struct kvm_run *run
103103
kvm_riscv_vcpu_pmu_incr_fw(vcpu, SBI_PMU_FW_FENCE_I_SENT);
104104
break;
105105
case SBI_EXT_RFENCE_REMOTE_SFENCE_VMA:
106-
if (cp->a2 == 0 && cp->a3 == 0)
106+
if ((cp->a2 == 0 && cp->a3 == 0) || cp->a3 == -1UL)
107107
kvm_riscv_hfence_vvma_all(vcpu->kvm, hbase, hmask);
108108
else
109109
kvm_riscv_hfence_vvma_gva(vcpu->kvm, hbase, hmask,
110110
cp->a2, cp->a3, PAGE_SHIFT);
111111
kvm_riscv_vcpu_pmu_incr_fw(vcpu, SBI_PMU_FW_HFENCE_VVMA_SENT);
112112
break;
113113
case SBI_EXT_RFENCE_REMOTE_SFENCE_VMA_ASID:
114-
if (cp->a2 == 0 && cp->a3 == 0)
114+
if ((cp->a2 == 0 && cp->a3 == 0) || cp->a3 == -1UL)
115115
kvm_riscv_hfence_vvma_asid_all(vcpu->kvm,
116116
hbase, hmask, cp->a4);
117117
else

0 commit comments

Comments
 (0)