Skip to content

Commit 8a8b342

Browse files
avpatelgregkh
authored andcommitted
RISC-V: KVM: Fix the size parameter check in SBI SFENCE calls
[ Upstream commit 6aba0cb ] 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 <atishp@rivosinc.com> Signed-off-by: Anup Patel <apatel@ventanamicro.com> Link: https://lore.kernel.org/r/20250605061458.196003-2-apatel@ventanamicro.com Signed-off-by: Anup Patel <anup@brainfault.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent fe399aa commit 8a8b342

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
@@ -91,14 +91,14 @@ static int kvm_sbi_ext_rfence_handler(struct kvm_vcpu *vcpu, struct kvm_run *run
9191
kvm_riscv_fence_i(vcpu->kvm, hbase, hmask);
9292
break;
9393
case SBI_EXT_RFENCE_REMOTE_SFENCE_VMA:
94-
if (cp->a2 == 0 && cp->a3 == 0)
94+
if ((cp->a2 == 0 && cp->a3 == 0) || cp->a3 == -1UL)
9595
kvm_riscv_hfence_vvma_all(vcpu->kvm, hbase, hmask);
9696
else
9797
kvm_riscv_hfence_vvma_gva(vcpu->kvm, hbase, hmask,
9898
cp->a2, cp->a3, PAGE_SHIFT);
9999
break;
100100
case SBI_EXT_RFENCE_REMOTE_SFENCE_VMA_ASID:
101-
if (cp->a2 == 0 && cp->a3 == 0)
101+
if ((cp->a2 == 0 && cp->a3 == 0) || cp->a3 == -1UL)
102102
kvm_riscv_hfence_vvma_asid_all(vcpu->kvm,
103103
hbase, hmask, cp->a4);
104104
else

0 commit comments

Comments
 (0)