[PATCH 0/3] Some minor modifications
by Youling Tang
Youling Tang (3):
defs.h: Fix the value of TIF_SIGPENDING macro
MIPS64: Modify the comment of mips64_register structure
MIPS64: Add support for ramdump type
defs.h | 18 +++++++++---------
ramdump.c | 2 +-
2 files changed, 10 insertions(+), 10 deletions(-)
--
2.1.0
3 years, 5 months
[PATCH] MIPS32/64: Add 'irq' command support
by Youling Tang
Added support for the 'irq' series of commands in the MIPS32/64 architecture,
except for the 'irq -d' command, others can be used.
The result of using the 'irq' command without this patch is as follows:
irq: cannot determine number of IRQs
Signed-off-by: Youling Tang <tangyouling(a)loongson.cn>
---
mips.c | 10 ++++++++--
mips64.c | 14 ++++++++++++++
2 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/mips.c b/mips.c
index f73dfad..d6602e3 100644
--- a/mips.c
+++ b/mips.c
@@ -1126,8 +1126,14 @@ mips_init(int when)
machdep->get_irq_affinity = generic_get_irq_affinity;
machdep->section_size_bits = _SECTION_SIZE_BITS;
machdep->max_physmem_bits = _MAX_PHYSMEM_BITS;
- ARRAY_LENGTH_INIT(machdep->nr_irqs, irq_desc,
- "irq_desc", NULL, 0);
+
+ if (symbol_exists("irq_desc"))
+ ARRAY_LENGTH_INIT(machdep->nr_irqs, irq_desc,
+ "irq_desc", NULL, 0);
+ else if (kernel_symbol_exists("nr_irqs"))
+ get_symbol_data("nr_irqs", sizeof(unsigned int),
+ &machdep->nr_irqs);
+
mips_stackframe_init();
if (!machdep->hz)
diff --git a/mips64.c b/mips64.c
index 62ed799..b1d6acf 100644
--- a/mips64.c
+++ b/mips64.c
@@ -1160,6 +1160,9 @@ mips64_dump_machdep_table(ulong arg)
fprintf(fp, " is_task_addr: mips64_is_task_addr()\n");
fprintf(fp, " verify_symbol: mips64_verify_symbol()\n");
fprintf(fp, " dis_filter: generic_dis_filter()\n");
+ fprintf(fp, " dump_irq: generic_dump_irq()\n");
+ fprintf(fp, " show_interrupts: generic_show_interrupts()\n");
+ fprintf(fp, " get_irq_affinity: generic_get_irq_affinity()\n");
fprintf(fp, " cmd_mach: mips64_cmd_mach()\n");
fprintf(fp, " get_smp_cpus: mips64_get_smp_cpus()\n");
fprintf(fp, " is_kvaddr: generic_is_kvaddr()\n");
@@ -1246,6 +1249,9 @@ mips64_init(int when)
machdep->is_task_addr = mips64_is_task_addr;
machdep->get_smp_cpus = mips64_get_smp_cpus;
machdep->dis_filter = generic_dis_filter;
+ machdep->dump_irq = generic_dump_irq;
+ machdep->show_interrupts = generic_show_interrupts;
+ machdep->get_irq_affinity = generic_get_irq_affinity;
machdep->value_to_symbol = generic_machdep_value_to_symbol;
machdep->init_kernel_pgd = NULL;
break;
@@ -1257,6 +1263,14 @@ mips64_init(int when)
mips64_stackframe_init();
if (!machdep->hz)
machdep->hz = 250;
+
+ if (symbol_exists("irq_desc"))
+ ARRAY_LENGTH_INIT(machdep->nr_irqs, irq_desc,
+ "irq_desc", NULL, 0);
+ else if (kernel_symbol_exists("nr_irqs"))
+ get_symbol_data("nr_irqs", sizeof(unsigned int),
+ &machdep->nr_irqs);
+
MEMBER_OFFSET_INIT(elf_prstatus_pr_reg, "elf_prstatus",
"pr_reg");
STRUCT_SIZE_INIT(note_buf, "note_buf_t");
--
2.1.0
3 years, 5 months
[PATCH] kmem: Add support for SECTION_TAINT_ZONE flag
by HAGIO KAZUHITO(萩尾 一仁)
Fix for the "kmem {-n|-p}" options on Linux 5.12-rc1 and later kernels
that contain commit 1f90a3477df3f ("mm: teach pfn_to_online_page()
about ZONE_DEVICE section collisions"). Without the patch, the
"kmem -n" option incorrectly shows mem_map addresses containing the
flag in bit 5 as part of the virtual address, and also the "kmem -p"
option shows page structures at wrong position. With the patch,
the "kmem -n" option displays the new "D" state flag.
Without the patch:
crash> kmem -n
...
NR SECTION CODED_MEM_MAP MEM_MAP STATE PFN
1040 ffff9edf3ffd4100 ffffe2bcc0000010 ffffe2bd42000010 PMOE 34078720
^ ^
crash> kmem -p
PAGE PHYSICAL MAPPING INDEX CNT FLAGS
ffffe2bd42000010 2080000000 400040 1ffffffff 9961471 dead000000000122 referenced,active,error
ffffe2bd42000050 2080001000 800080 1ffffffff 9961471 dead000000000122 referenced,active,error
ffffe2bd42000090 2080002000 0 1ffffffff 9961471 dead000000000122 referenced,active,error
^^
With the patch:
crash> kmem -n
...
NR SECTION CODED_MEM_MAP MEM_MAP STATE PFN
1040 ffff9edf3ffd4100 ffffe2bcc0000000 ffffe2bd42000000 PMOED 34078720
crash> kmem -p
PAGE PHYSICAL MAPPING INDEX CNT FLAGS
ffffe2bd42000000 2080000000 ffff9ebfc0044100 0 1 97ffffc0000200 slab
ffffe2bd42000040 2080001000 ffff9ebfc0044400 0 1 97ffffc0000200 slab
ffffe2bd42000080 2080002000 0 0 1 97ffffc0000000
Signed-off-by: Kazuhito Hagio <k-hagio-ab(a)nec.com>
---
help.c | 12 ++++++++----
memory.c | 15 +++++++++------
2 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/help.c b/help.c
index e0c84087add3..7734281166eb 100644
--- a/help.c
+++ b/help.c
@@ -6584,10 +6584,14 @@ char *help_kmem[] = {
" kernels, the vm_zone_stat, vm_node_stat and vm_numa_stat tables,",
" the cumulative page_states counter values if they exist, and/or ",
" the cumulative, vm_event_states counter values if they exist.",
-" -n display memory node, memory section, and memory block data",
-" and state; the state of each memory section state is encoded",
-" as \"P\", \"M\", \"O\" and/or \"E\", meaning SECTION_MARKED_PRESENT,",
-" SECTION_HAS_MEM_MAP, SECTION_IS_ONLINE and SECTION_IS_EARLY.",
+" -n display memory node, memory section, memory block data and state;",
+" the state of each memory section is shown as the following flags",
+" respectively:",
+" \"P\": SECTION_MARKED_PRESENT",
+" \"M\": SECTION_HAS_MEM_MAP",
+" \"O\": SECTION_IS_ONLINE",
+" \"E\": SECTION_IS_EARLY",
+" \"D\": SECTION_TAINT_ZONE_DEVICE",
" -z displays per-zone memory statistics.",
" -o displays each cpu's offset value that is added to per-cpu symbol",
" values to translate them into kernel virtual addresses.",
diff --git a/memory.c b/memory.c
index 8c6bbe409922..7bc9a2cd6d0e 100644
--- a/memory.c
+++ b/memory.c
@@ -17269,12 +17269,13 @@ nr_to_section(ulong nr)
* which results in PFN_SECTION_SHIFT equal 6.
* To sum it up, at least 6 bits are available.
*/
-#define SECTION_MARKED_PRESENT (1UL<<0)
-#define SECTION_HAS_MEM_MAP (1UL<<1)
-#define SECTION_IS_ONLINE (1UL<<2)
-#define SECTION_IS_EARLY (1UL<<3)
-#define SECTION_MAP_LAST_BIT (1UL<<4)
-#define SECTION_MAP_MASK (~(SECTION_MAP_LAST_BIT-1))
+#define SECTION_MARKED_PRESENT (1UL<<0)
+#define SECTION_HAS_MEM_MAP (1UL<<1)
+#define SECTION_IS_ONLINE (1UL<<2)
+#define SECTION_IS_EARLY (1UL<<3)
+#define SECTION_TAINT_ZONE_DEVICE (1UL<<4)
+#define SECTION_MAP_LAST_BIT (1UL<<5)
+#define SECTION_MAP_MASK (~(SECTION_MAP_LAST_BIT-1))
int
@@ -17372,6 +17373,8 @@ fill_mem_section_state(ulong state, char *buf)
bufidx += sprintf(buf + bufidx, "%s", "O");
if (state & SECTION_IS_EARLY)
bufidx += sprintf(buf + bufidx, "%s", "E");
+ if (state & SECTION_TAINT_ZONE_DEVICE)
+ bufidx += sprintf(buf + bufidx, "%s", "D");
}
void
--
2.27.0
3 years, 5 months
[PATCH] Fix for "kmem -n" option to display NID correctly
by HAGIO KAZUHITO(萩尾 一仁)
The nid member of struct memory_block is a 4-byte integer, but read
and printed as a 8-byte integer on 64-bit machines. Without the patch,
the option displays wrong NIDs.
crash> kmem -n
...
MEM_BLOCK NAME PHYSICAL RANGE NODE STATE START_SECTION_NO
ffff9edeff2b9400 memory0 0 - 7fffffff 14195095130662240256 ONLINE 0
ffff9edeff2bb400 memory2 100000000 - 17fffffff 14195094718345379840 ONLINE 32
The issue seems to appear on Linux 5.12 and later kernels that contain
commit e9a2e48e8704c ("drivers/base/memory: don't store phys_device in
memory blocks"), which changed the arrangement of the members of struct
memory_block.
Signed-off-by: Kazuhito Hagio <k-hagio-ab(a)nec.com>
---
memory.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/memory.c b/memory.c
index 8c6bbe409922..600f2de336d9 100644
--- a/memory.c
+++ b/memory.c
@@ -17564,13 +17564,13 @@ print_memory_block(ulong memory_block)
if (MEMBER_EXISTS("memory_block", "nid")) {
readmem(memory_block + OFFSET(memory_block_nid), KVADDR, &nid,
- sizeof(void *), "memory_block nid", FAULT_ON_ERROR);
+ sizeof(int), "memory_block nid", FAULT_ON_ERROR);
fprintf(fp, " %s %s %s %s %s %s\n",
mkstring(buf1, VADDR_PRLEN, LJUST|LONG_HEX,
MKSTR(memory_block)),
mkstring(buf2, 12, CENTER, name),
parangebuf,
- mkstring(buf5, strlen("NODE"), CENTER|LONG_DEC,
+ mkstring(buf5, strlen("NODE"), CENTER|INT_DEC,
MKSTR(nid)),
mkstring(buf6, strlen("OFFLINE"), LJUST,
statebuf),
--
2.27.0
3 years, 5 months
Re: [Crash-utility] [PATCHv5 1/3] crash-utility/arm64: store phy_offset and memstart_addr separately
by lijiang
Hi, Pingfan
Thank you for the update.
> This bug connects with kernel commit 7bc1a0f9e176 ("arm64: mm: use> single quantity to represent the PA to VA translation"), memstart_addr> can be negative, which makes it different from real phys_offset. If> using memstart_addr to calculate the real paddr, the unreasonable paddr> will be got.
> Furthermore, in crash utility, PTOV() needs memstart_addr to calculate> VA from PA, while getting PFN offset in a dumpfile, phys_offset is> required.
As you mentioned above, the calculation formula has been changed, how to
deal with the backward compatibility issue? Should we use kernel version
to determine which code branch it should execute? Please correct me if I
was wrong.
Thanks.
Lianbo
> To serve the different purpose, using phys_offset_nominal and>
phys_offset to store them.
3 years, 5 months
[PATCH] Fix the "kmem -s" option for Linux 5.7 and later kernels
by Lianbo Jiang
Linux 5.7 and later kernels that contain kernel commit <1ad53d9fa3f6>
("slub: improve bit diffusion for freelist ptr obfuscation") changed
the calculation formula in the freelist_ptr(), which added a swab()
call to mix bits a little more. When kernel is built with the
"CONFIG_SLAB_FREELIST_HARDENED=y",the "kmem -s" option fails with the
following errors, if there is no such patch.
crash> kmem -s
CACHE OBJSIZE ALLOCATED TOTAL SLABS SSIZE NAME
82166d00 144 0 0 0 4k fuse_request
82166e00 792 0 0 0 16k fuse_inode
87201e00 528 0 0 0 8k xfs_dqtrx
87201f00 496 0 0 0 8k xfs_dquot
kmem: xfs_buf: slab: 37202e6e900 invalid freepointer: b844bab900001d70
kmem: xfs_buf: slab: 3720250fd80 invalid freepointer: b8603f9400001370
...
Signed-off-by: Lianbo Jiang <lijiang(a)redhat.com>
---
memory.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/memory.c b/memory.c
index 8c6bbe409922..a3cf8a86728d 100644
--- a/memory.c
+++ b/memory.c
@@ -20,6 +20,7 @@
#include <sys/mman.h>
#include <ctype.h>
#include <netinet/in.h>
+#include <byteswap.h>
struct meminfo { /* general purpose memory information structure */
ulong cache; /* used by the various memory searching/dumping */
@@ -19336,10 +19337,14 @@ count_free_objects(struct meminfo *si, ulong freelist)
static ulong
freelist_ptr(struct meminfo *si, ulong ptr, ulong ptr_addr)
{
- if (VALID_MEMBER(kmem_cache_random))
+ if (VALID_MEMBER(kmem_cache_random)) {
/* CONFIG_SLAB_FREELIST_HARDENED */
+
+ if (THIS_KERNEL_VERSION >= LINUX(5,7,0))
+ ptr_addr = (sizeof(long) == 8) ? bswap_64(ptr_addr)
+ : bswap_32(ptr_addr);
return (ptr ^ si->random ^ ptr_addr);
- else
+ } else
return ptr;
}
--
2.17.1
3 years, 5 months