Registry Mirror
Skip to content

Conversation

@phip1611

@phip1611 phip1611 commented Dec 4, 2026

Copy link
Copy Markdown
Member

Part of bumping our gardenlinux patchset to upstream CH v55. This follows our agreed process, see ticket.

About

Follow-up of:

This adds our CPU profile series. Upstream v55 already supports CPU profiles from JSON files (CpuProfileConfig::File). We keep that and add our built-in profiles (Cascade Lake, Skylake, Sapphire Rapids) as additional variants. The built-in profiles keep their kebab-case names (e.g. sapphire-rapids), so VM configs from our v54 hosts stay compatible for live migration.

This PR is stacked on #237: only the last 19 commits belong to it.

Hints for Reviewers

  • libvirt nixos-tests pipeline
    • ??/140 passing (+??)
  • Check out our commits from the base gardenlinux branch and compare them. There might be some consolidations, squashing, and reorderings included but the general nature of our patchset must be preserved. Some patches are removed or changed as the new upstream version diverged.
  • Commits that differ from their gardenlinux original carry an [ Adapted to v55: ... ] note before the trailers.
  • Ticket

scholzp and others added 30 commits December 4, 2026 11:00
The DMA interface in `fw_cfg` in the CHV implementation is broken and
needs an overhaul. We deactivate it to force a guest to use the
traditional interface instead and ignore the DMA interface.[0]

We make DMA transfers no-ops for now and adjust the test to verify this
instead until we do a rework of the DMA path.

[0] https://www.qemu.org/docs/master/specs/fw_cfg.html#guest-side-dma-interface

On-behalf-of: SAP pascal.scholz@sap.com
Signed-off-by: Pascal Scholz <pascal.scholz@cyberus-technology.de>
QEMU checks if the read has an allowed width.[0] If it detects an
invalid read to a device mapped port, then QEMU will treat the
register reads as a read from unassigned I/O.[1] As a result, it
will return 0x0 for the whole buffer. For unmapped IO port access,
QEMU writes all-ones to the buffer. Unlike QEMU, CHV doesn't answer
unmapped reads with a deterministic value and leaves the buffer
unchanged instead. We preserve CHV behavior for ports unknown to
fw_cfg.

QEMU maps two separate memory regions to fw_cfg. One starting
at FW_CFG_IO_BASE which is 0x510 and one starting at 0x514.[2] The first
is two bytes, the size of the latter is eight bytes. This leaves a hole
at addresses 0x512 and 0x513 in the x86 I/O port mapping.

We mimic this behavior for CHV's `fw_cfg` design for improved
compatibility and respect the hole accordingly. In the last case this
means that reading from the hole at 0x512 and 0x513 is not treated by
zero-filling the buffer. Instead, we tread them as unmapped port and
leave the buffer unchanged.

[0] https://github.com/qemu/qemu/blob/6e9a825c1d4e7b62d072e99a89ecd1a74c7f0d55/hw/nvram/fw_cfg.c#L533
[1] https://github.com/qemu/qemu/blob/6e9a825c1d4e7b62d072e99a89ecd1a74c7f0d55/system/memory.c#L1480
[2] https://github.com/qemu/qemu/blob/6e9a825c1d4e7b62d072e99a89ecd1a74c7f0d55/hw/i386/fw_cfg.c#L130

[ Adapted to v55: match on data.len() as v55 dropped the size local,
  tests use the v55 FwCfg::new() and the FW_CFG_*_OFFSET constants ]

On-behalf-of: SAP pascal.scholz@sap.com
Signed-off-by: Pascal Scholz <pascal.scholz@cyberus-technology.de>
Using the result of an addition comes with the risk of it overflowing.
In terms of the address matching in `read` and `write` it makes no
difference if we use the provided offset directly instead of adding the
base to it.

[ Adapted to v55: test constant renames already happen in the previous
  commit, the log uses data.len() ]

On-behalf-of: SAP pascal.scholz@sap.com
Signed-off-by: Pascal Scholz <pascal.scholz@cyberus-technology.de>
While the documentation states that the SELECTOR register is
write-only, QEMU actually allows reading the SELECTOR register. This
is because QEMU uses a contiguous mapping for the SELECTOR and DATA
registers to allow the 16-bit width of the SELECTOR register.[0]
As a consequence, a read from SELECTOR is delegated to the same callback
as a read from DATA. It does not return the SELECTOR value.

We mimic this for maximal compatibility.

[0] https://github.com/qemu/qemu/blob/6e9a825c1d4e7b62d072e99a89ecd1a74c7f0d55/hw/nvram/fw_cfg.c#L539

[ Adapted to v55: read_data() takes no size argument, test uses the v55
  FwCfg::new() ]

On-behalf-of: SAP pascal.scholz@sap.com
Signed-off-by: Pascal Scholz <pascal.scholz@cyberus-technology.de>
Currently, the read implementation isn't complete and doesn't handle
some error cases gracefully. We rework it with the aim of maximal
compatibility to QEMU and add tests for it.
Problems of the old implementation include:
 * Reads beyond EOF should yield 0x0.[0] These currently panic.
 * Register reads with invalid SELECTOR should also yield 0x0.[1]
 * If provided with a buffer larger than an item, then the remaining
   buffer bytes should be set to zero.[1]

We use the existing interface for reading items that is also used for
DMA access and bring bug fixes from the POI read interface to it.
These include:
 * Fixing a possible underflow when calculating the offset within a
   file. Such an underflow can occur if the file is shrunk after
   the last successful access, placing the cursor behind the EOF.
 * Replace `seek` + `read` pattern by `read_exact_at` to make
   repeated access save.

[0] https://www.qemu.org/docs/master/specs/fw_cfg.html#data-register
[1] https://github.com/qemu/qemu/blob/6e9a825c1d4e7b62d072e99a89ecd1a74c7f0d55/hw/nvram/fw_cfg.c#L382

Original c217b8e:
devices: Restrict x86 fw_cfg PIO reads to one byte

In the traditional/PIO interface the DATA register has a width of one
byte on x86.[0]
We therefore do not allow reads with larger widths. Currently, all
tests assume a read with a width of one byte too.

We reject `fw_cfg` in aarch64 builds for now as these changes introduce
an incompatibility that adds to the incomplete implementation of it.
aarch64 support is a task to be solved in follow-up work, as this also
includes making corrections to the MMIO transport implementation and
FDT corrections.

[0] https://www.qemu.org/docs/master/specs/fw_cfg.html#data-register

Original 70a5b43:
devices: Allow arbitrary length reads from fw_cfg DATA

This is a fix to allow string reads that map to `rep ins`. KVM returns
an I/O exit with the respective port, the read size of the instruction
and the count of such reads. `kvm-ioctls` creates a buffer from this
with the size of `count * size` bytes.[0]

This makes it impossible to decide if the buffer was a single
four-byte-width read of the kind `inl` or `rep ins` with RCX set to 4,
for example. While the first would be invalid according to QEMU
semantics, the second is a valid repeated access with one byte width. We
therefore accept reads of any size until we can solve this issue.

[0] https://github.com/rust-vmm/kvm/blob/b4c9ed8df95a9e10a68f50f5ef5e7d04108759ba/kvm-ioctls/src/ioctls/vcpu.rs#L1549

[ Adapted to v55, which already consolidated the read paths: kept the
  static read_content()/read_data() with io::Result instead of
  FwCfgContentAccess and FwCfgContentAccessError, and ported the partial
  read, EOF cursor clamp, and zero fill semantics into them ]

On-behalf-of: SAP pascal.scholz@sap.com
Signed-off-by: Pascal Scholz <pascal.scholz@cyberus-technology.de>
Some entries are also 2 and 8 bytes in size. We therefore add the
missing content sizes.

[ Adapted to v55: U16/U64 arms go into read_content() as
  FwCfgContentAccess no longer exists ]

On-behalf-of: SAP pascal.scholz@sap.com
Signed-off-by: Pascal Scholz <pascal.scholz@cyberus-technology.de>
Fully populating a `fw_cfg` will require a lot more data than what is
currently passed to the associated function. We therefore make
`populate_fw_cfg` a method to gain access to all data stored in `Vm`.

[ Adapted to v55, which already has a populate_fw_cfg(&self) wrapper:
  made populate_fw_cfg_items() a method instead ]

On-behalf-of: SAP pascal.scholz@sap.com
Signed-off-by: Pascal Scholz <pascal.scholz@cyberus-technology.de>
To keep all data needed to initialize `fw_cfg` together, we move them
from function arguments to a dedicated helper. As their number is going
to grow, this will also help keeping the number of function arguments
low.

[ Adapted to v55: dropped e820_size as v55 adds the E820 map separately
  via add_e820() ]

On-behalf-of: SAP pascal.scholz@sap.com
Signed-off-by: Pascal Scholz <pascal.scholz@cyberus-technology.de>
Introduce a helper that reads an item through fw_cfg's legacy interface
and verifies that:
  - writing a selector resets the cursor
  - payload bytes are exact
  - reads beyond EOF return zero
  - the cursor does not advance beyond EOF

Use it in tests that repeatedly read items through the legacy interface.
This reduces repetition and ensures consistent coverage of these
properties. Use an empty guest-memory map in tests that do not require
the DMA interface.

[ Adapted to v55: the helper selects via the existing select(), tests
  use GuestMemory::default(), and v55's
  test_stage0_reserved_only_for_sev_snp is kept ]

On-behalf-of: SAP pascal.scholz@sap.com
Signed-off-by: Pascal Scholz <pascal.scholz@cyberus-technology.de>
QEMU uses a global variable to store the VM's UUID.[0] The same UUID is
used to initialize the corresponding SMBIOS and fw_cfg fields.[1,2]
Through C's static initialization this is initialized to all zeros.

We mimic this behavior by reading the UUID from the VM configuration.

[0] https://github.com/qemu/qemu/blob/6e9a825c1d4e7b62d072e99a89ecd1a74c7f0d55/system/globals.c#L67
[1] https://github.com/qemu/qemu/blob/6e9a825c1d4e7b62d072e99a89ecd1a74c7f0d55/hw/smbios/smbios.c#L624
[2] https://github.com/qemu/qemu/blob/6e9a825c1d4e7b62d072e99a89ecd1a74c7f0d55/hw/nvram/fw_cfg.c#L1006

[ Adapted to v55: test helper uses the v55 FwCfg::new() ]

On-behalf-of: SAP pascal.scholz@sap.com
Signed-off-by: Pascal Scholz <pascal.scholz@cyberus-technology.de>
QEMU uses the machine's settings to initialize `fw_cfg`'s memory size
field.[0] The machine field state is written once and the `fw_cfg` field
is written once at creation time. The entry in `fw_cfg` therefore
reflects the initial memory size at VM creation time in QEMU.

We initialize `fw_cfg` the same way in CHV.

[0] https://github.com/qemu/qemu/blob/6e9a825c1d4e7b62d072e99a89ecd1a74c7f0d55/hw/i386/fw_cfg.c#L147

On-behalf-of: SAP pascal.scholz@sap.com
Signed-off-by: Pascal Scholz <pascal.scholz@cyberus-technology.de>
QEMU emulates graphical output by default. This can be disabled through
the CLI option `-nographics` which also sets the global `nographic` to
true.[0]

CHV doesn't have graphical output. So we set the FW_CFG_NOGRAPHIC entry
to true.

[0] https://github.com/qemu/qemu/blob/6e9a825c1d4e7b62d072e99a89ecd1a74c7f0d55/system/vl.c#L2999

On-behalf-of: SAP pascal.scholz@sap.com
Signed-off-by: Pascal Scholz <pascal.scholz@cyberus-technology.de>
QEMU initializes `FW_CFG_NB_CPUS` with the number of boot vCPUs stored
in the machine's configuration.[0]

We do the same when populating `fw_cfg`. We don't follow QEMU's update
semantics whenever a vCPU is hot-plugged or hot-unplugged because CHV's
`fw_cfg` doesn't implement stateful recreation (e.g. snapshotting, live
migration...) yet. This means that whenever the VM is instantiated, a
new `fw_cfg` is created and populated with the then up-to-date values.

[0] https://github.com/qemu/qemu/blob/6e9a825c1d4e7b62d072e99a89ecd1a74c7f0d55/hw/i386/pc.c#L886

On-behalf-of: SAP pascal.scholz@sap.com
Signed-off-by: Pascal Scholz <pascal.scholz@cyberus-technology.de>
The current implementation uses architecture-specific guards through
all parts of `add_kernel_data` which lowers readability and
maintainability. We therefore move architecture-specific code into
specific helper functions and dispatch to those in `add_kernel_data`.

This also helps when trying to identify what selectors are implemented
for what architecture.

We additionally add a test for `add_kernel_data`.

Note: FW_CFG_SETUP_DATA is specific to x86 platforms.

[ Adapted to v55: use the existing x86-only io::Error import instead of
  IoError ]

On-behalf-of: SAP pascal.scholz@sap.com
Signed-off-by: Pascal Scholz <pascal.scholz@cyberus-technology.de>
We modify the existing kernel data processing routine to also set
FW_CFG_KERNEL_ADDR correctly depending on the supplied bzImage.

The current code assumes a recent bzImage. While doing so, it misses
any validation logic after it created `boot_params` from the first
bytes in the file. We add the missing validation logic and restrict
the supported bzImage versions to recent, high-loaded ones on x86. This
helps us safely support recent images and allows us to abort loading
the kernel data if an unsupported image/file format was supplied.

For such images, QEMU publishes FW_CFG_KERNEL_ADDR as
`0x10_0000`.[0, 1]. Note that QEMU doesn't populate this item for
AArch64 and RISC-V.

[0] https://github.com/qemu/qemu/blob/6e9a825c1d4e7b62d072e99a89ecd1a74c7f0d55/hw/i386/x86-common.c#L966
[1] https://github.com/qemu/qemu/blob/6e9a825c1d4e7b62d072e99a89ecd1a74c7f0d55/hw/i386/x86-common.c#L762

[ Adapted to v55: Error instead of IoError, test uses the v55
  FwCfg::new() ]

On-behalf-of: SAP pascal.scholz@sap.com
Signed-off-by: Pascal Scholz <pascal.scholz@cyberus-technology.de>
The name of this item is a bit misleading on x86 as the actual value
denotes the exclusive APIC-ID limit the firmware might see. This is
for compatibility reasons as documented in the QEMU code.[0]
QEMU does not populate this FW_CFG_MAX_CPUS for AArch64 and RISC-V, so
we make it an x86-specific item.

As `fw_cfg` is also available for MSHV featured builds, we need a way to
calculate the APIC-ID limit also in such builds. We therefore modify the
`kvm` guard for `max_apic_id` and include it for compilation if either
`kvm` or `fw_cfg` are used. All other call sites remain KVM specific.
Thus no additional changes are required.

[0] https://github.com/qemu/qemu/blob/6e9a825c1d4e7b62d072e99a89ecd1a74c7f0d55/hw/i386/fw_cfg.c#L134

On-behalf-of: SAP pascal.scholz@sap.com
Signed-off-by: Pascal Scholz <pascal.scholz@cyberus-technology.de>
QEMU can hint firmware to show a boot menu. To do so, one can use the
`-boot menu` option.

Cloud Hypervisor doesn't have a comparable option. We therefore set the
FW_CFG_BOOT_MENU entry to false.

On-behalf-of: SAP pascal.scholz@sap.com
Signed-off-by: Pascal Scholz <pascal.scholz@cyberus-technology.de>
We intentionally leave out certain fw_cfg legacy items. This commit adds
short documentation explaining why each item is omitted.

On-behalf-of: SAP pascal.scholz@sap.com
Signed-off-by: Pascal Scholz <pascal.scholz@cyberus-technology.de>
We make `fw_cfg` a default feature to allow for an easier build at our
customer.

[ Adapted to v55: realign the dhat-heap comment as required by taplo ]

On-behalf-of: SAP pascal.scholz@sap.com
Signed-off-by: Pascal Scholz <pascal.scholz@cyberus-technology.de>
fw_cfg is required for the bootorder feature.

Original 72531c5:
devices: Fix clippy: unneeded late initialization

```
warning: unneeded late initialization
   --> devices/src/legacy/gpio_pl061.rs:258:9
    |
258 |         let value;
    |         ^^^^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_late_init
    = note: `-D clippy::needless-late-init` implied by `-D clippy::all`
```

On-behalf-of: SAP pascal.scholz@sap.com
Signed-off-by: Pascal Scholz <pascal.scholz@cyberus-technology.de>
Signed-off-by: Rob Bradford <rbradford@meta.com>
QEMU uses the Open Firmware format for representing device paths in its
`fw_cfg`'s `bootorder` entry. Originally consumed by SeaBIOS, this is
also the format expected by OVMF/EDK2 for the respective `fw_cfg`
entry.[0]

CHV currently rejects device path generation for devices outside PCI
segment 0. This is required with the current OVMF integration: while
CHV exposes each PCI segment as a separate PCI domain/root complex,
OVMF only creates boot-time PCI root-bridge support for segment 0.[1]

To prepare the implementation of `fw_cfg`'s bootorder, we add support
for creating device paths in the Open Firmware format.

[0] https://github.com/tianocore/edk2/blob/2816ff0ab0d6505bf580aa8eec02cc2b89f04230/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c#L1222
[1] https://github.com/tianocore/edk2/blob/58a00ddd494845143667da0d807fa517bc5447b1/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.c#L136

Original 72531c5:
devices: Fix clippy: unneeded late initialization

```
warning: unneeded late initialization
   --> devices/src/legacy/gpio_pl061.rs:258:9
    |
258 |         let value;
    |         ^^^^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_late_init
    = note: `-D clippy::needless-late-init` implied by `-D clippy::all`
```

Signed-off-by: Pascal Scholz <pascal.scholz@cyberus-technology.de>
On-behalf-of: SAP pascal.scholz@sap.com
Signed-off-by: Rob Bradford <rbradford@meta.com>
Signed-off-by: Julian Schindel <julian.schindel@cyberus-technology.de>
For now we only support setting `bootindex` for disk devices.
Supporting `bootindex` for other devices (e.g. network) is left open
for a follow up to add once we need such a feature.

[ Adapted to v55: the fw_cfg SYNTAX variant is based on v55's string
  with the burst options ]

Signed-off-by: Pascal Scholz <pascal.scholz@cyberus-technology.de>
On-behalf-of: SAP pascal.scholz@sap.com
For consumption by the `fw_cfg` device, we make `DeviceManager` collect
and expose a list of devices for which a boot index was configured.

[ Adapted to v55: also forget the boot order entry after a failed
  hotplug. The fork did this in 6b2c581, but v55 carries the upstream
  version of that commit without the boot order part ]

Signed-off-by: Pascal Scholz <pascal.scholz@cyberus-technology.de>
On-behalf-of: SAP pascal.scholz@sap.com
It is possible that the user might supply an item with the path
`bootorder` via CLI/API. In this case, QEMU overrides the supplied item
with its own data when resetting the machine after creating it.[0, 1]
We do the same here.

Clean up some absolute paths referencing `FwCfgContent` in the process.

[0] https://github.com/qemu/qemu/blob/6e9a825c1d4e7b62d072e99a89ecd1a74c7f0d55/hw/nvram/fw_cfg.c#L976
[1] https://github.com/qemu/qemu/blob/6e9a825c1d4e7b62d072e99a89ecd1a74c7f0d55/hw/core/machine.c#L1728

Signed-off-by: Pascal Scholz <pascal.scholz@cyberus-technology.de>
On-behalf-of: SAP pascal.scholz@sap.com
QEMU's implementation does not provide any default binary blobs for
initrd, kernel and command line. We therefore also refrain from doing
so and make it the accepted default.

We replace the custom `Default` implementation with a derived one as
this implements `false` for all `bool` types and `None` for the
`Option` type.

[ Adapted to v55: e820 now also defaults to off (v55 enabled it on
  x86_64 only), kept v55's AArch64 note in the docs, and v55's SEV-SNP
  test fixture enables acpi_tables explicitly ]

Signed-off-by: Pascal Scholz <pascal.scholz@cyberus-technology.de>
On-behalf-of: SAP pascal.scholz@sap.com
Using `bootorder` in device configurations requires a `fw_cfg` device
to be present. The current way of instantiating one is by explicitly
adding one to the command line. In cases one wasn't created this way,
we need to implicitly add one to make the `bootorder` applicable.

Adding it in the `device_manager` if we require one works for both
cases, VM instantiation via an API call and via the CLI.

Signed-off-by: Pascal Scholz <pascal.scholz@cyberus-technology.de>
On-behalf-of: SAP pascal.scholz@sap.com
On-behalf-of: SAP pascal.scholz@sap.com
Signed-off-by: Pascal Scholz <pascal.scholz@cyberus-technology.de>
virtio-devices: generalize disk locking

Block device mirroring, planned in a follow-up series, must lock the
mirror destination image through the same path as the block device's
own disk image.

As preparation, extract advisory lock acquisition into a helper that
accepts a disk backend, path, requested mode, and current mode. Keep
`try_lock_image` as the source-disk wrapper. No behavior change.

On-behalf-of: SAP leander.kohler@sap.com
Signed-off-by: Leander Kohler <leander.kohler@cyberus-technology.de>

virtio-devices: generalize lock granularity

Block device mirroring, planned in a follow-up series, must apply a
block device's locking policy to the mirror destination image.

Therefore, calculate the advisory lock granularity from a supplied disk
backend and path instead of using Block::disk_image.

On-behalf-of: SAP leander.kohler@sap.com
Signed-off-by: Leander Kohler <leander.kohler@cyberus-technology.de>

vmm: add option for QEMU compatible file locking

QEMU uses locks on specific bytes for modeling file lock permissions.
This commit only implements what's needed to model the permissions
cloud-hypervisor currently uses. This is needed to be compatible with
storage management systems that expect QEMU compatible file locking like
NetApp's NFS implementation.

QEMU uses two offsets from the start of the file to separate permissions
and "unshared" permissions. "unshared" permissions are permissions that
cannot be shared between lock holders [0] and can be considered
exclusive.
Starting from each offset, locks are placed with a length of one byte.
Each corresponds to a specific permission [1][2].

The locking is done by first signaling intent by locking the
required marker bytes. Next any conflicts with existing locks are
detected and in the failure case, the locks are rolled back.
Locking is done via `F_RDLCK`, which allows other parties to set the
same locks and check for conflicts with `F_WRLCK`.

[0]: https://github.com/qemu/qemu/blob/30e8a06b64aa58a3990ba39cb5d09531e7d265e0/block/file-posix.c#L131-L134
[1]: https://github.com/qemu/qemu/blob/30e8a06b64aa58a3990ba39cb5d09531e7d265e0/include/block/block-common.h#L392-L437
[2]: https://github.com/qemu/qemu/blob/30e8a06b64aa58a3990ba39cb5d09531e7d265e0/block/file-posix.c#L868-L940

Original a7a5471:
vmm: set `QemuCompatible` to the default `LockGranularityChoice`

Original b99d6ad:
block: Retry locking when interrupted by EINTR

Acquiring an image lock can be interrupted with EINTR. In this case, we
returned with an error. Instead, we now retry acquiring the lock.

Original 2c30474:
vmm: remove `get_` prefix

Rust typically doesn't use `get_` prefixes.

Original 8182977:
vmm: add resize permission to qemu-compatible locking

Also lock the resize permission lock for read-write opened disks.
Cloud-hypervisor can resize disks, so we should lock the byte.

Original af4a4c2:
block: release stale QEMU lock after downgrade

Block device mirroring, planned in a follow-up series, will lock the
mirror destination for writing during the copy and downgrade a
previously read-only disk to the source's read-only lock on completion.

That downgrade is broken: `try_acquire_lock_qemu()` only releases
unneeded bytes on rollback after a failed acquisition, so the write
marker byte stays locked and blocks other readers.

Release the bytes that the new lock type does not need once the conflict
checks succeed, and add a test that downgrades a write lock to a read
lock and verifies that another reader can still acquire the image.

On-behalf-of: SAP julian.schindel@sap.com
Signed-off-by: Julian Schindel <julian.schindel@cyberus-technology.de>
Signed-off-by: Pascal Scholz <pascal.scholz@cyberus-technology.de>
On-behalf-of: SAP pascal.scholz@sap.com
On-behalf-of: SAP leander.kohler@sap.com
Signed-off-by: Leander Kohler <leander.kohler@cyberus-technology.de>

vmm: move error handling into `fcntl` function

Avoids repeating the retry/error logic when adding new users of the
function.

Original 3945fd0:
vmm: fix safety comment for `fcntl` wrapper

Reference to pointer coercion doesn't happen for variadic functions like
`libc::fcntl`. While this doesn't pose a problem by itself, it removes
the check whether a reference can be coerced to the appropriate pointer
type or mutability. By explicitly casting to a pointer, we ensure
refactors don't accidentally break the safety requirements.

On-behalf-of: SAP julian.schindel@sap.com
Signed-off-by: Julian Schindel <julian.schindel@cyberus-technology.de>

vmm: refactor `LockGranularity` for easier addition of variants

By extracting the full file and file range locking, it's easier to add
file lock handling that's not following this pattern.

On-behalf-of: SAP julian.schindel@sap.com
Signed-off-by: Julian Schindel <julian.schindel@cyberus-technology.de>

vmm: refactor locking functions to be methods of `LockGranularity`

All functions take a `LockGranularity` already and making them part of
`LockGranularity` makes it easier to add associated helpers.

On-behalf-of: SAP julian.schindel@sap.com
Signed-off-by: Julian Schindel <julian.schindel@cyberus-technology.de>

vmm: remove `get_lock_state` function

The function suffers from a TOCTOU problem. There is no guarantee that
the locks set on the file at the time of the state check are the same as
at the time of the locking attempt.

[ Adapted to v55: kept the clippy::panic expectation on fcntl(), v55's
  lock file retry loop uses the new lock API, and the SYNTAX strings
  keep v55's burst options ]

Co-authored-by: Leander Kohler <leander.kohler@cyberus-technology.de>
On-behalf-of: SAP julian.schindel@sap.com
Signed-off-by: Julian Schindel <julian.schindel@cyberus-technology.de>
During live migration, VM ownership is moved away from the VMM thread.
To preserve guest-triggered reboot and shutdown lifecycle intent
across that ownership handover, we need a small lifecycle marker to
travel with the migrated VM state.

This change introduces `PostMigrationLifecycleEvent` and stores it in
`VmSnapshot` with `#[serde(default)]` for backward compatibility.
`Vm::snapshot()` now serializes the marker, and VM construction from a
snapshot restores it.

No control-loop behavior is changed in this commit. This is only the
data model/plumbing needed by follow-up commits.

Original 7a49a65:
vmm: generalize postponed lifecycle events

The postponed lifecycle event describes a deferred reboot or shutdown,
but its type and helpers are named after live migration.

Rename them to describe the lifecycle operation itself and centralize
event replay. This removes duplicate reboot and shutdown dispatch while
preserving live-migration behavior. It enables reuse within
blockdev-mirroring.

On-behalf-of: SAP leander.kohler@sap.com
Signed-off-by: Leander Kohler <leander.kohler@cyberus-technology.de>
Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
Connect the explicit announcement API to the existing v54 net backend.
Send the first host RARP synchronously and rearm the existing control
worker for retries and guest notifications after an earlier guest ACK.
Without a control worker, send one host RARP per API request.

Keep the existing packet builder, automatic announcement lifecycle,
retry machinery, and device worker topology unchanged.

Original 216c3c8:
vmm: add internal post-migration announce action

Add an internal API action that triggers the post migration announce. We
can now wire this into the API.

Original a155689:
vmm: add mechanism for post-migration announcements

Some devices can or should do announcements after a live migration,
e.g., a network device announces its new location in a network to update
the MAC->port mappings in layer 2 switches. With this change a device
can return an announcement action ("announcer") to do that.

We use reverse ARP (RARP) packets for this, similar to QEMU. Also, we
do 5 rounds of announcements in background (in a dedicated thread).

[ Adapted to v55: ch-remote uses the clap derive Command enum, host RARP
  goes via the first tap as v55's VirtioNetHostAnnounceOps takes one
  tap, and the docs/api.md entry is dropped as v55 has no endpoint table
  there ]

On-behalf-of: SAP sebastian.eydam@sap.com
Signed-off-by: Sebastian Eydam <sebastian.eydam@cyberus-technology.de>
arctic-alpaca and others added 24 commits December 4, 2026 12:41
The RARP announcement retries are sent from the control queue worker. If
a network device doesn't have a control queue, we spawn a thread per
interface to send the announcements.

[ Adapted to v55: v55 has no Drop for Net, so add one that only
  invalidates the announcer, and return early without a tap ]

On-behalf-of: SAP julian.schindel@sap.com
Signed-off-by: Julian Schindel <julian.schindel@cyberus-technology.de>
While a live migration is running, the migration worker owns the VM and
the VMM control loop cannot execute vm_reboot()/vmm_shutdown() directly.
Guest-triggered reset/exit events in that window currently hit
VmMigrating and fail.

This change makes the control loop consume reset/exit as before, but
when ownership is `MaybeVmOwnership::Migration` it postpones a
post-migration lifecycle intent instead of calling lifecycle handlers
directly.

The postponed state is first-event-wins and is cleared when a new send
migration starts, preventing stale lifecycle intent from leaking between
migrations.

This commit only introduces source-side postponing behavior and does not
yet apply or replay the postponed event.

Original ba9159c:
vmm: migration: switch downtime on postponed event

When a lifecycle event like reset or shutdown is postponed during
pre-copy, switch to downtime at the next iteration boundary.
This keeps the current iteration send intact and then transitions
into the existing graceful downtime path (`stop_vcpu_throttling()`,
`pause()`, final transfer, snapshot).

To keep behavior deterministic on source migration failure,
replay the postponed lifecycle event locally after ownership is
returned:
- VmReboot -> reset_evt
- VmmShutdown -> exit_evt

Postponed state is cleared on both success and failure paths to avoid
stale state across migrations.

Original 7a49a65:
vmm: generalize postponed lifecycle events

The postponed lifecycle event describes a deferred reboot or shutdown,
but its type and helpers are named after live migration.

Rename them to describe the lifecycle operation itself and centralize
event replay. This removes duplicate reboot and shutdown dispatch while
preserving live-migration behavior. It enables reuse within
blockdev-mirroring.

Original ab27125:
vmm: defer guest exit during migration

Move the migration workaround from the shared Exit path to GuestExit
and rename the postponed shutdown event to `VmShutdown`.

With --no-shutdown, guest-triggered shutdown must keep following the
guest exit path even when it is delayed until after migration
completion. This preserves the distinction between guest shutdown and
real VMM exit conditions.

The existing fatal exit path stays unchanged.

[ Adapted to v55: postpone ahead of v55's configurable reset/shutdown
  actions, MigrationWorker has no hypervisor argument, and the then
  unfulfilled too_many_arguments expectation is dropped ]

On-behalf-of: SAP leander.kohler@sap.com
Signed-off-by: Leander Kohler <leander.kohler@cyberus-technology.de>
Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
When a lifecycle event like reset or shutdown is postponed during
pre-copy, switch to downtime at the next iteration boundary.
This keeps the current iteration send intact and then transitions
into the existing graceful downtime path (`stop_vcpu_throttling()`,
`pause()`, final transfer, snapshot).

To keep behavior deterministic on source migration failure,
replay the postponed lifecycle event locally after ownership is
returned:
- VmReboot -> reset_evt
- VmmShutdown -> exit_evt

Postponed state is cleared on both success and failure paths to avoid
stale state across migrations.

On-behalf-of: SAP leander.kohler@sap.com
Signed-off-by: Leander Kohler <leander.kohler@cyberus-technology.de>
Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
Legacy reset/poweroff paths waited only for vcpus_kill_signalled before
leaving their spin loops.

During migration, vCPUs are pause-signalled, not kill-signalled. This
could stall reset/poweroff handling and block migration completion.

Also break these waits on vcpus_pause_signalled and wire the new flag
through device construction paths.

Updated device paths:
  - i8042: guest reboot/reset write path wait loop
  - CMOS: reset register write (0x0f) wait loop
  - ACPI shutdown device:
    - reboot/reset write path wait loop
    - poweroff/shutdown write path wait loop

Original 07426a5:
devices: cmos: simplify pause/kill wait flags

Align CMOS reset wait logic with i8042/ACPI by using direct pause/kill
flags instead of optional wrappers and Option checks.

[ Adapted to v55: Cmos::new() also takes the restore state, v55's CMOS
  restore test is updated, and a redundant igvm cfg is dropped ]

On-behalf-of: SAP leander.kohler@sap.com
Signed-off-by: Leander Kohler <leander.kohler@cyberus-technology.de>
The log line is required for tests.

On-behalf-of: SAP julian.schindel@sap.com
Signed-off-by: Julian Schindel <julian.schindel@cyberus-technology.de>
Signed-off-by: Oliver Anderson <oliver.anderson@cyberus-technology.de>
On-behalf-of: SAP oliver.anderson@sap.com
We include CPU profiles corresponding to Intel Skylake and Sapphire
rapids server that we generated using our WIP CPU profile generation
tool.

Original d54f97a:
arch: Update CPU profiles (passthrough mutable fields)

We regenerate the CPU profiles to take the policy changes from the
previous commit into account.

Original 983b6b4:
arch: Regenerate CPU profiles after updating the serialization format

After updating the serialization format we were no longer able to start
CHV with a CPU profile. This is because deserialization now expects the
sub-leaf ranges to be hex encoded strings.

Original 1f3bc5c:
arch: Regenerate CPU profiles

Regenerate CPU profiles in order to enable machine check architecture
(MCA) for non-host CPU profiles which is required to boot Windows
server.

Original 1e759b7:
arch: Make Sapphire Rapids profile data compatible with backport

CPUID profile data no longer expects vendor and hypervisor. Removing
these fields is fine with respect to live migration across versions
because the serialized data is not transferred (only the name of
the CPU profile is).

Original 25359fc:
arch: Make Sapphire Rapids MSR profile data compatible with backport

MSR profile data no longer tracks cpu vendor and hypervisor and the
permitted_msrs field has been renamed.

This is not a problem with respect to live migration across versions
because the serialized data is not transmitted (only the CPU profile
name is).

Original dafe4ca:
arch: Set ITS_NO for the Sapphire Rapids CPU profile

Signed-off-by: Oliver Anderson <oliver.anderson@cyberus-technology.de>
On-behalf-of: SAP oliver.anderson@sap.com
These data structures are required to define CPU profiles.

Signed-off-by: Oliver Anderson <oliver.anderson@cyberus-technology.de>
On-behalf-of: SAP oliver.anderson@sap.com
We introduce CPUID definitions for Intel CPUs that will be utilized by
the upcoming CPU Profile generation tool.

Original ceb48c7:
arch: Passthrough policies for mutable CPUID fields

CPUID leaf 0x1 ECX[27] and 0x7 ECX[4] can change at runtime, hence it
does not make sense to set their values in the CPU profile.

Note that Section 21.1.5 of the Intel SDM Vol.1, mentions a few other
mutable CPUID fields as well, but we deem it safe to leave them as
the are.

Original 071f786:
arch: Disable UINTR state components

User Interrupts (UINTR) is a modern Intel CPU feature that allows
interrupts to be sent between userspace tasks without going through
the OS Kernel.

To the best of our knowledge this feature is currently not supported
by QEMU at all, and we expect there to be rather few projects intended
to run in the cloud utilizing this feature.

Thus in order to make it possible to run CHV with CPU profiles inside
a QEMU VM, we decide to disable UINTR for non-host CPU profiles for
now.

If/when UINTR gains more adoption in the future, we can then reconsider
this policy and potentially introduce new CPU profiles supporting this
feature.

Original bfd7c3f:
arch: Disable CET in CPUID for CPU profiles

Control-flow enforcement technology (CET) is currently not supported by
QEMU. In order to make it possible to run CHV with CPU profiles inside
a QEMU VM we decide to also disable this feature for CPU profiles.

We might want to revisit this decission and possibly include it in
a "V2" for some of our CPU profiles.

Original e6c3291:
arch: Change CPUID profile policy for WAITPKG

We change the CPUID policy for WAITPKG because we encountered problems
with it when testing CPU profiles with MSRs.

This is also off by default for CPU models in QEMU, but we may still
potentially want to revisit this decision in the future.

Original d0dd19f:
arch: More Inherit for CPUID leaf 0x7.EDX

MD_CLEAR (bit 10), STIBP (bit 27) and L1D_FLUSH (bit 28) all advertise
certain processor features. The passthrough policy is usually not
appropriate in that case, because one no longer has a guarantee that
if the CPU profile can be applied on both the source and destination
then the live migration CPUID compatibility checks must succeed.

We fix this issue by instead utilizing the Inherit policy for these
bits.

Original befa5d9:
arch: Disable PKU and OSPKE for non-host CPU profiles

Protection keys are not supported for CPU profiles and thus disabled

Original 4bfc784:
arch: Inherit policy for MCA

Windows server needs the machine check architecture (MCA) CPUID bit to
be set in order to boot.

Since Windows server is a use-case we want to support we need to revert
our previous decision to disable MCA for non-host CPU profiles.

Original 3179f8a:
arch: Disable HDC state components for CPU profiles

Hardware duty cycling (HDC) does not make sense in the virtualization
setting and should thus not be displayed as available to guests.

We have already disabled certain HDC aspects via CPUID 0x6 ECX[13],
but we forgot to disable the state components which is what we do
in this commit.

Original ac44263:
arch: Disable LBR state components

We have already disabled architectural LBR (last branch record) for CPU
profiles, but we forgot to disable the corresponding state components.

Original 3912ed8:
arch: Disable HWP state components

Hardware P-states (HWP) is already disabled for non-host CPU profiles,
but we forgot to also disable the associated state components.

Original 2a7e8b2:
arch: Disable PT state components

We already disabled Processor Trace (PT) for CPU profiles, but forgot
to disable the associated state components.

Original a73527e:
arch: Disable PASID state components

We have already forbidden IA32_PASID, an MSR related to process
address space identifiers (PASID), but we forgot to disable the
associated state components.

[ Adapted to v55: v55 denies clippy::panic, so the const fn compile-time
  check carries an expectation ]

Signed-off-by: Oliver Anderson <oliver.anderson@cyberus-technology.de>
On-behalf-of: SAP oliver.anderson@sap.com
We introduce CPUID definitions defined for the KVM hypervisor. These
definitions will later be utilized by the upcoming CPU profile
generation tool.

[ Adapted to v55: v55 denies clippy::panic, so the const fn compile-time
  check carries an expectation ]

Signed-off-by: Oliver Anderson <oliver.anderson@cyberus-technology.de>
On-behalf-of: SAP oliver.anderson@sap.com
We introduce MSR-based feature definitions for Intel CPUs that will be
utilized by the upcoming CPU profile generation tool.

Original 0dc18d0:
arch: I32_ARCH_CAPABILITIES changes according to PR review

We apply changes suggested in the PR review to the
IA32_ARCH_CAPABILITIES MSR policies.

Original 15c300b:
arch: Remove leftover lookup function

Original b836b57:
arch: Change policies for CR4_FIXED_I

This is to be consistent with recent changes to CPUID policies

Original e62a4bc:
arch: Disable VM_ENTRY_HARDWARE_EXCEPTIONS for CPU profiles

Bit 56 of VM_ENTRY_HARDWARE_EXCEPTIONS in IA32_VMX_BASIC is only
set on rather recent KVM versions.

Thus whenever a CPU profile is generated on a machine with a recent
Linux kernel, the current inherit policy will lead to the CPU profile
being incompatible on deplyoments with older Linux kernels. This may
not be the intention of the person generating the CPU profile, thus
we change the policy to `Static(0)` for the time being.

Original 18dd567:
arch: Clear LBR related bits in the VM-Exit and VM-Entry CTL MSRs

We have disabled LBR for non-host CPU profiles, but forgot to also do
so in the VM-Exit and VM-Entry control MSRs.

Original ed87056:
arch: Inherit ITS_NO for CPU profiles

If bit 62 (ITS_NO) of MSR IA32_ARCH_CAPABILITIES is set, then the system
is not affected by indirect target selection.

Since we now correctly check compatibility with regards to the value
of this bit we want to record it in the CPU profile.

This ensures that any VM launched with the same CPU profile sees the
same value for ITS_NO otherwise live migration may error even though
the CPU profile could be applied to both the migration source and
destination.

Signed-off-by: Oliver Anderson <oliver.anderson@cyberus-technology.de>
On-behalf-of: SAP oliver.anderson@sap.com
This list will be used to help us detect unknown MSRs when generating
CPU profiles. It serves no other purpose beyond that.

Original 615609f:
arch: Address architectural msrs review

TODO: Squash into previous commit if this all works as expected

Original ee6aeba:
arch: Permit IA32_MCG_CAP and IA32_MCG_STATUS

We permit these MSRs because they are expected to be available when
the CPUID 0x1.EDX[14](MCA) feature bit is set. Recall that MCA is
necessary in order to boot Windows Server which we want to support.

We also do not list the error reporting banks as forbidden any longer.
Aside: The previous implementation did not end up denying those MSRs
anyway, because KVM does not report them via KVM_GET_MSR_INDEX_LIST.
Now with MCA explicitly set, the guest will certainly expect the
presence of error reporting banks, so we make sure not to indicate
otherwise.

Recall that by default KVM reports all (32) error banks as available
and leaves all feature bits of IA32_MCG_CAP unset, hence the
information displayed to the guest in these MSRs will remain consistent
before and after a live migration in the absence of machine check
errors.

Note that as of today Cloud hypervisor does not transfer the error
reporting banks to the destination of a live migration which can indeed
lead to surprises, but on the other hand the information is likely to
be inaccurate at the point of resume anyway.

As a follow up we could try to mitigate the aforementioned problem
by checking for MCEs during live migration and marking the migration
as failed if any MCE occurred before or during the live migration.
That should however be addressed in a separate PR.

Original 0ba1625:
arch: FORDIB IA32_U_CET and IA32_S_CET in CPU Profiles

These are already displayed as not available to guests via CPUID for
non-host CPU profiles, but we forgot to forbid the corresponding MSRs.

The profiles we have generated are OK with respect to this oversight
because KVM_GET_MSR_INDEX_LIST did not report those MSRs at the time
they were generated, but it does now.

Original 4b7558d:
arch: Forbid IA32_XSS for non-host CPU profiles

IA32_XSS (Extended Supervisor State Mask) is only reported via
KVM_GET_MSR_INDEX_LIST on rather recent kernels. This can lead to CPU
profiles that are generated on a machine with the latest Linux kernel,
not work with deployments where the hosts use a bit older kernels which
may be unintentional.

We thus decide to forbid this MSR for now, even though
CPUID 0xd.0x1.EAX[3] can inform the guest that the MSR is available.
We do not want to force the aforementioned feature bit to 0 because
it is also used to report support for XSAVES/XRSTORS.

Although not ideal, we consider denying access to IA32_XSS to be
acceptable because the 0xd CPUID leaves report all IA32_XSS related
state components to be unsupported. There is thus no reason for the
guest to be interested in using this MSR.

Signed-off-by: Oliver Anderson <oliver.anderson@cyberus-technology.de>
On-behalf-of: SAP oliver.anderson@sap.com
We include a list of non-architectural MSRS. This list will only be
used to help the CPU profile generation tool rule out MSRs that it
does not know how to handle.

Signed-off-by: Oliver Anderson <oliver.anderson@cyberus-technology.de>
On-behalf-of: SAP oliver.anderson@sap.com
We include a list of MSRS defined by KVM that may be approved by
CPU profiles and another list of those that may not be approved by
CPU profiles. These lists will later be used by the CPU profile
generation tool.

Signed-off-by: Oliver Anderson <oliver.anderson@cyberus-technology.de>
On-behalf-of: SAP oliver.anderson@sap.com
Signed-off-by: Julian Schindel <julian.schindel@cyberus-technology.de>
In order to generate CPU profiles we also need definitions and policies
for MSR-based features, as some CPU features are exposed through MSRs
rather than CPUID.

This commit introduces the MSR analogues of the data structures we
previously introduced for CPUID definitions.

Signed-off-by: Oliver Anderson <oliver.anderson@cyberus-technology.de>
On-behalf-of: SAP oliver.anderson@sap.com
We add developer documentation on how to use the CPU profile generation
tool.

Original 666ea16:
docs: Update CPU profile generation developer documentation

Signed-off-by: Oliver Anderson <oliver.anderson@cyberus-technology.de>
On-behalf-of: SAP oliver.anderson@sap.com
We will later use flate2 in arch/build.rs to compress CPU profile
JSON files at compile time and also later to decompress them at
runtime.

Signed-off-by: Oliver Anderson <oliver.anderson@cyberus-technology.de>
On-behalf-of: SAP oliver.anderson@sap.com
We introduce a build.rs build script in the arch crate which
automatically constructs the x86_64 CpuProfile enum with one variant
per pre-generated CPU profile.

In order to keep the binary size in check we also take the opportunity
to compress the CPU profile JSON files into the binary which then get
decompressed at runtime.

We will adapt cpu_profile.rs in the next commit to use the output
of build.rs

Original d30e060:
arch: Deserialize CPU profiles in kebab-case

When we introduced our build script we forgot to tell `serde` to
(de-) serialize the `CpuProfile` enum in kebab-case which is a breaking
change.

Original ce0e7b0:
arch: Include Skylake and Sapphire rapids CPU profiles

We include CPU profiles corresponding to Intel Skylake and Sapphire
rapids server that we generated using our WIP CPU profile generation
tool.

[ Adapted to v55: Cargo.lock follows v55's dependency versions ]

Signed-off-by: Oliver Anderson <oliver.anderson@cyberus-technology.de>
On-behalf-of: SAP oliver.anderson@sap.com
We introduce data structures to describe values within the registers
modified by the CPUID instruction. These data structures will later be
used by the upcoming CPU profile generation tool.

Signed-off-by: Oliver Anderson <oliver.anderson@cyberus-technology.de>
On-behalf-of: SAP oliver.anderson@sap.com
Introduce a method on `CpuProfile` that is used to adjust the given
CPUID entries according to the chosen CPU profile.

This will be used in a later commit to apply the user chosen CPU
profile.

This commit also introduces a few unit tests using relatively simple,
somewhat contrived input values.

We will introduce snapshot tests with realistic adjustments
and CPUID entries in our planned follow up PR bringing in our
pregenerated CPU profiles.

Original 0140286:
arch: Re-enable loading pre-generated CPU profiles

Original 64ec088:
arch: Use MSR aware profiles

We regenerate the CPU profiles and include the MSR-related data.

Original a7a7458:
arch: Update cpu_profile.rs to include code generation from build.rs

Signed-off-by: Oliver Anderson <oliver.anderson@cyberus-technology.de>
On-behalf-of: SAP oliver.anderson@sap.com

arch: CpuProfile enum

Introduce a CpuProfile enum that will be deserialized from the user's
selected CPU profile.

Currently we only have a "host" variant, but in the future there will
be a build script automatically constructing this enum based on
pre-generated CPU profiles.

[ Adapted to v55, which has CpuProfileConfig with Host and File(path):
  build.rs adds the built-in profiles as extra variants, selected by
  their kebab-case name with a "Host" alias, and CpuProfile::builtin()
  provides their data ]

Signed-off-by: Oliver Anderson <oliver.anderson@cyberus-technology.de>
On-behalf-of: SAP oliver.anderson@sap.com
Introduce convenience methods for looking up CPUID value definitions.

We will later use these methods to assert certain policies at compile
time in order to stay consistent with MSR policies we introduce.

Due to the current limitations of const generics we unfortunately
need to duplicate a little bit code.

Signed-off-by: Oliver Anderson <oliver.anderson@cyberus-technology.de>
On-behalf-of: SAP oliver.anderson@sap.com
We refactor `generate_common_cpuid` to take CPU profiles into account.

Original 21cd135:
hypervisor: Remove redundant MSHV imports

Original 0c2c544:
misc: Make CPU profile part of various configs

We integrate the CPU profile into the various configs that
ultimately get set by the user.

This quickly ends up involving multiple files, luckily Rust
helps us find which ones via compilation errors.

Original 145622b:
arch: Fix typo in generate_common_cpuid

We fix a pre-existing typo in an info event in
the `generate_common_cpuid` function.

Original dbb1efd:
arch: Use backported CpuidParameters in profile generation code

In the cpuid_definitions crate we can now use the backported
CpuidParameters struct instead of Parameters.

In order to avoid further changes in this rather large patch set we
just re-export it for now.

Once the profile generation code has been upstreamed then we can just
simply replace these files with the upstreamed once anyway.

Original 46bd60a:
arch: Use backported RegisterAddress in CPU profile generation code

We re-export the backported RegisterAddress in the
msr_definitions module. We do this instead of directly importing
msr_adjustments::RegisterAddress everywhere because that is a larger
change.

Once we have upstreamed CPU profile generation then we can just simply
replace all of these files anyway.

Original 7551d1e:
arch: Remove duplicate serialization helpers

The serialization helpers have been moved into the helpers module.

We are now at a point where we can remove the duplicates in arch/lib.rs
without causing compilation errors.

Original 701188b:
arch: Allow unsafe for cpuid invocations

Since we have 1.89 as the MSRV (and not 1.95) we need to allow
unused unsafe in a few instances here.

It was painful to find the exact commit/revert that caused this
lint to appear so we just do it like this for now.

Original 9885fe5:
fuzz: Remove duplicate profile entry in CpusConfig

Original aea3800:
arch: Fix Clippy lints for CPUID updates

This fixes lints of the following kind:
```
error: this `if` can be collapsed into the outer `match`
   --> arch/src/x86_64/mod.rs:874:17
    |
874 | /                 if !config.amx {
875 | |                     if entry.index == 0 {
876 | |                         entry.edx &= !((1 << AMX_BF16) | (1 << AMX_TILE) | (1 << AMX_INT8));
...   |
882 | |                 }
    | |_________________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_match
    = note: `-D clippy::collapsible-match` implied by `-D clippy::all`
    = help: to override `-D clippy::all` add `#[allow(clippy::collapsible_match)]`
help: collapse nested if block
    |
873 ~             0x7
874 ~                 if !config.amx => {
875 |                     if entry.index == 0 {
...
881 |                     }
882 ~                 }
    |
```

[ Adapted to v55: v55 already parses the nested option, and the MSHV
  get_sregs() signature change is not needed ]

Signed-off-by: Oliver Anderson <oliver.anderson@cyberus-technology.de>
On-behalf-of: SAP oliver.anderson@sap.com
On-behalf-of: SAP pascal.scholz@sap.com
Signed-off-by: Pascal Scholz <pascal.scholz@cyberus-technology.de>
Signed-off-by: Julian Schindel <julian.schindel@cyberus-technology.de>
This commit introduces a CLI for generating a CPU profile closely
matching the CPU of the machine the CLI is executed on. The idea is to
have a simple way to add more CPU profiles corresponding to physical
CPUs.

Note however that with the current setup one still needs a little bit
of manual work to integrate the generated CPU profile data into cloud
hypervisor itself.

Original 638c12d:
arch: Make the CPU profile generation tool MSR aware

We adapt the CPU profile generation tool to also take the MSR-based
features into account.

Original b83151c:
arch: Re-enable CPU profile generation tool

We adapt the CPU profile generation tool to the backported functionality
and re-enable the tool.

[ Adapted to v55: anyhow is optional and only used by the generator, as
  v55's arch crate no longer depends on it, the generator enables the
  clap features it needs because the v55 workspace disables clap's
  default features, and the absolute paths flagged by clippy are
  imported (folded in from "arch: fix clippy issues in CI") ]

Signed-off-by: Oliver Anderson <oliver.anderson@cyberus-technology.de>
On-behalf-of: SAP oliver.anderson@sap.com
[ Adapted to v55: keep dep:anyhow from the previous commit ]

Signed-off-by: Oliver Anderson <oliver.anderson@cyberus-technology.de>
On-behalf-of: SAP oliver.anderson@sap.com
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.

6 participants