svn commit: r256248 - head/usr.sbin/bhyve

Peter Grehan grehan at FreeBSD.org
Wed Oct 9 23:53:22 UTC 2013


Author: grehan
Date: Wed Oct  9 23:53:21 2013
New Revision: 256248
URL: http://svnweb.freebsd.org/changeset/base/256248

Log:
  Allow a 4-byte write to PCI config space to overlap
  the 2 read-only bytes at the start of a PCI capability.
  This is the sequence that OpenBSD uses when enabling
  MSI interrupts, and works fine on real h/w.
  
  In bhyve, convert the 4 byte write to a 2-byte write to
  the r/w area past the first 2 r/o bytes of a capability.
  
  Reviewed by:	neel
  Approved by:	re@ (blanket)

Modified:
  head/usr.sbin/bhyve/pci_emul.c

Modified: head/usr.sbin/bhyve/pci_emul.c
==============================================================================
--- head/usr.sbin/bhyve/pci_emul.c	Wed Oct  9 22:10:03 2013	(r256247)
+++ head/usr.sbin/bhyve/pci_emul.c	Wed Oct  9 23:53:21 2013	(r256248)
@@ -941,10 +941,19 @@ pci_emul_capwrite(struct pci_devinst *pi
 	assert(offset >= capoff);
 
 	/*
-	 * Capability ID and Next Capability Pointer are readonly
+	 * Capability ID and Next Capability Pointer are readonly.
+	 * However, some o/s's do 4-byte writes that include these.
+	 * For this case, trim the write back to 2 bytes and adjust
+	 * the data.
 	 */
-	if (offset == capoff || offset == capoff + 1)
-		return;
+	if (offset == capoff || offset == capoff + 1) {
+		if (offset == capoff && bytes == 4) {
+			bytes = 2;
+			offset += 2;
+			val >>= 16;
+		} else
+			return;
+	}
 
 	switch (capid) {
 	case PCIY_MSI:


More information about the svn-src-all mailing list