Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2100950ybl; Thu, 30 Jan 2020 11:22:12 -0800 (PST) X-Google-Smtp-Source: APXvYqxlGgQAv/mZvq/ofskeRwYJRuu/5OSdNL9XKCXvOkaRAszG2jNtJwvGki4Y9KJAbmyicUtB X-Received: by 2002:a9d:1928:: with SMTP id j40mr4809104ota.68.1580412132506; Thu, 30 Jan 2020 11:22:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580412132; cv=none; d=google.com; s=arc-20160816; b=Za/fe5jcTCc1ta/FTu1EAWevbTDiX3G7KeNx2Td8Wr9sC5Ncmosme697yx6m9V1gd9 X9xWt72xMSF10v3eXWyAVAKHpZuW+f49Rgm+0o5pZLU12VTx+yAcY8zd6/37l9sZtyFn hUUA+v37walnmgiiUpbL43c9KfHIXoMkY/HkRxq3p47zwMG6kc7Xvo+bajG480HHZr4G ZYzO+ZzjDxycC1iPIDAsgOljar/YZfp+xnuYqlgQ+pQL+Za7g6VtlB66vVt+WhhwFejN /caadlA8d9/yryYtINncOdJjYwKFrLbj1HbtXB2OyPVGP5PYcvCie59n/mzPYAzdI4jj 33RA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=wWJugvb96nFPoUbkWdIqj+Tl5ercCDrF9OYukjB2zls=; b=rmWQXFUdLaQKLEIfx16vAJf9gfZPXe3TZWl74LiwWKQpPO9CcP/FFydE87gAMhiRQV mFvxUUOH4JgcRpo0i4POXMzV8e/ICF6Th0Mo+t/wahdJ5QF2OedpivQbxM6gRPJo3y5r 4G2HELgkvwBy9VmMJ7lqRlJYnwrOMMFzGwZ9UU8454Wk/bpOH7gLAfKi8BsOgvb5gw3k cQL+vvXIbFsYSgH2G/fe4+EDT7Y4/Y1j7N09Ivsa9UCYQHkdADb00FYKXc8O8AsJXhWJ rpD9n3dXxeUA09t7YG9+6W9cO7smN6ean7NpHJ9XkJ3SV8kitX8NUzVIxB5SvwYJA22f yXTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Yg0TCDrn; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f187si3396311oia.218.2020.01.30.11.22.00; Thu, 30 Jan 2020 11:22:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Yg0TCDrn; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731716AbgA3Su7 (ORCPT + 99 others); Thu, 30 Jan 2020 13:50:59 -0500 Received: from mail.kernel.org ([198.145.29.99]:56198 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731161AbgA3SqQ (ORCPT ); Thu, 30 Jan 2020 13:46:16 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8E93220674; Thu, 30 Jan 2020 18:46:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580409976; bh=jN6ANbQqioYljWwZi7eZoRc2McZejpuPir7nTRbPY+U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Yg0TCDrnLALwLQcdq/cPkT2T48qU9ROHcE1sJXBazWB7nmWmxD1oKxn1umZOibcXF W9EoSJ3yTiQeVQTKb7DcntWpjkrZf8pK2nMsaEuGJFSm/wQLAYmVaHC6yqakBW5g1N Vw79CEmMQmCt+u3N8sZg/ABfUv2MsyS/RckBcW50= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, James Morse , Will Deacon , Marc Zyngier , Andrew Murray , Catalin Marinas Subject: [PATCH 5.4 108/110] KVM: arm64: Write arch.mdcr_el2 changes since last vcpu_load on VHE Date: Thu, 30 Jan 2020 19:39:24 +0100 Message-Id: <20200130183626.144364351@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200130183613.810054545@linuxfoundation.org> References: <20200130183613.810054545@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andrew Murray commit 4942dc6638b07b5326b6d2faa142635c559e7cd5 upstream. On VHE systems arch.mdcr_el2 is written to mdcr_el2 at vcpu_load time to set options for self-hosted debug and the performance monitors extension. Unfortunately the value of arch.mdcr_el2 is not calculated until kvm_arm_setup_debug() in the run loop after the vcpu has been loaded. This means that the initial brief iterations of the run loop use a zero value of mdcr_el2 - until the vcpu is preempted. This also results in a delay between changes to vcpu->guest_debug taking effect. Fix this by writing to mdcr_el2 in kvm_arm_setup_debug() on VHE systems when a change to arch.mdcr_el2 has been detected. Fixes: d5a21bcc2995 ("KVM: arm64: Move common VHE/non-VHE trap config in separate functions") Cc: # 4.17.x- Suggested-by: James Morse Acked-by: Will Deacon Reviewed-by: Marc Zyngier Signed-off-by: Andrew Murray Signed-off-by: Catalin Marinas Signed-off-by: Greg Kroah-Hartman --- arch/arm64/kvm/debug.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- a/arch/arm64/kvm/debug.c +++ b/arch/arm64/kvm/debug.c @@ -101,7 +101,7 @@ void kvm_arm_reset_debug_ptr(struct kvm_ void kvm_arm_setup_debug(struct kvm_vcpu *vcpu) { bool trap_debug = !(vcpu->arch.flags & KVM_ARM64_DEBUG_DIRTY); - unsigned long mdscr; + unsigned long mdscr, orig_mdcr_el2 = vcpu->arch.mdcr_el2; trace_kvm_arm_setup_debug(vcpu, vcpu->guest_debug); @@ -197,6 +197,10 @@ void kvm_arm_setup_debug(struct kvm_vcpu if (vcpu_read_sys_reg(vcpu, MDSCR_EL1) & (DBG_MDSCR_KDE | DBG_MDSCR_MDE)) vcpu->arch.flags |= KVM_ARM64_DEBUG_DIRTY; + /* Write mdcr_el2 changes since vcpu_load on VHE systems */ + if (has_vhe() && orig_mdcr_el2 != vcpu->arch.mdcr_el2) + write_sysreg(vcpu->arch.mdcr_el2, mdcr_el2); + trace_kvm_arm_set_dreg32("MDCR_EL2", vcpu->arch.mdcr_el2); trace_kvm_arm_set_dreg32("MDSCR_EL1", vcpu_read_sys_reg(vcpu, MDSCR_EL1)); }