Page MenuHomeFreeBSD

bhyve: trap protected BAR regions of passthru devices
ClosedPublic

Authored by corvink on May 24 2024, 11:34 AM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Dec 9, 9:04 AM
Unknown Object (File)
Tue, Nov 25, 5:58 PM
Unknown Object (File)
Sat, Nov 15, 9:58 AM
Unknown Object (File)
Nov 11 2025, 11:03 PM
Unknown Object (File)
Nov 8 2025, 5:00 PM
Unknown Object (File)
Nov 7 2025, 11:31 PM
Unknown Object (File)
Nov 6 2025, 12:44 PM
Unknown Object (File)
Oct 31 2025, 8:05 AM
Subscribers

Details

Summary

At the moment, the list of protected BAR regions is unused by the passthru
emulation. Make use of it when mapping the BAR regions. This causes bhyve to
trap those regions.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 64801
Build 61685: arc lint + arc unit

Event Timeline

usr.sbin/bhyve/pci_passthru.c
1311–1312

Have you tried using tools/build/checkstyle9.pl?

1341
corvink added inline comments.
usr.sbin/bhyve/pci_passthru.c
1311–1312

Wasn't aware of this helper tool. I'm always using the top level .clang-format. Unfortunately, it seems to be incorrect for some cases.

Seems ok to me overall.

usr.sbin/bhyve/pci_passthru.c
1312
1342

You could perhaps use trunc_page and round_page here if you wished:

handler_off = trunc_page(handler->off);
handler_end = round_page(handler->off + handler->len);
1347
  • fix style issues
  • make use of trunc_page and round_page
  • rename len to size to match common naming in pci_passthru.c
This revision is now accepted and ready to land.Jun 30 2025, 6:30 PM