From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH 2/2] KVM: x86: Preserve guest single-stepping on register Date: Mon, 05 Oct 2009 12:44:10 +0200 Message-ID: <4AC9CDFA.1000501@redhat.com> References: <4AC67D94.6090406@web.de> <4AC67F45.3010808@web.de> <4AC8B63B.8060602@redhat.com> <4AC8F145.4000204@web.de> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Marcelo Tosatti , kvm-devel To: Jan Kiszka Return-path: Received: from mx1.redhat.com ([209.132.183.28]:50945 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932451AbZJEKoj (ORCPT ); Mon, 5 Oct 2009 06:44:39 -0400 In-Reply-To: <4AC8F145.4000204@web.de> Sender: kvm-owner@vger.kernel.org List-ID: On 10/04/2009 09:02 PM, Jan Kiszka wrote: > > Hmmmm, good point. Mind reverting 2/2 and applying this one instead? > > Jan > > ---------> > > KVM: x86: Rework guest single-step flag injection and filtering > > Push TF and RF injection and filtering on guest single-stepping into the > vender get/set_rflags callbacks. This makes the whole mechanism more > robust /wrt user space IOTCTL order and instruction emulations. > > Signed-off-by: Jan Kiszka > --- > > arch/x86/kvm/svm.c | 8 +++++++- > arch/x86/kvm/vmx.c | 4 ++++ > arch/x86/kvm/x86.c | 24 +++++++++--------------- > 3 files changed, 20 insertions(+), 16 deletions(-) > > diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c > index 279a2ae..407e1a7 100644 > --- a/arch/x86/kvm/svm.c > +++ b/arch/x86/kvm/svm.c > @@ -797,11 +797,17 @@ static void svm_vcpu_put(struct kvm_vcpu *vcpu) > > static unsigned long svm_get_rflags(struct kvm_vcpu *vcpu) > { > - return to_svm(vcpu)->vmcb->save.rflags; > + unsigned long rflags = to_svm(vcpu)->vmcb->save.rflags; > + > + if (vcpu->guest_debug& KVM_GUESTDBG_SINGLESTEP) > + rflags&= ~(unsigned long)(X86_EFLAGS_TF | X86_EFLAGS_RF); > + return rflags; > } > > static void svm_set_rflags(struct kvm_vcpu *vcpu, unsigned long rflags) > { > + if (vcpu->guest_debug& KVM_GUESTDBG_SINGLESTEP) > + rflags |= X86_EFLAGS_TF | X86_EFLAGS_RF; > to_svm(vcpu)->vmcb->save.rflags = rflags; > } > This code is duplicated in vmx. How about kvm_[gs]et_rflags to contain it? -- error compiling committee.c: too many arguments to function