Hi Dave,<br><br>Thanks for the quick reply! I followed approach 1 of disabling CONFIG_STRICT_DEVMEM and the problem disappeared. Now a new problem :-) On invoking crash, I get the following warning:<br><i><b>WARNING: cannot access vmalloc'd module memory</b></i><br>
<br>Because of this I am not able to run commands like "mod":<br>crash> mod<br>mod: cannot access vmalloc'd module memory<br>crash> <br><br>Should the approach 2 or 3 that you mentioned below solve this problem? I have upgraded crash to the latest version (4.0-7.7).<br>
<br>Thanks and regards,<br>Adhiraj.<br><br><br><div class="gmail_quote">On Wed, Feb 25, 2009 at 7:45 PM, Dave Anderson <span dir="ltr"><<a href="mailto:anderson@redhat.com">anderson@redhat.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div></div><div class="Wj3C7c"><br>
----- "Adhiraj Joshi" <<a href="mailto:adhiraj@linsyssoft.com">adhiraj@linsyssoft.com</a>> wrote:<br>
<br>
> Hi All,<br>
><br>
> On my x86 machine with fedora 10, I get an error which says: "crash:<br>
> read error: kernel virtual address:...". The running kernel is not the<br>
> Fedora 10 kernel, I have installed a latest vanilla kernel (2.6.27.12)<br>
> on my machine.<br>
><br>
> On googling, I found that someone has reported a similar problem but<br>
> which was on Fedora kernel and x86_64 arch. Here is the link to that bug:<br>
> <a href="https://bugzilla.redhat.com/show_bug.cgi?id=237383" target="_blank">https://bugzilla.redhat.com/show_bug.cgi?id=237383</a><br>
><br>
> In my case, this is the output from the crash command:<br>
><br>
> [root@maveric ~]# crash /lib/modules/`uname -r`/build/vmlinux<br>
> crash 4.0-7<br>
> Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Red Hat, Inc.<br>
> Copyright (C) 2004, 2005, 2006 IBM Corporation<br>
> Copyright (C) 1999-2006 Hewlett-Packard Co<br>
> Copyright (C) 2005, 2006 Fujitsu Limited<br>
> Copyright (C) 2006, 2007 VA Linux Systems Japan K.K.<br>
> Copyright (C) 2005 NEC Corporation<br>
> Copyright (C) 1999, 2002, 2007 Silicon Graphics, Inc.<br>
> Copyright (C) 1999, 2000, 2001, 2002 Mission Critical Linux, Inc.<br>
> This program is free software, covered by the GNU General Public License,<br>
> and you are welcome to change it and/or distribute copies of it under<br>
> certain conditions. Enter "help copying" to see the conditions.<br>
> This program has absolutely no warranty. Enter "help warranty" for<br>
> details.<br>
><br>
> GNU gdb 6.1<br>
> Copyright 2004 Free Software Foundation, Inc.<br>
> GDB is free software, covered by the GNU General Public License, and you are<br>
> welcome to change it and/or distribute copies of it under certain conditions.<br>
> Type "show copying" to see the conditions.<br>
> There is absolutely no warranty for GDB. Type "show warranty" for details.<br>
> This GDB was configured as "i686-pc-linux-gnu"...<br>
><br>
> crash: read error: kernel virtual address: c08b0ae8 type: "cpu_possible_map"<br>
> WARNING: cannot read cpu_possible_map<br>
> crash: read error: kernel virtual address: c0801a94 type: "cpu_present_map"<br>
> WARNING: cannot read cpu_present_map<br>
> crash: read error: kernel virtual address: c080155c type: "cpu_online_map"<br>
> WARNING: cannot read cpu_online_map<br>
> crash: read error: kernel virtual address: c08dd700 type: "xtime"<br>
> [root@maveric ~]#<br>
><br>
> This is the "uname -a" output:<br>
> "Linux maveric 2.6.27.12-adhi #1 SMP Fri Feb 20 22:13:54 IST 2009 i686<br>
> i686 i386 GNU/Linux"<br>
><br>
> Does anyone has any idea on this?<br>
<br>
</div></div>Your kernel is configured with CONFIG_STRICT_DEVMEM, which disallows<br>
the reading of /dev/mem above 1MB physical.  That makes it useless for<br>
the crash utility:<br>
<br>
  <a href="https://www.redhat.com/archives/crash-utility/2009-February/msg00003.html" target="_blank">https://www.redhat.com/archives/crash-utility/2009-February/msg00003.html</a><br>
<br>
Fedora and RHEL kernels contain the /dev/crash driver, which gets automatically<br>
installed upon crash invocation on the live system.  That driver, found in<br>
the kernel file "drivers/char/crash.c", is a replacement for the (restricted)<br>
/dev/mem driver.<br>
<br>
For your kernel, you've got 3 options:<br>
<br>
(1) Rebuild your kernel without the CONFIG_STRICT_DEVMEM restriction.<br>
(2) Port the Fedora /dev/crash driver (./drivers/char/crash.c) to your kernel.<br>
(3) Write a kretprobe module that tinkers with the return value of the<br>
    kernel's devmem_is_allowed() function such that it always returns 1.<br>
<br>
And w/respect to each option:<br>
<br>
(1) Obviously this is the course of least resistance.<br>
<br>
(2) Porting the RHEL/Fedora /dev/crash driver is possible, but since page_is_ram()<br>
    is not EXPORT_GPL()'d in 2.6.27 upstream kernels, then its usage by the driver<br>
    would have to be removed.  And if you were to make it EXPORT_GPL(), then it<br>
    makes far more sense to just remove the CONFIG_STRICT_DEVMEM instead.<br>
<br>
(3) I'll append some information re: writing a kretprobe module, but like<br>
    porting the /dev/crash driver, it may require rebuilding your kernel anyway.<br>
    And if that's the case, just remove the CONFIG_STRICT_DEVMEM restriction.<br>
<br>
Also, you should upgrade from 4.0-7.  There have been several fixes<br>
for 2.6.27 kernels since that version.<br>
<br>
Dave<br>
<br>
----------------------------------------------------------------------------<br>
<br>
Writing a kretprobe for devmem_is_allowed():<br>
<br>
There are are currently three types of probes: kprobes, jprobes, and<br>
kretprobes (also called return probes), but for this purpose, a<br>
kretprobe is required because it allows the return value of the<br>
devmem_is_allowed() function to be modified such that it will<br>
always return 1.<br>
<br>
The kernel documentation contains both directions for building<br>
a kretprobe module and example module files for each kprobe type.<br>
Pre-2.6.25 kernel trees put sample cut-and-pastable module files<br>
contained within the "./Documentation/kprobes.txt" file itself.<br>
2.6.25 and later kernel trees locate them in the "./samples/kprobes"<br>
directory.<br>
<br>
Note that pre-2.6.25 kernels must have been configured with both<br>
CONFIG_KPROBES, CONFIG_KALLSYMS and CONFIG_MODULES turned on.<br>
Additionally, 2.6.25 and later kernels also need CONFIG_KRETPROBES,<br>
In any case, if the target kernel configs preclude the installation<br>
of the module, then it probably makes more sense to rebuild the<br>
kernel with CONFIG_STRICT_DEVMEM turned off, and avoid this kprobe<br>
approach entirely.<br>
<br>
Take the "kretprobe-example.c" cut-and-pastable file from the<br>
the "./Documentation/kprobes.txt" file, or the standalone<br>
"./samples/kprobes/kretprobe_example.c" file, whichever is<br>
appropriate, and modify the kretprobe_init() and ret_handler()<br>
functions like so:<br>
<br>
 static int __init kretprobe_init(void)<br>
 {<br>
         int ret;<br>
<br>
-        my_kretprobe.kp.symbol_name = func_name;<br>
+        my_kretprobe.kp.symbol_name = "devmem_is_allowed";<br>
         ret = register_kretprobe(&my_kretprobe);<br>
         if (ret < 0) {<br>
                 printk(KERN_INFO "register_kretprobe failed, returned %d\n",<br>
                                 ret);<br>
                 return -1;<br>
         }<br>
         printk(KERN_INFO "Planted return probe at %s: %p\n",<br>
                         my_kretprobe.kp.symbol_name, my_kretprobe.kp.addr);<br>
         return 0;<br>
 }<br>
<br>
and make the ret_handler() function to simply do this:<br>
<br>
 static int ret_handler(struct kretprobe_instance *ri, struct pt_regs *regs)<br>
 {<br>
         regs->ax = 1;<br>
         return 0;<br>
 }<br>
<br>
Earlier kernel versions may have different pt_regs structure member<br>
names for the return register, i.e., "regs->eax" or "regs->rax" for<br>
the x86 and x86_64 architectures respectively.<br>
<br>
Build the kretprobe module as directed in ./Documentation/kprobes.txt"<br>
and insmod it, after which crash will run just fine with /dev/mem.<br>
<font color="#888888"><br>
<br>
<br>
<br>
<br>
<br>
--<br>
Crash-utility mailing list<br>
<a href="mailto:Crash-utility@redhat.com">Crash-utility@redhat.com</a><br>
<a href="https://www.redhat.com/mailman/listinfo/crash-utility" target="_blank">https://www.redhat.com/mailman/listinfo/crash-utility</a><br>
</font></blockquote></div><br>