Path: blob/master/arch/parisc/include/asm/mmu_context.h
26298 views
/* SPDX-License-Identifier: GPL-2.0 */1#ifndef __PARISC_MMU_CONTEXT_H2#define __PARISC_MMU_CONTEXT_H34#include <linux/mm.h>5#include <linux/sched.h>6#include <linux/atomic.h>7#include <linux/spinlock.h>8#include <asm-generic/mm_hooks.h>910/* on PA-RISC, we actually have enough contexts to justify an allocator11* for them. prumpf */1213extern unsigned long alloc_sid(void);14extern void free_sid(unsigned long);1516#define init_new_context init_new_context17static inline int18init_new_context(struct task_struct *tsk, struct mm_struct *mm)19{20BUG_ON(atomic_read(&mm->mm_users) != 1);2122mm->context.space_id = alloc_sid();23return 0;24}2526#define destroy_context destroy_context27static inline void28destroy_context(struct mm_struct *mm)29{30free_sid(mm->context.space_id);31mm->context.space_id = 0;32}3334static inline unsigned long __space_to_prot(mm_context_t context)35{36#if SPACEID_SHIFT == 037return context.space_id << 1;38#else39return context.space_id >> (SPACEID_SHIFT - 1);40#endif41}4243static inline void load_context(mm_context_t context)44{45mtsp(context.space_id, SR_USER);46mtctl(__space_to_prot(context), 8);47}4849static inline void switch_mm_irqs_off(struct mm_struct *prev,50struct mm_struct *next, struct task_struct *tsk)51{52if (prev != next) {53#ifdef CONFIG_TLB_PTLOCK54/* put physical address of page_table_lock in cr28 (tr4)55for TLB faults */56spinlock_t *pgd_lock = &next->page_table_lock;57mtctl(__pa(__ldcw_align(&pgd_lock->rlock.raw_lock)), 28);58#endif59mtctl(__pa(next->pgd), 25);60load_context(next->context);61}62}6364static inline void switch_mm(struct mm_struct *prev,65struct mm_struct *next, struct task_struct *tsk)66{67unsigned long flags;6869if (prev == next)70return;7172local_irq_save(flags);73switch_mm_irqs_off(prev, next, tsk);74local_irq_restore(flags);75}76#define switch_mm_irqs_off switch_mm_irqs_off7778#define activate_mm activate_mm79static inline void activate_mm(struct mm_struct *prev, struct mm_struct *next)80{81/*82* Activate_mm is our one chance to allocate a space id83* for a new mm created in the exec path. There's also84* some lazy tlb stuff, which is currently dead code, but85* we only allocate a space id if one hasn't been allocated86* already, so we should be OK.87*/8889BUG_ON(next == &init_mm); /* Should never happen */9091if (next->context.space_id == 0)92next->context.space_id = alloc_sid();9394switch_mm(prev,next,current);95}9697#include <asm-generic/mmu_context.h>9899#endif100101102