From patchwork Thu Apr 15 14:48:11 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: 421794 Delivered-To: patch@linaro.org Received: by 2002:a02:6a6f:0:0:0:0:0 with SMTP id m47csp558337jaf; Thu, 15 Apr 2021 08:05:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwb/0YliWcm5PT5MaX/gc/ZHb9NGfvG2uMdD36q67r7S4rvWwQdqRtS1TEttrHFxF94pwaN X-Received: by 2002:a62:de83:0:b029:23e:6d5f:b166 with SMTP id h125-20020a62de830000b029023e6d5fb166mr3405417pfg.78.1618499154105; Thu, 15 Apr 2021 08:05:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618499154; cv=none; d=google.com; s=arc-20160816; b=HyFJ/H7Jt2kWZPrwbZFWScmrxl5AnL76TSaSKa7e55TOfoQS6WpEugS8WYIVB0gPJD D9Ilvp5PTjTY548rCQzNz80qQXQOKmV2rJEDSmEnnPNiq9tYFHV2099N/fHvA6K8mc08 GeSzcu7Oa15jRzRhohac9VjuX2JxE2OJluZM2C7B2uDz+tWpGbvIwG3wy2k4WNKmmftZ Blu229zc7V1s+0BzVEtTUdCKP+fRWVJsvHqIdGHzBsaD8LjJ6cHueIdecXxrYUQxfZUe CGBU9JuYSjnd/8D9m7N4a+hxk/vq2YbfW+iFiT5nqgDvSsqM5u/Fm0alzDdje4ve/Nd2 fiaA== 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=hOkzW29iKg3yNhzOwBBF+D4ruC2eXhj9Cr9Vh7/zHk8=; b=CJPUlTGZYY8W5VSbTc+acciOtwUYj1JwVniuzJaTFBlmBoOYqQK8qAv2uOtyKLLa9/ dtIKMrfXBcdt7ftCGtQDWKKQnH0+ApP0GYYCIQ5zi2LzbByd/VTTQENodbuXenjlS1eX FmhLy41a01WkytDB6IDz63mklW5HMWrG5NhNHXcmVhw63AYua5bM3wru4rI72tA6Rko4 X+lXxJJC1FnPv31SeINrFmNoodd3lTk9+yDKbxgMp4je3+urdYLlKeQb6OZ10vJpiqkQ E/qz6eyLEKT4FZGvKTCA1jK4AP7hjE+f6s4Xe5SteSbt6uxIUzspoSYPN1yK73r4eW6V GpfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sCspONk4; 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 y7si3641929plg.223.2021.04.15.08.05.53; Thu, 15 Apr 2021 08:05:54 -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=sCspONk4; 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 S234314AbhDOPGO (ORCPT + 12 others); Thu, 15 Apr 2021 11:06:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:48860 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234760AbhDOPE5 (ORCPT ); Thu, 15 Apr 2021 11:04:57 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 60BD66142C; Thu, 15 Apr 2021 14:58:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1618498729; bh=oig4PkMG+5ETXt+u398CdLDRIpLa18RO/Hbb1ProsSQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sCspONk44Ved4vMEpDuuS8sINGpflJphxNVXUftsP3Mr327D3lFKJBplNooR/Mo// a/p7Tmfhh9OIBw1WW0YEdp46ovDJ3wsiC3Gz8qBJ4ZbHLeersF1+JcEiW0YshW78la xqH9eotKumRDsu2CVc7fnYW06Fag9W+oo/hVVd9k= 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.11 04/23] KVM: arm64: Disable guest access to trace filter controls Date: Thu, 15 Apr 2021 16:48:11 +0200 Message-Id: <20210415144413.296653437@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210415144413.146131392@linuxfoundation.org> References: <20210415144413.146131392@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 4e90c2debf70..94d4025acc0b 100644 --- a/arch/arm64/include/asm/kvm_arm.h +++ b/arch/arm64/include/asm/kvm_arm.h @@ -278,6 +278,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);