|
@@ -2556,6 +2556,19 @@ static int nested_vmx_check_exception(struct kvm_vcpu *vcpu, unsigned long *exit
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
+static void vmx_clear_hlt(struct kvm_vcpu *vcpu)
|
|
|
+{
|
|
|
+ /*
|
|
|
+ * Ensure that we clear the HLT state in the VMCS. We don't need to
|
|
|
+ * explicitly skip the instruction because if the HLT state is set,
|
|
|
+ * then the instruction is already executing and RIP has already been
|
|
|
+ * advanced.
|
|
|
+ */
|
|
|
+ if (kvm_hlt_in_guest(vcpu->kvm) &&
|
|
|
+ vmcs_read32(GUEST_ACTIVITY_STATE) == GUEST_ACTIVITY_HLT)
|
|
|
+ vmcs_write32(GUEST_ACTIVITY_STATE, GUEST_ACTIVITY_ACTIVE);
|
|
|
+}
|
|
|
+
|
|
|
static void vmx_queue_exception(struct kvm_vcpu *vcpu)
|
|
|
{
|
|
|
struct vcpu_vmx *vmx = to_vmx(vcpu);
|
|
@@ -2586,6 +2599,8 @@ static void vmx_queue_exception(struct kvm_vcpu *vcpu)
|
|
|
intr_info |= INTR_TYPE_HARD_EXCEPTION;
|
|
|
|
|
|
vmcs_write32(VM_ENTRY_INTR_INFO_FIELD, intr_info);
|
|
|
+
|
|
|
+ vmx_clear_hlt(vcpu);
|
|
|
}
|
|
|
|
|
|
static bool vmx_rdtscp_supported(void)
|
|
@@ -5545,6 +5560,8 @@ static u32 vmx_exec_control(struct vcpu_vmx *vmx)
|
|
|
if (kvm_mwait_in_guest(vmx->vcpu.kvm))
|
|
|
exec_control &= ~(CPU_BASED_MWAIT_EXITING |
|
|
|
CPU_BASED_MONITOR_EXITING);
|
|
|
+ if (kvm_hlt_in_guest(vmx->vcpu.kvm))
|
|
|
+ exec_control &= ~CPU_BASED_HLT_EXITING;
|
|
|
return exec_control;
|
|
|
}
|
|
|
|
|
@@ -5906,6 +5923,8 @@ static void vmx_vcpu_reset(struct kvm_vcpu *vcpu, bool init_event)
|
|
|
update_exception_bitmap(vcpu);
|
|
|
|
|
|
vpid_sync_context(vmx->vpid);
|
|
|
+ if (init_event)
|
|
|
+ vmx_clear_hlt(vcpu);
|
|
|
}
|
|
|
|
|
|
/*
|
|
@@ -5976,6 +5995,8 @@ static void vmx_inject_irq(struct kvm_vcpu *vcpu)
|
|
|
} else
|
|
|
intr |= INTR_TYPE_EXT_INTR;
|
|
|
vmcs_write32(VM_ENTRY_INTR_INFO_FIELD, intr);
|
|
|
+
|
|
|
+ vmx_clear_hlt(vcpu);
|
|
|
}
|
|
|
|
|
|
static void vmx_inject_nmi(struct kvm_vcpu *vcpu)
|
|
@@ -6006,6 +6027,8 @@ static void vmx_inject_nmi(struct kvm_vcpu *vcpu)
|
|
|
|
|
|
vmcs_write32(VM_ENTRY_INTR_INFO_FIELD,
|
|
|
INTR_TYPE_NMI_INTR | INTR_INFO_VALID_MASK | NMI_VECTOR);
|
|
|
+
|
|
|
+ vmx_clear_hlt(vcpu);
|
|
|
}
|
|
|
|
|
|
static bool vmx_get_nmi_mask(struct kvm_vcpu *vcpu)
|
|
@@ -12347,6 +12370,7 @@ static int vmx_pre_enter_smm(struct kvm_vcpu *vcpu, char *smstate)
|
|
|
|
|
|
vmx->nested.smm.vmxon = vmx->nested.vmxon;
|
|
|
vmx->nested.vmxon = false;
|
|
|
+ vmx_clear_hlt(vcpu);
|
|
|
return 0;
|
|
|
}
|
|
|
|