Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2100499ybl; Thu, 30 Jan 2020 11:21:42 -0800 (PST) X-Google-Smtp-Source: APXvYqyy/Je5W9Q8+RaJO8ZddteQk9b12bj6V9BURUfQVWbPoE9Jrb9ka2kWwAQ+mjC6uUEw+Vcd X-Received: by 2002:a05:6830:1d6e:: with SMTP id l14mr4650667oti.32.1580412102464; Thu, 30 Jan 2020 11:21:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580412102; cv=none; d=google.com; s=arc-20160816; b=j6CD0hEF1Uq6mT1svVmNQjyFB9x1CCvcFQxLSBug8pYTGnd+Mwu3TYy9xTj1MkuO05 T/AV9NVwC8Ex6B4Cd15FC/vDYcvoiXEyQVbxucReq/CZyUngTOYKi31XrOFZ6G74Hvti 7HwUg6FqhlOQmznhlx2wBVuHF1dRS4QR+IAVqqvxySyI+ptA7xmGqVDlGWyCeHIaKMXq QAv5Mwug4uJSJkx0iY5zx6I6NIB/9COymBLt3mAFx6MKOZBgndAI9t+Ip4cbNb0YOtUF cLI8b++dxxa+kdLhs+ntOTe3RLX1jeW5q3w7+j96ZUXYo4dhEuJVNWKjHEPrRNvwIFUk 0Uyg== 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=E8ziqU95fBTFmOKV0hV1qnjXBjjDFqEOwLb6glaDbCU=; b=aa1jUjkepyWYXxOVT9EEnEUN0QDX2hX8vCA+f7i0sU7KZ28vtRoFaPV+JjdLtZncZ+ cJREKs1nOoSEFQmLNcgZrFiPSyBbfKb0PYQ3MSz8pTKqWDEEXQ/4sOJtkh+gtJCbrQfO YgHPZwYK1EWvA7EuCY/orOvu2hhwMlGo6UKBErFZRsiAD+ALwBsjC22dt23OF0TdsAny 3QIZ3wGFYMLB3x5VbiZkcXSvSRD8oIkiM5BNlIHk++nPH4N0vO2Jl6piadb8aRaZAtPL liM36RgZaaw0aPgtgzdkqj+pmvnM47QTwjQc+a0m6uSzQdQ4hj4QleONDI3yDunbbPoO 7RUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uz044B4A; 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 h138si3068253oib.6.2020.01.30.11.21.23; Thu, 30 Jan 2020 11:21:42 -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=uz044B4A; 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 S1731653AbgA3StC (ORCPT + 99 others); Thu, 30 Jan 2020 13:49:02 -0500 Received: from mail.kernel.org ([198.145.29.99]:60270 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731649AbgA3Ss7 (ORCPT ); Thu, 30 Jan 2020 13:48:59 -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 ACB7F2082E; Thu, 30 Jan 2020 18:48:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580410139; bh=s2rmcFHlg0bundURMOPl/pYu5ppo6GpvVpIgo6Gqktk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uz044B4Av4Sv8nvgZDoJ6ucaMPBqGC6j519l3rVKjkkQ5gg7TyOBWT1mZg0JSZPyW WZUmV4HKxRUuo4H9i3RXDzUxOOEH6X0QAuaaJ6eZzm1D6Vq5Gjbo3Wh5ZzR8daZ7DD 0c1J66fRp0fYph4B0lKbA2Zp9Pd7AP6CRGsYIAtE= 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 4.19 55/55] KVM: arm64: Write arch.mdcr_el2 changes since last vcpu_load on VHE Date: Thu, 30 Jan 2020 19:39:36 +0100 Message-Id: <20200130183618.321089628@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200130183608.563083888@linuxfoundation.org> References: <20200130183608.563083888@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 @@ -112,7 +112,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); @@ -208,6 +208,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)); }