John Baldwin wrote: > > On Monday 06 April 2009 1:07:38 pm Ivan Voras wrote: > > 2009/4/6 John Baldwin <j...@freebsd.org>: > > > On Sunday 05 April 2009 12:23:39 pm Sergey Babkin wrote: > > > > > Hmm, the problem is we need to be able to write to BARs to size them. б > > > Any > OS > > > needs to be able to do this to know what address space regions are being > > > decoded by devices. б We can't avoid writing to BARs. > > > > I have only vague idea what BARs are and if it's the correct diagnosis > > in this case, but the fact is that other operating systems (Windows, > > Linux tested) work, so either there is a way around it or the original > > premise is wrong-ish. > > Every OS writes to BARs to size them during boot. It's the defined procedure > for sizing them. A BAR is a base address register, and it is how a PCI > device gets memory and I/O port resources. OS (or BIOS) writes a starting > address into the register to tell the PCI device where a given > resource "starts".
The OS doesn't have to write to the BAR if BIOS has already done it. And the BIOS in the Hyper-V VM is obviously special, so it doesn't trip on iself. Anyway, as far as I can tell, it's only the base register of the simulated DEC21140 device that has this issue, so it's quite possible that the bug is in that device's simulator. I've attached a modified patch that checks conservatively for this precise situation, so it should not break compatibility with anything else. I've tested it on Hyper-V. -SB
--- dev/pci/pci.c.0 2009-04-06 21:35:26.000000000 +0000 +++ dev/pci/pci.c 2009-04-06 22:43:08.000000000 +0000 @@ -3590,6 +3590,18 @@ struct pci_devinfo *dinfo = device_get_ivars(child); pcicfgregs *cfg = &dinfo->cfg; + /* A workaround for Hyper-V that hangs on VM stop + * if the base address register of the 21140 simulator is written; + * since on Hyper-V the value written is the same as the one + * already in the register, it can be simply skipped. + * 0x1011: DEC, 0x0009: 21140 */ + if (dinfo->cfg.vendor == 0x1011 && dinfo->cfg.device == 0x0009) { + if (reg == PCIR_BARS + && (val & ~3) == (PCIB_READ_CONFIG(device_get_parent(dev), + cfg->bus, cfg->slot, cfg->func, reg, width) & ~3) ) + return; + } + PCIB_WRITE_CONFIG(device_get_parent(dev), cfg->bus, cfg->slot, cfg->func, reg, val, width); }
_______________________________________________ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"