]> git.ipfire.org Git - thirdparty/pciutils.git/log
thirdparty/pciutils.git
17 months agoMerge remote-tracking branch 'pali/i386-io-windows'
Martin Mares [Sun, 13 Nov 2022 16:05:46 +0000 (17:05 +0100)] 
Merge remote-tracking branch 'pali/i386-io-windows'

17 months agoMerge remote-tracking branch 'pali/linux-ioperm'
Martin Mares [Sun, 13 Nov 2022 16:05:19 +0000 (17:05 +0100)] 
Merge remote-tracking branch 'pali/linux-ioperm'

17 months agoMerge remote-tracking branch 'pali/win32-cfgmgr32'
Martin Mares [Sun, 13 Nov 2022 16:04:10 +0000 (17:04 +0100)] 
Merge remote-tracking branch 'pali/win32-cfgmgr32'

17 months agoMerge remote-tracking branch 'pali/i386-ports'
Martin Mares [Sun, 13 Nov 2022 16:03:40 +0000 (17:03 +0100)] 
Merge remote-tracking branch 'pali/i386-ports'

18 months agowindows: Codepage in resource file is 16-bit number
Pali Rohár [Wed, 9 Nov 2022 19:27:23 +0000 (20:27 +0100)] 
windows: Codepage in resource file is 16-bit number

18 months agoi386-ports: Fix intel_io_lock usage
Pali Rohár [Sun, 6 Nov 2022 17:57:39 +0000 (18:57 +0100)] 
i386-ports: Fix intel_io_lock usage

Do not call pci_generic_block_read() and pci_generic_block_write()
functions when io is locked. These functions call back same backend
read/write function which tries to lock and unlock io again.

18 months agolibpci: win32-cfgmgr32: Fix typo
Pali Rohár [Sat, 22 Oct 2022 14:58:21 +0000 (16:58 +0200)] 
libpci: win32-cfgmgr32: Fix typo

18 months agolibpci: win32-cfgmgr32: Fix parsing paths in NT format
Pali Rohár [Mon, 18 Apr 2022 14:53:59 +0000 (16:53 +0200)] 
libpci: win32-cfgmgr32: Fix parsing paths in NT format

NT namespace separator may be single or double backslash.

18 months agoi386-io-linux: Prefer usage of ioperm()
Pali Rohár [Sun, 6 Nov 2022 12:58:55 +0000 (13:58 +0100)] 
i386-io-linux: Prefer usage of ioperm()

Since Linux 2.6.8, it is possible to use ioperm() syscall to gain access
for all I/O ports. Because iopl() syscall before Linux 5.5 allowed
userspace to disable interrupts, prefer usage of ioperm() syscall and ask
for access only for PCI ports.

18 months agowindows: Put name and version information into lspci/setpci executables
Pali Rohár [Sat, 5 Nov 2022 19:08:33 +0000 (20:08 +0100)] 
windows: Put name and version information into lspci/setpci executables

Extend existing .in resource template file and generate resource objects
also for lspci.exe and setpci.exe executables.

18 months agocxl: Fix Register Locator DVSEC decoding
Jaxon Haws [Mon, 31 Oct 2022 21:57:43 +0000 (16:57 -0500)] 
cxl: Fix Register Locator DVSEC decoding

Fix decoding of register blocks by introducing offset to position
calculation (8.1.9 of CXL 3.0 spec) and removed unused defines for
Register Locator DVSEC.

Signed-off-by: Jaxon Haws <jaxon.haws@amd.com>
18 months agolibpci: i386-io-windows.h: Improve ProcessUserModeIOPL error message
Pali Rohár [Sat, 5 Mar 2022 23:25:02 +0000 (00:25 +0100)] 
libpci: i386-io-windows.h: Improve ProcessUserModeIOPL error message

Show error message from intel_setup_io() function into debug area instead
of error area. This is what other backends do as intel_setup_io() is called
during quite detect phase, which may fail.

Also show human readable failure instead of magic code number.

18 months agoMerge remote-tracking branch 'pali/win32-dll'
Martin Mares [Sun, 30 Oct 2022 15:26:43 +0000 (16:26 +0100)] 
Merge remote-tracking branch 'pali/win32-dll'

18 months agolibpci: Put name and version information into DLL library
Pali Rohár [Sun, 8 May 2022 12:31:11 +0000 (14:31 +0200)] 
libpci: Put name and version information into DLL library

Generate rc file from in template and fill DLL name and DLL version from
Makefile.

It looks like that the only possible way via GNU tools to specify version
information for DLL library is via text rc file compiled as COFF object
file via GNU windres and linked into the final DLL library via GNU ld.

18 months agolibpci: Do not call unversioned symbols from libpci itself
Pali Rohár [Sun, 8 May 2022 08:52:35 +0000 (10:52 +0200)] 
libpci: Do not call unversioned symbols from libpci itself

Windows version of GNU LD has bugs which cause that linker would translate
this unknown unversioned symbols to some random version.

So change pci_fill_info() to pci_fill_info_v38() in lib/filter.c to ensure
that last version of this function would be used also by Windows version of
GNU LD linker.

Before this change GNU LD translated this function call to symbol
_pci_fill_info@LIBPCI_3.0. After this change GNU LD translate it to
_pci_fill_info@LIBPCI_3.8.

18 months agolibpci: Add support for building versioned shared Windows DLL library libpci3.dll
Pali Rohár [Sun, 8 May 2022 08:25:59 +0000 (10:25 +0200)] 
libpci: Add support for building versioned shared Windows DLL library libpci3.dll

PE/COFF format, used by DLL libraries, does not support version symbols
like ELF format. Recommendation from Microsoft for DLL symbol versioning is
to use DLL API sets. But DLL API sets scheme requires for every API change
to generated a new slim forwarding DLL library, which is unsuitable for
distribution which wants just one DLL library with all version symbols.

So instead of Microsoft recommended scheme for DLL versioning, use new
different versioning scheme: Symbol is composed by function name, at (@)
character and version string (version is same as for ELF targets). Symbol
name without version information is added only into the DLL DEF file as
alias to symbol with higest version. So linker at application link time
resolves "unversioned" symbol to the versioned one via this alias and puts
"versioned" symbol into final executable. This works fine if GNU LD is
linking application via import library libpci3.dll.a generated from that
DLL DEF file libpci3.def. But does not work when linking directly to the
DLL library because library itself does not contain aliases. Note that GNU
LD does not support linking to DEF file (it is required to first generated
import library from DEF file).

Note that older GNU LD versions have bug which cause generation of
corrupted DLL files if some symbol contains dot (.) character. Hopefully
this bug was fixed in GNU LD 2.21.

At the end application lspci.exe requires library libpci3.dll with symbols
pci_alloc@LIBPCI_3.0, pci_init@LIBPCI_3.5, pci_fill_info@LIBPCI_3.8 and
therefore libpci3.dll stays backward compatible with future changes.

PE/COFF executables can reference symbols either via name or via its
ordinal number. Because DLL DEF files are generated from libpci version
script and generator ver2def.pl preserves order of symbols, it means that
ordinal numbers stay backward compatible unless order of lines in version
script is changed.

WARNINGS:

GCC an GNU LD for Windows target have some bugs which cause that
-fvisibility=hidden switch and __attribute__((visibility("default"))) does
not work. Seems that they are broken and ignored when building DLL library.
So instead use -Wl,--exclude-all-symbols switch with explicit DLL DEF file
for building DLL library, which seems to work. This switch is supported
since GNU LD 2.21.

GNU LD has also another bug which results in broken DLL library if input
DLL DEF file which describes symbols for exports, contains also symbol
aliases via == operator.

So do not specify symbol aliases in input DLL DEF file for building DLL
library. Instead construct separate DLL DEF file for building libpci3.dll
without symbol aliases and separate DLL DEF file libpci3.def with symbol
aliases for building import library libpci3.dll.a suitable for linking into
target applications. Note that operator == for symbol aliases is supported
since GNU dlltool 2.21.

Generate those two DLL DEF files via new script ver2def.pl from libpci.ver
version script. So exported functions and version symbols would be defined
only at one place in file libpci.ver.

Note that GNU LD for Windows targets has also broken support for version
scripts, it exports nonsense data and completely ignores version
information. So always use only DLL DEF files generated by ver2def.pl
script and never pass original version script to GNU LD.

Due to another bugs in GNU dlltool, ordinals for aliased symbols from DLL
DEF file are calculated incorrectly when building import library. So
calculate ordinals manually in ver2def.pl script and explicitly put then
into generated libpci3.def DLL DEF file for every symbol, including
aliases.

And because aliases are stored only in libpci3.def file (and in import
library libpci3.dll.a generated from that DEF file) and not in DLL library
libpci3.dll itself, it is required to link all libpci applications via
import library and not directly to libpci3.dll. This is limitation of
PE/COFF format used by DLL libraries.

So for building Windows DLL library libpci3.dll is needed to use GNU
binutils 2.21 or new.

18 months agoMerge remote-tracking branch 'pali/win32-readeflags'
Martin Mares [Sun, 30 Oct 2022 13:00:29 +0000 (14:00 +0100)] 
Merge remote-tracking branch 'pali/win32-readeflags'

18 months agoMerge remote-tracking branch 'pali/setpci-register-checks'
Martin Mares [Sun, 30 Oct 2022 12:57:00 +0000 (13:57 +0100)] 
Merge remote-tracking branch 'pali/setpci-register-checks'

18 months agosetpci: Check if standard register on device exist
Pali Rohár [Thu, 16 Jun 2022 14:14:56 +0000 (16:14 +0200)] 
setpci: Check if standard register on device exist

Some standard registers are available only on device with header type 0,
some only on header type 1, some other only on header type 2 and some on
header type 0 and 1. Add definitions which registers are available on which
header type and add check to access only available registers.

18 months agoMerge remote-tracking branch 'thesamesam/which-hunt'
Martin Mares [Sun, 30 Oct 2022 12:42:12 +0000 (13:42 +0100)] 
Merge remote-tracking branch 'thesamesam/which-hunt'

18 months agoMerge remote-tracking branch 'pali/win32-sysdbg'
Martin Mares [Sun, 30 Oct 2022 12:34:44 +0000 (13:34 +0100)] 
Merge remote-tracking branch 'pali/win32-sysdbg'

18 months agolspci: Fix Virtual Channel VC# Caps: MaxTimeSlots
Mikhail Bratchikov [Thu, 2 Jun 2022 11:24:02 +0000 (14:24 +0300)] 
lspci: Fix Virtual Channel VC# Caps: MaxTimeSlots

18 months agolib: Fix PCI_L1PM_SUBSTAT_CAP_L1PM_SUPP
Mikhail Bratchikov [Mon, 30 May 2022 15:21:57 +0000 (18:21 +0300)] 
lib: Fix PCI_L1PM_SUBSTAT_CAP_L1PM_SUPP

18 months agolib: Fix PCI_HT_SEC_CMD_DN
Mikhail Bratchikov [Fri, 20 May 2022 14:33:01 +0000 (17:33 +0300)] 
lib: Fix PCI_HT_SEC_CMD_DN

18 months agoMerge remote-tracking branch 'sthibaul/master'
Martin Mares [Sun, 30 Oct 2022 12:29:34 +0000 (13:29 +0100)] 
Merge remote-tracking branch 'sthibaul/master'

18 months agoCXL: Code clean-up
Martin Mares [Sun, 30 Oct 2022 12:23:12 +0000 (13:23 +0100)] 
CXL: Code clean-up

- We now pass capability length and revision to functions
  instead of reading them from config space again and again.

- Centralize fetching of the capability.

- Add checks for overrunning capability length.

- Avoid out-of-bounds reads from the array of register names.

- Sort capability list by ID.

18 months agoMerge remote-tracking branch 'jphaws/cxl'
Martin Mares [Sun, 30 Oct 2022 11:51:17 +0000 (12:51 +0100)] 
Merge remote-tracking branch 'jphaws/cxl'

18 months agoMerge remote-tracking branch 'pali/lspci-tree-filter'
Martin Mares [Sun, 30 Oct 2022 11:47:06 +0000 (12:47 +0100)] 
Merge remote-tracking branch 'pali/lspci-tree-filter'

18 months agolspci: Fix filter support (-s/-d) for subtrees in tree mode (-t)
Pali Rohár [Sat, 29 Oct 2022 12:09:51 +0000 (14:09 +0200)] 
lspci: Fix filter support (-s/-d) for subtrees in tree mode (-t)

18 months agocxl: Add placeholder for undecoded DVSECs
Ben Widawsky [Mon, 3 Aug 2020 15:55:40 +0000 (08:55 -0700)] 
cxl: Add placeholder for undecoded DVSECs

Signed-off-by: Ben Widawsky <ben.widawsky@intel.com>
Signed-off-by: Jaxon Haws <jaxon.haws@amd.com>
18 months agocxl: Add DVSEC Register Locator
Ben Widawsky [Sat, 1 Aug 2020 05:12:43 +0000 (22:12 -0700)] 
cxl: Add DVSEC Register Locator

Signed-off-by: Ben Widawsky <ben.widawsky@intel.com>
Co-authored-by: Jaxon Haws <jaxon.haws@amd.com>
Signed-off-by: Jaxon Haws <jaxon.haws@amd.com>
18 months agocxl: Add support for DVSEC port cap
Ben Widawsky [Fri, 31 Jul 2020 21:31:17 +0000 (14:31 -0700)] 
cxl: Add support for DVSEC port cap

Signed-off-by: Ben Widawsky <ben.widawsky@intel.com>
Co-authored-by: Jaxon Haws <jaxon.haws@amd.com>
Signed-off-by: Jaxon Haws <jaxon.haws@amd.com>
---
Add Viral Enable (Jonathan)
Add missing tab (Jonathan)
Add Alt Mem base/limit (Jonathan)

19 months agocxl: Implement more device DVSEC decoding
Ben Widawsky [Fri, 4 Jun 2021 03:09:12 +0000 (20:09 -0700)] 
cxl: Implement more device DVSEC decoding

Signed-off-by: Ben Widawsky <ben.widawsky@intel.com>
Co-authored-by: Jaxon Haws <jaxon.haws@amd.com>
Signed-off-by: Jaxon Haws <jaxon.haws@amd.com>
---
Fix ranges (Pali): https://github.com/pciutils/pciutils/pull/59#discussion_r806335631

19 months agocxl: Rename caps to be device caps
Ben Widawsky [Fri, 31 Jul 2020 19:55:31 +0000 (12:55 -0700)] 
cxl: Rename caps to be device caps

Signed-off-by: Ben Widawsky <ben.widawsky@intel.com>
Co-authored-by: Jaxon Haws <jaxon.haws@amd.com>
Signed-off-by: Jaxon Haws <jaxon.haws@amd.com>
19 months agocxl: Rework caps to new function
Ben Widawsky [Fri, 31 Jul 2020 19:37:15 +0000 (12:37 -0700)] 
cxl: Rework caps to new function

This will help upcoming caps

Signed-off-by: Ben Widawsky <ben.widawsky@intel.com>
Co-authored-by: Jaxon Haws <jaxon.haws@amd.com>
Signed-off-by: Jaxon Haws <jaxon.haws@amd.com>
19 months agocxl: Collect all DVSEC Device fields
Ben Widawsky [Fri, 31 Jul 2020 19:24:17 +0000 (12:24 -0700)] 
cxl: Collect all DVSEC Device fields

Signed-off-by: Ben Widawsky <ben.widawsky@intel.com>
Co-authored-by: Jaxon Haws <jaxon.haws@amd.com>
Signed-off-by: Jaxon Haws <jaxon.haws@amd.com>
19 months agocxl: Make id check more explicit
Ben Widawsky [Fri, 31 Jul 2020 19:12:42 +0000 (12:12 -0700)] 
cxl: Make id check more explicit

Currently only type 0 DVSEC caps are handled. Moving this check will
allow more robust type handling in the future.

Should be no functional change.

Signed-off-by: Ben Widawsky <ben.widawsky@intel.com>
Signed-off-by: Jaxon Haws <jaxon.haws@amd.com>
19 months agocxl: Rename variable to match other code
Ben Widawsky [Thu, 3 Jun 2021 19:02:17 +0000 (12:02 -0700)] 
cxl: Rename variable to match other code

The current variable is word sized, and so this makes the CXL code match
the rest of the code.

Signed-off-by: Ben Widawsky <ben.widawsky@intel.com>
Signed-off-by: Jaxon Haws <jaxon.haws@amd.com>
20 months agohurd: fix filling information
Samuel Thibault [Fri, 19 Aug 2022 21:35:10 +0000 (21:35 +0000)] 
hurd: fix filling information

The hurdish methods only implement the region and base information, the
rest should be taken from the generic method.

21 months agoMaint: Tag releases with my new PGP key
Martin Mares [Wed, 10 Aug 2022 06:43:00 +0000 (08:43 +0200)] 
Maint: Tag releases with my new PGP key

21 months agoAvoid adding multiple version tags to the same symbol
Martin Mares [Wed, 10 Aug 2022 06:34:28 +0000 (13:34 +0700)] 
Avoid adding multiple version tags to the same symbol

This is apparently forbidden in most versions of binutils.

22 months agolibpci: i386-io-windows.h: Do not define __readeflags() for GCC 4.9+
Pali Rohár [Sat, 16 Apr 2022 15:23:45 +0000 (17:23 +0200)] 
libpci: i386-io-windows.h: Do not define __readeflags() for GCC 4.9+

GCC header file <x86intrin.h> defines static inline function __readeflags()
which calls correct __builtin_ia32_readeflags_XX() builtin.

Header file <x86intrin.h> is included by MinGW-w64's <intrin.h> header file
in new versions of MinGW-w64 and <intrin.h> may be included transitionally
by some other header files automatically.

Defining __readeflags() as both macro and static inline function cause
compile errors.

Fix this compile error by not defining __readeflags() macro and instead
include GCC header file <x86intrin.h>.

22 months agolib/configure: respect $PKG_CONFIG completely
Sam James [Sun, 19 Jun 2022 22:53:42 +0000 (23:53 +0100)] 
lib/configure: respect $PKG_CONFIG completely

Signed-off-by: Sam James <sam@gentoo.org>
22 months agolib/configure: drop usage of which
Sam James [Sun, 19 Jun 2022 22:52:22 +0000 (23:52 +0100)] 
lib/configure: drop usage of which

'which' is not required by POSIX and is an external command which may not be
available, and 'command -v' does the job just fine.

Debian and Gentoo at least are both making efforts to drop which from
their base system package list.

Signed-off-by: Sam James <sam@gentoo.org>
22 months agosetpci: Define CAPABILITIES register
Pali Rohár [Tue, 14 Jun 2022 12:09:02 +0000 (14:09 +0200)] 
setpci: Define CAPABILITIES register

23 months agoMakefile: Split variable for output shared library and import linking library
Pali Rohár [Mon, 18 Apr 2022 20:40:58 +0000 (22:40 +0200)] 
Makefile: Split variable for output shared library and import linking library

Use new variable $(PCIIMPLIB) for storing name of the libpci import library
for linking with shared library $(PCILIB).

This would allow compilation of lspci and setpci applications on systems
where linking needs to be done with import library.

23 months agoMakefile: Define ABI_VERSION variable without leading dot
Pali Rohár [Mon, 18 Apr 2022 20:37:18 +0000 (22:37 +0200)] 
Makefile: Define ABI_VERSION variable without leading dot

This would simplify usage of ABI_VERSION variable for platforms which do
not use leading dot in file names.

23 months agoMakefile: Unify building of shared libpci library
Pali Rohár [Mon, 18 Apr 2022 20:35:12 +0000 (22:35 +0200)] 
Makefile: Unify building of shared libpci library

Move Darwin and Linux/ELF platform link switches to new PCILIB_LDFLAGS
variable.

23 months agoMakefile: Fix usage of empty IDSDIR
Pali Rohár [Sun, 29 May 2022 15:41:07 +0000 (17:41 +0200)] 
Makefile: Fix usage of empty IDSDIR

When IDSDIR is empty then current lspci/setpci directory is assumed.
So install PCI_IDS into SBINDIR in this case.

23 months agoMakefile: Remove duplicate slash for $(DESTDIR) install target
Pali Rohár [Sun, 29 May 2022 15:22:33 +0000 (17:22 +0200)] 
Makefile: Remove duplicate slash for $(DESTDIR) install target

2 years agopcilib.man: Include information about win32-sysdbg
Pali Rohár [Mon, 7 Mar 2022 20:21:44 +0000 (21:21 +0100)] 
pcilib.man: Include information about win32-sysdbg

2 years agolibpci: Add new windows NT sysdbg implementation
Pali Rohár [Sun, 2 Jan 2022 19:51:02 +0000 (20:51 +0100)] 
libpci: Add new windows NT sysdbg implementation

NT SysDbg interface allow access to the PCI config space. Only devices on
the first domain are available and only first 256 bytes of the PCI config
space can be accessed. Compared to intel-conf1 access, this API is race
free as NT kernel serialize access to PCI I/O ports. This NT SysDbg API is
used by the !pci command of 32-bit WinDbg kernel debugger for displaying
PCI config space. Debug privilege is required to use this NT interface.

2 years agoReleased as 3.8.0. v3.8.0
Martin Mares [Mon, 18 Apr 2022 16:48:26 +0000 (18:48 +0200)] 
Released as 3.8.0.

2 years agoFilters: Fixed symbol versioning
Martin Mares [Mon, 18 Apr 2022 16:47:00 +0000 (18:47 +0200)] 
Filters: Fixed symbol versioning

2 years agoREADME and ChangeLog for 3.8.0.
Martin Mares [Fri, 15 Apr 2022 23:55:33 +0000 (01:55 +0200)] 
README and ChangeLog for 3.8.0.

2 years agoDocument new filter syntax in man pages
Martin Mares [Fri, 15 Apr 2022 23:26:19 +0000 (01:26 +0200)] 
Document new filter syntax in man pages

2 years agoFilters now support partially specified classes and also prog-if's
Martin Mares [Fri, 15 Apr 2022 23:22:44 +0000 (01:22 +0200)] 
Filters now support partially specified classes and also prog-if's

Rewritten the filter parser, the old code was too twisted to extend.

2 years agopciutils.lsm: metalab.unc.edu is gone
Martin Mares [Fri, 15 Apr 2022 22:21:39 +0000 (00:21 +0200)] 
pciutils.lsm: metalab.unc.edu is gone

2 years agoUpdated pci.ids to today's snapshot
Martin Mares [Fri, 15 Apr 2022 22:17:33 +0000 (00:17 +0200)] 
Updated pci.ids to today's snapshot

2 years agolspci: Fix detection of memory space bar
Pali Rohár [Thu, 10 Mar 2022 20:38:18 +0000 (21:38 +0100)] 
lspci: Fix detection of memory space bar

intel-conf1 backend never show AtomicOpsCap: capabilities despite the fact
that is successfuly detects memory bars on device. But other backends show
this capability.

Error is in device_has_memory_space_bar() function, it expects that ->size
member is always filled. But size of the BAR is not available in PCI config
space and therefore raw backends cannot retrieve it.

Probably intention of the non-zero check was to verify that base address
was filled with non-zero size. So either base address is non-zero or length
is non-zero. Adjust check.

2 years agolspci: Fix detection of extended capabilities
Pali Rohár [Sat, 5 Mar 2022 23:22:54 +0000 (00:22 +0100)] 
lspci: Fix detection of extended capabilities

Bus may report all-ones when trying to access non-existent extended space.
Same check is also in lib/caps.c extended space parser.

2 years agolspci: Fix detection of virtual regions
Pali Rohár [Sat, 5 Mar 2022 23:22:03 +0000 (00:22 +0100)] 
lspci: Fix detection of virtual regions

There are many issues with detection of virtual regions.

1. Variable for detecting virtual region is global and if one BAR is marked
   as virtual then all remaining BARs are treated as virtual too as this
   variable is not reset at next loop iteration.

2. Lower address is read from flg variable which on backends without config
   space is initialized from PCI flags, not from base address.

3. Code mixes at many places PCI flags, resource flags, PCI addresses and
   resource addresses. Some backends reports PCI flags in PCI addresses,
   some not.

Cleanup mess of ->base_addr, ->flags and PCI_BASE_ADDRESS. If backend
provides ->flags value (test via PCI_FILL_IO_FLAGS) then use it instead of
reading flags from pci config space.

Fix reading of PCI hw_lower and hw_upper addresses. If PCI_BASE_ADDRESS
reports different type than what is stored in base_addr then completely
ignore hw_lower and hw_upper values. It means that backend either provide
fiction information or provide resources in different order as they are
stored in hardware. In any case values from HW cannot be used as they do
not match values reported by backend.

And in the last case, make virtual variable local to the current BAR
processing and do not increment loop variable i when 64-bit MEM type is
detected via data from config space. It could miss some virtual resource
reported by the backend.

This change fixes displaying resources of PCI devices which have some
unset/unused BARs in the middle and OS reports virtual regions and
remaining regions without holes. E.g. HW BARs 0, 2, 5 are used and OS
reports base_addr 0, 1, 2, 3.

2 years agolspci: Fix handling of truncated lines for msvcrt.dll
Pali Rohár [Sun, 27 Feb 2022 23:06:00 +0000 (00:06 +0100)] 
lspci: Fix handling of truncated lines for msvcrt.dll

msvcrt.dll's vsnprintf() implementation does not fill terminating null byte
when overflow occurs and buffer size is returned.

2 years agolibpci: i386-io-windows.h: Fix error handling for GetProcessImageFileNameW() and...
Pali Rohár [Sun, 10 Apr 2022 11:58:38 +0000 (13:58 +0200)] 
libpci: i386-io-windows.h: Fix error handling for GetProcessImageFileNameW() and GetModuleFileNameExW()

These functions may require buffer which is larger than MAX_PATH (wide)
characters and their error handling is more complicated. Fix it.

2 years agolibpci: i386-io-windows.h: Fix MinGW build with pre-4.00 MSVCRT runtime library
Pali Rohár [Sun, 27 Feb 2022 19:02:37 +0000 (20:02 +0100)] 
libpci: i386-io-windows.h: Fix MinGW build with pre-4.00 MSVCRT runtime library

Like CRTDLL library, pre-4.00 MSVCRT runtime library does not provide I/O port functions.

2 years agolibpci: Always call pci_set_name_list_path() in pci_init_name_list_path()
Pali Rohár [Sun, 27 Feb 2022 00:57:38 +0000 (01:57 +0100)] 
libpci: Always call pci_set_name_list_path() in pci_init_name_list_path()

If pci_init_name_list_path() does not call pci_set_name_list_path() then
a->id_file_name variable is NULL and pci_load_name_list() would crash as it
tries to do fopen(NULL, ...).

If libpci was configured at compile time to use current executable path for
locating pci.ids file and it is not possible to determinate current
executable path then call pci_set_name_list_path() with just filename
without path (this would fallback to the current working directory).

2 years agolibpci: Compile windows i386-ports only for x86 CPU
Pali Rohár [Sun, 2 Jan 2022 14:38:42 +0000 (15:38 +0100)] 
libpci: Compile windows i386-ports only for x86 CPU

There are already arm32 and arm64 port of MinGW-w64 toolchain.

2 years agofbsd-device: One more fix
Martin Mares [Fri, 15 Apr 2022 21:51:21 +0000 (23:51 +0200)] 
fbsd-device: One more fix

Finishes the incomplete fix from 5c649bdcedfd823670dcbd74e9c38849d068db80.

2 years agoFix lspci: Power Management Control/Status PCI to PCI Bridge Support Extensions
Mikhail Bratchikov [Tue, 5 Apr 2022 11:34:49 +0000 (14:34 +0300)] 
Fix lspci: Power Management Control/Status PCI to PCI Bridge Support Extensions

2 years agoREADME: Mention cfgmgr32 for Windows
Pali Rohár [Sat, 26 Feb 2022 14:41:19 +0000 (15:41 +0100)] 
README: Mention cfgmgr32 for Windows

2 years agoREADME: Update information about Windows
Pali Rohár [Thu, 10 Feb 2022 19:41:53 +0000 (20:41 +0100)] 
README: Update information about Windows

Basic support for 64-bit systems is there.

2 years agopcilib.man: Include information about win32-cfgmgr32
Pali Rohár [Tue, 4 Jan 2022 13:19:18 +0000 (14:19 +0100)] 
pcilib.man: Include information about win32-cfgmgr32

2 years agolspci: Do not access config space when it is emulated
Pali Rohár [Tue, 28 Dec 2021 19:29:21 +0000 (20:29 +0100)] 
lspci: Do not access config space when it is emulated

Emulated config space contains only few information so it could look like
some valid config space. libpci compose emulated config space either from
struct pci_dev or put some fake information (when struct pci_dev does not
have them).

To prevent showing to user fake/bogus information about PCI devices, show
only information which are directly stored in struct pci_dev when emulated
config space is used.

Do it via setting lspci's header type to invalid value (byte)-1, so lspci
code will handle device as unknown without trying to interpret values
config space. This header type is set only in lspci, not in libpci, so
other libpci applications would see valid config space.

lspci users are probably not interested in fake information provided by
libpci just for purpose to export syntactically valid config space.
Information stored in struct pci_dev are the correct one (or rather what OS
things that is correct).

2 years agolibpci: Add windows cfgmgr32 implementation
Pali Rohár [Fri, 31 Dec 2021 16:49:00 +0000 (17:49 +0100)] 
libpci: Add windows cfgmgr32 implementation

Access via cfgmgr32.dll library allows to list PCI devices and retrieve
their basic properties and system resource configuration. Access is
available to all users and should not require special privileges, access
tokens, rights or permissions.

This cfgmgr32.dll library does not provide access to PCI config space.

2 years agolibpci: Implement virtual config space for provides without access to config space
Pali Rohár [Sun, 2 Jan 2022 12:33:12 +0000 (13:33 +0100)] 
libpci: Implement virtual config space for provides without access to config space

Add a new pci_dev member no_config_access which signals that there is no
access to config space for particular device. Reading operation in this
case should return data from emulated virtual config space. For provides
there is a new helper function pci_generic_read() which emulates config
spaces based on struct pci_dev members.

2 years agolspci: Show information also for devices with unknown header type
Pali Rohár [Sun, 27 Feb 2022 15:06:59 +0000 (16:06 +0100)] 
lspci: Show information also for devices with unknown header type

lspci sees header type with 0x7f value in case config space is not
accessible. It may be because of permission issues or missing backend
(e.g. on Windows) or because device itself does not respond to config
cycles and config space is inaccessible.

Inaccessible config space is common scenario for switchable PCIe GPU
cards. Some Nvidia and also some AMD cards when sleep then lspci sees
all-ones in their config space. But kernel has registered those cards and
some of their properties are cached ans available via sysfs or procfs (from
time when card was awake).

Currently lspci shows error message "Unknown header type 7f" and does not
parse any value neither from config space nor from sysfs backend.

So try to show at least information which kernel provided into libpci
struct pci_dev.

Set unknown values to zeros (instead of all-ones which are returned from
config space) and add a new function show_htype_unknown() for showing
additional information in case header type is unknown.

This change will also help new windows backend which has only emulated
config space and therefore valid data only in struct pci_dev.

2 years agolibpci: Define some more PCI_IORESOURCE flags (compatible with ioport.h)
Pali Rohár [Fri, 31 Dec 2021 16:48:10 +0000 (17:48 +0100)] 
libpci: Define some more PCI_IORESOURCE flags (compatible with ioport.h)

These flags define mapping between PCI config space and system resources.
So non-sysfs/procfs providers can fill these flags too.

2 years agoTried to fix the fbsd-device back-end
Martin Mares [Thu, 14 Apr 2022 12:17:07 +0000 (14:17 +0200)] 
Tried to fix the fbsd-device back-end

It was left broken by the fill_info reform.

2 years agopciutils: Add decode support for Data Object Exchange Extended Capability
Jonathan Cameron [Thu, 10 Feb 2022 16:19:45 +0000 (16:19 +0000)] 
pciutils: Add decode support for Data Object Exchange Extended Capability

PCI Data Object Exchange [1] provides a mailbox interface used as the
transport for various protocols defined by PCI-SIG and others. Make the
limited information in config space available. Note the Read/Write
Mailbox registers themselves are not currently parsed as the usefulness
of accessing one dword of a protocol is probably limited.

In future, operating systems may provide means to safely query the
supported protocols, but those have not yet been defined.

Example output:

Capabilities: [100 v1] Data Object Exchange
DOECap: IntSup+
Interrupt Message Number 001
DOECtl: IntEn+
DOESta: Busy- IntSta- Error- ObjectReady+

[1] PCIe r6.0, sections 6.30 and 7.9.24

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agolspci: Decode PCIe 6.0 Slot Power Limit values
Pali Rohár [Fri, 25 Feb 2022 18:12:09 +0000 (19:12 +0100)] 
lspci: Decode PCIe 6.0 Slot Power Limit values

When the Slot Power Limit Scale field equals 00b (1.0x) and Slot
Power Limit Value exceeds EFh, the following alternative encodings
are used:

  F0h   > 239 W and ≤ 250 W Slot Power Limit
  F1h   > 250 W and ≤ 275 W Slot Power Limit
  F2h   > 275 W and ≤ 300 W Slot Power Limit
  F3h   > 300 W and ≤ 325 W Slot Power Limit
  F4h   > 325 W and ≤ 350 W Slot Power Limit
  F5h   > 350 W and ≤ 375 W Slot Power Limit
  F6h   > 375 W and ≤ 400 W Slot Power Limit
  F7h   > 400 W and ≤ 425 W Slot Power Limit
  F8h   > 425 W and ≤ 450 W Slot Power Limit
  F9h   > 450 W and ≤ 475 W Slot Power Limit
  FAh   > 475 W and ≤ 500 W Slot Power Limit
  FBh   > 500 W and ≤ 525 W Slot Power Limit
  FCh   > 525 W and ≤ 550 W Slot Power Limit
  FDh   > 550 W and ≤ 575 W Slot Power Limit
  FEh   > 575 W and ≤ 600 W Slot Power Limit
  FFh   Reserved for Slot Power Limit Values above 600 W

Previously only values F0h, F1h and F2h were covered.

2 years agoMerge remote-tracking branch 'github/master'
Martin Mares [Thu, 10 Feb 2022 12:50:32 +0000 (13:50 +0100)] 
Merge remote-tracking branch 'github/master'

2 years agolspci: Replace find_driver() via libpci PCI_FILL_DRIVER
Pali Rohár [Mon, 27 Dec 2021 13:06:18 +0000 (14:06 +0100)] 
lspci: Replace find_driver() via libpci PCI_FILL_DRIVER

And implement this show_kernel() and show_kernel_machine() for all
platforms.

2 years agolibpci: sysfs: Implement support for PCI_FILL_DRIVER
Pali Rohár [Mon, 27 Dec 2021 13:05:47 +0000 (14:05 +0100)] 
libpci: sysfs: Implement support for PCI_FILL_DRIVER

In sysfs is driver name stored as symlink path of "driver" node.

2 years agolibpci: proc: Implement support for PCI_FILL_DRIVER
Pali Rohár [Mon, 27 Dec 2021 13:05:32 +0000 (14:05 +0100)] 
libpci: proc: Implement support for PCI_FILL_DRIVER

File /proc/bus/pci/devices contains optional driver name in the last 18th field.

2 years agolibpci: Define new string property PCI_FILL_DRIVER
Pali Rohár [Mon, 27 Dec 2021 13:04:59 +0000 (14:04 +0100)] 
libpci: Define new string property PCI_FILL_DRIVER

This change extends libpci library and allows providers to fill
PCI_FILL_DRIVER via native system APIs. As it is string property there is
no need to increase ABI version.

Intended usage in application is just:

  const char *driver = pci_get_string_property(d->dev, PCI_FILL_DRIVER);

2 years agolspci: Do not show -[00]- bus in tree output
Pali Rohár [Fri, 31 Dec 2021 13:39:51 +0000 (14:39 +0100)] 
lspci: Do not show -[00]- bus in tree output

Secondary or subordinate bus cannot be zero. Zero value could indicate
either invalid secondary bus value or the fact that secondary bus value was
not filled or indicates non-compliant PCI-to-PCI bridge. This change makes
tree output better readable when bus numbers are not known or not provided.

2 years agolspci: Build tree based on PCI_FILL_PARENT information
Pali Rohár [Tue, 28 Dec 2021 19:14:47 +0000 (20:14 +0100)] 
lspci: Build tree based on PCI_FILL_PARENT information

Topology reported by system (libpci provider) may be different from
topology built based on primary/secondary/subordinate numbers from PCI
bridges by lspci.

This happens for example when some non-compliant PCI-to-PCI bridge
with Type 0 header (e.g. Marvell one) is available in the system.

So add additional edges reported by libpci when building tree in lspci.

2 years agolibpci: sysfs: Implement support for PCI_FILL_PARENT
Pali Rohár [Tue, 28 Dec 2021 19:11:27 +0000 (20:11 +0100)] 
libpci: sysfs: Implement support for PCI_FILL_PARENT

2 years agolibpci: Add new option PCI_FILL_PARENT
Pali Rohár [Tue, 28 Dec 2021 19:09:57 +0000 (20:09 +0100)] 
libpci: Add new option PCI_FILL_PARENT

This change extends libpci and allows providers to fill parent pci_dev.
This is useful to retrieve topology as it is reported by the system itself.

2 years agolspci: Retrieve prog if, subsystem ids and revision id via libpci
Pali Rohár [Mon, 20 Dec 2021 21:39:42 +0000 (22:39 +0100)] 
lspci: Retrieve prog if, subsystem ids and revision id via libpci

Use pci_fill_info with CLASS_EXT and SUBSYS to fill this information.

lspci in some places reads class from what libpci provider fills in
dev->device_class and in some other places it reads directly from config
space. In dev->device_class is stored class possible different class as in
config space (e.g. if kernel is fixing class because device has bogus
information stored in config space).

With this change is class always read from dev->device_class which reflects
and respects lspci -b option (Bus-centric view). Same applies for subsystem
ids and revision id (note that prog if is part of class).

2 years agolibpci: sysfs: Implement CLASS_EXT and SUBSYS support
Pali Rohár [Mon, 27 Dec 2021 11:28:34 +0000 (12:28 +0100)] 
libpci: sysfs: Implement CLASS_EXT and SUBSYS support

In sysfs there are optional nodes with this information.

2 years agolibpci: generic: Implement SUBSYS also for PCI_HEADER_TYPE_BRIDGE
Pali Rohár [Mon, 20 Dec 2021 21:56:33 +0000 (22:56 +0100)] 
libpci: generic: Implement SUBSYS also for PCI_HEADER_TYPE_BRIDGE

Subsystem ids for PCI Bridges are stored in extended capability
PCI_CAP_ID_SSVID.

2 years agolibpci: generic: Implement CLASS_EXT and SUBSYS support
Pali Rohár [Mon, 27 Dec 2021 11:31:55 +0000 (12:31 +0100)] 
libpci: generic: Implement CLASS_EXT and SUBSYS support

PCI_FILL_SUBSYS is implemented only for PCI_HEADER_TYPE_NORMAL and
PCI_HEADER_TYPE_CARDBUS like in lspci.

2 years agolibpci: Add new options for pci_fill_info: CLASS_EXT and SUBSYS
Pali Rohár [Mon, 20 Dec 2021 21:07:28 +0000 (22:07 +0100)] 
libpci: Add new options for pci_fill_info: CLASS_EXT and SUBSYS

This change extends libpci library and allows providers to fill these
informations (Programming interface, Revision id and Subsystem ids) via
native system APIs, which sometimes may differs from what is stored in PCI
config space.

Programming interface is part of 24-bit Device Class number but apparently
libpci exports only high 16-bit of this number via device_class member.

2 years agolspci: Use PCI_FILL_BRIDGE_BASES to detect if range behind bridge is disabled or...
Pali Rohár [Sat, 20 Nov 2021 14:13:20 +0000 (15:13 +0100)] 
lspci: Use PCI_FILL_BRIDGE_BASES to detect if range behind bridge is disabled or unsupported

Show resources behind bridge as reported by PCI_FILL_BRIDGE_BASES.

I/O or Prefetchable memory behind bridge is unsupported by bridge if both
base and limit bridge registers are read-only and returns zero. So if base
and limit registers returns zero (which is valid enabled range) and kernel
reports that particular resource is disabled it means that resource is
unsupported. Both I/O or Prefetchable memory resources are only optional.

2 years agolibpci: Add support for filling bridge resources
Pali Rohár [Sat, 20 Nov 2021 13:36:40 +0000 (14:36 +0100)] 
libpci: Add support for filling bridge resources

Extend libpci API and ABI to fill bridge resources from sysfs.

2 years agolspci: Simplify printing range in show_range()
Pali Rohár [Sat, 20 Nov 2021 12:43:35 +0000 (13:43 +0100)] 
lspci: Simplify printing range in show_range()

Use just one printf() call with width format argument based on number of bits.

2 years agolspci: Show 16/32/64 bit width for address ranges behind bridge
Pali Rohár [Mon, 18 Oct 2021 14:58:33 +0000 (16:58 +0200)] 
lspci: Show 16/32/64 bit width for address ranges behind bridge

Type of address range is encoded in lower bits.

2 years agoMerge branch 'fill-info'
Martin Mares [Thu, 10 Feb 2022 12:49:06 +0000 (13:49 +0100)] 
Merge branch 'fill-info'

2 years agolibpci: i386-io-windows.h: Fix comment about CRTDLL
Pali Rohár [Thu, 10 Feb 2022 12:33:46 +0000 (13:33 +0100)] 
libpci: i386-io-windows.h: Fix comment about CRTDLL

There is no 64-bit version of CRTDLL library. MinGW-w64 provided bogus
64-bit import library for non-existent runtime DLL library, which was
recently deleted.