Compare commits
No commits in common. "imports/c8s/crash-7.2.8-7.el8" and "c8" have entirely different histories.
imports/c8
...
c8
|
@ -0,0 +1,2 @@
|
|||
SOURCES/crash-8.0.4.tar.gz
|
||||
SOURCES/gdb-10.2.tar.gz
|
|
@ -0,0 +1,142 @@
|
|||
From 38acd02c7fc09843ffb10fc2d695cccdd10cc7f6 Mon Sep 17 00:00:00 2001
|
||||
From: Chengen Du <chengen.du@canonical.com>
|
||||
Date: Fri, 17 Nov 2023 11:45:33 +0800
|
||||
Subject: [PATCH 01/14] Fix "rd" command for zram data display in Linux 6.2 and
|
||||
later
|
||||
|
||||
Kernel commit 7ac07a26dea7 ("zram: preparation for multi-zcomp support")
|
||||
replaced "compressor" member with "comp_algs" in the zram struct.
|
||||
Without the patch, the "rd" command can triggers the following error:
|
||||
|
||||
rd: WARNING: Some pages are swapped out to zram. Please run mod -s zram.
|
||||
rd: invalid user virtual address: ffff7d23f010 type: "64-bit UVADDR"
|
||||
|
||||
Related kernel commit:
|
||||
84b33bf78889 ("zram: introduce recompress sysfs knob")
|
||||
|
||||
Signed-off-by: Chengen Du <chengen.du@canonical.com>
|
||||
Signed-off-by: Kazuhito Hagio <k-hagio-ab@nec.com>
|
||||
Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
|
||||
---
|
||||
defs.h | 1 +
|
||||
diskdump.c | 47 ++++++++++++++++++++++++++++++-----------------
|
||||
2 files changed, 31 insertions(+), 17 deletions(-)
|
||||
|
||||
diff --git a/defs.h b/defs.h
|
||||
index 788f63ada739..2cae5b61e589 100644
|
||||
--- a/defs.h
|
||||
+++ b/defs.h
|
||||
@@ -2227,6 +2227,7 @@ struct offset_table { /* stash of commonly-used offsets */
|
||||
long module_memory_size;
|
||||
long irq_data_irq;
|
||||
long zspage_huge;
|
||||
+ long zram_comp_algs;
|
||||
};
|
||||
|
||||
struct size_table { /* stash of commonly-used sizes */
|
||||
diff --git a/diskdump.c b/diskdump.c
|
||||
index 0fe46f4644d0..25054d96313e 100644
|
||||
--- a/diskdump.c
|
||||
+++ b/diskdump.c
|
||||
@@ -2757,6 +2757,8 @@ diskdump_device_dump_info(FILE *ofp)
|
||||
|
||||
static ulong ZRAM_FLAG_SHIFT;
|
||||
static ulong ZRAM_FLAG_SAME_BIT;
|
||||
+static ulong ZRAM_COMP_PRIORITY_BIT1;
|
||||
+static ulong ZRAM_COMP_PRIORITY_MASK;
|
||||
|
||||
static void
|
||||
zram_init(void)
|
||||
@@ -2765,6 +2767,8 @@ zram_init(void)
|
||||
|
||||
MEMBER_OFFSET_INIT(zram_mempoll, "zram", "mem_pool");
|
||||
MEMBER_OFFSET_INIT(zram_compressor, "zram", "compressor");
|
||||
+ if (INVALID_MEMBER(zram_compressor))
|
||||
+ MEMBER_OFFSET_INIT(zram_comp_algs, "zram", "comp_algs");
|
||||
MEMBER_OFFSET_INIT(zram_table_flag, "zram_table_entry", "flags");
|
||||
if (INVALID_MEMBER(zram_table_flag))
|
||||
MEMBER_OFFSET_INIT(zram_table_flag, "zram_table_entry", "value");
|
||||
@@ -2782,6 +2786,8 @@ zram_init(void)
|
||||
|
||||
ZRAM_FLAG_SHIFT = 1 << zram_flag_shift;
|
||||
ZRAM_FLAG_SAME_BIT = 1 << (zram_flag_shift+1);
|
||||
+ ZRAM_COMP_PRIORITY_BIT1 = ZRAM_FLAG_SHIFT + 7;
|
||||
+ ZRAM_COMP_PRIORITY_MASK = 0x3;
|
||||
|
||||
if (CRASHDEBUG(1))
|
||||
fprintf(fp, "zram_flag_shift: %ld\n", zram_flag_shift);
|
||||
@@ -2981,9 +2987,9 @@ try_zram_decompress(ulonglong pte_val, unsigned char *buf, ulong len, ulonglong
|
||||
ulong zram, zram_table_entry, sector, index, entry, flags, size,
|
||||
outsize, off;
|
||||
|
||||
- if (INVALID_MEMBER(zram_compressor)) {
|
||||
+ if (INVALID_MEMBER(zram_mempoll)) {
|
||||
zram_init();
|
||||
- if (INVALID_MEMBER(zram_compressor)) {
|
||||
+ if (INVALID_MEMBER(zram_mempoll)) {
|
||||
error(WARNING,
|
||||
"Some pages are swapped out to zram. "
|
||||
"Please run mod -s zram.\n");
|
||||
@@ -2997,8 +3003,28 @@ try_zram_decompress(ulonglong pte_val, unsigned char *buf, ulong len, ulonglong
|
||||
if (!get_disk_name_private_data(pte_val, vaddr, NULL, &zram))
|
||||
return 0;
|
||||
|
||||
- readmem(zram + OFFSET(zram_compressor), KVADDR, name,
|
||||
- sizeof(name), "zram compressor", FAULT_ON_ERROR);
|
||||
+ if (THIS_KERNEL_VERSION >= LINUX(2, 6, 0))
|
||||
+ swp_offset = (ulonglong)__swp_offset(pte_val);
|
||||
+ else
|
||||
+ swp_offset = (ulonglong)SWP_OFFSET(pte_val);
|
||||
+
|
||||
+ sector = swp_offset << (PAGESHIFT() - 9);
|
||||
+ index = sector >> SECTORS_PER_PAGE_SHIFT;
|
||||
+ readmem(zram, KVADDR, &zram_table_entry,
|
||||
+ sizeof(void *), "zram_table_entry", FAULT_ON_ERROR);
|
||||
+ zram_table_entry += (index * SIZE(zram_table_entry));
|
||||
+ readmem(zram_table_entry + OFFSET(zram_table_flag), KVADDR, &flags,
|
||||
+ sizeof(void *), "zram_table_flag", FAULT_ON_ERROR);
|
||||
+ if (VALID_MEMBER(zram_compressor))
|
||||
+ readmem(zram + OFFSET(zram_compressor), KVADDR, name, sizeof(name),
|
||||
+ "zram compressor", FAULT_ON_ERROR);
|
||||
+ else {
|
||||
+ ulong comp_alg_addr;
|
||||
+ uint32_t prio = (flags >> ZRAM_COMP_PRIORITY_BIT1) & ZRAM_COMP_PRIORITY_MASK;
|
||||
+ readmem(zram + OFFSET(zram_comp_algs) + sizeof(const char *) * prio, KVADDR,
|
||||
+ &comp_alg_addr, sizeof(comp_alg_addr), "zram comp_algs", FAULT_ON_ERROR);
|
||||
+ read_string(comp_alg_addr, name, sizeof(name));
|
||||
+ }
|
||||
if (STREQ(name, "lzo")) {
|
||||
#ifdef LZO
|
||||
if (!(dd->flags & LZO_SUPPORTED)) {
|
||||
@@ -3019,12 +3045,6 @@ try_zram_decompress(ulonglong pte_val, unsigned char *buf, ulong len, ulonglong
|
||||
return 0;
|
||||
}
|
||||
|
||||
- if (THIS_KERNEL_VERSION >= LINUX(2, 6, 0)) {
|
||||
- swp_offset = (ulonglong)__swp_offset(pte_val);
|
||||
- } else {
|
||||
- swp_offset = (ulonglong)SWP_OFFSET(pte_val);
|
||||
- }
|
||||
-
|
||||
zram_buf = (unsigned char *)GETBUF(PAGESIZE());
|
||||
/* lookup page from swap cache */
|
||||
off = PAGEOFFSET(vaddr);
|
||||
@@ -3034,15 +3054,8 @@ try_zram_decompress(ulonglong pte_val, unsigned char *buf, ulong len, ulonglong
|
||||
goto out;
|
||||
}
|
||||
|
||||
- sector = swp_offset << (PAGESHIFT() - 9);
|
||||
- index = sector >> SECTORS_PER_PAGE_SHIFT;
|
||||
- readmem(zram, KVADDR, &zram_table_entry,
|
||||
- sizeof(void *), "zram_table_entry", FAULT_ON_ERROR);
|
||||
- zram_table_entry += (index * SIZE(zram_table_entry));
|
||||
readmem(zram_table_entry, KVADDR, &entry,
|
||||
sizeof(void *), "entry of table", FAULT_ON_ERROR);
|
||||
- readmem(zram_table_entry + OFFSET(zram_table_flag), KVADDR, &flags,
|
||||
- sizeof(void *), "zram_table_flag", FAULT_ON_ERROR);
|
||||
if (!entry || (flags & ZRAM_FLAG_SAME_BIT)) {
|
||||
int count;
|
||||
ulong *same_buf = (ulong *)GETBUF(PAGESIZE());
|
||||
--
|
||||
2.41.0
|
||||
|
|
@ -0,0 +1,168 @@
|
|||
From d65e5d3eae0dd06a5308a5cb00c05fee60594093 Mon Sep 17 00:00:00 2001
|
||||
From: Kazuhito Hagio <k-hagio-ab@nec.com>
|
||||
Date: Mon, 20 Nov 2023 13:22:56 +0900
|
||||
Subject: [PATCH 02/14] Fix typos in offset_table and missing "help -o" items
|
||||
|
||||
A few of zram related members in the offset_table have typos and
|
||||
irregular naming rule, also they are not present in the "help -o"
|
||||
output. Let's fix these.
|
||||
|
||||
Signed-off-by: Kazuhito Hagio <k-hagio-ab@nec.com>
|
||||
Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
|
||||
---
|
||||
defs.h | 8 ++++----
|
||||
diskdump.c | 24 ++++++++++++------------
|
||||
memory.c | 2 +-
|
||||
symbols.c | 12 ++++++++++++
|
||||
4 files changed, 29 insertions(+), 17 deletions(-)
|
||||
|
||||
diff --git a/defs.h b/defs.h
|
||||
index 2cae5b61e589..5218a94fe4a4 100644
|
||||
--- a/defs.h
|
||||
+++ b/defs.h
|
||||
@@ -2112,13 +2112,13 @@ struct offset_table { /* stash of commonly-used offsets */
|
||||
long bpf_prog_aux_name;
|
||||
long page_private;
|
||||
long swap_info_struct_bdev;
|
||||
- long zram_mempoll;
|
||||
+ long zram_mem_pool;
|
||||
long zram_compressor;
|
||||
- long zram_table_flag;
|
||||
- long zspoll_size_class;
|
||||
+ long zram_table_entry_flags;
|
||||
+ long zs_pool_size_class;
|
||||
long size_class_size;
|
||||
long gendisk_private_data;
|
||||
- long zram_table_entry;
|
||||
+ long zram_table_entry; /* unused; but cannot remove */
|
||||
long module_core_size_rw;
|
||||
long module_core_size_rx;
|
||||
long module_init_size_rw;
|
||||
diff --git a/diskdump.c b/diskdump.c
|
||||
index 25054d96313e..f20f3ac519a1 100644
|
||||
--- a/diskdump.c
|
||||
+++ b/diskdump.c
|
||||
@@ -2765,15 +2765,15 @@ zram_init(void)
|
||||
{
|
||||
long zram_flag_shift;
|
||||
|
||||
- MEMBER_OFFSET_INIT(zram_mempoll, "zram", "mem_pool");
|
||||
+ MEMBER_OFFSET_INIT(zram_mem_pool, "zram", "mem_pool");
|
||||
MEMBER_OFFSET_INIT(zram_compressor, "zram", "compressor");
|
||||
if (INVALID_MEMBER(zram_compressor))
|
||||
MEMBER_OFFSET_INIT(zram_comp_algs, "zram", "comp_algs");
|
||||
- MEMBER_OFFSET_INIT(zram_table_flag, "zram_table_entry", "flags");
|
||||
- if (INVALID_MEMBER(zram_table_flag))
|
||||
- MEMBER_OFFSET_INIT(zram_table_flag, "zram_table_entry", "value");
|
||||
+ MEMBER_OFFSET_INIT(zram_table_entry_flags, "zram_table_entry", "flags");
|
||||
+ if (INVALID_MEMBER(zram_table_entry_flags))
|
||||
+ MEMBER_OFFSET_INIT(zram_table_entry_flags, "zram_table_entry", "value");
|
||||
STRUCT_SIZE_INIT(zram_table_entry, "zram_table_entry");
|
||||
- MEMBER_OFFSET_INIT(zspoll_size_class, "zs_pool", "size_class");
|
||||
+ MEMBER_OFFSET_INIT(zs_pool_size_class, "zs_pool", "size_class");
|
||||
MEMBER_OFFSET_INIT(size_class_size, "size_class", "size");
|
||||
MEMBER_OFFSET_INIT(zspage_huge, "zspage", "huge");
|
||||
|
||||
@@ -2826,7 +2826,7 @@ zram_object_addr(ulong pool, ulong handle, unsigned char *zram_buf)
|
||||
if (zs_magic != ZSPAGE_MAGIC)
|
||||
error(FATAL, "zspage magic incorrect: %x\n", zs_magic);
|
||||
|
||||
- class = pool + OFFSET(zspoll_size_class);
|
||||
+ class = pool + OFFSET(zs_pool_size_class);
|
||||
class += (class_idx * sizeof(void *));
|
||||
readmem(class, KVADDR, &class, sizeof(void *), "size_class", FAULT_ON_ERROR);
|
||||
readmem(class + OFFSET(size_class_size), KVADDR,
|
||||
@@ -2987,9 +2987,9 @@ try_zram_decompress(ulonglong pte_val, unsigned char *buf, ulong len, ulonglong
|
||||
ulong zram, zram_table_entry, sector, index, entry, flags, size,
|
||||
outsize, off;
|
||||
|
||||
- if (INVALID_MEMBER(zram_mempoll)) {
|
||||
+ if (INVALID_MEMBER(zram_mem_pool)) {
|
||||
zram_init();
|
||||
- if (INVALID_MEMBER(zram_mempoll)) {
|
||||
+ if (INVALID_MEMBER(zram_mem_pool)) {
|
||||
error(WARNING,
|
||||
"Some pages are swapped out to zram. "
|
||||
"Please run mod -s zram.\n");
|
||||
@@ -3013,8 +3013,8 @@ try_zram_decompress(ulonglong pte_val, unsigned char *buf, ulong len, ulonglong
|
||||
readmem(zram, KVADDR, &zram_table_entry,
|
||||
sizeof(void *), "zram_table_entry", FAULT_ON_ERROR);
|
||||
zram_table_entry += (index * SIZE(zram_table_entry));
|
||||
- readmem(zram_table_entry + OFFSET(zram_table_flag), KVADDR, &flags,
|
||||
- sizeof(void *), "zram_table_flag", FAULT_ON_ERROR);
|
||||
+ readmem(zram_table_entry + OFFSET(zram_table_entry_flags), KVADDR, &flags,
|
||||
+ sizeof(void *), "zram_table_entry.flags", FAULT_ON_ERROR);
|
||||
if (VALID_MEMBER(zram_compressor))
|
||||
readmem(zram + OFFSET(zram_compressor), KVADDR, name, sizeof(name),
|
||||
"zram compressor", FAULT_ON_ERROR);
|
||||
@@ -3072,8 +3072,8 @@ try_zram_decompress(ulonglong pte_val, unsigned char *buf, ulong len, ulonglong
|
||||
goto out;
|
||||
}
|
||||
|
||||
- readmem(zram + OFFSET(zram_mempoll), KVADDR, &zram,
|
||||
- sizeof(void *), "zram_mempoll", FAULT_ON_ERROR);
|
||||
+ readmem(zram + OFFSET(zram_mem_pool), KVADDR, &zram,
|
||||
+ sizeof(void *), "zram.mem_pool", FAULT_ON_ERROR);
|
||||
|
||||
obj_addr = zram_object_addr(zram, entry, zram_buf);
|
||||
if (obj_addr == NULL) {
|
||||
diff --git a/memory.c b/memory.c
|
||||
index 86ccec5e2bac..791194a405d4 100644
|
||||
--- a/memory.c
|
||||
+++ b/memory.c
|
||||
@@ -519,7 +519,7 @@ vm_init(void)
|
||||
"swap_info_struct", "old_block_size");
|
||||
MEMBER_OFFSET_INIT(swap_info_struct_bdev, "swap_info_struct", "bdev");
|
||||
|
||||
- MEMBER_OFFSET_INIT(zspoll_size_class, "zs_pool", "size_class");
|
||||
+ MEMBER_OFFSET_INIT(zs_pool_size_class, "zs_pool", "size_class");
|
||||
MEMBER_OFFSET_INIT(size_class_size, "size_class", "size");
|
||||
|
||||
MEMBER_OFFSET_INIT(block_device_bd_inode, "block_device", "bd_inode");
|
||||
diff --git a/symbols.c b/symbols.c
|
||||
index 8e8b4c31d915..176c95026f03 100644
|
||||
--- a/symbols.c
|
||||
+++ b/symbols.c
|
||||
@@ -10304,6 +10304,7 @@ dump_offset_table(char *spec, ulong makestruct)
|
||||
OFFSET(page_active));
|
||||
fprintf(fp, " page_compound_head: %ld\n",
|
||||
OFFSET(page_compound_head));
|
||||
+ fprintf(fp, " page_private: %ld\n", OFFSET(page_private));
|
||||
|
||||
fprintf(fp, " trace_print_flags_mask: %ld\n",
|
||||
OFFSET(trace_print_flags_mask));
|
||||
@@ -10330,6 +10331,7 @@ dump_offset_table(char *spec, ulong makestruct)
|
||||
OFFSET(swap_info_struct_inuse_pages));
|
||||
fprintf(fp, "swap_info_struct_old_block_size: %ld\n",
|
||||
OFFSET(swap_info_struct_old_block_size));
|
||||
+ fprintf(fp, " swap_info_struct_bdev: %ld\n", OFFSET(swap_info_struct_bdev));
|
||||
fprintf(fp, " block_device_bd_inode: %ld\n",
|
||||
OFFSET(block_device_bd_inode));
|
||||
fprintf(fp, " block_device_bd_list: %ld\n",
|
||||
@@ -11359,6 +11361,8 @@ dump_offset_table(char *spec, ulong makestruct)
|
||||
OFFSET(gendisk_part0));
|
||||
fprintf(fp, " gendisk_queue: %ld\n",
|
||||
OFFSET(gendisk_queue));
|
||||
+ fprintf(fp, " gendisk_private_data: %ld\n", OFFSET(gendisk_private_data));
|
||||
+
|
||||
fprintf(fp, " hd_struct_dev: %ld\n",
|
||||
OFFSET(hd_struct_dev));
|
||||
fprintf(fp, " hd_struct_dkstats: %ld\n",
|
||||
@@ -11765,6 +11769,14 @@ dump_offset_table(char *spec, ulong makestruct)
|
||||
fprintf(fp, " maple_metadata_end: %ld\n", OFFSET(maple_metadata_end));
|
||||
fprintf(fp, " maple_metadata_gap: %ld\n", OFFSET(maple_metadata_gap));
|
||||
|
||||
+ fprintf(fp, " zram_mem_pool: %ld\n", OFFSET(zram_mem_pool));
|
||||
+ fprintf(fp, " zram_compressor: %ld\n", OFFSET(zram_compressor));
|
||||
+ fprintf(fp, " zram_comp_algs: %ld\n", OFFSET(zram_comp_algs));
|
||||
+ fprintf(fp, " zram_table_entry_flags: %ld\n", OFFSET(zram_table_entry_flags));
|
||||
+ fprintf(fp, " zs_pool_size_class: %ld\n", OFFSET(zs_pool_size_class));
|
||||
+ fprintf(fp, " size_class_size: %ld\n", OFFSET(size_class_size));
|
||||
+ fprintf(fp, " zspage_huge: %ld\n", OFFSET(zspage_huge));
|
||||
+
|
||||
fprintf(fp, "\n size_table:\n");
|
||||
fprintf(fp, " page: %ld\n", SIZE(page));
|
||||
fprintf(fp, " page_flags: %ld\n", SIZE(page_flags));
|
||||
--
|
||||
2.41.0
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
From 582febffa8b3567339148c2bb916fc70f2fc546e Mon Sep 17 00:00:00 2001
|
||||
From: Johan Erlandsson <johan.erlandsson@sony.com>
|
||||
Date: Fri, 20 Oct 2023 19:10:52 +0200
|
||||
Subject: [PATCH 03/14] zram: Fixes for lookup_swap_cache()
|
||||
|
||||
Fix the following three issues:
|
||||
(1) swap cache missing page tree offset
|
||||
The radix or xarray start at an offset inside struct address_space.
|
||||
(2) swap cache entries are pointer to struct page
|
||||
The entries in radix, xarray (swap cache) are address to struct page.
|
||||
(3) exclude shadow entries from swap cache lookup
|
||||
radix or xarray can contain shadow entries from previous page
|
||||
entries. These should be ignored when looking for a page pointer.
|
||||
|
||||
Without the patch,
|
||||
- lookup_swap_cache() returns NULL since do_xarray() call returns FALSE,
|
||||
- in try_zram_decompress(), since 'entry' is NULL, page is filled with 0,
|
||||
if (!entry || (flags & ZRAM_FLAG_SAME_BIT)) {
|
||||
and pages in swap cache will be seen to be a 'zero' page.
|
||||
|
||||
Signed-off-by: Johan Erlandsson <johan.erlandsson@sony.com>
|
||||
Signed-off-by: Kazuhito Hagio <k-hagio-ab@nec.com>
|
||||
Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
|
||||
---
|
||||
diskdump.c | 19 ++++++++++++++-----
|
||||
1 file changed, 14 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/diskdump.c b/diskdump.c
|
||||
index f20f3ac519a1..660c25729dad 100644
|
||||
--- a/diskdump.c
|
||||
+++ b/diskdump.c
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "diskdump.h"
|
||||
#include "xen_dom0.h"
|
||||
#include "vmcore.h"
|
||||
+#include "maple_tree.h"
|
||||
|
||||
#define BITMAP_SECT_LEN 4096
|
||||
|
||||
@@ -2877,11 +2878,16 @@ out:
|
||||
return zram_buf;
|
||||
}
|
||||
|
||||
+static inline bool radix_tree_exceptional_entry(ulong entry)
|
||||
+{
|
||||
+ return entry & RADIX_TREE_EXCEPTIONAL_ENTRY;
|
||||
+}
|
||||
+
|
||||
static unsigned char *
|
||||
lookup_swap_cache(ulonglong pte_val, unsigned char *zram_buf)
|
||||
{
|
||||
ulonglong swp_offset;
|
||||
- ulong swp_type, swp_space, page;
|
||||
+ ulong swp_type, swp_space;
|
||||
struct list_pair lp;
|
||||
physaddr_t paddr;
|
||||
static int is_xarray = -1;
|
||||
@@ -2907,10 +2913,13 @@ lookup_swap_cache(ulonglong pte_val, unsigned char *zram_buf)
|
||||
swp_space += (swp_offset >> SWAP_ADDRESS_SPACE_SHIFT) * SIZE(address_space);
|
||||
|
||||
lp.index = swp_offset;
|
||||
- if ((is_xarray ? do_xarray : do_radix_tree)(swp_space, RADIX_TREE_SEARCH, &lp)) {
|
||||
- readmem((ulong)lp.value, KVADDR, &page, sizeof(void *),
|
||||
- "swap_cache page", FAULT_ON_ERROR);
|
||||
- if (!is_page_ptr(page, &paddr)) {
|
||||
+ if ((is_xarray ? do_xarray : do_radix_tree)
|
||||
+ (swp_space+OFFSET(address_space_page_tree), RADIX_TREE_SEARCH, &lp)) {
|
||||
+ if ((is_xarray ? xa_is_value : radix_tree_exceptional_entry)((ulong)lp.value)) {
|
||||
+ /* ignore shadow values */
|
||||
+ return NULL;
|
||||
+ }
|
||||
+ if (!is_page_ptr((ulong)lp.value, &paddr)) {
|
||||
error(WARNING, "radix page: %lx: not a page pointer\n", lp.value);
|
||||
return NULL;
|
||||
}
|
||||
--
|
||||
2.41.0
|
||||
|
|
@ -0,0 +1,171 @@
|
|||
From f2ee6fa6c841ddc37ba665909dafbc7294c34d64 Mon Sep 17 00:00:00 2001
|
||||
From: Tao Liu <ltao@redhat.com>
|
||||
Date: Fri, 17 Nov 2023 15:52:19 +0800
|
||||
Subject: [PATCH 04/14] symbols: expand all kernel module symtable if not all
|
||||
expanded previously
|
||||
|
||||
There is an issue that, for kernel modules, "dis -rl" fails to display
|
||||
modules code line number data after execute "bt" command in crash.
|
||||
|
||||
Without the patch:
|
||||
crsah> mod -S
|
||||
crash> bt
|
||||
PID: 1500 TASK: ff2bd8b093524000 CPU: 16 COMMAND: "lpfc_worker_0"
|
||||
#0 [ff2c9f725c39f9e0] machine_kexec at ffffffff8e0686d3
|
||||
...snip...
|
||||
#8 [ff2c9f725c39fcc0] __lpfc_sli_release_iocbq_s4 at ffffffffc0f2f425 [lpfc]
|
||||
...snip...
|
||||
crash> dis -rl ffffffffc0f60f82
|
||||
0xffffffffc0f60eb0 <lpfc_nlp_get>: nopl 0x0(%rax,%rax,1) [FTRACE NOP]
|
||||
0xffffffffc0f60eb5 <lpfc_nlp_get+5>: push %rbp
|
||||
0xffffffffc0f60eb6 <lpfc_nlp_get+6>: push %rbx
|
||||
0xffffffffc0f60eb7 <lpfc_nlp_get+7>: test %rdi,%rdi
|
||||
|
||||
With the patch:
|
||||
crash> mod -S
|
||||
crash> bt
|
||||
PID: 1500 TASK: ff2bd8b093524000 CPU: 16 COMMAND: "lpfc_worker_0"
|
||||
#0 [ff2c9f725c39f9e0] machine_kexec at ffffffff8e0686d3
|
||||
...snip...
|
||||
#8 [ff2c9f725c39fcc0] __lpfc_sli_release_iocbq_s4 at ffffffffc0f2f425 [lpfc]
|
||||
...snip...
|
||||
crash> dis -rl ffffffffc0f60f82
|
||||
/usr/src/debug/kernel-4.18.0-425.13.1.el8_7/linux-4.18.0-425.13.1.el8_7.x86_64/drivers/scsi/lpfc/lpfc_hbadisc.c: 6756
|
||||
0xffffffffc0f60eb0 <lpfc_nlp_get>: nopl 0x0(%rax,%rax,1) [FTRACE NOP]
|
||||
/usr/src/debug/kernel-4.18.0-425.13.1.el8_7/linux-4.18.0-425.13.1.el8_7.x86_64/drivers/scsi/lpfc/lpfc_hbadisc.c: 6759
|
||||
0xffffffffc0f60eb5 <lpfc_nlp_get+5>: push %rbp
|
||||
|
||||
The root cause is, after kernel module been loaded by mod command, the symtable
|
||||
is not expanded in gdb side. crash bt or dis command will trigger such an
|
||||
expansion. However the symtable expansion is different for the 2 commands:
|
||||
|
||||
The stack trace of "dis -rl" for symtable expanding:
|
||||
|
||||
#0 0x00000000008d8d9f in add_compunit_symtab_to_objfile ...
|
||||
#1 0x00000000006d3293 in buildsym_compunit::end_symtab_with_blockvector ...
|
||||
#2 0x00000000006d336a in buildsym_compunit::end_symtab_from_static_block ...
|
||||
#3 0x000000000077e8e9 in process_full_comp_unit ...
|
||||
#4 process_queue ...
|
||||
#5 dw2_do_instantiate_symtab ...
|
||||
#6 0x000000000077ed67 in dw2_instantiate_symtab ...
|
||||
#7 0x000000000077f75e in dw2_expand_all_symtabs ...
|
||||
#8 0x00000000008f254d in gdb_get_line_number ...
|
||||
#9 0x00000000008f22af in gdb_command_funnel_1 ...
|
||||
#10 0x00000000008f2003 in gdb_command_funnel ...
|
||||
#11 0x00000000005b7f02 in gdb_interface ...
|
||||
#12 0x00000000005f5bd8 in get_line_number ...
|
||||
#13 0x000000000059e574 in cmd_dis ...
|
||||
|
||||
The stack trace of "bt" for symtable expanding:
|
||||
|
||||
#0 0x00000000008d8d9f in add_compunit_symtab_to_objfile ...
|
||||
#1 0x00000000006d3293 in buildsym_compunit::end_symtab_with_blockvector ...
|
||||
#2 0x00000000006d336a in buildsym_compunit::end_symtab_from_static_block ...
|
||||
#3 0x000000000077e8e9 in process_full_comp_unit ...
|
||||
#4 process_queue ...
|
||||
#5 dw2_do_instantiate_symtab ...
|
||||
#6 0x000000000077ed67 in dw2_instantiate_symtab ...
|
||||
#7 0x000000000077f8ed in dw2_lookup_symbol ...
|
||||
#8 0x00000000008e6d03 in lookup_symbol_via_quick_fns ...
|
||||
#9 0x00000000008e7153 in lookup_symbol_in_objfile ...
|
||||
#10 0x00000000008e73c6 in lookup_symbol_global_or_static_iterator_cb ...
|
||||
#11 0x00000000008b99c4 in svr4_iterate_over_objfiles_in_search_order ...
|
||||
#12 0x00000000008e754e in lookup_global_or_static_symbol ...
|
||||
#13 0x00000000008e75da in lookup_static_symbol ...
|
||||
#14 0x00000000008e632c in lookup_symbol_aux ...
|
||||
#15 0x00000000008e5a7a in lookup_symbol_in_language ...
|
||||
#16 0x00000000008e5b30 in lookup_symbol ...
|
||||
#17 0x00000000008f2a4a in gdb_get_datatype ...
|
||||
#18 0x00000000008f22c0 in gdb_command_funnel_1 ...
|
||||
#19 0x00000000008f2003 in gdb_command_funnel ...
|
||||
#20 0x00000000005b7f02 in gdb_interface ...
|
||||
#21 0x00000000005f8a9f in datatype_info ...
|
||||
#22 0x0000000000599947 in cpu_map_size ...
|
||||
#23 0x00000000005a975d in get_cpus_online ...
|
||||
#24 0x0000000000637a8b in diskdump_get_prstatus_percpu ...
|
||||
#25 0x000000000062f0e4 in get_netdump_regs_x86_64 ...
|
||||
#26 0x000000000059fe68 in back_trace ...
|
||||
#27 0x00000000005ab1cb in cmd_bt ...
|
||||
|
||||
For the stacktrace of "dis -rl", it calls dw2_expand_all_symtabs() to expand
|
||||
all symtable of the objfile, or "*.ko.debug" in our case. However for
|
||||
the stacktrace of "bt", it doesn't expand all, but only a subset of symtable
|
||||
which is enough to find a symbol by dw2_lookup_symbol(). As a result, the
|
||||
objfile->compunit_symtabs, which is the head of a single linked list of
|
||||
struct compunit_symtab, is not NULL but didn't contain all symtables. It
|
||||
will not be reinitialized in gdb_get_line_number() by "dis -rl" because
|
||||
!objfile_has_full_symbols(objfile) check will fail, so it cannot display
|
||||
the proper code line number data.
|
||||
|
||||
Since objfile_has_full_symbols(objfile) check cannot ensure all symbols
|
||||
been expanded, this patch add a new member as a flag for struct objfile
|
||||
to record if all symbols have been expanded. The flag will be set only ofter
|
||||
expand_all_symtabs been called.
|
||||
|
||||
Signed-off-by: Tao Liu <ltao@redhat.com>
|
||||
Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
|
||||
---
|
||||
gdb-10.2.patch | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
1 file changed, 50 insertions(+)
|
||||
|
||||
diff --git a/gdb-10.2.patch b/gdb-10.2.patch
|
||||
index d81030d946e8..2f7d585105aa 100644
|
||||
--- a/gdb-10.2.patch
|
||||
+++ b/gdb-10.2.patch
|
||||
@@ -3187,3 +3187,53 @@ exit 0
|
||||
result = stringtab + symbol_entry->_n._n_n._n_offset;
|
||||
}
|
||||
else
|
||||
+--- gdb-10.2/gdb/objfiles.h.orig
|
||||
++++ gdb-10.2/gdb/objfiles.h
|
||||
+@@ -712,6 +712,8 @@ struct objfile
|
||||
+ next time. If an objfile does not have the symbols, it will
|
||||
+ never have them. */
|
||||
+ bool skip_jit_symbol_lookup = false;
|
||||
++
|
||||
++ bool all_symtabs_expanded = false;
|
||||
+ };
|
||||
+
|
||||
+ /* A deleter for objfile. */
|
||||
+--- gdb-10.2/gdb/symfile.c.orig
|
||||
++++ gdb-10.2/gdb/symfile.c
|
||||
+@@ -1133,8 +1133,10 @@ symbol_file_add_with_addrs (bfd *abfd, const char *name,
|
||||
+ printf_filtered (_("Expanding full symbols from %ps...\n"),
|
||||
+ styled_string (file_name_style.style (), name));
|
||||
+
|
||||
+- if (objfile->sf)
|
||||
++ if (objfile->sf) {
|
||||
+ objfile->sf->qf->expand_all_symtabs (objfile);
|
||||
++ objfile->all_symtabs_expanded = true;
|
||||
++ }
|
||||
+ }
|
||||
+
|
||||
+ /* Note that we only print a message if we have no symbols and have
|
||||
+--- gdb-10.2/gdb/symtab.c.orig
|
||||
++++ gdb-10.2/gdb/symtab.c
|
||||
+@@ -7097,8 +7097,9 @@ gdb_get_line_number(struct gnu_request *req)
|
||||
+ */
|
||||
+ if (req->lm) {
|
||||
+ objfile = req->lm->loaded_objfile;
|
||||
+- if (!objfile_has_full_symbols(objfile) && objfile->sf) {
|
||||
++ if (!objfile->all_symtabs_expanded && objfile->sf) {
|
||||
+ objfile->sf->qf->expand_all_symtabs(objfile);
|
||||
++ objfile->all_symtabs_expanded = true;
|
||||
+ sal = find_pc_line(pc, 0);
|
||||
+ }
|
||||
+ }
|
||||
+@@ -7761,8 +7765,10 @@ iterate_datatypes (struct gnu_request *req)
|
||||
+ {
|
||||
+ for (objfile *objfile : current_program_space->objfiles ())
|
||||
+ {
|
||||
+- if (objfile->sf)
|
||||
++ if (objfile->sf) {
|
||||
+ objfile->sf->qf->expand_all_symtabs(objfile);
|
||||
++ objfile->all_symtabs_expanded = true;
|
||||
++ }
|
||||
+
|
||||
+ for (compunit_symtab *cust : objfile->compunits ())
|
||||
+ {
|
||||
--
|
||||
2.41.0
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
From 0c5ef6a4a3a2759915ffe72b1366dce2f32f65c5 Mon Sep 17 00:00:00 2001
|
||||
From: Tao Liu <ltao@redhat.com>
|
||||
Date: Tue, 14 Nov 2023 16:32:07 +0800
|
||||
Subject: [PATCH 05/14] symbols: skip load .init.* sections if module was
|
||||
successfully initialized
|
||||
|
||||
There might be address overlap of one modules .init.text symbols and
|
||||
another modules .text symbols. As a result, gdb fails to translate the
|
||||
address to symbol name correctly:
|
||||
|
||||
crash> sym -m virtio_blk | grep MODULE
|
||||
ffffffffc00a4000 MODULE START: virtio_blk
|
||||
ffffffffc00a86ec MODULE END: virtio_blk
|
||||
crash> gdb info address floppy_module_init
|
||||
Symbol "floppy_module_init" is a function at address 0xffffffffc00a4131.
|
||||
|
||||
Since the .init.* sections of a module had been freed by kernel if the
|
||||
module was initialized successfully, there is no need to load the .init.*
|
||||
sections data from "*.ko.debug" in gdb to create such an overlap.
|
||||
lm->mod_init_module_ptr is used as a flag of whether module is freed.
|
||||
|
||||
Without the patch:
|
||||
crash> mod -S
|
||||
crash> struct blk_mq_ops 0xffffffffc00a7160
|
||||
struct blk_mq_ops {
|
||||
queue_rq = 0xffffffffc00a45b0 <floppy_module_init+1151>, <-- translated from module floppy
|
||||
map_queue = 0xffffffff813015c0 <blk_mq_map_queue>,
|
||||
...snip...
|
||||
complete = 0xffffffffc00a4370 <floppy_module_init+575>,
|
||||
init_request = 0xffffffffc00a4260 <floppy_module_init+303>,
|
||||
...snip...
|
||||
}
|
||||
|
||||
With the patch:
|
||||
crash> mod -S
|
||||
crash> struct blk_mq_ops 0xffffffffc00a7160
|
||||
struct blk_mq_ops {
|
||||
queue_rq = 0xffffffffc00a45b0 <virtio_queue_rq>, <-- translated from module virtio_blk
|
||||
map_queue = 0xffffffff813015c0 <blk_mq_map_queue>,
|
||||
...snip...
|
||||
complete = 0xffffffffc00a4370 <virtblk_request_done>,
|
||||
init_request = 0xffffffffc00a4260 <virtblk_init_request>,
|
||||
...snip...
|
||||
}
|
||||
|
||||
Signed-off-by: Tao Liu <ltao@redhat.com>
|
||||
Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
|
||||
---
|
||||
symbols.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/symbols.c b/symbols.c
|
||||
index 176c95026f03..5d919910164e 100644
|
||||
--- a/symbols.c
|
||||
+++ b/symbols.c
|
||||
@@ -13295,7 +13295,7 @@ add_symbol_file_kallsyms(struct load_module *lm, struct gnu_request *req)
|
||||
shift_string_right(req->buf, strlen(buf));
|
||||
BCOPY(buf, req->buf, strlen(buf));
|
||||
retval = TRUE;
|
||||
- } else {
|
||||
+ } else if (lm->mod_init_module_ptr || !STRNEQ(section_name, ".init.")) {
|
||||
sprintf(buf, " -s %s 0x%lx", section_name, section_vaddr);
|
||||
while ((len + strlen(buf)) >= buflen) {
|
||||
RESIZEBUF(req->buf, buflen, buflen * 2);
|
||||
--
|
||||
2.41.0
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
From c15da07526291a5c357010cb4aaf4bde6151e642 Mon Sep 17 00:00:00 2001
|
||||
From: Johan Erlandsson <johan.erlandsson@sony.com>
|
||||
Date: Wed, 19 Apr 2023 11:26:04 +0200
|
||||
Subject: [PATCH 06/14] use NR_SWAPCACHE when nr_swapper_spaces isn't available
|
||||
|
||||
In 5.12 the following change was introduced:
|
||||
b6038942480e ("mm: memcg: add swapcache stat for memcg v2")
|
||||
|
||||
Then the variable 'nr_swapper_spaces' is not read (unless
|
||||
CONFIG_DEBUG_VM=y). In GKI builds this variable is then optimized
|
||||
out. But the same change provided a new way to obtain the same
|
||||
information, using NR_SWAPCACHE.
|
||||
|
||||
Reported-by: xueguolun <xueguolun@xiaomi.com>
|
||||
Signed-off-by: Johan Erlandsson <johan.erlandsson@sony.com>
|
||||
Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
|
||||
---
|
||||
memory.c | 6 ++++--
|
||||
1 file changed, 4 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/memory.c b/memory.c
|
||||
index 791194a405d4..b84e974a3325 100644
|
||||
--- a/memory.c
|
||||
+++ b/memory.c
|
||||
@@ -8486,7 +8486,7 @@ dump_kmeminfo(void)
|
||||
ulong hugetlb_total_pages, hugetlb_total_free_pages = 0;
|
||||
int done_hugetlb_calc = 0;
|
||||
long nr_file_pages, nr_slab;
|
||||
- ulong swapper_space_nrpages;
|
||||
+ long swapper_space_nrpages;
|
||||
ulong pct;
|
||||
uint tmp;
|
||||
struct meminfo meminfo;
|
||||
@@ -8609,7 +8609,9 @@ dump_kmeminfo(void)
|
||||
char *swapper_space = GETBUF(SIZE(address_space));
|
||||
|
||||
swapper_space_nrpages = 0;
|
||||
- if (symbol_exists("nr_swapper_spaces") &&
|
||||
+ if (dump_vm_stat("NR_SWAPCACHE", &swapper_space_nrpages, 0)) {
|
||||
+ ;
|
||||
+ } else if (symbol_exists("nr_swapper_spaces") &&
|
||||
(len = get_array_length("nr_swapper_spaces",
|
||||
NULL, 0))) {
|
||||
char *nr_swapper_space =
|
||||
--
|
||||
2.41.0
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
From 2e513114e7d77fadc88011f186ef943ccf397d35 Mon Sep 17 00:00:00 2001
|
||||
From: Alexander Gordeev <agordeev@linux.ibm.com>
|
||||
Date: Wed, 29 Nov 2023 13:47:34 +0100
|
||||
Subject: [PATCH 07/14] Fix identity_map_base value dump on S390
|
||||
|
||||
Kernel virtual base instead of identity base is printed
|
||||
|
||||
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
|
||||
Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
|
||||
---
|
||||
s390.c | 2 +-
|
||||
s390x.c | 2 +-
|
||||
2 files changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/s390.c b/s390.c
|
||||
index 42f5cc63ae52..a8b2bcca86c7 100644
|
||||
--- a/s390.c
|
||||
+++ b/s390.c
|
||||
@@ -183,7 +183,7 @@ s390_dump_machdep_table(ulong arg)
|
||||
fprintf(fp, ")\n");
|
||||
|
||||
fprintf(fp, " kvbase: %lx\n", machdep->kvbase);
|
||||
- fprintf(fp, " identity_map_base: %lx\n", machdep->kvbase);
|
||||
+ fprintf(fp, " identity_map_base: %lx\n", machdep->identity_map_base);
|
||||
fprintf(fp, " pagesize: %d\n", machdep->pagesize);
|
||||
fprintf(fp, " pageshift: %d\n", machdep->pageshift);
|
||||
fprintf(fp, " pagemask: %llx\n", machdep->pagemask);
|
||||
diff --git a/s390x.c b/s390x.c
|
||||
index d7ee3755fc0b..096c072186f5 100644
|
||||
--- a/s390x.c
|
||||
+++ b/s390x.c
|
||||
@@ -650,7 +650,7 @@ s390x_dump_machdep_table(ulong arg)
|
||||
fprintf(fp, ")\n");
|
||||
|
||||
fprintf(fp, " kvbase: %lx\n", machdep->kvbase);
|
||||
- fprintf(fp, " identity_map_base: %lx\n", machdep->kvbase);
|
||||
+ fprintf(fp, " identity_map_base: %lx\n", machdep->identity_map_base);
|
||||
fprintf(fp, " pagesize: %d\n", machdep->pagesize);
|
||||
fprintf(fp, " pageshift: %d\n", machdep->pageshift);
|
||||
fprintf(fp, " pagemask: %llx\n", machdep->pagemask);
|
||||
--
|
||||
2.41.0
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
From 4c78eb4a9199631fe94845cb3fbd6376aae1251d Mon Sep 17 00:00:00 2001
|
||||
From: Alexander Gordeev <agordeev@linux.ibm.com>
|
||||
Date: Wed, 29 Nov 2023 13:47:35 +0100
|
||||
Subject: [PATCH 08/14] s390x: fix virtual vs physical address confusion
|
||||
|
||||
Physical and virtual addresses are the same on S390X.
|
||||
That led to missing to use PTOV and VTOP macros where
|
||||
they actually expected.
|
||||
|
||||
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
|
||||
Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
|
||||
---
|
||||
s390x.c | 12 ++++++------
|
||||
1 file changed, 6 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/s390x.c b/s390x.c
|
||||
index 096c072186f5..957b839a5fa9 100644
|
||||
--- a/s390x.c
|
||||
+++ b/s390x.c
|
||||
@@ -311,7 +311,7 @@ static struct s390x_cpu *s390x_cpu_get(struct bt_info *bt)
|
||||
readmem(lowcore_ptr + cpu * sizeof(long), KVADDR,
|
||||
&prefix, sizeof(long), "lowcore_ptr", FAULT_ON_ERROR);
|
||||
for (i = 0; i < s390x_cpu_cnt; i++) {
|
||||
- if (s390x_cpu_vec[i].prefix == prefix)
|
||||
+ if (s390x_cpu_vec[i].prefix == VTOP(prefix))
|
||||
return &s390x_cpu_vec[i];
|
||||
}
|
||||
error(FATAL, "cannot determine CPU for task: %lx\n", bt->task);
|
||||
@@ -985,12 +985,12 @@ int s390x_vtop(ulong table, ulong vaddr, physaddr_t *phys_addr, int verbose)
|
||||
verbose);
|
||||
if (!entry)
|
||||
return FALSE;
|
||||
- table = entry & ~0xfffULL;
|
||||
+ table = PTOV(entry & ~0xfffULL);
|
||||
/* Check if this a 2GB page */
|
||||
if ((entry & 0x400ULL) && (level == 1)) {
|
||||
/* Add the 2GB frame offset & return the final value. */
|
||||
table &= ~0x7fffffffULL;
|
||||
- *phys_addr = table + (vaddr & 0x7fffffffULL);
|
||||
+ *phys_addr = VTOP(table + (vaddr & 0x7fffffffULL));
|
||||
return TRUE;
|
||||
}
|
||||
len = entry & 0x3ULL;
|
||||
@@ -1001,12 +1001,12 @@ int s390x_vtop(ulong table, ulong vaddr, physaddr_t *phys_addr, int verbose)
|
||||
if (entry & 0x400ULL) {
|
||||
/* Add the 1MB page offset and return the final value. */
|
||||
table &= ~0xfffffULL;
|
||||
- *phys_addr = table + (vaddr & 0xfffffULL);
|
||||
+ *phys_addr = VTOP(table + (vaddr & 0xfffffULL));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Get the page table entry */
|
||||
- entry = _kl_pg_table_deref_s390x(vaddr, entry & ~0x7ffULL, verbose);
|
||||
+ entry = _kl_pg_table_deref_s390x(vaddr, PTOV(entry & ~0x7ffULL), verbose);
|
||||
if (!entry)
|
||||
return FALSE;
|
||||
|
||||
@@ -1033,7 +1033,7 @@ s390x_vmalloc_start(void)
|
||||
{
|
||||
unsigned long highmem_addr,high_memory;
|
||||
highmem_addr=symbol_value("high_memory");
|
||||
- readmem(highmem_addr, PHYSADDR, &high_memory,sizeof(long),
|
||||
+ readmem(highmem_addr, KVADDR, &high_memory,sizeof(long),
|
||||
"highmem",FAULT_ON_ERROR);
|
||||
return high_memory;
|
||||
}
|
||||
--
|
||||
2.41.0
|
||||
|
|
@ -0,0 +1,323 @@
|
|||
From d0164e7e480ad2ffd3fe73fe53c46087e5e137a6 Mon Sep 17 00:00:00 2001
|
||||
From: Alexander Gordeev <agordeev@linux.ibm.com>
|
||||
Date: Thu, 7 Dec 2023 16:54:06 +0100
|
||||
Subject: [PATCH 09/14] s390x: uncouple physical and virtual memory spaces
|
||||
|
||||
Rework VTOP and PTOV macros to reflect the future
|
||||
uncoupling of physical and virtual address spaces
|
||||
in kernel. Existing versions are not affected.
|
||||
|
||||
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
|
||||
Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
|
||||
---
|
||||
defs.h | 20 +++++-
|
||||
s390x.c | 212 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
|
||||
2 files changed, 228 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/defs.h b/defs.h
|
||||
index 5218a94fe4a4..20237b72a10b 100644
|
||||
--- a/defs.h
|
||||
+++ b/defs.h
|
||||
@@ -4564,9 +4564,9 @@ struct efi_memory_desc_t {
|
||||
#define _64BIT_
|
||||
#define MACHINE_TYPE "S390X"
|
||||
|
||||
-#define PTOV(X) ((unsigned long)(X)+(machdep->kvbase))
|
||||
-#define VTOP(X) ((unsigned long)(X)-(machdep->kvbase))
|
||||
-#define IS_VMALLOC_ADDR(X) (vt->vmalloc_start && (ulong)(X) >= vt->vmalloc_start)
|
||||
+#define PTOV(X) s390x_PTOV((ulong)(X))
|
||||
+#define VTOP(X) s390x_VTOP((ulong)(X))
|
||||
+#define IS_VMALLOC_ADDR(X) s390x_IS_VMALLOC_ADDR(X)
|
||||
#define PTRS_PER_PTE 512
|
||||
#define PTRS_PER_PMD 1024
|
||||
#define PTRS_PER_PGD 2048
|
||||
@@ -6827,7 +6827,21 @@ void get_s390_panicmsg(char *);
|
||||
* s390x.c
|
||||
*/
|
||||
#ifdef S390X
|
||||
+
|
||||
+struct machine_specific
|
||||
+{
|
||||
+ ulong (*virt_to_phys)(ulong vaddr);
|
||||
+ ulong (*phys_to_virt)(ulong paddr);
|
||||
+ int (*is_vmalloc_addr)(ulong vaddr);
|
||||
+ ulong __kaslr_offset_phys;
|
||||
+ ulong amode31_start;
|
||||
+ ulong amode31_end;
|
||||
+};
|
||||
+
|
||||
void s390x_init(int);
|
||||
+ulong s390x_PTOV(ulong);
|
||||
+ulong s390x_VTOP(ulong);
|
||||
+int s390x_IS_VMALLOC_ADDR(ulong);
|
||||
void s390x_dump_machdep_table(ulong);
|
||||
#define display_idt_table() \
|
||||
error(FATAL, "-d option is not applicable to S390X architecture\n")
|
||||
diff --git a/s390x.c b/s390x.c
|
||||
index 957b839a5fa9..794ae825906d 100644
|
||||
--- a/s390x.c
|
||||
+++ b/s390x.c
|
||||
@@ -47,6 +47,7 @@
|
||||
#define S390X_PSW_MASK_PSTATE 0x0001000000000000UL
|
||||
|
||||
#define S390X_LC_VMCORE_INFO 0xe0c
|
||||
+#define S390X_LC_OS_INFO 0xe18
|
||||
|
||||
/*
|
||||
* Flags for Region and Segment table entries.
|
||||
@@ -168,6 +169,19 @@ static struct line_number_hook s390x_line_number_hooks[];
|
||||
static int s390x_is_uvaddr(ulong, struct task_context *);
|
||||
static int s390x_get_kvaddr_ranges(struct vaddr_range *);
|
||||
static int set_s390x_max_physmem_bits(void);
|
||||
+static ulong s390x_generic_VTOP(ulong vaddr);
|
||||
+static ulong s390x_generic_PTOV(ulong paddr);
|
||||
+static int s390x_generic_IS_VMALLOC_ADDR(ulong vaddr);
|
||||
+static ulong s390x_vr_VTOP(ulong vaddr);
|
||||
+static ulong s390x_vr_PTOV(ulong paddr);
|
||||
+static int s390x_vr_IS_VMALLOC_ADDR(ulong vaddr);
|
||||
+static int s390x_vr_is_kvaddr(ulong);
|
||||
+
|
||||
+struct machine_specific s390x_machine_specific = {
|
||||
+ .virt_to_phys = s390x_generic_VTOP,
|
||||
+ .phys_to_virt = s390x_generic_PTOV,
|
||||
+ .is_vmalloc_addr = s390x_generic_IS_VMALLOC_ADDR,
|
||||
+};
|
||||
|
||||
/*
|
||||
* struct lowcore name (old: "_lowcore", new: "lowcore")
|
||||
@@ -546,6 +560,191 @@ static void s390x_check_kaslr(void)
|
||||
free(vmcoreinfo);
|
||||
}
|
||||
|
||||
+#define OS_INFO_VERSION_MAJOR 1
|
||||
+#define OS_INFO_VERSION_MINOR 1
|
||||
+
|
||||
+#define OS_INFO_VMCOREINFO 0
|
||||
+#define OS_INFO_REIPL_BLOCK 1
|
||||
+#define OS_INFO_FLAGS_ENTRY 2
|
||||
+#define OS_INFO_RESERVED 3
|
||||
+#define OS_INFO_IDENTITY_BASE 4
|
||||
+#define OS_INFO_KASLR_OFFSET 5
|
||||
+#define OS_INFO_KASLR_OFF_PHYS 6
|
||||
+#define OS_INFO_VMEMMAP 7
|
||||
+#define OS_INFO_AMODE31_START 8
|
||||
+#define OS_INFO_AMODE31_END 9
|
||||
+
|
||||
+struct os_info_entry {
|
||||
+ union {
|
||||
+ __u64 addr;
|
||||
+ __u64 val;
|
||||
+ };
|
||||
+ __u64 size;
|
||||
+ __u32 csum;
|
||||
+} __attribute__((packed));
|
||||
+
|
||||
+struct os_info {
|
||||
+ __u64 magic;
|
||||
+ __u32 csum;
|
||||
+ __u16 version_major;
|
||||
+ __u16 version_minor;
|
||||
+ __u64 crashkernel_addr;
|
||||
+ __u64 crashkernel_size;
|
||||
+ struct os_info_entry entry[10];
|
||||
+ __u8 reserved[3864];
|
||||
+} __attribute__((packed));
|
||||
+
|
||||
+struct vm_info {
|
||||
+ __u64 __identity_base;
|
||||
+ __u64 __kaslr_offset;
|
||||
+ __u64 __kaslr_offset_phys;
|
||||
+ __u64 amode31_start;
|
||||
+ __u64 amode31_end;
|
||||
+};
|
||||
+
|
||||
+static bool
|
||||
+vmcoreinfo_read_u64(const char *key, __u64 *val)
|
||||
+{
|
||||
+ char *string;
|
||||
+
|
||||
+ string = pc->read_vmcoreinfo(key);
|
||||
+ if (string) {
|
||||
+ *val = strtoul(string, NULL, 16);
|
||||
+ free(string);
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ return false;
|
||||
+}
|
||||
+
|
||||
+static bool vmcoreinfo_read_vm_info(struct vm_info *_vm_info)
|
||||
+{
|
||||
+ struct vm_info vm_info;
|
||||
+
|
||||
+ if (!vmcoreinfo_read_u64("IDENTITYBASE", &vm_info.__identity_base) ||
|
||||
+ !vmcoreinfo_read_u64("KERNELOFFSET", &vm_info.__kaslr_offset) ||
|
||||
+ !vmcoreinfo_read_u64("KERNELOFFPHYS", &vm_info.__kaslr_offset_phys) ||
|
||||
+ !vmcoreinfo_read_u64("SAMODE31", &vm_info.amode31_start) ||
|
||||
+ !vmcoreinfo_read_u64("EAMODE31", &vm_info.amode31_end))
|
||||
+ return false;
|
||||
+
|
||||
+ *_vm_info = vm_info;
|
||||
+
|
||||
+ return true;
|
||||
+}
|
||||
+
|
||||
+static bool os_info_read_vm_info(struct vm_info *vm_info)
|
||||
+{
|
||||
+ struct os_info os_info;
|
||||
+ ulong addr;
|
||||
+
|
||||
+ if (!readmem(S390X_LC_OS_INFO, PHYSADDR, &addr,
|
||||
+ sizeof(addr), "s390x os_info ptr",
|
||||
+ QUIET|RETURN_ON_ERROR))
|
||||
+ return false;
|
||||
+
|
||||
+ if (addr == 0)
|
||||
+ return true;
|
||||
+
|
||||
+ if (!readmem(addr, PHYSADDR, &os_info,
|
||||
+ offsetof(struct os_info, reserved), "s390x os_info header",
|
||||
+ QUIET|RETURN_ON_ERROR))
|
||||
+ return false;
|
||||
+
|
||||
+ vm_info->__identity_base = os_info.entry[OS_INFO_IDENTITY_BASE].val;
|
||||
+ vm_info->__kaslr_offset = os_info.entry[OS_INFO_KASLR_OFFSET].val;
|
||||
+ vm_info->__kaslr_offset_phys = os_info.entry[OS_INFO_KASLR_OFF_PHYS].val;
|
||||
+ vm_info->amode31_start = os_info.entry[OS_INFO_AMODE31_START].val;
|
||||
+ vm_info->amode31_end = os_info.entry[OS_INFO_AMODE31_END].val;
|
||||
+
|
||||
+ return true;
|
||||
+}
|
||||
+
|
||||
+static bool vm_info_empty(struct vm_info *vm_info)
|
||||
+{
|
||||
+ return !vm_info->__kaslr_offset;
|
||||
+}
|
||||
+
|
||||
+static bool s390x_init_vm(void)
|
||||
+{
|
||||
+ struct vm_info vm_info;
|
||||
+
|
||||
+ if (pc->flags & PROC_KCORE) {
|
||||
+ if (!vmcoreinfo_read_vm_info(&vm_info))
|
||||
+ return true;
|
||||
+ } else {
|
||||
+ if (!os_info_read_vm_info(&vm_info))
|
||||
+ return false;
|
||||
+ }
|
||||
+ if (vm_info_empty(&vm_info))
|
||||
+ return true;
|
||||
+
|
||||
+ machdep->identity_map_base = vm_info.__identity_base;
|
||||
+ machdep->kvbase = vm_info.__kaslr_offset;
|
||||
+ machdep->machspec->__kaslr_offset_phys = vm_info.__kaslr_offset_phys;
|
||||
+ machdep->machspec->amode31_start = vm_info.amode31_start;
|
||||
+ machdep->machspec->amode31_end = vm_info.amode31_end;
|
||||
+
|
||||
+ machdep->is_kvaddr = s390x_vr_is_kvaddr;
|
||||
+ machdep->machspec->virt_to_phys = s390x_vr_VTOP;
|
||||
+ machdep->machspec->phys_to_virt = s390x_vr_PTOV;
|
||||
+ machdep->machspec->is_vmalloc_addr = s390x_vr_IS_VMALLOC_ADDR;
|
||||
+
|
||||
+ return true;
|
||||
+}
|
||||
+
|
||||
+static ulong s390x_generic_VTOP(ulong vaddr)
|
||||
+{
|
||||
+ return vaddr - machdep->kvbase;
|
||||
+}
|
||||
+
|
||||
+static ulong s390x_generic_PTOV(ulong paddr)
|
||||
+{
|
||||
+ return paddr + machdep->kvbase;
|
||||
+}
|
||||
+
|
||||
+static int s390x_generic_IS_VMALLOC_ADDR(ulong vaddr)
|
||||
+{
|
||||
+ return vt->vmalloc_start && vaddr >= vt->vmalloc_start;
|
||||
+}
|
||||
+
|
||||
+static ulong s390x_vr_VTOP(ulong vaddr)
|
||||
+{
|
||||
+ if (vaddr < LOWCORE_SIZE)
|
||||
+ return vaddr;
|
||||
+ if ((vaddr < machdep->machspec->amode31_end) &&
|
||||
+ (vaddr >= machdep->machspec->amode31_start))
|
||||
+ return vaddr;
|
||||
+ if (vaddr < machdep->kvbase)
|
||||
+ return vaddr - machdep->identity_map_base;
|
||||
+ return vaddr - machdep->kvbase + machdep->machspec->__kaslr_offset_phys;
|
||||
+}
|
||||
+
|
||||
+static ulong s390x_vr_PTOV(ulong paddr)
|
||||
+{
|
||||
+ return paddr + machdep->identity_map_base;
|
||||
+}
|
||||
+
|
||||
+static int s390x_vr_IS_VMALLOC_ADDR(ulong vaddr)
|
||||
+{
|
||||
+ return (vaddr >= vt->vmalloc_start && vaddr < machdep->kvbase);
|
||||
+}
|
||||
+
|
||||
+ulong s390x_VTOP(ulong vaddr)
|
||||
+{
|
||||
+ return machdep->machspec->virt_to_phys(vaddr);
|
||||
+}
|
||||
+
|
||||
+ulong s390x_PTOV(ulong paddr)
|
||||
+{
|
||||
+ return machdep->machspec->phys_to_virt(paddr);
|
||||
+}
|
||||
+
|
||||
+int s390x_IS_VMALLOC_ADDR(ulong vaddr)
|
||||
+{
|
||||
+ return machdep->machspec->is_vmalloc_addr(vaddr);
|
||||
+}
|
||||
+
|
||||
/*
|
||||
* Do all necessary machine-specific setup here. This is called several
|
||||
* times during initialization.
|
||||
@@ -560,6 +759,7 @@ s390x_init(int when)
|
||||
machdep->process_elf_notes = s390x_process_elf_notes;
|
||||
break;
|
||||
case PRE_SYMTAB:
|
||||
+ machdep->machspec = &s390x_machine_specific;
|
||||
machdep->verify_symbol = s390x_verify_symbol;
|
||||
if (pc->flags & KERNEL_DEBUG_QUERY)
|
||||
return;
|
||||
@@ -587,6 +787,8 @@ s390x_init(int when)
|
||||
machdep->kvbase = 0;
|
||||
machdep->identity_map_base = 0;
|
||||
machdep->is_kvaddr = generic_is_kvaddr;
|
||||
+ if (!s390x_init_vm())
|
||||
+ error(FATAL, "cannot initialize VM parameters.");
|
||||
machdep->is_uvaddr = s390x_is_uvaddr;
|
||||
machdep->eframe_search = s390x_eframe_search;
|
||||
machdep->back_trace = s390x_back_trace_cmd;
|
||||
@@ -681,7 +883,9 @@ s390x_dump_machdep_table(ulong arg)
|
||||
fprintf(fp, " dis_filter: s390x_dis_filter()\n");
|
||||
fprintf(fp, " cmd_mach: s390x_cmd_mach()\n");
|
||||
fprintf(fp, " get_smp_cpus: s390x_get_smp_cpus()\n");
|
||||
- fprintf(fp, " is_kvaddr: generic_is_kvaddr()\n");
|
||||
+ fprintf(fp, " is_kvaddr: %s()\n", machdep->is_kvaddr == s390x_vr_is_kvaddr ?
|
||||
+ "s390x_vr_is_kvaddr" :
|
||||
+ "generic_is_kvaddr");
|
||||
fprintf(fp, " is_uvaddr: s390x_is_uvaddr()\n");
|
||||
fprintf(fp, " verify_paddr: generic_verify_paddr()\n");
|
||||
fprintf(fp, " get_kvaddr_ranges: s390x_get_kvaddr_ranges()\n");
|
||||
@@ -702,6 +906,12 @@ s390x_dump_machdep_table(ulong arg)
|
||||
fprintf(fp, " machspec: %lx\n", (ulong)machdep->machspec);
|
||||
}
|
||||
|
||||
+static int
|
||||
+s390x_vr_is_kvaddr(ulong vaddr)
|
||||
+{
|
||||
+ return (vaddr < LOWCORE_SIZE) || (vaddr >= machdep->identity_map_base);
|
||||
+}
|
||||
+
|
||||
/*
|
||||
* Check if address is in context's address space
|
||||
*/
|
||||
--
|
||||
2.41.0
|
||||
|
|
@ -0,0 +1,160 @@
|
|||
From 5187a0320cc54a9cb8b326cf012e69795950a716 Mon Sep 17 00:00:00 2001
|
||||
From: Song Shuai <songshuaishuai@tinylab.org>
|
||||
Date: Tue, 12 Dec 2023 18:20:50 +0800
|
||||
Subject: [PATCH 10/14] RISCV64: Dump NT_PRSTATUS in 'help -n'
|
||||
|
||||
With the patch we can get full dump of "struct elf_prstatus" in 'help -n':
|
||||
```
|
||||
crash> help -n
|
||||
<snip>
|
||||
Elf64_Nhdr:
|
||||
n_namesz: 5 ("CORE")
|
||||
n_descsz: 376
|
||||
n_type: 1 (NT_PRSTATUS)
|
||||
si.signo: 0 si.code: 0 si.errno: 0
|
||||
cursig: 0 sigpend: 0 sighold: 0
|
||||
pid: 1 ppid: 0 pgrp: 0 sid:0
|
||||
utime: 0.000000 stime: 0.000000
|
||||
cutime: 0.000000 cstime: 0.000000
|
||||
epc: ffffffff8000a1dc ra: ffffffff800af958 sp: ff6000001fc501c0
|
||||
gp: ffffffff81515d38 tp: ff600000000d8000 t0: 6666666666663c5b
|
||||
t1: ff600000000d88c8 t2: 666666666666663c s0: ff6000001fc50320
|
||||
s1: ffffffff815170d8 a0: ff6000001fc501c8 a1: c0000000ffffefff
|
||||
a2: 0000000000000000 a3: 0000000000000001 a4: 0000000000000000
|
||||
a5: ff60000001782c00 a6: 000000000130e0f0 a7: 0000000000000000
|
||||
s2: ffffffff81517820 s3: ff6000001fc501c8 s4: 000000000000000f
|
||||
s5: 0000000000000000 s6: ff20000000013e60 s7: 0000000000000000
|
||||
s8: ff60000000861000 s9: 00007fffc3641694 s10: 00007fffc3641690
|
||||
s11: 00005555796ed240 t3: 0000000000010297 t4: ffffffff80c17810
|
||||
t5: ffffffff8195e7b8 t6: ff6000001fc50048
|
||||
0000000000000000 0000000000000000
|
||||
0000000000000000 0000000000000000
|
||||
0000000000000001 0000000000000000
|
||||
0000000000000000 0000000000000000
|
||||
0000000000000000 0000000000000000
|
||||
0000000000000000 0000000000000000
|
||||
0000000000000000 0000000000000000
|
||||
ffffffff8000a1dc ffffffff800af958
|
||||
ff6000001fc501c0 ffffffff81515d38
|
||||
ff600000000d8000 6666666666663c5b
|
||||
<snip>
|
||||
```
|
||||
|
||||
Signed-off-by: Song Shuai <songshuaishuai@tinylab.org>
|
||||
Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
|
||||
---
|
||||
netdump.c | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
1 file changed, 84 insertions(+)
|
||||
|
||||
diff --git a/netdump.c b/netdump.c
|
||||
index 390786364959..32586b6809d3 100644
|
||||
--- a/netdump.c
|
||||
+++ b/netdump.c
|
||||
@@ -2578,6 +2578,8 @@ dump_Elf64_Nhdr(Elf64_Off offset, int store)
|
||||
display_ELF_note(EM_PPC64, PRSTATUS_NOTE, note, nd->ofp);
|
||||
if (machine_type("ARM64") && (note->n_type == NT_PRSTATUS))
|
||||
display_ELF_note(EM_AARCH64, PRSTATUS_NOTE, note, nd->ofp);
|
||||
+ if (machine_type("RISCV64") && (note->n_type == NT_PRSTATUS))
|
||||
+ display_ELF_note(EM_RISCV, PRSTATUS_NOTE, note, nd->ofp);
|
||||
}
|
||||
for (i = lf = 0; i < note->n_descsz/sizeof(ulonglong); i++) {
|
||||
if (((i%2)==0)) {
|
||||
@@ -3399,6 +3401,80 @@ display_prstatus_arm64(void *note_ptr, FILE *ofp)
|
||||
space(sp), pr->pr_reg[33], pr->pr_fpvalid);
|
||||
}
|
||||
|
||||
+struct riscv64_elf_siginfo {
|
||||
+ int si_signo;
|
||||
+ int si_code;
|
||||
+ int si_errno;
|
||||
+};
|
||||
+
|
||||
+struct riscv64_elf_prstatus {
|
||||
+ struct riscv64_elf_siginfo pr_info;
|
||||
+ short pr_cursig;
|
||||
+ unsigned long pr_sigpend;
|
||||
+ unsigned long pr_sighold;
|
||||
+ pid_t pr_pid;
|
||||
+ pid_t pr_ppid;
|
||||
+ pid_t pr_pgrp;
|
||||
+ pid_t pr_sid;
|
||||
+ struct timeval pr_utime;
|
||||
+ struct timeval pr_stime;
|
||||
+ struct timeval pr_cutime;
|
||||
+ struct timeval pr_cstime;
|
||||
+/* elf_gregset_t pr_reg; => typedef struct user_regs_struct elf_gregset_t; */
|
||||
+ unsigned long pr_reg[32];
|
||||
+ int pr_fpvalid;
|
||||
+};
|
||||
+
|
||||
+static void
|
||||
+display_prstatus_riscv64(void *note_ptr, FILE *ofp)
|
||||
+{
|
||||
+ struct riscv64_elf_prstatus *pr;
|
||||
+ Elf64_Nhdr *note;
|
||||
+ int sp;
|
||||
+
|
||||
+ note = (Elf64_Nhdr *)note_ptr;
|
||||
+ pr = (struct riscv64_elf_prstatus *)(
|
||||
+ (char *)note + sizeof(Elf64_Nhdr) + note->n_namesz);
|
||||
+ pr = (struct riscv64_elf_prstatus *)roundup((ulong)pr, 4);
|
||||
+ sp = nd->num_prstatus_notes ? 25 : 22;
|
||||
+
|
||||
+ fprintf(ofp,
|
||||
+ "%ssi.signo: %d si.code: %d si.errno: %d\n"
|
||||
+ "%scursig: %d sigpend: %lx sighold: %lx\n"
|
||||
+ "%spid: %d ppid: %d pgrp: %d sid:%d\n"
|
||||
+ "%sutime: %01lld.%06d stime: %01lld.%06d\n"
|
||||
+ "%scutime: %01lld.%06d cstime: %01lld.%06d\n",
|
||||
+ space(sp), pr->pr_info.si_signo, pr->pr_info.si_code, pr->pr_info.si_errno,
|
||||
+ space(sp), pr->pr_cursig, pr->pr_sigpend, pr->pr_sighold,
|
||||
+ space(sp), pr->pr_pid, pr->pr_ppid, pr->pr_pgrp, pr->pr_sid,
|
||||
+ space(sp), (long long)pr->pr_utime.tv_sec, (int)pr->pr_utime.tv_usec,
|
||||
+ (long long)pr->pr_stime.tv_sec, (int)pr->pr_stime.tv_usec,
|
||||
+ space(sp), (long long)pr->pr_cutime.tv_sec, (int)pr->pr_cutime.tv_usec,
|
||||
+ (long long)pr->pr_cstime.tv_sec, (int)pr->pr_cstime.tv_usec);
|
||||
+ fprintf(ofp,
|
||||
+ "%sepc: %016lx ra: %016lx sp: %016lx\n"
|
||||
+ "%s gp: %016lx tp: %016lx t0: %016lx\n"
|
||||
+ "%s t1: %016lx t2: %016lx s0: %016lx\n"
|
||||
+ "%s s1: %016lx a0: %016lx a1: %016lx\n"
|
||||
+ "%s a2: %016lx a3: %016lx a4: %016lx\n"
|
||||
+ "%s a5: %016lx a6: %016lx a7: %016lx\n"
|
||||
+ "%s s2: %016lx s3: %016lx s4: %016lx\n"
|
||||
+ "%s s5: %016lx s6: %016lx s7: %016lx\n"
|
||||
+ "%s s8: %016lx s9: %016lx s10: %016lx\n"
|
||||
+ "%ss11: %016lx t3: %016lx t4: %016lx\n"
|
||||
+ "%s t5: %016lx t6: %016lx\n",
|
||||
+ space(sp), pr->pr_reg[0], pr->pr_reg[1], pr->pr_reg[2],
|
||||
+ space(sp), pr->pr_reg[3], pr->pr_reg[4], pr->pr_reg[5],
|
||||
+ space(sp), pr->pr_reg[6], pr->pr_reg[7], pr->pr_reg[8],
|
||||
+ space(sp), pr->pr_reg[9], pr->pr_reg[10], pr->pr_reg[11],
|
||||
+ space(sp), pr->pr_reg[12], pr->pr_reg[13], pr->pr_reg[14],
|
||||
+ space(sp), pr->pr_reg[15], pr->pr_reg[16], pr->pr_reg[17],
|
||||
+ space(sp), pr->pr_reg[18], pr->pr_reg[19], pr->pr_reg[20],
|
||||
+ space(sp), pr->pr_reg[21], pr->pr_reg[22], pr->pr_reg[23],
|
||||
+ space(sp), pr->pr_reg[24], pr->pr_reg[25], pr->pr_reg[26],
|
||||
+ space(sp), pr->pr_reg[27], pr->pr_reg[28], pr->pr_reg[29],
|
||||
+ space(sp), pr->pr_reg[30], pr->pr_reg[31]);
|
||||
+}
|
||||
|
||||
void
|
||||
display_ELF_note(int machine, int type, void *note, FILE *ofp)
|
||||
@@ -3449,6 +3525,14 @@ display_ELF_note(int machine, int type, void *note, FILE *ofp)
|
||||
break;
|
||||
}
|
||||
break;
|
||||
+ case EM_RISCV:
|
||||
+ switch (type)
|
||||
+ {
|
||||
+ case PRSTATUS_NOTE:
|
||||
+ display_prstatus_riscv64(note, ofp);
|
||||
+ break;
|
||||
+ }
|
||||
+ break;
|
||||
|
||||
default:
|
||||
return;
|
||||
--
|
||||
2.41.0
|
||||
|
|
@ -0,0 +1,87 @@
|
|||
From 9b69093e623f1d54c373b1e091900d40576c059b Mon Sep 17 00:00:00 2001
|
||||
From: Song Shuai <songshuaishuai@tinylab.org>
|
||||
Date: Tue, 12 Dec 2023 18:20:51 +0800
|
||||
Subject: [PATCH 11/14] RISCV64: Fix 'bt' output when no ra on the stack top
|
||||
|
||||
Same as the Linux commit f766f77a74f5 ("riscv/stacktrace: Fix
|
||||
stack output without ra on the stack top").
|
||||
|
||||
When a function doesn't have a callee, then it will not
|
||||
push ra into the stack, such as lkdtm functions, so
|
||||
correct the FP of the second frame and use pt_regs to get
|
||||
the right PC of the second frame.
|
||||
|
||||
Before this patch, the `bt -f` outputs only the first frame with
|
||||
the wrong PC and FP of next frame:
|
||||
```
|
||||
crash> bt -f
|
||||
PID: 1 TASK: ff600000000e0000 CPU: 1 COMMAND: "sh"
|
||||
#0 [ff20000000013cf0] lkdtm_EXCEPTION at ffffffff805303c0
|
||||
[PC: ffffffff805303c0 RA: ff20000000013d10 SP: ff20000000013cf0 SIZE: 16] <- wrong next PC
|
||||
ff20000000013cf0: 0000000000000001 ff20000000013d10 <- next FP
|
||||
ff20000000013d00: ff20000000013d40
|
||||
crash>
|
||||
```
|
||||
After this patch, the `bt` outputs the full frames:
|
||||
```
|
||||
crash> bt
|
||||
PID: 1 TASK: ff600000000e0000 CPU: 1 COMMAND: "sh"
|
||||
#0 [ff20000000013cf0] lkdtm_EXCEPTION at ffffffff805303c0
|
||||
#1 [ff20000000013d00] lkdtm_do_action at ffffffff8052fe36
|
||||
#2 [ff20000000013d10] direct_entry at ffffffff80530018
|
||||
#3 [ff20000000013d40] full_proxy_write at ffffffff80305044
|
||||
#4 [ff20000000013d80] vfs_write at ffffffff801b68b4
|
||||
#5 [ff20000000013e30] ksys_write at ffffffff801b6c4a
|
||||
#6 [ff20000000013e80] __riscv_sys_write at ffffffff801b6cc4
|
||||
#7 [ff20000000013e90] do_trap_ecall_u at ffffffff80836798
|
||||
crash>
|
||||
```
|
||||
|
||||
Acked-by: Kazuhito Hagio <k-hagio-ab@nec.com>
|
||||
Signed-off-by: Song Shuai <songshuaishuai@tinylab.org>
|
||||
Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
|
||||
---
|
||||
riscv64.c | 15 +++++++++++++--
|
||||
1 file changed, 13 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/riscv64.c b/riscv64.c
|
||||
index 0aaa14b2671e..872be594d72b 100644
|
||||
--- a/riscv64.c
|
||||
+++ b/riscv64.c
|
||||
@@ -747,11 +747,14 @@ riscv64_back_trace_cmd(struct bt_info *bt)
|
||||
{
|
||||
struct riscv64_unwind_frame current, previous;
|
||||
struct stackframe curr_frame;
|
||||
+ struct riscv64_register * regs;
|
||||
int level = 0;
|
||||
|
||||
if (bt->flags & BT_REGS_NOT_FOUND)
|
||||
return;
|
||||
|
||||
+ regs = (struct riscv64_register *) bt->machdep;
|
||||
+
|
||||
current.pc = bt->instptr;
|
||||
current.sp = bt->stkptr;
|
||||
current.fp = bt->frameptr;
|
||||
@@ -788,8 +791,16 @@ riscv64_back_trace_cmd(struct bt_info *bt)
|
||||
sizeof(curr_frame), "get stack frame", RETURN_ON_ERROR))
|
||||
return;
|
||||
|
||||
- previous.pc = curr_frame.ra;
|
||||
- previous.fp = curr_frame.fp;
|
||||
+ /* correct PC and FP of the second frame when the first frame has no callee */
|
||||
+
|
||||
+ if (regs && (regs->regs[RISCV64_REGS_EPC] == current.pc) && curr_frame.fp & 0x7){
|
||||
+ previous.pc = regs->regs[RISCV64_REGS_RA];
|
||||
+ previous.fp = curr_frame.ra;
|
||||
+ } else {
|
||||
+ previous.pc = curr_frame.ra;
|
||||
+ previous.fp = curr_frame.fp;
|
||||
+ }
|
||||
+
|
||||
previous.sp = current.fp;
|
||||
|
||||
riscv64_dump_backtrace_entry(bt, symbol, ¤t, &previous, level++);
|
||||
--
|
||||
2.41.0
|
||||
|
|
@ -0,0 +1,265 @@
|
|||
From 19d3c56c9fca9dea49dced0414becc6d1b12e9fc Mon Sep 17 00:00:00 2001
|
||||
From: Huang Shijie <shijie@os.amperecomputing.com>
|
||||
Date: Thu, 14 Dec 2023 15:15:20 +0800
|
||||
Subject: [PATCH 12/14] arm64: rewrite the arm64_get_vmcoreinfo_ul to
|
||||
arm64_get_vmcoreinfo
|
||||
|
||||
Rewrite the arm64_get_vmcoreinfo_ul to arm64_get_vmcoreinfo,
|
||||
add a new parameter "base" for it.
|
||||
|
||||
Also use it to simplify the arm64 code.
|
||||
|
||||
Signed-off-by: Huang Shijie <shijie@os.amperecomputing.com>
|
||||
Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
|
||||
---
|
||||
arm64.c | 99 +++++++++++++++++++++++----------------------------------
|
||||
1 file changed, 39 insertions(+), 60 deletions(-)
|
||||
|
||||
diff --git a/arm64.c b/arm64.c
|
||||
index 2b6b0e588d4e..57965c6cb3c8 100644
|
||||
--- a/arm64.c
|
||||
+++ b/arm64.c
|
||||
@@ -92,6 +92,7 @@ static void arm64_get_crash_notes(void);
|
||||
static void arm64_calc_VA_BITS(void);
|
||||
static int arm64_is_uvaddr(ulong, struct task_context *);
|
||||
static void arm64_calc_KERNELPACMASK(void);
|
||||
+static int arm64_get_vmcoreinfo(unsigned long *vaddr, const char *label, int base);
|
||||
|
||||
struct kernel_range {
|
||||
unsigned long modules_vaddr, modules_end;
|
||||
@@ -124,7 +125,6 @@ void
|
||||
arm64_init(int when)
|
||||
{
|
||||
ulong value;
|
||||
- char *string;
|
||||
struct machine_specific *ms;
|
||||
|
||||
#if defined(__x86_64__)
|
||||
@@ -160,11 +160,8 @@ arm64_init(int when)
|
||||
if (!ms->kimage_voffset && STREQ(pc->live_memsrc, "/dev/crash"))
|
||||
ioctl(pc->mfd, DEV_CRASH_ARCH_DATA, &ms->kimage_voffset);
|
||||
|
||||
- if (!ms->kimage_voffset &&
|
||||
- (string = pc->read_vmcoreinfo("NUMBER(kimage_voffset)"))) {
|
||||
- ms->kimage_voffset = htol(string, QUIET, NULL);
|
||||
- free(string);
|
||||
- }
|
||||
+ if (!ms->kimage_voffset)
|
||||
+ arm64_get_vmcoreinfo(&ms->kimage_voffset, "NUMBER(kimage_voffset)", NUM_HEX);
|
||||
|
||||
if (ms->kimage_voffset ||
|
||||
(ACTIVE() && (symbol_value_from_proc_kallsyms("kimage_voffset") != BADVAL))) {
|
||||
@@ -185,11 +182,8 @@ arm64_init(int when)
|
||||
if (kernel_symbol_exists("kimage_voffset"))
|
||||
machdep->flags |= NEW_VMEMMAP;
|
||||
|
||||
- if (!machdep->pagesize &&
|
||||
- (string = pc->read_vmcoreinfo("PAGESIZE"))) {
|
||||
- machdep->pagesize = atoi(string);
|
||||
- free(string);
|
||||
- }
|
||||
+ if (!machdep->pagesize && arm64_get_vmcoreinfo(&value, "PAGESIZE", NUM_DEC))
|
||||
+ machdep->pagesize = (unsigned int)value;
|
||||
|
||||
if (!machdep->pagesize) {
|
||||
/*
|
||||
@@ -443,9 +437,8 @@ arm64_init(int when)
|
||||
arm64_get_section_size_bits();
|
||||
|
||||
if (!machdep->max_physmem_bits) {
|
||||
- if ((string = pc->read_vmcoreinfo("NUMBER(MAX_PHYSMEM_BITS)"))) {
|
||||
- machdep->max_physmem_bits = atol(string);
|
||||
- free(string);
|
||||
+ if (arm64_get_vmcoreinfo(&machdep->max_physmem_bits, "NUMBER(MAX_PHYSMEM_BITS)", NUM_DEC)) {
|
||||
+ /* nothing */
|
||||
} else if (machdep->machspec->VA_BITS == 52) /* guess */
|
||||
machdep->max_physmem_bits = _MAX_PHYSMEM_BITS_52;
|
||||
else if (THIS_KERNEL_VERSION >= LINUX(3,17,0))
|
||||
@@ -573,16 +566,28 @@ static int arm64_get_struct_page_max_shift(struct machine_specific *ms)
|
||||
}
|
||||
|
||||
/* Return TRUE if we succeed, return FALSE on failure. */
|
||||
-static int arm64_get_vmcoreinfo_ul(unsigned long *vaddr, const char* label)
|
||||
+static int
|
||||
+arm64_get_vmcoreinfo(unsigned long *vaddr, const char *label, int base)
|
||||
{
|
||||
+ int err = 0;
|
||||
char *string = pc->read_vmcoreinfo(label);
|
||||
|
||||
if (!string)
|
||||
return FALSE;
|
||||
|
||||
- *vaddr = strtoul(string, NULL, 0);
|
||||
+ switch (base) {
|
||||
+ case NUM_HEX:
|
||||
+ *vaddr = strtoul(string, NULL, 16);
|
||||
+ break;
|
||||
+ case NUM_DEC:
|
||||
+ *vaddr = strtoul(string, NULL, 10);
|
||||
+ break;
|
||||
+ default:
|
||||
+ err++;
|
||||
+ error(INFO, "Unknown type:%#x, (NUM_HEX|NUM_DEC)\n", base);
|
||||
+ }
|
||||
free(string);
|
||||
- return TRUE;
|
||||
+ return err ? FALSE: TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -594,21 +599,21 @@ static struct kernel_range *arm64_get_range_v5_18(struct machine_specific *ms)
|
||||
struct kernel_range *r = &tmp_range;
|
||||
|
||||
/* Get the MODULES_VADDR ~ MODULES_END */
|
||||
- if (!arm64_get_vmcoreinfo_ul(&r->modules_vaddr, "NUMBER(MODULES_VADDR)"))
|
||||
+ if (!arm64_get_vmcoreinfo(&r->modules_vaddr, "NUMBER(MODULES_VADDR)", NUM_HEX))
|
||||
return NULL;
|
||||
- if (!arm64_get_vmcoreinfo_ul(&r->modules_end, "NUMBER(MODULES_END)"))
|
||||
+ if (!arm64_get_vmcoreinfo(&r->modules_end, "NUMBER(MODULES_END)", NUM_HEX))
|
||||
return NULL;
|
||||
|
||||
/* Get the VMEMMAP_START ~ VMEMMAP_END */
|
||||
- if (!arm64_get_vmcoreinfo_ul(&r->vmemmap_vaddr, "NUMBER(VMEMMAP_START)"))
|
||||
+ if (!arm64_get_vmcoreinfo(&r->vmemmap_vaddr, "NUMBER(VMEMMAP_START)", NUM_HEX))
|
||||
return NULL;
|
||||
- if (!arm64_get_vmcoreinfo_ul(&r->vmemmap_end, "NUMBER(VMEMMAP_END)"))
|
||||
+ if (!arm64_get_vmcoreinfo(&r->vmemmap_end, "NUMBER(VMEMMAP_END)", NUM_HEX))
|
||||
return NULL;
|
||||
|
||||
/* Get the VMALLOC_START ~ VMALLOC_END */
|
||||
- if (!arm64_get_vmcoreinfo_ul(&r->vmalloc_start_addr, "NUMBER(VMALLOC_START)"))
|
||||
+ if (!arm64_get_vmcoreinfo(&r->vmalloc_start_addr, "NUMBER(VMALLOC_START)", NUM_HEX))
|
||||
return NULL;
|
||||
- if (!arm64_get_vmcoreinfo_ul(&r->vmalloc_end, "NUMBER(VMALLOC_END)"))
|
||||
+ if (!arm64_get_vmcoreinfo(&r->vmalloc_end, "NUMBER(VMALLOC_END)", NUM_HEX))
|
||||
return NULL;
|
||||
|
||||
return r;
|
||||
@@ -888,12 +893,7 @@ range_failed:
|
||||
/* Get the size of struct page {} */
|
||||
static void arm64_get_struct_page_size(struct machine_specific *ms)
|
||||
{
|
||||
- char *string;
|
||||
-
|
||||
- string = pc->read_vmcoreinfo("SIZE(page)");
|
||||
- if (string)
|
||||
- ms->struct_page_size = atol(string);
|
||||
- free(string);
|
||||
+ arm64_get_vmcoreinfo(&ms->struct_page_size, "SIZE(page)", NUM_DEC);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1469,16 +1469,12 @@ arm64_calc_phys_offset(void)
|
||||
physaddr_t paddr;
|
||||
ulong vaddr;
|
||||
struct syment *sp;
|
||||
- char *string;
|
||||
|
||||
if ((machdep->flags & NEW_VMEMMAP) &&
|
||||
ms->kimage_voffset && (sp = kernel_symbol_search("memstart_addr"))) {
|
||||
if (pc->flags & PROC_KCORE) {
|
||||
- if ((string = pc->read_vmcoreinfo("NUMBER(PHYS_OFFSET)"))) {
|
||||
- ms->phys_offset = htol(string, QUIET, NULL);
|
||||
- free(string);
|
||||
+ if (arm64_get_vmcoreinfo(&ms->phys_offset, "NUMBER(PHYS_OFFSET)", NUM_HEX))
|
||||
return;
|
||||
- }
|
||||
vaddr = symbol_value_from_proc_kallsyms("memstart_addr");
|
||||
if (vaddr == BADVAL)
|
||||
vaddr = sp->value;
|
||||
@@ -1560,9 +1556,8 @@ arm64_get_section_size_bits(void)
|
||||
} else
|
||||
machdep->section_size_bits = _SECTION_SIZE_BITS;
|
||||
|
||||
- if ((string = pc->read_vmcoreinfo("NUMBER(SECTION_SIZE_BITS)"))) {
|
||||
- machdep->section_size_bits = atol(string);
|
||||
- free(string);
|
||||
+ if (arm64_get_vmcoreinfo(&machdep->section_size_bits, "NUMBER(SECTION_SIZE_BITS)", NUM_DEC)) {
|
||||
+ /* nothing */
|
||||
} else if (kt->ikconfig_flags & IKCONFIG_AVAIL) {
|
||||
if ((ret = get_kernel_config("CONFIG_MEMORY_HOTPLUG", NULL)) == IKCONFIG_Y) {
|
||||
if ((ret = get_kernel_config("CONFIG_HOTPLUG_SIZE_BITS", &string)) == IKCONFIG_STR)
|
||||
@@ -1581,15 +1576,11 @@ arm64_get_section_size_bits(void)
|
||||
static int
|
||||
arm64_kdump_phys_base(ulong *phys_offset)
|
||||
{
|
||||
- char *string;
|
||||
struct syment *sp;
|
||||
physaddr_t paddr;
|
||||
|
||||
- if ((string = pc->read_vmcoreinfo("NUMBER(PHYS_OFFSET)"))) {
|
||||
- *phys_offset = htol(string, QUIET, NULL);
|
||||
- free(string);
|
||||
+ if (arm64_get_vmcoreinfo(phys_offset, "NUMBER(PHYS_OFFSET)", NUM_HEX))
|
||||
return TRUE;
|
||||
- }
|
||||
|
||||
if ((machdep->flags & NEW_VMEMMAP) &&
|
||||
machdep->machspec->kimage_voffset &&
|
||||
@@ -4592,10 +4583,9 @@ static int
|
||||
arm64_set_va_bits_by_tcr(void)
|
||||
{
|
||||
ulong value;
|
||||
- char *string;
|
||||
|
||||
- if ((string = pc->read_vmcoreinfo("NUMBER(TCR_EL1_T1SZ)")) ||
|
||||
- (string = pc->read_vmcoreinfo("NUMBER(tcr_el1_t1sz)"))) {
|
||||
+ if (arm64_get_vmcoreinfo(&value, "NUMBER(TCR_EL1_T1SZ)", NUM_HEX) ||
|
||||
+ arm64_get_vmcoreinfo(&value, "NUMBER(tcr_el1_t1sz)", NUM_HEX)) {
|
||||
/* See ARMv8 ARM for the description of
|
||||
* TCR_EL1.T1SZ and how it can be used
|
||||
* to calculate the vabits_actual
|
||||
@@ -4604,10 +4594,9 @@ arm64_set_va_bits_by_tcr(void)
|
||||
* Basically:
|
||||
* vabits_actual = 64 - T1SZ;
|
||||
*/
|
||||
- value = 64 - strtoll(string, NULL, 0);
|
||||
+ value = 64 - value;
|
||||
if (CRASHDEBUG(1))
|
||||
fprintf(fp, "vmcoreinfo : vabits_actual: %ld\n", value);
|
||||
- free(string);
|
||||
machdep->machspec->VA_BITS_ACTUAL = value;
|
||||
machdep->machspec->VA_BITS = value;
|
||||
machdep->machspec->VA_START = _VA_START(machdep->machspec->VA_BITS_ACTUAL);
|
||||
@@ -4623,13 +4612,8 @@ arm64_calc_VA_BITS(void)
|
||||
int bitval;
|
||||
struct syment *sp;
|
||||
ulong vabits_actual, value;
|
||||
- char *string;
|
||||
|
||||
- if ((string = pc->read_vmcoreinfo("NUMBER(VA_BITS)"))) {
|
||||
- value = atol(string);
|
||||
- free(string);
|
||||
- machdep->machspec->CONFIG_ARM64_VA_BITS = value;
|
||||
- }
|
||||
+ arm64_get_vmcoreinfo(&machdep->machspec->CONFIG_ARM64_VA_BITS, "NUMBER(VA_BITS)", NUM_DEC);
|
||||
|
||||
if (kernel_symbol_exists("vabits_actual")) {
|
||||
if (pc->flags & PROC_KCORE) {
|
||||
@@ -4754,9 +4738,7 @@ arm64_calc_virtual_memory_ranges(void)
|
||||
ulong PUD_SIZE = UNINITIALIZED;
|
||||
|
||||
if (!machdep->machspec->CONFIG_ARM64_VA_BITS) {
|
||||
- if ((string = pc->read_vmcoreinfo("NUMBER(VA_BITS)"))) {
|
||||
- value = atol(string);
|
||||
- free(string);
|
||||
+ if (arm64_get_vmcoreinfo(&value, "NUMBER(VA_BITS)", NUM_DEC)) {
|
||||
machdep->machspec->CONFIG_ARM64_VA_BITS = value;
|
||||
} else if (kt->ikconfig_flags & IKCONFIG_AVAIL) {
|
||||
if ((ret = get_kernel_config("CONFIG_ARM64_VA_BITS",
|
||||
@@ -4852,11 +4834,8 @@ arm64_swp_offset(ulong pte)
|
||||
static void arm64_calc_KERNELPACMASK(void)
|
||||
{
|
||||
ulong value;
|
||||
- char *string;
|
||||
|
||||
- if ((string = pc->read_vmcoreinfo("NUMBER(KERNELPACMASK)"))) {
|
||||
- value = htol(string, QUIET, NULL);
|
||||
- free(string);
|
||||
+ if (arm64_get_vmcoreinfo(&value, "NUMBER(KERNELPACMASK)", NUM_HEX)) {
|
||||
machdep->machspec->CONFIG_ARM64_KERNELPACMASK = value;
|
||||
if (CRASHDEBUG(1))
|
||||
fprintf(fp, "CONFIG_ARM64_KERNELPACMASK: %lx\n", value);
|
||||
--
|
||||
2.41.0
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
From 38435c3acec075b076353ca28f557a0dfe1341c3 Mon Sep 17 00:00:00 2001
|
||||
From: Li Zhijian <lizhijian@fujitsu.com>
|
||||
Date: Fri, 15 Dec 2023 10:44:21 +0800
|
||||
Subject: [PATCH 13/14] help.c: Remove "kmem -l" help messages
|
||||
|
||||
"kmem -l" option has existed when crash git project initialization, but
|
||||
its help message was not accurate (extra arguments a|i|ic|id was missing).
|
||||
|
||||
In addition, those symbols required by the -l option were for very old
|
||||
kernels, at least 2.6 kernels don't contain them. Also, this option has
|
||||
not been fixed for a long time.
|
||||
|
||||
Instead of document this option, hide it from help messages.
|
||||
|
||||
Signed-off-by: Li Zhijian <lizhijian@fujitsu.com>
|
||||
Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
|
||||
---
|
||||
help.c | 2 --
|
||||
1 file changed, 2 deletions(-)
|
||||
|
||||
diff --git a/help.c b/help.c
|
||||
index cc7ab20e343e..d80e843703c1 100644
|
||||
--- a/help.c
|
||||
+++ b/help.c
|
||||
@@ -6888,8 +6888,6 @@ char *help_kmem[] = {
|
||||
" members of the associated page struct are displayed.",
|
||||
" address when used with -c, the address must be a page pointer address;",
|
||||
" the page_hash_table entry containing the page is displayed.",
|
||||
-" address when used with -l, the address must be a page pointer address;",
|
||||
-" the page address is displayed if it is contained with the list.",
|
||||
" address when used with -v, the address can be a mapped kernel virtual",
|
||||
" address or physical address; the mapped region containing the",
|
||||
" address is displayed.\n",
|
||||
--
|
||||
2.41.0
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
From 53d2577cef98b76b122aade94349637a11e06138 Mon Sep 17 00:00:00 2001
|
||||
From: Tao Liu <ltao@redhat.com>
|
||||
Date: Tue, 26 Dec 2023 09:19:28 +0800
|
||||
Subject: [PATCH 14/14] x86_64: check bt->bptr before calculate framesize
|
||||
|
||||
Previously the value of bt->bptr is not checked, which may led to a
|
||||
wrong prev_sp and framesize. As a result, bt->stackbuf[] will be
|
||||
accessed out of range, and segfault.
|
||||
|
||||
Before:
|
||||
crash> set debug 1
|
||||
crash> bt
|
||||
...snip...
|
||||
--- <NMI exception stack> ---
|
||||
#8 [ffffffff9a603e10] __switch_to_asm at ffffffff99800214
|
||||
rsp: ffffffff9a603e10 textaddr: ffffffff99800214 -> spo: 0 bpo: 0 spr: 0 bpr: 0 type: 0 end: 0
|
||||
#9 [ffffffff9a603e40] __schedule at ffffffff9960dfb1
|
||||
rsp: ffffffff9a603e40 textaddr: ffffffff9960dfb1 -> spo: 16 bpo: -16 spr: 4 bpr: 1 type: 0 end: 0
|
||||
rsp: ffffffff9a603e40 rbp: ffffb9ca076e7ca8 prev_sp: ffffb9ca076e7cb8 framesize: 1829650024
|
||||
Segmentation fault (core dumped)
|
||||
|
||||
(gdb) p/x bt->stackbase
|
||||
$1 = 0xffffffff9a600000
|
||||
(gdb) p/x bt->stacktop
|
||||
$2 = 0xffffffff9a604000
|
||||
|
||||
After:
|
||||
crash> set debug 1
|
||||
crash> bt
|
||||
...snip...
|
||||
--- <NMI exception stack> ---
|
||||
#8 [ffffffff9a603e10] __switch_to_asm at ffffffff99800214
|
||||
rsp: ffffffff9a603e10 textaddr: ffffffff99800214 -> spo: 0 bpo: 0 spr: 0 bpr: 0 type: 0 end: 0
|
||||
#9 [ffffffff9a603e40] __schedule at ffffffff9960dfb1
|
||||
rsp: ffffffff9a603e40 textaddr: ffffffff9960dfb1 -> spo: 16 bpo: -16 spr: 4 bpr: 1 type: 0 end: 0
|
||||
#10 [ffffffff9a603e98] schedule_idle at ffffffff9960e87c
|
||||
rsp: ffffffff9a603e98 textaddr: ffffffff9960e87c -> spo: 8 bpo: 0 spr: 5 bpr: 0 type: 0 end: 0
|
||||
rsp: ffffffff9a603e98 prev_sp: ffffffff9a603ea8 framesize: 0
|
||||
...snip...
|
||||
|
||||
Check bt->bptr value before calculate framesize. Only bt->bptr within
|
||||
the range of bt->stackbase and bt->stacktop will be regarded as valid.
|
||||
|
||||
Signed-off-by: Tao Liu <ltao@redhat.com>
|
||||
Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
|
||||
---
|
||||
x86_64.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/x86_64.c b/x86_64.c
|
||||
index 42ade4817ad9..f59991f8c4c5 100644
|
||||
--- a/x86_64.c
|
||||
+++ b/x86_64.c
|
||||
@@ -8649,7 +8649,7 @@ x86_64_get_framesize(struct bt_info *bt, ulong textaddr, ulong rsp, char *stack_
|
||||
if (CRASHDEBUG(1))
|
||||
fprintf(fp, "rsp: %lx prev_sp: %lx framesize: %d\n",
|
||||
rsp, prev_sp, framesize);
|
||||
- } else if ((korc->sp_reg == ORC_REG_BP) && bt->bptr) {
|
||||
+ } else if ((korc->sp_reg == ORC_REG_BP) && bt->bptr && INSTACK(bt->bptr, bt)) {
|
||||
prev_sp = bt->bptr + korc->sp_offset;
|
||||
framesize = (prev_sp - (rsp + 8) - 8);
|
||||
if (CRASHDEBUG(1))
|
||||
--
|
||||
2.41.0
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
--- crash-8.0.4/Makefile.orig
|
||||
+++ crash-8.0.4/Makefile
|
||||
@@ -204,7 +204,7 @@ GDB_FLAGS=
|
||||
# TARGET_CFLAGS will be configured automatically by configure
|
||||
TARGET_CFLAGS=
|
||||
|
||||
-CRASH_CFLAGS=-g -D${TARGET} ${TARGET_CFLAGS} ${GDB_FLAGS} ${CFLAGS}
|
||||
+CRASH_CFLAGS=-g -D${TARGET} ${TARGET_CFLAGS} ${GDB_FLAGS} ${CFLAGS} ${CPPFLAGS} -fPIE
|
||||
|
||||
GPL_FILES=
|
||||
TAR_FILES=${SOURCE_FILES} Makefile ${GPL_FILES} README .rh_rpm_package crash.8 \
|
||||
@@ -256,7 +256,7 @@ all: make_configure
|
||||
gdb_merge: force
|
||||
@if [ ! -f ${GDB}/README ]; then \
|
||||
$(MAKE) gdb_unzip; fi
|
||||
- @echo "${LDFLAGS} -lz -llzo2 -lsnappy -lzstd -ldl -rdynamic" > ${GDB}/gdb/mergelibs
|
||||
+ @echo "${LDFLAGS} -lz -llzo2 -lsnappy -lzstd -ldl -rdynamic -Wl,-z,now -fPIE" > ${GDB}/gdb/mergelibs
|
||||
@echo "../../${PROGRAM} ../../${PROGRAM}lib.a" > ${GDB}/gdb/mergeobj
|
||||
@rm -f ${PROGRAM}
|
||||
@if [ ! -f ${GDB}/config.status ]; then \
|
||||
--- crash-8.0.4/configure.c.orig
|
||||
+++ crash-8.0.4/configure.c
|
||||
@@ -810,7 +810,8 @@ build_configure(struct supported_gdb_version *sp)
|
||||
fprintf(fp2, "%s\n", sp->GDB);
|
||||
sprintf(target_data.gdb_version, "%s", &sp->GDB[4]);
|
||||
} else if (strncmp(buf, "LDFLAGS=", strlen("LDFLAGS=")) == 0) {
|
||||
- fprintf(fp2, "LDFLAGS=%s\n", ldflags ? ldflags : "");
|
||||
+ if (ldflags)
|
||||
+ fprintf(fp2, "LDFLAGS=%s\n", ldflags ? ldflags : "");
|
||||
} else
|
||||
fprintf(fp2, "%s", buf);
|
||||
|
||||
|
|
@ -1,909 +0,0 @@
|
|||
commit 9596b4388ea5ebbf7de79f0e377a497de1616654
|
||||
Author: Bhupesh Sharma <bhsharma@redhat.com>
|
||||
Date: Thu Aug 6 13:17:26 2020 +0530
|
||||
|
||||
crash/arm64: Revert to implementation used in crash-7.2.3-17.el8 [Support for CONFIG_ARM64_USER_VA_BITS_52 and CONFIG_ARM64_PA_BITS=52]
|
||||
|
||||
Signed-off-by: Bhupesh Sharma <bhsharma@redhat.com>
|
||||
|
||||
diff --git a/arm64.c b/arm64.c
|
||||
index 49e25733f094..dfcde6e11359 100644
|
||||
--- a/arm64.c
|
||||
+++ b/arm64.c
|
||||
@@ -27,12 +27,9 @@
|
||||
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 int arm64_search_for_kimage_voffset(ulong);
|
||||
-static int verify_kimage_voffset(void);
|
||||
static void arm64_calc_kimage_voffset(void);
|
||||
static void arm64_calc_phys_offset(void);
|
||||
static void arm64_calc_virtual_memory_ranges(void);
|
||||
-static void arm64_get_section_size_bits(void);
|
||||
static int arm64_kdump_phys_base(ulong *);
|
||||
static ulong arm64_processor_speed(void);
|
||||
static void arm64_init_kernel_pgd(void);
|
||||
@@ -81,7 +78,7 @@ static int arm64_on_irq_stack(int, ulong);
|
||||
static void arm64_set_irq_stack(struct bt_info *);
|
||||
static void arm64_set_process_stack(struct bt_info *);
|
||||
static int arm64_get_kvaddr_ranges(struct vaddr_range *);
|
||||
-static void arm64_get_crash_notes(void);
|
||||
+static int arm64_get_crash_notes(void);
|
||||
static void arm64_calc_VA_BITS(void);
|
||||
static int arm64_is_uvaddr(ulong, struct task_context *);
|
||||
|
||||
@@ -147,12 +144,6 @@ arm64_init(int when)
|
||||
if (kernel_symbol_exists("kimage_voffset"))
|
||||
machdep->flags |= NEW_VMEMMAP;
|
||||
|
||||
- if (!machdep->pagesize &&
|
||||
- (string = pc->read_vmcoreinfo("PAGESIZE"))) {
|
||||
- machdep->pagesize = atoi(string);
|
||||
- free(string);
|
||||
- }
|
||||
-
|
||||
if (!machdep->pagesize) {
|
||||
/*
|
||||
* Kerneldoc Documentation/arm64/booting.txt describes
|
||||
@@ -179,16 +170,17 @@ arm64_init(int when)
|
||||
|
||||
}
|
||||
|
||||
- /*
|
||||
- * This code section will only be executed if the kernel is
|
||||
- * earlier than Linux 4.4 (if there is no vmcoreinfo)
|
||||
- */
|
||||
if (!machdep->pagesize &&
|
||||
kernel_symbol_exists("swapper_pg_dir") &&
|
||||
kernel_symbol_exists("idmap_pg_dir")) {
|
||||
- value = symbol_value("swapper_pg_dir") -
|
||||
- symbol_value("idmap_pg_dir");
|
||||
+ if (kernel_symbol_exists("tramp_pg_dir"))
|
||||
+ value = symbol_value("tramp_pg_dir");
|
||||
+ else if (kernel_symbol_exists("reserved_ttbr0"))
|
||||
+ value = symbol_value("reserved_ttbr0");
|
||||
+ else
|
||||
+ value = symbol_value("swapper_pg_dir");
|
||||
|
||||
+ value -= symbol_value("idmap_pg_dir");
|
||||
/*
|
||||
* idmap_pg_dir is 2 pages prior to 4.1,
|
||||
* and 3 pages thereafter. Only 4K and 64K
|
||||
@@ -214,19 +206,12 @@ arm64_init(int when)
|
||||
|
||||
arm64_calc_VA_BITS();
|
||||
ms = machdep->machspec;
|
||||
- if (ms->VA_BITS_ACTUAL) {
|
||||
- ms->page_offset = ARM64_PAGE_OFFSET_ACTUAL;
|
||||
- machdep->identity_map_base = ARM64_PAGE_OFFSET_ACTUAL;
|
||||
- machdep->kvbase = ARM64_PAGE_OFFSET_ACTUAL;
|
||||
- ms->userspace_top = ARM64_USERSPACE_TOP_ACTUAL;
|
||||
- } else {
|
||||
- ms->page_offset = ARM64_PAGE_OFFSET;
|
||||
- machdep->identity_map_base = ARM64_PAGE_OFFSET;
|
||||
- machdep->kvbase = ARM64_VA_START;
|
||||
- ms->userspace_top = ARM64_USERSPACE_TOP;
|
||||
- }
|
||||
+ ms->page_offset = ARM64_PAGE_OFFSET;
|
||||
+ machdep->identity_map_base = ARM64_PAGE_OFFSET;
|
||||
+ machdep->kvbase = ARM64_VA_START;
|
||||
machdep->is_kvaddr = generic_is_kvaddr;
|
||||
machdep->kvtop = arm64_kvtop;
|
||||
+ ms->userspace_top = ARM64_USERSPACE_TOP;
|
||||
if (machdep->flags & NEW_VMEMMAP) {
|
||||
struct syment *sp;
|
||||
|
||||
@@ -235,15 +220,11 @@ arm64_init(int when)
|
||||
sp = kernel_symbol_search("_end");
|
||||
ms->kimage_end = (sp ? sp->value : 0);
|
||||
|
||||
- if (ms->VA_BITS_ACTUAL) {
|
||||
- ms->modules_vaddr = (st->_stext_vmlinux & TEXT_OFFSET_MASK) - ARM64_MODULES_VSIZE;
|
||||
- ms->modules_end = ms->modules_vaddr + ARM64_MODULES_VSIZE -1;
|
||||
- } else {
|
||||
- ms->modules_vaddr = ARM64_VA_START;
|
||||
- if (kernel_symbol_exists("kasan_init"))
|
||||
- ms->modules_vaddr += ARM64_KASAN_SHADOW_SIZE;
|
||||
- ms->modules_end = ms->modules_vaddr + ARM64_MODULES_VSIZE -1;
|
||||
- }
|
||||
+ ms->modules_vaddr = ARM64_VA_START;
|
||||
+ if (kernel_symbol_exists("kasan_init"))
|
||||
+ ms->modules_vaddr += ARM64_KASAN_SHADOW_SIZE;
|
||||
+ ms->modules_end = ms->modules_vaddr
|
||||
+ + ARM64_MODULES_VSIZE -1;
|
||||
|
||||
ms->vmalloc_start_addr = ms->modules_end + 1;
|
||||
|
||||
@@ -285,7 +266,7 @@ arm64_init(int when)
|
||||
case 65536:
|
||||
if (kernel_symbol_exists("idmap_ptrs_per_pgd") &&
|
||||
readmem(symbol_value("idmap_ptrs_per_pgd"), KVADDR,
|
||||
- &value, sizeof(ulong), "idmap_ptrs_per_pgd", QUIET|RETURN_ON_ERROR))
|
||||
+ &value, sizeof(ulong), "idmap_ptrs_per_pgd", RETURN_ON_ERROR))
|
||||
machdep->ptrs_per_pgd = value;
|
||||
|
||||
if (machdep->machspec->VA_BITS > PGDIR_SHIFT_L3_64K) {
|
||||
@@ -335,6 +316,10 @@ arm64_init(int when)
|
||||
|
||||
machdep->uvtop = arm64_uvtop;
|
||||
machdep->is_uvaddr = arm64_is_uvaddr;
|
||||
+ if (kernel_symbol_exists("vabits_user") &&
|
||||
+ readmem(symbol_value("vabits_user"), KVADDR,
|
||||
+ &value, sizeof(ulong), "vabits_user", RETURN_ON_ERROR))
|
||||
+ machdep->machspec->vabits_user = value;
|
||||
machdep->eframe_search = arm64_eframe_search;
|
||||
machdep->back_trace = arm64_back_trace_cmd;
|
||||
machdep->in_alternate_stack = arm64_in_alternate_stack;
|
||||
@@ -375,8 +360,7 @@ arm64_init(int when)
|
||||
|
||||
case POST_GDB:
|
||||
arm64_calc_virtual_memory_ranges();
|
||||
- arm64_get_section_size_bits();
|
||||
-
|
||||
+ machdep->section_size_bits = _SECTION_SIZE_BITS;
|
||||
if (!machdep->max_physmem_bits) {
|
||||
if ((string = pc->read_vmcoreinfo("NUMBER(MAX_PHYSMEM_BITS)"))) {
|
||||
machdep->max_physmem_bits = atol(string);
|
||||
@@ -388,24 +372,8 @@ arm64_init(int when)
|
||||
else
|
||||
machdep->max_physmem_bits = _MAX_PHYSMEM_BITS;
|
||||
}
|
||||
-
|
||||
ms = machdep->machspec;
|
||||
|
||||
- if (CRASHDEBUG(1)) {
|
||||
- if (ms->VA_BITS_ACTUAL) {
|
||||
- fprintf(fp, "CONFIG_ARM64_VA_BITS: %ld\n", ms->CONFIG_ARM64_VA_BITS);
|
||||
- fprintf(fp, " VA_BITS_ACTUAL: %ld\n", ms->VA_BITS_ACTUAL);
|
||||
- fprintf(fp, "(calculated) VA_BITS: %ld\n", ms->VA_BITS);
|
||||
- fprintf(fp, " PAGE_OFFSET: %lx\n", ARM64_PAGE_OFFSET_ACTUAL);
|
||||
- fprintf(fp, " VA_START: %lx\n", ms->VA_START);
|
||||
- fprintf(fp, " modules: %lx - %lx\n", ms->modules_vaddr, ms->modules_end);
|
||||
- fprintf(fp, " vmalloc: %lx - %lx\n", ms->vmalloc_start_addr, ms->vmalloc_end);
|
||||
- fprintf(fp, "kernel image: %lx - %lx\n", ms->kimage_text, ms->kimage_end);
|
||||
- fprintf(fp, " vmemmap: %lx - %lx\n\n", ms->vmemmap_vaddr, ms->vmemmap_end);
|
||||
- }
|
||||
- }
|
||||
-
|
||||
-
|
||||
if (THIS_KERNEL_VERSION >= LINUX(4,0,0)) {
|
||||
ms->__SWP_TYPE_BITS = 6;
|
||||
ms->__SWP_TYPE_SHIFT = 2;
|
||||
@@ -465,8 +433,11 @@ arm64_init(int when)
|
||||
* of the crash. We need this information to extract correct
|
||||
* backtraces from the panic task.
|
||||
*/
|
||||
- if (!LIVE())
|
||||
- arm64_get_crash_notes();
|
||||
+ if (!LIVE() && !arm64_get_crash_notes())
|
||||
+ error(WARNING,
|
||||
+ "cannot retrieve registers for active task%s\n\n",
|
||||
+ kt->cpus > 1 ? "s" : "");
|
||||
+
|
||||
break;
|
||||
|
||||
case LOG_ONLY:
|
||||
@@ -648,15 +619,9 @@ arm64_dump_machdep_table(ulong arg)
|
||||
|
||||
fprintf(fp, " machspec: %lx\n", (ulong)ms);
|
||||
fprintf(fp, " VA_BITS: %ld\n", ms->VA_BITS);
|
||||
- fprintf(fp, " CONFIG_ARM64_VA_BITS: %ld\n", ms->CONFIG_ARM64_VA_BITS);
|
||||
- fprintf(fp, " VA_START: ");
|
||||
- if (ms->VA_START)
|
||||
- fprintf(fp, "%lx\n", ms->VA_START);
|
||||
- else
|
||||
- fprintf(fp, "(unused)\n");
|
||||
- fprintf(fp, " VA_BITS_ACTUAL: ");
|
||||
- if (ms->VA_BITS_ACTUAL)
|
||||
- fprintf(fp, "%ld\n", ms->VA_BITS_ACTUAL);
|
||||
+ fprintf(fp, " vabits_user: ");
|
||||
+ if (ms->vabits_user)
|
||||
+ fprintf(fp, "%ld\n", ms->vabits_user);
|
||||
else
|
||||
fprintf(fp, "(unused)\n");
|
||||
fprintf(fp, " userspace_top: %016lx\n", ms->userspace_top);
|
||||
@@ -745,12 +710,12 @@ arm64_parse_machdep_arg_l(char *argstring, char *param, ulong *value)
|
||||
int flags = RETURN_ON_ERROR | QUIET;
|
||||
int err = 0;
|
||||
|
||||
- if (STRNEQ(argstring, "max_physmem_bits")) {
|
||||
- *value = dtol(p, flags, &err);
|
||||
- } else if (megabytes) {
|
||||
+ if (megabytes) {
|
||||
*value = dtol(p, flags, &err);
|
||||
if (!err)
|
||||
*value = MEGABYTES(*value);
|
||||
+ } else if (STRNEQ(argstring, "max_physmem_bits")) {
|
||||
+ *value = dtol(p, flags, &err);
|
||||
} else {
|
||||
*value = htol(p, flags, &err);
|
||||
}
|
||||
@@ -824,60 +789,11 @@ arm64_parse_cmdline_args(void)
|
||||
}
|
||||
}
|
||||
|
||||
-#define MIN_KIMG_ALIGN (0x00200000) /* kimage load address must be aligned 2M */
|
||||
-/*
|
||||
- * Traverse the entire dumpfile to find/verify kimage_voffset.
|
||||
- */
|
||||
-static int
|
||||
-arm64_search_for_kimage_voffset(ulong phys_base)
|
||||
-{
|
||||
- ulong kimage_load_addr;
|
||||
- ulong phys_end;
|
||||
- struct machine_specific *ms = machdep->machspec;
|
||||
-
|
||||
- if (!arm_kdump_phys_end(&phys_end))
|
||||
- return FALSE;
|
||||
-
|
||||
- for (kimage_load_addr = phys_base;
|
||||
- kimage_load_addr <= phys_end; kimage_load_addr += MIN_KIMG_ALIGN) {
|
||||
- ms->kimage_voffset = ms->vmalloc_start_addr - kimage_load_addr;
|
||||
-
|
||||
- if ((kt->flags2 & KASLR) && (kt->flags & RELOC_SET))
|
||||
- ms->kimage_voffset += (kt->relocate * - 1);
|
||||
-
|
||||
- if (verify_kimage_voffset()) {
|
||||
- if (CRASHDEBUG(1))
|
||||
- error(INFO,
|
||||
- "dumpfile searched for kimage_voffset: %lx\n\n",
|
||||
- ms->kimage_voffset);
|
||||
- break;
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- if (kimage_load_addr > phys_end)
|
||||
- return FALSE;
|
||||
-
|
||||
- return TRUE;
|
||||
-}
|
||||
-
|
||||
-static int
|
||||
-verify_kimage_voffset(void)
|
||||
-{
|
||||
- ulong kimage_voffset;
|
||||
-
|
||||
- if (!readmem(symbol_value("kimage_voffset"), KVADDR, &kimage_voffset,
|
||||
- sizeof(kimage_voffset), "verify kimage_voffset", QUIET|RETURN_ON_ERROR))
|
||||
- return FALSE;
|
||||
-
|
||||
- return (machdep->machspec->kimage_voffset == kimage_voffset);
|
||||
-}
|
||||
-
|
||||
static void
|
||||
arm64_calc_kimage_voffset(void)
|
||||
{
|
||||
struct machine_specific *ms = machdep->machspec;
|
||||
- ulong phys_addr = 0;
|
||||
- int errflag;
|
||||
+ ulong phys_addr;
|
||||
|
||||
if (ms->kimage_voffset) /* vmcoreinfo, ioctl, or --machdep override */
|
||||
return;
|
||||
@@ -885,6 +801,7 @@ arm64_calc_kimage_voffset(void)
|
||||
if (ACTIVE()) {
|
||||
char buf[BUFSIZE];
|
||||
char *p1;
|
||||
+ int errflag;
|
||||
FILE *iomem;
|
||||
ulong kimage_voffset, vaddr;
|
||||
|
||||
@@ -925,24 +842,9 @@ arm64_calc_kimage_voffset(void)
|
||||
if (errflag)
|
||||
return;
|
||||
|
||||
- } else if (KDUMP_DUMPFILE()) {
|
||||
- errflag = 1;
|
||||
- if (arm_kdump_phys_base(&phys_addr)) { /* Get start address of first memory block */
|
||||
- ms->kimage_voffset = ms->vmalloc_start_addr - phys_addr;
|
||||
- if ((kt->flags2 & KASLR) && (kt->flags & RELOC_SET))
|
||||
- ms->kimage_voffset += (kt->relocate * -1);
|
||||
- if (verify_kimage_voffset() || arm64_search_for_kimage_voffset(phys_addr))
|
||||
- errflag = 0;
|
||||
- }
|
||||
-
|
||||
- if (errflag) {
|
||||
- error(WARNING,
|
||||
- "kimage_voffset cannot be determined from the dumpfile.\n");
|
||||
- error(CONT,
|
||||
- "Try using the command line option: --machdep kimage_voffset=<addr>\n");
|
||||
- }
|
||||
- return;
|
||||
- } else {
|
||||
+ } else if (KDUMP_DUMPFILE())
|
||||
+ arm_kdump_phys_base(&phys_addr); /* Get start address of first memory block */
|
||||
+ else {
|
||||
error(WARNING,
|
||||
"kimage_voffset cannot be determined from the dumpfile.\n");
|
||||
error(CONT,
|
||||
@@ -981,16 +883,10 @@ arm64_calc_phys_offset(void)
|
||||
physaddr_t paddr;
|
||||
ulong vaddr;
|
||||
struct syment *sp;
|
||||
- char *string;
|
||||
|
||||
if ((machdep->flags & NEW_VMEMMAP) &&
|
||||
ms->kimage_voffset && (sp = kernel_symbol_search("memstart_addr"))) {
|
||||
if (pc->flags & PROC_KCORE) {
|
||||
- if ((string = pc->read_vmcoreinfo("NUMBER(PHYS_OFFSET)"))) {
|
||||
- ms->phys_offset = htol(string, QUIET, NULL);
|
||||
- free(string);
|
||||
- return;
|
||||
- }
|
||||
vaddr = symbol_value_from_proc_kallsyms("memstart_addr");
|
||||
if (vaddr == BADVAL)
|
||||
vaddr = sp->value;
|
||||
@@ -1053,31 +949,6 @@ arm64_calc_phys_offset(void)
|
||||
fprintf(fp, "using %lx as phys_offset\n", ms->phys_offset);
|
||||
}
|
||||
|
||||
-/*
|
||||
- * Determine SECTION_SIZE_BITS either by reading VMCOREINFO or the kernel
|
||||
- * config, otherwise use the 64-bit ARM default definiton.
|
||||
- */
|
||||
-static void
|
||||
-arm64_get_section_size_bits(void)
|
||||
-{
|
||||
- int ret;
|
||||
- char *string;
|
||||
-
|
||||
- machdep->section_size_bits = _SECTION_SIZE_BITS;
|
||||
-
|
||||
- if ((string = pc->read_vmcoreinfo("NUMBER(SECTION_SIZE_BITS)"))) {
|
||||
- machdep->section_size_bits = atol(string);
|
||||
- free(string);
|
||||
- } else if (kt->ikconfig_flags & IKCONFIG_AVAIL) {
|
||||
- if ((ret = get_kernel_config("CONFIG_MEMORY_HOTPLUG", NULL)) == IKCONFIG_Y) {
|
||||
- if ((ret = get_kernel_config("CONFIG_HOTPLUG_SIZE_BITS", &string)) == IKCONFIG_STR)
|
||||
- machdep->section_size_bits = atol(string);
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- if (CRASHDEBUG(1))
|
||||
- fprintf(fp, "SECTION_SIZE_BITS: %ld\n", machdep->section_size_bits);
|
||||
-}
|
||||
|
||||
/*
|
||||
* Determine PHYS_OFFSET either by reading VMCOREINFO or the kernel
|
||||
@@ -1133,12 +1004,6 @@ ulong
|
||||
arm64_VTOP(ulong addr)
|
||||
{
|
||||
if (machdep->flags & NEW_VMEMMAP) {
|
||||
- if (machdep->machspec->VA_START &&
|
||||
- (addr >= machdep->machspec->kimage_text) &&
|
||||
- (addr <= machdep->machspec->kimage_end)) {
|
||||
- return addr - machdep->machspec->kimage_voffset;
|
||||
- }
|
||||
-
|
||||
if (addr >= machdep->machspec->page_offset)
|
||||
return machdep->machspec->phys_offset
|
||||
+ (addr - machdep->machspec->page_offset);
|
||||
@@ -1215,11 +1080,6 @@ arm64_uvtop(struct task_context *tc, ulong uvaddr, physaddr_t *paddr, int verbos
|
||||
}
|
||||
}
|
||||
|
||||
-#define PTE_ADDR_LOW ((((1UL) << (48 - machdep->pageshift)) - 1) << machdep->pageshift)
|
||||
-#define PTE_ADDR_HIGH ((0xfUL) << 12)
|
||||
-#define PTE_TO_PHYS(pteval) (machdep->max_physmem_bits == 52 ? \
|
||||
- (((pteval & PTE_ADDR_LOW) | ((pteval & PTE_ADDR_HIGH) << 36))) : (pteval & PTE_ADDR_LOW))
|
||||
-
|
||||
#define PMD_TYPE_MASK 3
|
||||
#define PMD_TYPE_SECT 1
|
||||
#define PMD_TYPE_TABLE 2
|
||||
@@ -1312,7 +1172,7 @@ arm64_vtop_3level_64k(ulong pgd, ulong vaddr, physaddr_t *paddr, int verbose)
|
||||
* #define __PAGETABLE_PUD_FOLDED
|
||||
*/
|
||||
|
||||
- pmd_base = (ulong *)PTOV(PTE_TO_PHYS(pgd_val));
|
||||
+ pmd_base = (ulong *)PTOV(pgd_val & PHYS_MASK & (s32)machdep->pagemask);
|
||||
FILL_PMD(pmd_base, KVADDR, PTRS_PER_PMD_L3_64K * sizeof(ulong));
|
||||
pmd_ptr = pmd_base + (((vaddr) >> PMD_SHIFT_L3_64K) & (PTRS_PER_PMD_L3_64K - 1));
|
||||
pmd_val = ULONG(machdep->pmd + PAGEOFFSET(pmd_ptr));
|
||||
@@ -1322,7 +1182,7 @@ arm64_vtop_3level_64k(ulong pgd, ulong vaddr, physaddr_t *paddr, int verbose)
|
||||
goto no_page;
|
||||
|
||||
if ((pmd_val & PMD_TYPE_MASK) == PMD_TYPE_SECT) {
|
||||
- ulong sectionbase = PTE_TO_PHYS(pmd_val) & SECTION_PAGE_MASK_512MB;
|
||||
+ ulong sectionbase = (pmd_val & SECTION_PAGE_MASK_512MB) & PHYS_MASK;
|
||||
if (verbose) {
|
||||
fprintf(fp, " PAGE: %lx (512MB)\n\n", sectionbase);
|
||||
arm64_translate_pte(pmd_val, 0, 0);
|
||||
@@ -1331,7 +1191,7 @@ arm64_vtop_3level_64k(ulong pgd, ulong vaddr, physaddr_t *paddr, int verbose)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
- pte_base = (ulong *)PTOV(PTE_TO_PHYS(pmd_val));
|
||||
+ pte_base = (ulong *)PTOV(pmd_val & PHYS_MASK & (s32)machdep->pagemask);
|
||||
FILL_PTBL(pte_base, KVADDR, PTRS_PER_PTE_L3_64K * sizeof(ulong));
|
||||
pte_ptr = pte_base + (((vaddr) >> machdep->pageshift) & (PTRS_PER_PTE_L3_64K - 1));
|
||||
pte_val = ULONG(machdep->ptbl + PAGEOFFSET(pte_ptr));
|
||||
@@ -1341,7 +1201,7 @@ arm64_vtop_3level_64k(ulong pgd, ulong vaddr, physaddr_t *paddr, int verbose)
|
||||
goto no_page;
|
||||
|
||||
if (pte_val & PTE_VALID) {
|
||||
- *paddr = PTE_TO_PHYS(pte_val) + PAGEOFFSET(vaddr);
|
||||
+ *paddr = (PAGEBASE(pte_val) & PHYS_MASK) + PAGEOFFSET(vaddr);
|
||||
if (verbose) {
|
||||
fprintf(fp, " PAGE: %lx\n\n", PAGEBASE(*paddr));
|
||||
arm64_translate_pte(pte_val, 0, 0);
|
||||
@@ -1644,11 +1504,10 @@ arm64_stackframe_init(void)
|
||||
machdep->machspec->kern_eframe_offset = SIZE(pt_regs);
|
||||
}
|
||||
|
||||
- if ((sp1 = kernel_symbol_search("__exception_text_start")) &&
|
||||
- (sp2 = kernel_symbol_search("__exception_text_end"))) {
|
||||
- machdep->machspec->__exception_text_start = sp1->value;
|
||||
- machdep->machspec->__exception_text_end = sp2->value;
|
||||
- }
|
||||
+ machdep->machspec->__exception_text_start =
|
||||
+ symbol_value("__exception_text_start");
|
||||
+ machdep->machspec->__exception_text_end =
|
||||
+ symbol_value("__exception_text_end");
|
||||
if ((sp1 = kernel_symbol_search("__irqentry_text_start")) &&
|
||||
(sp2 = kernel_symbol_search("__irqentry_text_end"))) {
|
||||
machdep->machspec->__irqentry_text_start = sp1->value;
|
||||
@@ -1857,38 +1716,20 @@ arm64_eframe_search(struct bt_info *bt)
|
||||
return count;
|
||||
}
|
||||
|
||||
-static char *arm64_exception_functions[] = {
|
||||
- "do_undefinstr",
|
||||
- "do_sysinstr",
|
||||
- "do_debug_exception",
|
||||
- "do_mem_abort",
|
||||
- "do_el0_irq_bp_hardening",
|
||||
- "do_sp_pc_abort",
|
||||
- NULL
|
||||
-};
|
||||
-
|
||||
static int
|
||||
arm64_in_exception_text(ulong ptr)
|
||||
{
|
||||
struct machine_specific *ms = machdep->machspec;
|
||||
- char *name, **func;
|
||||
+
|
||||
+ if ((ptr >= ms->__exception_text_start) &&
|
||||
+ (ptr < ms->__exception_text_end))
|
||||
+ return TRUE;
|
||||
|
||||
if (ms->__irqentry_text_start && ms->__irqentry_text_end &&
|
||||
((ptr >= ms->__irqentry_text_start) &&
|
||||
(ptr < ms->__irqentry_text_end)))
|
||||
return TRUE;
|
||||
|
||||
- if (ms->__exception_text_start && ms->__exception_text_end) {
|
||||
- if ((ptr >= ms->__exception_text_start) &&
|
||||
- (ptr < ms->__exception_text_end))
|
||||
- return TRUE;
|
||||
- } else if ((name = closest_symbol(ptr))) { /* Linux 5.5 and later */
|
||||
- for (func = &arm64_exception_functions[0]; *func; func++) {
|
||||
- if (STREQ(name, *func))
|
||||
- return TRUE;
|
||||
- }
|
||||
- }
|
||||
-
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -3297,7 +3138,7 @@ arm64_translate_pte(ulong pte, void *physaddr, ulonglong unused)
|
||||
char *arglist[MAXARGS];
|
||||
int page_present;
|
||||
|
||||
- paddr = PTE_TO_PHYS(pte);
|
||||
+ paddr = pte & PHYS_MASK & (s32)machdep->pagemask;
|
||||
page_present = pte & (PTE_VALID | machdep->machspec->PTE_PROT_NONE);
|
||||
|
||||
if (physaddr) {
|
||||
@@ -3563,8 +3404,8 @@ arm64_display_machine_stats(void)
|
||||
fprintf(fp, " HZ: %d\n", machdep->hz);
|
||||
fprintf(fp, " PAGE SIZE: %d\n", PAGESIZE());
|
||||
fprintf(fp, "KERNEL VIRTUAL BASE: %lx\n", machdep->machspec->page_offset);
|
||||
- fprintf(fp, "KERNEL MODULES BASE: %lx\n", machdep->machspec->modules_vaddr);
|
||||
fprintf(fp, "KERNEL VMALLOC BASE: %lx\n", machdep->machspec->vmalloc_start_addr);
|
||||
+ fprintf(fp, "KERNEL MODULES BASE: %lx\n", machdep->machspec->modules_vaddr);
|
||||
fprintf(fp, "KERNEL VMEMMAP BASE: %lx\n", machdep->machspec->vmemmap_vaddr);
|
||||
fprintf(fp, " KERNEL STACK SIZE: %ld\n", STACKSIZE());
|
||||
if (machdep->machspec->irq_stack_size) {
|
||||
@@ -3594,7 +3435,7 @@ arm64_get_smp_cpus(void)
|
||||
/*
|
||||
* Retrieve task registers for the time of the crash.
|
||||
*/
|
||||
-static void
|
||||
+static int
|
||||
arm64_get_crash_notes(void)
|
||||
{
|
||||
struct machine_specific *ms = machdep->machspec;
|
||||
@@ -3603,10 +3444,10 @@ arm64_get_crash_notes(void)
|
||||
ulong offset;
|
||||
char *buf, *p;
|
||||
ulong *notes_ptrs;
|
||||
- ulong i, found;
|
||||
+ ulong i;
|
||||
|
||||
if (!symbol_exists("crash_notes"))
|
||||
- return;
|
||||
+ return FALSE;
|
||||
|
||||
crash_notes = symbol_value("crash_notes");
|
||||
|
||||
@@ -3618,9 +3459,9 @@ arm64_get_crash_notes(void)
|
||||
*/
|
||||
if (!readmem(crash_notes, KVADDR, ¬es_ptrs[kt->cpus-1],
|
||||
sizeof(notes_ptrs[kt->cpus-1]), "crash_notes", RETURN_ON_ERROR)) {
|
||||
- error(WARNING, "cannot read \"crash_notes\"\n");
|
||||
+ error(WARNING, "cannot read crash_notes\n");
|
||||
FREEBUF(notes_ptrs);
|
||||
- return;
|
||||
+ return FALSE;
|
||||
}
|
||||
|
||||
if (symbol_exists("__per_cpu_offset")) {
|
||||
@@ -3636,11 +3477,12 @@ arm64_get_crash_notes(void)
|
||||
if (!(ms->panic_task_regs = calloc((size_t)kt->cpus, sizeof(struct arm64_pt_regs))))
|
||||
error(FATAL, "cannot calloc panic_task_regs space\n");
|
||||
|
||||
- for (i = found = 0; i < kt->cpus; i++) {
|
||||
+ for (i = 0; i < kt->cpus; i++) {
|
||||
+
|
||||
if (!readmem(notes_ptrs[i], KVADDR, buf, SIZE(note_buf),
|
||||
"note_buf_t", RETURN_ON_ERROR)) {
|
||||
- error(WARNING, "cpu %d: cannot read NT_PRSTATUS note\n", i);
|
||||
- continue;
|
||||
+ error(WARNING, "failed to read note_buf_t\n");
|
||||
+ goto fail;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3670,24 +3512,19 @@ arm64_get_crash_notes(void)
|
||||
note->n_descsz == notesz)
|
||||
BCOPY((char *)note, buf, notesz);
|
||||
} else {
|
||||
- error(WARNING, "cpu %d: cannot find NT_PRSTATUS note\n", i);
|
||||
+ error(WARNING,
|
||||
+ "cannot find NT_PRSTATUS note for cpu: %d\n", i);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
- /*
|
||||
- * Check the sanity of NT_PRSTATUS note only for each online cpu.
|
||||
- * If this cpu has invalid note, continue to find the crash notes
|
||||
- * for other online cpus.
|
||||
- */
|
||||
if (note->n_type != NT_PRSTATUS) {
|
||||
- error(WARNING, "cpu %d: invalid NT_PRSTATUS note (n_type != NT_PRSTATUS)\n", i);
|
||||
- continue;
|
||||
+ error(WARNING, "invalid note (n_type != NT_PRSTATUS)\n");
|
||||
+ goto fail;
|
||||
}
|
||||
-
|
||||
- if (!STRNEQ(p, "CORE")) {
|
||||
- error(WARNING, "cpu %d: invalid NT_PRSTATUS note (name != \"CORE\")\n", i);
|
||||
- continue;
|
||||
+ if (p[0] != 'C' || p[1] != 'O' || p[2] != 'R' || p[3] != 'E') {
|
||||
+ error(WARNING, "invalid note (name != \"CORE\"\n");
|
||||
+ goto fail;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3700,17 +3537,18 @@ arm64_get_crash_notes(void)
|
||||
|
||||
BCOPY(p + OFFSET(elf_prstatus_pr_reg), &ms->panic_task_regs[i],
|
||||
sizeof(struct arm64_pt_regs));
|
||||
-
|
||||
- found++;
|
||||
}
|
||||
|
||||
FREEBUF(buf);
|
||||
FREEBUF(notes_ptrs);
|
||||
+ return TRUE;
|
||||
|
||||
- if (!found) {
|
||||
- free(ms->panic_task_regs);
|
||||
- ms->panic_task_regs = NULL;
|
||||
- }
|
||||
+fail:
|
||||
+ FREEBUF(buf);
|
||||
+ FREEBUF(notes_ptrs);
|
||||
+ free(ms->panic_task_regs);
|
||||
+ ms->panic_task_regs = NULL;
|
||||
+ return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -3834,9 +3672,6 @@ arm64_IS_VMALLOC_ADDR(ulong vaddr)
|
||||
(vaddr <= machdep->machspec->kimage_end))
|
||||
return FALSE;
|
||||
|
||||
- if (ms->VA_START && (vaddr >= ms->VA_START))
|
||||
- return TRUE;
|
||||
-
|
||||
return ((vaddr >= ms->vmalloc_start_addr && vaddr <= ms->vmalloc_end) ||
|
||||
((machdep->flags & VMEMMAP) &&
|
||||
(vaddr >= ms->vmemmap_vaddr && vaddr <= ms->vmemmap_end)) ||
|
||||
@@ -3848,54 +3683,9 @@ arm64_calc_VA_BITS(void)
|
||||
{
|
||||
int bitval;
|
||||
struct syment *sp;
|
||||
- ulong vabits_actual, value;
|
||||
+ ulong value;
|
||||
char *string;
|
||||
|
||||
- if ((string = pc->read_vmcoreinfo("NUMBER(VA_BITS)"))) {
|
||||
- value = atol(string);
|
||||
- free(string);
|
||||
- machdep->machspec->CONFIG_ARM64_VA_BITS = value;
|
||||
- }
|
||||
-
|
||||
- if (kernel_symbol_exists("vabits_actual")) {
|
||||
- if (pc->flags & PROC_KCORE) {
|
||||
- vabits_actual = symbol_value_from_proc_kallsyms("vabits_actual");
|
||||
- if ((vabits_actual != BADVAL) && (READMEM(pc->mfd, &value, sizeof(ulong),
|
||||
- vabits_actual, KCORE_USE_VADDR) > 0)) {
|
||||
- if (CRASHDEBUG(1))
|
||||
- fprintf(fp,
|
||||
- "/proc/kcore: vabits_actual: %ld\n", value);
|
||||
- machdep->machspec->VA_BITS_ACTUAL = value;
|
||||
- machdep->machspec->VA_BITS = value;
|
||||
- machdep->machspec->VA_START = _VA_START(machdep->machspec->VA_BITS_ACTUAL);
|
||||
- } else
|
||||
- error(FATAL, "/proc/kcore: cannot read vabits_actual\n");
|
||||
- } else if (ACTIVE())
|
||||
- error(FATAL, "cannot determine VA_BITS_ACTUAL: please use /proc/kcore\n");
|
||||
- else {
|
||||
- if ((string = pc->read_vmcoreinfo("NUMBER(TCR_EL1_T1SZ)"))) {
|
||||
- /* See ARMv8 ARM for the description of
|
||||
- * TCR_EL1.T1SZ and how it can be used
|
||||
- * to calculate the vabits_actual
|
||||
- * supported by underlying kernel.
|
||||
- *
|
||||
- * Basically:
|
||||
- * vabits_actual = 64 - T1SZ;
|
||||
- */
|
||||
- value = 64 - strtoll(string, NULL, 0);
|
||||
- if (CRASHDEBUG(1))
|
||||
- fprintf(fp, "vmcoreinfo : vabits_actual: %ld\n", value);
|
||||
- free(string);
|
||||
- machdep->machspec->VA_BITS_ACTUAL = value;
|
||||
- machdep->machspec->VA_BITS = value;
|
||||
- machdep->machspec->VA_START = _VA_START(machdep->machspec->VA_BITS_ACTUAL);
|
||||
- } else
|
||||
- error(FATAL, "cannot determine VA_BITS_ACTUAL\n");
|
||||
- }
|
||||
-
|
||||
- return;
|
||||
- }
|
||||
-
|
||||
if (!(sp = symbol_search("swapper_pg_dir")) &&
|
||||
!(sp = symbol_search("idmap_pg_dir")) &&
|
||||
!(sp = symbol_search("_text")) &&
|
||||
@@ -3924,12 +3714,14 @@ arm64_calc_VA_BITS(void)
|
||||
/*
|
||||
* Verify against dumpfiles that export VA_BITS in vmcoreinfo
|
||||
*/
|
||||
- if (machdep->machspec->CONFIG_ARM64_VA_BITS &&
|
||||
- (machdep->machspec->VA_BITS != machdep->machspec->CONFIG_ARM64_VA_BITS)) {
|
||||
- error(WARNING, "VA_BITS: calculated: %ld vmcoreinfo: %ld\n",
|
||||
- machdep->machspec->VA_BITS, machdep->machspec->CONFIG_ARM64_VA_BITS);
|
||||
- machdep->machspec->VA_BITS = machdep->machspec->CONFIG_ARM64_VA_BITS;
|
||||
- }
|
||||
+ if ((string = pc->read_vmcoreinfo("NUMBER(VA_BITS)"))) {
|
||||
+ value = atol(string);
|
||||
+ free(string);
|
||||
+ if (machdep->machspec->VA_BITS != value)
|
||||
+ error(WARNING, "VA_BITS: calculated: %ld vmcoreinfo: %ld\n",
|
||||
+ machdep->machspec->VA_BITS, value);
|
||||
+ }
|
||||
+
|
||||
|
||||
if (CRASHDEBUG(1))
|
||||
fprintf(fp, "VA_BITS: %ld\n", machdep->machspec->VA_BITS);
|
||||
@@ -3947,15 +3739,6 @@ arm64_calc_VA_BITS(void)
|
||||
*
|
||||
* Since VMEMMAP_SIZE is dependent upon the size of a struct page,
|
||||
* the two ranges cannot be determined until POST_GDB.
|
||||
- *
|
||||
- * Since 52-bit VA was introduced:
|
||||
- *
|
||||
- * #define STRUCT_PAGE_MAX_SHIFT 6
|
||||
- * #define VMEMMAP_SIZE (UL(1) << (VA_BITS - PAGE_SHIFT - 1 + STRUCT_PAGE_MAX_SHIFT))
|
||||
- * #define VMEMMAP_START (-VMEMMAP_SIZE)
|
||||
- * #define VMALLOC_START (MODULES_END)
|
||||
- * #define VMALLOC_END (- PUD_SIZE - VMEMMAP_SIZE - SZ_64K)
|
||||
- * #define vmemmap ((struct page *)VMEMMAP_START - (memstart_addr >> PAGE_SHIFT))
|
||||
*/
|
||||
|
||||
#define ALIGN(x, a) __ALIGN_KERNEL((x), (a))
|
||||
@@ -3967,18 +3750,10 @@ static void
|
||||
arm64_calc_virtual_memory_ranges(void)
|
||||
{
|
||||
struct machine_specific *ms = machdep->machspec;
|
||||
- ulong value, vmemmap_start, vmemmap_end, vmemmap_size, vmalloc_end;
|
||||
- char *string;
|
||||
+ ulong vmemmap_start, vmemmap_end, vmemmap_size;
|
||||
+ ulong vmalloc_end;
|
||||
ulong PUD_SIZE = UNINITIALIZED;
|
||||
|
||||
- if (!machdep->machspec->CONFIG_ARM64_VA_BITS) {
|
||||
- if ((string = pc->read_vmcoreinfo("NUMBER(VA_BITS)"))) {
|
||||
- value = atol(string);
|
||||
- free(string);
|
||||
- machdep->machspec->CONFIG_ARM64_VA_BITS = value;
|
||||
- }
|
||||
- }
|
||||
-
|
||||
if (THIS_KERNEL_VERSION < LINUX(3,17,0)) /* use original hardwired values */
|
||||
return;
|
||||
|
||||
@@ -3997,19 +3772,8 @@ arm64_calc_virtual_memory_ranges(void)
|
||||
break;
|
||||
}
|
||||
|
||||
-#define STRUCT_PAGE_MAX_SHIFT 6
|
||||
-
|
||||
- if (ms->VA_BITS_ACTUAL) {
|
||||
- vmemmap_size = (1UL) << (ms->CONFIG_ARM64_VA_BITS - machdep->pageshift - 1 + STRUCT_PAGE_MAX_SHIFT);
|
||||
- vmalloc_end = (- PUD_SIZE - vmemmap_size - KILOBYTES(64));
|
||||
- vmemmap_start = (-vmemmap_size);
|
||||
- ms->vmalloc_end = vmalloc_end - 1;
|
||||
- ms->vmemmap_vaddr = vmemmap_start;
|
||||
- ms->vmemmap_end = -1;
|
||||
- return;
|
||||
- }
|
||||
-
|
||||
if (machdep->flags & NEW_VMEMMAP)
|
||||
+#define STRUCT_PAGE_MAX_SHIFT 6
|
||||
vmemmap_size = 1UL << (ms->VA_BITS - machdep->pageshift - 1
|
||||
+ STRUCT_PAGE_MAX_SHIFT);
|
||||
else
|
||||
@@ -4033,7 +3797,7 @@ arm64_calc_virtual_memory_ranges(void)
|
||||
static int
|
||||
arm64_is_uvaddr(ulong addr, struct task_context *tc)
|
||||
{
|
||||
- return (addr < machdep->machspec->userspace_top);
|
||||
+ return (addr < ARM64_USERSPACE_TOP);
|
||||
}
|
||||
|
||||
|
||||
diff --git a/defs.h b/defs.h
|
||||
index ac24a5d730d5..d0b021f61c67 100644
|
||||
--- a/defs.h
|
||||
+++ b/defs.h
|
||||
@@ -3148,17 +3148,9 @@ typedef signed int s32;
|
||||
*/
|
||||
#define ARM64_VA_START ((0xffffffffffffffffUL) \
|
||||
<< machdep->machspec->VA_BITS)
|
||||
-#define _VA_START(va) ((0xffffffffffffffffUL) - \
|
||||
- ((1UL) << ((va) - 1)) + 1)
|
||||
-#define TEXT_OFFSET_MASK (~((MEGABYTES(2UL))-1))
|
||||
-
|
||||
#define ARM64_PAGE_OFFSET ((0xffffffffffffffffUL) \
|
||||
<< (machdep->machspec->VA_BITS - 1))
|
||||
-#define ARM64_PAGE_OFFSET_ACTUAL ((0xffffffffffffffffUL) \
|
||||
- - ((1UL) << machdep->machspec->VA_BITS_ACTUAL) + 1)
|
||||
-
|
||||
#define ARM64_USERSPACE_TOP ((1UL) << machdep->machspec->VA_BITS)
|
||||
-#define ARM64_USERSPACE_TOP_ACTUAL ((1UL) << machdep->machspec->VA_BITS_ACTUAL)
|
||||
|
||||
/* only used for v4.6 or later */
|
||||
#define ARM64_MODULES_VSIZE MEGABYTES(128)
|
||||
@@ -3261,9 +3253,7 @@ struct machine_specific {
|
||||
ulong kern_eframe_offset;
|
||||
ulong machine_kexec_start;
|
||||
ulong machine_kexec_end;
|
||||
- ulong VA_BITS_ACTUAL;
|
||||
- ulong CONFIG_ARM64_VA_BITS;
|
||||
- ulong VA_START;
|
||||
+ ulong vabits_user;
|
||||
};
|
||||
|
||||
struct arm64_stackframe {
|
||||
diff --git a/netdump.c b/netdump.c
|
||||
index 0054d6ab35b4..31ab6fae5ccd 100644
|
||||
--- a/netdump.c
|
||||
+++ b/netdump.c
|
||||
@@ -1228,19 +1228,7 @@ netdump_memory_dump(FILE *fp)
|
||||
if (machine_type("X86_64"))
|
||||
netdump_print("%lx (relocate)\n", nd->arch_data1);
|
||||
else if (machine_type("ARM64"))
|
||||
- netdump_print("%lx (kimage_voffset)\n", nd->arch_data1);
|
||||
- } else
|
||||
- netdump_print("(unused)\n");
|
||||
- netdump_print(" arch_data2: ");
|
||||
- if (nd->arch_data2) {
|
||||
- if (machine_type("ARM64"))
|
||||
- netdump_print("%016lx\n"
|
||||
- " CONFIG_ARM64_VA_BITS: %ld\n"
|
||||
- " VA_BITS_ACTUAL: %lld\n",
|
||||
- nd->arch_data2, nd->arch_data2 & 0xffffffff,
|
||||
- ((ulonglong)nd->arch_data2 >> 32));
|
||||
- else
|
||||
- netdump_print("%016lx (?)\n", nd->arch_data2);
|
||||
+ netdump_print("%lx (kimage_voffset)\n", nd->arch_data);
|
||||
} else
|
||||
netdump_print("(unused)\n");
|
||||
netdump_print(" switch_stack: %lx\n", nd->switch_stack);
|
||||
@@ -1865,8 +1853,7 @@ vmcoreinfo_read_string(const char *key)
|
||||
int i, j, end;
|
||||
size_t value_length;
|
||||
size_t key_length = strlen(key);
|
||||
- char *vmcoreinfo;
|
||||
- uint size_vmcoreinfo;
|
||||
+ char *vmcoreinfo = (char *)nd->vmcoreinfo;
|
||||
char *value = NULL;
|
||||
|
||||
/*
|
||||
@@ -1875,49 +1862,25 @@ vmcoreinfo_read_string(const char *key)
|
||||
* the NT_TASKSTRUCT note.
|
||||
*/
|
||||
if ((pc->flags2 & SNAP)) {
|
||||
- if (STREQ(key, "NUMBER(kimage_voffset)") && nd->arch_data1) {
|
||||
+ if (STREQ(key, "NUMBER(kimage_voffset)") && nd->arch_data) {
|
||||
value = calloc(VADDR_PRLEN+1, sizeof(char));
|
||||
- sprintf(value, "%lx", nd->arch_data1);
|
||||
- if (nd->arch_data2 == 0)
|
||||
- pc->read_vmcoreinfo = no_vmcoreinfo;
|
||||
- return value;
|
||||
- }
|
||||
- if (STREQ(key, "NUMBER(VA_BITS)") && nd->arch_data2) {
|
||||
- value = calloc(VADDR_PRLEN+1, sizeof(char));
|
||||
- sprintf(value, "%ld", nd->arch_data2 & 0xffffffff);
|
||||
- return value;
|
||||
- }
|
||||
- if (STREQ(key, "NUMBER(TCR_EL1_T1SZ)") && nd->arch_data2) {
|
||||
- value = calloc(VADDR_PRLEN+1, sizeof(char));
|
||||
- sprintf(value, "%lld", ((ulonglong)nd->arch_data2 >> 32) & 0xffffffff);
|
||||
+ sprintf(value, "%lx", nd->arch_data);
|
||||
pc->read_vmcoreinfo = no_vmcoreinfo;
|
||||
return value;
|
||||
}
|
||||
- if (STREQ(key, "relocate") && nd->arch_data1) {
|
||||
+ if (STREQ(key, "relocate") && nd->arch_data) {
|
||||
value = calloc(VADDR_PRLEN+1, sizeof(char));
|
||||
- sprintf(value, "%lx", nd->arch_data1);
|
||||
+ sprintf(value, "%lx", nd->arch_data);
|
||||
pc->read_vmcoreinfo = no_vmcoreinfo;
|
||||
return value;
|
||||
}
|
||||
- return NULL;
|
||||
- }
|
||||
-
|
||||
- if (nd->vmcoreinfo) {
|
||||
- vmcoreinfo = (char *)nd->vmcoreinfo;
|
||||
- size_vmcoreinfo = nd->size_vmcoreinfo;
|
||||
- } else if (ACTIVE() && pkd->vmcoreinfo) {
|
||||
- vmcoreinfo = (char *)pkd->vmcoreinfo;
|
||||
- size_vmcoreinfo = pkd->size_vmcoreinfo;
|
||||
- } else {
|
||||
- vmcoreinfo = NULL;
|
||||
- size_vmcoreinfo = 0;
|
||||
}
|
||||
|
||||
- if (!vmcoreinfo)
|
||||
+ if (!nd->vmcoreinfo)
|
||||
return NULL;
|
||||
|
||||
/* the '+ 1' is the equal sign */
|
||||
- for (i = 0; i < (int)(size_vmcoreinfo - key_length + 1); i++) {
|
||||
+ for (i = 0; i < (nd->size_vmcoreinfo - key_length + 1); i++) {
|
||||
/*
|
||||
* We must also check if we're at the beginning of VMCOREINFO
|
||||
* or the separating newline is there, and of course if we
|
||||
@@ -1931,7 +1894,7 @@ vmcoreinfo_read_string(const char *key)
|
||||
|
||||
/* Found -- search for the next newline. */
|
||||
for (j = i + key_length + 1;
|
||||
- j < size_vmcoreinfo; j++) {
|
||||
+ j < nd->size_vmcoreinfo; j++) {
|
||||
if (vmcoreinfo[j] == '\n') {
|
||||
end = j;
|
||||
break;
|
||||
@@ -1944,7 +1907,7 @@ vmcoreinfo_read_string(const char *key)
|
||||
*/
|
||||
if (end == -1) {
|
||||
/* Point after the end. */
|
||||
- end = size_vmcoreinfo + 1;
|
||||
+ end = nd->size_vmcoreinfo + 1;
|
||||
}
|
||||
|
||||
value_length = end - (1+ i + key_length);
|
|
@ -1,368 +0,0 @@
|
|||
From b97e7fd4e8268d5c46f1b30b41ce1f6ca9ceb216 Mon Sep 17 00:00:00 2001
|
||||
From: HATAYAMA Daisuke <d.hatayama@fujitsu.com>
|
||||
Date: Mon, 27 Jul 2020 19:00:19 +0900
|
||||
Subject: [PATCH 1/4] symbols: Add linux_banner_vmlinux in symbol table
|
||||
|
||||
Add linux_banner_vmlinux in symbol table, which we'll later use in
|
||||
calc_kaslr_offset() to do a sanity check in calculation of
|
||||
kaslr_offset and phys_base.
|
||||
|
||||
Signed-off-by: HATAYAMA Daisuke <d.hatayama@fujitsu.com>
|
||||
---
|
||||
defs.h | 1 +
|
||||
symbols.c | 10 ++++++++++
|
||||
2 files changed, 11 insertions(+)
|
||||
|
||||
diff --git a/defs.h b/defs.h
|
||||
index d7adb23b86d5..17e98763362b 100644
|
||||
--- a/defs.h
|
||||
+++ b/defs.h
|
||||
@@ -2714,6 +2714,7 @@ struct symbol_table_data {
|
||||
ulong pti_init_vmlinux;
|
||||
ulong kaiser_init_vmlinux;
|
||||
int kernel_symbol_type;
|
||||
+ ulong linux_banner_vmlinux;
|
||||
};
|
||||
|
||||
/* flags for st */
|
||||
diff --git a/symbols.c b/symbols.c
|
||||
index 3b1f08af43ff..b9de4a179d93 100644
|
||||
--- a/symbols.c
|
||||
+++ b/symbols.c
|
||||
@@ -3226,6 +3226,11 @@ dump_symbol_table(void)
|
||||
fprintf(fp, " kaiser_init_vmlinux: (unused)\n");
|
||||
}
|
||||
|
||||
+ if (SADUMP_DUMPFILE())
|
||||
+ fprintf(fp, "linux_banner_vmlinux: %lx\n", st->linux_banner_vmlinux);
|
||||
+ else
|
||||
+ fprintf(fp, "linux_banner_vmlinux: (unused)\n");
|
||||
+
|
||||
fprintf(fp, " symval_hash[%d]: %lx\n", SYMVAL_HASH,
|
||||
(ulong)&st->symval_hash[0]);
|
||||
|
||||
@@ -12687,6 +12692,11 @@ numeric_forward(const void *P_x, const void *P_y)
|
||||
else if (STREQ(y->name, "idt_table"))
|
||||
st->idt_table_vmlinux = valueof(y);
|
||||
|
||||
+ if (STREQ(x->name, "linux_banner"))
|
||||
+ st->linux_banner_vmlinux = valueof(x);
|
||||
+ else if (STREQ(y->name, "linux_banner"))
|
||||
+ st->linux_banner_vmlinux = valueof(y);
|
||||
+
|
||||
if (STREQ(x->name, "saved_command_line"))
|
||||
st->saved_command_line_vmlinux = valueof(x);
|
||||
else if (STREQ(y->name, "saved_command_line"))
|
||||
--
|
||||
2.7.4
|
||||
|
||||
|
||||
From d494fabe99b90cea8d717a90951e44e6dbda84bb Mon Sep 17 00:00:00 2001
|
||||
From: HATAYAMA Daisuke <d.hatayama@fujitsu.com>
|
||||
Date: Mon, 27 Jul 2020 19:00:20 +0900
|
||||
Subject: [PATCH 2/4] symbols: fix initialization of st->{pti_init,
|
||||
kaiser}_vmlinux
|
||||
|
||||
In numeric_forward(), care must be taken both for x- and y- positions,
|
||||
but either of kaiser_init and pti_init is only for x- or y- position
|
||||
only. Fix this. Also, move the code in an appropriate position
|
||||
according to each symbol name in the alphabetical order.
|
||||
|
||||
Signed-off-by: HATAYAMA Daisuke <d.hatayama@fujitsu.com>
|
||||
---
|
||||
symbols.c | 15 ++++++++++-----
|
||||
1 file changed, 10 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/symbols.c b/symbols.c
|
||||
index b9de4a179d93..2fecaee093a2 100644
|
||||
--- a/symbols.c
|
||||
+++ b/symbols.c
|
||||
@@ -12692,20 +12692,25 @@ numeric_forward(const void *P_x, const void *P_y)
|
||||
else if (STREQ(y->name, "idt_table"))
|
||||
st->idt_table_vmlinux = valueof(y);
|
||||
|
||||
+ if (STREQ(x->name, "kaiser_init"))
|
||||
+ st->kaiser_init_vmlinux = valueof(x);
|
||||
+ else if (STREQ(y->name, "kaiser_init"))
|
||||
+ st->kaiser_init_vmlinux = valueof(y);
|
||||
+
|
||||
if (STREQ(x->name, "linux_banner"))
|
||||
st->linux_banner_vmlinux = valueof(x);
|
||||
else if (STREQ(y->name, "linux_banner"))
|
||||
st->linux_banner_vmlinux = valueof(y);
|
||||
|
||||
+ if (STREQ(x->name, "pti_init"))
|
||||
+ st->pti_init_vmlinux = valueof(x);
|
||||
+ else if (STREQ(y->name, "pti_init"))
|
||||
+ st->pti_init_vmlinux = valueof(y);
|
||||
+
|
||||
if (STREQ(x->name, "saved_command_line"))
|
||||
st->saved_command_line_vmlinux = valueof(x);
|
||||
else if (STREQ(y->name, "saved_command_line"))
|
||||
st->saved_command_line_vmlinux = valueof(y);
|
||||
-
|
||||
- if (STREQ(x->name, "pti_init"))
|
||||
- st->pti_init_vmlinux = valueof(x);
|
||||
- else if (STREQ(y->name, "kaiser_init"))
|
||||
- st->kaiser_init_vmlinux = valueof(y);
|
||||
}
|
||||
|
||||
xs = bfd_get_section(x);
|
||||
--
|
||||
2.7.4
|
||||
|
||||
|
||||
From ff45c8da8cafed350940b1a56dce65f58051db5e Mon Sep 17 00:00:00 2001
|
||||
From: HATAYAMA Daisuke <d.hatayama@fujitsu.com>
|
||||
Date: Mon, 27 Jul 2020 19:00:22 +0900
|
||||
Subject: [PATCH 3/4] kaslr: cleanup how to set values to the arguments of
|
||||
calc_kaslr_offset()
|
||||
|
||||
Setting values of the arguments of calc_kaslr_offset() should be done
|
||||
at the end of the function. Currently, they are set in the middle
|
||||
where their values could still be changed according to
|
||||
get_kaslr_offset_from_vmcoreinfo(). This behavior will be problematic
|
||||
in the later commits when we implement a trial-and-error approach
|
||||
because the value of kaslr_offset could be passed to the outside of
|
||||
calc_kaslr_offset() unexpectedly. Thus, fix this first.
|
||||
|
||||
Signed-off-by: HATAYAMA Daisuke <d.hatayama@fujitsu.com>
|
||||
---
|
||||
kaslr_helper.c | 22 +++++++++++++---------
|
||||
1 file changed, 13 insertions(+), 9 deletions(-)
|
||||
|
||||
diff --git a/kaslr_helper.c b/kaslr_helper.c
|
||||
index fe5909caa937..acbb5c2692e2 100644
|
||||
--- a/kaslr_helper.c
|
||||
+++ b/kaslr_helper.c
|
||||
@@ -394,10 +394,11 @@ quit:
|
||||
#define PTI_USER_PGTABLE_MASK (1 << PTI_USER_PGTABLE_BIT)
|
||||
#define CR3_PCID_MASK 0xFFFull
|
||||
int
|
||||
-calc_kaslr_offset(ulong *kaslr_offset, ulong *phys_base)
|
||||
+calc_kaslr_offset(ulong *ko, ulong *pb)
|
||||
{
|
||||
uint64_t cr3 = 0, idtr = 0, pgd = 0, idtr_paddr;
|
||||
ulong divide_error_vmcore;
|
||||
+ ulong kaslr_offset, phys_base;
|
||||
ulong kaslr_offset_kdump, phys_base_kdump;
|
||||
int ret = FALSE;
|
||||
int verbose = CRASHDEBUG(1)? 1: 0;
|
||||
@@ -445,9 +446,9 @@ calc_kaslr_offset(ulong *kaslr_offset, ulong *phys_base)
|
||||
|
||||
/* Now we can calculate kaslr_offset and phys_base */
|
||||
divide_error_vmcore = get_vec0_addr(idtr_paddr);
|
||||
- *kaslr_offset = divide_error_vmcore - st->divide_error_vmlinux;
|
||||
- *phys_base = idtr_paddr -
|
||||
- (st->idt_table_vmlinux + *kaslr_offset - __START_KERNEL_map);
|
||||
+ kaslr_offset = divide_error_vmcore - st->divide_error_vmlinux;
|
||||
+ phys_base = idtr_paddr -
|
||||
+ (st->idt_table_vmlinux + kaslr_offset - __START_KERNEL_map);
|
||||
|
||||
if (CRASHDEBUG(1)) {
|
||||
fprintf(fp, "calc_kaslr_offset: idtr=%lx\n", idtr);
|
||||
@@ -465,9 +466,9 @@ calc_kaslr_offset(ulong *kaslr_offset, ulong *phys_base)
|
||||
* from vmcoreinfo
|
||||
*/
|
||||
if (get_kaslr_offset_from_vmcoreinfo(
|
||||
- *kaslr_offset, &kaslr_offset_kdump, &phys_base_kdump)) {
|
||||
- *kaslr_offset = kaslr_offset_kdump;
|
||||
- *phys_base = phys_base_kdump;
|
||||
+ kaslr_offset, &kaslr_offset_kdump, &phys_base_kdump)) {
|
||||
+ kaslr_offset = kaslr_offset_kdump;
|
||||
+ phys_base = phys_base_kdump;
|
||||
} else if (CRASHDEBUG(1)) {
|
||||
fprintf(fp, "kaslr_helper: failed to determine which kernel was running at crash,\n");
|
||||
fprintf(fp, "kaslr_helper: asssuming the kdump 1st kernel.\n");
|
||||
@@ -475,10 +476,13 @@ calc_kaslr_offset(ulong *kaslr_offset, ulong *phys_base)
|
||||
|
||||
if (CRASHDEBUG(1)) {
|
||||
fprintf(fp, "calc_kaslr_offset: kaslr_offset=%lx\n",
|
||||
- *kaslr_offset);
|
||||
- fprintf(fp, "calc_kaslr_offset: phys_base=%lx\n", *phys_base);
|
||||
+ kaslr_offset);
|
||||
+ fprintf(fp, "calc_kaslr_offset: phys_base=%lx\n", phys_base);
|
||||
}
|
||||
|
||||
+ *ko = kaslr_offset;
|
||||
+ *pb = phys_base;
|
||||
+
|
||||
ret = TRUE;
|
||||
quit:
|
||||
vt->kernel_pgd[0] = 0;
|
||||
--
|
||||
2.7.4
|
||||
|
||||
|
||||
From 8b50d94ada21f403665a5e562f40191f111e0313 Mon Sep 17 00:00:00 2001
|
||||
From: HATAYAMA Daisuke <d.hatayama@fujitsu.com>
|
||||
Date: Mon, 27 Jul 2020 19:00:23 +0900
|
||||
Subject: [PATCH 4/4] kaslr: fix failure of calculating kaslr_offset due to an
|
||||
sadump format restriction
|
||||
|
||||
We faced recently a memory dump collected by sadump where unused part
|
||||
of register values are non-zero. For the crash dump, calculating
|
||||
kaslr_offset fails because it is based on the assumption that unused
|
||||
part of register values in the sadump format are always zero cleared.
|
||||
|
||||
The problem is that used and unused part of register values are
|
||||
rigorously indistinguishable in the sadump format. Although there is
|
||||
kernel data structure that represents a map between logical cpu
|
||||
numbers and lapic ids, they cannot be used in order to calculate
|
||||
kaslr_offset.
|
||||
|
||||
To fix this, we have no choice but use a trial-and-error approach: try
|
||||
to use each entry of register values in order until we find a good
|
||||
pair of cr3 and idtr by which we can refer to linux_banner symbol as
|
||||
expected.
|
||||
|
||||
This fix is for the sadump specific issue, so there is no functional
|
||||
change for the other crash dump formats.
|
||||
|
||||
[ lijiang: adjust the code indent. ]
|
||||
|
||||
Signed-off-by: HATAYAMA Daisuke <d.hatayama@fujitsu.com>
|
||||
---
|
||||
kaslr_helper.c | 39 +++++++++++++++++++++++++++++++++++----
|
||||
sadump.c | 52 ++++++++++++++++++++++++++++------------------------
|
||||
2 files changed, 63 insertions(+), 28 deletions(-)
|
||||
|
||||
diff --git a/kaslr_helper.c b/kaslr_helper.c
|
||||
index acbb5c2692e2..bb19e548d04e 100644
|
||||
--- a/kaslr_helper.c
|
||||
+++ b/kaslr_helper.c
|
||||
@@ -406,6 +406,7 @@ calc_kaslr_offset(ulong *ko, ulong *pb)
|
||||
if (!machine_type("X86_64"))
|
||||
return FALSE;
|
||||
|
||||
+retry:
|
||||
if (SADUMP_DUMPFILE()) {
|
||||
if (!sadump_get_cr3_idtr(&cr3, &idtr))
|
||||
return FALSE;
|
||||
@@ -437,12 +438,20 @@ calc_kaslr_offset(ulong *ko, ulong *pb)
|
||||
machdep->machspec->pgdir_shift = PGDIR_SHIFT;
|
||||
machdep->machspec->ptrs_per_pgd = PTRS_PER_PGD;
|
||||
if (!readmem(pgd, PHYSADDR, machdep->pgd, PAGESIZE(),
|
||||
- "pgd", RETURN_ON_ERROR))
|
||||
- goto quit;
|
||||
+ "pgd", RETURN_ON_ERROR)) {
|
||||
+ if (SADUMP_DUMPFILE())
|
||||
+ goto retry;
|
||||
+ else
|
||||
+ goto quit;
|
||||
+ }
|
||||
|
||||
/* Convert virtual address of IDT table to physical address */
|
||||
- if (!kvtop(NULL, idtr, &idtr_paddr, verbose))
|
||||
- goto quit;
|
||||
+ if (!kvtop(NULL, idtr, &idtr_paddr, verbose)) {
|
||||
+ if (SADUMP_DUMPFILE())
|
||||
+ goto retry;
|
||||
+ else
|
||||
+ goto quit;
|
||||
+ }
|
||||
|
||||
/* Now we can calculate kaslr_offset and phys_base */
|
||||
divide_error_vmcore = get_vec0_addr(idtr_paddr);
|
||||
@@ -450,6 +459,28 @@ calc_kaslr_offset(ulong *ko, ulong *pb)
|
||||
phys_base = idtr_paddr -
|
||||
(st->idt_table_vmlinux + kaslr_offset - __START_KERNEL_map);
|
||||
|
||||
+ if (SADUMP_DUMPFILE()) {
|
||||
+ char buf[sizeof("Linux version")];
|
||||
+ ulong linux_banner_paddr;
|
||||
+
|
||||
+ if (!kvtop(NULL,
|
||||
+ st->linux_banner_vmlinux + kaslr_offset,
|
||||
+ &linux_banner_paddr,
|
||||
+ verbose))
|
||||
+ goto retry;
|
||||
+
|
||||
+ if (!readmem(linux_banner_paddr,
|
||||
+ PHYSADDR,
|
||||
+ buf,
|
||||
+ sizeof(buf),
|
||||
+ "linux_banner",
|
||||
+ RETURN_ON_ERROR))
|
||||
+ goto retry;
|
||||
+
|
||||
+ if (!STRNEQ(buf, "Linux version"))
|
||||
+ goto retry;
|
||||
+ }
|
||||
+
|
||||
if (CRASHDEBUG(1)) {
|
||||
fprintf(fp, "calc_kaslr_offset: idtr=%lx\n", idtr);
|
||||
fprintf(fp, "calc_kaslr_offset: pgd=%lx\n", pgd);
|
||||
diff --git a/sadump.c b/sadump.c
|
||||
index 35f7cf0fcf8f..009e17a4a44a 100644
|
||||
--- a/sadump.c
|
||||
+++ b/sadump.c
|
||||
@@ -1664,29 +1664,32 @@ get_sadump_data(void)
|
||||
static int
|
||||
get_sadump_smram_cpu_state_any(struct sadump_smram_cpu_state *smram)
|
||||
{
|
||||
- ulong offset;
|
||||
- struct sadump_header *sh = sd->dump_header;
|
||||
- int apicid;
|
||||
- struct sadump_smram_cpu_state scs, zero;
|
||||
-
|
||||
- offset = sd->sub_hdr_offset + sizeof(uint32_t) +
|
||||
- sd->dump_header->nr_cpus * sizeof(struct sadump_apic_state);
|
||||
-
|
||||
- memset(&zero, 0, sizeof(zero));
|
||||
-
|
||||
- for (apicid = 0; apicid < sh->nr_cpus; ++apicid) {
|
||||
- if (!read_device(&scs, sizeof(scs), &offset)) {
|
||||
- error(INFO, "sadump: cannot read sub header "
|
||||
- "cpu_state\n");
|
||||
- return FALSE;
|
||||
- }
|
||||
- if (memcmp(&scs, &zero, sizeof(scs)) != 0) {
|
||||
- *smram = scs;
|
||||
- return TRUE;
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- return FALSE;
|
||||
+ ulong offset;
|
||||
+ struct sadump_header *sh = sd->dump_header;
|
||||
+ static int apicid;
|
||||
+ struct sadump_smram_cpu_state scs;
|
||||
+
|
||||
+ if (apicid >= sh->nr_cpus)
|
||||
+ return FALSE;
|
||||
+
|
||||
+ offset = sd->sub_hdr_offset + sizeof(uint32_t) +
|
||||
+ sd->dump_header->nr_cpus * sizeof(struct sadump_apic_state) +
|
||||
+ apicid * sizeof(scs);
|
||||
+
|
||||
+ while (apicid < sh->nr_cpus) {
|
||||
+ apicid++;
|
||||
+ if (!read_device(&scs, sizeof(scs), &offset)) {
|
||||
+ error(INFO, "sadump: cannot read sub header "
|
||||
+ "cpu_state\n");
|
||||
+ return FALSE;
|
||||
+ }
|
||||
+ if (scs.Cr3 && (scs.IdtUpper || scs.IdtLower)) {
|
||||
+ *smram = scs;
|
||||
+ return TRUE;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return FALSE;
|
||||
}
|
||||
|
||||
int
|
||||
@@ -1695,7 +1698,8 @@ sadump_get_cr3_idtr(ulong *cr3, ulong *idtr)
|
||||
struct sadump_smram_cpu_state scs;
|
||||
|
||||
memset(&scs, 0, sizeof(scs));
|
||||
- get_sadump_smram_cpu_state_any(&scs);
|
||||
+ if (!get_sadump_smram_cpu_state_any(&scs))
|
||||
+ return FALSE;
|
||||
|
||||
*cr3 = scs.Cr3;
|
||||
*idtr = ((uint64_t)scs.IdtUpper)<<32 | (uint64_t)scs.IdtLower;
|
||||
--
|
||||
2.7.4
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
--- crash-8.0.4/Makefile.orig
|
||||
+++ crash-8.0.4/Makefile
|
||||
@@ -256,7 +256,7 @@ all: make_configure
|
||||
gdb_merge: force
|
||||
@if [ ! -f ${GDB}/README ]; then \
|
||||
$(MAKE) gdb_unzip; fi
|
||||
- @echo "${LDFLAGS} -lz -ldl -rdynamic" > ${GDB}/gdb/mergelibs
|
||||
+ @echo "${LDFLAGS} -lz -llzo2 -lsnappy -lzstd -ldl -rdynamic" > ${GDB}/gdb/mergelibs
|
||||
@echo "../../${PROGRAM} ../../${PROGRAM}lib.a" > ${GDB}/gdb/mergeobj
|
||||
@rm -f ${PROGRAM}
|
||||
@if [ ! -f ${GDB}/config.status ]; then \
|
||||
--- crash-8.0.4/diskdump.c.orig
|
||||
+++ crash-8.0.4/diskdump.c
|
||||
@@ -23,6 +23,9 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
+#define LZO
|
||||
+#define SNAPPY
|
||||
+#define ZSTD
|
||||
#include "defs.h"
|
||||
#include "diskdump.h"
|
||||
#include "xen_dom0.h"
|
154
SPECS/crash.spec
154
SPECS/crash.spec
|
@ -3,31 +3,41 @@
|
|||
#
|
||||
Summary: Kernel analysis utility for live systems, netdump, diskdump, kdump, LKCD or mcore dumpfiles
|
||||
Name: crash
|
||||
Version: 7.2.8
|
||||
Release: 7%{?dist}
|
||||
Version: 8.0.4
|
||||
Release: 2%{?dist}.alma
|
||||
License: GPLv3
|
||||
Group: Development/Debuggers
|
||||
Source0: https://github.com/crash-utility/crash/archive/crash-%{version}.tar.gz
|
||||
Source1: http://ftp.gnu.org/gnu/gdb/gdb-7.6.tar.gz
|
||||
Source1: http://ftp.gnu.org/gnu/gdb/gdb-10.2.tar.gz
|
||||
URL: https://crash-utility.github.io
|
||||
ExclusiveOS: Linux
|
||||
ExclusiveArch: %{ix86} ia64 x86_64 ppc ppc64 s390 s390x %{arm} aarch64 ppc64le
|
||||
Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot-%(%{__id_u} -n)
|
||||
BuildRequires: ncurses-devel zlib-devel lzo-devel bison snappy-devel
|
||||
BuildRequires: ncurses-devel zlib-devel lzo-devel bison snappy-devel wget patch texinfo libzstd-devel
|
||||
BuildRequires: gcc gcc-c++ make
|
||||
Requires: binutils
|
||||
Provides: bundled(gdb) = 7.6
|
||||
Patch0: lzo_snappy.patch
|
||||
Patch1: rhel8_build.patch
|
||||
Patch2: github_b80b16549e24.patch
|
||||
Patch3: github_0f29a8ac6b73.patch
|
||||
Patch4: github_1c45cea02df7.patch
|
||||
Patch5: github_9596b4388ea5.patch
|
||||
Patch6: github_b97e7fd4e826_to_8b50d94ada21.patch
|
||||
Provides: bundled(libiberty)
|
||||
Provides: bundled(gdb) = 10.2
|
||||
Patch0: lzo_snappy_zstd.patch
|
||||
Patch1: crash-8.0.4_build.patch
|
||||
Patch2: 0001-Fix-rd-command-for-zram-data-display-in-Linux-6.2-an.patch
|
||||
Patch3: 0002-Fix-typos-in-offset_table-and-missing-help-o-items.patch
|
||||
Patch4: 0003-zram-Fixes-for-lookup_swap_cache.patch
|
||||
Patch5: 0004-symbols-expand-all-kernel-module-symtable-if-not-all.patch
|
||||
Patch6: 0005-symbols-skip-load-.init.-sections-if-module-was-succ.patch
|
||||
Patch7: 0006-use-NR_SWAPCACHE-when-nr_swapper_spaces-isn-t-availa.patch
|
||||
Patch8: 0007-Fix-identity_map_base-value-dump-on-S390.patch
|
||||
Patch9: 0008-s390x-fix-virtual-vs-physical-address-confusion.patch
|
||||
Patch10: 0009-s390x-uncouple-physical-and-virtual-memory-spaces.patch
|
||||
Patch11: 0010-RISCV64-Dump-NT_PRSTATUS-in-help-n.patch
|
||||
Patch12: 0011-RISCV64-Fix-bt-output-when-no-ra-on-the-stack-top.patch
|
||||
Patch13: 0012-arm64-rewrite-the-arm64_get_vmcoreinfo_ul-to-arm64_g.patch
|
||||
Patch14: 0013-help.c-Remove-kmem-l-help-messages.patch
|
||||
Patch15: 0014-x86_64-check-bt-bptr-before-calculate-framesize.patch
|
||||
|
||||
%description
|
||||
The core analysis suite is a self-contained tool that can be used to
|
||||
investigate either live systems, kernel core dumps created from the
|
||||
netdump, diskdump and kdump packages from Red Hat Linux, the mcore kernel patch
|
||||
netdump, diskdump and kdump packages from AlmaLinux, the mcore kernel patch
|
||||
offered by Mission Critical Linux, or the LKCD kernel patch.
|
||||
|
||||
%package devel
|
||||
|
@ -38,28 +48,36 @@ Group: Development/Debuggers
|
|||
%description devel
|
||||
The core analysis suite is a self-contained tool that can be used to
|
||||
investigate either live systems, kernel core dumps created from the
|
||||
netdump, diskdump and kdump packages from Red Hat Linux, the mcore kernel patch
|
||||
netdump, diskdump and kdump packages from AlmaLinux, the mcore kernel patch
|
||||
offered by Mission Critical Linux, or the LKCD kernel patch.
|
||||
|
||||
%prep
|
||||
%setup -n %{name}-%{version} -q
|
||||
%patch0 -p1 -b lzo_snappy.patch
|
||||
%patch1 -p1 -b rhel8_build.patch
|
||||
%patch2 -p1 -b github_b80b16549e24.patch
|
||||
%patch3 -p1 -b github_0f29a8ac6b73.patch
|
||||
%patch4 -p1 -b github_1c45cea02df7.patch
|
||||
%patch5 -p1 -b github_9596b4388ea5.patch
|
||||
%patch6 -p1 -b github_b97e7fd4e826_to_8b50d94ada21.patch
|
||||
%patch -P 0 -p1 -b lzo_snappy_zstd.patch
|
||||
%patch -P 1 -p1 -b crash-8.0.4_build.patch
|
||||
%patch -P 2 -p1
|
||||
%patch -P 3 -p1
|
||||
%patch -P 4 -p1
|
||||
%patch -P 5 -p1
|
||||
%patch -P 6 -p1
|
||||
%patch -P 7 -p1
|
||||
%patch -P 8 -p1
|
||||
%patch -P 9 -p1
|
||||
%patch -P 10 -p1
|
||||
%patch -P 11 -p1
|
||||
%patch -P 12 -p1
|
||||
%patch -P 13 -p1
|
||||
%patch -P 14 -p1
|
||||
%patch -P 15 -p1
|
||||
|
||||
%build
|
||||
cp %{SOURCE1} .
|
||||
#make RPMPKG="%{version}-%{release}" CFLAGS="%{optflags}"
|
||||
make RPMPKG="%{version}-%{release}" CFLAGS="%{optflags}" LDFLAGS="%{build_ldflags}"
|
||||
make -j`nproc` RPMPKG="%{version}-%{release}" CFLAGS="%{optflags}" CXXFLAGS="%{optflags}" LDFLAGS="%{build_ldflags}"
|
||||
|
||||
%install
|
||||
rm -rf %{buildroot}
|
||||
mkdir -p %{buildroot}%{_bindir}
|
||||
make DESTDIR=%{buildroot} install
|
||||
%make_install
|
||||
mkdir -p %{buildroot}%{_mandir}/man8
|
||||
cp -p crash.8 %{buildroot}%{_mandir}/man8/crash.8
|
||||
mkdir -p %{buildroot}%{_includedir}/crash
|
||||
|
@ -70,16 +88,98 @@ cp -p defs.h %{buildroot}%{_includedir}/crash
|
|||
rm -rf %{buildroot}
|
||||
|
||||
%files
|
||||
%defattr(-,root,root,-)
|
||||
%{_bindir}/crash
|
||||
%{_mandir}/man8/crash.8*
|
||||
%doc README COPYING3
|
||||
|
||||
%files devel
|
||||
%defattr(-,root,root,-)
|
||||
%{_includedir}/*
|
||||
|
||||
%changelog
|
||||
* Wed Mar 27 2024 Eduard Abdullin <eabdullin@almalinux.org> - 8.0.4-2.alma
|
||||
- AlmaLinux changes
|
||||
|
||||
* Tue Jan 02 2024 Lianbo Jiang <lijiang@redhat.com> - 8.0.4-2
|
||||
- Fix the "dis -lr" not displaying the source file names
|
||||
and line numbers
|
||||
- Fix incorrect symbol translation by the 'struct blk_mq_ops'
|
||||
* Fri Nov 17 2023 Lianbo Jiang <lijiang@redhat.com> - 8.0.4-1
|
||||
- Rebase to upstream crash 8.0.4
|
||||
|
||||
* Thu Sep 07 2023 Lianbo Jiang <lijiang@redhat.com> - 8.0.3-1
|
||||
- Rebase to upstream crash-utility 8.0.3
|
||||
- Backport the latest patches from upstream crash-utility
|
||||
|
||||
* Thu Jun 15 2023 Lianbo Jiang <lijiang@redhat.com> - 7.3.2-8
|
||||
- arm64: Fix again segfault in arm64_is_kernel_exception_frame()
|
||||
- Fix invalid structure size error during crash startup on ppc64
|
||||
* Wed Jun 07 2023 Lianbo Jiang <lijiang@redhat.com> - 7.3.2-7
|
||||
- Fix segfault caused by failure of stopping CPUs
|
||||
|
||||
* Mon May 08 2023 Lianbo Jiang <lijiang@redhat.com> - 7.3.2-6
|
||||
- Fix for freelist pointer on PPC64le, ARM64 and S390x
|
||||
|
||||
* Mon May 08 2023 Lianbo Jiang <lijiang@redhat.com> - 7.3.2-5
|
||||
- Update to the latest upstream commit 47216437e79a
|
||||
- ("Fix "net" command on kernel configured with CONFIG_IPV6=m")
|
||||
|
||||
* Mon Nov 21 2022 Lianbo Jiang <lijiang@redhat.com> - 7.3.2-4
|
||||
- Fix for commit 2145b2bb79c5, there are different behaviors between gdb-7.6 and gdb-10.2
|
||||
* Thu Nov 17 2022 Lianbo Jiang <lijiang@redhat.com> - 7.3.2-3
|
||||
- Update to the latest commit a158590f475c from master branch
|
||||
|
||||
* Thu Jun 16 2022 Lianbo Jiang <lijiang@redhat.com> - 7.3.2-2
|
||||
- Enhance "dev -d|-D" options to support blk-mq sbitmap
|
||||
* Mon May 16 2022 Lianbo Jiang <lijiang@redhat.com> - 7.3.2-1
|
||||
- Rebase to upstream crash 7.3.2
|
||||
|
||||
* Tue Feb 08 2022 Lianbo Jiang <lijiang@redhat.com> - 7.3.1-5
|
||||
- Rebuild for osci badfuncs issue
|
||||
|
||||
* Mon Feb 07 2022 Lianbo Jiang <lijiang@redhat.com> - 7.3.1-4
|
||||
- Fix segfault on aarch64 for "bt -a|-c" command
|
||||
- Fix HZ calculation on Linux 5.14 and later
|
||||
- Fix for "timer -r" option to display all the per-CPU clocks
|
||||
|
||||
* Mon Dec 13 2021 Lianbo Jiang <lijiang@redhat.com> - 7.3.1-3
|
||||
- Fix segmentation fault caused by crash extension modules
|
||||
- Support the overflow stack exception handling on aarch64
|
||||
|
||||
* Tue Dec 07 2021 Lianbo Jiang <lijiang@redhat.com> - 7.3.1-2
|
||||
- Enable ZSTD feature support
|
||||
|
||||
* Fri Nov 26 2021 Lianbo Jiang <lijiang@redhat.com> - 7.3.1-1
|
||||
- Rebase to the latest crash-7.3.1
|
||||
|
||||
* Thu Nov 18 2021 Lianbo Jiang <lijiang@redhat.com> - 7.3.0-3
|
||||
- Fix for "sched: Change task_struct::state"
|
||||
- Fix for "sched: move CPU field back into thread_info if THREAD_INFO_IN_TASK=y"
|
||||
- Fix live debugging with lockdown=integrity
|
||||
- Fix 'waitq' command for Linux 4.13 and later kernels
|
||||
- Fix for "kmem -s|-S" option on Linux 5.7 and later kernels
|
||||
|
||||
* Fri May 14 2021 Lianbo Jiang <lijiang@redhat.com> - 7.3.0-2
|
||||
- Update the sha512 hash in the sources file to solve the
|
||||
compilation issues
|
||||
|
||||
* Thu May 13 2021 Lianbo Jiang <lijiang@redhat.com> - 7.3.0-1
|
||||
- Rebase to upstream 7.3.0
|
||||
|
||||
* Tue Dec 1 2020 Bhupesh Sharma <bhsharma@redhat.com> - 7.2.9-2
|
||||
- Fix the sources file to add gdb-7.6 tarball
|
||||
[The line was somehow removed when using rhpkg new-sources to
|
||||
update the crash tarball location]
|
||||
Resolves: rhbz#1881854
|
||||
|
||||
* Tue Dec 1 2020 Bhupesh Sharma <bhsharma@redhat.com> - 7.2.9-1
|
||||
- Rebase to upstream crash version 7.2.9
|
||||
- Also minimize the rhel-only patches to the bare minimum.
|
||||
Resolves: rhbz#1881854
|
||||
|
||||
* Thu Nov 5 2020 Bhupesh Sharma <bhsharma@redhat.com> - 7.2.8-8
|
||||
- crash/arm64: Fix arm64 read error with 'idmap_ptrs_per_pgd' symbol with debug kernel
|
||||
Resolves: rhbz#1876039
|
||||
|
||||
* Mon Aug 17 2020 Bhupesh Sharma <bhsharma@redhat.com> - 7.2.8-7
|
||||
- crash/sadump, kaslr: fix failure of calculating kaslr_offset due to an sadump format restriction
|
||||
Resolves: rhbz#1855527
|
||||
|
|
Loading…
Reference in New Issue