Pali Rohár [Fri, 29 Mar 2024 20:19:27 +0000 (21:19 +0100)]
windows: Do not show unwanted file-not-found GUI message box
Sometimes SEM_FAILCRITICALERRORS flag (disable critical-error-handler GUI
messages) is not enough for LoadLibrary() and SEM_NOOPENFILEERRORBOX flag
(disable file-not-found GUI messages) is needed too to prevent showing GUI
messages on LoadLibrary() failures.
Pali Rohár [Tue, 27 Feb 2024 23:32:08 +0000 (00:32 +0100)]
libpci: ecam: Fix scanning of Extended BIOS Data Area for ACPI RSDP
At physical address 0x40E (part of BDA) is stored indirect 16-bit paragraph
offset to the EBDA, and not the EBDA itself. Fix it.
ACPI code in linux kernel checks if the EBDA offset in BDA is above
physical address 0x400. Do the same check here. It is for detection if EBDA
is present as it does not have to be on the old computers or in some
virtualised environments.
Pali Rohár [Sun, 25 Feb 2024 02:22:08 +0000 (03:22 +0100)]
Makefile: Pass CFLAGS also when linking executable
Optimization flags like -O2 from $(OPT) passed via $(CFLAGS) used during
compiling individual object files are ignored when gcc's LTO is enabled for
the linking final executable.
Optimization flags used for compiling individual object files should be
same as optimization flags for linking final executable.
Fix propagation of $(CFLAGS) and $(OPT) when LTO is enabled.
PCIe r6.1, sec 7.5.3.3 defines "TEE-IO Supported" in the PCI Express Device
Capabilities Register which indicates that the function implements
the TEE-IO functionality as described by the TEE Device Interface Security
Protocol (TDISP, PCIe r6.1, chapter 11).
ls-ecaps: Add decode support for IDE Extended Capability
IDE (Integrity & Data Encryption) Extended Capability defined in [1]
implements control of the PCI link encryption. The verbose level > 2 prints
offsets of the fields to make running setpci easier.
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