Skip to content

Commit 1851e78

Browse files
SiFiveHollandpalmer-dabbelt
authored andcommitted
RISC-V: KVM: Allow Smnpm and Ssnpm extensions for guests
The interface for controlling pointer masking in VS-mode is henvcfg.PMM, which is part of the Ssnpm extension, even though pointer masking in HS-mode is provided by the Smnpm extension. As a result, emulating Smnpm in the guest requires (only) Ssnpm on the host. The guest configures Smnpm through the SBI Firmware Features extension, which KVM does not yet implement, so currently the ISA extension has no visible effect on the guest, and thus it cannot be disabled. Ssnpm is configured using the senvcfg CSR within the guest, so that extension cannot be hidden from the guest without intercepting writes to the CSR. Signed-off-by: Samuel Holland <samuel.holland@sifive.com> Reviewed-by: Anup Patel <anup@brainfault.org> Link: https://lore.kernel.org/r/20241016202814.4061541-10-samuel.holland@sifive.com Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
1 parent 3c2e0af commit 1851e78

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

arch/riscv/include/uapi/asm/kvm.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,8 @@ enum KVM_RISCV_ISA_EXT_ID {
175175
KVM_RISCV_ISA_EXT_ZCF,
176176
KVM_RISCV_ISA_EXT_ZCMOP,
177177
KVM_RISCV_ISA_EXT_ZAWRS,
178+
KVM_RISCV_ISA_EXT_SMNPM,
179+
KVM_RISCV_ISA_EXT_SSNPM,
178180
KVM_RISCV_ISA_EXT_MAX,
179181
};
180182

arch/riscv/kvm/vcpu_onereg.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,11 @@ static const unsigned long kvm_isa_ext_arr[] = {
3434
[KVM_RISCV_ISA_EXT_M] = RISCV_ISA_EXT_m,
3535
[KVM_RISCV_ISA_EXT_V] = RISCV_ISA_EXT_v,
3636
/* Multi letter extensions (alphabetically sorted) */
37+
[KVM_RISCV_ISA_EXT_SMNPM] = RISCV_ISA_EXT_SSNPM,
3738
KVM_ISA_EXT_ARR(SMSTATEEN),
3839
KVM_ISA_EXT_ARR(SSAIA),
3940
KVM_ISA_EXT_ARR(SSCOFPMF),
41+
KVM_ISA_EXT_ARR(SSNPM),
4042
KVM_ISA_EXT_ARR(SSTC),
4143
KVM_ISA_EXT_ARR(SVINVAL),
4244
KVM_ISA_EXT_ARR(SVNAPOT),
@@ -127,8 +129,10 @@ static bool kvm_riscv_vcpu_isa_disable_allowed(unsigned long ext)
127129
case KVM_RISCV_ISA_EXT_C:
128130
case KVM_RISCV_ISA_EXT_I:
129131
case KVM_RISCV_ISA_EXT_M:
132+
case KVM_RISCV_ISA_EXT_SMNPM:
130133
/* There is not architectural config bit to disable sscofpmf completely */
131134
case KVM_RISCV_ISA_EXT_SSCOFPMF:
135+
case KVM_RISCV_ISA_EXT_SSNPM:
132136
case KVM_RISCV_ISA_EXT_SSTC:
133137
case KVM_RISCV_ISA_EXT_SVINVAL:
134138
case KVM_RISCV_ISA_EXT_SVNAPOT:

0 commit comments

Comments
 (0)