[Crash-utility] [PATCH v2] arm64: fix kernel memory map handling for kaslr-enabled kernel

AKASHI Takahiro takahiro.akashi at linaro.org
Fri May 27 03:18:56 UTC 2016


On Thu, May 26, 2016 at 01:27:08PM +0530, Pratyush Anand wrote:
> On 26/05/2016:04:04:08 PM, AKASHI Takahiro wrote:
> > Pratyush,
> > 
> > Just for debug purpose.
> > Please add the following line to *your* arch_crash_save_vmcoreinfo():
> > > vmcoreinfo_append_str("NUMBER(kimage_voffset)=%llx\n", kimage_voffset);
> 
> Thanks for the pointer.
> 
> I did had VMCOREINFO_NUMBER(kimage_voffset) in arch_crash_save_vmcoreinfo().
> 
> https://github.com/pratyushanand/linux/commit/7011e478aae3e568cc8dca15b6c128fe728416f7#diff-cdf29c3b9471b9d813afc107dd154acdR291
> 
> But, I noticed that in crash code you have "ms->kimage_voffset = htol(string,
> QUIET, NULL);". So, the change you have suggested will work.

I know that. It is intentional.

> However, I think its preferable to use VMCOREINFO_NUMBER() macro instead.
> makedumpfile is able to calculate kimage_voffset correctly with that without any
> issue.

I think that VMCOREINFO_NUMBER() is, at least originally, intended
to be used for a small *unsigned* integer.

I also know that PHYS_OFFSET can now be nagative in v4.6 on arm64.
Yet I'm thinking of adding "0x" as a prefix to VMCOREINOF string.

-Takahiro AKASHI

> I will suggest to take following modification in crash code:
> 
> diff --git a/arm64.c b/arm64.c
> index 6b97093..9397d6d 100644
> --- a/arm64.c
> +++ b/arm64.c
> @@ -122,7 +122,7 @@ arm64_init(int when)
>                 ms = machdep->machspec;
>                 if (!ms->kimage_voffset &&
>                     (string = pc->read_vmcoreinfo("NUMBER(kimage_voffset)"))) {
> -                       ms->kimage_voffset = htol(string, QUIET, NULL);
> +                       ms->kimage_voffset = dtol(string, QUIET, NULL);
>                         free(string);
>                 }
> 
> diff --git a/tools.c b/tools.c
> index 384bebd..1383e43 100644
> --- a/tools.c
> +++ b/tools.c
> @@ -877,7 +877,7 @@ dtol(char *s, int flags, int *errptr)
>                  s++;
> 
>          for (j = 0; s[j] != '\0'; j++)
> -                if ((s[j] < '0' || s[j] > '9'))
> +                if ( (s[j] != '-') && ((s[j] < '0' || s[j] > '9')))
>                          break ;
> 
>         if (s[j] != '\0') {
> 
> ~Pratyush
> 
> > 
> > I will add this to my next kdump patch.
> > 
> > Thanks,
> > -Takahiro AKASHI
> > 
> > 
> > On Thu, May 26, 2016 at 10:58:24AM +0530, Pratyush Anand wrote:
> > > On 24/05/2016:01:59:06 PM, Dave Anderson wrote:
> > > > 
> > > > 
> > > > ----- Original Message -----
> > > > > Yet some issues, but ...
> > > > >
> > > > 
> > > > Hi Takahiro,
> > > > 
> > > > Here are my general comments on my testing of the v2 patch, followed 
> > > > by a few comments in the patch itself. 
> > > > 
> > > > First, the combination of the new memory map layout and KASLR is somewhat
> > > > confusing.  I am testing your patch on a 4.6.0-0.rc7.git2.1.fc25 kernel
> > > > that has this configuration:
> > > > 
> > > >   config-arm64:# CONFIG_RANDOMIZE_BASE is not set
> > > > 
> > > > So KASLR doesn't really enter into the picture.  But when bringing
> > > > up the crash session, it shows the "kaslr kernel" WARNING:
> > > > 
> > > >   # ./crash
> > > >   
> > > >   crash 7.1.5++
> > > >   Copyright (C) 2002-2016  Red Hat, Inc.
> > > >   Copyright (C) 2004, 2005, 2006, 2010  IBM Corporation
> > > >   Copyright (C) 1999-2006  Hewlett-Packard Co
> > > >   Copyright (C) 2005, 2006, 2011, 2012  Fujitsu Limited
> > > >   Copyright (C) 2006, 2007  VA Linux Systems Japan K.K.
> > > >   Copyright (C) 2005, 2011  NEC Corporation
> > > >   Copyright (C) 1999, 2002, 2007  Silicon Graphics, Inc.
> > > >   Copyright (C) 1999, 2000, 2001, 2002  Mission Critical Linux, Inc.
> > > >   This program is free software, covered by the GNU General Public License,
> > > >   and you are welcome to change it and/or distribute copies of it under
> > > >   certain conditions.  Enter "help copying" to see the conditions.
> > > >   This program has absolutely no warranty.  Enter "help warranty" for details.
> > > >    
> > > >   WARNING: kimage_voffset not identified for kaslr kernel
> > > >   GNU gdb (GDB) 7.6
> > > >   Copyright (C) 2013 Free Software Foundation, Inc.
> > > >   License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
> > > >   This is free software: you are free to change and redistribute it.
> > > >   There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
> > > >   and "show warranty" for details.
> > > >   This GDB was configured as "aarch64-unknown-linux-gnu"...
> > > >   
> > > >         KERNEL: /usr/lib/debug/lib/modules/4.6.0-0.rc7.git2.1.fc25.aarch64/vmlinux
> > > >       DUMPFILE: /dev/crash
> > > >           CPUS: 8
> > > >           DATE: Tue May 24 10:08:08 2016
> > > >         UPTIME: 11 days, 18:32:41
> > > >   LOAD AVERAGE: 0.17, 0.09, 0.12
> > > >          TASKS: 197
> > > >       NODENAME: apm-mustang-ev3-36.khw.lab.eng.bos.redhat.com
> > > >        RELEASE: 4.6.0-0.rc7.git2.1.fc25.aarch64
> > > >        VERSION: #1 SMP Thu May 12 13:28:43 UTC 2016
> > > >        MACHINE: aarch64  (unknown Mhz)
> > > >         MEMORY: 16 GB
> > > >            PID: 7556
> > > >        COMMAND: "crash"
> > > >           TASK: fffffe00beb45400  [THREAD_INFO: fffffe00beb98000]
> > > >            CPU: 7
> > > >          STATE: TASK_RUNNING (ACTIVE)
> > > >   
> > > >   crash>
> > > 
> > > Do not know whats missing, I am yet not able to reach "crash>" prompt. I have
> > > crash utility having this patch on top of "commit
> > > 8ceb1ac628bf6a0a7f0bbfff030ec93081bca4cd" [1]. I have kernel code v4.6+kexec-v15 [2].
> > > 
> > > In my .config:
> > > # CONFIG_KASAN is not set
> > > # CONFIG_RANDOMIZE_BASE is not set
> > > 
> > > This is what I get:
> > > 
> > > [root at dhcppc15 crash]# ./crash /lib/modules/4.6.0+/build/vmlinux /var/crash/127.0.0.1-2016-05-26-09\:40\:05/vmcore
> > > 
> > > crash 7.1.5++
> > > Copyright (C) 2002-2016  Red Hat, Inc.
> > > Copyright (C) 2004, 2005, 2006, 2010  IBM Corporation
> > > Copyright (C) 1999-2006  Hewlett-Packard Co
> > > Copyright (C) 2005, 2006, 2011, 2012  Fujitsu Limited
> > > Copyright (C) 2006, 2007  VA Linux Systems Japan K.K.
> > > Copyright (C) 2005, 2011  NEC Corporation
> > > Copyright (C) 1999, 2002, 2007  Silicon Graphics, Inc.
> > > Copyright (C) 1999, 2000, 2001, 2002  Mission Critical Linux, Inc.
> > > This program is free software, covered by the GNU General Public License,
> > > and you are welcome to change it and/or distribute copies of it under
> > > certain conditions.  Enter "help copying" to see the conditions.
> > > This program has absolutely no warranty.  Enter "help warranty" for details.
> > > 
> > > GNU gdb (GDB) 7.6
> > > Copyright (C) 2013 Free Software Foundation, Inc.
> > > License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
> > > This is free software: you are free to change and redistribute it.
> > > There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
> > > and "show warranty" for details.
> > > This GDB was configured as "aarch64-unknown-linux-gnu"...
> > > 
> > > crash: read error: kernel virtual address: fffffc0008b80fd8  type: "possible"
> > > WARNING: cannot read cpu_possible_map
> > > crash: read error: kernel virtual address: fffffc0008b80dd8  type: "present"
> > > WARNING: cannot read cpu_present_map
> > > crash: read error: kernel virtual address: fffffc0008b80bd8  type: "online"
> > > WARNING: cannot read cpu_online_map
> > > crash: read error: kernel virtual address: fffffc0008b811d8  type: "active"
> > > WARNING: cannot read cpu_active_map
> > > crash: read error: kernel virtual address: fffffc00091f6c78  type: "shadow_timekeeper xtime_sec"
> > > crash: read error: kernel virtual address: fffffc0008b9223c  type: "init_uts_ns"
> > > crash: /lib/modules/4.6.0+/build/vmlinux and /var/crash/127.0.0.1-2016-05-26-09:40:05/vmcore do not match!
> > > 
> > > Usage:
> > > 
> > >   crash [OPTION]... NAMELIST MEMORY-IMAGE[@ADDRESS]     (dumpfile form)
> > >   crash [OPTION]... [NAMELIST]                          (live system form)
> > > 
> > > Enter "crash -h" for details.
> > > 
> > > 
> > > ~Pratyush
> > > 
> > > [1] https://github.com/pratyushanand/crash/commits/master
> > > [2] https://github.com/pratyushanand/linux/commits/upstream_arm64_devel_test
> > > 
> > 
> > -- 
> > Thanks,
> > -Takahiro AKASHI

-- 
Thanks,
-Takahiro AKASHI




More information about the Crash-utility mailing list