From patchwork Mon May 4 15:55:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 11526613 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 42A131392 for ; Mon, 4 May 2020 15:56:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 21DB620721 for ; Mon, 4 May 2020 15:56:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="GMd86aVf" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728655AbgEDP4T (ORCPT ); Mon, 4 May 2020 11:56:19 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:59925 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728873AbgEDP4E (ORCPT ); Mon, 4 May 2020 11:56:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588607763; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:in-reply-to:in-reply-to:references:references; bh=qfjHToR8uqa7tXot0UhNc4RMRZnM9s7plHAoZTYaT2A=; b=GMd86aVfAYaKFYmC5GC1Z1V9OnMKAvix+N7rIvpeRwiTFE0yc13w6lxr7MLqhpPfHhpzv4 YqHoyJayxUKH0zheStNVYMbpkd+4Rueg8tCYiuUVI4eHF82Q9Kk3rldjE6Z/eLxx4QuPF0 biyobl6OfDRK8hiLGtjQBrcT/Yg03cI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-169-U8e_kOqjMra00k7xWgOnUw-1; Mon, 04 May 2020 11:56:01 -0400 X-MC-Unique: U8e_kOqjMra00k7xWgOnUw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5321D8014D5; Mon, 4 May 2020 15:56:00 +0000 (UTC) Received: from virtlab511.virt.lab.eng.bos.redhat.com (virtlab511.virt.lab.eng.bos.redhat.com [10.19.152.198]) by smtp.corp.redhat.com (Postfix) with ESMTP id D88B857990; Mon, 4 May 2020 15:55:59 +0000 (UTC) From: Paolo Bonzini To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Sean Christopherson Subject: [PATCH 2/3] KVM: SVM: keep DR6 synchronized with vcpu->arch.dr6 Date: Mon, 4 May 2020 11:55:57 -0400 Message-Id: <20200504155558.401468-3-pbonzini@redhat.com> In-Reply-To: <20200504155558.401468-1-pbonzini@redhat.com> References: <20200504155558.401468-1-pbonzini@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Ensure that the current value of DR6 is always available in vcpu->arch.dr6, so that the get_dr6 callback can just access vcpu->arch.dr6 and becomes redundant. Signed-off-by: Paolo Bonzini --- arch/x86/kvm/svm/svm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index dbcf4198a9fe..6b65c75b6816 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -1654,7 +1654,7 @@ static void new_asid(struct vcpu_svm *svm, struct svm_cpu_data *sd) static u64 svm_get_dr6(struct kvm_vcpu *vcpu) { - return to_svm(vcpu)->vmcb->save.dr6; + return vcpu->arch.dr6; } static void svm_set_dr6(struct kvm_vcpu *vcpu, unsigned long value) @@ -1673,7 +1673,7 @@ static void svm_sync_dirty_debug_regs(struct kvm_vcpu *vcpu) get_debugreg(vcpu->arch.db[1], 1); get_debugreg(vcpu->arch.db[2], 2); get_debugreg(vcpu->arch.db[3], 3); - vcpu->arch.dr6 = svm_get_dr6(vcpu); + vcpu->arch.dr6 = svm->vmcb->save.dr6; vcpu->arch.dr7 = svm->vmcb->save.dr7; vcpu->arch.switch_db_regs &= ~KVM_DEBUGREG_WONT_EXIT; @@ -1719,6 +1719,7 @@ static int db_interception(struct vcpu_svm *svm) if (!(svm->vcpu.guest_debug & (KVM_GUESTDBG_SINGLESTEP | KVM_GUESTDBG_USE_HW_BP)) && !svm->nmi_singlestep) { + vcpu->arch.dr6 = svm->vmcb->save.dr6; kvm_queue_exception(&svm->vcpu, DB_VECTOR); return 1; }