Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 25 Oct 2019 00:16:57 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r354058 - in stable: 11/sys/dev/acpica 11/sys/i386/pci 12/sys/dev/acpica 12/sys/i386/pci
Message-ID:  <201910250016.x9P0Gv24084681@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhb
Date: Fri Oct 25 00:16:57 2019
New Revision: 354058
URL: https://svnweb.freebsd.org/changeset/base/354058

Log:
  MFC 350662:
  Detect invalid PCI devices more correctly in PCI interrupt router drivers.
  
  - Check for an invalid device (vendor is invalid) before reading the
    header type register when examining function 0 of a possible device.
  - When iterating over functions of a device, reject any device whose
    16-bit vendor is invalid rather than requiring the full 32-bit
    vendor+device to be all 1's.  In practice the latter check is
    probably fine, but checking the vendor is what the PCI spec
    recommends.

Modified:
  stable/12/sys/dev/acpica/acpi_pci_link.c
  stable/12/sys/i386/pci/pci_pir.c
Directory Properties:
  stable/12/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/11/sys/dev/acpica/acpi_pci_link.c
  stable/11/sys/i386/pci/pci_pir.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/12/sys/dev/acpica/acpi_pci_link.c
==============================================================================
--- stable/12/sys/dev/acpica/acpi_pci_link.c	Thu Oct 24 22:34:48 2019	(r354057)
+++ stable/12/sys/dev/acpica/acpi_pci_link.c	Fri Oct 25 00:16:57 2019	(r354058)
@@ -577,6 +577,9 @@ acpi_pci_link_search_irq(int bus, int device, int pin)
 	uint8_t func, maxfunc;
 
 	/* See if we have a valid device at function 0. */
+	value = pci_cfgregread(bus, device, 0, PCIR_VENDOR, 2);
+	if (value == PCIV_INVALID)
+		return (PCI_INVALID_IRQ);
 	value = pci_cfgregread(bus, device, 0, PCIR_HDRTYPE, 1);
 	if ((value & PCIM_HDRTYPE) > PCI_MAXHDRTYPE)
 		return (PCI_INVALID_IRQ);
@@ -587,8 +590,8 @@ acpi_pci_link_search_irq(int bus, int device, int pin)
 
 	/* Scan all possible functions at this device. */
 	for (func = 0; func <= maxfunc; func++) {
-		value = pci_cfgregread(bus, device, func, PCIR_DEVVENDOR, 4);
-		if (value == 0xffffffff)
+		value = pci_cfgregread(bus, device, func, PCIR_VENDOR, 2);
+		if (value == PCIV_INVALID)
 			continue;
 		value = pci_cfgregread(bus, device, func, PCIR_INTPIN, 1);
 

Modified: stable/12/sys/i386/pci/pci_pir.c
==============================================================================
--- stable/12/sys/i386/pci/pci_pir.c	Thu Oct 24 22:34:48 2019	(r354057)
+++ stable/12/sys/i386/pci/pci_pir.c	Fri Oct 25 00:16:57 2019	(r354058)
@@ -257,8 +257,8 @@ pci_pir_create_links(struct PIR_entry *entry, struct P
 }
 
 /*
- * Look to see if any of the function on the PCI device at bus/device have
- * an interrupt routed to intpin 'pin' by the BIOS.
+ * Look to see if any of the functions on the PCI device at bus/device
+ * have an interrupt routed to intpin 'pin' by the BIOS.
  */
 static uint8_t
 pci_pir_search_irq(int bus, int device, int pin)
@@ -267,6 +267,9 @@ pci_pir_search_irq(int bus, int device, int pin)
 	uint8_t func, maxfunc;
 
 	/* See if we have a valid device at function 0. */
+	value = pci_cfgregread(bus, device, 0, PCIR_VENDOR, 2);
+	if (value == PCIV_INVALID)
+		return (PCI_INVALID_IRQ);
 	value = pci_cfgregread(bus, device, 0, PCIR_HDRTYPE, 1);
 	if ((value & PCIM_HDRTYPE) > PCI_MAXHDRTYPE)
 		return (PCI_INVALID_IRQ);
@@ -277,8 +280,8 @@ pci_pir_search_irq(int bus, int device, int pin)
 
 	/* Scan all possible functions at this device. */
 	for (func = 0; func <= maxfunc; func++) {
-		value = pci_cfgregread(bus, device, func, PCIR_DEVVENDOR, 4);
-		if (value == 0xffffffff)
+		value = pci_cfgregread(bus, device, func, PCIR_VENDOR, 2);
+		if (value == PCIV_INVALID)
 			continue;
 		value = pci_cfgregread(bus, device, func, PCIR_INTPIN, 1);
 



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