From mboxrd@z Thu Jan 1 00:00:00 1970 From: Radim =?utf-8?B?S3LEjW3DocWZ?= Subject: Re: [PATCH] KVM: SVM: handle singlestep exception when skipping emulated instructions Date: Wed, 21 Jun 2017 18:55:01 +0200 Message-ID: <20170621165501.GA27032@potion> References: <20170621133741.25627-1-lprosek@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvm@vger.kernel.org To: Ladi Prosek Return-path: Received: from mx1.redhat.com ([209.132.183.28]:36972 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751116AbdFUQzF (ORCPT ); Wed, 21 Jun 2017 12:55:05 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7D47561D37 for ; Wed, 21 Jun 2017 16:55:04 +0000 (UTC) Content-Disposition: inline In-Reply-To: <20170621133741.25627-1-lprosek@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: 2017-06-21 15:37+0200, Ladi Prosek: > kvm_skip_emulated_instruction handles the singlestep debug exception > which is something we almost always want. This commit (specifically > the change in rdmsr_interception) makes the debug.flat KVM unit test > pass on AMD. kvm_skip_emulated_instruction() also has a return value, which says whether the debug exception was requested by the userspace or by the guest (userspace has priority). This patch fixes the guest debugging, but userspace still won't receive its events. I think it would be better to fix both at once, > Signed-off-by: Ladi Prosek > --- > diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c > @@ -2278,7 +2278,7 @@ static int io_interception(struct vcpu_svm *svm) > port = io_info >> 16; > size = (io_info & SVM_IOIO_SIZE_MASK) >> SVM_IOIO_SIZE_SHIFT; > svm->next_rip = svm->vmcb->control.exit_info_2; > - skip_emulated_instruction(&svm->vcpu); > + kvm_skip_emulated_instruction(&svm->vcpu); > > return in ? kvm_fast_pio_in(vcpu, size, port) > : kvm_fast_pio_out(vcpu, size, port); i.e. ret = kvm_skip_emulated_instruction(&svm->vcpu); return ret && (...); > @@ -3063,7 +3063,7 @@ static int vmload_interception(struct vcpu_svm *svm) > return 1; > > svm->next_rip = kvm_rip_read(&svm->vcpu) + 3; > - skip_emulated_instruction(&svm->vcpu); > + kvm_skip_emulated_instruction(&svm->vcpu); ret = kvm_skip_emulated_instruction(&svm->vcpu); > > nested_svm_vmloadsave(nested_vmcb, svm->vmcb); > nested_svm_unmap(page); return ret; and so on ... thanks.