From patchwork Tue Feb 27 11:33:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 10245005 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 C267E60362 for ; Tue, 27 Feb 2018 12:07:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF6A428793 for ; Tue, 27 Feb 2018 12:07:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A425F287A9; Tue, 27 Feb 2018 12:07:42 +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=unavailable 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 28D2728793 for ; Tue, 27 Feb 2018 12:07:42 +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=7HbBfL2HhCy0ogS0NgqBLUx8sAcWtakvmhnXPEjTAjw=; b=ewoRapSXlawn1bhmyIGV4jhWyD KjDhk4QWQJTIcylT9hwLVedZnPDpxJTT4cX+KHXFE/zuxT3hhOkGPRgV433rowkqKNNviN8AGP8BH PckPlI2vSNJI81hAYuZHCe8+SP6zN0Dl1UNuS6Exxs675e15MBN12CC63DbVU5Os/W+m41CoFsyll SwlVtY3MTzR1omg1rsT83hrFGOLql+dOrMTPZPN/tIqYumIL1FtH1IggPmMEEZqJBFXJbFiB7rLFN mh4yy1AWx6Bl1od8H9NuSfoLR6Wa6UkuDJQn2xN3z61uq46cr5ZfbUk90OIJZiQ/POTuUMMkb9MhK bRImqIsw==; 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 1eqe2i-0003A5-EQ; Tue, 27 Feb 2018 12:07:36 +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 1eqdX2-0006ZQ-Ix for linux-arm-kernel@lists.infradead.org; Tue, 27 Feb 2018 11:34:59 +0000 Received: by mail-wm0-x242.google.com with SMTP id t6so14821240wmt.5 for ; Tue, 27 Feb 2018 03:34:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=christofferdall-dk.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=SzJE4/wbWJS1xcz9nPtq4727YRkF1ZFfDfXtuSmCa5Q=; b=pCzzavolIiIZMY8VLYxxQu0IDiArCcUZCjKoUvay5GZAx2+PjmJ0W0HUD2wL/LBQfm SoEZ8cvq37CfBehHZo/dMK8YQmyBkcdISh6QoIxc0MoJeqo+7ZUxvtZfDBWt/P/er7d2 R43yG1EV+pWc89Io1uiASFRzepL+t0wRT567LSQQ66Y1NQ/kbhkxbiBBzpOMiblUimH0 0qTte2pSYJy9Wwg/6B+qael5QX9RUIU6ljb/9Lw75pIEocBf0G27uOs2gpsgzadfCgmV YqIHbn1np0uKm6amIcoptflWCJD0vkejwW7aBbW6NmgeBn9doYw5TRgRfSayOdbm6VHI lK2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=SzJE4/wbWJS1xcz9nPtq4727YRkF1ZFfDfXtuSmCa5Q=; b=drK0YO87bAD5EZdubUdFE5o+ieLhWgGPjDcp3hFuIbdr3wscN3zvWAB8g5j7R4PPP7 Hcw/VMOfI8mAwZISsMyz7H0B/8tCI26jtQyU7fBnc6EaSBDnOp1gB49+T+FQeLVgL7lU G9HUqmN8+Pw/2Ce1+/XMcNjfdI5z5b68Tp6VyFyTh9no/hbkHLZNPIjcTdo35QOOx5h0 pCbpVGMQ9+BpzD7lJpM4Xa38cye2t8HnbPKQRmudHF7sUg8YhYZK/FbS1BND9YYeBI3c P3t3QPetPufNznMwnlg11AETZoDcOBsbpE4/oobMN3cXv2Zca3X9Qw3va6FtrEpirE1A VbDQ== X-Gm-Message-State: APf1xPC6OFftfGYMLw91CJw6tVrG/eVuHHi7eNSNTjK+BS36TaqHQvcP 6mMAMRCSOkyTAXj/nW0ZiFStmg== X-Google-Smtp-Source: AH8x225muizGWaA8k8r6prHVkKO3z45gD/9/rS0t5crUPw5ZY1sWk01lVCwnGUvow+Hu/Z6SCnnGBg== X-Received: by 10.80.182.52 with SMTP id b49mr18719843ede.279.1519731285445; Tue, 27 Feb 2018 03:34:45 -0800 (PST) Received: from localhost.localdomain (x50d2404e.cust.hiper.dk. [80.210.64.78]) by smtp.gmail.com with ESMTPSA id m1sm9176786ede.39.2018.02.27.03.34.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 27 Feb 2018 03:34:44 -0800 (PST) From: Christoffer Dall To: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Subject: [PATCH v5 09/40] KVM: arm64: Move debug dirty flag calculation out of world switch Date: Tue, 27 Feb 2018 12:33:58 +0100 Message-Id: <20180227113429.637-10-cdall@kernel.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180227113429.637-1-cdall@kernel.org> References: <20180227113429.637-1-cdall@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180227_033453_295874_3CEDBE50 X-CRM114-Status: GOOD ( 12.95 ) 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 , 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 From: Christoffer Dall 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 Reviewed-by: Andrew Jones Signed-off-by: Christoffer Dall --- 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);