Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp664739pxb; Thu, 25 Feb 2021 11:47:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJzgQCaHPqbkVVEirHDHSab3EuyYhLizZZqR1/xb0U9iwSvCXidDMXHswx797svhifvgIXbj X-Received: by 2002:a17:906:2892:: with SMTP id o18mr4206618ejd.220.1614282467677; Thu, 25 Feb 2021 11:47:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614282467; cv=none; d=google.com; s=arc-20160816; b=N23EklmM3MNGQn/GuduOkz1KsecUP5XweM9ptGy7ixxxF8rDmdqd6f8r+tBduq0eh7 iRQXHQfJLOZeX8CJaAx6sc6v+60ewbtD414jaSurZaQKXRbjZKaWjCc6myg2M8o9bXCH aUvs73pLQrPCVu0tavr4/QAZeEqCsYJkwDlmvSm+t0mP8z1W2GZl2sLzy2fqDnv3fwxI /h0VmaFoME6vOvbEucopXKoCJivjb6ikHhsxdk/ehlDymlPGWU96aGLRPS6IcUaQxABl RlSWD0o3a4cYqVmGqxDYVwdE+67sE+/ZtuHePUYI6fN8knaoALwhNZeHxHD3WYhrp1J5 t1vg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=ZuwI7n7ha02awqTikDWmNrMMgcVgOFuojmrRgc2Oi5o=; b=crblaGkvGuST/zQKi/lF9d91NWJlqD1whe4DGCi+xY2JwM0qsFM5tKT1NBHPXfyy3l 9tBx2RASXY7CLuzSD33SlTKoGMyd9t5K0uimMQ4/vzNXeaUaYR+1FaWW4JHieff0+AEs gVjVwWnrPIMq43csLnv0Jvy0Stx9qELPsxu/FbjuzhU6owSnCPO7BlIyaAnnbp9FlcMZ hbqfaNMNDWhGWeKY9ODWrVKQDkt6f99kv+iNzXRrAFqiFPT24QxJi6A26hwVZ6cPmGOa j1ypltrWCwTsqOlvjpq3oEOWvTvfmOstlEH2hO8MAr6oq06Da/waMuwjUT5/TOfbZ+RZ t8fA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z1si4214757ejm.289.2021.02.25.11.47.24; Thu, 25 Feb 2021 11:47:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233571AbhBYTpw (ORCPT + 99 others); Thu, 25 Feb 2021 14:45:52 -0500 Received: from foss.arm.com ([217.140.110.172]:48412 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234335AbhBYTje (ORCPT ); Thu, 25 Feb 2021 14:39:34 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E440E13A1; Thu, 25 Feb 2021 11:36:06 -0800 (PST) Received: from ewhatever.cambridge.arm.com (ewhatever.cambridge.arm.com [10.1.197.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 793C33F70D; Thu, 25 Feb 2021 11:36:05 -0800 (PST) From: Suzuki K Poulose To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, mathieu.poirier@linaro.org, mike.leach@linaro.org, anshuman.khandual@arm.com, leo.yan@linaro.org, Suzuki K Poulose , Marc Zyngier , Will Deacon , Mark Rutland , Catalin Marinas Subject: [PATCH v4 05/19] kvm: arm64: Disable guest access to trace filter controls Date: Thu, 25 Feb 2021 19:35:29 +0000 Message-Id: <20210225193543.2920532-6-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20210225193543.2920532-1-suzuki.poulose@arm.com> References: <20210225193543.2920532-1-suzuki.poulose@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- New patch --- arch/arm64/include/asm/kvm_arm.h | 1 + arch/arm64/kvm/debug.c | 2 ++ 2 files changed, 3 insertions(+) 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); -- 2.24.1