# good command to start 'crash utility'

 

1. 1st verified command 


./crash dump1@0x80000000,dump2@0x880000000 -p 4096 -m vabits_actual=39 -m kimage_voffset=0xffffffbf70000000 --no_panic --smp $1

 

2. Under progress

 

./crash1 -d -6 SYS_COREDUMP -m --kaslr=0x1d43c00000 -m vabits_actual=39 -m kimage_voffset=0xffffffa611c00000 -m --smp vmlinux

diff --git a/arm64.c b/arm64.c
index bdb2a0a..7c3a8ea 100644
--- a/arm64.c
+++ b/arm64.c
@@ -361,6 +361,19 @@ arm64_init(int when)
        /* use machdep parameters */
        arm64_calc_phys_offset();
     
+       error(INFO, "[+][%s][%d] at %s\n", __func__, __LINE__, __FILE__);
+       error(INFO, "kimage_voffset: %lx phys_offset: %lx \n",
+                               machdep->machspec->kimage_voffset, machdep->machspec->phys_offset);
+
+        error(INFO, "CONFIG_ARM64_VA_BITS: %ld\n", ms->CONFIG_ARM64_VA_BITS);
+        error(INFO,  "     VA_BITS_ACTUAL: %ld\n", ms->VA_BITS_ACTUAL);
+        error(INFO, "(calculated) VA_BITS: %ld\n", ms->VA_BITS);
+        error(INFO, " PAGE_OFFSET: %lx\n", ARM64_PAGE_OFFSET_ACTUAL);
+        error(INFO, "    VA_START: %lx\n", ms->VA_START);
+        error(INFO, "     modules: %lx - %lx\n", ms->modules_vaddr, ms->modules_end);
+        error(INFO, "     vmalloc: %lx - %lx\n", ms->vmalloc_start_addr, ms->vmalloc_end);
+        error(INFO, "kernel image: %lx - %lx\n", ms->kimage_text, ms->kimage_end);
+        error(INFO, "     vmemmap: %lx - %lx\n\n", ms->vmemmap_vaddr, ms->vmemmap_end);
        if (CRASHDEBUG(1)) {
            if (machdep->flags & NEW_VMEMMAP)
                fprintf(fp, "kimage_voffset: %lx\n",
@@ -816,6 +829,11 @@ arm64_parse_cmdline_args(void)
                    "setting max_physmem_bits to: %ld\n\n",
                    machdep->max_physmem_bits);
                continue;
+           } else if (arm64_parse_machdep_arg_l(arglist[i], "kaddr_offset",
+               &machdep->machspec->kimage_addr_offset)) {
+               error(WARNING, "setting kimage_addr_offset to: 0x%lx\n\n",
+                                   machdep->machspec->kimage_addr_offset);
+               continue;
            }
  
            error(WARNING, "ignoring --machdep option: %s\n",
@@ -1011,6 +1029,12 @@ arm64_kdump_phys_base(ulong *phys_offset)
    if ((machdep->flags & NEW_VMEMMAP) &&
        machdep->machspec->kimage_voffset &&
        (sp = kernel_symbol_search("memstart_addr"))) {
+
+       physaddr_t kimage_offset_addr = machdep->machspec->kimage_addr_offset;
+
+       if (kimage_offset_addr) {
+           machdep->machspec->kimage_voffset -= kimage_offset_addr;
+       }
        paddr = sp->value - machdep->machspec->kimage_voffset;
        if (READMEM(-1, phys_offset, sizeof(*phys_offset),
            sp->value, paddr) > 0)
diff --git a/defs.h b/defs.h
index 42e381e..a377611 100644
--- a/defs.h
+++ b/defs.h
@@ -3259,6 +3259,7 @@ struct machine_specific {
    ulong VA_BITS_ACTUAL;
    ulong CONFIG_ARM64_VA_BITS;
    ulong VA_START;
+   ulong kimage_addr_offset;
 };
  
 struct arm64_stackframe {
diff --git a/main.c b/main.c
index 83ccd31..971486e 100644
--- a/main.c
+++ b/main.c
@@ -21,6 +21,13 @@
 #include <getopt.h>
 #include <sys/prctl.h>
  
+#define OCIMEM_OFFSET_ADDR             0x14680000
+#define RPI5_KASLR_ADDR_LOCATION     0x146bf6d0
+#define ADDR_READ_OFFSET           0x4
+
+#define RPI5_ADDR_FORMAT_SIZE    19
+#define RPI5_KASLR_ADDR_OFFSET  ( RPI5_KASLR_ADDR_LOCATION - OCIMEM_OFFSET_ADDR + ADDR_READ_OFFSET )
+
 static void setup_environment(int, char **);
 static int is_external_command(void);
 static int is_builtin_command(void);
@@ -80,6 +87,9 @@ main(int argc, char **argv)
 {
    int i, c, option_index;
    char *tmpname;
+   FILE *ocimem_file = NULL;
+   uint64_t c_64, kaslr_offset = 0;
+   char *optarg_backup;
  
    setup_environment(argc, argv);
  
@@ -226,6 +236,29 @@ main(int argc, char **argv)
                        optarg);
                }
            } else if (STREQ(long_options[option_index].name, "kaslr")) {
+               ocimem_file = fopen("./OCIMEM.BIN", "r");
+
+               if(!ocimem_file) {
+                   error(INFO, "Fail to open OCIMEM.BIN\n");
+                   goto OCIMEM_READ_EXIT;
+               }
+
+               fseek(ocimem_file, RPI5_KASLR_ADDR_OFFSET, SEEK_SET);
+
+               optarg_backup = optarg;
+               optarg = malloc(RPI5_ADDR_FORMAT_SIZE);
+
+               for(i=0;i<sizeof(uint64_t);i++) {
+                   c_64 = getc(ocimem_file);
+                   kaslr_offset |= (c_64 << (i*8));
+               }
+              
+               snprintf(optarg, RPI5_ADDR_FORMAT_SIZE, "0x%lx", kaslr_offset);
+               error(INFO, "kaslr_offset=%s\n", optarg);
+OCIMEM_READ_EXIT:
+               if(ocimem_file)
+                   fclose(ocimem_file);
+
                if (!machine_type("X86_64") &&
                    !machine_type("ARM64") && !machine_type("X86") &&
                    !machine_type("S390X"))

 

>>>

* bad dump

SECTIONS_PER_ROOT = 128
SECTION_ROOT_MASK = 0x7f
PAGES_PER_SECTION = 262144
<readmem: ffffffa653a30058, KVADDR, "mem_section", 8, (FOE), 7ffd4f76eb20>
<read_kdump: addr: ffffffa653a30058 paddr: 41e30058 cnt: 8>
read_netdump: addr: ffffffa653a30058 paddr: 41e30058 cnt: 8 offset: 1e34058
<readmem: 0, KVADDR, "memory section root table", 64, (FOE), 5625b4edac70>
crash1: invalid kernel virtual address: 0  type: "memory section root table"


        if (!(vt->mem_sec = (void *)malloc(mem_section_size)))
                error(FATAL, "cannot malloc mem_sec cache\n");
        if (!(vt->mem_section = (char *)malloc(SIZE(mem_section))))
                error(FATAL, "cannot malloc mem_section cache\n");

        if (mem_section_is_ptr)
                get_symbol_data("mem_section", sizeof(void *), &addr);
        else
                addr = symbol_value("mem_section");

        readmem(addr, KVADDR, vt->mem_sec, mem_section_size,
                "memory section root table", FAULT_ON_ERROR);

 * good dump 

crash64>  p &mem_section
p: per_cpu_symbol_search(&mem_section): NULL
GETBUF(344 -> 0)
$1 = (struct mem_section ***) 0xffffff9d4e1a0010 <mem_section>
FREEBUF(0)


 7135 <readmem: ffffffd3bf5eb880, KVADDR, "memory section root table", 32768, (FOE), 556a792d83e0>
 7136 <read_ramdump: addr: ffffffd3bf5eb880 paddr: 17f5eb880 cnt: 1920>
 7137 read_ramdump: addr: ffffffd3bf5eb880 paddr: 17f5eb880 cnt: 1920 offset: 3f5eb880
 7138 <read_ramdump: addr: ffffffd3bf5ec000 paddr: 17f5ec000 cnt: 4096>
 7139 read_ramdump: addr: ffffffd3bf5ec000 paddr: 17f5ec000 cnt: 4096 offset: 3f5ec000
 7140 <read_ramdump: addr: ffffffd3bf5ed000 paddr: 17f5ed000 cnt: 4096>

crash64> rd 0xffffff9d4e1a0010 100
<addr: ffffff9d4e1a0010 count: 100 flag: 490 (KVADDR)>
<readmem: ffffff9d4e1a0010, KVADDR, "64-bit KVADDR", 8, (FOE), 7ffea347dc28>
<read_ramdump: addr: ffffff9d4e1a0010 paddr: a25a0010 cnt: 8>
read_ramdump: addr: ffffff9d4e1a0010 paddr: a25a0010 cnt: 8 offset: 225a0010
ffffff9d4e1a0010:  ffffffd3bf5eb880 <readmem: ffffff9d4e1a0018, KVADDR, "64-bit KVADDR", 8, (FOE), 7ffea347dc28>


./crash64 --minimal SYS_COREDUMP vmlinux

./crash64 --minimal SYS_COREDUMP --kaslr=0x1d43c00000 vmlinux

+ Recent posts