From patchwork Fri Sep 18 13:00:32 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 48529 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 n8ID0gJp022742 for ; Fri, 18 Sep 2009 13:00:43 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755068AbZIRNAd (ORCPT ); Fri, 18 Sep 2009 09:00:33 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755854AbZIRNAc (ORCPT ); Fri, 18 Sep 2009 09:00:32 -0400 Received: from cantor.suse.de ([195.135.220.2]:55661 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753537AbZIRNAa (ORCPT ); Fri, 18 Sep 2009 09:00:30 -0400 Received: from relay2.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 5C2A38FEA2 for ; Fri, 18 Sep 2009 15:00:33 +0200 (CEST) From: Alexander Graf To: kvm@vger.kernel.org Subject: [PATCH 5/5] Notify nested hypervisor of lost event injections Date: Fri, 18 Sep 2009 15:00:32 +0200 Message-Id: <1253278832-31803-6-git-send-email-agraf@suse.de> X-Mailer: git-send-email 1.6.0.2 In-Reply-To: <1253278832-31803-5-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> <1253278832-31803-3-git-send-email-agraf@suse.de> <1253278832-31803-4-git-send-email-agraf@suse.de> <1253278832-31803-5-git-send-email-agraf@suse.de> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Normally when event_inj is valid the host CPU would write the contents to exit_int_info, so the hypervisor knows that the event wasn't injected. We failed to do so so far, so let's model closer to the CPU. Signed-off-by: Alexander Graf Acked-by: Joerg Roedel --- arch/x86/kvm/svm.c | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-) diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 12ec8ee..75e3d75 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -1643,6 +1643,22 @@ static int nested_svm_vmexit(struct vcpu_svm *svm) nested_vmcb->control.exit_info_2 = vmcb->control.exit_info_2; nested_vmcb->control.exit_int_info = vmcb->control.exit_int_info; nested_vmcb->control.exit_int_info_err = vmcb->control.exit_int_info_err; + + /* + * If we emulate a VMRUN/#VMEXIT in the same host #vmexit cycle we have + * to make sure that we do not lose injected events. So check event_inj + * here and copy it to exit_int_info if it is valid. + * exit_int_info and event_inj can't be both valid because the below + * case only happens on a VMRUN instruction intercept which has not + * valid exit_int_info set. + */ + if (vmcb->control.event_inj & SVM_EVTINJ_VALID) { + struct vmcb_control_area *nc = &nested_vmcb->control; + + nc->exit_int_info = vmcb->control.event_inj; + nc->exit_int_info_err = vmcb->control.event_inj_err; + } + nested_vmcb->control.tlb_ctl = 0; nested_vmcb->control.event_inj = 0; nested_vmcb->control.event_inj_err = 0;