Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2094590ybl; Thu, 30 Jan 2020 11:15:33 -0800 (PST) X-Google-Smtp-Source: APXvYqy7wE7zNyeBG7ZypLp9l8ZByWUePkXskB8m3d5b6oQnQuDiRe5U52diClQ6nwjpt6xcHxnb X-Received: by 2002:a05:6830:138b:: with SMTP id d11mr4536937otq.38.1580411732750; Thu, 30 Jan 2020 11:15:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580411732; cv=none; d=google.com; s=arc-20160816; b=UMkEs7fmslZt+cHyd9GHkFP2mLYY1iRr4Y5zMmc1+AxyZmFE9K9iwzzCJAs3wUJ49a T72s1kbBQS+F6FiiuzfcTYMIG23xzdNhJwTQ6uOMAMa3Q9M8VCXzJ1+oNKm0mRyF95Hk hmuoloduOC2zZwuyvQx3v9cqGJloBIvNLfh2KI+jROExZomquqYRUw0qo1yzFJOj6BHR j8y2GG1RMyqcfy86jI3bR7PYCPRbwdbWHaFvzJ9w/cp7q70vMMlAFJcsgAXEouMX9ng5 Mm+oWwBTwEXgCSU7SfIn50iio5tTVho3UDqFKnbVXw6GYwpoRzGGcl2vmXOTV7RbgH4M EBCQ== 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=01EwlUvWkcmmooMraDv1YG96RIvOiL0hIe1M16+tNEAmF71figDn2/S6S9XFnO+HDB C7KqjuNZ8npcH0CmQBOkjjWxR3S1kVi+d4zYS14AFZBL4Mb8yc6XW9ArPqEpO1+z1KQl qm5YeXxVSgnR8D7aRF5TorfXM4w44U3p2wAM+WORv9v29nadiV42Mhx4RFQGQ+pQMdow 3U4CHEMBuHITyUYtTL6XTdwI5X1Mn95wuluOPjyzNGn6VxuGwK9zfPzXqfbrY9csVd8H WPZm13OoGZ1K8JCHWmAz30i+672rVQkCAAiYE2NnoQ5OZ8bjKCK26jYJxF2YqiQdccJG bxwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0Dp2MA5j; 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 o1si3554957otk.154.2020.01.30.11.15.21; Thu, 30 Jan 2020 11:15:32 -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=0Dp2MA5j; 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 S1730230AbgA3Sln (ORCPT + 99 others); Thu, 30 Jan 2020 13:41:43 -0500 Received: from mail.kernel.org ([198.145.29.99]:49650 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730211AbgA3Sli (ORCPT ); Thu, 30 Jan 2020 13:41:38 -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 99491205F4; Thu, 30 Jan 2020 18:41:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580409698; bh=jN6ANbQqioYljWwZi7eZoRc2McZejpuPir7nTRbPY+U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0Dp2MA5j9xVf4gneBfhxn1jKm9j45X2cpCs9EfmMbE9QVZ3Qxn+y8ML5x+a1vXqNU 8iON2yMOlHcs2mk8vS85HMsKvRXqQlQlAIckc/j7weyStgt/TQnM+uy9G8f1FlpFpb QOTgPS46yscCyQavBH7dbSefyK4Co1RqYOzIT4EI= 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.5 54/56] KVM: arm64: Write arch.mdcr_el2 changes since last vcpu_load on VHE Date: Thu, 30 Jan 2020 19:39:11 +0100 Message-Id: <20200130183618.519896222@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200130183608.849023566@linuxfoundation.org> References: <20200130183608.849023566@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)); }