From patchwork Fri Jan 12 12:07:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 10160629 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 BCDC660327 for ; Fri, 12 Jan 2018 12:24:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A108727968 for ; Fri, 12 Jan 2018 12:24:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 93CCE289D3; Fri, 12 Jan 2018 12:24:06 +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 13BF527968 for ; Fri, 12 Jan 2018 12:24:06 +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=xlcO523e0YJRmSMO5l46m9MqHtWCI9hhCs4W8FqZoiw=; b=TM+c9L3YEJyMGKfkZZC66MIR8R n45n4c7f49WC6HpIEgC/dYCaLGnEJpdCAQNvYE3Fr2rots4zoAMFP6ZxFczgqqKqG+TcJgIEPfO2B O9ilivFBu8og2YMBTfKdFEJb5+VdFYRF3VxXYemDWtdXhYzK2LSlU3Cm9bYKw4cBs17+lqJaVVV5N Okkg1BuR0BfIxuRtNvNxfJ6cmjAWlhjokRYnMNsD+BVBYm1IxrdWscc6JmNEiySw8LX5arXcEXD6i Jb0l1V+e1imwEYsrDl9Z7mG9OR/eyVTC8Uc6sh3P6J113fQ1uOpZXytspUqHM/d5MaGIfXHqxVrLJ noGJ7lyw==; 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 1eZyNQ-0007n4-Ta; Fri, 12 Jan 2018 12:24:04 +0000 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eZy88-0000CL-DT for linux-arm-kernel@lists.infradead.org; Fri, 12 Jan 2018 12:08:25 +0000 Received: by mail-wm0-x244.google.com with SMTP id r78so11482625wme.0 for ; Fri, 12 Jan 2018 04:08:08 -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=XJ3kWkx9zCHyxDTaHY1usgDH/9jkqmLLNwS0xel/V+8=; b=Bjs6d5eJVIiRUwU1xoDHViE0ORpiC0OBmIEUm3UFv2zgY8bsXRzjNGUKOkankJWeC4 icaze2c8JE7m5tEiqwmJlK1HwXPofpDteN+CiA65M+aUDO8Gmb2jKhTFiej0eWpDUtDH tOWGRr8RhRZiuaJTMsCcrPNeHHM7Kdq+Lm8Yw= 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=XJ3kWkx9zCHyxDTaHY1usgDH/9jkqmLLNwS0xel/V+8=; b=fbxyGvNvig2UyvQHFzc3qSsAkNDhk1f/ErlXDQUCQIC/kmTfahK/3y7+bUfPwnQZs5 zsjjk7R0zVpKtGy95WDj51xSKTPXQ2XJrcut2mTTBJGDgZ8494TfXhv652xhvslSsolL LugFXW+nsMi9Vv6ZoS8qV90r6AnFV7BG+BgMnjF6/uyJMALmN5mvWOLSy9oFBclljDa2 a1SY1bHHQixYDOXyswtzg6xrTMLa0eZ8JuX/BJrMsl06rSphOt1iwqUTgX2CU5VlcLf8 R9D7eLQXUafTcTyP2fdJRT+2qUkTgLOdbHTYzSeh9JNiSkDE4c47zcQFf31Lf0mcw6Pt PJaA== X-Gm-Message-State: AKwxyteWlG17JNvBfSnvOZcSoN6Kj4H0gtX1UuDxp4BQuGSIvPvxnu2L 0uBxmZDpRAQX3EYJ5M4DraGGRQ== X-Google-Smtp-Source: ACJfBou3v7x6DEL5xaOrdBpqw49SzUR9BpguyVEgPVFX4p49ddb104ogf2X6xaKLwZsmbis5b0AZaQ== X-Received: by 10.80.165.243 with SMTP id b48mr16046777edc.201.1515758886833; Fri, 12 Jan 2018 04:08:06 -0800 (PST) Received: from localhost.localdomain (x50d2404e.cust.hiper.dk. [80.210.64.78]) by smtp.gmail.com with ESMTPSA id f16sm13489705edj.65.2018.01.12.04.08.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 12 Jan 2018 04:08:05 -0800 (PST) From: Christoffer Dall To: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 10/41] KVM: arm64: Move debug dirty flag calculation out of world switch Date: Fri, 12 Jan 2018 13:07:16 +0100 Message-Id: <20180112120747.27999-11-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180112120747.27999-1-christoffer.dall@linaro.org> References: <20180112120747.27999-1-christoffer.dall@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180112_040817_049287_53D19F9A X-CRM114-Status: GOOD ( 11.63 ) 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 , Andrew Jones , 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. Reviewed-by: Marc Zyngier Signed-off-by: Christoffer Dall Reviewed-by: Julien Thierry --- 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);