Commit Graph

10226 Commits

Author SHA1 Message Date
Julian Schindel
032f29da29 misc: replace as <pointer> casts with safer alternatives
`as` casts can change mutability, which quickly leads to undefined
behavior.

Signed-off-by: Julian Schindel <mail@arctic-alpaca.de>
2026-05-03 08:38:31 +00:00
Ruben Hakobyan
c97d635d40 hypervisor, vmm: Build and pass SNP ID block to launch finish
Add KvmSevSnpIdBlock and KvmSevSnpIdAuth structs matching the AMD
SEV-SNP Firmware ABI Spec (Rev 1.58), and build them from the IGVM
SNP ID block directive during launch finish. This properly populates
id_block_uaddr/id_auth_uaddr in KVM_SEV_SNP_LAUNCH_FINISH and derives
auth_key_en from the assembled author key, matching QEMU's behavior.

Thread the guest policy from sev_snp_init to launch_finish via an
atomic on KvmVm so the ID block gets the correct policy value.

Also track has_snp_id_block in IgvmLoadedInfo to enable the ID block
based on whether the IGVM file actually contains one, rather than
hardcoding it for KVM.

Signed-off-by: Ruben Hakobyan <hruben@meta.com>
2026-05-01 20:28:55 +00:00
Ruben Hakobyan
bfab43e252 vmm: Parse guest policy from IGVM initialization headers
Extract the SNP guest policy from IGVM initialization headers when
available, falling back to the default policy. This matches QEMU's
behaviour where only a non-zero IGVM policy overrides the default.

Signed-off-by: Ruben Hakobyan <hruben@meta.com>
2026-05-01 20:28:55 +00:00
Kevin Hui
4a91b4a608 vmm: Preserve SEV-SNP IGVM load ordering
Preserve the original IGVM import order for KVM SNP launch updates.
The launch digest is order-sensitive, so only coalesce adjacent pages
that already share the same page type and size. MSHV continues to
sort by GPA for hypercall batching.

Signed-off-by: Kevin Hui <kevinhui@meta.com>
2026-05-01 20:28:55 +00:00
Kevin Hui
982934fba0 vmm: Add SNP zero-page type for IGVM imports
Introduce the KVM_SNP_PAGE_TYPE_ZERO page type for ZERO
pages. AMD SEV SNP can accept ZERO pages as a page in which
the page memory is functionally just zeroes

Signed-off-by: Kevin Hui <kevinhui@meta.com>
2026-05-01 20:28:55 +00:00
Kevin Hui
e3e22d8e78 vmm: Add unit tests for generating hash blocks for SEV-SNP
Verify the SEV hash table layout, GUID placement, kernel/initrd/cmdline
digest values, and the setup_sects > boot_params size branch. These
guard against silent regressions in the launch digest computation.

Signed-off-by: Kevin Hui <kevinhui@meta.com>
2026-05-01 20:28:55 +00:00
Kevin Hui
70388fb1bb vmm: Introduce kernel hashes measured boot
This introduces the kernel hashes measured boot table into
cloud hypervisor if a cmdline and kernel is passed into an
SEV-SNP CVM, incorporating a kernel/cmdline/optional initrd
into a memory page that is measured into the launch digest
of a SEV-SNP CVM. If both --kernel and --cmdline are not
provided, we do not insert this data page

Signed-off-by: Kevin Hui <kevinhui@meta.com>
2026-05-01 20:28:55 +00:00
Ruben Hakobyan
9f1247fe60 devices: fw_cfg: Don't modify kernel header for KVM SEV-SNP guests
For KVM SEV-SNP guests, the VMM should not modify the kernel
boot header before sending it via fw_cfg. The guest firmware is expected
to set fields like type_of_loader itself.

For upcoming measured boot logic for SEV-SNP, modifying `type_of_loader`
causes the kernel hash computed by the VMM to diverge from the hash that
`sev-snp-measure` (and the guest firmware) compute, resulting in a
launch measurement mismatch.

This matches QEMU's behavior, which skips kernel header modifications
for confidential guests so the data sent via fw_cfg matches the
original kernel file provided by the user.

Signed-off-by: Ruben Hakobyan <hruben@meta.com>
2026-05-01 20:28:55 +00:00
Rob Bradford
ffeee2880f vmm: memory_manager: Handle sparse snapshot file on restore
Walk the input snapshot file extent by extent via lseek(SEEK_DATA) /
lseek(SEEK_HOLE) within each region's slot and read only those bytes
into guest RAM via the existing read_volatile_from primitive. Holes are
left as the guest mapping's natural zero-fill, which matches the source
content.

Symmetric counterpart to sparse-write on snapshot. Works for both new
sparse snapshots and old dense snapshots: a dense file has no holes, so
SEEK_DATA returns the full range as one extent and the I/O pattern
matches the previous behaviour.

If the input file's filesystem does not support SEEK_HOLE the code falls
back to the existing dense read path.

Measured on a 4 GiB shared-memory VM (2 vCPUs, ~340 MiB touched), total
restore time as reported by the in-tree timing instrumentation:

  Before (dense):  ~1487ms, reads 4.0 GiB from file
  After (sparse):  ~136ms,  reads 340 MiB from file (92% less I/O, 11x faster)

Assisted-by: Claude:Opus-4.7
Signed-off-by: Rob Bradford <rbradford@meta.com>
2026-05-01 15:40:50 +00:00
Rob Bradford
ee1d9dae34 vmm: memory_manager: Write snapshot file sparsely
For memfd-backed guest RAM regions, walk the backing fd extent by extent
via lseek(SEEK_DATA) / lseek(SEEK_HOLE) and write each populated extent
into the snapshot file's per-region slot via
std::os::unix::fs::FileExt::write_at. Pre-size the file with
set_len(total): on filesystems that support sparse files unwritten bytes
become real holes; on others the kernel zero-fills the allocation, which
is still byte-correct.

If set_len fails (some FUSE backends reject ftruncate-extend with
EOPNOTSUPP), fall back entirely to the dense write path which streams
bytes sequentially via write_volatile_to and never writes past the
growing EOF.

When the guest region has no backing file (anonymous mmap) or the
backing fd does not support SEEK_HOLE (hugetlbfs), fall back to the
dense write path on a per-region basis.

The on-disk byte stream is identical to the dense format from the
perspective of any reader using read/pread/mmap, so old readers see no
change.

Measured on a 4 GiB shared-memory VM (2 vCPUs, ~340 MiB touched), total
snapshot time as reported by the in-tree timing instrumentation:

  Before (dense):  ~2400ms, 4.0 GiB on disk
  After (sparse):  ~132ms,  340 MiB on disk (92% smaller, 18x faster)

Assisted-by: Claude:Opus-4.7
Signed-off-by: Rob Bradford <rbradford@meta.com>
2026-05-01 15:40:50 +00:00
Rob Bradford
bf3279f094 vmm: memory_manager: Add SEEK_DATA-based extent iterator
Adds next_data_extent: a streaming helper that returns the next
populated extent within a window of a file descriptor using
lseek(SEEK_DATA) / lseek(SEEK_HOLE). Used by subsequent commits to walk
the snapshot file extent-by-extent without collecting the full extent
list.

Returns an error on fds or filesystems without SEEK_HOLE support so the
caller can fall back to a dense write path.

Assisted-by: Claude:Opus-4.7
Signed-off-by: Rob Bradford <rbradford@meta.com>
2026-05-01 15:40:50 +00:00
Rob Bradford
739ea8c9fc ci: Remove lychee as a required CI step
Remove the dependency on lychee from all-green.

Signed-off-by: Rob Bradford <rbradford@meta.com>
2026-05-01 12:14:43 +01:00
Muminul Islam
89cae74ddd performance-metrics: Use default_kernel_cmdline helper
Replace explicit --kernel and --cmdline arguments with the
default_kernel_cmdline() helper in performance_net_throughput,
performance_net_latency, and performance_block_io. This
simplifies the code and ensures consistency with how the
kernel command line is configured across tests.

Signed-off-by: Muminul Islam <muislam@microsoft.com>
2026-05-01 09:36:58 +00:00
Muminul Islam
3440802c99 performance-metrics: CVM not supported on AArch64
Confidential VMs (CVM) are not currently supported on the
AArch64 architecture. Add an early check in the performance
metrics binary to exit with a clear error message when CVM
mode is selected on AArch64.

Signed-off-by: Muminul Islam <muislam@microsoft.com>
2026-05-01 09:36:58 +00:00
Muminul Islam
7d684e3add performance-metrics: Add --vm-type CLI argument
Add a --vm-type command-line argument to allow users to select
between 'regular' (default) and 'confidential' (CVM) VM types
when running performance tests.

Example: --vm-type confidential

Signed-off-by: Muminul Islam <muislam@microsoft.com>
2026-05-01 09:36:58 +00:00
Muminul Islam
ab7749a5ce performance-metrics: Apply vm_type override in run()
Apply the vm_type override from PerformanceTestOverrides to the
effective_control used during test execution, alongside the
existing test_timeout override.

Signed-off-by: Muminul Islam <muislam@microsoft.com>
2026-05-01 09:36:58 +00:00
Muminul Islam
56a986145e performance-metrics: Add vm_type to PerformanceTestOverrides
Add an optional vm_type field to PerformanceTestOverrides to
allow overriding the VM type at runtime. Include vm_type in
the Display output for override logging.

Signed-off-by: Muminul Islam <muislam@microsoft.com>
2026-05-01 09:36:58 +00:00
Muminul Islam
55e2700fbc performance-metrics: Use control.vm_type in all tests
Replace hardcoded GuestVmType::Regular with control.vm_type
in all performance test functions to support CVM benchmarking:
net_throughput, net_latency, boot_time, boot_time_pmem,
block_io, and restore_latency.

Signed-off-by: Muminul Islam <muislam@microsoft.com>
2026-05-01 09:36:58 +00:00
Muminul Islam
938db39e26 performance-metrics: Add vm_type param to new_guest
Update performance_test_new_guest() to accept a GuestVmType
parameter. When set to Confidential, configure the guest with
CVM-specific settings: vm_type, boot_timeout, and nested
virtualization disabled.

All callers pass GuestVmType::Regular to preserve existing
behavior.

Signed-off-by: Muminul Islam <muislam@microsoft.com>
2026-05-01 09:36:58 +00:00
Muminul Islam
82a0dc7252 performance-metrics: Add vm_type to PerformanceTestControl
Add a vm_type field of type GuestVmType to PerformanceTestControl,
defaulting to GuestVmType::Regular. Include vm_type in the Display
output for test control logging.

Signed-off-by: Muminul Islam <muislam@microsoft.com>
2026-05-01 09:36:58 +00:00
Muminul Islam
4b4845eb4d performance-metrics: Refactor run() to use effective_control
Consolidate override application into a single effective_control
variable built once before the test loop. This removes duplicated
timeout override logic from both warmup and measurement iterations.

Signed-off-by: Muminul Islam <muislam@microsoft.com>
2026-05-01 09:36:58 +00:00
Muminul Islam
11623a2183 test_infra: Implement Display for GuestVmType
Add Display trait implementation for GuestVmType to enable
formatted output of the VM type in logs and diagnostics.

Signed-off-by: Muminul Islam <muislam@microsoft.com>
2026-05-01 09:36:58 +00:00
Muminul Islam
0e7fcc623e test_infra: Implement FromStr for GuestVmType
Add FromStr trait implementation for GuestVmType to enable
parsing from CLI string arguments. Supports "regular" and
"confidential" string values.

Signed-off-by: Muminul Islam <muislam@microsoft.com>
2026-05-01 09:36:58 +00:00
Muminul Islam
246890802b build: update mshv-bindings/ioctls to 0.6.9
Update mshv-bindings and mshv-ioctls from 0.6.8 to 0.6.9
in workspace Cargo.toml and fuzz/Cargo.toml.

Signed-off-by: Muminul Islam <muislam@microsoft.com>
2026-05-01 08:52:44 +00:00
Julian Schindel
05d8606a32 vmm: replace unsafe with safe Vec creation for LocalX2Apic
The `LocalX2Apic` structs implements `IntoBytes`, so we can use the safe
abstraction instead having to use `unsafe`.

On-behalf-of: SAP julian.schindel@sap.com
Signed-off-by: Julian Schindel <julian.schindel@cyberus-technology.de>
2026-05-01 08:26:38 +00:00
dependabot[bot]
e0ab116a0c build(deps): bump the non-rust-vmm group across 2 directories with 11 updates
Bumps the non-rust-vmm group with 4 updates in the / directory: [cc](https://github.com/rust-lang/cc-rs), [jiff](https://github.com/BurntSushi/jiff), [pastey](https://github.com/as1100k/pastey) and [zbus_names](https://github.com/z-galaxy/zbus).
Bumps the non-rust-vmm group with 4 updates in the /fuzz directory: [libc](https://github.com/rust-lang/libc), [cc](https://github.com/rust-lang/cc-rs), [pastey](https://github.com/as1100k/pastey) and [winnow](https://github.com/winnow-rs/winnow).


Updates `cc` from 1.2.60 to 1.2.61
- [Release notes](https://github.com/rust-lang/cc-rs/releases)
- [Changelog](https://github.com/rust-lang/cc-rs/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.60...cc-v1.2.61)

Updates `jiff` from 0.2.23 to 0.2.24
- [Release notes](https://github.com/BurntSushi/jiff/releases)
- [Changelog](https://github.com/BurntSushi/jiff/blob/master/CHANGELOG.md)
- [Commits](https://github.com/BurntSushi/jiff/compare/jiff-static-0.2.23...jiff-static-0.2.24)

Updates `jiff-static` from 0.2.23 to 0.2.24
- [Release notes](https://github.com/BurntSushi/jiff/releases)
- [Changelog](https://github.com/BurntSushi/jiff/blob/master/CHANGELOG.md)
- [Commits](https://github.com/BurntSushi/jiff/compare/jiff-static-0.2.23...jiff-static-0.2.24)

Updates `pastey` from 0.2.1 to 0.2.2
- [Release notes](https://github.com/as1100k/pastey/releases)
- [Changelog](https://github.com/AS1100K/pastey/blob/master/CHANGELOG.md)
- [Commits](https://github.com/as1100k/pastey/compare/v0.2.1...v0.2.2)

Updates `zbus_names` from 4.3.1 to 4.3.2
- [Release notes](https://github.com/z-galaxy/zbus/releases)
- [Changelog](https://github.com/z-galaxy/zbus/blob/main/release-plz.toml)
- [Commits](https://github.com/z-galaxy/zbus/compare/zbus_names-4.3.1...zbus_names-4.3.2)

Updates `zvariant` from 5.10.0 to 5.10.1
- [Release notes](https://github.com/z-galaxy/zbus/releases)
- [Changelog](https://github.com/z-galaxy/zbus/blob/main/release-plz.toml)
- [Commits](https://github.com/z-galaxy/zbus/compare/zvariant-5.10.0...zvariant-5.10.1)

Updates `zvariant_derive` from 5.10.0 to 5.10.1
- [Release notes](https://github.com/z-galaxy/zbus/releases)
- [Changelog](https://github.com/z-galaxy/zbus/blob/main/release-plz.toml)
- [Commits](https://github.com/z-galaxy/zbus/compare/zvariant_derive-5.10.0...zvariant_derive-5.10.1)

Updates `zvariant_utils` from 3.3.0 to 3.3.1
- [Release notes](https://github.com/z-galaxy/zbus/releases)
- [Changelog](https://github.com/z-galaxy/zbus/blob/main/release-plz.toml)
- [Commits](https://github.com/z-galaxy/zbus/compare/zvariant_utils-3.3.0...zvariant_utils-3.3.1)

Updates `libc` from 0.2.185 to 0.2.186
- [Release notes](https://github.com/rust-lang/libc/releases)
- [Changelog](https://github.com/rust-lang/libc/blob/0.2.186/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/libc/compare/0.2.185...0.2.186)

Updates `bitfield-struct` from 0.12.1 to 0.13.0
- [Release notes](https://github.com/wrenger/bitfield-struct-rs/releases)
- [Commits](https://github.com/wrenger/bitfield-struct-rs/compare/0.12.1...0.13.0)

Updates `cc` from 1.2.60 to 1.2.61
- [Release notes](https://github.com/rust-lang/cc-rs/releases)
- [Changelog](https://github.com/rust-lang/cc-rs/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.60...cc-v1.2.61)

Updates `pastey` from 0.2.1 to 0.2.2
- [Release notes](https://github.com/as1100k/pastey/releases)
- [Changelog](https://github.com/AS1100K/pastey/blob/master/CHANGELOG.md)
- [Commits](https://github.com/as1100k/pastey/compare/v0.2.1...v0.2.2)

Updates `winnow` from 1.0.1 to 1.0.2
- [Changelog](https://github.com/winnow-rs/winnow/blob/main/CHANGELOG.md)
- [Commits](https://github.com/winnow-rs/winnow/compare/v1.0.1...v1.0.2)

---
updated-dependencies:
- dependency-name: cc
  dependency-version: 1.2.61
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: non-rust-vmm
- dependency-name: jiff
  dependency-version: 0.2.24
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: non-rust-vmm
- dependency-name: jiff-static
  dependency-version: 0.2.24
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: non-rust-vmm
- dependency-name: pastey
  dependency-version: 0.2.2
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: non-rust-vmm
- dependency-name: zbus_names
  dependency-version: 4.3.2
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: non-rust-vmm
- dependency-name: zvariant
  dependency-version: 5.10.1
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: non-rust-vmm
- dependency-name: zvariant_derive
  dependency-version: 5.10.1
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: non-rust-vmm
- dependency-name: zvariant_utils
  dependency-version: 3.3.1
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: non-rust-vmm
- dependency-name: libc
  dependency-version: 0.2.186
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: non-rust-vmm
- dependency-name: bitfield-struct
  dependency-version: 0.13.0
  dependency-type: indirect
  update-type: version-update:semver-minor
  dependency-group: non-rust-vmm
- dependency-name: cc
  dependency-version: 1.2.61
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: non-rust-vmm
- dependency-name: pastey
  dependency-version: 0.2.2
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: non-rust-vmm
- dependency-name: winnow
  dependency-version: 1.0.2
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: non-rust-vmm
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-05-01 00:50:42 +00:00
dependabot[bot]
3bd90933e3 build(deps): bump crate-ci/typos from 1.45.2 to 1.46.0
Bumps [crate-ci/typos](https://github.com/crate-ci/typos) from 1.45.2 to 1.46.0.
- [Release notes](https://github.com/crate-ci/typos/releases)
- [Changelog](https://github.com/crate-ci/typos/blob/master/CHANGELOG.md)
- [Commits](7c57295821...bbaefadf97)

---
updated-dependencies:
- dependency-name: crate-ci/typos
  dependency-version: 1.46.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-05-01 00:37:26 +00:00
Rob Bradford
9411f7ecd8 vmm: Validate balloon size against total RAM
The total RAM in the system needs to consider any hotpluggable RAM that
is hotplugged in as well as the initial static "base" RAM.

Signed-off-by: Rob Bradford <rbradford@meta.com>
2026-04-30 15:56:09 +00:00
Muminul Islam
f6ed896f68 vmm: gate reserve_bootloader_regions on KVM hypervisor type
The reserve_bootloader_regions() call allocates RAM regions at
KVM-specific addresses (0xffc00000 for stage0, 0xfffffffff000
for VMSA) that are only needed by the KVM SEV-SNP boot path.

The existing #[cfg(all(feature = "kvm", feature = "sev_snp"))]
compile-time guard is insufficient when both 'mshv' and 'kvm'
features are enabled in the same binary. The runtime check only
verified sev_snp_enabled() but not the hypervisor type, causing
these KVM-specific memory regions to be allocated on MSHV.

On MSHV, these spurious RAM mappings at high addresses interfere
with the hypervisor's address space layout. When the guest kernel
subsequently accesses MMIO regions (e.g., IOAPIC at 0xFEC00000),
MSHV incorrectly reports HVMSG_UNACCEPTED_GPA instead of routing
the access through MMIO emulation, crashing the guest.

Add a runtime hypervisor type check to ensure these regions are
only reserved when running on KVM.

Assisted-by: Claude:Opus-4.6

Signed-off-by: Muminul Islam <muislam@microsoft.com>
2026-04-30 10:39:28 +00:00
Muminul Islam
4608de134f vmm: igvm: gate CPUID page read with runtime hypervisor check
The SnpCpuidInfo allocation and guest_memory.read() call in the
isolated page import loop are only needed for KVM's CPUID page
retry logic. However, when building with both 'mshv' and 'kvm'
features, #[cfg(feature = "kvm")] alone is insufficient as a
guard because both features compile into the same binary.

Without a runtime hypervisor type check, this code executes on
MSHV as well, reading guest memory at arbitrary GPAs that may
not be valid in the MSHV memory layout. This can cause undefined
behavior or crashes during IGVM loading.

Add #[cfg(feature = "kvm")] to the variable declarations and
wrap the guest_memory.read() call in a runtime check for
HypervisorType::Kvm to ensure it only executes on KVM.

Assisted-by: Claude:Opus-4.6

Signed-off-by: Muminul Islam <muislam@microsoft.com>
2026-04-30 10:39:28 +00:00
Muminul Islam
7d24608bcf vmm: igvm: use correct MSHV page types for CPUID and secrets
The PageTypeConfig for MSHV incorrectly mapped the cpuid field
to HV_ISOLATED_PAGE_TYPE_NORMAL (0) and the secrets field to
HV_ISOLATED_PAGE_TYPE_UNMEASURED (3).

The correct MSHV page type constants are:
- CPUID pages: HV_ISOLATED_PAGE_TYPE_CPUID (5)
- Secrets pages: HV_ISOLATED_PAGE_TYPE_SECRETS (4)

This was introduced in commit 75ed2c9f90 ("vmm: add KVM
SEV-SNP support to IGVM loader") which abstracted page types
into a PageTypeConfig struct but assigned wrong values for the
MSHV variant. Using incorrect page types causes the MSHV
hypervisor to reject or mishandle isolated page imports,
leading to guest boot failure.

Assisted-by: Claude:Opus-4.6

Signed-off-by: Muminul Islam <muislam@microsoft.com>
2026-04-30 10:39:28 +00:00
Muminul Islam
8598b45a95 vmm: skip configure_system when rsdp_addr is None
For SEV-SNP guests using IGVM, the ACPI tables and system
configuration (MP tables, EBDA, SMBIOS, PVH start info, e820)
are provided by the IGVM file. The rsdp_addr is set to None
for these guests to indicate ACPI table creation was skipped.

Commit 7d65187350 ("vmm: make RSDP address optional in
configure_system") removed the guard that prevented calling
configure_system when rsdp_addr is None. This caused MSHV
SEV-SNP guests to crash because configure_system writes to
guest memory locations that conflict with the IGVM-provided
layout.

Restore the guard by only calling configure_system when
rsdp_addr is Some, which preserves the intended behavior
for CVM guests while still allowing the Option<GuestAddress>
refactoring.

Assisted-by: Claude:Opus-4.6

Signed-off-by: Muminul Islam <muislam@microsoft.com>
2026-04-30 10:39:28 +00:00
Rob Bradford
87ffc620e4 virtio-devices: net: Gracefully handle MTU query failure
If querying the fd's MTU fails (because it was from a different network
namespace). Degrade gracefully by not advertising the VIRTIO_NET_F_MTU
feature and instead let the guest kernel use the default 1500 Ethernet
MTU.

Signed-off-by: Rob Bradford <rbradford@meta.com>
2026-04-29 17:57:14 +00:00
Muminul Islam
475c8d3efb hypervisor: mshv: Use VP register page for state access
Use the VP register page to read and write emulation-related
special registers directly, avoiding expensive IOCTLs for
registers that instruction emulation never touches.

In cpu_state(), read only segments, cr0, and efer from the VP
register page instead of calling get_sregs() which issues
IOCTLs for tr, ldt, gdt, idt, cr2, apic_base, and
pending_interruption.

In update_cpu_state(), when segments change, write only the 6
segment registers to the VP register page and set the segment
dirty bit, instead of calling set_sregs() which issues IOCTLs
for tr, ldt, gdt, idt, cr0-cr4, cr8, efer, and apic_base.

Both paths fall back to the IOCTL-based methods when the VP
register page is not available.

Signed-off-by: Muminul Islam <muislam@microsoft.com>
2026-04-29 15:07:26 +00:00
Dylan Reid
54cde010c5 pci: vfio_user: bounds-check size in DMA map
VfioUserDmaMapping::map is reached from the virtio-iommu MAP handler
with (iova, gpa, size) all guest-controlled. Validate the length of the
region fits, not just the start.

Before this change the vfio-user on the other end could get a size that
spans past the end of its backing storage.

Signed-off-by: Dylan Reid <dgreid@fb.com>
2026-04-29 09:23:36 +00:00
Dylan Reid
9f405a21ac virtio-devices: vsock: Add bounds check on inline TX path
The TX path's inline-data branch didn't check the inline buffer length
against the guest-supplied pkt.len() field. The worker will later panic
when it tries to index the packet.

Add the missing check, mirroring the other TX branches.

Signed-off-by: Dylan Reid <dgreid@fb.com>
2026-04-29 09:23:36 +00:00
Dylan Reid
02b503ee16 virtio-devices: vdpa: checked arithmetic in dma_unmap
dma_unmap computed `iova + size - 1` unchecked while the sibling dma_map
already used checked_add/checked_sub. A guest reaching dma_unmap via
VIRTIO_IOMMU_T_UNMAP could cause a panic.

Signed-off-by: Dylan Reid <dgreid@fb.com>
2026-04-29 09:23:36 +00:00
Dylan Reid
5b199498ff virtio-devices: iommu: checked arithmetic for MAP
Catch u64 overflows on map so that later translation requests from the
guest don't have a vector for causing a host panic.

Signed-off-by: Dylan Reid <dgreid@fb.com>
2026-04-29 09:23:36 +00:00
Dylan Reid
22eeb3f808 virtio-devices: pci: skip activation of invalid queues
prepare_activator() called queue.is_valid() and only logged the failure,
then still pushed the queue to the activator. This would later panic.

Technically this is a fixup for:
a10508970 "virtio-devices: Support driver programming fewer queues"
But that's been in there since 2021. The intent was to allow a subset of
possible queues to be configured, but the invalid queues slipped through
too.

Signed-off-by: Dylan Reid <dgreid@fb.com>
2026-04-29 09:23:36 +00:00
Stepan Rabotkin
feddff025a vmm: openapi: add user_devices to spec
Signed-off-by: Stepan Rabotkin <epicstyt@gmail.com>
2026-04-29 07:19:29 +00:00
Wei Liu
389257964b hypervisor: mshv: Make the translation caching code idiomatic
Signed-off-by: Wei Liu <liuwe@microsoft.com>
2026-04-28 17:42:41 +00:00
dependabot[bot]
b03e186270 build(deps): bump crate-ci/typos from 1.45.1 to 1.45.2
Bumps [crate-ci/typos](https://github.com/crate-ci/typos) from 1.45.1 to 1.45.2.
- [Release notes](https://github.com/crate-ci/typos/releases)
- [Changelog](https://github.com/crate-ci/typos/blob/master/CHANGELOG.md)
- [Commits](cf5f1c29a8...7c57295821)

---
updated-dependencies:
- dependency-name: crate-ci/typos
  dependency-version: 1.45.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-04-28 03:15:02 +00:00
Rob Bradford
1bee4edf0c ci: Drop superseded workflows
Delete the PR/MQ workflows superseded by consolidated ci.yaml.

Signed-off-by: Rob Bradford <rbradford@meta.com>
2026-04-27 20:31:44 +00:00
Rob Bradford
7e3129a303 ci: Consolidate PR/MQ workflows into a single ci.yaml
Replace existing CI files with a consolidated one to delay starting
resource intensive CI jobs until after less resource intensive ones have
completed: e.g. don't start integration tests if the basic build tests
fail.

Architecture:
- Trigger on [pull_request, merge_group]; concurrency keyed per PR/ref.
- preflight job classifies changed paths and exposes a 'full' flag that
  gates the heavier build/quality/integration suite.  Any CI change
  classifies itself as full so it is exercised.
- Leaf jobs gate at the job level using preflight outputs; doc-only,
  openapi-only, dockerfile-only and similar PRs skip the full suite.
- integration-x86-64-pr runs the (garm-jammy, gnu) slice on PR and MQ;
  integration-x86-64-mq runs the other 3 matrix entries on MQ only.
- integration-{arm64, vfio, windows, rate-limiter} are MQ-only.
- integration jobs gate on dco/quality/build success.
- A single all-green aggregator job is the only required-status check;
  it folds in every leaf job via `needs`.

Assisted-by: Claude:Opus-4.7
Signed-off-by: Rob Bradford <rbradford@meta.com>
2026-04-27 20:31:44 +00:00
Rob Bradford
8d62133383 virtio-devices: generic-vhost-user: Config change notification
Add support for backend that is connected via the vhost-user-generic
frontend to generate an interrupt into the guest when it has made a
change to the configuration. This is useful for devices that can change
the exposed configuration at runtime.

Assisted-by: Claude:Opus-4.7
Signed-off-by: Rob Bradford <rbradford@meta.com>
2026-04-27 11:51:43 +00:00
Anatol Belski
abef0e5b69 block: qcow: Add physical size test
Verify that a freshly created sparse QCOW2 image reports a
physical size smaller than its logical size.

Assisted-by: Claude:Opus-4.6
Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2026-04-27 11:19:37 +00:00
Anatol Belski
5958872943 block: qcow: Add try_clone backend preservation tests
Verify that try_clone preserves the backend dispatch for both
sync and io_uring backends.

Assisted-by: Claude:Opus-4.6
Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2026-04-27 11:19:37 +00:00
Anatol Belski
9043098473 block: qcow: Add async I/O dispatch tests
Verify that the sync backend disables batch requests and the
io_uring backend enables them.

Assisted-by: Claude:Opus-4.6
Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2026-04-27 11:19:37 +00:00
Anatol Belski
4ec2ff1080 block: qcow: Add test for correct logical size
Verify that QcowDisk reports the expected virtual size.

Assisted-by: Claude:Opus-4.6
Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2026-04-27 11:19:37 +00:00
Anatol Belski
587093ddfd block: qcow: Remove old wrapper structs, restrict visibility
Delete QcowDiskSync and QcowDiskAsync wrapper structs along with
their DiskFile trait impls. Only the AsyncIo worker structs
QcowSync and QcowAsync remain. Reduce module visibility of
qcow_sync and qcow_async to pub(crate).

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2026-04-27 11:19:37 +00:00