aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/svm.c
diff options
context:
space:
mode:
authorJoerg Roedel <joerg.roedel@amd.com>2010-04-22 06:33:13 -0400
committerAvi Kivity <avi@redhat.com>2010-05-17 05:19:26 -0400
commitce7ddec4bbbc08f0c2901cc103773aed864b09fd (patch)
treed1cc4b3d0cd472ff30c3c796e6537dd41ec4e268 /arch/x86/kvm/svm.c
parentc2c63a493924e09a1984d1374a0e60dfd54fc0b0 (diff)
KVM: x86: Allow marking an exception as reinjected
This patch adds logic to kvm/x86 which allows to mark an injected exception as reinjected. This allows to remove an ugly hack from svm_complete_interrupts that prevented exceptions from being reinjected at all in the nested case. The hack was necessary because an reinjected exception into the nested guest could cause a nested vmexit emulation. But reinjected exceptions must not intercept. The downside of the hack is that a exception that in injected could get lost. This patch fixes the problem and puts the code for it into generic x86 files because. Nested-VMX will likely have the same problem and could reuse the code. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/x86/kvm/svm.c')
-rw-r--r--arch/x86/kvm/svm.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 65fc11438b75..30e49fe7f8c0 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -338,7 +338,8 @@ static void skip_emulated_instruction(struct kvm_vcpu *vcpu)
338} 338}
339 339
340static void svm_queue_exception(struct kvm_vcpu *vcpu, unsigned nr, 340static void svm_queue_exception(struct kvm_vcpu *vcpu, unsigned nr,
341 bool has_error_code, u32 error_code) 341 bool has_error_code, u32 error_code,
342 bool reinject)
342{ 343{
343 struct vcpu_svm *svm = to_svm(vcpu); 344 struct vcpu_svm *svm = to_svm(vcpu);
344 345
@@ -346,7 +347,8 @@ static void svm_queue_exception(struct kvm_vcpu *vcpu, unsigned nr,
346 * If we are within a nested VM we'd better #VMEXIT and let the guest 347 * If we are within a nested VM we'd better #VMEXIT and let the guest
347 * handle the exception 348 * handle the exception
348 */ 349 */
349 if (nested_svm_check_exception(svm, nr, has_error_code, error_code)) 350 if (!reinject &&
351 nested_svm_check_exception(svm, nr, has_error_code, error_code))
350 return; 352 return;
351 353
352 if (nr == BP_VECTOR && !svm_has(SVM_FEATURE_NRIP)) { 354 if (nr == BP_VECTOR && !svm_has(SVM_FEATURE_NRIP)) {
@@ -2918,8 +2920,6 @@ static void svm_complete_interrupts(struct vcpu_svm *svm)
2918 svm->vcpu.arch.nmi_injected = true; 2920 svm->vcpu.arch.nmi_injected = true;
2919 break; 2921 break;
2920 case SVM_EXITINTINFO_TYPE_EXEPT: 2922 case SVM_EXITINTINFO_TYPE_EXEPT:
2921 if (is_nested(svm))
2922 break;
2923 /* 2923 /*
2924 * In case of software exceptions, do not reinject the vector, 2924 * In case of software exceptions, do not reinject the vector,
2925 * but re-execute the instruction instead. Rewind RIP first 2925 * but re-execute the instruction instead. Rewind RIP first
@@ -2935,10 +2935,10 @@ static void svm_complete_interrupts(struct vcpu_svm *svm)
2935 } 2935 }
2936 if (exitintinfo & SVM_EXITINTINFO_VALID_ERR) { 2936 if (exitintinfo & SVM_EXITINTINFO_VALID_ERR) {
2937 u32 err = svm->vmcb->control.exit_int_info_err; 2937 u32 err = svm->vmcb->control.exit_int_info_err;
2938 kvm_queue_exception_e(&svm->vcpu, vector, err); 2938 kvm_requeue_exception_e(&svm->vcpu, vector, err);
2939 2939
2940 } else 2940 } else
2941 kvm_queue_exception(&svm->vcpu, vector); 2941 kvm_requeue_exception(&svm->vcpu, vector);
2942 break; 2942 break;
2943 case SVM_EXITINTINFO_TYPE_INTR: 2943 case SVM_EXITINTINFO_TYPE_INTR:
2944 kvm_queue_interrupt(&svm->vcpu, vector, false); 2944 kvm_queue_interrupt(&svm->vcpu, vector, false);