// SPDX-License-Identifier: GPL-2.0-or-later /* * OpenRISC tlb.c * * Linux architectural port borrowing liberally from similar works of * others. All original copyrights apply as per the original source * declaration. * * Modifications for the OpenRISC architecture: * Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com> * Copyright (C) 2010-2011 Julius Baxter <julius.baxter@orsoc.se> * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se>
*/
#define NUM_DTLB_SETS (1 << ((mfspr(SPR_IMMUCFGR) & SPR_IMMUCFGR_NTS) >> \
SPR_DMMUCFGR_NTS_OFF)) #define NUM_ITLB_SETS (1 << ((mfspr(SPR_IMMUCFGR) & SPR_IMMUCFGR_NTS) >> \
SPR_IMMUCFGR_NTS_OFF)) #define DTLB_OFFSET(addr) (((addr) >> PAGE_SHIFT) & (NUM_DTLB_SETS-1)) #define ITLB_OFFSET(addr) (((addr) >> PAGE_SHIFT) & (NUM_ITLB_SETS-1)) /* * Invalidate all TLB entries. * * This comes down to setting the 'valid' bit for all xTLBMR registers to 0. * Easiest way to accomplish this is to just zero out the xTLBMR register * completely. *
*/
void local_flush_tlb_all(void)
{ int i; unsignedlong num_tlb_sets;
/* Determine number of sets for IMMU. */ /* FIXME: Assumption is I & D nsets equal. */
num_tlb_sets = NUM_ITLB_SETS;
for (i = 0; i < num_tlb_sets; i++) {
mtspr_off(SPR_DTLBMR_BASE(0), i, 0);
mtspr_off(SPR_ITLBMR_BASE(0), i, 0);
}
}
/* * Invalidate a single page. This is what the xTLBEIR register is for. * * There's no point in checking the vma for PAGE_EXEC to determine whether it's * the data or instruction TLB that should be flushed... that would take more * than the few instructions that the following compiles down to! * * The case where we don't have the xTLBEIR register really only works for * MMU's with a single way and is hard-coded that way.
*/
for (addr = start; addr < end; addr += PAGE_SIZE) { if (dtlbeir)
flush_dtlb_page_eir(addr); else
flush_dtlb_page_no_eir(addr);
if (itlbeir)
flush_itlb_page_eir(addr); else
flush_itlb_page_no_eir(addr);
}
}
/* * Invalidate the selected mm context only. * * FIXME: Due to some bug here, we're flushing everything for now. * This should be changed to loop over over mm and call flush_tlb_range.
*/
void local_flush_tlb_mm(struct mm_struct *mm)
{
/* Was seeing bugs with the mm struct passed to us. Scrapped most of
this function. */ /* Several architectures do this */
local_flush_tlb_all();
}
/* called in schedule() just before actually doing the switch_to */
/* remember the pgd for the fault handlers * this is similar to the pgd register in some other CPU's. * we need our own copy of it because current and active_mm * might be invalid at points where we still need to derefer * the pgd.
*/
current_pgd[cpu] = next->pgd;
/* We don't have context support implemented, so flush all * entries belonging to previous map
*/
local_flush_tlb_mm(prev);
}
/* * Initialize the context related info for a new mm_struct * instance.
*/
/* called by __exit_mm to destroy the used MMU context if any before * destroying the mm itself. this is only called when the last user of the mm * drops it.
*/
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.