[PATCH] makedumpfile/x86_64: Fix calculation of page_offset for kernel 4.19

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Bhupesh, Baoquan,

As for x86_64, I'm going to merge the patch below for fixing the
--mem-usage issue with kernel 4.19, if there is no objection.
I think the same approach will also work on arm64 with regard to
page_offset for the time being..

Thanks,
Kazu

--
From: Kazuhito Hagio <k-hagio@xxxxxxxxxxxxx>
Date: Fri, 26 Oct 2018 14:43:22 -0400
Subject: [PATCH] x86_64: Fix calculation of page_offset for kernel 4.19

* Required for kernel 4.19

Kernel commit 6855dc41b24619c3d1de3dbd27dd0546b0e45272 ("x86: Add
entry trampolines to kcore") added program headers for PTI entry
trampoline pages to /proc/kcore.

This caused the failure of makedumpfile --mem-usage due to wrong
calculation of page_offset.

  # makedumpfile --mem-usage /proc/kcore
  [...]
  set_kcore_vmcoreinfo: Can't get the offset of VMCOREINFO(/proc/kcore). Success

  makedumpfile Failed.

Since program headers for linear maps are located after ones for
kernel text and so on in /proc/vmcore and /proc/kcore, with this
patch, we use the last valid one to set page_offset.

Also, this patch adds a few debug messages for better debugging.

Cc: Bhupesh Sharma <bhsharma@xxxxxxxxxx>
Cc: Baoquan He <bhe@xxxxxxxxxx>
Signed-off-by: Kazuhito Hagio <k-hagio@xxxxxxxxxxxxx>
---
 arch/x86_64.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/arch/x86_64.c b/arch/x86_64.c
index 2b3c0bb..ed2a970 100644
--- a/arch/x86_64.c
+++ b/arch/x86_64.c
@@ -95,10 +95,17 @@ get_page_offset_x86_64(void)
 			 ERRMSG("Can't read page_offset_base.\n");
 			 return FALSE;
 		}
+		DEBUG_MSG("page_offset  : %lx (from page_offset_base)\n",
+			info->page_offset);
 		return TRUE;
 	}
 
 	if (get_num_pt_loads()) {
+		/*
+		 * Since program headers for linear maps are located after
+		 * ones for kernel text and so on in /proc/vmcore and
+		 * /proc/kcore, we use the last valid one to set page_offset.
+		 */
 		for (i = 0;
 			get_pt_load(i, &phys_start, NULL, &virt_start, NULL);
 			i++) {
@@ -106,9 +113,13 @@ get_page_offset_x86_64(void)
 					&& virt_start < __START_KERNEL_map
 					&& phys_start != NOT_PADDR) {
 				info->page_offset = virt_start - phys_start;
-				return TRUE;
 			}
 		}
+		if (info->page_offset) {
+			DEBUG_MSG("page_offset  : %lx (from pt_load)\n",
+				info->page_offset);
+			return TRUE;
+		}
 	}
 
 	if (info->kernel_version < KERNEL_VERSION(2, 6, 27)) {
@@ -119,6 +130,7 @@ get_page_offset_x86_64(void)
 		info->page_offset = __PAGE_OFFSET_2_6_27;
 	}
 
+	DEBUG_MSG("page_offset  : %lx (from constant)\n", info->page_offset);
 	return TRUE;
 }
 
-- 
1.8.3.1



_______________________________________________
kexec mailing list
kexec@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/kexec



[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux