From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kiszka Subject: Re: [PATCH] KVM: move DR register access handling into generic code. Date: Mon, 12 Apr 2010 18:09:50 +0200 Message-ID: <4BC345CE.2060301@siemens.com> References: <20100412122712.GC23554@redhat.com> <4BC3341E.2050108@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 7bit Cc: Gleb Natapov , "kvm@vger.kernel.org" , "mtosatti@redhat.com" To: Avi Kivity Return-path: Received: from thoth.sbs.de ([192.35.17.2]:20063 "EHLO thoth.sbs.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752598Ab0DLQKH (ORCPT ); Mon, 12 Apr 2010 12:10:07 -0400 In-Reply-To: <4BC3341E.2050108@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: Avi Kivity wrote: > On 04/12/2010 03:27 PM, Gleb Natapov wrote: >> Currently both SVM and VMX have their own DR handling code. Move it to >> x86.c. >> >> > > The standard process is to make them identical first and finally merge > identical code, but I guess we can skip it in this case (Jan?) Looks OK, I would just... > +int kvm_set_dr(struct kvm_vcpu *vcpu, int dr, unsigned long val) > +{ > + switch (dr) { > + case 0 ... 3: > + vcpu->arch.db[dr] = val; > + if (!(vcpu->guest_debug & KVM_GUESTDBG_USE_HW_BP)) > + vcpu->arch.eff_db[dr] = val; > + break; > + case 4: > + if (kvm_read_cr4_bits(vcpu, X86_CR4_DE)) { > + kvm_queue_exception(vcpu, UD_VECTOR); > + return 1; > + } > + /* fall through */ > + case 6: > + if (val & 0xffffffff00000000ULL) { > + kvm_inject_gp(vcpu, 0); > + return -1; ...either return 1 or -1 on failure. Jan -- Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux