Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp525151pxb; Wed, 27 Jan 2021 13:54:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJwZD3cbqcyHWsa1Ec297Ed+bG8ud2IPKmtE4m8cgV+MKKbUDgyjDhVgvXQ7wChHwpPYE38Q X-Received: by 2002:a05:6402:4382:: with SMTP id o2mr11237927edc.371.1611784469472; Wed, 27 Jan 2021 13:54:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611784469; cv=none; d=google.com; s=arc-20160816; b=E1proRnQ/euTKu7cBbVyzB0wVQCckTQvuKABkoIo00LwV+QNFtkbKBzGhdMGEyLqi5 /npfuPtc0cZ/Gycek8XViVnlEUUNtPXl4Wuh1wPkGZI49i30C1GvQh9Ua2n9doGIbqBA PTfToVjjKTlzimJFRIUsSguCnyTOzoFFpRvW8W+3jH3PI8oUQKQlHnvrMmMN2nKw59z4 ILNA9LQ3Jul7l+jjc7B0zNRHj7b+MCtx2hFqYfwGA3jQEq1NHXi+25dO4LVdP3NHJB+Q X10hEfzXtPht4sGkYnZbqnADQWnzouECTnvczcB1dnh83ILqQ3c4J/JAP95AkXW1H4rI eUzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=6mX23Rwliy6V2myhbkuD2JtQDKqrsFBINkS1CbwKnLE=; b=FuuFWrc+16JAll1G6SE9h5CqWXiTt3YPATbSvgvgKdFIoYUaVMfbjZ2MeUp26UYq85 BK+CTe5TVhI+yh11J8aBxGFsUw4AUipeswDP/bpJwz31Eiz/3UDtwvet/ClqfQSOCBS5 Ahc2aGxn7VZXoYEiu6ZbWZIkxmE4LDx1/YJ3oZoL9W6MixhPJF+SGLRvRDVtpvm2SOjo NFoKaQ5ekBpQUhBLioeLI/VtURSJ70virRBrlc0eojXFzYRdvEGcmSSDjlv219/BHoUv Xc1fNccdaLQAfZilUTvDZR8KrheXHKt3yHzL8aaN9Arni/Xzi8DQ6jnHKP6vvLIncjc5 GqmQ== 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 gq1si1313464ejb.675.2021.01.27.13.54.00; Wed, 27 Jan 2021 13:54:29 -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 S235623AbhA0JwR (ORCPT + 99 others); Wed, 27 Jan 2021 04:52:17 -0500 Received: from foss.arm.com ([217.140.110.172]:32954 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233049AbhA0I7I (ORCPT ); Wed, 27 Jan 2021 03:59:08 -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 E35FF14FF; Wed, 27 Jan 2021 00:55:56 -0800 (PST) Received: from p8cg001049571a15.arm.com (unknown [10.163.91.246]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 3E52C3F66B; Wed, 27 Jan 2021 00:55:52 -0800 (PST) From: Anshuman Khandual To: linux-arm-kernel@lists.infradead.org, coresight@lists.linaro.org Cc: mathieu.poirier@linaro.org, suzuki.poulose@arm.com, mike.leach@linaro.org, lcherian@marvell.com, linux-kernel@vger.kernel.org, Anshuman Khandual , Will Deacon , Catalin Marinas , Marc Zyngier , Mark Rutland Subject: [PATCH V3 10/14] arm64: nvhe: Allow TRBE access at EL1 Date: Wed, 27 Jan 2021 14:25:34 +0530 Message-Id: <1611737738-1493-11-git-send-email-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1611737738-1493-1-git-send-email-anshuman.khandual@arm.com> References: <1611737738-1493-1-git-send-email-anshuman.khandual@arm.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Suzuki K Poulose When the kernel is booted at EL2 in a nvhe configuration, enable the TRBE access to the EL1. The EL1 still can't trace EL2, unless EL2 permits explicitly via TRFCR_EL2.E2TRE. Cc: Will Deacon Cc: Catalin Marinas Cc: Marc Zyngier Cc: Mark Rutland cc: Anshuman Khandual Signed-off-by: Suzuki K Poulose Signed-off-by: Anshuman Khandual --- arch/arm64/include/asm/el2_setup.h | 19 +++++++++++++++++++ arch/arm64/include/asm/kvm_arm.h | 2 ++ 2 files changed, 21 insertions(+) diff --git a/arch/arm64/include/asm/el2_setup.h b/arch/arm64/include/asm/el2_setup.h index a7f5a1b..05ecce9 100644 --- a/arch/arm64/include/asm/el2_setup.h +++ b/arch/arm64/include/asm/el2_setup.h @@ -72,6 +72,25 @@ .endif 3: + +.ifeqs "\mode", "nvhe" + /* + * If the Trace Buffer is available, allow + * the EL1 to own it. Note that EL1 cannot + * trace the EL2, as it is prevented by + * TRFCR_EL2.E2TRE == 0. + */ + ubfx x0, x1, #ID_AA64DFR0_TRBE_SHIFT, #4 + cbz x0, 1f + + mrs_s x0, SYS_TRBIDR_EL1 + and x0, x0, TRBIDR_PROG + cbnz x0, 1f + mov x0, #(MDCR_EL2_E2TB_EL1_OWN << MDCR_EL2_E2TB_SHIFT) + orr x2, x2, x0 +.endif + +1: msr mdcr_el2, x2 // Configure debug traps .endm diff --git a/arch/arm64/include/asm/kvm_arm.h b/arch/arm64/include/asm/kvm_arm.h index 4e90c2d..ed8b789 100644 --- a/arch/arm64/include/asm/kvm_arm.h +++ b/arch/arm64/include/asm/kvm_arm.h @@ -281,6 +281,8 @@ #define MDCR_EL2_TPMS (1 << 14) #define MDCR_EL2_E2PB_MASK (UL(0x3)) #define MDCR_EL2_E2PB_SHIFT (UL(12)) +#define MDCR_EL2_E2TB_EL1_OWN (UL(0x3)) +#define MDCR_EL2_E2TB_SHIFT (UL(24)) #define MDCR_EL2_TDRA (1 << 11) #define MDCR_EL2_TDOSA (1 << 10) #define MDCR_EL2_TDA (1 << 9) -- 2.7.4