: Qemu Host PCI Proxy v0.3
PATCH 1/1 : Qemu Host PCI Proxy v0.3
Hi all,
This is a patch for qemu to allow using PCI devices on the host machine from within the guest machine (for now, only as long as Linux is the host OS). This is in order to facilitate the easy reverse engineering of PCI devices. You can see it working in this screenshot:
http://www.scaramanga.co.uk/stuff/qemu-pciproxy-0.3.png
where I have a Broadcom 94306 802.11g card running under win2k. For the interested I have uploaded a (1.4MB) log of its I/O while installing the win2k driver to this URL:
http://www.scaramanga.co.uk/stuff/bcm94306-win2k-install-driver.txt
Features since 0.2:
o Forward PCI config reads/writes as necessary.
o Support IRQ delivery via. Linux kernel patch.
The IRQ delivery kernel patch is against 2.6.6 and available at:
http://www.scaramanga.co.uk/stuff/linux-sigirq-0.1.diff
This means that most hardware will actually work now (apart from PCI-DMA). For now I will be turning my attentions to reverse engineering the bcm94306 and looking at doing the same thing for USB ;)
Still TODO:
o Update kernel patch to work with shared IRQs on host.
o Documentation (thats still a WIP)
o Fast logging support
o AGP support
o Support for PCI-DMA with patched guest OS (any win2k hackers out there wanna help on this?). Until this is done the code won't be ready for normal users...
o Lock the PCI device
o Figure out cause of win2k-server / 3c905c problem.
Signature · 3 lines
// Gianni Tedesco (gianni at scaramanga dot co dot uk) lynx --source www.scaramanga.co.uk/scaramanga.asc | gpg --import 8646BE7D: 6D9F 2287 870E A2C9 8F60 3A3C 91B5 7669 8646 BE7D
Makefile.target +1 -1
@@ -232,7 +232,7 @@ endif # must use static linking to avoid leaving stuff in virtual address space -VL_OBJS=vl.o osdep.o block.o monitor.o pci.o +VL_OBJS=vl.o osdep.o block.o monitor.o pci.o pciproxy.o ifeq ($(TARGET_ARCH), i386) # Hardware support
configure +5 -0
@@ -391,6 +391,11 @@ elif test -f "/usr/include/byteswap.h" ; then echo "#define HAVE_BYTESWAP_H 1" >> $config_h fi +if test -f "/usr/include/sys/io.h"; then + echo "#define HAVE_SYS_IO_H 1" >> $config_h + echo "#define HAVE_IOPL 1" >> $config_h + echo "#define HAVE_IOPERM 1" >> $config_h +fi if test "$gdbstub" = "yes" ; then echo "CONFIG_GDBSTUB=yes" >> $config_mak echo "#define CONFIG_GDBSTUB 1" >> $config_h
hw/pc.c +2 -0
@@ -394,6 +394,8 @@if (pci_enabled) {i440fx_init ();piix3_init (); +if ( pciproxy_devpath ) +pciproxy_add_device (pciproxy_devpath); }/* init basic PC hardware */
hw/pciproxy.c +744 -0
744 lines not on this page · raw message
vl.c +7 -1
@@ -104,6 +104,7 @@/* XXX: use a two level table to limit memory usage */ #define MAX_IOPORTS 65536 +char *pciproxy_devpath =NULL ;const char *bios_dir =CONFIG_QEMU_SHAREDIR ;char phys_ram_file[1024 ];CPUState *global_env;
@@ -1081,7 +1082,7 @@return -1 ; }memset (&ifr,0 ,sizeof (ifr)); - ifr.ifr_flags =IFF_TAP |IFF_NO_PI ; + ifr.ifr_flags =IFF_TAP |IFF_NO_PI |IFF_ONE_QUEUE ;pstrcpy (ifr.ifr_name,IFNAMSIZ ,"tun%d" ); ret =ioctl (fd,TUNSETIFF , (void *) &ifr);if (ret !=0 ) {
@@ -2052,6 +2053,7 @@QEMU_OPTION_L , QEMU_OPTION_no_code_copy, QEMU_OPTION_pci, + QEMU_OPTION_pciproxy, QEMU_OPTION_prep, QEMU_OPTION_localtime, QEMU_OPTION_cirrusvga,
@@ -2102,6 +2104,7 @@ #ifdef TARGET_PPC { "prep", 0, QEMU_OPTION_prep }, #endif + { "pciproxy", HAS_ARG, QEMU_OPTION_pciproxy }, { "localtime", 0, QEMU_OPTION_localtime }, /* temporary options */
@@ -2389,6 +2392,9 @@case QEMU_OPTION_cirrusvga: cirrus_vga_enabled =1 ;break ; +case QEMU_OPTION_pciproxy: + pciproxy_devpath = (char *)optarg; +break ; } } }
vl.h +4 -0
@@ -515,6 +515,10 @@void pci_pmac_init (void );void pci_ppc_bios_init (void ); +/* pciproxy.c */ +extern char *pciproxy_devpath; +void pciproxy_add_device (char *devpath); +/* vga.c */ #define VGA_RAM_SIZE (4096 * 1024)