Skip to content

Commit d191aaf

Browse files
chenhuacaitsbogend
authored andcommitted
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: <[email protected]> Signed-off-by: Pei Huang <[email protected]> Signed-off-by: Huacai Chen <[email protected]> Signed-off-by: Thomas Bogendoerfer <[email protected]>
1 parent 78bdbba commit d191aaf

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

arch/mips/mm/tlbex.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1480,6 +1480,7 @@ static void build_r4000_tlb_refill_handler(void)
14801480

14811481
static void setup_pw(void)
14821482
{
1483+
unsigned int pwctl;
14831484
unsigned long pgd_i, pgd_w;
14841485
#ifndef __PAGETABLE_PMD_FOLDED
14851486
unsigned long pmd_i, pmd_w;
@@ -1506,6 +1507,7 @@ static void setup_pw(void)
15061507

15071508
pte_i = ilog2(_PAGE_GLOBAL);
15081509
pte_w = 0;
1510+
pwctl = 1 << 30; /* Set PWDirExt */
15091511

15101512
#ifndef __PAGETABLE_PMD_FOLDED
15111513
write_c0_pwfield(pgd_i << 24 | pmd_i << 12 | pt_i << 6 | pte_i);
@@ -1516,8 +1518,9 @@ static void setup_pw(void)
15161518
#endif
15171519

15181520
#ifdef CONFIG_MIPS_HUGE_TLB_SUPPORT
1519-
write_c0_pwctl(1 << 6 | psn);
1521+
pwctl |= (1 << 6 | psn);
15201522
#endif
1523+
write_c0_pwctl(pwctl);
15211524
write_c0_kpgd((long)swapper_pg_dir);
15221525
kscratch_used_mask |= (1 << 7); /* KScratch6 is used for KPGD */
15231526
}

0 commit comments

Comments
 (0)