From 16c34ef60c7735425f0990e859f13b0fdf3f15f3 Mon Sep 17 00:00:00 2001 From: Mark Johnston Date: Thu, 23 Feb 2023 12:40:37 -0500 Subject: [PATCH 49/52] mips: Fix tlb_update() for "odd" superpage mappings Superpage mappings require special treatment here since a superpage PDE always corresponds to the low half of a TLB entry. When handling a fault on the upper half of a superpage mapping, we were writing the same value to both lo0 and lo1. --- sys/mips/mips/tlb.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sys/mips/mips/tlb.c b/sys/mips/mips/tlb.c index 0e24d1d673be..79cee32a8b8a 100644 --- a/sys/mips/mips/tlb.c +++ b/sys/mips/mips/tlb.c @@ -365,12 +365,15 @@ tlb_update(struct pmap *pmap, vm_offset_t va, pt_entry_t pte) printf("%s:%d va %#lx pte %#lx pte1 %#lx\n", __func__, __LINE__, va, pte, pte1); } } else { - mips_wr_entrylo1(pte); if (pagemask & ~PAGE_MASK) { /* Superpage */ + pte += (size >> PAGE_SHIFT) << TLBLO_PFN_SHIFT; + mips_wr_entrylo1(pte); pte0 = (pte0 & ~(PTE_VR | PTE_D)) | (pte & (PTE_VR | PTE_D)); mips_wr_entrylo0(pte0); printf("%s:%d va %#lx pte %#lx pte0 %#lx\n", __func__, __LINE__, va, pte, pte0); + } else { + mips_wr_entrylo1(pte); } } tlb_write_indexed(); -- 2.41.0