svn commit: r202400 - stable/8/sys/sparc64/pci

Marius Strobl marius at FreeBSD.org
Fri Jan 15 16:46:03 UTC 2010


Author: marius
Date: Fri Jan 15 16:46:03 2010
New Revision: 202400
URL: http://svn.freebsd.org/changeset/base/202400

Log:
  MFC: r201395
  
  - Preserve the PROM IOMMU in order to allow OFW drivers to continue to
    work.
  - Sanity check the parameters passed to the implementations of the
    pcib_{read,write}_config() methods. Using illegal values can cause
    no real harm but it doesn't hurt to avoid unnecessary data error
    traps requiring to flush and re-enable the level 1 caches.

Modified:
  stable/8/sys/sparc64/pci/psycho.c
  stable/8/sys/sparc64/pci/psychovar.h
  stable/8/sys/sparc64/pci/schizo.c
  stable/8/sys/sparc64/pci/schizovar.h
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/sparc64/pci/psycho.c
==============================================================================
--- stable/8/sys/sparc64/pci/psycho.c	Fri Jan 15 16:43:19 2010	(r202399)
+++ stable/8/sys/sparc64/pci/psycho.c	Fri Jan 15 16:46:03 2010	(r202400)
@@ -554,6 +554,7 @@ psycho_attach(device_t dev)
 		    M_NOWAIT | M_ZERO);
 		if (sc->sc_is == NULL)
 			panic("%s: malloc iommu_state failed", __func__);
+		sc->sc_is->is_flags = IOMMU_PRESERVE_PROM;
 		if (sc->sc_mode == PSYCHO_MODE_SABRE)
 			sc->sc_is->is_pmaxaddr =
 			    IOMMU_MAXADDR(SABRE_IOMMU_BITS);
@@ -591,10 +592,11 @@ psycho_attach(device_t dev)
 		panic("%s: could not get bus-range", __func__);
 	if (i != sizeof(prop_array))
 		panic("%s: broken bus-range (%d)", __func__, i);
+	sc->sc_pci_secbus = prop_array[0];
+	sc->sc_pci_subbus = prop_array[1];
 	if (bootverbose)
 		device_printf(dev, "bus range %u to %u; PCI bus %d\n",
-		    prop_array[0], prop_array[1], prop_array[0]);
-	sc->sc_pci_secbus = prop_array[0];
+		    sc->sc_pci_secbus, sc->sc_pci_subbus, sc->sc_pci_secbus);
 
 	/* Clear any pending PCI error bits. */
 	PCIB_WRITE_CONFIG(dev, sc->sc_pci_secbus, PCS_DEVICE, PCS_FUNC,
@@ -923,6 +925,10 @@ psycho_read_config(device_t dev, u_int b
 	int i;
 
 	sc = device_get_softc(dev);
+	if (bus < sc->sc_pci_secbus || bus > sc->sc_pci_subbus ||
+	    slot > PCI_SLOTMAX || func > PCI_FUNCMAX || reg > PCI_REGMAX)
+		return (-1);
+
 	bh = sc->sc_pci_bh[OFW_PCI_CS_CONFIG];
 
 	/*
@@ -1003,6 +1009,10 @@ psycho_write_config(device_t dev, u_int 
 	u_long offset = 0;
 
 	sc = device_get_softc(dev);
+	if (bus < sc->sc_pci_secbus || bus > sc->sc_pci_subbus ||
+	    slot > PCI_SLOTMAX || func > PCI_FUNCMAX || reg > PCI_REGMAX)
+		return;
+
 	offset = PSYCHO_CONF_OFF(bus, slot, func, reg);
 	bh = sc->sc_pci_bh[OFW_PCI_CS_CONFIG];
 	switch (width) {

Modified: stable/8/sys/sparc64/pci/psychovar.h
==============================================================================
--- stable/8/sys/sparc64/pci/psychovar.h	Fri Jan 15 16:43:19 2010	(r202399)
+++ stable/8/sys/sparc64/pci/psychovar.h	Fri Jan 15 16:46:03 2010	(r202400)
@@ -75,6 +75,7 @@ struct psycho_softc {
 	struct rman			sc_pci_io_rman;
 
 	uint8_t				sc_pci_secbus;
+	uint8_t				sc_pci_subbus;
 
 	uint8_t				sc_pci_hpbcfg[16];
 

Modified: stable/8/sys/sparc64/pci/schizo.c
==============================================================================
--- stable/8/sys/sparc64/pci/schizo.c	Fri Jan 15 16:43:19 2010	(r202399)
+++ stable/8/sys/sparc64/pci/schizo.c	Fri Jan 15 16:46:03 2010	(r202400)
@@ -454,6 +454,7 @@ schizo_attach(device_t dev)
 	 * buffer, in Schizo version < 5 (i.e. revision < 2.3) it's
 	 * affected by several errata and basically unusable though.
 	 */
+	sc->sc_is.is_flags = IOMMU_PRESERVE_PROM;
 	sc->sc_is.is_pmaxaddr = IOMMU_MAXADDR(STX_IOMMU_BITS);
 	sc->sc_is.is_sb[0] = sc->sc_is.is_sb[1] = 0;
 	if (OF_getproplen(node, "no-streaming-cache") < 0 &&
@@ -548,10 +549,11 @@ schizo_attach(device_t dev)
 		panic("%s: could not get bus-range", __func__);
 	if (i != sizeof(prop_array))
 		panic("%s: broken bus-range (%d)", __func__, i);
+	sc->sc_pci_secbus = prop_array[0];
+	sc->sc_pci_subbus = prop_array[1];
 	if (bootverbose)
 		device_printf(dev, "bus range %u to %u; PCI bus %d\n",
-		    prop_array[0], prop_array[1], prop_array[0]);
-	sc->sc_pci_secbus = prop_array[0];
+		    sc->sc_pci_secbus, sc->sc_pci_subbus, sc->sc_pci_secbus);
 
 	/* Clear any pending PCI error bits. */
 	PCIB_WRITE_CONFIG(dev, sc->sc_pci_secbus, STX_CS_DEVICE, STX_CS_FUNC,
@@ -927,6 +929,9 @@ schizo_read_config(device_t dev, u_int b
 	uint8_t byte;
 
 	sc = device_get_softc(dev);
+	if (bus < sc->sc_pci_secbus || bus > sc->sc_pci_subbus ||
+	    slot > PCI_SLOTMAX || func > PCI_FUNCMAX || reg > PCI_REGMAX)
+		return (-1);
 
 	/*
 	 * The Schizo bridges contain a dupe of their header at 0x80.
@@ -975,6 +980,10 @@ schizo_write_config(device_t dev, u_int 
 	u_long offset = 0;
 
 	sc = device_get_softc(dev);
+	if (bus < sc->sc_pci_secbus || bus > sc->sc_pci_subbus ||
+	    slot > PCI_SLOTMAX || func > PCI_FUNCMAX || reg > PCI_REGMAX)
+		return;
+
 	offset = STX_CONF_OFF(bus, slot, func, reg);
 	bh = sc->sc_pci_bh[OFW_PCI_CS_CONFIG];
 	switch (width) {

Modified: stable/8/sys/sparc64/pci/schizovar.h
==============================================================================
--- stable/8/sys/sparc64/pci/schizovar.h	Fri Jan 15 16:43:19 2010	(r202399)
+++ stable/8/sys/sparc64/pci/schizovar.h	Fri Jan 15 16:46:03 2010	(r202400)
@@ -71,6 +71,7 @@ struct schizo_softc {
 	bus_dma_tag_t			sc_pci_dmat;
 
 	uint8_t				sc_pci_secbus;
+	uint8_t				sc_pci_subbus;
 
 	struct ofw_bus_iinfo		sc_pci_iinfo;
 


More information about the svn-src-stable-8 mailing list