Re: [PATCH v2 14/15] RISC-V: KVM: add support for FWFT SBI extension

2025-02-14 Thread Clément Léger
On 11/02/2025 06:57, Deepak Gupta wrote: > On Mon, Feb 10, 2025 at 10:35:47PM +0100, Clément Léger wrote: >> Add basic infrastructure to support the FWFT extension in KVM. >> >> Signed-off-by: Clément Léger >> --- >> arch/riscv/include/asm/kvm_host.h 

Re: [PATCH v2 14/15] RISC-V: KVM: add support for FWFT SBI extension

2025-02-11 Thread Clément Léger
On 11/02/2025 06:43, Deepak Gupta wrote: >> +static int kvm_sbi_fwft_get(struct kvm_vcpu *vcpu, unsigned long >> feature, >> +    unsigned long *value) >> +{ >> +    int ret; >> +    struct kvm_sbi_fwft_config *conf; >> + >> +    ret = kvm_fwft_get_feature(vcpu, feature, &conf); >> +

[PATCH v2 14/15] RISC-V: KVM: add support for FWFT SBI extension

2025-02-10 Thread Clément Léger
Add basic infrastructure to support the FWFT extension in KVM. Signed-off-by: Clément Léger --- arch/riscv/include/asm/kvm_host.h | 4 + arch/riscv/include/asm/kvm_vcpu_sbi.h | 1 + arch/riscv/include/asm/kvm_vcpu_sbi_fwft.h | 37 arch/riscv/include/uapi/asm/kvm.h

[PATCH v2 15/15] RISC-V: KVM: add support for SBI_FWFT_MISALIGNED_DELEG

2025-02-10 Thread Clément Léger
SBI_FWFT_MISALIGNED_DELEG needs hedeleg to be modified to delegate misaligned load/store exceptions. Save and restore it during CPU load/put. Signed-off-by: Clément Léger --- arch/riscv/kvm/vcpu.c | 3 +++ arch/riscv/kvm/vcpu_sbi_fwft.c | 39 ++ 2 files

[PATCH v2 12/15] RISC-V: KVM: add SBI extension init()/deinit() functions

2025-02-10 Thread Clément Léger
The FWFT SBI extension will need to dynamically allocate memory and do init time specific initialization. Add an init/deinit callbacks that allows to do so. Signed-off-by: Clément Léger --- arch/riscv/include/asm/kvm_vcpu_sbi.h | 9 arch/riscv/kvm/vcpu.c | 2 ++ arch

[PATCH v2 13/15] RISC-V: KVM: add SBI extension reset callback

2025-02-10 Thread Clément Léger
Currently, oonly the STA extension needed a reset function but that's going to be the case for FWFT as well. Add a reset callback that can be implemented by SBI extensions. Signed-off-by: Clément Léger --- arch/riscv/include/asm/kvm_host.h | 1 - arch/riscv/include/asm/kvm_vcpu_sbi.h

[PATCH v2 11/15] selftests: riscv: add misaligned access testing

2025-02-10 Thread Clément Léger
are tested. Signed-off-by: Clément Léger --- .../selftests/riscv/misaligned/.gitignore | 1 + .../selftests/riscv/misaligned/Makefile | 12 + .../selftests/riscv/misaligned/common.S | 33 +++ .../testing/selftests/riscv/misaligned/fpu.S | 180 + tools/testing

[PATCH v2 10/15] Documentation/sysctl: add riscv to unaligned-trap supported archs

2025-02-10 Thread Clément Léger
riscv supports the "unaligned-trap" sysctl variable, add it to the list of supported architectures. Signed-off-by: Clément Léger --- Documentation/admin-guide/sysctl/kernel.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/admin-guide/sysctl/ker

[PATCH v2 09/15] riscv: misaligned: use get_user() instead of __get_user()

2025-02-10 Thread Clément Léger
Now that we can safely handle user memory accesses while in the misaligned access handlers, use get_user() instead of __get_user() to have user memory access checks. Signed-off-by: Clément Léger --- arch/riscv/kernel/traps_misaligned.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff

[PATCH v2 08/15] riscv: misaligned: enable IRQs while handling misaligned accesses

2025-02-10 Thread Clément Léger
We can safely reenable IRQs if they were enabled in the previous context. This allows to access user memory that could potentially trigger a page fault. Signed-off-by: Clément Léger --- arch/riscv/kernel/traps.c | 8 1 file changed, 8 insertions(+) diff --git a/arch/riscv/kernel

[PATCH v2 07/15] riscv: misaligned: factorize trap handling

2025-02-10 Thread Clément Léger
misaligned accesses traps are not nmi and should be treated as normal one using irqentry_enter()/exit(). Since both load/store and user/kernel should use almost the same path and that we are going to add some code around that, factorize it. Signed-off-by: Clément Léger --- arch/riscv/kernel

[PATCH v2 06/15] riscv: misaligned: add a function to check misalign trap delegability

2025-02-10 Thread Clément Léger
Checking for the delegability of the misaligned access trap is needed for the KVM FWFT extension implementation. Add a function to get the delegability of the misaligned trap exception. Signed-off-by: Clément Léger --- arch/riscv/include/asm/cpufeature.h | 5 + arch/riscv/kernel

[PATCH v2 05/15] riscv: misaligned: move emulated access uniformity check in a function

2025-02-10 Thread Clément Léger
Split the code that check for the uniformity of misaligned accesses performance on all cpus from check_unaligned_access_emulated_all_cpus() to its own function which will be used for delegation check. No functional changes intended. Signed-off-by: Clément Léger --- arch/riscv/kernel

[PATCH v2 04/15] riscv: misaligned: use correct CONFIG_ ifdef for misaligned_access_speed

2025-02-10 Thread Clément Léger
misaligned_access_speed is defined under CONFIG_RISCV_SCALAR_MISALIGNED but was used under CONFIG_RISCV_PROBE_UNALIGNED_ACCESS. Fix that by using the correct config option. Signed-off-by: Clément Léger --- arch/riscv/kernel/traps_misaligned.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion

[PATCH v2 03/15] riscv: misaligned: use on_each_cpu() for scalar misaligned access probing

2025-02-10 Thread Clément Léger
less of a problem since this code is ran in a kthread. Add a comment to explicit that. Signed-off-by: Clément Léger --- arch/riscv/kernel/traps_misaligned.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/riscv/kernel/traps_misaligned.c b/arch/riscv/k

[PATCH v2 02/15] riscv: misaligned: request misaligned exception from SBI

2025-02-10 Thread Clément Léger
Now that the kernel can handle misaligned accesses in S-mode, request misaligned access exception delegation from SBI. This uses the FWFT SBI extension defined in SBI version 3.0. Signed-off-by: Clément Léger --- arch/riscv/include/asm/cpufeature.h| 3 +- arch/riscv/kernel

[PATCH v2 00/15] riscv: add SBI FWFT misaligned exception delegation support

2025-02-10 Thread Clément Léger
dded reset for KVM SBI FWFT lock - Return SBI_ERR_DENIED_LOCKED when LOCK flag is set Clément Léger (15): riscv: add Firmware Feature (FWFT) SBI extensions definitions riscv: misaligned: request misaligned exception from SBI riscv: misaligned: use on_each_cpu() for scalar misaligned access

[PATCH v2 01/15] riscv: add Firmware Feature (FWFT) SBI extensions definitions

2025-02-10 Thread Clément Léger
The Firmware Features extension (FWFT) was added as part of the SBI 3.0 specification. Add SBI definitions to use this extension. Signed-off-by: Clément Léger Reviewed-by: Samuel Holland Tested-by: Samuel Holland --- arch/riscv/include/asm/sbi.h | 33 + 1 file

Re: [PATCH v9 14/26] riscv/traps: Introduce software check exception

2025-02-09 Thread Clément Léger
On 07/02/2025 22:26, Deepak Gupta wrote: > Hi Clement, > > Thanks for looking at it. Inline > On Thu, Feb 06, 2025 at 02:49:09PM +0100, Clément Léger wrote: >> >> >> On 05/02/2025 02:22, Deepak Gupta wrote: >>> zicfiss / zicfilp introduces a ne

Re: [PATCH v9 03/26] riscv: zicfiss / zicfilp enumeration

2025-02-06 Thread Clément Léger
On 05/02/2025 02:21, Deepak Gupta wrote: > This patch adds support for detecting zicfiss and zicfilp. zicfiss and > zicfilp stands for unprivleged integer spec extension for shadow stack > and branch tracking on indirect branches, respectively. > > This patch looks for zicfiss and zicfilp in de

Re: [PATCH v9 14/26] riscv/traps: Introduce software check exception

2025-02-06 Thread Clément Léger
On 05/02/2025 02:22, Deepak Gupta wrote: > zicfiss / zicfilp introduces a new exception to priv isa `software check > exception` with cause code = 18. This patch implements software check > exception. Hey Deepak, While not directly related to this patch, is the exception 18 delegation document