From: Joerg Roedel Subject: [PATCH 16/21] kvm/svm: handle errors in vmrun emulation path appropriatly Date: Fri, 7 Aug 2009 11:49:43 +0200 Message-ID: <1249638588-10982-17-git-send-email-joerg.roedel@amd.com> References: <1249638588-10982-1-git-send-email-joerg.roedel@amd.com> Mime-Version: 1.0 Content-Type: text/plain Cc: Alexander Graf , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Joerg Roedel To: Avi Kivity Return-path: Received: from outbound-dub.frontbridge.com ([213.199.154.16]:18838 "EHLO IE1EHSOBE001.bigfish.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755913AbZHGJuK (ORCPT ); Fri, 7 Aug 2009 05:50:10 -0400 In-Reply-To: <1249638588-10982-1-git-send-email-joerg.roedel@amd.com> Sender: kvm-owner@vger.kernel.org List-ID: If nested svm fails to load the msrpm the vmrun succeeds with the old msrpm which is not correct. This patch changes the logic to roll back to host mode in case the msrpm cannot be loaded. Signed-off-by: Joerg Roedel --- arch/x86/kvm/svm.c | 14 +++++++++++++- 1 files changed, 13 insertions(+), 1 deletions(-) diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 63d2f63..cad7582 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -1880,6 +1880,7 @@ static int vmsave_interception(struct vcpu_svm *svm, struct kvm_run *kvm_run) static int vmrun_interception(struct vcpu_svm *svm, struct kvm_run *kvm_run) { nsvm_printk("VMrun\n"); + if (nested_svm_check_permissions(svm)) return 1; @@ -1890,7 +1891,18 @@ static int vmrun_interception(struct vcpu_svm *svm, struct kvm_run *kvm_run) return 1; if (!nested_svm_vmrun_msrpm(svm)) - return 1; + goto failed; + + return 1; + +failed: + + svm->vmcb->control.exit_code = SVM_EXIT_ERR; + svm->vmcb->control.exit_code_hi = 0; + svm->vmcb->control.exit_info_1 = 0; + svm->vmcb->control.exit_info_2 = 0; + + nested_svm_vmexit(svm); return 1; } -- 1.6.3.3