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: 10244837 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 A13F560208 for ; Tue, 27 Feb 2018 11:34:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 944D528833 for ; Tue, 27 Feb 2018 11:34:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 87F2228841; Tue, 27 Feb 2018 11:34:56 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D15C128833 for ; Tue, 27 Feb 2018 11:34:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753074AbeB0Lev (ORCPT ); Tue, 27 Feb 2018 06:34:51 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:36670 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752986AbeB0Leq (ORCPT ); Tue, 27 Feb 2018 06:34:46 -0500 Received: by mail-wm0-f68.google.com with SMTP id 188so22534732wme.1 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=d8UJDajCD6cRXsdDzfmeJ3CZYCy5Nycy29V6qhyEmW1eXQJkRtgQXnUJW4TkPn2q39 4XkbWglY/VJfdrmMTTboo/dYiSbRoRCzQ6Eqx6lEx7IknEIHGk8oYH/St0LI3Yjb9/nD 8I6xCm6nAdnDJU/6aZ93GmKQ0XB4DC0ZaqoBTXFFnjSetm1HDaAJyY72bE1RDbBh5bo6 wBeawz3sm/zoo1t66g7sS6lCUToqkxIw5RUv9CvxSJIyrioH5m8Vk5IWANKQJV60gORj iS7m8TmkYfF96XbTdGYs2ufZktLIWJaK/PpcP/bVfrmNT13RuGi5YAQaj8IJpsTErcHW puEg== X-Gm-Message-State: APf1xPC9/aLYx3yDw0oDaXKfNa2gk06dZbkDTvTWQoUFMiC2uBJ2Jp/j oByww427mQL+BKorxgwP0l4qEw== 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 Cc: kvm@vger.kernel.org, Marc Zyngier , Andrew Jones , Shih-Wei Li , Dave Martin , Julien Grall , Tomasz Nowicki , Yury Norov 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> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.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);