2005-04-17 05:20:36 +07:00
|
|
|
/*
|
|
|
|
* Dump R4x00 TLB for debugging purposes.
|
|
|
|
*
|
|
|
|
* Copyright (C) 1994, 1995 by Waldorf Electronics, written by Ralf Baechle.
|
|
|
|
* Copyright (C) 1999 by Silicon Graphics, Inc.
|
|
|
|
*/
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/mm.h>
|
|
|
|
|
2015-05-19 15:50:32 +07:00
|
|
|
#include <asm/hazards.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
#include <asm/mipsregs.h>
|
|
|
|
#include <asm/page.h>
|
|
|
|
#include <asm/pgtable.h>
|
2007-07-11 22:51:00 +07:00
|
|
|
#include <asm/tlbdebug.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2015-07-15 22:17:43 +07:00
|
|
|
void dump_tlb_regs(void)
|
|
|
|
{
|
|
|
|
const int field = 2 * sizeof(unsigned long);
|
|
|
|
|
|
|
|
pr_info("Index : %0x\n", read_c0_index());
|
|
|
|
pr_info("PageMask : %0x\n", read_c0_pagemask());
|
|
|
|
pr_info("EntryHi : %0*lx\n", field, read_c0_entryhi());
|
|
|
|
pr_info("EntryLo0 : %0*lx\n", field, read_c0_entrylo0());
|
|
|
|
pr_info("EntryLo1 : %0*lx\n", field, read_c0_entrylo1());
|
|
|
|
pr_info("Wired : %0x\n", read_c0_wired());
|
|
|
|
pr_info("PageGrain: %0x\n", read_c0_pagegrain());
|
|
|
|
if (cpu_has_htw) {
|
|
|
|
pr_info("PWField : %0*lx\n", field, read_c0_pwfield());
|
|
|
|
pr_info("PWSize : %0*lx\n", field, read_c0_pwsize());
|
|
|
|
pr_info("PWCtl : %0x\n", read_c0_pwctl());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
static inline const char *msk2str(unsigned int mask)
|
|
|
|
{
|
|
|
|
switch (mask) {
|
|
|
|
case PM_4K: return "4kb";
|
|
|
|
case PM_16K: return "16kb";
|
|
|
|
case PM_64K: return "64kb";
|
|
|
|
case PM_256K: return "256kb";
|
2009-04-02 19:07:10 +07:00
|
|
|
#ifdef CONFIG_CPU_CAVIUM_OCTEON
|
|
|
|
case PM_8K: return "8kb";
|
|
|
|
case PM_32K: return "32kb";
|
|
|
|
case PM_128K: return "128kb";
|
|
|
|
case PM_512K: return "512kb";
|
|
|
|
case PM_2M: return "2Mb";
|
|
|
|
case PM_8M: return "8Mb";
|
|
|
|
case PM_32M: return "32Mb";
|
|
|
|
#endif
|
2005-04-17 05:20:36 +07:00
|
|
|
#ifndef CONFIG_CPU_VR41XX
|
|
|
|
case PM_1M: return "1Mb";
|
|
|
|
case PM_4M: return "4Mb";
|
|
|
|
case PM_16M: return "16Mb";
|
|
|
|
case PM_64M: return "64Mb";
|
|
|
|
case PM_256M: return "256Mb";
|
2008-10-23 23:27:57 +07:00
|
|
|
case PM_1G: return "1Gb";
|
2005-04-17 05:20:36 +07:00
|
|
|
#endif
|
|
|
|
}
|
2007-06-01 22:21:30 +07:00
|
|
|
return "";
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2007-06-01 22:30:25 +07:00
|
|
|
static void dump_tlb(int first, int last)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2007-06-01 22:21:30 +07:00
|
|
|
unsigned long s_entryhi, entryhi, asid;
|
MIPS: dump_tlb: Take RI/XI bits into account
The RI/XI bits when present are above the PFN field in the EntryLo
registers, at bits 63,62 when read with dmfc0, and bits 31,30 when read
with mfc0. This makes them appear as part of the physical address, since
the other bits are masked with PAGE_MASK, for example:
Index: 253 pgmask=16kb va=77b18000 asid=75
[pa=1000744000 c=5 d=1 v=1 g=0] [pa=100134c000 c=5 d=1 v=1 g=0]
The physical addresses have bit 36 set, which corresponds to bit 30 of
EntryLo1, the XI bit.
Explicitly mask off the RI and XI bits from the printed physical
address, and print the RI and XI bits separately if they exist, giving
output more like this:
Index: 226 pgmask=16kb va=77be0000 asid=79
[ri=0 xi=1 pa=01288000 c=5 d=1 v=1 g=0] [ri=0 xi=0 pa=010e4000 c=5 d=0 v=1 g=0]
Cc: linux-mips@linux-mips.org
Cc: James Hogan <james.hogan@imgtec.com>
Cc: David Daney <ddaney@caviumnetworks.com>
Patchwork: https://patchwork.linux-mips.org/patch/10080/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
2015-05-19 15:50:37 +07:00
|
|
|
unsigned long long entrylo0, entrylo1, pa;
|
2012-10-17 06:01:20 +07:00
|
|
|
unsigned int s_index, s_pagemask, pagemask, c0, c1, i;
|
2015-05-19 15:50:33 +07:00
|
|
|
#ifdef CONFIG_32BIT
|
2015-05-19 15:50:38 +07:00
|
|
|
bool xpa = cpu_has_xpa && (read_c0_pagegrain() & PG_ELPA);
|
|
|
|
int pwidth = xpa ? 11 : 8;
|
|
|
|
int vwidth = 8;
|
2015-05-19 15:50:33 +07:00
|
|
|
#else
|
2015-05-19 15:50:38 +07:00
|
|
|
bool xpa = false;
|
|
|
|
int pwidth = 11;
|
|
|
|
int vwidth = 11;
|
2015-05-19 15:50:33 +07:00
|
|
|
#endif
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2012-10-17 06:01:20 +07:00
|
|
|
s_pagemask = read_c0_pagemask();
|
2005-04-17 05:20:36 +07:00
|
|
|
s_entryhi = read_c0_entryhi();
|
|
|
|
s_index = read_c0_index();
|
2013-05-14 03:56:44 +07:00
|
|
|
asid = s_entryhi & 0xff;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
for (i = first; i <= last; i++) {
|
|
|
|
write_c0_index(i);
|
2015-05-19 15:50:32 +07:00
|
|
|
mtc0_tlbr_hazard();
|
2005-04-17 05:20:36 +07:00
|
|
|
tlb_read();
|
2015-05-19 15:50:32 +07:00
|
|
|
tlb_read_hazard();
|
2005-04-17 05:20:36 +07:00
|
|
|
pagemask = read_c0_pagemask();
|
2013-01-22 18:59:30 +07:00
|
|
|
entryhi = read_c0_entryhi();
|
2005-04-17 05:20:36 +07:00
|
|
|
entrylo0 = read_c0_entrylo0();
|
|
|
|
entrylo1 = read_c0_entrylo1();
|
|
|
|
|
2015-05-19 15:50:36 +07:00
|
|
|
/* EHINV bit marks entire entry as invalid */
|
|
|
|
if (cpu_has_tlbinv && entryhi & MIPS_ENTRYHI_EHINV)
|
|
|
|
continue;
|
2015-05-19 15:50:33 +07:00
|
|
|
/*
|
|
|
|
* Prior to tlbinv, unused entries have a virtual address of
|
|
|
|
* CKSEG0.
|
|
|
|
*/
|
|
|
|
if ((entryhi & ~0x1ffffUL) == CKSEG0)
|
|
|
|
continue;
|
2015-05-19 15:50:35 +07:00
|
|
|
/*
|
|
|
|
* ASID takes effect in absence of G (global) bit.
|
|
|
|
* We check both G bits, even though architecturally they should
|
|
|
|
* match one another, because some revisions of the SB1 core may
|
|
|
|
* leave only a single G bit set after a machine check exception
|
|
|
|
* due to duplicate TLB entry.
|
|
|
|
*/
|
|
|
|
if (!((entrylo0 | entrylo1) & MIPS_ENTRYLO_G) &&
|
|
|
|
(entryhi & 0xff) != asid)
|
2015-05-19 15:50:33 +07:00
|
|
|
continue;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Only print entries in use
|
|
|
|
*/
|
|
|
|
printk("Index: %2d pgmask=%s ", i, msk2str(pagemask));
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2015-05-19 15:50:34 +07:00
|
|
|
c0 = (entrylo0 & MIPS_ENTRYLO_C) >> MIPS_ENTRYLO_C_SHIFT;
|
|
|
|
c1 = (entrylo1 & MIPS_ENTRYLO_C) >> MIPS_ENTRYLO_C_SHIFT;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2015-05-19 15:50:33 +07:00
|
|
|
printk("va=%0*lx asid=%02lx\n",
|
2015-05-19 15:50:38 +07:00
|
|
|
vwidth, (entryhi & ~0x1fffUL),
|
2015-05-19 15:50:33 +07:00
|
|
|
entryhi & 0xff);
|
MIPS: dump_tlb: Take RI/XI bits into account
The RI/XI bits when present are above the PFN field in the EntryLo
registers, at bits 63,62 when read with dmfc0, and bits 31,30 when read
with mfc0. This makes them appear as part of the physical address, since
the other bits are masked with PAGE_MASK, for example:
Index: 253 pgmask=16kb va=77b18000 asid=75
[pa=1000744000 c=5 d=1 v=1 g=0] [pa=100134c000 c=5 d=1 v=1 g=0]
The physical addresses have bit 36 set, which corresponds to bit 30 of
EntryLo1, the XI bit.
Explicitly mask off the RI and XI bits from the printed physical
address, and print the RI and XI bits separately if they exist, giving
output more like this:
Index: 226 pgmask=16kb va=77be0000 asid=79
[ri=0 xi=1 pa=01288000 c=5 d=1 v=1 g=0] [ri=0 xi=0 pa=010e4000 c=5 d=0 v=1 g=0]
Cc: linux-mips@linux-mips.org
Cc: James Hogan <james.hogan@imgtec.com>
Cc: David Daney <ddaney@caviumnetworks.com>
Patchwork: https://patchwork.linux-mips.org/patch/10080/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
2015-05-19 15:50:37 +07:00
|
|
|
/* RI/XI are in awkward places, so mask them off separately */
|
|
|
|
pa = entrylo0 & ~(MIPS_ENTRYLO_RI | MIPS_ENTRYLO_XI);
|
2015-05-19 15:50:38 +07:00
|
|
|
if (xpa)
|
|
|
|
pa |= (unsigned long long)readx_c0_entrylo0() << 30;
|
MIPS: dump_tlb: Take RI/XI bits into account
The RI/XI bits when present are above the PFN field in the EntryLo
registers, at bits 63,62 when read with dmfc0, and bits 31,30 when read
with mfc0. This makes them appear as part of the physical address, since
the other bits are masked with PAGE_MASK, for example:
Index: 253 pgmask=16kb va=77b18000 asid=75
[pa=1000744000 c=5 d=1 v=1 g=0] [pa=100134c000 c=5 d=1 v=1 g=0]
The physical addresses have bit 36 set, which corresponds to bit 30 of
EntryLo1, the XI bit.
Explicitly mask off the RI and XI bits from the printed physical
address, and print the RI and XI bits separately if they exist, giving
output more like this:
Index: 226 pgmask=16kb va=77be0000 asid=79
[ri=0 xi=1 pa=01288000 c=5 d=1 v=1 g=0] [ri=0 xi=0 pa=010e4000 c=5 d=0 v=1 g=0]
Cc: linux-mips@linux-mips.org
Cc: James Hogan <james.hogan@imgtec.com>
Cc: David Daney <ddaney@caviumnetworks.com>
Patchwork: https://patchwork.linux-mips.org/patch/10080/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
2015-05-19 15:50:37 +07:00
|
|
|
pa = (pa << 6) & PAGE_MASK;
|
|
|
|
printk("\t[");
|
|
|
|
if (cpu_has_rixi)
|
|
|
|
printk("ri=%d xi=%d ",
|
|
|
|
(entrylo0 & MIPS_ENTRYLO_RI) ? 1 : 0,
|
|
|
|
(entrylo0 & MIPS_ENTRYLO_XI) ? 1 : 0);
|
|
|
|
printk("pa=%0*llx c=%d d=%d v=%d g=%d] [",
|
2015-05-19 15:50:38 +07:00
|
|
|
pwidth, pa, c0,
|
2015-05-19 15:50:34 +07:00
|
|
|
(entrylo0 & MIPS_ENTRYLO_D) ? 1 : 0,
|
|
|
|
(entrylo0 & MIPS_ENTRYLO_V) ? 1 : 0,
|
|
|
|
(entrylo0 & MIPS_ENTRYLO_G) ? 1 : 0);
|
MIPS: dump_tlb: Take RI/XI bits into account
The RI/XI bits when present are above the PFN field in the EntryLo
registers, at bits 63,62 when read with dmfc0, and bits 31,30 when read
with mfc0. This makes them appear as part of the physical address, since
the other bits are masked with PAGE_MASK, for example:
Index: 253 pgmask=16kb va=77b18000 asid=75
[pa=1000744000 c=5 d=1 v=1 g=0] [pa=100134c000 c=5 d=1 v=1 g=0]
The physical addresses have bit 36 set, which corresponds to bit 30 of
EntryLo1, the XI bit.
Explicitly mask off the RI and XI bits from the printed physical
address, and print the RI and XI bits separately if they exist, giving
output more like this:
Index: 226 pgmask=16kb va=77be0000 asid=79
[ri=0 xi=1 pa=01288000 c=5 d=1 v=1 g=0] [ri=0 xi=0 pa=010e4000 c=5 d=0 v=1 g=0]
Cc: linux-mips@linux-mips.org
Cc: James Hogan <james.hogan@imgtec.com>
Cc: David Daney <ddaney@caviumnetworks.com>
Patchwork: https://patchwork.linux-mips.org/patch/10080/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
2015-05-19 15:50:37 +07:00
|
|
|
/* RI/XI are in awkward places, so mask them off separately */
|
|
|
|
pa = entrylo1 & ~(MIPS_ENTRYLO_RI | MIPS_ENTRYLO_XI);
|
2015-05-19 15:50:38 +07:00
|
|
|
if (xpa)
|
|
|
|
pa |= (unsigned long long)readx_c0_entrylo1() << 30;
|
MIPS: dump_tlb: Take RI/XI bits into account
The RI/XI bits when present are above the PFN field in the EntryLo
registers, at bits 63,62 when read with dmfc0, and bits 31,30 when read
with mfc0. This makes them appear as part of the physical address, since
the other bits are masked with PAGE_MASK, for example:
Index: 253 pgmask=16kb va=77b18000 asid=75
[pa=1000744000 c=5 d=1 v=1 g=0] [pa=100134c000 c=5 d=1 v=1 g=0]
The physical addresses have bit 36 set, which corresponds to bit 30 of
EntryLo1, the XI bit.
Explicitly mask off the RI and XI bits from the printed physical
address, and print the RI and XI bits separately if they exist, giving
output more like this:
Index: 226 pgmask=16kb va=77be0000 asid=79
[ri=0 xi=1 pa=01288000 c=5 d=1 v=1 g=0] [ri=0 xi=0 pa=010e4000 c=5 d=0 v=1 g=0]
Cc: linux-mips@linux-mips.org
Cc: James Hogan <james.hogan@imgtec.com>
Cc: David Daney <ddaney@caviumnetworks.com>
Patchwork: https://patchwork.linux-mips.org/patch/10080/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
2015-05-19 15:50:37 +07:00
|
|
|
pa = (pa << 6) & PAGE_MASK;
|
|
|
|
if (cpu_has_rixi)
|
|
|
|
printk("ri=%d xi=%d ",
|
|
|
|
(entrylo1 & MIPS_ENTRYLO_RI) ? 1 : 0,
|
|
|
|
(entrylo1 & MIPS_ENTRYLO_XI) ? 1 : 0);
|
|
|
|
printk("pa=%0*llx c=%d d=%d v=%d g=%d]\n",
|
2015-05-19 15:50:38 +07:00
|
|
|
pwidth, pa, c1,
|
2015-05-19 15:50:34 +07:00
|
|
|
(entrylo1 & MIPS_ENTRYLO_D) ? 1 : 0,
|
|
|
|
(entrylo1 & MIPS_ENTRYLO_V) ? 1 : 0,
|
|
|
|
(entrylo1 & MIPS_ENTRYLO_G) ? 1 : 0);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
printk("\n");
|
|
|
|
|
|
|
|
write_c0_entryhi(s_entryhi);
|
|
|
|
write_c0_index(s_index);
|
2012-10-17 06:01:20 +07:00
|
|
|
write_c0_pagemask(s_pagemask);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
void dump_tlb_all(void)
|
|
|
|
{
|
|
|
|
dump_tlb(0, current_cpu_data.tlbsize - 1);
|
|
|
|
}
|