From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40918) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xjnhx-00070g-M0 for qemu-devel@nongnu.org; Thu, 30 Oct 2014 07:16:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xjnhs-0007uk-ON for qemu-devel@nongnu.org; Thu, 30 Oct 2014 07:16:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45279) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xjnhs-0007uc-Hz for qemu-devel@nongnu.org; Thu, 30 Oct 2014 07:15:56 -0400 Message-ID: <54521DDC.8040809@redhat.com> Date: Thu, 30 Oct 2014 12:15:40 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <20141030093100.7176.716.stgit@PASHA-ISP> In-Reply-To: <20141030093100.7176.716.stgit@PASHA-ISP> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] kvmvapic: patch_instruction fix List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Pavel Dovgalyuk , qemu-devel@nongnu.org Cc: fred.konrad@greensocs.com, zealot351@gmail.com, maria.klimushenkova@ispras.ru, mark.burton@greensocs.com, batuzovk@ispras.ru On 10/30/2014 10:31 AM, Pavel Dovgalyuk wrote: > When QEMU works in icount mode cpu_restore_state function performs two actions: > restoring the program counter and updating icount to the correct value. > kvmvapic's patch_instruction function is called by cpu_report_tpr_access > function which also invokes cpu_restore_state. It results to calling > cpu_restore_state twice - in cpu_report_tpr_access and in patch_instruction. > When icount is disabled second call is safe. But when icount is enabled, > cpu_restore_state modifies instructions counter twice, which leads to incorrect > behavior. This patch removes useless cpu_restore_state call from kvmvapic. > > Signed-off-by: Pavel Dovgalyuk > --- > hw/i386/kvmvapic.c | 1 - > 1 files changed, 0 insertions(+), 1 deletions(-) > > diff --git a/hw/i386/kvmvapic.c b/hw/i386/kvmvapic.c > index f9da050..28547a7 100644 > --- a/hw/i386/kvmvapic.c > +++ b/hw/i386/kvmvapic.c > @@ -405,7 +405,6 @@ static void patch_instruction(VAPICROMState *s, X86CPU *cpu, target_ulong ip) > } > > if (!kvm_enabled()) { > - cpu_restore_state(cs, cs->mem_io_pc); > cpu_get_tb_cpu_state(env, ¤t_pc, ¤t_cs_base, > ¤t_flags); > } > Thanks, applying. Paolo