Page MenuHomeFreeBSD

pci_user: Add compatibility padding
ClosedPublic

Authored by jfree on Aug 31 2025, 7:57 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Oct 10, 5:00 PM
Unknown Object (File)
Fri, Oct 10, 5:00 PM
Unknown Object (File)
Fri, Oct 10, 5:00 PM
Unknown Object (File)
Fri, Oct 10, 11:37 AM
Unknown Object (File)
Sat, Sep 20, 2:19 AM
Unknown Object (File)
Fri, Sep 19, 9:42 AM
Unknown Object (File)
Thu, Sep 18, 8:01 PM
Unknown Object (File)
Wed, Sep 17, 8:13 PM
Subscribers

Details

Summary

Avoid future compatibility churn when adding new members to struct
pci_conf by introducing some padding.

An additional member, pc_reported_len, has also been added to report the
length of the valid portion of an encompassing pci_conf. This allows
users to verify that their definition of pci_conf matches the kernel's,
preventing the use of invalid data.

Test Plan

Test case has been updated to verify that pc_reported_len == offsetof(struct pci_conf, pc_spare): https://reviews.freebsd.org/P644

This works on both 32 and 64 bit binaries:

[root@freebsd ~/tests/pci]$ ./pci15 | tail
vendor: 32902
device: 4110
class: 2
subclass: 0
progif: 0
revid: 3
driver: em
unit: 0
NUMA node: 0
Reported length: 64

[root@freebsd ~/tests/pci]$ ./pci15_32 | tail
vendor: 32902
device: 4110
class: 2
subclass: 0
progif: 0
revid: 3
driver: em
unit: 0
NUMA node: 0
Reported length: 52

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

jfree requested review of this revision.Aug 31 2025, 7:57 PM
jfree edited the test plan for this revision. (Show Details)

This looks great! I'd suggest a kyua test for this, but once we start getting hardware involved in testing it gets dicy.

This revision is now accepted and ready to land.Aug 31 2025, 11:41 PM
This revision was automatically updated to reflect the committed changes.