Skip to contentSkip to conversation

Userspace PIO access under xen

DISCUSSION Michael S. Tsirkin 1 participant 1 message Jul 25, 2005

lore
Share & tools
lore
#0 lore raw

Hi!
The following simple program (below) mmaps PCI I/O memory into userspace. This works fine under linux, but not in Xen dom0.

Linux:

# ./test1 /sys/bus/pci/devices/0000\:07\:00.0/resource0 0
0 0

Xen dom0:

# ./test1 /sys/bus/pci/devices/0000\:07\:00.0/resource0 0
0 0xf000eef3

Where does one start looking at fixing this?
Thanks,
MST

---

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <string.h>

/* Usage: test0 file offset */

int main(int argc, char** argv)

{
    int fd;
    if (argc < 3) {
	    fprintf(stderr, "Usage: %s file offset\n", argv[0]);
	    return 2;
    }

    fd = open(argv[1], O_RDWR | O_SYNC);
    if (fd < 0) {
	    perror("open");
	    return errno;
    }

    long o = strtol(argv[2], NULL, 0);

    long* ptr = mmap(NULL, 0x1000, PROT_READ, MAP_SHARED, fd, o);

    if ( (! ptr) || (ptr == MAP_FAILED) ) {
	    perror("mmap");
	    return errno;
    }

    printf("%#lx %#lx\n", o, *ptr);

    return 0;
}
Signature · 1 line
MST