From patchwork Fri Sep 4 12:51:20 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 45682 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n84Cs0lo005081 for ; Fri, 4 Sep 2009 12:54:01 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756835AbZIDMxy (ORCPT ); Fri, 4 Sep 2009 08:53:54 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756831AbZIDMxy (ORCPT ); Fri, 4 Sep 2009 08:53:54 -0400 Received: from thoth.sbs.de ([192.35.17.2]:17672 "EHLO thoth.sbs.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756833AbZIDMxw (ORCPT ); Fri, 4 Sep 2009 08:53:52 -0400 Received: from mail1.siemens.de (localhost [127.0.0.1]) by thoth.sbs.de (8.12.11.20060308/8.12.11) with ESMTP id n84CrdvG005035; Fri, 4 Sep 2009 14:53:39 +0200 Received: from [139.25.109.167] (mchn012c.mchp.siemens.de [139.25.109.167] (may be forged)) by mail1.siemens.de (8.12.11.20060308/8.12.11) with ESMTP id n84CrdZK002569; Fri, 4 Sep 2009 14:53:39 +0200 From: Jan Kiszka Subject: [PATCH 4/6] KVM: VMX: Fix emulation of DR4 and DR5 To: Avi Kivity , Marcelo Tosatti Cc: kvm@vger.kernel.org, Jan Kiszka Date: Fri, 04 Sep 2009 14:51:20 +0200 Message-ID: <20090904125119.18939.29087.stgit@mchn012c.ww002.siemens.net> In-Reply-To: <20090904125119.18939.89733.stgit@mchn012c.ww002.siemens.net> References: <20090904125119.18939.89733.stgit@mchn012c.ww002.siemens.net> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Make sure DR4 and DR5 are aliased to DR6 and DR7, respectively, if CR4.DE is not set. Signed-off-by: Jan Kiszka --- arch/x86/kvm/vmx.c | 33 ++++++++++++++++++++++++++------- 1 files changed, 26 insertions(+), 7 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 7012680..d34aea5 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -2963,14 +2963,24 @@ static int handle_dr(struct kvm_vcpu *vcpu) case 0 ... 3: val = vcpu->arch.db[dr]; break; + case 4: + if (vcpu->arch.cr4 & X86_CR4_DE) { + kvm_queue_exception(vcpu, UD_VECTOR); + goto skip_instr; + } + /* fall through */ case 6: val = vcpu->arch.dr6; break; - case 7: + case 5: + if (vcpu->arch.cr4 & X86_CR4_DE) { + kvm_queue_exception(vcpu, UD_VECTOR); + goto skip_instr; + } + /* fall through */ + default: /* 7 */ val = vcpu->arch.dr7; break; - default: - val = 0; } kvm_register_write(vcpu, reg, val); } else { @@ -2981,10 +2991,12 @@ static int handle_dr(struct kvm_vcpu *vcpu) if (!(vcpu->guest_debug & KVM_GUESTDBG_USE_HW_BP)) vcpu->arch.eff_db[dr] = val; break; - case 4 ... 5: - if (vcpu->arch.cr4 & X86_CR4_DE) + case 4: + if (vcpu->arch.cr4 & X86_CR4_DE) { kvm_queue_exception(vcpu, UD_VECTOR); - break; + break; + } + /* fall through */ case 6: if (val & 0xffffffff00000000ULL) { kvm_queue_exception(vcpu, GP_VECTOR); @@ -2992,7 +3004,13 @@ static int handle_dr(struct kvm_vcpu *vcpu) } vcpu->arch.dr6 = (val & DR6_VOLATILE) | DR6_FIXED_1; break; - case 7: + case 5: + if (vcpu->arch.cr4 & X86_CR4_DE) { + kvm_queue_exception(vcpu, UD_VECTOR); + break; + } + /* fall through */ + default: /* 7 */ if (val & 0xffffffff00000000ULL) { kvm_queue_exception(vcpu, GP_VECTOR); break; @@ -3006,6 +3024,7 @@ static int handle_dr(struct kvm_vcpu *vcpu) break; } } +skip_instr: skip_emulated_instruction(vcpu); return 1; }