From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753242AbcBZLmo (ORCPT ); Fri, 26 Feb 2016 06:42:44 -0500 Received: from mga09.intel.com ([134.134.136.24]:3285 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752267AbcBZLmm (ORCPT ); Fri, 26 Feb 2016 06:42:42 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,498,1449561600"; d="scan'208";a="753701359" Subject: Re: [PATCH] KVM: x86: fix missed hardware breakpoints To: Nadav Amit References: <1455879402-23009-1-git-send-email-pbonzini@redhat.com> <56D02C01.2040400@linux.intel.com> <6DD9380A-1EF7-4226-9405-017D17859472@gmail.com> Cc: Paolo Bonzini , Linux Kernel Mailing List , kvm , oleg@redhat.com, Nadav Amit , avagin@gmail.com, stable@vger.kernel.org From: Xiao Guangrong Message-ID: <56D03A2C.9080008@linux.intel.com> Date: Fri, 26 Feb 2016 19:42:36 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: <6DD9380A-1EF7-4226-9405-017D17859472@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/26/2016 07:28 PM, Nadav Amit wrote: > Xiao Guangrong wrote: > >> On 02/19/2016 06:56 PM, Paolo Bonzini wrote: >>> Sometimes when setting a breakpoint a process doesn't stop on it. >>> This is because the debug registers are not loaded correctly on >>> VCPU load. >>> >>> >>> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c >>> index 4244c2baf57d..f4891f2ece23 100644 >>> --- a/arch/x86/kvm/x86.c >>> +++ b/arch/x86/kvm/x86.c >>> @@ -2752,6 +2752,7 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu) >>> } >>> >>> kvm_make_request(KVM_REQ_STEAL_UPDATE, vcpu); >>> + vcpu->arch.switch_db_regs |= KVM_DEBUGREG_RELOAD; >> >> Er, i do not understand how it works. The BP is enabled in this test case so >> the debug registers are always reloaded before entering guest as >> KVM_DEBUGREG_BP_ENABLED bit is always set on switch_db_regs. What did i miss? > > Note that KVM_DEBUGREG_BP_ENABLED does not have to be set, since > kvm_update_dr7() is not called once the guest has KVM_DEBUGREG_WONT_EXIT. Ah, yes. So that we will enter guest without reloading debug registers under this case. Is it safe? What about if gdb/perf attached to QEMU and reset the debug0-3 (in this case, the vcpu is interrupted by IPI and it is not rescheduled)?