From patchwork Thu Apr 15 14:47:51 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: 421787 Delivered-To: patch@linaro.org Received: by 2002:a02:6a6f:0:0:0:0:0 with SMTP id m47csp554113jaf; Thu, 15 Apr 2021 08:02:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx+9OqQsZNILz/kDTWJgIfsgHB4qMET6jSVjW21LNbW0chAxoZoSrSURRuss1eCW9x5k0HA X-Received: by 2002:a1c:f701:: with SMTP id v1mr3624520wmh.69.1618498925641; Thu, 15 Apr 2021 08:02:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618498925; cv=none; d=google.com; s=arc-20160816; b=aQHrDE/VakFM5cbF8D06vVwxsfcNPh8F4EbfIQHLaaP9Vxs1EE0TVxaLcFVGZe/PFi 8XIa1ng3OEasHJBPEAuWOOvsKPp/IndTyaEqEDzx1Sv9se9a31+Vdikj4Q+XmYR5oX7S sbn0UKfsrjtNrNnm5LmDDcJBVNj/WMxcrZw5GpXIXcIKXAD0yXLLRlu+bVPTg0OC1G+5 twpfxxcHk1GLrGHn11N7FkFf7GER6fSGyEwdqpypq8j1gMnimXGv7BY3FmEzQwfdJboZ YYdBWjgiTOYL6OrjhV09VFOTh0IiMpBds7J/BSjDU682HTdyOkxTSXDt6fCAfxo07YcC vGHw== 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=fgtATRjZWI5nqObnXJG4jmF/xiQ03SGnhOLDUemlUpg=; b=zefjqR8vqCEsyWM6n+nKwttKkPQwN+E2E29vbvXadyFBKmJnBN7wey29QleiL6iK9Z MfK8P8Rt33DsB+LT2zYNh6zUJ3WGEWfxGYMwa4eHF+8IsUECOl3zaPkM3SEUDrRbHEh1 gaOqaEeeDAnBRf7RN/U84oWuf9g2o+F/1toPfOOC4/OerAazJT4AHCtcT8GJAGZNZfNJ DraPmsag2QEv79NPPRhgMIUgpJZukGQ2r8pdk6XR1Mem5h1FicF+3LEb40MpJRWKj5Ge zWq6CDXecZY4GFDCzn6RCsEYOUXlqJbVI0Tz8tCqplnszjgUS7Kmeqb1Zk2QGz4Iyrcp a2gA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=NN+HcWul; 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 b13si2713610ede.461.2021.04.15.08.02.05; Thu, 15 Apr 2021 08:02:05 -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=NN+HcWul; 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 S234166AbhDOPCY (ORCPT + 12 others); Thu, 15 Apr 2021 11:02:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:44862 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234914AbhDOPAI (ORCPT ); Thu, 15 Apr 2021 11:00:08 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D59C461404; Thu, 15 Apr 2021 14:55:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1618498553; bh=U0NkCqrtt2/5zmQhJfG2/sgeLgus2MBC9ny/6oHh/0c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NN+HcWulOtPjiop+MLk5jPmnoMYlz7hLy8pvPZBa7vz5YQ77RSkF91Z3vbL+APmqT ZuombAnpYuNkzgKiSWwQEJR6piejzXFRcTS0/w72B3n3U1m5XSMz7rUYd6yeRiA2VH QhsAiE9QGjYrinIBhadT0jddDNNZfWOzneAGyrJw= 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 4.19 02/13] KVM: arm64: Disable guest access to trace filter controls Date: Thu, 15 Apr 2021 16:47:51 +0200 Message-Id: <20210415144411.677616810@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210415144411.596695196@linuxfoundation.org> References: <20210415144411.596695196@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 a3b6f58d188c..6d43f7901da2 100644 --- a/arch/arm64/include/asm/kvm_arm.h +++ b/arch/arm64/include/asm/kvm_arm.h @@ -198,6 +198,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 4e722d73a3c3..3606f6b89094 100644 --- a/arch/arm64/kvm/debug.c +++ b/arch/arm64/kvm/debug.c @@ -100,6 +100,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 @@ -123,6 +124,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);