2019-05-29 07:18:00 -07:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2017-07-10 18:06:09 -07:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2012 Regents of the University of California
|
2017-10-25 14:30:32 -07:00
|
|
|
* Copyright (C) 2017 SiFive
|
2017-07-10 18:06:09 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _ASM_RISCV_MMU_CONTEXT_H
|
|
|
|
#define _ASM_RISCV_MMU_CONTEXT_H
|
|
|
|
|
2017-11-29 17:55:20 -08:00
|
|
|
#include <linux/mm_types.h>
|
2017-07-10 18:06:09 -07:00
|
|
|
#include <asm-generic/mm_hooks.h>
|
|
|
|
|
|
|
|
#include <linux/mm.h>
|
|
|
|
#include <linux/sched.h>
|
|
|
|
|
2019-03-27 00:41:29 +00:00
|
|
|
void switch_mm(struct mm_struct *prev, struct mm_struct *next,
|
|
|
|
struct task_struct *task);
|
2017-07-10 18:06:09 -07:00
|
|
|
|
2020-09-02 00:15:33 +10:00
|
|
|
#define activate_mm activate_mm
|
2017-07-10 18:06:09 -07:00
|
|
|
static inline void activate_mm(struct mm_struct *prev,
|
|
|
|
struct mm_struct *next)
|
|
|
|
{
|
2024-10-16 13:27:46 -07:00
|
|
|
#ifdef CONFIG_RISCV_ISA_SUPM
|
|
|
|
next->context.pmlen = 0;
|
|
|
|
#endif
|
2017-07-10 18:06:09 -07:00
|
|
|
switch_mm(prev, next, NULL);
|
|
|
|
}
|
|
|
|
|
2021-02-03 15:19:07 +05:30
|
|
|
#define init_new_context init_new_context
|
|
|
|
static inline int init_new_context(struct task_struct *tsk,
|
|
|
|
struct mm_struct *mm)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_MMU
|
|
|
|
atomic_long_set(&mm->context.id, 0);
|
|
|
|
#endif
|
2024-10-16 13:27:46 -07:00
|
|
|
if (IS_ENABLED(CONFIG_RISCV_ISA_SUPM))
|
|
|
|
clear_bit(MM_CONTEXT_LOCK_PMLEN, &mm->context.flags);
|
2021-02-03 15:19:07 +05:30
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-06-06 17:20:50 +02:00
|
|
|
DECLARE_STATIC_KEY_FALSE(use_asid_allocator);
|
|
|
|
|
2024-10-16 13:27:46 -07:00
|
|
|
#ifdef CONFIG_RISCV_ISA_SUPM
|
|
|
|
#define mm_untag_mask mm_untag_mask
|
|
|
|
static inline unsigned long mm_untag_mask(struct mm_struct *mm)
|
|
|
|
{
|
|
|
|
return -1UL >> mm->context.pmlen;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2020-09-02 00:15:33 +10:00
|
|
|
#include <asm-generic/mmu_context.h>
|
2017-07-10 18:06:09 -07:00
|
|
|
|
|
|
|
#endif /* _ASM_RISCV_MMU_CONTEXT_H */
|