mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
um: nommu: memory handling
This commit adds memory operations on UML under !MMU environment. Some part of the original UML code relying on CONFIG_MMU are excluded from compilation when !CONFIG_MMU. Additionally, generic functions such as uaccess, futex, memcpy/strnlen/strncpy can be used as user- and kernel-space share the address space in !CONFIG_MMU mode. Signed-off-by: Hajime Tazaki <thehajime@gmail.com> Signed-off-by: Ricardo Koller <ricarkol@google.com> [drop unnecessary bits] Link: https://patch.msgid.link/20260723113633.1206c739d6c0.I88b7ddf5613d072b934ce5fd9ef133ea5a4aa2b6@changeid Signed-off-by: Johannes Berg <johannes.berg@intel.com>
This commit is contained in:
parent
130031906f
commit
cf2dd04179
|
|
@ -7,8 +7,12 @@
|
|||
#include <asm/errno.h>
|
||||
|
||||
|
||||
#ifdef CONFIG_MMU
|
||||
int arch_futex_atomic_op_inuser(int op, u32 oparg, int *oval, u32 __user *uaddr);
|
||||
int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
|
||||
u32 oldval, u32 newval);
|
||||
#else
|
||||
#include <asm-generic/futex.h>
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -22,10 +22,13 @@ typedef struct mm_context {
|
|||
unsigned long sync_tlb_range_from;
|
||||
unsigned long sync_tlb_range_to;
|
||||
|
||||
#ifndef CONFIG_MMU
|
||||
unsigned long end_brk;
|
||||
#ifdef CONFIG_BINFMT_ELF_FDPIC
|
||||
unsigned long exec_fdpic_loadmap;
|
||||
unsigned long interp_fdpic_loadmap;
|
||||
#endif
|
||||
#endif /* !CONFIG_MMU */
|
||||
} mm_context_t;
|
||||
|
||||
#define INIT_MM_CONTEXT(mm) \
|
||||
|
|
|
|||
|
|
@ -18,11 +18,13 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
|
|||
{
|
||||
}
|
||||
|
||||
#ifdef CONFIG_MMU
|
||||
#define init_new_context init_new_context
|
||||
extern int init_new_context(struct task_struct *task, struct mm_struct *mm);
|
||||
|
||||
#define destroy_context destroy_context
|
||||
extern void destroy_context(struct mm_struct *mm);
|
||||
#endif
|
||||
|
||||
#include <asm-generic/mmu_context.h>
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
#define __addr_range_nowrap(addr, size) \
|
||||
((unsigned long) (addr) <= ((unsigned long) (addr) + (size)))
|
||||
|
||||
#ifdef CONFIG_MMU
|
||||
extern unsigned long raw_copy_from_user(void *to, const void __user *from, unsigned long n);
|
||||
extern unsigned long raw_copy_to_user(void __user *to, const void *from, unsigned long n);
|
||||
extern unsigned long __clear_user(void __user *mem, unsigned long len);
|
||||
|
|
@ -29,8 +30,6 @@ static inline int __access_ok(const void __user *ptr, unsigned long size);
|
|||
|
||||
#define INLINE_COPY_USER
|
||||
|
||||
#include <asm-generic/uaccess.h>
|
||||
|
||||
static inline int __access_ok(const void __user *ptr, unsigned long size)
|
||||
{
|
||||
unsigned long addr = (unsigned long)ptr;
|
||||
|
|
@ -62,5 +61,8 @@ do { \
|
|||
barrier(); \
|
||||
current->thread.segv_continue = NULL; \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#include <asm-generic/uaccess.h>
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -64,7 +64,8 @@ void __init arch_mm_preinit(void)
|
|||
* to be turned on.
|
||||
*/
|
||||
brk_end = PAGE_ALIGN((unsigned long) sbrk(0));
|
||||
map_memory(brk_end, __pa(brk_end), uml_reserved - brk_end, 1, 1, 0);
|
||||
map_memory(brk_end, __pa(brk_end), uml_reserved - brk_end, 1, 1,
|
||||
!IS_ENABLED(CONFIG_MMU));
|
||||
memblock_free((void *)brk_end, uml_reserved - brk_end);
|
||||
uml_reserved = brk_end;
|
||||
min_low_pfn = PFN_UP(__pa(uml_reserved));
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user