Skip to content

Commit ad5643c

Browse files
SiFiveHollandpalmer-dabbelt
authored andcommitted
riscv: Define TASK_SIZE_MAX for __access_ok()
TASK_SIZE_MAX should be set to a constant value, at least the largest valid userspace address under any runtime configuration. This optimizes the check in __access_ok(), which no longer needs to compute the runtime value of TASK_SIZE. The check does not need to be exact, as long as it accepts all valid userspace addresses and rejects all valid kernel addresses; well-behaved programs will never fail the access_ok() check. For RISC-V, which requires all virtual addresses to be sign extended, the optimal choice is LONG_MAX because it simplifies the limit comparison to a sign bit test. This removes about half of the references to pgtable_l[45]_enabled. Signed-off-by: Samuel Holland <[email protected]> Reviewed-by: Arnd Bergmann <[email protected]> Reviewed-by: Alexandre Ghiti <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 9ad6bb3 commit ad5643c

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

arch/riscv/include/asm/pgtable.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -870,6 +870,7 @@ static inline pte_t pte_swp_clear_exclusive(pte_t pte)
870870
*/
871871
#ifdef CONFIG_64BIT
872872
#define TASK_SIZE_64 (PGDIR_SIZE * PTRS_PER_PGD / 2)
873+
#define TASK_SIZE_MAX LONG_MAX
873874

874875
#ifdef CONFIG_COMPAT
875876
#define TASK_SIZE_32 (_AC(0x80000000, UL) - PAGE_SIZE)

0 commit comments

Comments
 (0)