For 4-level page table, we are referring to level3 as PGD instead of
PUD, which is not inline with how kernel refers to it. This patch
corrects it by referring to level4 as PGD and level3 as PUD.
Signed-off-by: Hari Bathini <hbathini(a)linux.vnet.ibm.com>
---
defs.h | 18 ++++--------------
ppc64.c | 62 +++++++++++++++++++++++++++++++-------------------------------
2 files changed, 35 insertions(+), 45 deletions(-)
diff --git a/defs.h b/defs.h
index ea77823..6e537b9 100644
--- a/defs.h
+++ b/defs.h
@@ -3831,12 +3831,13 @@ struct efi_memory_desc_t {
#define HUGE_PTE_MASK 0x03
#define HUGEPD_SHIFT_MASK 0x3f
-#define L4_MASK \
+#define PGD_MASK_L4 \
(THIS_KERNEL_VERSION >= LINUX(3,10,0) ? (machdep->ptrs_per_pgd - 1) : 0x1ff)
-#define L4_OFFSET(vaddr) ((vaddr >> (machdep->machspec->l4_shift)) &
L4_MASK)
-
#define PGD_OFFSET_L4(vaddr) \
+ ((vaddr >> (machdep->machspec->l4_shift)) & PGD_MASK_L4)
+
+#define PUD_OFFSET_L4(vaddr) \
((vaddr >> (machdep->machspec->l3_shift)) &
(machdep->machspec->ptrs_per_l3 - 1))
#define PMD_OFFSET_L4(vaddr) \
@@ -5670,8 +5671,6 @@ struct machine_specific {
ulong hwintrstack[NR_CPUS];
char *hwstackbuf;
uint hwstacksize;
- char *level4;
- ulong last_level4_read;
uint l4_index_size;
uint l3_index_size;
@@ -5708,15 +5707,6 @@ struct machine_specific {
int (*is_vmaddr)(ulong);
};
-#define IS_LAST_L4_READ(l4) ((ulong)(l4) == machdep->machspec->last_level4_read)
-
-#define FILL_L4(L4, TYPE, SIZE) \
- if (!IS_LAST_L4_READ(L4)) { \
- readmem((ulonglong)((ulong)(L4)), TYPE, machdep->machspec->level4, \
- SIZE, "level4 page", FAULT_ON_ERROR); \
- machdep->machspec->last_level4_read = (ulong)(L4); \
- }
-
void ppc64_init(int);
void ppc64_dump_machdep_table(ulong);
#define display_idt_table() \
diff --git a/ppc64.c b/ppc64.c
index bf0cd82..511c189 100644
--- a/ppc64.c
+++ b/ppc64.c
@@ -179,9 +179,9 @@ ppc64_init(int when)
return;
machdep->stacksize = PPC64_STACK_SIZE;
machdep->last_pgd_read = 0;
- machdep->last_pmd_read = 0;
- machdep->last_ptbl_read = 0;
- machdep->machspec->last_level4_read = 0;
+ machdep->last_pud_read = 0;
+ machdep->last_pmd_read = 0;
+ machdep->last_ptbl_read = 0;
machdep->verify_paddr = generic_verify_paddr;
machdep->ptrs_per_pgd = PTRS_PER_PGD;
machdep->flags |= MACHDEP_BT_TEXT;
@@ -223,12 +223,12 @@ ppc64_init(int when)
machdep->pagemask = ~((ulonglong)machdep->pageoffset);
if ((machdep->pgd = (char *)malloc(PAGESIZE())) == NULL)
error(FATAL, "cannot malloc pgd space.");
+ if ((machdep->pud = (char *)malloc(PAGESIZE())) == NULL)
+ error(FATAL, "cannot malloc pud space.");
if ((machdep->pmd = (char *)malloc(PAGESIZE())) == NULL)
error(FATAL, "cannot malloc pmd space.");
if ((machdep->ptbl = (char *)malloc(PAGESIZE())) == NULL)
error(FATAL, "cannot malloc ptbl space.");
- if ((machdep->machspec->level4 = (char *)malloc(PAGESIZE())) == NULL)
- error(FATAL, "cannot malloc level4 space.");
machdep->identity_map_base = symbol_value("_stext");
machdep->is_kvaddr = machdep->machspec->is_kvaddr;
@@ -271,8 +271,8 @@ ppc64_init(int when)
}
if (machdep->flags & VM_ORIG) {
/* pre-2.6.14 layout */
- free(machdep->machspec->level4);
- machdep->machspec->level4 = NULL;
+ free(machdep->pud);
+ machdep->pud = NULL;
machdep->ptrs_per_pgd = PTRS_PER_PGD;
} else {
/* 2.6.14 layout */
@@ -519,10 +519,12 @@ ppc64_dump_machdep_table(ulong arg)
fprintf(fp, "xen_kdump_p2m_create: NULL\n");
fprintf(fp, " line_number_hooks: ppc64_line_number_hooks\n");
fprintf(fp, " last_pgd_read: %lx\n", machdep->last_pgd_read);
+ fprintf(fp, " last_pud_read: %lx\n", machdep->last_pud_read);
fprintf(fp, " last_pmd_read: %lx\n", machdep->last_pmd_read);
fprintf(fp, " last_ptbl_read: %lx\n", machdep->last_ptbl_read);
fprintf(fp, "clear_machdep_cache: ppc64_clear_machdep_cache()\n");
fprintf(fp, " pgd: %lx\n", (ulong)machdep->pgd);
+ fprintf(fp, " pud: %lx\n", (ulong)machdep->pud);
fprintf(fp, " pmd: %lx\n", (ulong)machdep->pmd);
fprintf(fp, " ptbl: %lx\n", (ulong)machdep->ptbl);
fprintf(fp, " ptrs_per_pgd: %d\n", machdep->ptrs_per_pgd);
@@ -561,8 +563,6 @@ ppc64_dump_machdep_table(ulong arg)
fprintf(fp, "\n");
fprintf(fp, " hwstackbuf: %lx\n",
(ulong)machdep->machspec->hwstackbuf);
fprintf(fp, " hwstacksize: %d\n",
machdep->machspec->hwstacksize);
- fprintf(fp, " level4: %lx\n",
(ulong)machdep->machspec->level4);
- fprintf(fp, " last_level4_read: %lx\n",
(ulong)machdep->machspec->last_level4_read);
fprintf(fp, " l4_index_size: %d\n",
machdep->machspec->l4_index_size);
fprintf(fp, " l3_index_size: %d\n",
machdep->machspec->l3_index_size);
fprintf(fp, " l2_index_size: %d\n",
machdep->machspec->l2_index_size);
@@ -687,53 +687,53 @@ ppc64_vtop(ulong vaddr, ulong *pgd, physaddr_t *paddr, int verbose)
static int
ppc64_vtop_level4(ulong vaddr, ulong *level4, physaddr_t *paddr, int verbose)
{
- ulong *level4_dir;
- ulong *page_dir;
+ ulong *pgdir;
+ ulong *page_upper;
ulong *page_middle;
ulong *page_table;
- ulong level4_pte, pgd_pte, pmd_pte;
+ ulong pgd_pte, pud_pte, pmd_pte;
ulong pte;
uint hugepage_type = 0; /* 0: regular entry; 1: huge pte; 2: huge pd */
if (verbose)
fprintf(fp, "PAGE DIRECTORY: %lx\n", (ulong)level4);
- level4_dir = (ulong *)((ulong *)level4 + L4_OFFSET(vaddr));
- FILL_L4(PAGEBASE(level4), KVADDR, PAGESIZE());
- level4_pte = ULONG(machdep->machspec->level4 + PAGEOFFSET(level4_dir));
+ pgdir = (ulong *)((ulong *)level4 + PGD_OFFSET_L4(vaddr));
+ FILL_PGD(PAGEBASE(level4), KVADDR, PAGESIZE());
+ pgd_pte = ULONG(machdep->pgd + PAGEOFFSET(pgdir));
if (verbose)
- fprintf(fp, " L4: %lx => %lx\n", (ulong)level4_dir, level4_pte);
- if (!level4_pte)
+ fprintf(fp, " PGD: %lx => %lx\n", (ulong)pgdir, pgd_pte);
+ if (!pgd_pte)
return FALSE;
- hugepage_type = get_ptetype(level4_pte);
+ hugepage_type = get_ptetype(pgd_pte);
if (hugepage_type) {
- pte = level4_pte;
+ pte = pgd_pte;
goto out;
}
/* Sometimes we don't have level3 pagetable entries */
if (machdep->machspec->l3_index_size != 0) {
- page_dir = (ulong *)((ulong *)level4_pte + PGD_OFFSET_L4(vaddr));
- FILL_PGD(PAGEBASE(level4_pte), KVADDR, PAGESIZE());
- pgd_pte = ULONG(machdep->pgd + PAGEOFFSET(page_dir));
+ page_upper = (ulong *)((ulong *)pgd_pte + PUD_OFFSET_L4(vaddr));
+ FILL_PUD(PAGEBASE(pgd_pte), KVADDR, PAGESIZE());
+ pud_pte = ULONG(machdep->pud + PAGEOFFSET(page_upper));
if (verbose)
- fprintf(fp, " PGD: %lx => %lx\n", (ulong)page_dir, pgd_pte);
- if (!pgd_pte)
+ fprintf(fp, " PUD: %lx => %lx\n", (ulong)page_upper, pud_pte);
+ if (!pud_pte)
return FALSE;
- hugepage_type = get_ptetype(pgd_pte);
+ hugepage_type = get_ptetype(pud_pte);
if (hugepage_type) {
- pte = pgd_pte;
+ pte = pud_pte;
goto out;
}
} else {
- pgd_pte = level4_pte;
+ pud_pte = pgd_pte;
}
- page_middle = (ulong *)((ulong *)pgd_pte + PMD_OFFSET_L4(vaddr));
- FILL_PMD(PAGEBASE(pgd_pte), KVADDR, PAGESIZE());
+ page_middle = (ulong *)((ulong *)pud_pte + PMD_OFFSET_L4(vaddr));
+ FILL_PMD(PAGEBASE(pud_pte), KVADDR, PAGESIZE());
pmd_pte = ULONG(machdep->pmd + PAGEOFFSET(page_middle));
if (verbose)
@@ -2967,8 +2967,8 @@ ppc64_init_cpu_info(void)
void
ppc64_clear_machdep_cache(void)
{
- if (machdep->machspec->last_level4_read != vt->kernel_pgd[0])
- machdep->machspec->last_level4_read = 0;
+ if (machdep->last_pgd_read != vt->kernel_pgd[0])
+ machdep->last_pgd_read = 0;
}
static int