From patchwork Wed Jun 2 06:49:14 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 54343 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 538EEB7D51 for ; Wed, 2 Jun 2010 16:50:31 +1000 (EST) Received: from localhost ([127.0.0.1]:47179 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OJhmW-00009U-IS for incoming@patchwork.ozlabs.org; Wed, 02 Jun 2010 02:50:28 -0400 Received: from [140.186.70.92] (port=56935 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OJhlY-000083-PO for qemu-devel@nongnu.org; Wed, 02 Jun 2010 02:49:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OJhlU-0007Hq-9j for qemu-devel@nongnu.org; Wed, 02 Jun 2010 02:49:28 -0400 Received: from fmmailgate01.web.de ([217.72.192.221]:44610) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OJhlT-0007Hc-Rx for qemu-devel@nongnu.org; Wed, 02 Jun 2010 02:49:24 -0400 Received: from smtp06.web.de ( [172.20.5.172]) by fmmailgate01.web.de (Postfix) with ESMTP id 6D0CE15D4024A; Wed, 2 Jun 2010 08:49:21 +0200 (CEST) Received: from [88.65.44.253] (helo=[192.168.1.10]) by smtp06.web.de with asmtp (TLSv1:AES256-SHA:256) (WEB.DE 4.110 #4) id 1OJhlR-0002Fb-00; Wed, 02 Jun 2010 08:49:21 +0200 Message-ID: <4C05FEEA.20909@web.de> Date: Wed, 02 Jun 2010 08:49:14 +0200 From: Jan Kiszka User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 MIME-Version: 1.0 To: Erik van der Kouwe References: <4C05479E.3010705@siemens.com> <4C056F16.8000906@cs.vu.nl> In-Reply-To: <4C056F16.8000906@cs.vu.nl> X-Enigmail-Version: 0.95.7 X-Sender: jan.kiszka@web.de X-Provags-ID: V01U2FsdGVkX1+QupYwXTkB4/oRnF5sfa++/dwUmWE+bpek4BLm 72YmSJpJAhUuCD4/PVAPS8MrXH0U+GaYaN9K08fmPhoO8ZZvQ6 GCSULrrtk= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 Cc: Joerg Roedel , qemu-devel , Gleb Natapov Subject: [Qemu-devel] [PATCH v2] x86: svm: Always clear event_inj on vmexit X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Erik van der Kouwe wrote: > Hi, > >> We currently only clear SVM_EVTINJ_VALID after successful interrupt >> delivery. This apparently does not match real hardware which clears the >> whole event_inj field on every vmexit, including unsuccessful interrupt >> delivery. > > Thanks for the patch. It is a bit hard for me to test right now as I > messed up my test setup, but I will do so ASAP and let you know. > > However, I'm worried that this patch may introduce a new problem (I may > be mistaken though). There is still this code to load the exit interrupt > info: > > stl_phys(env->vm_vmcb + offsetof(struct vmcb, > control.exit_int_info_err), > ldl_phys(env->vm_vmcb + offsetof(struct vmcb, > control.event_inj_err))); > > Now that event_inj is no longer loaded, won't this mean that > exit_int_info and exit_int_info_err also won't be loaded? Sorry, can't follow this ATM. But maybe you mean this: there is indeed a problem with removing the clearance of event_inj.invalid as it may be later on transferred into exit_int_info. And if we succeed with injecting the event, that field must not remaind valid. OK, here is v2: -------> From: Jan Kiszka We currently only clear SVM_EVTINJ_VALID after successful interrupt delivery. This apparently does not match real hardware which clears the whole event_inj field on every vmexit, including unsuccessful interrupt delivery. Reported-by: Erik van der Kouwe Signed-off-by: Jan Kiszka --- target-i386/op_helper.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/target-i386/op_helper.c b/target-i386/op_helper.c index dcbdfe7..52e8910 100644 --- a/target-i386/op_helper.c +++ b/target-i386/op_helper.c @@ -5388,6 +5388,7 @@ void helper_vmexit(uint32_t exit_code, uint64_t exit_info_1) ldl_phys(env->vm_vmcb + offsetof(struct vmcb, control.event_inj))); stl_phys(env->vm_vmcb + offsetof(struct vmcb, control.exit_int_info_err), ldl_phys(env->vm_vmcb + offsetof(struct vmcb, control.event_inj_err))); + stl_phys(env->vm_vmcb + offsetof(struct vmcb, control.event_inj), 0); env->hflags2 &= ~HF2_GIF_MASK; /* FIXME: Resets the current ASID register to zero (host ASID). */