From patchwork Thu Dec 7 17:06:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 10100377 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E8FDC60325 for ; Thu, 7 Dec 2017 17:21:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CF52622701 for ; Thu, 7 Dec 2017 17:21:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C3C1B28511; Thu, 7 Dec 2017 17:21:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 53F7F22701 for ; Thu, 7 Dec 2017 17:21:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=cPTGWHiM54vku+zM6REfG3apgVrlZMuZQHdnC9MjTEw=; b=j5jhi3hGmrQf0+yEN+sgn6oXE8 EF+1i+j5vmEevG0Olj3bZe/a0mpyXIr68m+9dDrZpG6gmL5UrxK655IFTRmjmqUMvRMC0l3EsoyS5 x6IvcHKLrJtVkKJOjyMVS7bXJVR3e0Z3RbM8Nwc9+E5H34Ddp8kBCkHoLfN2kVgFevKYrsAyA7YJ5 36DciIEVQ2+PwGckGTqcFoXAraV1xN0neatLU46LnjMqQO/BUym8eKmMHOtH1aytAhTV3YWXwF8sK DH+m9tSm55Kf6MOl6q/mHNU49/7MMGerkQYFycDfqg5AZ4rJPQqwS9Xp0tTXS22qc+kbk5DeOl3NI 0VeoN1Pw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eMzrB-00024a-EB; Thu, 07 Dec 2017 17:21:09 +0000 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eMzdf-0002qF-0r for linux-arm-kernel@lists.infradead.org; Thu, 07 Dec 2017 17:07:21 +0000 Received: by mail-wm0-x244.google.com with SMTP id y82so1447536wmg.1 for ; Thu, 07 Dec 2017 09:06:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4engDh8aHybKiNwG6FjkZXN0lNjoW/ndJ63XHJmsSvc=; b=eFZvmRXwIn0UAr2kWwsD9IpSdVVSlpFGu9BkZG44u2FPIp44SaOQ3drEtoqWQS7yh5 EDwPzYPD5EuwzGqPT6jY+bYOcJYmHHoLE7wdCL+DGcAC3/CWpIeQM6uBijQ3bixiCxQ2 lRBW+SouhbCW/5B69UNnyHVG/5Ly3NuoDxijc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=4engDh8aHybKiNwG6FjkZXN0lNjoW/ndJ63XHJmsSvc=; b=k3Y8FNtAhDQorUIJtcaYbwNMygToSsSTb9dhJOTi12aTFV95YGLwZwuXny84UWP7pp Wp+DSTPbSONrHE9IoYq+U1yvlp7kosR2EuklfsyUez7v39wSD2yONwzP2VbzgwtPHMUA 9SGaaTo2lis/65Yv6MgnV3Wp0Jyn7nIWwW1nJYk0ac0FHzZxnYK8lpqL1xs0KEjloaN6 0LU1Jti1/6NdUnsUQ1/qohLWS6ixCq/Qh6i6j7QTVv0hAn3kHsGTvBfgdo/DPJLNS0ne o35vBGmDGuOL/Y08c+QtXKGg/7DbhMBKW8af2acD6qkVscm3onY5i7AtdXrDBj//QyYd p2VQ== X-Gm-Message-State: AJaThX6zNg6Vvt7up3pkXM4x4bdFsPpVo5jLfBqsrREvbE8HAtVxXRgI HsFZ31sGD3US+R/8IQ5smPlDHA== X-Google-Smtp-Source: AGs4zMZJABO+zheFHsyLTIf1ccyOnLXEwGMAdD3KDY1K5smB4ebJ/H5tDfYatEbdKzxRpsEx4ubBfw== X-Received: by 10.80.161.37 with SMTP id 34mr31525388edj.15.1512666411370; Thu, 07 Dec 2017 09:06:51 -0800 (PST) Received: from localhost.localdomain (x50d2404e.cust.hiper.dk. [80.210.64.78]) by smtp.gmail.com with ESMTPSA id a16sm2868270edd.19.2017.12.07.09.06.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 07 Dec 2017 09:06:50 -0800 (PST) From: Christoffer Dall To: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 07/36] KVM: arm64: Move debug dirty flag calculation out of world switch Date: Thu, 7 Dec 2017 18:06:01 +0100 Message-Id: <20171207170630.592-8-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171207170630.592-1-christoffer.dall@linaro.org> References: <20171207170630.592-1-christoffer.dall@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171207_090711_571951_5BC69F7F X-CRM114-Status: GOOD ( 11.71 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marc Zyngier , Andrew Jones , Christoffer Dall , Shih-Wei Li , kvm@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP There is no need to figure out inside the world-switch if we should save/restore the debug registers or not, we can might as well do that in the higher level debug setup code, making it easier to optimize down the line. Signed-off-by: Christoffer Dall Reviewed-by: Marc Zyngier --- arch/arm64/kvm/debug.c | 5 +++++ arch/arm64/kvm/hyp/debug-sr.c | 6 ------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/arch/arm64/kvm/debug.c b/arch/arm64/kvm/debug.c index fa63b28c65e0..feedb877cff8 100644 --- a/arch/arm64/kvm/debug.c +++ b/arch/arm64/kvm/debug.c @@ -193,6 +193,11 @@ void kvm_arm_setup_debug(struct kvm_vcpu *vcpu) if (trap_debug) vcpu->arch.mdcr_el2 |= MDCR_EL2_TDA; + /* If KDE or MDE are set, perform a full save/restore cycle. */ + if ((vcpu_sys_reg(vcpu, MDSCR_EL1) & DBG_MDSCR_KDE) || + (vcpu_sys_reg(vcpu, MDSCR_EL1) & DBG_MDSCR_MDE)) + vcpu->arch.debug_flags |= KVM_ARM64_DEBUG_DIRTY; + trace_kvm_arm_set_dreg32("MDCR_EL2", vcpu->arch.mdcr_el2); trace_kvm_arm_set_dreg32("MDSCR_EL1", vcpu_sys_reg(vcpu, MDSCR_EL1)); } diff --git a/arch/arm64/kvm/hyp/debug-sr.c b/arch/arm64/kvm/hyp/debug-sr.c index 321c9c05dd9e..406829b6a43e 100644 --- a/arch/arm64/kvm/hyp/debug-sr.c +++ b/arch/arm64/kvm/hyp/debug-sr.c @@ -162,12 +162,6 @@ void __hyp_text __debug_restore_state(struct kvm_vcpu *vcpu, void __hyp_text __debug_cond_save_host_state(struct kvm_vcpu *vcpu) { - /* If any of KDE, MDE or KVM_ARM64_DEBUG_DIRTY is set, perform - * a full save/restore cycle. */ - if ((vcpu->arch.ctxt.sys_regs[MDSCR_EL1] & DBG_MDSCR_KDE) || - (vcpu->arch.ctxt.sys_regs[MDSCR_EL1] & DBG_MDSCR_MDE)) - vcpu->arch.debug_flags |= KVM_ARM64_DEBUG_DIRTY; - __debug_save_state(vcpu, &vcpu->arch.host_debug_state.regs, kern_hyp_va(vcpu->arch.host_cpu_context)); __debug_save_spe()(&vcpu->arch.host_debug_state.pmscr_el1);