mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00

When pointer masking is enabled for userspace, the kernel can accept tagged pointers as arguments to some system calls. Allow this by untagging the pointers in access_ok() and the uaccess routines. The uaccess routines must peform untagging in software because U-mode and S-mode have entirely separate pointer masking configurations. In fact, hardware may not even implement pointer masking for S-mode. Since the number of tag bits is variable, untagged_addr_remote() needs to know what PMLEN to use for the remote mm. Therefore, the pointer masking mode must be the same for all threads sharing an mm. Enforce this with a lock flag in the mm context, as x86 does for LAM. The flag gets reset in init_new_context() during fork(), as the new mm is no longer multithreaded. Reviewed-by: Charlie Jenkins <charlie@rivosinc.com> Tested-by: Charlie Jenkins <charlie@rivosinc.com> Signed-off-by: Samuel Holland <samuel.holland@sifive.com> Link: https://lore.kernel.org/r/20241016202814.4061541-6-samuel.holland@sifive.com Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
45 lines
1 KiB
C
45 lines
1 KiB
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
/*
|
|
* Copyright (C) 2012 Regents of the University of California
|
|
*/
|
|
|
|
|
|
#ifndef _ASM_RISCV_MMU_H
|
|
#define _ASM_RISCV_MMU_H
|
|
|
|
#ifndef __ASSEMBLY__
|
|
|
|
typedef struct {
|
|
#ifndef CONFIG_MMU
|
|
unsigned long end_brk;
|
|
#else
|
|
atomic_long_t id;
|
|
#endif
|
|
void *vdso;
|
|
#ifdef CONFIG_SMP
|
|
/* A local icache flush is needed before user execution can resume. */
|
|
cpumask_t icache_stale_mask;
|
|
/* Force local icache flush on all migrations. */
|
|
bool force_icache_flush;
|
|
#endif
|
|
#ifdef CONFIG_BINFMT_ELF_FDPIC
|
|
unsigned long exec_fdpic_loadmap;
|
|
unsigned long interp_fdpic_loadmap;
|
|
#endif
|
|
unsigned long flags;
|
|
#ifdef CONFIG_RISCV_ISA_SUPM
|
|
u8 pmlen;
|
|
#endif
|
|
} mm_context_t;
|
|
|
|
/* Lock the pointer masking mode because this mm is multithreaded */
|
|
#define MM_CONTEXT_LOCK_PMLEN 0
|
|
|
|
#define cntx2asid(cntx) ((cntx) & SATP_ASID_MASK)
|
|
#define cntx2version(cntx) ((cntx) & ~SATP_ASID_MASK)
|
|
|
|
void __meminit create_pgd_mapping(pgd_t *pgdp, uintptr_t va, phys_addr_t pa, phys_addr_t sz,
|
|
pgprot_t prot);
|
|
#endif /* __ASSEMBLY__ */
|
|
|
|
#endif /* _ASM_RISCV_MMU_H */
|