Skip to content

Conversation

@sluck-msft
Copy link
Contributor

Since the host can provide CPUID bits (to a varying degree), check if there are any XSAVE-dependent features where the XSAVE support is not expressed as available (this appears to be validated to varying degrees by the TCBs in question), and update CPUID so that those features are not advertised as available.

On TDX, avx_vnni_int16 was also being filtered out. There doesn't seem to be a reason to do this, so filter it back in.

Tested:
SNP VM boots

@sluck-msft sluck-msft requested a review from a team as a code owner January 24, 2026 00:59
Copilot AI review requested due to automatic review settings January 24, 2026 00:59
0,
cpuid::ExtendedFeatureSubleaf1Edx::new()
.with_avx_vnni_int8(true)
.with_avx_vnni_int16(true)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@chris-oo avx_vnni_int16 is the new bit being filtered in. Lmk if you prefer we don't make this change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(I still haven't tested yet that TDX boots)

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR enhances CPUID feature consistency for confidential VMs (CVMs) by ensuring that features requiring XSAVE support are not advertised when the corresponding XSAVE state components are unavailable. The changes add the avx_vnni_int16 field to the CPUID structure and implement XSAVE dependency validation across both common code and TDX-specific paths.

Changes:

  • Added avx_vnni_int16 field to ExtendedFeatureSubleaf1Edx structure
  • Implemented common XSAVE dependency checking that clears AVX/AVX2/AVX512 features when required XSAVE states are missing
  • Added TDX-specific XSAVE dependency handling for leaf 7.1 features
  • Moved leaf 7.1 feature masking from common masking.rs to TDX-specific code, allowing avx_vnni_int16 to be exposed for TDX
  • Added test coverage for XSAVE dependency validation

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
vm/x86/x86defs/src/cpuid.rs Adds avx_vnni_int16 field to ExtendedFeatureSubleaf1Edx bitfield structure
openhcl/virt_mshv_vtl/src/cvm_cpuid/tests/xfem.rs Adds test verifying CPUID features are cleared when XSAVE support is missing
openhcl/virt_mshv_vtl/src/cvm_cpuid/tdx.rs Implements TDX-specific XSAVE dependency handling and adds avx_vnni_int16 to additional_leaf_mask
openhcl/virt_mshv_vtl/src/cvm_cpuid/snp.rs Adds no-op SNP-specific update_xsave_dependencies implementation
openhcl/virt_mshv_vtl/src/cvm_cpuid/mod.rs Implements common XSAVE dependency checking for AVX/AVX2/AVX512 features and adds trait method for architecture-specific handling
openhcl/virt_mshv_vtl/src/cvm_cpuid/masking.rs Removes leaf 7.1 masking from common code (moved to TDX-specific implementation)

Comment on lines +1260 to +1267
let result = cpuid_result(&cpuid, CpuidFunction::VersionAndFeatures, 0);
assert_eq!(result.ecx & u32::from(version_and_features_clear), 0);

let result = cpuid_result(&cpuid, CpuidFunction::ExtendedFeatures, 0);
assert_eq!(result.ebx & extended_features_0_clear.ebx, 0);
assert_eq!(result.ecx & extended_features_0_clear.ecx, 0);
assert_eq!(result.edx & extended_features_0_clear.edx, 0);
}
Copy link

Copilot AI Jan 24, 2026

Choose a reason for hiding this comment

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

The test should verify that features in ExtendedFeatureSubleaf1 (leaf 7.1) are also being cleared when XSAVE support is missing. Currently, the test only checks leaf 1 (VersionAndFeatures) and leaf 7.0 (ExtendedFeatures subleaf 0), but doesn't verify that avx_vnni, avx_ifma, avx_vnni_int8, avx_vnni_int16, avx_ne_convert, or avx512_bfloat16 from leaf 7.1 are properly cleared. This is important because the PR specifically adds support for clearing these features in TDX environments.

Copilot uses AI. Check for mistakes.
@github-actions
Copy link

@sluck-msft sluck-msft force-pushed the user/sluck/cpuid-consistency branch from ef0f4bb to 1dcd2c5 Compare January 26, 2026 21:56
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.

4 participants