Pali Rohár [Sat, 24 Feb 2024 15:12:26 +0000 (16:12 +0100)]
libpci: Define STATIC_ALIAS for DLL Windows builds
Windows builds for versioned symbols use inline asm .set directive which in
some cases makes x86-64 LTO compiler to drop the referenced value. Define
STATIC_ALIAS macro with VERSIONED_ABI (used) attribute which forces LTO
compiler to not drop the symbol from the final DLL library.
Pali Rohár [Sat, 24 Feb 2024 15:09:35 +0000 (16:09 +0100)]
libpci: win32-cfgmgr32: Do not include resolver for cfgmgr32 function for MinGW-w64
MinGW-w64 toolchain (as opposite to MinGW32) provides all needed cfgmgr32
functions in import library. Use import library and do not resolve
functions at runtime.
Pali Rohár [Wed, 14 Jun 2023 15:43:21 +0000 (17:43 +0200)]
windows: Fix setting permissions in grant_process_token_dacl_permissions()
Rewrite function to always add a new allow granting permissions at first
position in DACL. Normally all deny permissions are before allow
permissions, so previously allow permission could have been overridden by
explicit deny permission. With this change, our newly added allow
permission override any possible deny permission and always grant access
for asked process user.
Also properly handle automatic inheritance model which is in use since
Windows 2000 and handle also special case when DACL is not present which
gives allow access to everyone.
Pali Rohár [Sun, 1 Jan 2023 18:52:16 +0000 (19:52 +0100)]
windows: Make msvc __readeflags more readable
Semicolon in msvc __asm block means start of the comment, and not end of
the __asm statement, like it is for all other C statements. Also function
which uses msvc inline assembly cannot be inlined to another function
(compiler reports a warning about it, not a fatal error). So add explicit
curly brackets for __asm block, remove misleading semicolons and do not
declare function as inline.
Nikita Proshkin [Wed, 27 Dec 2023 09:45:00 +0000 (14:45 +0500)]
pcilmr: Add the ability to pass multiple links to the utility
* Add support for different utility modes;
* Make the default (now --margin) mode capable to accept several
components and run test for all of them;
* Add --full mode for sequential start of the test on all ready links
in the system;
* The complication of the main function is due to the need to pre-read the
parameters of the devices before starting the tests in order to calculate
Total ETA of the utility.
Reviewed-by: Sergei Miroshnichenko <s.miroshnichenko@yadro.com> Signed-off-by: Nikita Proshkin <n.proshkin@yadro.com>
Nikita Proshkin [Wed, 27 Dec 2023 09:44:59 +0000 (14:44 +0500)]
pcilmr: Add support for unique hardware quirks
Make it possible to change receiver margining parameters depending on
current hardware specificity.
In our tests Intel Ice Lake CPUs RC ports reported
MaxVoltageOffset = 50 (RxA), which led to results several times bigger
than the results of the hardware debugger.
Looks like in Intel Sapphire Rapids this was fixed, these CPU RC ports
report MaxVoltageOffset = 12 (RxA). To solve the problem it was decided
to hardcode Volt Offset to 12 (120 mV) for Ice Lake RC ports.
In the case of margining a specific link, only information about
Downstream and Upstream ports should be sufficient to decide whether to
use quirks, so the feature was implemented based on a list of devices
(vendor - device - revision triples), whose problems are known.
Back to Ice Lake ports, according to Integrators List on the pci-sig site,
the list of possible RC ports of Ice Lake Xeon's includes at least three
more options (with ids 347B/C/D) besides the one used in this commit, but
we don't have such processors to check the relevance of the MaxVoltageOffset
problem for these ports.
Reviewed-by: Sergei Miroshnichenko <s.miroshnichenko@yadro.com> Signed-off-by: Nikita Proshkin <n.proshkin@yadro.com>
Nikita Proshkin [Wed, 27 Dec 2023 09:44:57 +0000 (14:44 +0500)]
pcilmr: Add function for default margining results log
Lanes are rated according to the minimum/recommended values.
The minimum values are taken from PCIe Base Spec Rev 5.0 section 8.4.4.
30% UI recommended value for timing is taken from NVIDIA presentation
"PCIe 4.0 Mass Electrical Margins Data Collection".
Receiver lanes are called 'Weird' if all results of all receiver lanes
are equal to the spec minimum value.
Reviewed-by: Sergei Miroshnichenko <s.miroshnichenko@yadro.com> Signed-off-by: Nikita Proshkin <n.proshkin@yadro.com>
Nikita Proshkin [Wed, 27 Dec 2023 09:44:56 +0000 (14:44 +0500)]
pcilmr: Add logging functions for margining
* Implement option to turn on/off logging for margining;
* Support systems with several PCI domains;
* margin_log_margining function prints margining in progress log using
one line messages for each Receiver in the form:
"Margining - <direction> - Lanes [<current simultaneous lanes>] - ETA:
<current direction-lanes margining remaining time> Steps: <current
margining steps done> Total ETA: <utility run total remaining time>".
Reviewed-by: Sergei Miroshnichenko <s.miroshnichenko@yadro.com> Signed-off-by: Nikita Proshkin <n.proshkin@yadro.com>
Nikita Proshkin [Wed, 27 Dec 2023 09:44:55 +0000 (14:44 +0500)]
pcilmr: Add margining process functions
* Implement the margining flow as described in the section "Example
Software Flow for Lane Margining at Receiver"
of the PCIe Base Spec Rev 5.0;
* Implement margining commands formation and response parsing according
to the PCIe Base Spec Rev 5.0 table 4-26;
* Use Receiver margining parameters as described in the
PCIe Base Spec Rev 5.0 table 8-11;
* Support lane reversal and simultaneous margining of several link lanes.
Reviewed-by: Sergei Miroshnichenko <s.miroshnichenko@yadro.com> Signed-off-by: Nikita Proshkin <n.proshkin@yadro.com>
Nikita Proshkin [Wed, 27 Dec 2023 09:44:54 +0000 (14:44 +0500)]
pcilmr: Add functions for device checking and preparations before main margining processes
Follow the checklist from PCIe Base Spec Rev 5.0 section 4.2.13.3
"Receiver Margin Testing Requirements":
* Verify the Link is at 16 GT/s or higher data rate, in DO PM state;
* Verify that Margining Ready bit of the device is set;
* Disable the ASPM and Autonomous Speed/Width features for the duration
of the test.
Also verify that Upstream Port of the Link is Function 0 of a Device,
according to spec, only it must implement margining registers.
Reviewed-by: Sergei Miroshnichenko <s.miroshnichenko@yadro.com> Signed-off-by: Nikita Proshkin <n.proshkin@yadro.com>
Nikita Proshkin [Wed, 27 Dec 2023 09:44:52 +0000 (14:44 +0500)]
lspci: Add Lane Margining support to the lspci
Gather all the info available without writing to the config space.
Without any commands margining capability exposes only 3 status bits to
read through Margining Port Capabilities and Margining Port Status registers.
It makes sense to show them anyway. For example, Margining Ready bit
indicates whether the device is actually ready for the margining process.
Reviewed-by: Sergei Miroshnichenko <s.miroshnichenko@yadro.com> Signed-off-by: Nikita Proshkin <n.proshkin@yadro.com>
Nikita Proshkin [Wed, 27 Dec 2023 09:44:50 +0000 (14:44 +0500)]
lspci: Fix unsynchronized caches in lspci struct device and pci struct pci_dev
lspci initializes both caches for the device to the same memory block in
its scan_device function. Latter calls to config_fetch function will
realloc cache in struct device, but not in struct pci_dev leading to
the invalid pointer in the latter. pci_dev cache is used by pci_read_*
functions, what will lead to a possible use-after-free situations.
Pali Rohár [Sun, 8 Oct 2023 13:10:12 +0000 (15:10 +0200)]
lib: Refactor access to x86 I/O ports
On all systems except BeOS and Haiku are x86 I/O ports accessed in the
standard way by the x86 in/out instructions.
On more systems there are wrapper functions for x86 in/out instructions but
under different names and sometimes even for same system those names
depends on user version of toolchain/compiler. And also some systems have
same function names but switched order of arguments.
Simplify this code, define own wrapper functions for x86 in/out
instructions in new header file i386-io-access.h and use it for every
platform except BeOS and Haiku.
This change simplifies Windows port, duplicated code between SunOS and
Windows and also tons of redefined port functions in every port.
To not conlict with possible system functions included from some header
file, add intel_ prefix for every function included from the file
lib/i386-io-access.h into lib/i386-ports.c
Martin Mares [Fri, 29 Dec 2023 14:23:00 +0000 (15:23 +0100)]
Get rid of workarounds for Linux systems without pread/pwrite
Many things have changed since we introduced work-arounds for Linux
systems with missing pread/pwrite in 1999 (if you are curious, it was
in commit bc6346df8d89ece4814be7dff951ec1a7d259938).
I believe that it is supported by all reasonably recent Linux systems
now. After all, pread() was already defined by POSIX.1-2001.
This should also fix problems with musl libc mentioned in GitHub
issue #158.
Martin Mares [Fri, 29 Dec 2023 14:16:03 +0000 (15:16 +0100)]
Constants for CXL capability should not change
When CXL capability decoding was upgraded to revision 2 by commit c0ccce1b4cd5b42b17f2e8f7bae4031c311677ff, the value of PCI_CXL_DEV_LEN
in lib/header.h has changed.
This is probably not a good idea - programs using libpci can depend
on the exact value of this constant.
Let us revert PCI_CXL_DEV_LEN to the original value for revision 1
and add PCI_CXL_DEV_LEN_REV2 for the next revision.
Also, fixed a bug in the decoder which caused it to read past the
end of the buffer for a capability which is declared as revision 2,
but too short.
Pali Rohár [Thu, 18 May 2023 19:36:50 +0000 (21:36 +0200)]
libpci: ecam: Fix big address range mappings
If more buses span continuous address space then there can be up to the
256 MB long address range which ecam backend tries to map.
Such huge space cannot be mapped on some memory limited systems. And also
it is not needed to map whole 256 MB long address range because ecam
backend cache uses mapping only for one bus. One bus has maximal mapping
size just 32*8*4096 bytes.
Pali Rohár [Thu, 17 Aug 2023 20:03:19 +0000 (22:03 +0200)]
libpci: win32-cfgmgr32: Do not use GetWindowsDirectory()
GetWindowsDirectory() function returns HOME user folder if application is
running on the Terminal Server. So this function is not suitable.
Instead of use GetSystemDirectory() which returns path to system32 folder
or GetSystemWindowsDirectory() which returns path to Windows folder (but
this is not available on all Windows versions).
Pali Rohár [Thu, 17 Aug 2023 19:15:02 +0000 (21:15 +0200)]
libpci: win32-kldbg: Fix driver constructing path
Get*Directory() functions have strange API. When called with zero buffer
they return length of the required buffer for storing path including
nul-term in TCHAR units (which is 1 for ANSI builds and 2 for UNICODE
builds). When called with non-zero buffer which can store full path they
return length of the path without nul-term (again in TCHAR units).
GetWindowsDirectory() function returns HOME user folder if application is
running on the Terminal Server. So this function is not suitable.
Fix calculation of path buffer for UNICODE builds and instead of usage
GetWindowsDirectory() function with concatenating "\\system32" string, use
function GetSystemDirectory() which returns path directly to system32
folder and which works correctly also on Terminal Server (per KB281316).
Ilpo Järvinen [Fri, 8 Dec 2023 10:13:07 +0000 (12:13 +0200)]
lspci: Add PCIe 6.0 data rate (64 GT/s) also to LnkCap2
While commit 5bdf63b6b1bc ("lspci: Add PCIe 6.0 data rate (64 GT/s)
support") added 64 GT/s support to some registers, LnkCap2 Supported
Link Speeds Vector was not included.
Add PCIe 6.0 data rate bit check also into
cap_express_link2_speed_cap().
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Ashok Raj [Wed, 18 Oct 2023 21:34:15 +0000 (14:34 -0700)]
Subject: lspci: Display PASID required attribute in Page Status Register.
Display the PASID required attribute in the Page Request Status Register.
When set, the function expects a PASID on Page Group Response (PRG)
messages when the corresponding page request had a PASID.
Decode the PCIe DevCtl2 End-to-End TLP Prefix Blocking bit. The
"EETLPPrefixBlk" format is analogous to the existing "EETLPPrefix" format
used for the corresponding DevCap2 bit.
Martin Mares [Sat, 22 Jul 2023 21:47:13 +0000 (23:47 +0200)]
update-pciids: Re-compress pci.ids if needed
Previously, if pciutils were configured with compression of pci.ids,
update-pciids downloaded the gzipped version. Now, it downloads the
most compressed version for which tools are found installed, and
recompresses it to gzip if needed.
David Edmondson [Wed, 19 Jul 2023 14:16:41 +0000 (15:16 +0100)]
lspci: Use mangled vendor/device ID when examining vendor caps
Given that PCI VFs are expected to have a vendor and device ID of
0xffff, when examining vendor capabilities use the mangled vendor and
device IDs (typically copied from the PF) rather than those read from
the VF configuration space.
Signed-off-by: David Edmondson <david.edmondson@oracle.com>