devices: vfio_pci: MMIO BAR allocation for devices on non-root buses

Since we'll be putting all PCI devices on non-root buses behind virtual
PCI-E root ports, MMIO BARs in such devices must be inside the forward
windows of their root ports. This presents additional requirements for
their MMIO BAR allocation:

1. All non-prefetchable BARs must be inside the same 32-bit MMIO window
2. All prefetchable BARs must be inside the same MMIO window, but
   different than the non-prefetchable MMIO window
3. Both windows must be 1MB-aligned
4. No other PCI devices should occupy MMIO space in these windows

Allocate the entire window from the system resource allocator to prevent
any space within the window from being used elsewhere. To maximize
memory space efficiency, use VfioResourceAllocator for BAR allocation.

BUG=b:185084350
TEST=passthrough a vfio-pci device with bus_number > 0 and static connet it
behind a pcie root port, then check pcie RP and vfio-pci device function in
guest.

Change-Id: Ic9865afc48eb3ff9fa475dbcfdf90642b012980c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3166888
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
7 files changed
tree: 12df70bb1a4d08b98041045ee243d16aa12d717e
  1. .cargo/
  2. .devcontainer/
  3. .github/
  4. aarch64/
  5. acpi_tables/
  6. arch/
  7. bin/
  8. bit_field/
  9. ci/
  10. common/
  11. crosvm-fuzz/
  12. crosvm_control/
  13. crosvm_plugin/
  14. devices/
  15. disk/
  16. docs/
  17. fuse/
  18. gpu_display/
  19. hypervisor/
  20. infra/
  21. integration_tests/
  22. kernel_cmdline/
  23. kernel_loader/
  24. kvm/
  25. kvm_sys/
  26. libcras_stub/
  27. libvda/
  28. linux_input_sys/
  29. logo/
  30. net_sys/
  31. net_util/
  32. power_monitor/
  33. protos/
  34. qcow_utils/
  35. resources/
  36. rutabaga_gfx/
  37. seccomp/
  38. src/
  39. system_api_stub/
  40. tests/
  41. third_party/
  42. tools/
  43. tpm2/
  44. tpm2-sys/
  45. usb_sys/
  46. usb_util/
  47. vfio_sys/
  48. vhost/
  49. virtio_sys/
  50. vm_control/
  51. vm_memory/
  52. x86_64/
  53. .dockerignore
  54. .gitignore
  55. .gitmodules
  56. .rustfmt.toml
  57. ARCHITECTURE.md
  58. Cargo.toml
  59. CONTRIBUTING.md
  60. LICENSE
  61. navbar.md
  62. OWNERS
  63. README.chromeos.md
  64. README.md
  65. run_tests
  66. rust-toolchain
  67. setup_cros_cargo.sh
  68. test_all
  69. unblocked_terms.txt
README.md

crosvm - The Chrome OS Virtual Machine Monitor

crosvm is a virtual machine monitor (VMM) based on Linux’s KVM hypervisor, with a focus on simplicity, security, and speed. crosvm is intended to run Linux guests, originally as a security boundary for running native applications on the Chrome OS platform. Compared to QEMU, crosvm doesn’t emulate architectures or real hardware, instead concentrating on paravirtualized devices, such as the virtio standard.

crosvm is currently used to run Linux/Android guests on Chrome OS devices.

Logo