From patchwork Thu Apr 15 14:47:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 421792 Delivered-To: patch@linaro.org Received: by 2002:a02:6a6f:0:0:0:0:0 with SMTP id m47csp557782jaf; Thu, 15 Apr 2021 08:05:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzOKEuWiaLwdDFN42up26xVuoobvWi/Xih1+jHAdPTKzatak4tiPLAFV1WEOHVulYDF2Tff X-Received: by 2002:a63:360b:: with SMTP id d11mr3855854pga.297.1618499125134; Thu, 15 Apr 2021 08:05:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618499125; cv=none; d=google.com; s=arc-20160816; b=zszWJjH8Mi/KsIAjF+dIUn7+1fBpxncIvuQtMdIFIuKpKVBMNGAIMWJdXNPpShsZRw U/SN2qf/1Wn4VJgxA6DH+RgBkqD9KpQQzYALfVdEFGsizCOL6uZCcGjYz2gSxGKYTEwt LyZIQHiWL3oHjO4utMyjzgpzEOS60NXxeq7w4cAwpVeJmKf4lhIUxeEZ77hisf3WOySW fxZcP9jSmuFX5Q8wokgcjyngALZC9r9ZEgNLUBjsY9nURPwqcVkkrlej7B1cBz3gXDGp F2l8932iYuj8yniNWmLVYGRj2RqZ2s3QmvgxKuZM8xVemB5RKvrjeQ1/1xJtCHSGIE7k Koyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=9CAvGd1L30geecNhv5+iJ+3tN1Ci2iPk3w5K1tKr/xo=; b=WYqbhpZuZz8JBf9mzvQyQ/g+WSwhTI0d6kHSn0lknrf5CmrKBK8baZteEIM2vhyCUn w+NSdT8trFDzb0M6pqvRjCBc3sOZoOm1FjHU8QsEtV8DKxmaKkWdoHdvy8Tp9T/bKyPQ OjH3xtUGO/eBwTHoAi9wd4HCm2Kxyo8UnTqqlgMuHJi4bqXl/PLfWGy5uxbmwUd5j9AJ zEXwfLZK7qD6EKiYNSoDvSCF9nBoojtI7vvNke69hJhAuUTlLwLWNDzUZQsKd7o+l1XF OVlJ5glduqaogzC79yv7nnNbhXlfaloAdegoDOrsZJi+LKVrPVcEWLvchvux+th48wss KzCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pyzx5FUl; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s1si2822824pgk.72.2021.04.15.08.05.24; Thu, 15 Apr 2021 08:05:25 -0700 (PDT) Received-SPF: pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pyzx5FUl; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233781AbhDOPFk (ORCPT + 12 others); Thu, 15 Apr 2021 11:05:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:47228 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234175AbhDOPC0 (ORCPT ); Thu, 15 Apr 2021 11:02:26 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D65406141D; Thu, 15 Apr 2021 14:57:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1618498670; bh=3g36g50sGrlLKwYeeXFoH665hG2tCB9SHANgl+u75Aw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pyzx5FUlIjjmyi6CpA4F2exTN+iz9ucozKh2bft5WOHkLDCQWZbje6mGxgA8Xev4y A35iJ6QDiLdbkR1kP7tPPB9LRvm0RTWPHQGsSt76WSt5b6NHkQUIRF9dJ2EAtyeT/6 52j0p1rCCz87elHKEb0aHQHawdKEzJ/ne+vlgaV0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marc Zyngier , Will Deacon , Mark Rutland , Catalin Marinas , Suzuki K Poulose , Sasha Levin Subject: [PATCH 5.10 04/25] KVM: arm64: Disable guest access to trace filter controls Date: Thu, 15 Apr 2021 16:47:58 +0200 Message-Id: <20210415144413.305721939@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210415144413.165663182@linuxfoundation.org> References: <20210415144413.165663182@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Suzuki K Poulose [ Upstream commit a354a64d91eec3e0f8ef0eed575b480fd75b999c ] Disable guest access to the Trace Filter control registers. We do not advertise the Trace filter feature to the guest (ID_AA64DFR0_EL1: TRACE_FILT is cleared) already, but the guest can still access the TRFCR_EL1 unless we trap it. This will also make sure that the guest cannot fiddle with the filtering controls set by a nvhe host. Cc: Marc Zyngier Cc: Will Deacon Cc: Mark Rutland Cc: Catalin Marinas Signed-off-by: Suzuki K Poulose Signed-off-by: Marc Zyngier Link: https://lore.kernel.org/r/20210323120647.454211-3-suzuki.poulose@arm.com Signed-off-by: Sasha Levin --- arch/arm64/include/asm/kvm_arm.h | 1 + arch/arm64/kvm/debug.c | 2 ++ 2 files changed, 3 insertions(+) -- 2.30.2 diff --git a/arch/arm64/include/asm/kvm_arm.h b/arch/arm64/include/asm/kvm_arm.h index 64ce29378467..395cb22d9f7d 100644 --- a/arch/arm64/include/asm/kvm_arm.h +++ b/arch/arm64/include/asm/kvm_arm.h @@ -277,6 +277,7 @@ #define CPTR_EL2_DEFAULT CPTR_EL2_RES1 /* Hyp Debug Configuration Register bits */ +#define MDCR_EL2_TTRF (1 << 19) #define MDCR_EL2_TPMS (1 << 14) #define MDCR_EL2_E2PB_MASK (UL(0x3)) #define MDCR_EL2_E2PB_SHIFT (UL(12)) diff --git a/arch/arm64/kvm/debug.c b/arch/arm64/kvm/debug.c index 7a7e425616b5..dbc890511631 100644 --- a/arch/arm64/kvm/debug.c +++ b/arch/arm64/kvm/debug.c @@ -89,6 +89,7 @@ void kvm_arm_reset_debug_ptr(struct kvm_vcpu *vcpu) * - Debug ROM Address (MDCR_EL2_TDRA) * - OS related registers (MDCR_EL2_TDOSA) * - Statistical profiler (MDCR_EL2_TPMS/MDCR_EL2_E2PB) + * - Self-hosted Trace Filter controls (MDCR_EL2_TTRF) * * Additionally, KVM only traps guest accesses to the debug registers if * the guest is not actively using them (see the KVM_ARM64_DEBUG_DIRTY @@ -112,6 +113,7 @@ void kvm_arm_setup_debug(struct kvm_vcpu *vcpu) vcpu->arch.mdcr_el2 = __this_cpu_read(mdcr_el2) & MDCR_EL2_HPMN_MASK; vcpu->arch.mdcr_el2 |= (MDCR_EL2_TPM | MDCR_EL2_TPMS | + MDCR_EL2_TTRF | MDCR_EL2_TPMCR | MDCR_EL2_TDRA | MDCR_EL2_TDOSA);