Repace the PML4 and UPML with the common PGD and Use PUD macro in the
4-level paging table in x86_64. make the x86_64_vtop_xxx() uniform for
the different situation.
Signed-off-by: Dou Liyang <douly.fnst(a)cn.fujitsu.com>
---
defs.h | 53 ++++++-------
sadump.c | 9 ++-
x86_64.c | 260 ++++++++++++++++++++++++++++++---------------------------------
3 files changed, 148 insertions(+), 174 deletions(-)
diff --git a/defs.h b/defs.h
index e0b77ce..5804206 100644
--- a/defs.h
+++ b/defs.h
@@ -3332,56 +3332,44 @@ struct arm64_stackframe {
#define VTOP(X) x86_64_VTOP((ulong)(X))
#define IS_VMALLOC_ADDR(X) x86_64_IS_VMALLOC_ADDR((ulong)(X))
-#define PML4_SHIFT 39
-#define PTRS_PER_PML4 512
+/* origin level page */
#define PGDIR_SHIFT 30
#define PTRS_PER_PGD 512
#define PMD_SHIFT 21
#define PTRS_PER_PMD 512
#define PTRS_PER_PTE 512
+/* 4 level page */
+#define PGDIR_SHIFT_4LEVEL 39
+#define PTRS_PER_PGD_4LEVEL 512
+#define PUD_SHIFT 30
+#define PTRS_PER_PUD 512
+
+/* 5 level page */
#define PGDIR_SHIFT_5LEVEL 48
#define PTRS_PER_PGD_5LEVEL 512
#define P4D_SHIFT 39
#define PTRS_PER_P4D 512
#define __PGDIR_SHIFT (machdep->machspec->pgdir_shift)
+#define __PTRS_PER_PGD (machdep->machspec->ptrs_per_pgd)
-#define pml4_index(address) (((address) >> PML4_SHIFT) & (PTRS_PER_PML4-1))
+#define pgd_index(address) (((address) >> __PGDIR_SHIFT) &
(__PTRS_PER_PGD-1))
#define p4d_index(address) (((address) >> P4D_SHIFT) & (PTRS_PER_P4D - 1))
-#define pgd_index(address) (((address) >> __PGDIR_SHIFT) & (PTRS_PER_PGD-1))
+#define pud_index(address) (((address) >> PUD_SHIFT) & (PTRS_PER_PUD - 1))
#define pmd_index(address) (((address) >> PMD_SHIFT) & (PTRS_PER_PMD-1))
#define pte_index(address) (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
-#define IS_LAST_PML4_READ(pml4) ((ulong)(pml4) ==
machdep->machspec->last_pml4_read)
-
-#define FILL_PML4() \
- if (!(pc->flags & RUNTIME) || ACTIVE()) { \
- if (!IS_LAST_PML4_READ(vt->kernel_pgd[0])) { \
- readmem(vt->kernel_pgd[0], KVADDR, machdep->machspec->pml4, \
- PAGESIZE(), "init_level4_pgt", FAULT_ON_ERROR); \
- machdep->machspec->last_pml4_read = (ulong)(vt->kernel_pgd[0]); \
- } \
+#define FILL_TOP_PGD() \
+ if (!(pc->flags & RUNTIME) || ACTIVE()) { \
+ FILL_PGD(vt->kernel_pgd[0], KVADDR, PAGESIZE()); \
}
-#define FILL_PML4_HYPER() \
- if (!machdep->machspec->last_pml4_read) { \
- unsigned long idle_pg_table = symbol_exists("idle_pg_table_4") ? \
- symbol_value("idle_pg_table_4") : \
- symbol_value("idle_pg_table"); \
- readmem(idle_pg_table, KVADDR, machdep->machspec->pml4, PAGESIZE(), \
- "idle_pg_table", FAULT_ON_ERROR); \
- machdep->machspec->last_pml4_read = idle_pg_table; \
- }
-
-#define IS_LAST_UPML_READ(pml) ((ulong)(pml) == machdep->machspec->last_upml_read)
-
-#define FILL_UPML(PML, TYPE, SIZE) \
- if (!IS_LAST_UPML_READ(PML)) { \
- readmem((ulonglong)((ulong)(PML)), TYPE, machdep->machspec->upml, \
- SIZE, "pml page", FAULT_ON_ERROR);
\
- machdep->machspec->last_upml_read = (ulong)(PML); \
- }
+#define FILL_TOP_PGD_HYPER() \
+ unsigned long idle_pg_table = symbol_exists("idle_pg_table_4") ? \
+ symbol_value("idle_pg_table_4") : \
+ symbol_value("idle_pg_table"); \
+ FILL_PGD(idle_pg_table, KVADDR, PAGESIZE());
#define IS_LAST_P4D_READ(p4d) ((ulong)(p4d) == machdep->machspec->last_p4d_read)
@@ -5749,7 +5737,7 @@ struct machine_specific {
ulong modules_vaddr;
ulong modules_end;
ulong phys_base;
- char *pml4;
+ char *pml4;
char *upml;
ulong last_upml_read;
ulong last_pml4_read;
@@ -5773,6 +5761,7 @@ struct machine_specific {
ulong irq_stack_gap;
ulong kpti_entry_stack;
ulong kpti_entry_stack_size;
+ ulong ptrs_per_pgd;
};
#define KSYMS_START (0x1)
diff --git a/sadump.c b/sadump.c
index 25cefe9..17cfd93 100644
--- a/sadump.c
+++ b/sadump.c
@@ -2057,10 +2057,11 @@ sadump_calc_kaslr_offset(ulong *kaslr_offset)
* TODO: XEN and 5-level is not supported
*/
vt->kernel_pgd[0] = pgd;
- machdep->machspec->last_pml4_read = vt->kernel_pgd[0];
+ machdep->last_pgd_read = vt->kernel_pgd[0];
machdep->machspec->physical_mask_shift = __PHYSICAL_MASK_SHIFT_2_6;
- machdep->machspec->pgdir_shift = PGDIR_SHIFT;
- if (!readmem(pgd, PHYSADDR, machdep->machspec->pml4, PAGESIZE(),
+ machdep->machspec->pgdir_shift = PGDIR_SHIFT_4LEVEL;
+ machdep->machspec->ptrs_per_pgd = PTRS_PER_PGD_4LEVEL;
+ if (!readmem(pgd, PHYSADDR, machdep->pgd, PAGESIZE(),
"pgd", RETURN_ON_ERROR))
goto quit;
@@ -2108,7 +2109,7 @@ sadump_calc_kaslr_offset(ulong *kaslr_offset)
ret = TRUE;
quit:
vt->kernel_pgd[0] = 0;
- machdep->machspec->last_pml4_read = 0;
+ machdep->last_pgd_read = 0;
return ret;
}
#else
diff --git a/x86_64.c b/x86_64.c
index e3a8db7..f5e70b5 100644
--- a/x86_64.c
+++ b/x86_64.c
@@ -168,20 +168,17 @@ x86_64_init(int when)
machdep->pageoffset = machdep->pagesize - 1;
machdep->pagemask = ~((ulonglong)machdep->pageoffset);
machdep->stacksize = machdep->pagesize * 2;
- if ((machdep->machspec->upml = (char *)malloc(PAGESIZE())) ==
NULL)
- error(FATAL, "cannot malloc upml space.");
- if ((machdep->pgd = (char *)malloc(PAGESIZE())) == NULL)
+ 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->pml4 =
- (char *)malloc(PAGESIZE()*2)) == NULL)
- error(FATAL, "cannot malloc pml4 space.");
- machdep->machspec->last_upml_read = 0;
- machdep->machspec->last_pml4_read = 0;
+
machdep->last_pgd_read = 0;
+ machdep->last_pud_read = 0;
machdep->last_pmd_read = 0;
machdep->last_ptbl_read = 0;
machdep->verify_paddr = x86_64_verify_paddr;
@@ -235,12 +232,10 @@ x86_64_init(int when)
machdep->machspec->modules_vaddr = MODULES_VADDR_ORIG;
machdep->machspec->modules_end = MODULES_END_ORIG;
- free(machdep->machspec->upml);
- machdep->machspec->upml = NULL;
-
machdep->uvtop = x86_64_uvtop;
machdep->machspec->physical_mask_shift = __PHYSICAL_MASK_SHIFT_2_6;
machdep->machspec->pgdir_shift = PGDIR_SHIFT;
+ machdep->machspec->ptrs_per_pgd = PTRS_PER_PGD;
break;
case VM_2_6_11:
@@ -266,7 +261,8 @@ x86_64_init(int when)
machdep->uvtop = x86_64_uvtop_level4;
machdep->machspec->physical_mask_shift = __PHYSICAL_MASK_SHIFT_2_6;
- machdep->machspec->pgdir_shift = PGDIR_SHIFT;
+ machdep->machspec->pgdir_shift = PGDIR_SHIFT_4LEVEL;
+ machdep->machspec->ptrs_per_pgd = PTRS_PER_PGD_4LEVEL;
break;
case VM_XEN:
@@ -278,7 +274,6 @@ x86_64_init(int when)
machdep->machspec->modules_vaddr = MODULES_VADDR_XEN;
machdep->machspec->modules_end = MODULES_END_XEN;
machdep->machspec->physical_mask_shift = __PHYSICAL_MASK_SHIFT_XEN;
- machdep->machspec->pgdir_shift = PGDIR_SHIFT;
break;
case VM_XEN_RHEL4:
@@ -290,7 +285,6 @@ x86_64_init(int when)
machdep->machspec->modules_vaddr =
MODULES_VADDR_XEN_RHEL4;
machdep->machspec->modules_end = MODULES_END_XEN_RHEL4;
machdep->machspec->physical_mask_shift = __PHYSICAL_MASK_SHIFT_XEN;
- machdep->machspec->pgdir_shift = PGDIR_SHIFT;
break;
case VM_5LEVEL:
@@ -304,6 +298,7 @@ x86_64_init(int when)
machdep->machspec->vmemmap_end = VMEMMAP_END_5LEVEL;
machdep->machspec->physical_mask_shift = __PHYSICAL_MASK_SHIFT_5LEVEL;
machdep->machspec->pgdir_shift = PGDIR_SHIFT_5LEVEL;
+ machdep->machspec->ptrs_per_pgd = PTRS_PER_PGD_5LEVEL;
if ((machdep->machspec->p4d = (char *)malloc(PAGESIZE())) == NULL)
error(FATAL, "cannot malloc p4d space.");
machdep->machspec->last_p4d_read = 0;
@@ -631,14 +626,21 @@ x86_64_init(int when)
case VM_XEN:
case VM_2_6_11:
machdep->uvtop = x86_64_uvtop_level4_xen_wpt;
+ machdep->machspec->pgdir_shift = PGDIR_SHIFT_4LEVEL;
+ machdep->machspec->ptrs_per_pgd = PTRS_PER_PGD_4LEVEL;
break;
case VM_XEN_RHEL4:
machdep->uvtop = x86_64_uvtop_level4_rhel4_xen_wpt;
+ machdep->machspec->pgdir_shift = PGDIR_SHIFT;
+ machdep->machspec->ptrs_per_pgd = PTRS_PER_PGD;
break;
}
machdep->machspec->physical_mask_shift = __PHYSICAL_MASK_SHIFT_XEN;
- } else
- machdep->uvtop = x86_64_uvtop_level4;
+ } else {
+ machdep->uvtop = x86_64_uvtop_level4;
+ machdep->machspec->pgdir_shift = PGDIR_SHIFT_4LEVEL;
+ machdep->machspec->ptrs_per_pgd = PTRS_PER_PGD_4LEVEL;
+ }
MEMBER_OFFSET_INIT(vcpu_guest_context_user_regs,
"vcpu_guest_context", "user_regs");
ASSIGN_OFFSET(cpu_user_regs_rsp) =
@@ -816,9 +818,11 @@ x86_64_dump_machdep_table(ulong arg)
fprintf(fp, " value_to_symbol: x86_64_value_to_symbol()\n");
fprintf(fp, " in_alternate_stack: x86_64_in_alternate_stack()\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, " 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);
@@ -853,15 +857,25 @@ x86_64_dump_machdep_table(ulong arg)
fprintf(fp, " pgdir_shift: %ld\n", ms->pgdir_shift);
fprintf(fp, " GART_start: %lx\n", ms->GART_start);
fprintf(fp, " GART_end: %lx\n", ms->GART_end);
- fprintf(fp, " pml4: %lx\n", (ulong)ms->pml4);
- fprintf(fp, " last_pml4_read: %lx\n",
(ulong)ms->last_pml4_read);
+
+ /* pml4 and upml is legacy for extension modules */
+ if (ms->pml4) {
+ fprintf(fp, " pml4: %lx\n", (ulong)ms->pml4);
+ fprintf(fp, " last_pml4_read: %lx\n", (ulong)ms->last_pml4_read);
+
+ } else {
+ fprintf(fp, " pml4: (unused)\n");
+ fprintf(fp, " last_pml4_read: (unused)\n");
+ }
+
if (ms->upml) {
- fprintf(fp, " upml: %lx\n", (ulong)ms->upml);
- fprintf(fp, " last_upml_read: %lx\n",
(ulong)ms->last_upml_read);
+ fprintf(fp, " upml: %lx\n", (ulong)ms->upml);
+ fprintf(fp, " last_upml_read: %lx\n", (ulong)ms->last_upml_read);
} else {
- fprintf(fp, " upml: (unused)\n");
- fprintf(fp, " last_upml_read: (unused)\n");
+ fprintf(fp, " upml: (unused)\n");
+ fprintf(fp, " last_upml_read: (unused)\n");
}
+
if (ms->p4d) {
fprintf(fp, " p4d: %lx\n", (ulong)ms->p4d);
fprintf(fp, " last_p4d_read: %lx\n",
(ulong)ms->last_p4d_read);
@@ -1529,7 +1543,7 @@ x86_64_init_kernel_pgd(void)
for (i = 0; i < NR_CPUS; i++)
vt->kernel_pgd[i] = kernel_pgt;
- FILL_PML4();
+ FILL_TOP_PGD();
}
/*
@@ -1589,8 +1603,8 @@ x86_64_kpgd_offset(ulong kvaddr, int verbose, int IS_XEN)
{
ulong *pgd;
- FILL_PML4();
- pgd = ((ulong *)machdep->machspec->pml4) + pml4_index(kvaddr);
+ FILL_TOP_PGD();
+ pgd = ((ulong *)machdep->pgd) + pgd_index(kvaddr);
if (verbose) {
fprintf(fp, "PGD DIRECTORY: %lx\n", vt->kernel_pgd[0]);
if(IS_XEN)
@@ -1613,16 +1627,16 @@ x86_64_upgd_offset(struct task_context *tc, ulong uvaddr, int
verbose, int IS_XE
ulong pgd_paddr;
ulong pgd_pte;
- if (task_mm(tc->task, TRUE))
- pgd = ULONG_PTR(tt->mm_struct + OFFSET(mm_struct_pgd));
- else
- readmem(tc->mm_struct + OFFSET(mm_struct_pgd), KVADDR, &pgd,
- sizeof(long), "mm_struct pgd", FAULT_ON_ERROR);
+ if (task_mm(tc->task, TRUE))
+ pgd = ULONG_PTR(tt->mm_struct + OFFSET(mm_struct_pgd));
+ else
+ readmem(tc->mm_struct + OFFSET(mm_struct_pgd), KVADDR, &pgd,
+ sizeof(long), "mm_struct pgd", FAULT_ON_ERROR);
- pgd_paddr = x86_64_VTOP((ulong)pgd);
- FILL_UPML(pgd_paddr, PHYSADDR, PAGESIZE());
- pgd = ((ulong *)pgd_paddr) + pml4_index(uvaddr);
- pgd_pte = ULONG(machdep->machspec->pml4 + PAGEOFFSET(pgd));
+ pgd_paddr = x86_64_VTOP((ulong)pgd);
+ FILL_PGD(pgd_paddr, PHYSADDR, PAGESIZE());
+ pgd = ((ulong *)pgd_paddr) + pgd_index(uvaddr);
+ pgd_pte = ULONG(machdep->pgd + PAGEOFFSET(pgd));
if (verbose) {
if(IS_XEN)
fprintf(fp, " PGD: %lx => %lx [machine]\n", (ulong)pgd, pgd_pte);
@@ -1653,7 +1667,7 @@ x86_64_pud_offset(ulong pgd_pte, ulong vaddr, int verbose, int
IS_XEN)
}
FILL_PUD(pud_paddr, PHYSADDR, PAGESIZE());
- pud = ((ulong *)pud_paddr) + pgd_index(vaddr);
+ pud = ((ulong *)pud_paddr) + pud_index(vaddr);
pud_pte = ULONG(machdep->pud + PAGEOFFSET(pud));
if (verbose) {
if(IS_XEN)
@@ -1935,9 +1949,6 @@ no_upage:
static int
x86_64_uvtop_level4_rhel4_xen_wpt(struct task_context *tc, ulong uvaddr, physaddr_t
*paddr, int verbose)
{
- ulong mm;
- ulong *pgd;
- ulong pgd_paddr;
ulong pgd_pte;
ulong pmd_pte;
ulong pseudo_pmd_pte;
@@ -1954,18 +1965,7 @@ x86_64_uvtop_level4_rhel4_xen_wpt(struct task_context *tc, ulong
uvaddr, physadd
if (IS_KVADDR(uvaddr))
return x86_64_kvtop(tc, uvaddr, paddr, verbose);
- if ((mm = task_mm(tc->task, TRUE)))
- pgd = ULONG_PTR(tt->mm_struct + OFFSET(mm_struct_pgd));
- else
- readmem(tc->mm_struct + OFFSET(mm_struct_pgd), KVADDR, &pgd,
- sizeof(long), "mm_struct pgd", FAULT_ON_ERROR);
-
- pgd_paddr = x86_64_VTOP((ulong)pgd);
- FILL_PGD(pgd_paddr, PHYSADDR, PAGESIZE());
- pgd = ((ulong *)pgd_paddr) + pgd_index(uvaddr);
- pgd_pte = ULONG(machdep->pgd + PAGEOFFSET(pgd));
- if (verbose)
- fprintf(fp, " PGD: %lx => %lx [machine]\n", (ulong)pgd,
pgd_pte);
+ pgd_pte = x86_64_upgd_offset(tc, uvaddr, verbose, TRUE);
if (!(pgd_pte & _PAGE_PRESENT))
goto no_upage;
@@ -2046,9 +2046,6 @@ no_upage:
static int
x86_64_uvtop(struct task_context *tc, ulong uvaddr, physaddr_t *paddr, int verbose)
{
- ulong mm;
- ulong *pgd;
- ulong pgd_paddr;
ulong pgd_pte;
ulong pmd_pte;
ulong pte;
@@ -2062,21 +2059,10 @@ x86_64_uvtop(struct task_context *tc, ulong uvaddr, physaddr_t
*paddr, int verbo
if (IS_KVADDR(uvaddr))
return x86_64_kvtop(tc, uvaddr, paddr, verbose);
- /*
- * pgd = pgd_offset(mm, address);
- */
- if ((mm = task_mm(tc->task, TRUE)))
- pgd = ULONG_PTR(tt->mm_struct + OFFSET(mm_struct_pgd));
- else
- readmem(tc->mm_struct + OFFSET(mm_struct_pgd), KVADDR, &pgd,
- sizeof(long), "mm_struct pgd", FAULT_ON_ERROR);
-
- pgd_paddr = x86_64_VTOP((ulong)pgd);
- FILL_PGD(pgd_paddr, PHYSADDR, PAGESIZE());
- pgd = ((ulong *)pgd_paddr) + pgd_index(uvaddr);
- pgd_pte = ULONG(machdep->pgd + PAGEOFFSET(pgd));
- if (verbose)
- fprintf(fp, " PGD: %lx => %lx\n", (ulong)pgd, pgd_pte);
+ /*
+ * pgd = pgd_offset(mm, address);
+ */
+ pgd_pte = x86_64_upgd_offset(tc, uvaddr, verbose, FALSE);
if (!(pgd_pte & _PAGE_PRESENT))
goto no_upage;
@@ -2137,7 +2123,7 @@ no_upage:
static int
x86_64_kvtop(struct task_context *tc, ulong kvaddr, physaddr_t *paddr, int verbose)
{
- ulong *pml4;
+ ulong *pgd;
ulong pud_pte;
ulong pmd_pte;
ulong pte;
@@ -2166,11 +2152,11 @@ x86_64_kvtop(struct task_context *tc, ulong kvaddr, physaddr_t
*paddr, int verbo
*paddr = kvaddr - DIRECTMAP_VIRT_START;
return TRUE;
}
- FILL_PML4_HYPER();
- pml4 = ((ulong *)machdep->machspec->pml4) + pml4_index(kvaddr);
+ FILL_TOP_PGD_HYPER();
+ pgd = ((ulong *)machdep->pgd) + pgd_index(kvaddr);
if (verbose) {
- fprintf(fp, "PML4 DIRECTORY: %lx\n", vt->kernel_pgd[0]);
- fprintf(fp, "PAGE DIRECTORY: %lx\n", *pml4);
+ fprintf(fp, "PGD DIRECTORY: %lx\n", vt->kernel_pgd[0]);
+ fprintf(fp, "PAGE DIRECTORY: %lx\n", *pgd);
}
} else {
if (!vt->vmalloc_start) {
@@ -2197,10 +2183,10 @@ x86_64_kvtop(struct task_context *tc, ulong kvaddr, physaddr_t
*paddr, int verbo
}
start_vtop_with_pagetable:
- if (!(*pml4 & _PAGE_PRESENT))
+ if (!(*pgd & _PAGE_PRESENT))
goto no_kpage;
- pud_pte = x86_64_pud_offset(*pml4, kvaddr, verbose, FALSE);
+ pud_pte = x86_64_pud_offset(*pgd, kvaddr, verbose, FALSE);
if (!(pud_pte & _PAGE_PRESENT))
goto no_kpage;
@@ -2260,7 +2246,7 @@ x86_64_kvtop_5level(struct task_context *tc, ulong kvaddr,
physaddr_t *paddr, in
static int
x86_64_kvtop_xen_wpt(struct task_context *tc, ulong kvaddr, physaddr_t *paddr, int
verbose)
{
- ulong *pml4;
+ ulong *pgd;
ulong pud_pte;
ulong pmd_pte;
ulong pseudo_pmd_pte;
@@ -2272,11 +2258,11 @@ x86_64_kvtop_xen_wpt(struct task_context *tc, ulong kvaddr,
physaddr_t *paddr, i
/*
* pgd = pgd_offset_k(addr);
*/
- pml4 = x86_64_kpgd_offset(kvaddr, verbose, TRUE);
- if (!(*pml4 & _PAGE_PRESENT))
+ pgd = x86_64_kpgd_offset(kvaddr, verbose, TRUE);
+ if (!(*pgd & _PAGE_PRESENT))
goto no_kpage;
- pud_pte = x86_64_pud_offset(*pml4, kvaddr, verbose, TRUE);
+ pud_pte = x86_64_pud_offset(*pgd, kvaddr, verbose, TRUE);
if (!(pud_pte & _PAGE_PRESENT))
goto no_kpage;
@@ -5865,7 +5851,8 @@ parse_cmdline_args(void)
void
x86_64_clear_machdep_cache(void)
{
- machdep->machspec->last_upml_read = 0;
+ if (machdep->last_pgd_read != vt->kernel_pgd[0])
+ machdep->last_pgd_read = 0;
}
#define PUSH_RBP_MOV_RSP_RBP 0xe5894855
@@ -6244,12 +6231,12 @@ use_cr3:
if (CRASHDEBUG(1))
fprintf(fp, "x86_64_xen_kdump_p2m_create: cr3: %lx\n",
xkd->cr3);
- if (!readmem(PTOB(xkd->cr3), PHYSADDR, machdep->machspec->pml4,
+ if (!readmem(PTOB(xkd->cr3), PHYSADDR, machdep->pgd,
PAGESIZE(), "xen kdump cr3 page", RETURN_ON_ERROR))
error(FATAL, "cannot read xen kdump cr3 page\n");
if (CRASHDEBUG(7))
- x86_64_debug_dump_page(fp, machdep->machspec->pml4,
+ x86_64_debug_dump_page(fp, machdep->pgd,
"contents of PML4 page:");
/*
@@ -6284,7 +6271,7 @@ use_cr3:
if (CRASHDEBUG(1))
fprintf(fp, "phys_to_machine_mapping: %lx\n", kvaddr);
- machdep->last_pgd_read = BADADDR;
+ machdep->last_pud_read = BADADDR;
machdep->last_pmd_read = BADADDR;
machdep->last_ptbl_read = BADADDR;
@@ -6299,7 +6286,7 @@ use_cr3:
fprintf(fp, "\n");
}
- machdep->last_pgd_read = 0;
+ machdep->last_pud_read = 0;
machdep->last_ptbl_read = 0;
machdep->last_pmd_read = 0;
pc->curcmd_flags &= ~XEN_MACHINE_ADDR;
@@ -6313,33 +6300,33 @@ static char *
x86_64_xen_kdump_load_page(ulong kvaddr, char *pgbuf)
{
ulong mfn;
- ulong *pml4, *pgd, *pmd, *ptep;
+ ulong *pgd, *pud, *pmd, *ptep;
- pml4 = ((ulong *)machdep->machspec->pml4) + pml4_index(kvaddr);
- mfn = ((*pml4) & PHYSICAL_PAGE_MASK) >> PAGESHIFT();
+ pgd = ((ulong *)machdep->pgd) + pgd_index(kvaddr);
+ mfn = ((*pgd) & PHYSICAL_PAGE_MASK) >> PAGESHIFT();
if (CRASHDEBUG(3))
fprintf(fp,
- "[%lx] pml4: %lx mfn: %lx pml4_index: %lx\n",
- kvaddr, *pml4, mfn, pml4_index(kvaddr));
+ "[%lx] pgd: %lx mfn: %lx pgd_index: %lx\n",
+ kvaddr, *pgd, mfn, pgd_index(kvaddr));
- if (!readmem(PTOB(mfn), PHYSADDR, machdep->pgd, PAGESIZE(),
+ if (!readmem(PTOB(mfn), PHYSADDR, machdep->pud, PAGESIZE(),
"xen kdump pud page", RETURN_ON_ERROR))
error(FATAL, "cannot read/find pud page\n");
- machdep->last_pgd_read = mfn;
+ machdep->last_pud_read = mfn;
if (CRASHDEBUG(7))
- x86_64_debug_dump_page(fp, machdep->pgd,
+ x86_64_debug_dump_page(fp, machdep->pud,
"contents of page upper directory page:");
- pgd = ((ulong *)machdep->pgd) + pgd_index(kvaddr);
- mfn = ((*pgd) & PHYSICAL_PAGE_MASK) >> PAGESHIFT();
+ pud = ((ulong *)machdep->pud) + pud_index(kvaddr);
+ mfn = ((*pud) & PHYSICAL_PAGE_MASK) >> PAGESHIFT();
if (CRASHDEBUG(3))
fprintf(fp,
- "[%lx] pgd: %lx mfn: %lx pgd_index: %lx\n",
- kvaddr, *pgd, mfn, pgd_index(kvaddr));
+ "[%lx] pud: %lx mfn: %lx pud_index: %lx\n",
+ kvaddr, *pgd, mfn, pud_index(kvaddr));
if (!readmem(PTOB(mfn), PHYSADDR, machdep->pmd, PAGESIZE(),
"xen kdump pmd page", RETURN_ON_ERROR))
@@ -6392,21 +6379,21 @@ static ulong
x86_64_xen_kdump_page_mfn(ulong kvaddr)
{
ulong mfn;
- ulong *pml4, *pgd, *pmd, *ptep;
+ ulong *pgd, *pud, *pmd, *ptep;
- pml4 = ((ulong *)machdep->machspec->pml4) + pml4_index(kvaddr);
- mfn = ((*pml4) & PHYSICAL_PAGE_MASK) >> PAGESHIFT();
+ pgd = ((ulong *)machdep->pgd) + pgd_index(kvaddr);
+ mfn = ((*pgd) & PHYSICAL_PAGE_MASK) >> PAGESHIFT();
- if ((mfn != machdep->last_pgd_read) &&
- !readmem(PTOB(mfn), PHYSADDR, machdep->pgd, PAGESIZE(),
+ if ((mfn != machdep->last_pud_read) &&
+ !readmem(PTOB(mfn), PHYSADDR, machdep->pud, PAGESIZE(),
"xen kdump pud entry", RETURN_ON_ERROR))
error(FATAL, "cannot read/find pud page\n");
- machdep->last_pgd_read = mfn;
+ machdep->last_pud_read = mfn;
- pgd = ((ulong *)machdep->pgd) + pgd_index(kvaddr);
- mfn = ((*pgd) & PHYSICAL_PAGE_MASK) >> PAGESHIFT();
+ pud = ((ulong *)machdep->pud) + pud_index(kvaddr);
+ mfn = ((*pud) & PHYSICAL_PAGE_MASK) >> PAGESHIFT();
- if ((mfn != machdep->last_pmd_read) &&
+ if ((mfn != machdep->last_pmd_read) &&
!readmem(PTOB(mfn), PHYSADDR, machdep->pmd, PAGESIZE(),
"xen kdump pmd entry", RETURN_ON_ERROR))
error(FATAL, "cannot read/find pmd page\n");
@@ -6761,12 +6748,12 @@ x86_64_xendump_p2m_create(struct xendump_data *xd)
mfn = ctrlreg[3] >> PAGESHIFT();
- if (!xc_core_mfn_to_page(mfn, machdep->machspec->pml4))
+ if (!xc_core_mfn_to_page(mfn, machdep->pgd))
error(FATAL, "cannot read/find cr3 page\n");
if (CRASHDEBUG(7))
- x86_64_debug_dump_page(xd->ofp, machdep->machspec->pml4,
- "contents of PML4 page:");
+ x86_64_debug_dump_page(xd->ofp, machdep->pgd,
+ "contents of PGD page:");
/*
* kernel version < 2.6.27 => end_pfn
@@ -6847,12 +6834,12 @@ x86_64_pvops_xendump_p2m_create(struct xendump_data *xd)
mfn = ctrlreg[3] >> PAGESHIFT();
- if (!xc_core_mfn_to_page(mfn, machdep->machspec->pml4))
+ if (!xc_core_mfn_to_page(mfn, machdep->pgd))
error(FATAL, "cannot read/find cr3 page\n");
if (CRASHDEBUG(7))
- x86_64_debug_dump_page(xd->ofp, machdep->machspec->pml4,
- "contents of PML4 page:");
+ x86_64_debug_dump_page(xd->ofp, machdep->pgd,
+ "contents of PGD page:");
/*
* kernel version < 2.6.27 => end_pfn
@@ -7028,32 +7015,32 @@ static char *
x86_64_xendump_load_page(ulong kvaddr, struct xendump_data *xd)
{
ulong mfn;
- ulong *pml4, *pgd, *pmd, *ptep;
+ ulong *pgd, *pud, *pmd, *ptep;
- pml4 = ((ulong *)machdep->machspec->pml4) + pml4_index(kvaddr);
- mfn = ((*pml4) & PHYSICAL_PAGE_MASK) >> PAGESHIFT();
+ pgd = ((ulong *)machdep->pgd) + pgd_index(kvaddr);
+ mfn = ((*pgd) & PHYSICAL_PAGE_MASK) >> PAGESHIFT();
if (CRASHDEBUG(3))
fprintf(xd->ofp,
- "[%lx] pml4: %lx mfn: %lx pml4_index: %lx\n",
- kvaddr, *pml4, mfn, pml4_index(kvaddr));
+ "[%lx] pgd: %lx mfn: %lx pgd_index: %lx\n",
+ kvaddr, *pgd, mfn, pgd_index(kvaddr));
- if (!xc_core_mfn_to_page(mfn, machdep->pgd))
+ if (!xc_core_mfn_to_page(mfn, machdep->pud))
error(FATAL, "cannot read/find pud page\n");
- machdep->last_pgd_read = mfn;
+ machdep->last_pud_read = mfn;
if (CRASHDEBUG(7))
- x86_64_debug_dump_page(xd->ofp, machdep->pgd,
+ x86_64_debug_dump_page(xd->ofp, machdep->pud,
"contents of page upper directory page:");
- pgd = ((ulong *)machdep->pgd) + pgd_index(kvaddr);
- mfn = ((*pgd) & PHYSICAL_PAGE_MASK) >> PAGESHIFT();
+ pud = ((ulong *)machdep->pud) + pud_index(kvaddr);
+ mfn = ((*pud) & PHYSICAL_PAGE_MASK) >> PAGESHIFT();
if (CRASHDEBUG(3))
fprintf(xd->ofp,
- "[%lx] pgd: %lx mfn: %lx pgd_index: %lx\n",
- kvaddr, *pgd, mfn, pgd_index(kvaddr));
+ "[%lx] pud: %lx mfn: %lx pud_index: %lx\n",
+ kvaddr, *pud, mfn, pud_index(kvaddr));
if (!xc_core_mfn_to_page(mfn, machdep->pmd))
error(FATAL, "cannot read/find pmd page\n");
@@ -7107,18 +7094,18 @@ x86_64_xendump_page_index(ulong kvaddr, struct xendump_data *xd)
{
int idx;
ulong mfn;
- ulong *pml4, *pgd, *pmd, *ptep;
+ ulong *pgd, *pud, *pmd, *ptep;
- pml4 = ((ulong *)machdep->machspec->pml4) + pml4_index(kvaddr);
- mfn = ((*pml4) & PHYSICAL_PAGE_MASK) >> PAGESHIFT();
+ pgd = ((ulong *)machdep->pgd) + pgd_index(kvaddr);
+ mfn = ((*pgd) & PHYSICAL_PAGE_MASK) >> PAGESHIFT();
- if ((mfn != machdep->last_pgd_read) &&
- !xc_core_mfn_to_page(mfn, machdep->pgd))
+ if ((mfn != machdep->last_pud_read) &&
+ !xc_core_mfn_to_page(mfn, machdep->pud))
error(FATAL, "cannot read/find pud page\n");
- machdep->last_pgd_read = mfn;
+ machdep->last_pud_read = mfn;
- pgd = ((ulong *)machdep->pgd) + pgd_index(kvaddr);
- mfn = ((*pgd) & PHYSICAL_PAGE_MASK) >> PAGESHIFT();
+ pud = ((ulong *)machdep->pud) + pud_index(kvaddr);
+ mfn = ((*pud) & PHYSICAL_PAGE_MASK) >> PAGESHIFT();
if ((mfn != machdep->last_pmd_read) &&
!xc_core_mfn_to_page(mfn, machdep->pmd))
@@ -7609,20 +7596,17 @@ x86_64_init_hyper(int when)
machdep->pageoffset = machdep->pagesize - 1;
machdep->pagemask = ~((ulonglong)machdep->pageoffset);
machdep->stacksize = machdep->pagesize * 2;
- if ((machdep->machspec->upml = (char *)malloc(PAGESIZE())) ==
NULL)
- error(FATAL, "cannot malloc upml space.");
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->pml4 =
- (char *)malloc(PAGESIZE()*2)) == NULL)
- error(FATAL, "cannot malloc pml4 space.");
- machdep->machspec->last_upml_read = 0;
- machdep->machspec->last_pml4_read = 0;
+
machdep->last_pgd_read = 0;
+ machdep->last_pud_read = 0;
machdep->last_pmd_read = 0;
machdep->last_ptbl_read = 0;
machdep->verify_paddr = generic_verify_paddr;
--
2.14.3