From: Xu Lu Date: Mon, 14 Jul 2025 09:45:54 +0000 (+0800) Subject: RISC-V: KVM: Delegate illegal instruction fault to VS mode X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3729fe8cbb4807c6156938bc0eb643d97775a80d;p=thirdparty%2Flinux.git RISC-V: KVM: Delegate illegal instruction fault to VS mode Delegate illegal instruction fault to VS mode by default to avoid such exceptions being trapped to HS and redirected back to VS. The delegation of illegal instruction fault is particularly important to guest applications that use vector instructions frequently. In such cases, an illegal instruction fault will be raised when guest user thread uses vector instruction the first time and then guest kernel will enable user thread to execute following vector instructions. The fw pmu event counter remains undeleted so that guest can still query illegal instruction events via sbi call. Guest will only see zero count on illegal instruction faults and know 'firmware' has delegated it. Reviewed-by: Anup Patel Signed-off-by: Xu Lu Link: https://lore.kernel.org/r/20250714094554.89151-1-luxu.kernel@bytedance.com Signed-off-by: Anup Patel --- diff --git a/arch/riscv/include/asm/kvm_host.h b/arch/riscv/include/asm/kvm_host.h index dae26110e9b25..d71d3299a335c 100644 --- a/arch/riscv/include/asm/kvm_host.h +++ b/arch/riscv/include/asm/kvm_host.h @@ -47,6 +47,7 @@ #define __KVM_HAVE_ARCH_FLUSH_REMOTE_TLBS_RANGE #define KVM_HEDELEG_DEFAULT (BIT(EXC_INST_MISALIGNED) | \ + BIT(EXC_INST_ILLEGAL) | \ BIT(EXC_BREAKPOINT) | \ BIT(EXC_SYSCALL) | \ BIT(EXC_INST_PAGE_FAULT) | \