[PATCH] handle renamed init_level4_pgt -> init_top_pgt
Jeff Mahoney
jeffm at suse.com
Mon Nov 6 18:52:01 PST 2017
Linux 4.13 renamed init_level4_pgt to init_top_pgt in preparation for
introducing 5-level page tables. This patch follows the rename if
the lookup for init_level4_pgt fails. It also checks to see if
5-level page tables are enabled and bails if it discovers they are.
Signed-off-by: Jeff Mahoney <jeffm at suse.com>
---
arch/x86_64.c | 24 +++++++++++++++++++++---
makedumpfile.c | 6 ++++++
makedumpfile.h | 2 ++
3 files changed, 29 insertions(+), 3 deletions(-)
diff --git a/arch/x86_64.c b/arch/x86_64.c
index 08dd6b2..9b09035 100644
--- a/arch/x86_64.c
+++ b/arch/x86_64.c
@@ -259,16 +259,26 @@ vtop4_x86_64(unsigned long vaddr)
{
unsigned long page_dir, pml4, pgd_paddr, pgd_pte, pmd_paddr, pmd_pte;
unsigned long pte_paddr, pte;
+ unsigned long init_level4_pgt;
- if (SYMBOL(init_level4_pgt) == NOT_FOUND_SYMBOL) {
+ if (SYMBOL(init_level4_pgt) != NOT_FOUND_SYMBOL)
+ init_level4_pgt = SYMBOL(init_level4_pgt);
+ else if (SYMBOL(init_top_pgt) != NOT_FOUND_SYMBOL)
+ init_level4_pgt = SYMBOL(init_top_pgt);
+ else {
ERRMSG("Can't get the symbol of init_level4_pgt.\n");
return NOT_PADDR;
}
+ if (SYMBOL(level4_kernel_pgt) != NOT_FOUND_SYMBOL) {
+ ERRMSG("Kernel is built with 5-level page tables\n");
+ return NOT_PADDR;
+ }
+
/*
* Get PGD.
*/
- page_dir = SYMBOL(init_level4_pgt) - __START_KERNEL_map + info->phys_base;
+ page_dir = init_level4_pgt - __START_KERNEL_map + info->phys_base;
if (is_xen_memory()) {
page_dir = ptom_xen(page_dir);
if (page_dir == NOT_PADDR)
@@ -549,8 +559,16 @@ find_vmemmap_x86_64()
struct vmap_pfns *vmapp, *vmaphead = NULL, *cur, *tail;
init_level4_pgt = SYMBOL(init_level4_pgt);
+ if (init_level4_pgt == NOT_FOUND_SYMBOL)
+ init_level4_pgt = SYMBOL(init_top_pgt);
+
if (init_level4_pgt == NOT_FOUND_SYMBOL) {
- ERRMSG("init_level4_pgt not found\n");
+ ERRMSG("init_level4_pgt/init_top_pgt not found\n");
+ return FAILED;
+ }
+
+ if (SYMBOL(level4_kernel_pgt) != NOT_FOUND_SYMBOL) {
+ ERRMSG("kernel is configured for 5-level page tables\n");
return FAILED;
}
pagestructsize = size_table.page;
diff --git a/makedumpfile.c b/makedumpfile.c
index f85003a..6e5ec34 100644
--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -1486,6 +1486,8 @@ get_symbol_info(void)
SYMBOL_INIT(_stext, "_stext");
SYMBOL_INIT(swapper_pg_dir, "swapper_pg_dir");
SYMBOL_INIT(init_level4_pgt, "init_level4_pgt");
+ SYMBOL_INIT(level4_kernel_pgt, "level4_kernel_pgt");
+ SYMBOL_INIT(init_top_pgt, "init_top_pgt");
SYMBOL_INIT(vmlist, "vmlist");
SYMBOL_INIT(vmap_area_list, "vmap_area_list");
SYMBOL_INIT(node_online_map, "node_online_map");
@@ -2105,6 +2107,8 @@ write_vmcoreinfo_data(void)
WRITE_SYMBOL("_stext", _stext);
WRITE_SYMBOL("swapper_pg_dir", swapper_pg_dir);
WRITE_SYMBOL("init_level4_pgt", init_level4_pgt);
+ WRITE_SYMBOL("level4_kernel_pgt", level4_kernel_pgt);
+ WRITE_SYMBOL("init_top_pgt", init_top_pgt);
WRITE_SYMBOL("vmlist", vmlist);
WRITE_SYMBOL("vmap_area_list", vmap_area_list);
WRITE_SYMBOL("node_online_map", node_online_map);
@@ -2500,6 +2504,8 @@ read_vmcoreinfo(void)
READ_SYMBOL("_stext", _stext);
READ_SYMBOL("swapper_pg_dir", swapper_pg_dir);
READ_SYMBOL("init_level4_pgt", init_level4_pgt);
+ READ_SYMBOL("level4_kernel_pgt", level4_kernel_pgt);
+ READ_SYMBOL("init_top_pgt", init_top_pgt);
READ_SYMBOL("vmlist", vmlist);
READ_SYMBOL("vmap_area_list", vmap_area_list);
READ_SYMBOL("node_online_map", node_online_map);
diff --git a/makedumpfile.h b/makedumpfile.h
index 8a05794..9357e47 100644
--- a/makedumpfile.h
+++ b/makedumpfile.h
@@ -1517,6 +1517,8 @@ struct symbol_table {
unsigned long long _stext;
unsigned long long swapper_pg_dir;
unsigned long long init_level4_pgt;
+ unsigned long long level4_kernel_pgt;
+ unsigned long long init_top_pgt;
unsigned long long vmlist;
unsigned long long vmap_area_list;
unsigned long long phys_base;
--
Jeff Mahoney
SUSE Labs
More information about the kexec
mailing list