crash/0012-mod-Show-the-base-addr...

221 lines
11 KiB
Diff

From 33c322e9295b0453db4152d0f7c962ced2944c78 Mon Sep 17 00:00:00 2001
From: Yunfeng Ye <yeyunfeng@huawei.com>
Date: Tue, 19 Jan 2021 10:02:17 +0800
Subject: [PATCH 12/13] mod: Show the base address of module
Currently the "mod" command shows the address of the module struct,
it is inconvenient to know the address range of the module, so extend
to show the base adddress.
[ kh: added help page update ]
Signed-off-by: Yunfeng Ye <yeyunfeng@huawei.com>
Signed-off-by: Kazuhito Hagio <k-hagio-ab@nec.com>
Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
---
help.c | 126 +++++++++++++++++++------------------------------------
kernel.c | 7 +++-
2 files changed, 48 insertions(+), 85 deletions(-)
diff --git a/help.c b/help.c
index 7c9455f87758..587c7173f495 100644
--- a/help.c
+++ b/help.c
@@ -5547,9 +5547,9 @@ char *help_mod[] = {
"module information and loading of symbols and debugging data",
"-s module [objfile] | -d module | -S [directory] [-D|-t|-r|-R|-o|-g]",
" With no arguments, this command displays basic information of the currently",
-" installed modules, consisting of the module address, name, size, the",
-" object file name (if known), and whether the module was compiled with",
-" CONFIG_KALLSYMS.",
+" installed modules, consisting of the module address, name, base address,",
+" size, the object file name (if known), and whether the module was compiled",
+" with CONFIG_KALLSYMS.",
" ",
" The arguments are concerned with with the loading or deleting of symbolic",
" and debugging data from a module's object file. A modules's object file",
@@ -5634,106 +5634,64 @@ char *help_mod[] = {
"\nEXAMPLES",
" Display the currently-installed modules:\n",
" %s> mod",
-" MODULE NAME SIZE OBJECT FILE",
-" c8019000 soundcore 2788 (not loaded)",
-" c801b000 soundlow 336 (not loaded)",
-" c801d000 sound 59864 (not loaded)",
-" c802d000 ad1848 15728 (not loaded)",
-" c8032000 uart401 6000 (not loaded)",
-" c8035000 cs4232 2472 (not loaded)",
-" c8043000 opl3 11048 (not loaded)",
-" c8047000 3c59x 18152 (not loaded)",
-" c804d000 sunrpc 53796 (not loaded)",
-" c805c000 lockd 31528 (not loaded)",
-" c8065000 nfsd 151896 (not loaded)",
-" c8092000 nfs 29752 (not loaded)",
+" MODULE NAME BASE SIZE OBJECT FILE",
+" f7e44c20 dm_mod f7e34000 88568 (not loaded)",
+" f7e5a8a0 dm_log f7e59000 8354 (not loaded)",
+" f7e66420 dm_region_hash f7e65000 9708 (not loaded)",
+" f7e76b60 dm_mirror f7e74000 12609 (not loaded)",
+" f7e8b8e0 ata_piix f7e87000 20637 (not loaded)",
+" ...",
" ",
" Display the currently-installed modules on a system where all modules were",
" compiled with CONFIG_KALLSYMS:",
" ",
" %s> mod",
-" MODULE NAME SIZE OBJECT FILE",
-" e080d000 jbd 57016 (not loaded) [CONFIG_KALLSYMS]",
-" e081e000 ext3 92360 (not loaded) [CONFIG_KALLSYMS]",
-" e0838000 usbcore 83168 (not loaded) [CONFIG_KALLSYMS]",
-" e0850000 usb-uhci 27532 (not loaded) [CONFIG_KALLSYMS]",
-" e085a000 ehci-hcd 20904 (not loaded) [CONFIG_KALLSYMS]",
-" e0865000 input 6208 (not loaded) [CONFIG_KALLSYMS]",
-" e086a000 hid 22404 (not loaded) [CONFIG_KALLSYMS]",
-" e0873000 mousedev 5688 (not loaded) [CONFIG_KALLSYMS]",
-" e0878000 keybdev 2976 (not loaded) [CONFIG_KALLSYMS]",
-" e08fd000 cdrom 34144 (not loaded) [CONFIG_KALLSYMS]",
-" e0909000 ide-cd 35776 (not loaded) [CONFIG_KALLSYMS]",
-" e0915000 scsi_mod 117928 (not loaded) [CONFIG_KALLSYMS]",
-" e0935000 ide-scsi 12752 (not loaded) [CONFIG_KALLSYMS]",
-" e093c000 microcode 5248 (not loaded) [CONFIG_KALLSYMS]",
-" e0943000 sr_mod 18136 (not loaded) [CONFIG_KALLSYMS]",
-" e0956000 floppy 59056 (not loaded) [CONFIG_KALLSYMS]",
-" e0966000 sg 38060 (not loaded) [CONFIG_KALLSYMS]",
-" e0971000 ip_tables 16544 (not loaded) [CONFIG_KALLSYMS]",
-" e097d000 iptable_filter 2412 (not loaded) [CONFIG_KALLSYMS]",
-" e097f000 e1000 76096 (not loaded) [CONFIG_KALLSYMS]",
-" e09ba000 autofs 13780 (not loaded) [CONFIG_KALLSYMS]",
-" e09c1000 parport 39072 (not loaded) [CONFIG_KALLSYMS]",
-" e09ce000 lp 9220 (not loaded) [CONFIG_KALLSYMS]",
-" e09d4000 parport_pc 19204 (not loaded) [CONFIG_KALLSYMS]",
-" e09e2000 agpgart 59128 (not loaded) [CONFIG_KALLSYMS]",
-" e0a1a000 radeon 117156 (not loaded) [CONFIG_KALLSYMS]",
-" e2dc7000 sunrpc 91996 (not loaded) [CONFIG_KALLSYMS]",
-" e2de1000 lockd 60624 (not loaded) [CONFIG_KALLSYMS]",
-" e2df3000 nfs 96880 (not loaded) [CONFIG_KALLSYMS]",
+" MODULE NAME BASE SIZE OBJECT FILE",
+" f7e44c20 dm_mod f7e34000 88568 (not loaded) [CONFIG_KALLSYMS]",
+" f7e5a8a0 dm_log f7e59000 8354 (not loaded) [CONFIG_KALLSYMS]",
+" f7e66420 dm_region_hash f7e65000 9708 (not loaded) [CONFIG_KALLSYMS]",
+" f7e76b60 dm_mirror f7e74000 12609 (not loaded) [CONFIG_KALLSYMS]",
+" f7e8b8e0 ata_piix f7e87000 20637 (not loaded) [CONFIG_KALLSYMS]",
+" ...",
" ",
" Load the symbolic and debugging data of all modules:\n",
" %s> mod -S",
-" MODULE NAME SIZE OBJECT FILE",
-" c8019000 soundcore 2788 /lib/modules/2.2.5-15/misc/soundcore.o",
-" c801b000 soundlow 336 /lib/modules/2.2.5-15/misc/soundlow.o",
-" c801d000 sound 59864 /lib/modules/2.2.5-15/misc/sound.o",
-" c802d000 ad1848 15728 /lib/modules/2.2.5-15/misc/ad1848.o",
-" c8032000 uart401 6000 /lib/modules/2.2.5-15/misc/uart401.o",
-" c8035000 cs4232 2472 /lib/modules/2.2.5-15/misc/cs4232.o",
-" c8043000 opl3 11048 /lib/modules/2.2.5-15/misc/opl3.o",
-" c8047000 3c59x 18152 /lib/modules/2.2.5-15/net/3c59x.o",
-" c804d000 sunrpc 53796 /lib/modules/2.2.5-15/misc/sunrpc.o",
-" c805c000 lockd 31528 /lib/modules/2.2.5-15/fs/lockd.o",
-" c8065000 nfsd 151896 /lib/modules/2.2.5-15/fs/nfsd.o",
-" c8092000 nfs 29752 /lib/modules/2.2.5-15/fs/nfs.o",
+" MODULE NAME BASE SIZE OBJECT FILE",
+" f7e44c20 dm_mod f7e34000 88568 /lib/modules/2.6.32/kernel/drivers/md/dm-mod.ko",
+" f7e5a8a0 dm_log f7e59000 8354 /lib/modules/2.6.32/kernel/drivers/md/dm-log.ko",
+" f7e66420 dm_region_hash f7e65000 9708 /lib/modules/2.6.32/kernel/drivers/md/dm-region-hash.ko",
+" f7e76b60 dm_mirror f7e74000 12609 /lib/modules/2.6.32/kernel/drivers/md/dm-mirror.ko",
+" f7e8b8e0 ata_piix f7e87000 20637 /lib/modules/2.6.32/kernel/drivers/ata/ata_piix.ko",
+" ...",
" ",
-" Load the symbolic and debugging data of the soundcore module from its",
+" Load the symbolic and debugging data of the dm_mod module from its",
" known location:",
" ",
-" %s> mod -s soundcore",
-" MODULE NAME SIZE OBJECT FILE",
-" c8019000 soundcore 2788 /lib/modules/2.2.5-15/misc/soundcore.o",
+" %s> mod -s dm_mod",
+" MODULE NAME BASE SIZE OBJECT FILE",
+" f7e44c20 dm_mod f7e34000 88568 /lib/modules/2.6.32/kernel/drivers/md/dm-mod.ko",
" ",
-" Delete the current symbolic and debugging data of the soundcore module, ",
+" Delete the current symbolic and debugging data of the dm_mod module,",
" and then re-load it from a specified object file:",
" ",
-" %s> mod -d soundcore",
-" %s> mod -s soundcore /tmp/soundcore.o",
-" MODULE NAME SIZE OBJECT FILE",
-" c8019000 soundcore 2788 /tmp/soundcore.o",
+" %s> mod -d dm_mod",
+" %s> mod -s dm_mod /tmp/dm_mod.ko",
+" MODULE NAME BASE SIZE OBJECT FILE",
+" f7e44c20 dm_mod f7e34000 88568 /tmp/dm-mod.ko",
" ",
" After installing a new kernel module on a live system, reinitialize the",
" installed module list:\n",
-" %s> !insmod mdacon",
+" %s> !modprobe soundcore",
" %s> mod",
" mod: NOTE: modules have changed on this system -- reinitializing",
-" MODULE NAME SIZE OBJECT FILE",
-" c8019000 soundcore 2788 (not loaded)",
-" c801b000 soundlow 336 (not loaded)",
-" c801d000 sound 59864 (not loaded)",
-" c802d000 ad1848 15728 (not loaded)",
-" c8032000 uart401 6000 (not loaded)",
-" c8035000 cs4232 2472 (not loaded)",
-" c8043000 opl3 11048 (not loaded)",
-" c8047000 3c59x 18152 (not loaded)",
-" c804d000 sunrpc 53796 (not loaded)",
-" c805c000 lockd 31528 (not loaded)",
-" c8065000 nfs 29752 (not loaded)",
-" c806e000 autofs 9316 (not loaded)",
-" c8072000 nfsd 151896 (not loaded)",
-" c80a1000 mdacon 3556 (not loaded)",
+" MODULE NAME BASE SIZE OBJECT FILE",
+" f7e44c20 dm_mod f7e34000 88568 (not loaded)",
+" f7e5a8a0 dm_log f7e59000 8354 (not loaded)",
+" f7e62e40 soundcore f7e62000 6390 (not loaded)",
+" f7e66420 dm_region_hash f7e65000 9708 (not loaded)",
+" f7e76b60 dm_mirror f7e74000 12609 (not loaded)",
+" f7e8b8e0 ata_piix f7e87000 20637 (not loaded)",
+" ...",
" ",
" Display modules that are \"tainted\", where in this case",
" where they are proprietary and unsigned:",
diff --git a/kernel.c b/kernel.c
index 5fcd86575be5..ac765e302639 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.17.1