summaryrefslogtreecommitdiff
path: root/lib/sbi/sbi_fwft.c
AgeCommit message (Collapse)Author
2026-05-11lib: sbi: Fix hw a/d updating defaultsAndrew Jones
The Svade dt-binding description states that Svadu should only be enabled at boot time when only Svadu is present in the DT. Ensure that's the case. Also, when only Svadu is supported, disable FWFT.PTE_AD_HW_UPDATING, as we need both to support toggling. Signed-off-by: Andrew Jones <[email protected]> Reviewed-by: Radim Krčmář <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2025-12-16lib: sbi: Flush TLBs upon FWFT ADUE changeAndrew Waterman
A clarification has been added to the RISC-V privileged specification regarding synchronization requirements when xenvcfg.ADUE changes. (Refer, the following commit in the RISC-V Privileged ISA spec https://github.com/riscv/riscv-isa-manual/commit/4e540263db8ae3a27d132a1752cc0fad222facd8) As-per these requirements, the SBI FWFT ADUE implementation must flush TLBs upon changes in ADUE state on a hart. Signed-off-by: Andrew Waterman <[email protected]> Signed-off-by: Anup Patel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2025-06-15lib: sbi: fwft: Use only the provided PMLEN valueSamuel Holland
As of riscv-sbi-doc commit c7d3d1f7dcaa ("ext-fwft: use the provided value in fwft_set(POINTER_MASKING_PMLEN)"), the SBI implementation must use only the provided PMLEN value or else fail. It may not fall back to a larger PMLEN value. Signed-off-by: Samuel Holland <[email protected]> Reviewed-by: Radim Krčmář <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2025-02-19lib: sbi: fwft: Return SBI_ERR_DENIED_LOCKED when setting a locked featureClément Léger
Latest modifications to the spec mandates that a set on a lock feature returns SBI_ERR_DENIED_LOCKED. Signed-off-by: Clément Léger <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-11-28sbi: fwft: clear the config lock when warm bootNick Hu
The hotplug cpu should clear the fwft config's SBI_FWFT_SET_FLAG_LOCK in the warm boot flow otherwise the cpu can't set the menvcfg.sse by SBI_EXT_FWFT_SET sbi call and cause the illegal instruction when accessing the CSR_SSP in kernel. Signed-off-by: Nick Hu <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-10-25lib: sbi: implement firmware feature SBI_FWFT_DOUBLE_TRAPClément Léger
Add support for double trap firmware feature. Link: https://lists.riscv.org/g/tech-prs/message/985 [1] Signed-off-by: Clément Léger <[email protected]> Reviewed-by: Samuel Holland <[email protected]>
2024-10-25lib: sbi: fwft: factorize menvcfg read/writeClément Léger
MENVCFG access will be used as well for double trap, landing pad and shadow stack fwft support. Factorize that in a common function. Signed-off-by: Clément Léger <[email protected]> Reviewed-by: Samuel Holland <[email protected]>
2024-09-23lib: sbi: fwft: implement landing pad and shadow stack fwft interfaceDeepak Gupta
Supervisor software can enable control flow integrity features for itself using fwft feature `SBI_FWFT_LANDING_PAD` and `SBI_FWFT_SHADOW_STACK`. This patch implements the mechanism to enable both these fwft. Signed-off-by: Deepak Gupta <[email protected]> Reviewed-by: Atish Patra <[email protected]> Reviewed-by: Clément Léger <[email protected]>
2024-09-23lib: sbi: fwft: add support for SBI_FWFT_POINTER_MASKING_PMLENSamuel Holland
Add support for controlling the pointer masking mode on harts which support the Smnpm extension. This extension can only exist on harts where XLEN >= 64 bits. This implementation selects the mode with the smallest PMLEN that satisfies the caller's requested lower bound. Signed-off-by: Samuel Holland <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-08-02lib: sbi: fwft: fix incorrect size passed to sbi_zalloc()Carlos López
The fwt_hart_state struct inciludes a flexible array member, so its allocation size will be that of the struct itself, plus that of each of the members in the array. When calculating this size, instead of taking the size of the struct, the size of a pointer to it was taken, which is incorrect. Luckily, this happenned to not produce memory corruption because the size of the non-flexible members of the struct is the same as the size of a pointer. Signed-off-by: Carlos López <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-06-26lib: sbi: fwft: return SBI_EINVAL rather than SBI_ERR_INVALID_PARAMClément Léger
Error code returned by the ecall handles should use the defines from sbi_ecall_interface.h rather than sbi_error.h. Signed-off-by: Clément Léger <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-06-26lib: sbi: fwft: check feature value to be exactly 1 or 0Clément Léger
As stated by the spec and pointed out by Andrew Jones, the value passed for MISALIGNED_EXC_DELEG and PTE_AD_HW_UPDATING should be either 0 or 1. Add check for these values and return SBI_EINVAL if not. Signed-off-by: Clément Léger <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-06-19lib: sbi: fwft: add support for SBI_FWFT_PTE_AD_HW_UPDATINGClément Léger
Add support for SBI_FWFT_PTE_AD_HW_UPDATING based on SVADU presence. Signed-off-by: Clément Léger <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-06-19lib: sbi: fwft: add support for SBI_FWFT_MISALIGNED_EXC_DELEGClément Léger
Add support for SBI_FWFT_MISALIGNED_EXC_DELEG withing FWFT support. This support allows to delegate misaligned accesses traps. Signed-off-by: Clément Léger <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-06-19lib: sbi: add support for firmware features extensionClément Léger
This extension allows the software running in supervisor mode to control the behavior of various features of the SBI [1]. Implement the support for such extension. Link: https://lists.riscv.org/g/tech-prs/message/924 [1] Signed-off-by: Clément Léger <[email protected]> Reviewed-by: Anup Patel <[email protected]>