From 10d9a7879589888c8ffe24e8245062115dc16f1e Mon Sep 17 00:00:00 2001 From: Yueyi Li Date: Tue, 14 Mar 2017 21:25:21 +0800 Subject: [PATCH] [ARM64][patch] Auto calculate kimage_voffset by kaslr offset ARM64 kimage_voffset can be calculated if kernel ASLR offset is known. Add a function to auto calculate kimage_voffset when '--kaslr=' was set. --- arm64.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/arm64.c b/arm64.c index 6eaf96d..b51b826 100644 --- a/arm64.c +++ b/arm64.c @@ -27,6 +27,7 @@ static struct machine_specific arm64_machine_specific = { 0 }; static int arm64_verify_symbol(const char *, ulong, char); static void arm64_parse_cmdline_args(void); +static void arm64_calc_kimage_voffset(void); static void arm64_calc_phys_offset(void); static void arm64_calc_virtual_memory_ranges(void); static int arm64_kdump_phys_base(ulong *); @@ -324,6 +325,9 @@ arm64_init(int when) machdep->init_kernel_pgd = arm64_init_kernel_pgd; /* use machdep parameters */ + arm64_calc_kimage_voffset(); + + /* use machdep parameters */ arm64_calc_phys_offset(); if (CRASHDEBUG(1)) { @@ -735,6 +739,23 @@ arm64_parse_cmdline_args(void) } } +static void +arm64_calc_kimage_voffset(void) +{ + struct machine_specific *ms = machdep->machspec; + ulong phys_offset; + + if (ms->kimage_voffset) /* vmcoreinfo or --machdep override */ + return; + + if (DISKDUMP_DUMPFILE()) + return; + else if ((kt->flags2 & KASLR) && (kt->flags & RELOC_SET)){ + arm_kdump_phys_base(&phys_offset); /*get start address of first memory block*/ + ms->kimage_voffset = ms->vmalloc_start_addr + (kt->relocate * -1) - phys_offset; + } + +} static void arm64_calc_phys_offset(void) -- 1.9.1