]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
RISC-V: KVM: Fix inclusion of Smnpm in the guest ISA bitmap
authorSamuel Holland <samuel.holland@sifive.com>
Sat, 11 Jan 2025 00:46:58 +0000 (16:46 -0800)
committerAnup Patel <anup@brainfault.org>
Mon, 28 Jul 2025 16:57:45 +0000 (22:27 +0530)
commit7826c8f37220daabf90c09fcd9a835d6763f1372
tree8f322543d46c30795c24fdc23b74029460a538a1
parent3729fe8cbb4807c6156938bc0eb643d97775a80d
RISC-V: KVM: Fix inclusion of Smnpm in the guest ISA bitmap

The Smnpm extension requires special handling because the guest ISA
extension maps to a different extension (Ssnpm) on the host side.
commit 1851e7836212 ("RISC-V: KVM: Allow Smnpm and Ssnpm extensions for
guests") missed that the vcpu->arch.isa bit is based only on the host
extension, so currently both KVM_RISCV_ISA_EXT_{SMNPM,SSNPM} map to
vcpu->arch.isa[RISCV_ISA_EXT_SSNPM]. This does not cause any problems
for the guest, because both extensions are force-enabled anyway when the
host supports Ssnpm, but prevents checking for (guest) Smnpm in the SBI
FWFT logic.

Redefine kvm_isa_ext_arr to look up the guest extension, since only the
guest -> host mapping is unambiguous. Factor out the logic for checking
for host support of an extension, so this special case only needs to be
handled in one place, and be explicit about which variables hold a host
vs a guest ISA extension.

Fixes: 1851e7836212 ("RISC-V: KVM: Allow Smnpm and Ssnpm extensions for guests")
Signed-off-by: Samuel Holland <samuel.holland@sifive.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20250111004702.2813013-2-samuel.holland@sifive.com
Signed-off-by: Anup Patel <anup@brainfault.org>
arch/riscv/kvm/vcpu_onereg.c