Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

MIPS/tlbex: Fix LDDIR usage in setup_pw() for Loongson-3

LDDIR/LDPTE is Loongson-3's acceleration for Page Table Walking. If BD
(Base Directory, the 4th page directory) is not enabled, then GDOffset
is biased by BadVAddr[63:62]. So, if GDOffset (aka. BadVAddr[47:36] for
Loongson-3) is big enough, "0b11(BadVAddr[63:62])|BadVAddr[47:36]|...."
can far beyond pg_swapper_dir. This means the pg_swapper_dir may NOT be
accessed by LDDIR correctly, so fix it by set PWDirExt in CP0_PWCtl.

Cc: <stable@vger.kernel.org>
Signed-off-by: Pei Huang <huangpei@loongson.cn>
Signed-off-by: Huacai Chen <chenhc@lemote.com>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>

authored by

Huacai Chen and committed by
Thomas Bogendoerfer
d191aaff 78bdbbac

+4 -1
+4 -1
arch/mips/mm/tlbex.c
··· 1480 1480 1481 1481 static void setup_pw(void) 1482 1482 { 1483 + unsigned int pwctl; 1483 1484 unsigned long pgd_i, pgd_w; 1484 1485 #ifndef __PAGETABLE_PMD_FOLDED 1485 1486 unsigned long pmd_i, pmd_w; ··· 1507 1506 1508 1507 pte_i = ilog2(_PAGE_GLOBAL); 1509 1508 pte_w = 0; 1509 + pwctl = 1 << 30; /* Set PWDirExt */ 1510 1510 1511 1511 #ifndef __PAGETABLE_PMD_FOLDED 1512 1512 write_c0_pwfield(pgd_i << 24 | pmd_i << 12 | pt_i << 6 | pte_i); ··· 1518 1516 #endif 1519 1517 1520 1518 #ifdef CONFIG_MIPS_HUGE_TLB_SUPPORT 1521 - write_c0_pwctl(1 << 6 | psn); 1519 + pwctl |= (1 << 6 | psn); 1522 1520 #endif 1521 + write_c0_pwctl(pwctl); 1523 1522 write_c0_kpgd((long)swapper_pg_dir); 1524 1523 kscratch_used_mask |= (1 << 7); /* KScratch6 is used for KPGD */ 1525 1524 }