Hi

One last important detail. The module works creating the mmap driver operation. The driver uses vm_insert_page and getting the pages with __get_free_pages. Would that be  the problem???

thanks

David

On Fri, Jul 11, 2008 at 3:04 PM, David Francisco Rodriguez Perez <david.francisco.rodriguez@gmail.com> wrote:
Hi All

I am having problems with LKM compiled for UML. I am porting some drivers from our box to our simulation based on UML. But I am having segmentation faults or memory corruptions which by gdb always looks  at the same place. So I wanted to know if my problem is because the modules have been compiled incorrectly or it is something in my module itself or my kernel is missing something at the config. My guest kernel is 2.6.24.3 and the host, I am trying are 2.6.9-34.ELsmp and the other host is 2.6.24-19-generic. I am working with SKAS0 as for now so I do not have patch neither the guest, neither the host. The other thing is that the linux has been compiled with the initramfs embeded on the image. Anexing boot up and then the problem.

Thanks

David Rodriguez

PS. loadmodule is an script that is doing
/sbin/insmod /lib/modules/module <args> || exit 1

$ gdb ./linux
GNU gdb Red Hat Linux (6.3.0.0-1.96rh)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux-gnu"...Using host libthread_db library "/lib/tls/libthread_db.so.1".

(gdb) set args mem=128M eth0=mcast NI=5
(gdb) r
Starting program: /home/darodrig/sim_ni/linux mem=128M eth0=mcast NI=5
ENTERING NOT INTERACTIVE SHELL
Core dump limits :
    soft - 0
    hard - NONE
Checking that ptrace can change system call numbers...Detaching after fork from child process 30262.
OK
Checking syscall emulation patch for ptrace...Detaching after fork from child process 30263.
missing
Checking for tmpfs mount on /dev/shm...OK
Checking PROT_EXEC mmap in /dev/shm/...OK
Checking for the skas3 patch in the host:
  - /proc/mm...not found: No such file or directory
  - PTRACE_FAULTINFO...Detaching after fork from child process 30264.
not found
  - PTRACE_LDT...Detaching after fork from child process 30265.
not found
UML running in SKAS0 mode
Linux version 2.6.24.3 (darodrig@guppy8) (gcc version 4.2.1) #1 Mon Jul 7 19:06:46 PDT 2008
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 32512
Kernel command line: mem=128M eth0=mcast NI=5 root=98:0
PID hash table entries: 512 (order: 9, 2048 bytes)
Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)
Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)
Memory: 115384k available
Mount-cache hash table entries: 512
Checking for host processor cmov support...Yes
Checking for host processor xmm support...No
Checking that host ptys support output SIGIO...Yes
Checking that host ptys support SIGIO on close...No, enabling workaround
net_namespace: 64 bytes
/usr/include/linux/aio_abi.h not present during build
2.6 host AIO support not used - falling back to I/O thread
NET: Registered protocol family 16
NET: Registered protocol family 2
Time: itimer clocksource has been installed.
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 4096 (order: 3, 32768 bytes)
TCP bind hash table entries: 4096 (order: 2, 16384 bytes)
TCP: Hash tables configured (established 4096 bind 4096)
TCP reno registered
Checking host MADV_REMOVE support...<3>MADV_REMOVE failed, err = -22
Can't release memory to the host - memory hotplug won't be supported
mconsole (version 2) initialized on /home/darodrig/.uml/HUa8DH/mconsole
Host TLS support detected
Detected host type: i386
VFS: Disk quotas dquot_6.5.1
Dquot-cache hash table entries: 1024 (order 0, 4096 bytes)
io scheduler noop registered
io scheduler anticipatory registered (default)
io scheduler deadline registered
io scheduler cfq registered
TCP cubic registered
NET: Registered protocol family 1
NET: Registered protocol family 10
lo: Disabled Privacy Extensions
IPv6 over IPv4 tunneling driver
sit0: Disabled Privacy Extensions
NET: Registered protocol family 17
Initialized stdio console driver
Console initialized on /dev/tty0
console [tty0] enabled
Initializing software serial port version 1
Configured mcast device: 239.192.168.1:1102-1
Choosing a random ethernet address for device eth0
Netdevice 0 (36:f0:ec:94:c4:9e) : mcast backend multicast address: 239.192.168.1:1102, TTL:1
console [mc-1] enabled
Couldn't stat "root_fs" : err = 2
Failed to initialize ubd device 0 :Couldn't determine size of device's file
Detaching after fork from child process 30269.
                                              line_ioctl: tty0: unknown ioctl: 0x541e
Doing NI Startup...
Finishing Startup NI 5
Serial line 0 assigned device '/dev/pts/9'
;


ni login: admin
Password:


I5 # loadmodule
Initializing with Board Type: 0x5555
Loading module qdisp with parameter qdisp_board_type=0x5555 slot=5 .

Program received signal SIGSEGV, Segmentation fault.
0x0805c2bb in copy_chunk_from_user (from=148668472, len=4040, arg=0xdd8de48) at include/asm/arch/string_32.h:35
35    __asm__ __volatile__(
(gdb) bt
#0  0x0805c2bb in copy_chunk_from_user (from=148668472, len=4040, arg=0xdd8de48) at include/asm/arch/string_32.h:35
#1  0x0805c11a in do_op_one_page (addr=Variable "addr" is not available.
)
    at /soft/100/kernel/linux-2.6.24.3/arch/um/kernel/skas/uaccess.c:52
#2  0x0805c1b0 in do_buffer_op (jmpbuf=0xdd8ddc0, arg_ptr=0xdd8dddc)
    at /soft/100/kernel/linux-2.6.24.3/arch/um/kernel/skas/uaccess.c:80
#3  0x080687f5 in setjmp_wrapper (proc=0x805c128 <do_buffer_op>)
    at /soft/100/kernel/linux-2.6.24.3/arch/um/os-Linux/util.c:100
#4  0x0805c27d in buffer_op (addr=134942776, len=129212, is_write=0, op=0x805c2a6 <copy_chunk_from_user>, arg=0xdd8de48)
    at /soft/100/kernel/linux-2.6.24.3/arch/um/kernel/skas/uaccess.c:122
#5  0x0805c350 in copy_from_user (to=0x10800000, from=0x80b1038, n=129212)
    at /soft/100/kernel/linux-2.6.24.3/arch/um/kernel/skas/uaccess.c:146
#6  0x08090b8d in load_module (umod=0x80b1038, len=129212, uargs=0x80b1008 "\205�t\016\200x\001")
    at /soft/100/kernel/linux-2.6.24.3/kernel/module.c:1695
#7  0x0809157a in sys_init_module (umod=0x80b1038, len=129212, uargs=0x80b1008 "\205�t\016\200x\001")
    at /soft/100/kernel/linux-2.6.24.3/kernel/module.c:2108
#8  0x0805c01f in handle_syscall (r=0xde6cde4)
    at /soft/100/kernel/linux-2.6.24.3/arch/um/kernel/skas/syscall.c:35
#9  0x08069cba in handle_trap (pid=30356, regs=0xde6cde4, local_using_sysemu=0)
    at /soft100/kernel/linux-2.6.24.3/arch/um/os-Linux/skas/process.c:168
#10 0x0806a127 in userspace (regs=0xde6cde4)
    at /soft/100/kernel/linux-2.6.24.3/arch/um/os-Linux/skas/process.c:341
#11 0x08059abe in fork_handler () at /soft/100/kernel/linux-2.6.24.3/arch/um/kernel/process.c:183
#12 0x05d31045 in ?? ()

Other crash!!!

NI15 # loadmodule
Initializing with Board Type: 0x52012001
Loading module qdisp with parameter qdisp_board_type=0x52012001 slot=15 ...
queue_dispatch: Allocated 255 12KB packet buffers
Qdispatcher loaded
NI15 # Slab corruption: size-32768 start=0fcb0000, len=32768
000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00