mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-25 14:43:46 +07:00
1031398035
Since MIPSr6 the Wired register is split into 2 fields, with the upper
16 bits of the register indicating a limit on the value that the wired
entry count in the bottom 16 bits of the register can take. This means
that simply reading the wired register doesn't get us a valid TLB entry
index any longer, and we instead need to retrieve only the lower 16 bits
of the register. Introduce a new num_wired_entries() function which does
this on MIPSr6 or higher and simply returns the value of the wired
register on older architecture revisions, and make use of it when
reading the number of wired entries.
Since commit e710d66683
("MIPS: tlb-r4k: If there are wired entries,
don't use TLBINVF") we have been using a non-zero number of wired
entries to determine whether we should avoid use of the tlbinvf
instruction (which would invalidate wired entries) and instead loop over
TLB entries in local_flush_tlb_all(). This loop begins with the number
of wired entries, or before this patch some large bogus TLB index on
MIPSr6 systems. Thus since the aforementioned commit some MIPSr6 systems
with FTLBs have been prone to leaving stale address translations in the
FTLB & crashing in various weird & wonderful ways when we later observe
the wrong memory.
Signed-off-by: Paul Burton <paul.burton@imgtec.com>
Cc: Matt Redfearn <matt.redfearn@imgtec.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/14557/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
41 lines
947 B
C
41 lines
947 B
C
#ifndef __ASM_TLB_H
|
|
#define __ASM_TLB_H
|
|
|
|
#include <asm/cpu-features.h>
|
|
#include <asm/mipsregs.h>
|
|
|
|
/*
|
|
* MIPS doesn't need any special per-pte or per-vma handling, except
|
|
* we need to flush cache for area to be unmapped.
|
|
*/
|
|
#define tlb_start_vma(tlb, vma) \
|
|
do { \
|
|
if (!tlb->fullmm) \
|
|
flush_cache_range(vma, vma->vm_start, vma->vm_end); \
|
|
} while (0)
|
|
#define tlb_end_vma(tlb, vma) do { } while (0)
|
|
#define __tlb_remove_tlb_entry(tlb, ptep, address) do { } while (0)
|
|
|
|
/*
|
|
* .. because we flush the whole mm when it fills up.
|
|
*/
|
|
#define tlb_flush(tlb) flush_tlb_mm((tlb)->mm)
|
|
|
|
#define UNIQUE_ENTRYHI(idx) \
|
|
((CKSEG0 + ((idx) << (PAGE_SHIFT + 1))) | \
|
|
(cpu_has_tlbinv ? MIPS_ENTRYHI_EHINV : 0))
|
|
|
|
static inline unsigned int num_wired_entries(void)
|
|
{
|
|
unsigned int wired = read_c0_wired();
|
|
|
|
if (cpu_has_mips_r6)
|
|
wired &= MIPSR6_WIRED_WIRED;
|
|
|
|
return wired;
|
|
}
|
|
|
|
#include <asm-generic/tlb.h>
|
|
|
|
#endif /* __ASM_TLB_H */
|