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 19:03:03 +0200 Message-ID: <20170621170302.GB27032@potion> References: <20170621133741.25627-1-lprosek@redhat.com> <20170621165501.GA27032@potion> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Cc: kvm@vger.kernel.org To: Ladi Prosek Return-path: Received: from mx1.redhat.com ([209.132.183.28]:36502 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751795AbdFURDG (ORCPT ); Wed, 21 Jun 2017 13:03:06 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C1B7EBBF48 for ; Wed, 21 Jun 2017 17:03:05 +0000 (UTC) Content-Disposition: inline In-Reply-To: <20170621165501.GA27032@potion> Sender: kvm-owner@vger.kernel.org List-ID: 2017-06-21 18:55+0200, Radim Krčmář: > 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 && (...); Nope, the ret has to be checked afterwards ... better look at handle_io() in vmx.c. :)