Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions src/vmx/vcpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1220,20 +1220,25 @@ impl<H: AxVCpuHal> VmxVcpu<H> {
return None;
}

if x.contains(Xcr0::XCR0_OPMASK_STATE)
if (x.contains(Xcr0::XCR0_OPMASK_STATE)

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.

Could you please add some comments here to describe why these combinations are invalid

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.

Also maybe we can extract these ifs into a new validator function?

|| x.contains(Xcr0::XCR0_ZMM_HI256_STATE)
|| x.contains(Xcr0::XCR0_HI16_ZMM_STATE)
|| !x.contains(Xcr0::XCR0_AVX_STATE)
|| x.contains(Xcr0::XCR0_HI16_ZMM_STATE))
&& (!x.contains(Xcr0::XCR0_AVX_STATE)
|| !x.contains(Xcr0::XCR0_OPMASK_STATE)
|| !x.contains(Xcr0::XCR0_ZMM_HI256_STATE)
|| !x.contains(Xcr0::XCR0_HI16_ZMM_STATE)
|| !x.contains(Xcr0::XCR0_HI16_ZMM_STATE))

Copilot AI Jan 21, 2026

Copy link

Choose a reason for hiding this comment

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

The indentation on this line appears inconsistent with the previous lines in the same logical group. It should align with lines 1227-1228 to maintain consistent formatting.

Suggested change
|| !x.contains(Xcr0::XCR0_HI16_ZMM_STATE))
|| !x.contains(Xcr0::XCR0_HI16_ZMM_STATE))

Copilot uses AI. Check for mistakes.
{
return None;
}

Some(x)
})
.ok_or(ax_err_type!(InvalidInput))
.ok_or_else(|| {
ax_err_type!(
InvalidInput,
format_args!("invalid xcr0 value: {:#x}", value)
)
})
.and_then(|x| {
self.xstate.guest_xcr0 = x.bits();
self.advance_rip(VM_EXIT_INSTR_LEN_XSETBV)
Expand Down
Loading