diff --git a/hypervisor/arch/x86/guest/vmcs.c b/hypervisor/arch/x86/guest/vmcs.c index e0b7a46aa..ea58e80da 100644 --- a/hypervisor/arch/x86/guest/vmcs.c +++ b/hypervisor/arch/x86/guest/vmcs.c @@ -297,7 +297,8 @@ static void init_exec_ctrl(struct acrn_vcpu *vcpu) */ value32 = check_vmx_ctrl(MSR_IA32_VMX_PROCBASED_CTLS2, VMX_PROCBASED_CTLS2_VAPIC | VMX_PROCBASED_CTLS2_EPT |VMX_PROCBASED_CTLS2_VPID | - VMX_PROCBASED_CTLS2_RDTSCP | VMX_PROCBASED_CTLS2_UNRESTRICT); + VMX_PROCBASED_CTLS2_RDTSCP | VMX_PROCBASED_CTLS2_UNRESTRICT | + VMX_PROCBASED_CTLS2_PAUSE_LOOP); /* SDM Vol3, 25.3, setting "enable INVPCID" VM-execution to 1 with "INVLPG exiting" disabled, * passes-through INVPCID instruction to guest if the instruction is supported. @@ -425,6 +426,10 @@ static void init_exec_ctrl(struct acrn_vcpu *vcpu) exec_vmwrite(VMX_CR3_TARGET_1, 0UL); exec_vmwrite(VMX_CR3_TARGET_2, 0UL); exec_vmwrite(VMX_CR3_TARGET_3, 0UL); + + /* Setup PAUSE-loop exiting - 24.6.13 */ + exec_vmwrite(VMX_PLE_GAP, 128U); + exec_vmwrite(VMX_PLE_WINDOW, 4096U); } static void init_entry_ctrl(const struct acrn_vcpu *vcpu) diff --git a/hypervisor/arch/x86/guest/vmexit.c b/hypervisor/arch/x86/guest/vmexit.c index ac73f4caa..f8b4e3aa9 100644 --- a/hypervisor/arch/x86/guest/vmexit.c +++ b/hypervisor/arch/x86/guest/vmexit.c @@ -30,6 +30,7 @@ static int32_t unhandled_vmexit_handler(struct acrn_vcpu *vcpu); static int32_t xsetbv_vmexit_handler(struct acrn_vcpu *vcpu); static int32_t wbinvd_vmexit_handler(struct acrn_vcpu *vcpu); static int32_t undefined_vmexit_handler(struct acrn_vcpu *vcpu); +static int32_t pause_vmexit_handler(__unused struct acrn_vcpu *vcpu); /* VM Dispatch table for Exit condition handling */ static const struct vm_exit_dispatch dispatch_table[NR_VMX_EXIT_REASONS] = { @@ -113,7 +114,7 @@ static const struct vm_exit_dispatch dispatch_table[NR_VMX_EXIT_REASONS] = { [VMX_EXIT_REASON_MONITOR] = { .handler = unhandled_vmexit_handler}, [VMX_EXIT_REASON_PAUSE] = { - .handler = unhandled_vmexit_handler}, + .handler = pause_vmexit_handler}, [VMX_EXIT_REASON_ENTRY_FAILURE_MACHINE_CHECK] = { .handler = unhandled_vmexit_handler}, [VMX_EXIT_REASON_TPR_BELOW_THRESHOLD] = { @@ -277,6 +278,12 @@ static int32_t triple_fault_vmexit_handler(struct acrn_vcpu *vcpu) return 0; } +static int32_t pause_vmexit_handler(__unused struct acrn_vcpu *vcpu) +{ + yield_current(); + return 0; +} + int32_t cpuid_vmexit_handler(struct acrn_vcpu *vcpu) { uint64_t rax, rbx, rcx, rdx;