[openib-general] mstflint - test2

Michael S. Tsirkin mst at mellanox.co.il
Sun Jan 16 00:15:00 PST 2005


Hello!
Quoting r. Tom Duffy (tduffy at sun.com) "Re: [openib-general] Re: mmap(/dev/mem) causing sigbus":
> On Fri, 2005-01-14 at 16:46 +0200, Michael S. Tsirkin wrote:
> > I now tested it on x86 and it works. Still, I wont
> > change the default until I test it some more.
> > Tom, pls try with latest svn , changing CONFIG_USE_DEV_MEM
> > from 1 to 0 in mtcr.h. If there are problems I'll
> > work on it on Sunday, same goes for your error handling
> > patch.
> 
> tat:~# ./mstflint -d 0000:81:00.0 q
> Device open failed: Primary extended query larger than TOTAL_QUERY_SIZE
> 
> -tduffy

The issue is most likely incorrect data being returned by
reading the mmaped region.

Please try the attached test (BAR0 and NAME values may need fixing),
and let me know the result.



#define BAR0 0x1ff00100004ull;
#define NAME "/proc/bus/pci/0000:81/00.0"

#define _XOPEN_SOURCE 500
#define _FILE_OFFSET_BITS 64
#include <sys/mman.h>
#include <fcntl.h>

#include <unistd.h>

#include <stdio.h>


int main()
{
	int fd;
	void *ptr;
	unsigned value;
	unsigned long long offset = BAR0;
	fd = open(NAME,O_RDWR | O_SYNC);
	if (fd<0) {
		perror("open");
		return 1;
	}

	ptr = mmap(NULL, 0x100000, PROT_READ | PROT_WRITE,
			MAP_SHARED, fd, offset);

	if ( (! ptr) || (ptr == MAP_FAILED) ) {
		perror("map");
		return 1;
	}

	value= *( (unsigned*)(ptr + 0x000f0014) );
	
	printf("value at 0x000f0014 is %#8.8x\n", value);

	return 0;
err:
	return 1;
}




More information about the general mailing list