Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/pci Fix a bug that the TPH ST table is decoded even ...



details:   https://anonhg.NetBSD.org/src/rev/f6e7d9ae06d3
branches:  trunk
changeset: 827186:f6e7d9ae06d3
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Thu Oct 19 05:52:57 2017 +0000

description:
Fix a bug that the TPH ST table is decoded even if it's not in the TPH
Requester extended capability structure.

diffstat:

 sys/dev/pci/pci_subr.c |  22 +++++++++++++---------
 sys/dev/pci/pcireg.h   |   5 ++++-
 2 files changed, 17 insertions(+), 10 deletions(-)

diffs (89 lines):

diff -r 1f543061210c -r f6e7d9ae06d3 sys/dev/pci/pci_subr.c
--- a/sys/dev/pci/pci_subr.c    Thu Oct 19 05:45:37 2017 +0000
+++ b/sys/dev/pci/pci_subr.c    Thu Oct 19 05:52:57 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pci_subr.c,v 1.193 2017/10/12 02:40:34 msaitoh Exp $   */
+/*     $NetBSD: pci_subr.c,v 1.194 2017/10/19 05:52:57 msaitoh Exp $   */
 
 /*
  * Copyright (c) 1997 Zubin D. Dittia.  All rights reserved.
@@ -40,7 +40,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pci_subr.c,v 1.193 2017/10/12 02:40:34 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_subr.c,v 1.194 2017/10/19 05:52:57 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_pci.h"
@@ -3499,15 +3499,15 @@
 }
 
 static const char *
-pci_conf_print_tph_req_cap_sttabloc(unsigned char val)
+pci_conf_print_tph_req_cap_sttabloc(uint8_t val)
 {
 
        switch (val) {
-       case 0x0:
+       case PCI_TPH_REQ_STTBLLOC_NONE:
                return "Not Present";
-       case 0x1:
+       case PCI_TPH_REQ_STTBLLOC_TPHREQ:
                return "in the TPH Requester Capability Structure";
-       case 0x2:
+       case PCI_TPH_REQ_STTBLLOC_MSIX:
                return "in the MSI-X Table";
        default:
                return "Unknown";
@@ -3519,6 +3519,7 @@
 {
        pcireg_t reg;
        int size, i, j;
+       uint8_t sttbloc;
 
        printf("\n  TPH Requester Extended Capability\n");
 
@@ -3528,9 +3529,9 @@
        onoff("Interrupt Vector Mode Supported", reg, PCI_TPH_REQ_CAP_INTVEC);
        onoff("Device Specific Mode Supported", reg, PCI_TPH_REQ_CAP_DEVSPEC);
        onoff("Extend TPH Reqester Supported", reg, PCI_TPH_REQ_CAP_XTPHREQ);
+       sttbloc = __SHIFTOUT(reg, PCI_TPH_REQ_CAP_STTBLLOC);
        printf("      ST Table Location: %s\n",
-           pci_conf_print_tph_req_cap_sttabloc(
-                   (unsigned char)__SHIFTOUT(reg, PCI_TPH_REQ_CAP_STTBLLOC)));
+           pci_conf_print_tph_req_cap_sttabloc(sttbloc));
        size = __SHIFTOUT(reg, PCI_TPH_REQ_CAP_STTBLSIZ) + 1;
        printf("      ST Table Size: %d\n", size);
 
@@ -3566,7 +3567,10 @@
                printf("(reserved vaule)\n");
                break;
        }
-       
+
+       if (sttbloc != PCI_TPH_REQ_STTBLLOC_TPHREQ)
+               return;
+
        for (i = 0; i < size ; i += 2) {
                reg = regs[o2i(extcapoff + PCI_TPH_REQ_STTBL + i / 2)];
                for (j = 0; j < 2 ; j++) {
diff -r 1f543061210c -r f6e7d9ae06d3 sys/dev/pci/pcireg.h
--- a/sys/dev/pci/pcireg.h      Thu Oct 19 05:45:37 2017 +0000
+++ b/sys/dev/pci/pcireg.h      Thu Oct 19 05:52:57 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pcireg.h,v 1.134 2017/10/10 03:11:01 msaitoh Exp $     */
+/*     $NetBSD: pcireg.h,v 1.135 2017/10/19 05:52:57 msaitoh Exp $     */
 
 /*
  * Copyright (c) 1995, 1996, 1999, 2000
@@ -1904,6 +1904,9 @@
 #define        PCI_TPH_REQ_CAP_DEVSPEC __BIT(2)   /* Device Specific Mode Supported */
 #define        PCI_TPH_REQ_CAP_XTPHREQ __BIT(8)    /* Extend TPH Reqester Supported */
 #define        PCI_TPH_REQ_CAP_STTBLLOC __BITS(10, 9)  /* ST Table Location */
+#define        PCI_TPH_REQ_STTBLLOC_NONE       0       /* not present */
+#define        PCI_TPH_REQ_STTBLLOC_TPHREQ     1       /* in the TPHREQ cap */
+#define        PCI_TPH_REQ_STTBLLOC_MSIX       2       /* in the MSI-X table */
 #define        PCI_TPH_REQ_CAP_STTBLSIZ __BITS(26, 16) /* ST Table Size */
 #define        PCI_TPH_REQ_CTL 0x08    /* TPH Requester Control */
 #define        PCI_TPH_REQ_CTL_STSEL   __BITS(2, 0)    /* ST Mode Select */



Home | Main Index | Thread Index | Old Index