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: 10100165 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 16A0E60360 for ; Thu, 7 Dec 2017 17:06:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 019AE204FE for ; Thu, 7 Dec 2017 17:06:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EA8D5284DE; Thu, 7 Dec 2017 17:06:58 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI 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 9AB4B204FE for ; Thu, 7 Dec 2017 17:06:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756603AbdLGRG5 (ORCPT ); Thu, 7 Dec 2017 12:06:57 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:33926 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755830AbdLGRGw (ORCPT ); Thu, 7 Dec 2017 12:06:52 -0500 Received: by mail-wm0-f66.google.com with SMTP id y82so1447535wmg.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=dIfakc5gzq4JYXBXw4EvyM0gIu5lIJ3M9DBZyPWNUXopTXxy3u97kF0inhJ/UaBjDU TyP/IvzmrWNHyrM34ZPmxDcuMsz/U2eSxv+w3ooEDmY0CG2thwdoxmAz0x0Gpv8LrGKM d/D9sfreKJVNfp52fyQekJsk1zFs1mQ3ngNFGzyk/0RsHmla6zYE4GacP4ErEzOhCDzY e4EWyOEiIUthS9qJSMdghml9Cvhh6gcyfog5CvG3fKbbCAFyi4/xDwKOi2dcX7FR9rQX FvflNM6AQzRqw12DA2Z7HlIGAVA3NLzGi2uPyB6P8hDekMLr2LQELXfCfW5eJ2y0UzZw Yxug== X-Gm-Message-State: AJaThX4JqPpehIXAwCgv7Ud+LBbKkEdnyzRp9nyTszmg6vLMpq/116EZ Et943QRGK+IMK7CbScH9TwpEQg== 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 Cc: kvm@vger.kernel.org, Marc Zyngier , Shih-Wei Li , Andrew Jones , Christoffer Dall 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> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.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);