From patchwork Thu Feb 15 21:03:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 10223653 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 CD0BC60467 for ; Thu, 15 Feb 2018 21:12:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B9E5129511 for ; Thu, 15 Feb 2018 21:12:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ABC3D29516; Thu, 15 Feb 2018 21:12:12 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.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 391EE29511 for ; Thu, 15 Feb 2018 21:12:11 +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=caA+YnL6M6Diq1IbRRShOySnO7rH0sZ28zIgRDBSQs8=; b=Y3H8hYLGcPi5Z9f4rAGSOuLml8 +Kic2tUYQCiN5ZEFFt0DaRoW/177iwuM7qY1zS/BM5zbyxkKd+OL3ixRFx1pNUeIZoNVCKpSjv8nG XTqd0Nr9A3hJ7BHQwkQY1SJO+IyJpEqGGBGrz8FvINctJ36PGIVLeMy8skMV87ZQCDaZZ03lydgxz p5jqItsQKLkSMw0ym/R4aCQ4rTmoJZWvaYHtwn+cjpQdLUZSZ/asSKiCls2fYnRc+X0yFEI4lw9tq bkJd1e/8YVcdEbxpQUVOtwZW6ONLfsq3EU0EmwRVheuKjLzoqGYKoHQ9dQxLejEdEFKFbg98Hg8X0 KMAcLu2A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1emQot-000841-Lb; Thu, 15 Feb 2018 21:11:55 +0000 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1emQhL-0008Fe-2M for linux-arm-kernel@lists.infradead.org; Thu, 15 Feb 2018 21:04:26 +0000 Received: by mail-wm0-x242.google.com with SMTP id z81so3260358wmb.4 for ; Thu, 15 Feb 2018 13:04:01 -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=3YBr9Wfut8+mvOiuhlaZWCk7NZfi+Lpp7DX/Drc+ADM=; b=cO8Kpki9FUeeEPmMl+R7tijK3yX8vk86r2mu1mIxJifDLjT0LOB/XQRWoLo6VnYNph IuYUGxwI0ICzp9PXt6xw8vbzLxV6W60Sq6cQT8k9elLK9k6D+zppVaoulYVKg5YtTp2x KSaP6Asz02EqvPieT6Z6vKgmQld6KDCsYXr5E= 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=3YBr9Wfut8+mvOiuhlaZWCk7NZfi+Lpp7DX/Drc+ADM=; b=Oz4OiPbrqn1pOWLCWayE4+S3orHa9Iw1WyWY/cJQ5uVAWktLWXpgMh75+OeJjK54AS zCAnheDJmLnTZsYqDnZiL6MjTpaEjK9/Lv4/PnuVTofDut5IX0b+jiG3IRM9pStbPp/o TTV/6qzTjzOaWYsgPeNPW5VmyPKcJUPqq1Ba+bI8INtoItj9YypKgkTdzKf7ux307bU2 JnuiWdnEMDX2dixmkG+JWiVzKFR9U4TktjX0t+ZL8wCZfGLU7bdj5U5B1Mx4ICGrkDc/ iwJNgrp+3w/z6WsXjyJ3lGxdEU+fX0/cdi7xYhlWT2cLFAfD0AQB6EYex5FraeCX1Csa 8k1w== X-Gm-Message-State: APf1xPDoVZEWAQ1Y9zQlxID1K5r9XPvNIPzaS8gvH6KQhXsmQpigI5Ch x8vVj2KawBIagN5I2EY8BISR2A== X-Google-Smtp-Source: AH8x226ahG8VJ2GYA+87vclSwUcWPMAAbLS472raVEcezu7NJcMKX9ybJRNDvAJd/6cYcsk2hgOPfA== X-Received: by 10.80.161.5 with SMTP id 5mr5032432edj.65.1518728639910; Thu, 15 Feb 2018 13:03:59 -0800 (PST) Received: from localhost.localdomain (x50d2404e.cust.hiper.dk. [80.210.64.78]) by smtp.gmail.com with ESMTPSA id p55sm8220030edc.15.2018.02.15.13.03.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 15 Feb 2018 13:03:58 -0800 (PST) From: Christoffer Dall To: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Subject: [PATCH v4 09/40] KVM: arm64: Move debug dirty flag calculation out of world switch Date: Thu, 15 Feb 2018 22:03:01 +0100 Message-Id: <20180215210332.8648-10-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180215210332.8648-1-christoffer.dall@linaro.org> References: <20180215210332.8648-1-christoffer.dall@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180215_130407_974646_369738D7 X-CRM114-Status: GOOD ( 12.22 ) 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: Andrew Jones , kvm@vger.kernel.org, Marc Zyngier , Tomasz Nowicki , Julien Grall , Yury Norov , Christoffer Dall , Dave Martin , Shih-Wei Li 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 might as well do that in the higher level debug setup code, making it easier to optimize down the line. Reviewed-by: Julien Thierry Reviewed-by: Marc Zyngier Signed-off-by: Christoffer Dall Reviewed-by: Andrew Jones --- 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 dabb5cc7b087..d958cd63a547 100644 --- a/arch/arm64/kvm/hyp/debug-sr.c +++ b/arch/arm64/kvm/hyp/debug-sr.c @@ -166,12 +166,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);