Blame SOURCES/kexec-tools-2.0.15-makedumpfile-Introduce-vtop4_x86_64_pagetable.patch

06c2a2
From 8c89727155f4994b4e75a659e28e5eff16ff6cbc Mon Sep 17 00:00:00 2001
06c2a2
From: Takao Indoh <indou.takao@jp.fujitsu.com>
06c2a2
Date: Thu, 26 Oct 2017 20:32:54 +0900
06c2a2
Subject: [PATCH 2/4] [PATCH v3 2/4] Introduce vtop4_x86_64_pagetable
06c2a2
06c2a2
This patch introduces new function vtop4_x86_64_pagetable
06c2a2
to translate virtual address to physical address. Unlike vtop4_x86_64,
06c2a2
vtop4_x86_64_pagetable need a pointer of top of pagetable like CR3.
06c2a2
06c2a2
Current vtop4_x86_64 implementation uses symbol value of
06c2a2
init_level4_pgt, therefore vtop4_x86_64 does not work for sadump
06c2a2
dumpfile of kaslr enabled kernel because it does not have vmcoreinfo to
06c2a2
correct address of init_level4_pgt. vtop4_x86_64_pagetable requires
06c2a2
pagetable address instead of init_level4_pgt and sadump dumpfile can
06c2a2
pass CR3 value which is included in dump header.
06c2a2
06c2a2
Signed-off-by: Takao Indoh <indou.takao@jp.fujitsu.com>
06c2a2
Signed-off-by: HATAYAMA Daisuke <d.hatayama@jp.fujitsu.com>
06c2a2
---
06c2a2
 arch/x86_64.c  | 30 +++++++++++++++++++++++-------
06c2a2
 makedumpfile.h |  1 +
06c2a2
 2 files changed, 24 insertions(+), 7 deletions(-)
06c2a2
06c2a2
diff --git a/arch/x86_64.c b/arch/x86_64.c
06c2a2
index 08dd6b208bce..33621f1f259c 100644
06c2a2
--- a/makedumpfile-1.6.2/arch/x86_64.c
06c2a2
+++ b/makedumpfile-1.6.2/arch/x86_64.c
06c2a2
@@ -255,20 +255,15 @@ get_versiondep_info_x86_64(void)
06c2a2
  * Translate a virtual address to a physical address by using 4 levels paging.
06c2a2
  */
06c2a2
 unsigned long long
06c2a2
-vtop4_x86_64(unsigned long vaddr)
06c2a2
+__vtop4_x86_64(unsigned long vaddr, unsigned long pagetable)
06c2a2
 {
06c2a2
 	unsigned long page_dir, pml4, pgd_paddr, pgd_pte, pmd_paddr, pmd_pte;
06c2a2
 	unsigned long pte_paddr, pte;
06c2a2
 
06c2a2
-	if (SYMBOL(init_level4_pgt) == NOT_FOUND_SYMBOL) {
06c2a2
-		ERRMSG("Can't get the symbol of init_level4_pgt.\n");
06c2a2
-		return NOT_PADDR;
06c2a2
-	}
06c2a2
-
06c2a2
 	/*
06c2a2
 	 * Get PGD.
06c2a2
 	 */
06c2a2
-	page_dir = SYMBOL(init_level4_pgt) - __START_KERNEL_map + info->phys_base;
06c2a2
+	page_dir = pagetable;
06c2a2
 	if (is_xen_memory()) {
06c2a2
 		page_dir = ptom_xen(page_dir);
06c2a2
 		if (page_dir == NOT_PADDR)
06c2a2
@@ -346,6 +341,27 @@ vtop4_x86_64(unsigned long vaddr)
06c2a2
 	return (pte & ENTRY_MASK) + PAGEOFFSET(vaddr);
06c2a2
 }
06c2a2
 
06c2a2
+unsigned long long
06c2a2
+vtop4_x86_64(unsigned long vaddr)
06c2a2
+{
06c2a2
+	unsigned long pagetable;
06c2a2
+
06c2a2
+	if (SYMBOL(init_level4_pgt) == NOT_FOUND_SYMBOL) {
06c2a2
+		ERRMSG("Can't get the symbol of init_level4_pgt.\n");
06c2a2
+		return NOT_PADDR;
06c2a2
+	}
06c2a2
+
06c2a2
+	pagetable = SYMBOL(init_level4_pgt) - __START_KERNEL_map + info->phys_base;
06c2a2
+
06c2a2
+	return __vtop4_x86_64(vaddr, pagetable);
06c2a2
+}
06c2a2
+
06c2a2
+unsigned long long
06c2a2
+vtop4_x86_64_pagetable(unsigned long vaddr, unsigned long pagetable)
06c2a2
+{
06c2a2
+	return __vtop4_x86_64(vaddr, pagetable);
06c2a2
+}
06c2a2
+
06c2a2
 /*
06c2a2
  * for Xen extraction
06c2a2
  */
06c2a2
diff --git a/makedumpfile.h b/makedumpfile.h
06c2a2
index 704a6bc2f8f4..f48dc0b82d4a 100644
06c2a2
--- a/makedumpfile-1.6.2/makedumpfile.h
06c2a2
+++ b/makedumpfile-1.6.2/makedumpfile.h
06c2a2
@@ -978,6 +978,7 @@ int get_phys_base_x86_64(void);
06c2a2
 int get_machdep_info_x86_64(void);
06c2a2
 int get_versiondep_info_x86_64(void);
06c2a2
 unsigned long long vtop4_x86_64(unsigned long vaddr);
06c2a2
+unsigned long long vtop4_x86_64_pagetable(unsigned long vaddr, unsigned long pagetable);
06c2a2
 #define find_vmemmap()		find_vmemmap_x86_64()
06c2a2
 #define get_phys_base()		get_phys_base_x86_64()
06c2a2
 #define get_machdep_info()	get_machdep_info_x86_64()
06c2a2
-- 
06c2a2
2.5.5
06c2a2