From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752193AbcK1R31 (ORCPT ); Mon, 28 Nov 2016 12:29:27 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58860 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751660AbcK1R3U (ORCPT ); Mon, 28 Nov 2016 12:29:20 -0500 Subject: Re: [PATCH 5/5] KVM: VMX: Handle RFLAGS.TF in skip_emulated_instruction To: Kyle Huey References: <20161128041856.11420-1-khuey@kylehuey.com> <20161128041856.11420-6-khuey@kylehuey.com> <9eff6257-0420-102d-539a-d3b8b57ba05b@redhat.com> Cc: =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , Joerg Roedel , kvm list , open list From: Paolo Bonzini Message-ID: Date: Mon, 28 Nov 2016 18:19:23 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 28 Nov 2016 17:19:28 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 28/11/2016 17:13, Kyle Huey wrote: > On Mon, Nov 28, 2016 at 3:42 AM, Paolo Bonzini wrote: >> This code is pretty much the same as kvm_vcpu_check_singlestep. Let's >> not duplicate the code and implement skip_emulated_instruction can be >> implemented in x86.c, like >> >> unsigned long rflags = kvm_x86_ops->get_rflags(vcpu); >> int r = EMULATE_DONE; >> >> /* This would be the no_trap variant */ >> kvm_x86_ops->skip_emulated_instruction(vcpu); >> kvm_vcpu_check_singlestep(vcpu, rflags, &r); >> return r == EMULATE_DONE; >> >> (because x86.c/vmx.c/svm.c are separate modules, when moving the function >> to x86.c you should rename it to kvm_skip_emulated_instruction). >> >> Paolo > > They're not exactly the same. For some reason I don't understand > kvm_vcpu_check_singlestep clears the trap flag. Perhaps that is also > a bug? The Intel manual says "The processor clears the TF flag before calling the exception handler" (17.3.1.4), so I think you should do it too. Paolo