Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix CVM boot failure on MSHV - #7548

Merged
likebreath merged 1 commit into
cloud-hypervisor:mainfrom
russell-islam:muislam/fix/cvm-boot-failure
Jan 21, 2026
Merged

likebreath merged 1 commit into
cloud-hypervisor:mainfrom
russell-islam:muislam/fix/cvm-boot-failure

Conversation

@russell-islam

@russell-islam russell-islam commented Dec 8, 2025

Copy link
Copy Markdown
Contributor

Recent changes related to arm64 support in MSHV exposed inconsistencies in the VM initialization and CVM boot paths.
The VM creation flow currently diverges across multiple scenarios, including regular MSHV, CVM, and arm64, with each path performing guest initialization steps in a different order. Certain platform-specific requirements further constrain the ordering
of operations, such as the timing of address space creation, IGVM loading, interrupt controller setup, and payload loading. For
CVM case address-space creation must be done after IGVM loading, and PSP measurement. For Regular and arm64 this memory initialization must be done early. For MSHV, vm.init() and sev_snp.init() are called in different order which is run time and build time conditionally checked.

Additionally, while the KVM initialization path differs slightly from MSHV, it shares common logic that is currently split across
separate conditional and build-time code paths, contributing to fragmentation of the overall flow.

This change restructures the VM creation and initialization sequence to better align shared logic, enforce scenario-specific ordering constraints, and ensure consistent and correct behavior across all supported configurations. In doing so, it restores proper CVM boot behavior and improves the maintainability of the initialization code.

@russell-islam
russell-islam requested a review from a team as a code owner December 8, 2025 02:12
@russell-islam
russell-islam force-pushed the muislam/fix/cvm-boot-failure branch from 5d38232 to ebed942 Compare December 8, 2025 21:23
Comment thread vmm/src/vm.rs
Comment thread vmm/src/vm.rs
@russell-islam
russell-islam force-pushed the muislam/fix/cvm-boot-failure branch from ebed942 to 649e47e Compare December 17, 2025 20:39
@russell-islam

russell-islam commented Dec 30, 2025

Copy link
Copy Markdown
Contributor Author

@likebreath @liuw Would you be able to take a look here?

@rbradford rbradford left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm rubber stamping this since it sounds like it's need to fix important functionality - but i've opened #7598 to handle that this method is now pretty difficult to follow.

Comment thread vmm/src/igvm/igvm_loader.rs
@russell-islam

russell-islam commented Jan 12, 2026

Copy link
Copy Markdown
Contributor Author

I'm rubber stamping this since it sounds like it's need to fix important functionality - but i've opened #7598 to handle that this method is now pretty difficult to follow.

Exactly, this function is very ugly. I think after this PR merged we can simplify and make it more readable. Thx

@russell-islam
russell-islam force-pushed the muislam/fix/cvm-boot-failure branch 2 times, most recently from d7cd3ed to 9b88872 Compare January 12, 2026 17:27
@russell-islam russell-islam changed the title vmm: fix CVM boot failure fix CVM boot failure on MSHV upon arm64 support Jan 12, 2026
@russell-islam

Copy link
Copy Markdown
Contributor Author

There is a shell check error in the main branch.

@likebreath

Copy link
Copy Markdown
Member

i've opened #7598 to handle that this method is now pretty difficult to follow.

Right, that is my main concern too, but I haven't had a chance to dig deeper and come up with a proposal.

@russell-islam While you are working on this, could you summarize the VM boot requirements for the various permutations and add that to the issue? Specifically, we need to understand the matrix across hypervisors (KVM/MSHV), architectures (x86_64/AArch64), and VM types (legacy vs. confidential).

@likebreath likebreath left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM for legacy VM use cases, specifically KVM (x86_64/AArch64).

However, we still need a review of the impact on confidential VMs, especially regarding MSHV. I also have a question regarding this below.

Comment thread vmm/src/igvm/igvm_loader.rs
@russell-islam
russell-islam force-pushed the muislam/fix/cvm-boot-failure branch from 9b88872 to a5e8dd0 Compare January 12, 2026 19:12
@russell-islam russell-islam changed the title fix CVM boot failure on MSHV upon arm64 support fix CVM boot failure on MSHV Jan 12, 2026
@russell-islam

Copy link
Copy Markdown
Contributor Author

i've opened #7598 to handle that this method is now pretty difficult to follow.

Right, that is my main concern too, but I haven't had a chance to dig deeper and come up with a proposal.

@russell-islam While you are working on this, could you summarize the VM boot requirements for the various permutations and add that to the issue? Specifically, we need to understand the matrix across hypervisors (KVM/MSHV), architectures (x86_64/AArch64), and VM types (legacy vs. confidential).

I am working on that.

Recent changes related to arm64 support in MSHV exposed
inconsistencies in the VM initialization and CVM boot paths.
The VM creation flow currently diverges across multiple scenarios,
including regular MSHV, CVM, and arm64, with each path performing
guest initialization steps in a different order.
Certain platform-specific requirements further constrain the ordering
of operations, such as the timing of address space creation,
IGVM loading, interrupt controller setup, and payload loading. For
CVM case address-space creation must be done after IGVM loading, and
PSP measurement. For Regular and arm64 this memory initialization
must be done early. For MSHV, vm.init() and sev_snp.init() are called in
different order which is run time and build time conditionally checked.

Additionally, while the KVM initialization path differs slightly
from MSHV, it shares common logic that is currently split across
separate conditional and build-time code paths, contributing to
fragmentation of the overall flow.

This change restructures the VM creation and initialization sequence
to better align shared logic, enforce scenario-specific ordering
constraints, and ensure consistent and correct behavior across all
supported configurations. In doing so, it restores proper CVM boot
behavior and improves the maintainability of the initialization code.

Signed-off-by: Muminul Islam <[email protected]>
@russell-islam
russell-islam force-pushed the muislam/fix/cvm-boot-failure branch from a5e8dd0 to 646e43c Compare January 16, 2026 17:25
@rbradford

Copy link
Copy Markdown
Member

What's the status of this PR - are we ready to move forward?

@likebreath

Copy link
Copy Markdown
Member

LGTM for legacy VM use cases, specifically KVM (x86_64/AArch64).

However, we still need a review of the impact on confidential VMs, especially regarding MSHV.

It needs a review from MSHV side.

@russell-islam

Copy link
Copy Markdown
Contributor Author

@liuw @NunoDasNeves @anirudhrb Could you please take a look?

@likebreath
likebreath added this pull request to the merge queue Jan 20, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jan 20, 2026
@liuw
liuw added this pull request to the merge queue Jan 21, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jan 21, 2026

@anirudhrb anirudhrb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested guest boot on arm64 MSHV.

Comment thread vmm/src/vm.rs
}
}
#[cfg(feature = "sev_snp")]
if sev_snp_enabled {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All this ugly "double checking" for sev_snp support could be fixed if the config option is always available, but just hardcoded to false when support is not compiled in... I guess that's out of scope here.

You could probably clean up this function, however, by doing the following (above, where sev_snp_enabled is defined):

let sev_snp_enabled = cfg_if::cfg_if! {
        if #[cfg(feature = "sev_snp")] {
            config.lock().unwrap().is_sev_snp_enabled()
        } else {
            false
        }
}

I haven't checked this but I think it's worth doing in this PR if at all possible.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1. I suggested the same above. #7548 (comment)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's land this one as it is, since we all agree on its functional changes. Please send out a PR to improve the code quality. Thank you.

Comment thread vmm/src/vm.rs
vm.sev_snp_init().map_err(Error::InitializeSevSnpVm)?;
}

#[cfg(feature = "sev_snp")]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see above, can we remove this check if sev_snp_enabled is always defined?

Comment thread vmm/src/vm.rs
.unwrap()
.allocate_address_space()
.map_err(Error::MemoryManager)?;
cfg_if::cfg_if! {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above, can we reduce this to a single check if sev_snp_enabled is always defined?

Comment thread vmm/src/vm.rs
};
// First case is when sev_snp is enabled(compiled), but run time non-cvn
// guest boot. 2nd case is when sev_snp is not compiled in, KVM and MSHV regular guest boot.
cfg_if::cfg_if! {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above, can we reduce this to a single check if sev_snp_enabled is always defined?

Comment thread vmm/src/vm.rs
.map_err(Error::CpuManager)?;
// First case is when sev_snp is enabled(compiled), but run time non-cvn
// guest boot. 2nd case is when sev_snp is not compiled in, KVM and MSHV regular guest boot.
cfg_if::cfg_if! {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above, can we reduce this to a single check if sev_snp_enabled is always defined?

@likebreath
likebreath added this pull request to the merge queue Jan 21, 2026
Merged via the queue into cloud-hypervisor:main with commit c9cd82b Jan 21, 2026
46 of 47 checks passed
@likebreath likebreath added the mshv Affects mshv only label Feb 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mshv Affects mshv only

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

6 participants