You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

94 lines
3.1 KiB

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