|
From: Chris D. <Chr...@am...> - 2007-09-06 00:25:19
|
Hi, I am looking for some advice on supporting a user-space driver toolkit in valgrind. I am working off v3.2.3. This is on x86 Linux. The driver toolkit consists of a kernel module that exports a whole mess of ioctls. So, I have been working in syswrap-generic.c adding the needed ioctls. I think that I understand that part OK with the PRE_MEM_READ()/POST_MEM_WRITE() stuff, but the key routine maps a PCI card into userspace. In other words it acts like mmap(), shmat(), or sbrk() and adds a mapping of a PCI card's memory spaces into my program. I do not know that mapped addresses until after registering the card, and there is no way to influence the addresses the kernel picks. What I have done so far is to take advantage of the mmap() hooks in aspacem. In the POST_ioctl wrapper I page align the address and size for my new mapping and then call am_notify_client_mmap(). I then call VG_TRACK(new_mem_mmap...) to hopefully let the core and client tool know about the new memory. The problem is that it doesn't seem to work when my program actually accesses the mapped addresses. e.g. I get this when Address 0x40001000 is most certainly mapped. ==251== Invalid read of size 4 ==251== at 0x4101746: FLASH_ReadDword (flash_lib.cpp:647) ==251== by 0x410F8D5: LAS0::read_bit0(bit_id, unsigned long&) (fmmap.cpp:44) ==251== by 0x411568C: module_io::present() (moduleio.cpp:186) ==251== by 0x4108C08: FMCntrlReadData(int, unsigned long long, unsigned char*, unsigned long&) (fmcntrl.cpp:716) ==251== by 0x406F7DF: CFlashMedia::cntrl_get_data(unsigned long long, unsigned char*, int) (csm_fm.cpp:664) ==251== by 0x406D816: CFlashMedia::get_block_header(unsigned long long, unsigned long*) (csm_fm.cpp:77) ==251== by 0x409180D: CPosition::get_timestamp(int, timecode_type&, int*) (position.cpp:2916) ==251== by 0x4090837: CPosition::post_begin_record(timecode_type*) (position.cpp:2644) ==251== by 0x40942C6: CPosition::write_raw_data(unsigned char*, int&) (position.cpp:3840) ==251== by 0x40A3117: recorder::set_raw_data(int&, unsigned char*) (recorder.cpp:253) ==251== by 0x40395C7: CMsgDlg::write_raw_data(void*, int&) (msgdlg.cpp:1234) ==251== by 0x403D84A: FCL_WriteData(int, void*, int&) (ddfc.cpp:222) ==251== Address 0x40001000 is not stack'd, malloc'd or (recently) free'd What else must I do to tell memcheck and other tools about my new address space? Thanks, Chris -- Christopher Douty <Chr...@am...> +1-650-367-3129 Senior Engineer, Software & Systems - AMPEX Data Systems Corp. |