From 9c17439807c80876bf7027b17859714b31401ab9 Mon Sep 17 00:00:00 2001 From: Bart Trojanowski Date: Fri, 11 Jan 2008 19:59:54 -0500 Subject: [PATCH] X86EMU: pass the correct bus:dev:fn tag to pci emulation Signed-off-by: Bart Trojanowski Work funded by: Symbio Technologies There seems to be an inconsistency between what the x86emu gets from the PCI handling code and by accessing hardware directly. x86emu relies on a set of functions to emulate PCI access. When things goes wrong, the emulator is asked to execute an OUT instruction on port 0x20. I've put together a patch against xserver-xorg package that prevents accesses to BAD registers. This turns a freeze into a segfault in X. http://www.jukie.net/~bart/patches/xorg-server/20080111/0001-X86EMU-added-blacklist-for-I-O-port-in-0-0xFF-range.patch It does not address the DDC not working, I hope that after fixing the bugs in x86emu, things may improve. Anyway, I am continuing to investigate the real cause of the PCI access issue. To find out more read this thread: http://lists.freedesktop.org/archives/xorg/2008-January/031811.html -Bart diff -Nurp xorg-server-1.4.1~git20080118-patched/hw/xfree86/int10/helper_exec.c xorg-server-1.4.1~git20080118-working/hw/xfree86/int10/helper_exec.c --- xorg-server-1.4.1~git20080118-patched/hw/xfree86/int10/helper_exec.c 2008-01-22 10:22:26.000000000 -0800 +++ xorg-server-1.4.1~git20080118-working/hw/xfree86/int10/helper_exec.c 2008-01-22 11:00:52.000000000 -0800 @@ -542,7 +542,8 @@ Mem_wl(CARD32 addr, CARD32 val) static CARD32 PciCfg1Addr = 0; -#define OFFSET(Cfg1Addr) (Cfg1Addr & 0xff) +#define PCI_OFFSET(x) ((x) & 0x000000ff) +#define PCI_TAG(x) ((x) & 0x00ffff00) static int pciCfg1in(CARD16 addr, CARD32 *val) @@ -552,7 +553,7 @@ pciCfg1in(CARD16 addr, CARD32 *val) return 1; } if (addr == 0xCFC) { - *val = pciReadLong(Int10Current->Tag, OFFSET(PciCfg1Addr)); + *val = pciReadLong(PCI_TAG(PciCfg1Addr), PCI_OFFSET(PciCfg1Addr)); if (PRINT_PORT && DEBUG_IO_TRACE()) ErrorF(" cfg_inl(%#x) = %8.8x\n", PciCfg1Addr, *val); return 1; @@ -570,7 +571,7 @@ pciCfg1out(CARD16 addr, CARD32 val) if (addr == 0xCFC) { if (PRINT_PORT && DEBUG_IO_TRACE()) ErrorF(" cfg_outl(%#x, %8.8x)\n", PciCfg1Addr, val); - pciWriteLong(Int10Current->Tag, OFFSET(PciCfg1Addr), val); + pciWriteLong(PCI_TAG(PciCfg1Addr), PCI_OFFSET(PciCfg1Addr), val); return 1; } return 0; @@ -588,7 +589,7 @@ pciCfg1inw(CARD16 addr, CARD16 *val) } if ((addr >= 0xCFC) && (addr <= 0xCFF)) { offset = addr - 0xCFC; - *val = pciReadWord(Int10Current->Tag, OFFSET(PciCfg1Addr) + offset); + *val = pciReadWord(PCI_TAG(PciCfg1Addr), PCI_OFFSET(PciCfg1Addr) + offset); if (PRINT_PORT && DEBUG_IO_TRACE()) ErrorF(" cfg_inw(%#x) = %4.4x\n", PciCfg1Addr + offset, *val); return 1; @@ -611,7 +612,7 @@ pciCfg1outw(CARD16 addr, CARD16 val) offset = addr - 0xCFC; if (PRINT_PORT && DEBUG_IO_TRACE()) ErrorF(" cfg_outw(%#x, %4.4x)\n", PciCfg1Addr + offset, val); - pciWriteWord(Int10Current->Tag, OFFSET(PciCfg1Addr) + offset, val); + pciWriteWord(PCI_TAG(PciCfg1Addr), PCI_OFFSET(PciCfg1Addr) + offset, val); return 1; } return 0; @@ -629,7 +630,7 @@ pciCfg1inb(CARD16 addr, CARD8 *val) } if ((addr >= 0xCFC) && (addr <= 0xCFF)) { offset = addr - 0xCFC; - *val = pciReadByte(Int10Current->Tag, OFFSET(PciCfg1Addr) + offset); + *val = pciReadByte(PCI_TAG(PciCfg1Addr), PCI_OFFSET(PciCfg1Addr) + offset); if (PRINT_PORT && DEBUG_IO_TRACE()) ErrorF(" cfg_inb(%#x) = %2.2x\n", PciCfg1Addr + offset, *val); return 1; @@ -652,7 +653,7 @@ pciCfg1outb(CARD16 addr, CARD8 val) offset = addr - 0xCFC; if (PRINT_PORT && DEBUG_IO_TRACE()) ErrorF(" cfg_outb(%#x, %2.2x)\n", PciCfg1Addr + offset, val); - pciWriteByte(Int10Current->Tag, OFFSET(PciCfg1Addr) + offset, val); + pciWriteByte(PCI_TAG(PciCfg1Addr), PCI_OFFSET(PciCfg1Addr) + offset, val); return 1; } return 0;