Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 7 May 2015 18:35:15 +0000 (UTC)
From:      Neel Natu <neel@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r282595 - head/usr.sbin/bhyve
Message-ID:  <201505071835.t47IZFEn087376@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: neel
Date: Thu May  7 18:35:15 2015
New Revision: 282595
URL: https://svnweb.freebsd.org/changeset/base/282595

Log:
  Allow byte reads of AHCI registers.
  
  This is needed to support Windows guests that use byte reads to access certain
  AHCI registers (e.g. PxTFD.Status and PxTFD.Error).
  
  Reviewed by:	grehan, mav
  Reported by:	Leon Dang (ldang@nahannisys.com)
  Differential Revision:	https://reviews.freebsd.org/D2469
  MFC after:	2 weeks

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

Modified: head/usr.sbin/bhyve/pci_ahci.c
==============================================================================
--- head/usr.sbin/bhyve/pci_ahci.c	Thu May  7 18:35:01 2015	(r282594)
+++ head/usr.sbin/bhyve/pci_ahci.c	Thu May  7 18:35:15 2015	(r282595)
@@ -2093,7 +2093,7 @@ pci_ahci_write(struct vmctx *ctx, int vc
 	struct pci_ahci_softc *sc = pi->pi_arg;
 
 	assert(baridx == 5);
-	assert(size == 4);
+	assert((offset % 4) == 0 && size == 4);
 
 	pthread_mutex_lock(&sc->mtx);
 
@@ -2182,24 +2182,29 @@ pci_ahci_port_read(struct pci_ahci_softc
 
 static uint64_t
 pci_ahci_read(struct vmctx *ctx, int vcpu, struct pci_devinst *pi, int baridx,
-    uint64_t offset, int size)
+    uint64_t regoff, int size)
 {
 	struct pci_ahci_softc *sc = pi->pi_arg;
+	uint64_t offset;
 	uint32_t value;
 
 	assert(baridx == 5);
-	assert(size == 4);
+	assert(size == 1 || size == 2 || size == 4);
+	assert((regoff & (size - 1)) == 0);
 
 	pthread_mutex_lock(&sc->mtx);
 
+	offset = regoff & ~0x3;	    /* round down to a multiple of 4 bytes */
 	if (offset < AHCI_OFFSET)
 		value = pci_ahci_host_read(sc, offset);
 	else if (offset < AHCI_OFFSET + sc->ports * AHCI_STEP)
 		value = pci_ahci_port_read(sc, offset);
 	else {
 		value = 0;
-		WPRINTF("pci_ahci: unknown i/o read offset 0x%"PRIx64"\n", offset);
+		WPRINTF("pci_ahci: unknown i/o read offset 0x%"PRIx64"\n",
+		    regoff);
 	}
+	value >>= 8 * (regoff & 0x3);
 
 	pthread_mutex_unlock(&sc->mtx);
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201505071835.t47IZFEn087376>