summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormlarkin <mlarkin@openbsd.org>2017-03-25 07:33:46 +0000
committermlarkin <mlarkin@openbsd.org>2017-03-25 07:33:46 +0000
commit8e37be76140e4a33ad6f72170fc16c4d96b5f0d6 (patch)
tree1a902cd46626f9a1acec3e4676f56a369b2b0192
parentmention Opteron A1100 systems (diff)
downloadwireguard-openbsd-8e37be76140e4a33ad6f72170fc16c4d96b5f0d6.tar.xz
wireguard-openbsd-8e37be76140e4a33ad6f72170fc16c4d96b5f0d6.zip
More PCI extended capabilities handling in pcidump.
From Simon Mages ok deraadt@
-rw-r--r--sys/dev/pci/pcireg.h4
-rw-r--r--usr.sbin/pcidump/pcidump.c9
2 files changed, 8 insertions, 5 deletions
diff --git a/sys/dev/pci/pcireg.h b/sys/dev/pci/pcireg.h
index 9676ad44a2d..ab53be0dce2 100644
--- a/sys/dev/pci/pcireg.h
+++ b/sys/dev/pci/pcireg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: pcireg.h,v 1.52 2017/03/22 07:21:39 jsg Exp $ */
+/* $OpenBSD: pcireg.h,v 1.53 2017/03/25 07:33:46 mlarkin Exp $ */
/* $NetBSD: pcireg.h,v 1.26 2000/05/10 16:58:42 thorpej Exp $ */
/*
@@ -606,7 +606,7 @@ typedef u_int8_t pci_revision_t;
#define PCI_PCIE_ECAP 0x100
#define PCI_PCIE_ECAP_ID(x) (((x) & 0x0000ffff))
#define PCI_PCIE_ECAP_VER(x) (((x) >> 16) & 0x0f)
-#define PCI_PCIE_ECAP_NEXT(x) ((x) >> 20)
+#define PCI_PCIE_ECAP_NEXT(x) (((x) >> 20) & 0xffc)
#define PCI_PCIE_ECAP_LAST 0x0
/*
diff --git a/usr.sbin/pcidump/pcidump.c b/usr.sbin/pcidump/pcidump.c
index 73d9e7c24e9..2acd7b209df 100644
--- a/usr.sbin/pcidump/pcidump.c
+++ b/usr.sbin/pcidump/pcidump.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pcidump.c,v 1.42 2017/03/16 22:05:46 deraadt Exp $ */
+/* $OpenBSD: pcidump.c,v 1.43 2017/03/25 07:33:46 mlarkin Exp $ */
/*
* Copyright (c) 2006, 2007 David Gwynne <loki@animata.net>
@@ -392,6 +392,7 @@ void
dump_pcie_enhanced_caplist(int bus, int dev, int func)
{
u_int32_t reg;
+ u_int32_t capidx;
u_int16_t ptr;
u_int16_t ecap;
@@ -407,10 +408,12 @@ dump_pcie_enhanced_caplist(int bus, int dev, int func)
ecap = PCI_PCIE_ECAP_ID(reg);
if (ecap >= nitems(pci_enhanced_capnames))
- ecap = 0;
+ capidx = 0;
+ else
+ capidx = ecap;
printf("\t0x%04x: Enhanced Capability 0x%02x: ", ptr, ecap);
- printf("%s\n", pci_enhanced_capnames[ecap]);
+ printf("%s\n", pci_enhanced_capnames[capidx]);
ptr = PCI_PCIE_ECAP_NEXT(reg);