From patchwork Thu Oct 12 10:41:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 10001597 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 68865602BF for ; Thu, 12 Oct 2017 10:44:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 59F0828AB0 for ; Thu, 12 Oct 2017 10:44:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4EA8628AB7; Thu, 12 Oct 2017 10:44:31 +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 C296928ADD for ; Thu, 12 Oct 2017 10:44:30 +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=0MkBQo2BSklfEbTYwvIeYW+VHO+CxOgqEdWuJYhH64s=; b=HNSiZpAaTjJIAXlPKqc8ftM0pi c0cGa9JSiY2WEQeWJoB+dEtKMViRqyscqZmdum9nkOR4CneI8YeVMzgZKhHQuHzieaEPEuT5jvM88 h2uq/vprwSY8M5Sbu1w+iaHQrlH8NYpbQScJfe2dDoR67RBdLzw3BEydGqr6ZxnnE53X7wnBEIds+ 4jDgPlnTCD/eRVvsjD9cUraeRMKuOhkVitpYpzXsIZc2bTcEdgtIjBY69DAAuaUJtDYwZ1rOYoi+Q 8Y2ENjzPDVTreZYyiOhvkf44UK3w83N/XNA10SDs1rtPg48ZiftFZ0t2peXcKDDUzf78m2Wvp7r4h LfyIX9DA==; 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 1e2ayX-00014N-EC; Thu, 12 Oct 2017 10:44:25 +0000 Received: from mail-wm0-x22c.google.com ([2a00:1450:400c:c09::22c]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1e2awS-0007W4-1M for linux-arm-kernel@lists.infradead.org; Thu, 12 Oct 2017 10:42:29 +0000 Received: by mail-wm0-x22c.google.com with SMTP id i124so11856409wmf.3 for ; Thu, 12 Oct 2017 03:41:55 -0700 (PDT) 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=Stq3xw4oKAe/yBeousXXdbIXHX2wLPJhD1FHRg13mik=; b=WUX+i53kWQm/9P5eeXjklQNB8oo/W9nJIwOwEZdSDcIbIiwgKnhgl4DrkNraTXyvsK hWNvTxf+Fczahyj1xg9o5VYj62OPKaOObg+qKOVUU9fm13nLdIpX3BJMNnIk0LhzNcvm SodxSZ6fD3yPmrs2M6bwp5xCdwJ8JXid20E3E= 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=Stq3xw4oKAe/yBeousXXdbIXHX2wLPJhD1FHRg13mik=; b=kuIIcankSwU6mQshxibfyYhfIgNFs8gf67sEP0urqPLeC6tiu/EMsi01Kri4cbyb6R 9PGOLG0/E96CIafhTrdwD5SPzDrJq4dEajTfL0fBdPBnW3y7iyDFligP7Lhg4sq4COot X3CQfA/pjmRjNmb3/LZe4KwDmMH05U8cRqVFZzOgCiIBMQjRjinSJf4qU6oT/NbzIn0O mkO2J6h6Btedtiz894E79hLJAyRfeydNjpuhjPGbjuctzy9Qmyl/S/j+/uF+C72lsHbz BukeSTcZ9452aKhrxDT7uMPhZiD2h450MX1MXtBaknucnP7opMz0bgdzvZAoL2Ba2lJq idDQ== X-Gm-Message-State: AMCzsaVLAdb4GvBiw1wuBpzaloROfEmxyUuawG0dh4E5qxml4W0jkvuq eIz+NtTrm7IlTyy2Oi8Uw4Tg7g== X-Google-Smtp-Source: AOwi7QBEzMT306SRYWd1Bt4eOYHw6gaspCS3BQc4CJDr7A/C/tNTN7x9hp3RAlLJ9fZYPN5q/0wElA== X-Received: by 10.80.153.59 with SMTP id k56mr2434030edb.208.1507804914265; Thu, 12 Oct 2017 03:41:54 -0700 (PDT) Received: from localhost.localdomain (xd93dd96b.cust.hiper.dk. [217.61.217.107]) by smtp.gmail.com with ESMTPSA id g49sm4798603edc.31.2017.10.12.03.41.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Oct 2017 03:41:53 -0700 (PDT) From: Christoffer Dall To: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Subject: [PATCH 09/37] KVM: arm64: Move debug dirty flag calculation out of world switch Date: Thu, 12 Oct 2017 12:41:13 +0200 Message-Id: <20171012104141.26902-10-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20171012104141.26902-1-christoffer.dall@linaro.org> References: <20171012104141.26902-1-christoffer.dall@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171012_034216_771465_F93FF89E X-CRM114-Status: GOOD ( 12.39 ) 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 , 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 --- arch/arm64/kvm/debug.c | 9 +++++++++ arch/arm64/kvm/hyp/debug-sr.c | 6 ------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/arch/arm64/kvm/debug.c b/arch/arm64/kvm/debug.c index dbadfaf..62550de19 100644 --- a/arch/arm64/kvm/debug.c +++ b/arch/arm64/kvm/debug.c @@ -193,6 +193,15 @@ void kvm_arm_setup_debug(struct kvm_vcpu *vcpu) if (trap_debug) vcpu->arch.mdcr_el2 |= MDCR_EL2_TDA; + /* + * If any of KDE, MDE or KVM_ARM64_DEBUG_DIRTY is 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 f5154ed..0fc0758 100644 --- a/arch/arm64/kvm/hyp/debug-sr.c +++ b/arch/arm64/kvm/hyp/debug-sr.c @@ -172,12 +172,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);