aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Kiszka <jan.kiszka@siemens.com>2013-12-04 02:58:54 -0500
committerPaolo Bonzini <pbonzini@redhat.com>2013-12-12 04:49:56 -0500
commit6dfacadd5858882eee1983995854d4e1fb1b966e (patch)
tree932c4a94bf720cda40e1ed0cb3262a07a31b326b
parent2961e8764faad212234e93907a370a7c36a67da5 (diff)
KVM: nVMX: Add support for activity state HLT
We can easily emulate the HLT activity state for L1: If it decides that L2 shall be halted on entry, just invoke the normal emulation of halt after switching to L2. We do not depend on specific host features to provide this, so we can expose the capability unconditionally. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r--arch/x86/include/asm/vmx.h1
-rw-r--r--arch/x86/kvm/vmx.c7
2 files changed, 7 insertions, 1 deletions
diff --git a/arch/x86/include/asm/vmx.h b/arch/x86/include/asm/vmx.h
index 966502d4682e..2067264fb7f5 100644
--- a/arch/x86/include/asm/vmx.h
+++ b/arch/x86/include/asm/vmx.h
@@ -100,6 +100,7 @@
100 100
101#define VMX_MISC_PREEMPTION_TIMER_RATE_MASK 0x0000001f 101#define VMX_MISC_PREEMPTION_TIMER_RATE_MASK 0x0000001f
102#define VMX_MISC_SAVE_EFER_LMA 0x00000020 102#define VMX_MISC_SAVE_EFER_LMA 0x00000020
103#define VMX_MISC_ACTIVITY_HLT 0x00000040
103 104
104/* VMCS Encodings */ 105/* VMCS Encodings */
105enum vmcs_field { 106enum vmcs_field {
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 1024689ac717..f90320b204a9 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -2340,6 +2340,7 @@ static __init void nested_vmx_setup_ctls_msrs(void)
2340 rdmsr(MSR_IA32_VMX_MISC, nested_vmx_misc_low, nested_vmx_misc_high); 2340 rdmsr(MSR_IA32_VMX_MISC, nested_vmx_misc_low, nested_vmx_misc_high);
2341 nested_vmx_misc_low &= VMX_MISC_PREEMPTION_TIMER_RATE_MASK | 2341 nested_vmx_misc_low &= VMX_MISC_PREEMPTION_TIMER_RATE_MASK |
2342 VMX_MISC_SAVE_EFER_LMA; 2342 VMX_MISC_SAVE_EFER_LMA;
2343 nested_vmx_misc_low |= VMX_MISC_ACTIVITY_HLT;
2343 nested_vmx_misc_high = 0; 2344 nested_vmx_misc_high = 0;
2344} 2345}
2345 2346
@@ -7938,7 +7939,8 @@ static int nested_vmx_run(struct kvm_vcpu *vcpu, bool launch)
7938 return 1; 7939 return 1;
7939 } 7940 }
7940 7941
7941 if (vmcs12->guest_activity_state != GUEST_ACTIVITY_ACTIVE) { 7942 if (vmcs12->guest_activity_state != GUEST_ACTIVITY_ACTIVE &&
7943 vmcs12->guest_activity_state != GUEST_ACTIVITY_HLT) {
7942 nested_vmx_failValid(vcpu, VMXERR_ENTRY_INVALID_CONTROL_FIELD); 7944 nested_vmx_failValid(vcpu, VMXERR_ENTRY_INVALID_CONTROL_FIELD);
7943 return 1; 7945 return 1;
7944 } 7946 }
@@ -8067,6 +8069,9 @@ static int nested_vmx_run(struct kvm_vcpu *vcpu, bool launch)
8067 8069
8068 prepare_vmcs02(vcpu, vmcs12); 8070 prepare_vmcs02(vcpu, vmcs12);
8069 8071
8072 if (vmcs12->guest_activity_state == GUEST_ACTIVITY_HLT)
8073 return kvm_emulate_halt(vcpu);
8074
8070 /* 8075 /*
8071 * Note no nested_vmx_succeed or nested_vmx_fail here. At this point 8076 * Note no nested_vmx_succeed or nested_vmx_fail here. At this point
8072 * we are no longer running L1, and VMLAUNCH/VMRESUME has not yet 8077 * we are no longer running L1, and VMLAUNCH/VMRESUME has not yet