From patchwork Fri Sep 18 13:00:29 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 48528 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n8ID0f0m022735 for ; Fri, 18 Sep 2009 13:00:41 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755990AbZIRNAe (ORCPT ); Fri, 18 Sep 2009 09:00:34 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751540AbZIRNAe (ORCPT ); Fri, 18 Sep 2009 09:00:34 -0400 Received: from cantor.suse.de ([195.135.220.2]:55660 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753377AbZIRNAa (ORCPT ); Fri, 18 Sep 2009 09:00:30 -0400 Received: from relay1.suse.de (relay-ext.suse.de [195.135.221.8]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.suse.de (Postfix) with ESMTP id 4B4598D893 for ; Fri, 18 Sep 2009 15:00:33 +0200 (CEST) From: Alexander Graf To: kvm@vger.kernel.org Subject: [PATCH 2/5] Don't call svm_complete_interrupts for nested guests Date: Fri, 18 Sep 2009 15:00:29 +0200 Message-Id: <1253278832-31803-3-git-send-email-agraf@suse.de> X-Mailer: git-send-email 1.6.0.2 In-Reply-To: <1253278832-31803-2-git-send-email-agraf@suse.de> References: <1253278832-31803-1-git-send-email-agraf@suse.de> <1253278832-31803-2-git-send-email-agraf@suse.de> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org SVM has some cleanup code, that tries to reinject interrupts and exceptions when the guest didn't manage to deal with them yet. It basically transfers them to KVM internal state. Unfortunately, the internal state is reserved for the L1 guest state, so we shouldn't try to go through that logic when running a nested guest. When doing something the host KVM can handle, let's just reinject the event into the L2 guest, because we didn't touch its state anyways. Signed-off-by: Alexander Graf --- arch/x86/kvm/svm.c | 18 ++++++++++++++---- 1 files changed, 14 insertions(+), 4 deletions(-) diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index f12a669..61efd13 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -2349,7 +2349,10 @@ static int handle_exit(struct kvm_vcpu *vcpu) trace_kvm_exit(exit_code, svm->vmcb->save.rip); if (is_nested(svm)) { + struct vmcb_control_area *control = &svm->vmcb->control; int vmexit; + int type; + int vec; nsvm_printk("nested handle_exit: 0x%x | 0x%lx | 0x%lx | 0x%lx\n", exit_code, svm->vmcb->control.exit_info_1, @@ -2362,9 +2365,18 @@ static int handle_exit(struct kvm_vcpu *vcpu) if (vmexit == NESTED_EXIT_DONE) return 1; - } - svm_complete_interrupts(svm); + type = control->exit_int_info & SVM_EXITINTINFO_TYPE_MASK; + vec = control->exit_int_info & SVM_EXITINTINFO_VEC_MASK; + if ((type == SVM_EXITINTINFO_TYPE_INTR) || + ((type == SVM_EXITINTINFO_TYPE_EXEPT) && !kvm_exception_is_soft(vec))) { + control->event_inj = control->exit_int_info; + control->event_inj_err = control->exit_int_info_err; + } + } else { + /* Don't interpret exit_info for nested guests */ + svm_complete_interrupts(svm); + } if (npt_enabled) { int mmu_reload = 0; @@ -2602,8 +2614,6 @@ static void svm_complete_interrupts(struct vcpu_svm *svm) case SVM_EXITINTINFO_TYPE_EXEPT: /* In case of software exception do not reinject an exception vector, but re-execute and instruction instead */ - if (is_nested(svm)) - break; if (kvm_exception_is_soft(vector)) break; if (exitintinfo & SVM_EXITINTINFO_VALID_ERR) {