RISC-V: KVM: Delegate illegal instruction fault to VS mode
authorXu Lu <luxu.kernel@bytedance.com>
Mon, 14 Jul 2025 09:45:54 +0000 (17:45 +0800)
committerAnup Patel <anup@brainfault.org>
Mon, 28 Jul 2025 16:57:40 +0000 (22:27 +0530)
commit3729fe8cbb4807c6156938bc0eb643d97775a80d
tree2de95fe95aaa67cfaf8319cab4e8d6af695a2032
parent1f6d0eee54f7ed498a5e4ab3e12ea81bdac86b89
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 <anup@brainfault.org>
Signed-off-by: Xu Lu <luxu.kernel@bytedance.com>
Link: https://lore.kernel.org/r/20250714094554.89151-1-luxu.kernel@bytedance.com
Signed-off-by: Anup Patel <anup@brainfault.org>
arch/riscv/include/asm/kvm_host.h