[PATCH 05/16] MIPS64: Add 'pte' command support
by Youling Tang
The pte command converts the pte table entry into a physical address and
displays the page flags. Also fixed the pte part in the vtop command.
E.g. With this patch:
crash> vtop ffffffffc0004000
VIRTUAL PHYSICAL
ffffffffc0004000 2504ac000
SEGMENT: sseg
PAGE DIRECTORY: ffffffff81330000
PGD: ffffffff81333ff8 => 9800000255828000
PMD: 000000025582bf00 => 98000002504bc000
PTE: 00000002504bc008 => 0000001282563e0f
PAGE: 00000002504ac000
PTE PHYSICAL FLAGS
1282563e0f 2504ac000 (PRESENT|WRITE|ACCESSED|MODIFIED|GLOBAL|VALID|DIRTY)
PAGE PHYSICAL MAPPING INDEX CNT FLAGS
9800000257f04ac0 2504ac000 0 0 1 2501fff000000
crash> pte 1282563e0f
PTE PHYSICAL FLAGS
1282563e0f 2504ac000 (PRESENT|WRITE|ACCESSED|MODIFIED|GLOBAL|VALID|DIRTY)
Signed-off-by: Huacai Chen <chenhuacai(a)loongson.cn>
Signed-off-by: Youling Tang <tangyouling(a)loongson.cn>
---
mips64.c | 118 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 118 insertions(+)
diff --git a/mips64.c b/mips64.c
index 21a8206..74f0492 100644
--- a/mips64.c
+++ b/mips64.c
@@ -23,6 +23,9 @@ static int mips64_uvtop(struct task_context *tc, ulong vaddr,
physaddr_t *paddr, int verbose);
static int mips64_kvtop(struct task_context *tc, ulong kvaddr,
physaddr_t *paddr, int verbose);
+static void mips64_init_page_flags(void);
+static int mips64_translate_pte(ulong pte, void *physaddr,
+ ulonglong pte64);
/*
* 3 Levels paging PAGE_SIZE=16KB
@@ -75,6 +78,104 @@ static struct machine_specific mips64_machine_specific = { 0 };
static struct mips64_register *panic_task_regs;
/*
+ * 31 15 14 12 11 10 9 8 7 6 5 4 3 2 1 0
+ * +-------------------+--------+--+--+--+--+--+--+--+--+--+--+--+--+
+ * | VPN | C | D| V| G|RI|XI|SP|PN| H| M| A| W| P|
+ * +-------------------+--------+--+--+--+--+--+--+--+--+--+--+--+--+
+ */
+static void
+mips64_init_page_flags(void)
+{
+ ulong shift = 0;
+
+ _PAGE_PRESENT = 1UL << shift++;
+ _PAGE_WRITE = 1UL << shift++;
+ _PAGE_ACCESSED = 1UL << shift++;
+ _PAGE_MODIFIED = 1UL << shift++;
+ _PAGE_HUGE = 1UL << shift++;
+ _PAGE_PROTNONE = 1UL << shift++;
+
+ if (THIS_KERNEL_VERSION >= LINUX(4,5,0))
+ _PAGE_SPECIAL = 1UL << shift++;
+
+ _PAGE_NO_EXEC = 1UL << shift++;
+ _PAGE_NO_READ = _PAGE_READ = 1UL << shift++;
+ _PAGE_GLOBAL = 1UL << shift++;
+ _PAGE_VALID = 1UL << shift++;
+ _PAGE_DIRTY = 1UL << shift++;
+
+ _PFN_SHIFT = PAGESHIFT() - 12 + shift + 3;
+}
+
+/*
+ * Translate a PTE, returning TRUE if the page is present.
+ * If a physaddr pointer is passed in, don't print anything.
+ */
+static int
+mips64_translate_pte(ulong pte, void *physaddr, ulonglong pte64)
+{
+ char ptebuf[BUFSIZE];
+ char physbuf[BUFSIZE];
+ char buf[BUFSIZE];
+ int page_present;
+ int len1, len2, others;
+ ulong paddr;
+
+ paddr = PTOB(pte >> _PFN_SHIFT);
+ page_present = !!(pte & _PAGE_PRESENT);
+
+ if (physaddr) {
+ *(ulong *)physaddr = paddr;
+ return page_present;
+ }
+
+ sprintf(ptebuf, "%lx", pte);
+ len1 = MAX(strlen(ptebuf), strlen("PTE"));
+ fprintf(fp, "%s ", mkstring(buf, len1, CENTER | LJUST, "PTE"));
+
+ if (!page_present)
+ return page_present;
+
+ sprintf(physbuf, "%lx", paddr);
+ len2 = MAX(strlen(physbuf), strlen("PHYSICAL"));
+ fprintf(fp, "%s ", mkstring(buf, len2, CENTER | LJUST, "PHYSICAL"));
+
+ fprintf(fp, "FLAGS\n");
+ fprintf(fp, "%s %s ",
+ mkstring(ptebuf, len1, CENTER | RJUST, NULL),
+ mkstring(physbuf, len2, CENTER | RJUST, NULL));
+
+ fprintf(fp, "(");
+ others = 0;
+
+#define CHECK_PAGE_FLAG(flag) \
+ if ((_PAGE_##flag) && (pte & _PAGE_##flag)) \
+ fprintf(fp, "%s" #flag, others++ ? "|" : "")
+
+ if (pte) {
+ CHECK_PAGE_FLAG(PRESENT);
+ CHECK_PAGE_FLAG(WRITE);
+ CHECK_PAGE_FLAG(ACCESSED);
+ CHECK_PAGE_FLAG(MODIFIED);
+ CHECK_PAGE_FLAG(HUGE);
+ CHECK_PAGE_FLAG(PROTNONE);
+ CHECK_PAGE_FLAG(SPECIAL);
+ CHECK_PAGE_FLAG(NO_EXEC);
+ CHECK_PAGE_FLAG(NO_READ);
+ CHECK_PAGE_FLAG(READ);
+ CHECK_PAGE_FLAG(GLOBAL);
+ CHECK_PAGE_FLAG(VALID);
+ CHECK_PAGE_FLAG(DIRTY);
+ } else {
+ fprintf(fp, "no mapping");
+ }
+
+ fprintf(fp, ")\n");
+
+ return page_present;
+}
+
+/*
* Virtual to physical memory translation. This function will be called
* by both mips64_kvtop and mips64_uvtop.
*/
@@ -140,6 +241,21 @@ mips64_pgd_vtop(ulong *pgd, ulong vaddr, physaddr_t *paddr, int verbose)
if (!pte_val)
goto no_page;
+ if (!(pte_val & _PAGE_PRESENT)) {
+ if (verbose) {
+ fprintf(fp, "\n");
+ mips64_translate_pte((ulong)pte_val, 0, pte_val);
+ }
+ return FALSE;
+ }
+
+ *paddr = PTOB(pte_val >> _PFN_SHIFT) + PAGEOFFSET(vaddr);
+
+ if (verbose) {
+ fprintf(fp, " PAGE: %016lx\n\n", PAGEBASE(*paddr));
+ mips64_translate_pte(pte_val, 0, 0);
+ }
+
return TRUE;
no_page:
fprintf(fp, "invalid\n");
@@ -327,6 +443,7 @@ mips64_init(int when)
machdep->processor_speed = mips64_processor_speed;
machdep->get_stackbase = generic_get_stackbase;
machdep->get_stacktop = generic_get_stacktop;
+ machdep->translate_pte = mips64_translate_pte;
machdep->memory_size = generic_memory_size;
machdep->is_task_addr = mips64_is_task_addr;
machdep->get_smp_cpus = mips64_get_smp_cpus;
@@ -335,6 +452,7 @@ mips64_init(int when)
break;
case POST_GDB:
+ mips64_init_page_flags();
machdep->section_size_bits = _SECTION_SIZE_BITS;
machdep->max_physmem_bits = _MAX_PHYSMEM_BITS;
break;
--
2.1.0
3 years, 10 months
[PATCH 02/16] MIPS64: Support getting regs from kdump dumpfiles
by Youling Tang
Add support for using the notes in MIPS kdump compressed format dumpfiles.
Signed-off-by: Huacai Chen <chenhuacai(a)loongson.cn>
Signed-off-by: Youling Tang <tangyouling(a)loongson.cn>
---
diskdump.c | 8 +++++++-
mips64.c | 9 +++++++++
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/diskdump.c b/diskdump.c
index 4ad2c50..b5e77da 100644
--- a/diskdump.c
+++ b/diskdump.c
@@ -1470,6 +1470,12 @@ get_diskdump_regs_arm64(struct bt_info *bt, ulong *eip, ulong *esp)
}
static void
+get_diskdump_regs_mips(struct bt_info *bt, ulong *eip, ulong *esp)
+{
+ machdep->get_stack_frame(bt, eip, esp);
+}
+
+static void
get_diskdump_regs_sparc64(struct bt_info *bt, ulong *eip, ulong *esp)
{
Elf64_Nhdr *note;
@@ -1508,7 +1514,7 @@ get_diskdump_regs(struct bt_info *bt, ulong *eip, ulong *esp)
break;
case EM_MIPS:
- return get_diskdump_regs_32(bt, eip, esp);
+ return get_diskdump_regs_mips(bt, eip, esp);
break;
case EM_386:
diff --git a/mips64.c b/mips64.c
index 5ebe61d..c3eb03c 100644
--- a/mips64.c
+++ b/mips64.c
@@ -22,9 +22,18 @@ mips64_dump_machdep_table(ulong arg)
{
}
+/*
+ * Do all necessary machine-specific setup here. This is called several
+ * times during initialization.
+ */
void
mips64_init(int when)
{
+ switch (when) {
+ case SETUP_ENV:
+ machdep->process_elf_notes = process_elf64_notes;
+ break;
+ }
}
void
--
2.1.0
3 years, 10 months
[PATCH 00/16] Add MIPS64 support
by Youling Tang
Initial support is limited to the 64-bit MIPS kernel, configured as little
endian. Regarding dump file types, vmcore and makedumpfile tools can be
used to dump compressed dumpfile files. Does not supports running a live
kernel.
The changes were tested on a mips64 Loongson-3A4000 processor. Can
successfully enter the crash command line and support for common
commands, such as bt, vtop, log commands, etc.
Youling Tang (16):
Add MIPS64 framework code support
MIPS64: Support getting regs from kdump dumpfiles
MIPS64: Add gdb patch for Loongson machine
MIPS64: Make the crash tool successfully enter the crash command line
MIPS64: Add 'pte' command support
MIPS64: Add 'dis' command support
MIPS: Fix display memory size issue
MIPS64: Add to get processor speed
MIPS64: Add 'mach' command support
MIPS64: Add basic support for the 'bt' command
MIPS64: Fixes for the gathering of the active task registers for the
'bt' command
MIPS64: Add 'bt -f' command support
MIPS64: Add 'bt -l' command support
MIPS64: Add the relization of verify symbol
MIPS64: Add 'help -m/M' command support
MIPS64: Add 'help -r' command support
Makefile | 10 +-
configure.c | 35 +-
defs.h | 143 ++++-
diskdump.c | 24 +-
gdb-7.6-loongson.patch | 19 +
lkcd_vmdump_v2_v3.h | 3 +-
memory.c | 28 +-
mips64.c | 1378 ++++++++++++++++++++++++++++++++++++++++++++++++
netdump.c | 4 +
symbols.c | 10 +
10 files changed, 1632 insertions(+), 22 deletions(-)
create mode 100644 gdb-7.6-loongson.patch
create mode 100644 mips64.c
--
2.1.0
3 years, 10 months
Re: [Crash-utility] increase __PHYSICAL_MASK_SHIFT_XEN?
by lijiang
Hi, Jiri
在 2021年01月22日 01:00, crash-utility-request(a)redhat.com 写道:
> Date: Thu, 21 Jan 2021 17:18:29 +0100
> From: Jiri Bohac <jbohac(a)suse.cz>
> To: crash-utility(a)redhat.com
> Cc: anderson(a)redhat.com
> Subject: [Crash-utility] increase __PHYSICAL_MASK_SHIFT_XEN?
> Message-ID: <20210121161829.vizm27sb6pfrgmrl(a)dwarf.suse.cz>
> Content-Type: text/plain; charset=us-ascii
>
> Hi,
>
> I've just come across a situation where crash failed to open a
> dump generated by a 4.12 XEN PV dom0 kernel, terminating with
> this message:
>
> crash: read error: physical address: ffffffffffffffff type: "pud page"
>
> The problem is a failed machine-to-physical translation.
> xen_m2p() returns an error (-1UL) and x86_64_pud_offset() than
> uses that value as a physical address.
>
> I debugged the problem by running crash inside gdb. The backtrace was:
> #0 xen_m2p (machine=973135872) at kernel.c:9714
> #1 0x000000000053ed4a in x86_64_pud_offset (pgd_pte=3299508019303, vaddr=18446744072642223552, verbose=0, IS_XEN=1)
> at x86_64.c:1889
> #2 0x0000000000540c8a in x86_64_kvtop_xen_wpt (tc=0x0, kvaddr=18446744072642223552, paddr=0x7fffffffdb30, verbose=0)
> at x86_64.c:2523
> #3 0x00000000005407d0 in x86_64_kvtop (tc=0x0, kvaddr=18446744072642223552, paddr=0x7fffffffdb30, verbose=0)
> at x86_64.c:2413
> #4 0x0000000000491a97 in kvtop (tc=0x0, kvaddr=18446744072642223552, paddr=0x7fffffffdb30, verbose=0) at memory.c:3062
> #5 0x000000000048f3f0 in readmem (addr=18446744072642223552, memtype=1, buffer=0xba63a0 <shared_bufs>, size=832,
> type=0x92e1f2 "module struct", error_handle=6) at memory.c:2314
> #6 0x00000000005071e2 in module_init () at kernel.c:3699
> ....
>
> I tracked the problem to a wrong value of
> __PHYSICAL_MASK_SHIFT_XEN. The current value of 40 does not
> correspond to the current kernel value of 52 since kernel commit
> 6f0e8bf16730a36ff6773802d8c8df56d10e60cd (xen: support 52 bit
> physical addresses in pv guests).
>
> The result is visible in the above backtrace:
> x86_64_pud_offset() is called with pgd_pte=0x3003a00e067 and that
> value is wrongly masked by "pud_paddr = pgd_pte &
> PHYSICAL_PAGE_MASK" and passed to xen_m2p() as 0x3a00e000 instead
> of 0x3003a00e000, causing the m2p translation to fail.
>
Thank you for sharing the details.
> Setting __PHYSICAL_MASK_SHIFT_XEN to 52 fixes the problem with
> this dump.
>
> But I am not confident it's a safe change. My understanding is
> that it should be safe, as all the unused bits of the physical
> address inside the PTEs should be 0 and thus having the mask wider
> than necessary should not hurt. But I am suspicious if my
> reasoning is correct. Why does crash go into such trouble
> differentiating between different kernels and sets
> machdep->machspec->physical_mask_shift dynamically to one of
> __PHYSICAL_MASK_SHIFT_XEN (40), __PHYSICAL_MASK_SHIFT_2_6 (46),
The reason is that the supported kernel virtual address allows to
be configured on other architectures, and that still relies on the
hardware capability.
> and __PHYSICAL_MASK_SHIFT_5LEVEL (52)? Would something break if
> it were always set to 52? The commit adding the logic is
> 307e7f35.
>
It's time to update the physical mask for xen, but can you help to
test the address translation via some command such as vtop, ptov,
etc? Or follow up the 5-level page changes to check if it has the
capability(cr4 & CR4_LA57)?
Thanks.
Lianbo
> Thanks,
>
> -- Jiri Bohac <jbohac(a)suse.cz> SUSE Labs, Prague, Czechia
3 years, 10 months
Re: [Crash-utility] [PATCH] Fix "kmem -v" option on Linux 5.11-rc1 and later kernels
by lijiang
在 2021年01月19日 17:43, crash-utility-request(a)redhat.com 写道:
> Date: Tue, 19 Jan 2021 09:42:54 +0000
> From: HAGIO KAZUHITO(?????) <k-hagio-ab(a)nec.com>
> To: "crash-utility(a)redhat.com" <crash-utility(a)redhat.com>
> Subject: [Crash-utility] [PATCH] Fix "kmem -v" option on Linux
> 5.11-rc1 and later kernels
> Message-ID:
> <OSBPR01MB19911991A7F295330CBC0AC5DDA30(a)OSBPR01MB1991.jpnprd01.prod.outlook.com>
>
> Content-Type: text/plain; charset="iso-2022-jp"
>
> Fix the "kmem -v" option on Linux 5.11-rc1 and later kernels
> that contains commit 96e2db456135db0cf2476b6890f1e8b2fdcf21eb
> ("mm/vmalloc: rework the drain logic"). Without the patch,
> the option will display nothing or fail with the error message
> "kmem: invalid kernel virtual address: <address> type: "vmlist addr".
>
> Signed-off-by: Kazuhito Hagio <k-hagio-ab(a)nec.com>
> ---
> memory.c | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/memory.c b/memory.c
> index 0848097eb4f5..33b0ca7af977 100644
> --- a/memory.c
> +++ b/memory.c
> @@ -403,8 +403,6 @@ vm_init(void)
> VALID_MEMBER(vmap_area_va_end) &&
> VALID_MEMBER(vmap_area_list) &&
> VALID_MEMBER(vmap_area_vm) &&
> - (VALID_MEMBER(vmap_area_flags) ||
> - (OFFSET(vmap_area_vm) == MEMBER_OFFSET("vmap_area", "purge_list"))) &&
> kernel_symbol_exists("vmap_area_list"))
> vt->flags |= USE_VMAP_AREA;
Also looks good. Acked-by: Lianbo Jiang <lijiang(a)redhat.com>
>
> -- 2.18.4
3 years, 10 months
Re: [Crash-utility] [PATCH] Fix "dev -d" option on Linux 5.11-rc1 and later kernels
by lijiang
Hi, Kazu
Thanks for the fix.
在 2021年01月19日 17:43, crash-utility-request(a)redhat.com 写道:
> Date: Tue, 19 Jan 2021 06:03:39 +0000
> From: HAGIO KAZUHITO(?????) <k-hagio-ab(a)nec.com>
> To: "crash-utility(a)redhat.com" <crash-utility(a)redhat.com>
> Subject: [Crash-utility] [PATCH] Fix "dev -d" option on Linux 5.11-rc1
> and later kernels
> Message-ID:
> <OSBPR01MB19917F02662F0F017A3E7062DDA30(a)OSBPR01MB1991.jpnprd01.prod.outlook.com>
>
> Content-Type: text/plain; charset="iso-2022-jp"
>
> Fix the "dev -d" option on Linux 5.11-rc1 and later kernels that
> contains commit 0d02129e76edf91cf04fabf1efbc3a9a1f1d729a
> ("block: merge struct block_device and struct hd_struct").
> Without the patch, the option fails with the error message
> "dev: invalid structure member offset: hd_struct_dev".
>
This change looks good. Acked-by: Lianbo Jiang <lijiang(a)redhat.com>
> Signed-off-by: Kazuhito Hagio <k-hagio-ab(a)nec.com>
> ---
> defs.h | 2 ++
> dev.c | 29 +++++++++++++++++++++++++----
> symbols.c | 4 ++++
> 3 files changed, 31 insertions(+), 4 deletions(-)
>
> diff --git a/defs.h b/defs.h
> index e468b1d99fcf..ffbe73bfb508 100644
> --- a/defs.h
> +++ b/defs.h
> @@ -2128,6 +2128,8 @@ struct offset_table { /* stash of commonly-used offsets */
> long prb_data_ring_size_bits;
> long prb_data_ring_data;
> long atomic_long_t_counter;
> + long block_device_bd_device;
> + long block_device_bd_stats;
> };
>
> struct size_table { /* stash of commonly-used sizes */
> diff --git a/dev.c b/dev.c
> index 56e84ab9007c..effe789f38d8 100644
> --- a/dev.c
> +++ b/dev.c
> @@ -4067,13 +4067,22 @@ get_gendisk_5(unsigned long entry)
> {
> unsigned long device_address;
> unsigned long device_private_address;
> + unsigned long gendisk;
>
> device_private_address = entry - OFFSET(device_private_knode_class);
> readmem(device_private_address + OFFSET(device_private_device),
> KVADDR, &device_address, sizeof(device_address),
> "device_private.device", FAULT_ON_ERROR);
>
> - return device_address - OFFSET(hd_struct_dev) - OFFSET(gendisk_part0);
> + if (VALID_MEMBER(hd_struct_dev))
> + return device_address - OFFSET(hd_struct_dev) - OFFSET(gendisk_part0);
> +
> + /* kernel version >= 5.11 */
> + readmem(device_address - OFFSET(block_device_bd_device) +
> + OFFSET(block_device_bd_disk), KVADDR, &gendisk,
> + sizeof(ulong), "block_device.bd_disk", FAULT_ON_ERROR);
> +
> + return gendisk;
> }
>
> /* 2.6.24 < kernel version <= 2.6.27 */
> @@ -4290,9 +4299,19 @@ get_diskio_1(unsigned long rq, unsigned long gendisk, struct diskio *io)
> io->read = count[0];
> io->write = count[1];
> } else {
> - readmem(gendisk + OFFSET(gendisk_part0) +
> - OFFSET(hd_struct_dkstats), KVADDR, &dkstats,
> - sizeof(ulong), "gendisk.part0.dkstats", FAULT_ON_ERROR);
> + if (VALID_MEMBER(hd_struct_dkstats))
> + readmem(gendisk + OFFSET(gendisk_part0) +
> + OFFSET(hd_struct_dkstats), KVADDR, &dkstats,
> + sizeof(ulong), "gendisk.part0.dkstats", FAULT_ON_ERROR);
> + else { /* kernel version >= 5.11 */
> + ulong block_device;
> + readmem(gendisk + OFFSET(gendisk_part0), KVADDR, &block_device,
> + sizeof(ulong), "gendisk.part0", FAULT_ON_ERROR);
> + readmem(block_device + OFFSET(block_device_bd_stats), KVADDR,
> + &dkstats, sizeof(ulong), "block_device.bd_stats",
> + FAULT_ON_ERROR);
> + }
> +
> get_one_diskio_from_dkstats(dkstats, io_counts);
>
> io->read = io_counts[0];
> @@ -4549,6 +4568,8 @@ void diskio_init(void)
> MEMBER_OFFSET_INIT(gendisk_queue, "gendisk", "queue");
> MEMBER_OFFSET_INIT(hd_struct_dev, "hd_struct", "__dev");
> MEMBER_OFFSET_INIT(hd_struct_dkstats, "hd_struct", "dkstats");
> + MEMBER_OFFSET_INIT(block_device_bd_device, "block_device", "bd_device");
> + MEMBER_OFFSET_INIT(block_device_bd_stats, "block_device", "bd_stats");
> MEMBER_OFFSET_INIT(klist_k_list, "klist", "k_list");
> MEMBER_OFFSET_INIT(klist_node_n_klist, "klist_node", "n_klist");
> MEMBER_OFFSET_INIT(klist_node_n_node, "klist_node", "n_node");
> diff --git a/symbols.c b/symbols.c
> index a51078d58e6b..ed5f731fa1b3 100644
> --- a/symbols.c
> +++ b/symbols.c
> @@ -9291,6 +9291,10 @@ dump_offset_table(char *spec, ulong makestruct)
> OFFSET(block_device_bd_list));
> fprintf(fp, " block_device_bd_disk: %ld\n",
> OFFSET(block_device_bd_disk));
> + fprintf(fp, " block_device_bd_device: %ld\n",
> + OFFSET(block_device_bd_device));
> + fprintf(fp, " block_device_bd_stats: %ld\n",
> + OFFSET(block_device_bd_stats));
> fprintf(fp, " address_space_nrpages: %ld\n",
> OFFSET(address_space_nrpages));
> fprintf(fp, " address_space_page_tree: %ld\n",
> -- 2.18.4
3 years, 10 months
[PATCH] Show the module's base address for "mod" command
by Yunfeng Ye
Currently the "mod" command show the address of the module struct,
it is inconvenient to know the address range of the module, so extend
to show the base adddress for "mod" command.
Signed-off-by: Yunfeng Ye <yeyunfeng(a)huawei.com>
---
kernel.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/kernel.c b/kernel.c
index 272e0d8751cf..9391c5b37a15 100644
--- a/kernel.c
+++ b/kernel.c
@@ -4473,6 +4473,7 @@ do_module_cmd(ulong flag, char *modref, ulong address,
char buf1[BUFSIZE];
char buf2[BUFSIZE];
char buf3[BUFSIZE];
+ char buf4[BUFSIZE];
if (NO_MODULES())
return;
@@ -4494,10 +4495,12 @@ do_module_cmd(ulong flag, char *modref, ulong address,
}
if (flag == LIST_MODULE_HDR) {
- fprintf(fp, "%s %s %s OBJECT FILE\n",
+ fprintf(fp, "%s %s %s %s OBJECT FILE\n",
mkstring(buf1, VADDR_PRLEN, CENTER|LJUST,
"MODULE"),
mkstring(buf2, maxnamelen, LJUST, "NAME"),
+ mkstring(buf4, VADDR_PRLEN, CENTER|LJUST,
+ "BASE"),
mkstring(buf3, maxsizelen, RJUST, "SIZE"));
}
@@ -4509,6 +4512,8 @@ do_module_cmd(ulong flag, char *modref, ulong address,
LONG_HEX|RJUST, MKSTR(lm->module_struct)));
fprintf(fp, "%s ", mkstring(buf2, maxnamelen,
LJUST, lm->mod_name));
+ fprintf(fp, "%s ", mkstring(buf4, VADDR_PRLEN,
+ LONG_HEX|RJUST, MKSTR(lm->mod_base)));
fprintf(fp, "%s ", mkstring(buf3, maxsizelen,
RJUST|LONG_DEC, MKSTR(lm->mod_size)));
// fprintf(fp, "%6ld ", lm->mod_size);
--
2.27.0
3 years, 10 months
Re: [Crash-utility] [PATCH] Show the module's base address for "mod" command
by lijiang
在 2021年01月25日 14:55, crash-utility-request(a)redhat.com 写道:
>> Currently the "mod" command show the address of the module struct,
>> it is inconvenient to know the address range of the module, so extend
>> to show the base adddress for "mod" command.
>>
>> Signed-off-by: Yunfeng Ye <yeyunfeng(a)huawei.com>
> Thanks for the patch, it looks good and would be useful.
>
> Acked-by: Kazuhito Hagio <k-hagio-ab(a)nec.com>
>
> Please wait for another ack.
>
> Lianbo, Bhupesh, I will update the help page this time.
>
Sounds pretty good. Please go ahead, Kazu.
Thanks.
Lianbo
> Thanks,
> Kazu
>
3 years, 10 months
Re: [Crash-utility] [PATCH] Show the module's base address for "mod" command
by lijiang
Hi,Shiyuan
Thank you for the patch.
在 2021年01月19日 17:43, crash-utility-request(a)redhat.com 写道:
> Date: Tue, 19 Jan 2021 10:02:17 +0800
> From: Yunfeng Ye <yeyunfeng(a)huawei.com>
> To: <crash-utility(a)redhat.com>
> Cc: Hewenliang <hewenliang4(a)huawei.com>, Shiyuan Hu
> <hushiyuan(a)huawei.com>
> Subject: [Crash-utility] [PATCH] Show the module's base address for
> "mod" command
> Message-ID: <f1f1ae61-1526-a7d5-ff07-493a1579ff3d(a)huawei.com>
> Content-Type: text/plain; charset="utf-8"
>
> Currently the "mod" command show the address of the module struct,
> it is inconvenient to know the address range of the module, so extend
> to show the base adddress for "mod" command.
Acked-by: Lianbo Jiang <lijiang(a)redhat.com>
>
> Signed-off-by: Yunfeng Ye <yeyunfeng(a)huawei.com>
> ---
> kernel.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/kernel.c b/kernel.c
> index 272e0d8751cf..9391c5b37a15 100644
> --- a/kernel.c
> +++ b/kernel.c
> @@ -4473,6 +4473,7 @@ do_module_cmd(ulong flag, char *modref, ulong address,
> char buf1[BUFSIZE];
> char buf2[BUFSIZE];
> char buf3[BUFSIZE];
> + char buf4[BUFSIZE];
>
> if (NO_MODULES())
> return;
> @@ -4494,10 +4495,12 @@ do_module_cmd(ulong flag, char *modref, ulong address,
> }
>
> if (flag == LIST_MODULE_HDR) {
> - fprintf(fp, "%s %s %s OBJECT FILE\n",
> + fprintf(fp, "%s %s %s %s OBJECT FILE\n",
> mkstring(buf1, VADDR_PRLEN, CENTER|LJUST,
> "MODULE"),
> mkstring(buf2, maxnamelen, LJUST, "NAME"),
> + mkstring(buf4, VADDR_PRLEN, CENTER|LJUST,
> + "BASE"),
> mkstring(buf3, maxsizelen, RJUST, "SIZE"));
> }
>
> @@ -4509,6 +4512,8 @@ do_module_cmd(ulong flag, char *modref, ulong address,
> LONG_HEX|RJUST, MKSTR(lm->module_struct)));
> fprintf(fp, "%s ", mkstring(buf2, maxnamelen,
> LJUST, lm->mod_name));
> + fprintf(fp, "%s ", mkstring(buf4, VADDR_PRLEN,
> + LONG_HEX|RJUST, MKSTR(lm->mod_base)));
> fprintf(fp, "%s ", mkstring(buf3, maxsizelen,
> RJUST|LONG_DEC, MKSTR(lm->mod_size)));
> // fprintf(fp, "%6ld ", lm->mod_size);
> -- 2.27.0
3 years, 10 months
Re: [Crash-utility] [PATCH] Fix "sys [-t]|mod -S" after "mod -t" when crash runs with -s option
by lijiang
Hi, Kazu
在 2021年01月21日 01:00, crash-utility-request(a)redhat.com 写道:
> Date: Wed, 20 Jan 2021 06:16:24 +0000
> From: HAGIO KAZUHITO(?????) <k-hagio-ab(a)nec.com>
> To: "crash-utility(a)redhat.com" <crash-utility(a)redhat.com>
> Subject: [Crash-utility] [PATCH] Fix "sys [-t]|mod -S" after "mod -t"
> when crash runs with -s option
> Message-ID:
> <OSBPR01MB199187BDE9E90C416DF2B327DDA20(a)OSBPR01MB1991.jpnprd01.prod.outlook.com>
>
> Content-Type: text/plain; charset="iso-2022-jp"
>
> When crash runs with -s option, SIZE(taint_flag) and OFFSET(tnt_false)
> are not set during initialization. If the "mod -t" option is executed,
> it sets the former but does not set the latter. After that, the "sys"
> command uses OFFSET(tnt_false) without setting it, because it checks
> only if SIZE(taint_flag) is set.
>
> Without the patch, the "sys [-t]" and "mod -S" options after "mod -t"
> option fail with the error message:
>
Hmm, I also ran into a similar issue with an old vmcore, that can be reproduced
with the following steps:
crash> history
[1] mod -S 3.10.0-957.el7.x86_64
[2] mod -s dm_service_time
[3] set scope st_create
[4] mod -d dm_service_time
[5] mod -sr dm_service_time
[6] set scope st_create
[7] sys
[8] set scope st_create
And after the step[7] "sys" command, the step[8] will definitely fail. But step[6]
is successful before the "sys" command.
Seems that it should be another issue.
Thanks.
Lianbo
> sys: invalid structure member offset: tnt_false
> FILE: kernel.c LINE: 11203 FUNCTION: show_kernel_taints_v4_10()
>
> Signed-off-by: Kazuhito Hagio <k-hagio-ab(a)nec.com>
> ---
> kernel.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/kernel.c b/kernel.c
> index 272e0d8751cf..5fcd86575be5 100644
> --- a/kernel.c
> +++ b/kernel.c
> @@ -11160,7 +11160,8 @@ show_kernel_taints_v4_10(char *buf, int verbose)
> ulong tainted_mask, *tainted_mask_ptr;
> struct syment *sp;
>
> - if (!VALID_STRUCT(taint_flag)) {
> + if (!(VALID_STRUCT(taint_flag) &&
> + VALID_MEMBER(tnt_true) && VALID_MEMBER(tnt_false))) {
> STRUCT_SIZE_INIT(taint_flag, "taint_flag");
> MEMBER_OFFSET_INIT(tnt_true, "taint_flag", "true");
> MEMBER_OFFSET_INIT(tnt_false, "taint_flag", "false");
> -- 2.18.4
3 years, 10 months