Skip to content

Commit 36de10c

Browse files
committed
xtensa: fix TLB sanity checker
Virtual and translated addresses retrieved by the xtensa TLB sanity checker must be consistent, i.e. correspond to the same state of the checked TLB entry. KASAN shadow memory is mapped dynamically using auto-refill TLB entries and thus may change TLB state between the virtual and translated address retrieval, resulting in false TLB insanity report. Move read_xtlb_translation close to read_xtlb_virtual to make sure that read values are consistent. Cc: [email protected] Fixes: a99e07e ("xtensa: check TLB sanity on return to userspace") Signed-off-by: Max Filippov <[email protected]>
1 parent f5ee256 commit 36de10c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

arch/xtensa/mm/tlb.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,8 @@ static int check_tlb_entry(unsigned w, unsigned e, bool dtlb)
224224
unsigned tlbidx = w | (e << PAGE_SHIFT);
225225
unsigned r0 = dtlb ?
226226
read_dtlb_virtual(tlbidx) : read_itlb_virtual(tlbidx);
227+
unsigned r1 = dtlb ?
228+
read_dtlb_translation(tlbidx) : read_itlb_translation(tlbidx);
227229
unsigned vpn = (r0 & PAGE_MASK) | (e << PAGE_SHIFT);
228230
unsigned pte = get_pte_for_vaddr(vpn);
229231
unsigned mm_asid = (get_rasid_register() >> 8) & ASID_MASK;
@@ -239,8 +241,6 @@ static int check_tlb_entry(unsigned w, unsigned e, bool dtlb)
239241
}
240242

241243
if (tlb_asid == mm_asid) {
242-
unsigned r1 = dtlb ? read_dtlb_translation(tlbidx) :
243-
read_itlb_translation(tlbidx);
244244
if ((pte ^ r1) & PAGE_MASK) {
245245
pr_err("%cTLB: way: %u, entry: %u, mapping: %08x->%08x, PTE: %08x\n",
246246
dtlb ? 'D' : 'I', w, e, r0, r1, pte);

0 commit comments

Comments
 (0)