* [PATCH v4] RISC-V: KVM: Delegate illegal instruction fault to VS mode
@ 2025-07-14 9:45 Xu Lu
2025-07-16 5:20 ` Anup Patel
0 siblings, 1 reply; 2+ messages in thread
From: Xu Lu @ 2025-07-14 9:45 UTC (permalink / raw)
To: rkrcmar, cleger, anup, atish.patra, paul.walmsley, palmer, aou,
alex
Cc: kvm, kvm-riscv, linux-riscv, linux-kernel, Xu Lu
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.
Signed-off-by: Xu Lu <luxu.kernel@bytedance.com>
---
arch/riscv/include/asm/kvm_host.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/riscv/include/asm/kvm_host.h b/arch/riscv/include/asm/kvm_host.h
index 85cfebc32e4cf..3f6b9270f366a 100644
--- a/arch/riscv/include/asm/kvm_host.h
+++ b/arch/riscv/include/asm/kvm_host.h
@@ -44,6 +44,7 @@
#define KVM_REQ_STEAL_UPDATE KVM_ARCH_REQ(6)
#define KVM_HEDELEG_DEFAULT (BIT(EXC_INST_MISALIGNED) | \
+ BIT(EXC_INST_ILLEGAL) | \
BIT(EXC_BREAKPOINT) | \
BIT(EXC_SYSCALL) | \
BIT(EXC_INST_PAGE_FAULT) | \
--
2.20.1
--
kvm-riscv mailing list
kvm-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kvm-riscv
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v4] RISC-V: KVM: Delegate illegal instruction fault to VS mode
2025-07-14 9:45 [PATCH v4] RISC-V: KVM: Delegate illegal instruction fault to VS mode Xu Lu
@ 2025-07-16 5:20 ` Anup Patel
0 siblings, 0 replies; 2+ messages in thread
From: Anup Patel @ 2025-07-16 5:20 UTC (permalink / raw)
To: Xu Lu
Cc: rkrcmar, cleger, atish.patra, paul.walmsley, palmer, aou, alex,
kvm, kvm-riscv, linux-riscv, linux-kernel
On Mon, Jul 14, 2025 at 3:16 PM Xu Lu <luxu.kernel@bytedance.com> wrote:
>
> 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.
>
> Signed-off-by: Xu Lu <luxu.kernel@bytedance.com>
LGTM.
Reviewed-by: Anup Patel <anup@brainfault.org>
Queued this patch for Linux-6.17
Thanks,
Anup
> ---
> arch/riscv/include/asm/kvm_host.h | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/arch/riscv/include/asm/kvm_host.h b/arch/riscv/include/asm/kvm_host.h
> index 85cfebc32e4cf..3f6b9270f366a 100644
> --- a/arch/riscv/include/asm/kvm_host.h
> +++ b/arch/riscv/include/asm/kvm_host.h
> @@ -44,6 +44,7 @@
> #define KVM_REQ_STEAL_UPDATE KVM_ARCH_REQ(6)
>
> #define KVM_HEDELEG_DEFAULT (BIT(EXC_INST_MISALIGNED) | \
> + BIT(EXC_INST_ILLEGAL) | \
> BIT(EXC_BREAKPOINT) | \
> BIT(EXC_SYSCALL) | \
> BIT(EXC_INST_PAGE_FAULT) | \
> --
> 2.20.1
>
--
kvm-riscv mailing list
kvm-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kvm-riscv
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-07-16 5:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-14 9:45 [PATCH v4] RISC-V: KVM: Delegate illegal instruction fault to VS mode Xu Lu
2025-07-16 5:20 ` Anup Patel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).