Skip to content

Pci: fixes and unit testings#695

Merged
dgarske merged 14 commits intowolfSSL:masterfrom
rizlik:fix-pci
Feb 25, 2026
Merged

Pci: fixes and unit testings#695
dgarske merged 14 commits intowolfSSL:masterfrom
rizlik:fix-pci

Conversation

@rizlik
Copy link
Copy Markdown
Contributor

@rizlik rizlik commented Feb 25, 2026

This PR address several problems in PCI code:

  • correctly sizing of 64bit BAR
  • fix bugs in error path don't restoring state correctly
  • fix wrong register offset for bridge I/O window settings
  • fix using the offset instead of address in pci_config_io_write16/read16
  • minors

It also add unit testi to pci.c, to a coverage of 97.8%

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes critical bugs in the PCI enumeration code and adds comprehensive unit tests achieving 97.8% code coverage.

Changes:

  • Fixed 64-bit BAR size detection by ensuring both upper and lower BAR registers are written with probe mask before reading size
  • Corrected PCI bridge I/O window register offsets from incorrect 0x30/0x32 to spec-compliant 0x1C/0x1D
  • Fixed I/O config space read/write functions to use offset values instead of full encoded addresses
  • Added proper error path state restoration in bridge programming
  • Fixed BAR restore to use correct offset (bar_off instead of bar_idx)
  • Added extensive unit test infrastructure with mock PCI topology

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
tools/unit-tests/unit-pci.c Complete rewrite with mock PCI topology infrastructure and 25+ comprehensive test cases covering all major code paths including error handling
src/pci.c Multiple critical bug fixes: 64-bit BAR sizing, I/O window offsets, I/O config read/write offset handling, error path restoration, BAR restore offset fix, and debug output cleanup
include/pci.h Corrected I/O base/limit register offsets and changed pci_enum_bus return type from uint32_t to int

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings February 25, 2026 12:48
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

dgarske
dgarske previously approved these changes Feb 25, 2026
Copy link
Copy Markdown
Contributor

@dgarske dgarske left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you Marco!

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings February 25, 2026 16:23
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@dgarske dgarske merged commit 38e2a1f into wolfSSL:master Feb 25, 2026
311 of 312 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants