MIPS: mm: Unify ASID version checks
Introduce a new check_mmu_context() function to check an mm's ASID version & get a new one if it's outdated, and a check_switch_mmu_context() function which additionally sets up the new ASID & page directory. Simplify switch_mm() & various get_new_mmu_context() callsites in MIPS KVM by making use of the new functions, which will help reduce the amount of code that requires modification to gain MMID support. Signed-off-by: Paul Burton <paul.burton@mips.com> Cc: linux-mips@vger.kernel.org
This commit is contained in:
@@ -17,3 +17,21 @@ void get_new_mmu_context(struct mm_struct *mm)
|
||||
|
||||
cpu_context(cpu, mm) = asid_cache(cpu) = asid;
|
||||
}
|
||||
|
||||
void check_mmu_context(struct mm_struct *mm)
|
||||
{
|
||||
unsigned int cpu = smp_processor_id();
|
||||
|
||||
/* Check if our ASID is of an older version and thus invalid */
|
||||
if ((cpu_context(cpu, mm) ^ asid_cache(cpu)) & asid_version_mask(cpu))
|
||||
get_new_mmu_context(mm);
|
||||
}
|
||||
|
||||
void check_switch_mmu_context(struct mm_struct *mm)
|
||||
{
|
||||
unsigned int cpu = smp_processor_id();
|
||||
|
||||
check_mmu_context(mm);
|
||||
write_c0_entryhi(cpu_asid(cpu, mm));
|
||||
TLBMISS_HANDLER_SETUP_PGD(mm->pgd);
|
||||
}
|
||||
|
Reference in New Issue
Block a user