Skip to content

Commit 082d2e6

Browse files
committed
[feat] improve features setting in SecondaryControls
1 parent 7eb2b58 commit 082d2e6

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/vmx/vcpu.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -677,25 +677,30 @@ impl<H: AxVCpuHal> VmxVcpu<H> {
677677

678678
// Enable EPT, RDTSCP, INVPCID, and unrestricted guest.
679679
use SecondaryControls as CpuCtrl2;
680-
let mut val = CpuCtrl2::ENABLE_EPT
681-
| CpuCtrl2::UNRESTRICTED_GUEST
682-
| CpuCtrl2::ENABLE_USER_WAIT_PAUSE
683-
| CpuCtrl2::ENABLE_VM_FUNCTIONS;
680+
let mut val =
681+
CpuCtrl2::ENABLE_EPT | CpuCtrl2::UNRESTRICTED_GUEST | CpuCtrl2::ENABLE_VM_FUNCTIONS;
682+
684683
if let Some(features) = raw_cpuid.get_extended_processor_and_feature_identifiers() {
685684
if features.has_rdtscp() {
686685
val |= CpuCtrl2::ENABLE_RDTSCP;
687686
}
688687
}
688+
689689
if let Some(features) = raw_cpuid.get_extended_feature_info() {
690690
if features.has_invpcid() {
691691
val |= CpuCtrl2::ENABLE_INVPCID;
692692
}
693+
if features.has_waitpkg() {
694+
val |= CpuCtrl2::ENABLE_USER_WAIT_PAUSE;
695+
}
693696
}
697+
694698
if let Some(features) = raw_cpuid.get_extended_state_info() {
695699
if features.has_xsaves_xrstors() {
696700
val |= CpuCtrl2::ENABLE_XSAVES_XRSTORS;
697701
}
698702
}
703+
699704
vmcs::set_control(
700705
VmcsControl32::SECONDARY_PROCBASED_EXEC_CONTROLS,
701706
Msr::IA32_VMX_PROCBASED_CTLS2,

0 commit comments

Comments
 (0)