Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp133541ybc; Mon, 18 Nov 2019 21:54:31 -0800 (PST) X-Google-Smtp-Source: APXvYqy4ZfAB1L/hRJm9wryjuXB7LeCZIIJgHsG3gMHt7JQnPpbTN+oF0NZrlup2nPmrlWcZ64I/ X-Received: by 2002:a17:906:7e08:: with SMTP id e8mr32624902ejr.199.1574142871132; Mon, 18 Nov 2019 21:54:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574142871; cv=none; d=google.com; s=arc-20160816; b=LKcr3JvBfpAF/Td/BUUaLh6wOAq/fbQEQYvw7EiIqBhyTkye5FE+hXXW97jt5mxP5O HttUAbCOsxEYW8t7eufRD6Rs7pRk1uOyeDbRfliln/Yjd9IE7cNR9UQjccgyvZmpgwka wYAaGv7ZIX13lmLLsiFIqupU9YWPX8tDFwSL986ozWmURlYRep9Ouvvac4qymCymB+cr qPXDUMsA3FkhY9oJ8wYyj5PmQyeHxIZ/IPcJatrefo4+4gG8hLGqTk0PhbW+0h0TWJbc c5OORj8XT5MtZp/Vs+C+iCud7LRrMWSADLE2KHFn+T6dIGVJFYoARoP00V1Ow3Y5sbZp pIYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=8vwtfiMeHy4/5j29fOTt0QRTy0JQaAiO5MfOla/WpDk=; b=zQspCHg+tbEbQ6AHJ8BVC5BzXHBc8jd+gbtDgo8KRamr+2NKePqMU3X3yhgI5DLUad MXYjYDug0j8potfbzAHnBskqNBOI2dmuap8+3dQTF3M59ZD/E9trHHkzT+rjeaRmwHwZ PKiicVp4xpPqk93eWGWf+NIUgxSd4k8OObqrQSWNhNgViM2rdhNnkPJYZNLtVlqt/63x 6uOK4CAXid14SEKqSwFAxvL39f3CqpDafZsoQ5/oJtiYcQW/qXGjp7X0xxB5Eur6IQbD 4L76AXNMzvYTR0RpuofInjhZeW5tBq4quLwb2Qpkqa1TVkwV5UBL+OFWdkCaAnjNWddY M+lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OgD03Zud; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c31si14312480eda.343.2019.11.18.21.54.07; Mon, 18 Nov 2019 21:54:31 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OgD03Zud; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731960AbfKSFwx (ORCPT + 99 others); Tue, 19 Nov 2019 00:52:53 -0500 Received: from mail.kernel.org ([198.145.29.99]:50676 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731212AbfKSFwv (ORCPT ); Tue, 19 Nov 2019 00:52:51 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 06A8F20862; Tue, 19 Nov 2019 05:52:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574142770; bh=tTpIGXVuqGrtRoD1ab8w5sMCyys71HtQw55eRKeWIeo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OgD03ZudjRa+rdYPP9+yILrk+ljysWemHC/Y6sRKuABd2N/hZW0TXDsFc3exPparv 8ksHFwM0C0oouBzumo8nuLrCkqmRhB4wBEBSjlk9CViWdWB1sG+swx5V2cTTli84sf EXQp/fbrpS4ZveY1/Tr81vUCNKwzAfOmO0Sz7W1s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tomasz Nowicki , Mathieu Poirier , Sasha Levin Subject: [PATCH 4.14 194/239] coresight: etm4x: Configure EL2 exception level when kernel is running in HYP Date: Tue, 19 Nov 2019 06:19:54 +0100 Message-Id: <20191119051335.880239322@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191119051255.850204959@linuxfoundation.org> References: <20191119051255.850204959@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tomasz Nowicki [ Upstream commit b860801e3237ec4c74cf8de0be4816996757ae5c ] For non-VHE systems host kernel runs at EL1 and jumps to EL2 whenever hypervisor code should be executed. In this case ETM4x driver must restrict configuration to EL1 when it setups kernel tracing. However, there is no separate hypervisor privilege level when VHE is enabled, the host kernel runs at EL2. This patch fixes configuration of TRCACATRn register for VHE systems so that ETM_EXLEVEL_NS_HYP bit is used instead of ETM_EXLEVEL_NS_OS to on/off kernel tracing. At the same time, it moves common code to new helper. Signed-off-by: Tomasz Nowicki Signed-off-by: Mathieu Poirier Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/hwtracing/coresight/coresight-etm4x.c | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-etm4x.c b/drivers/hwtracing/coresight/coresight-etm4x.c index b0141ba7b7414..fb392688281b5 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x.c +++ b/drivers/hwtracing/coresight/coresight-etm4x.c @@ -35,6 +35,7 @@ #include #include #include +#include #include "coresight-etm4x.h" #include "coresight-etm-perf.h" @@ -623,7 +624,7 @@ static void etm4_set_default_config(struct etmv4_config *config) config->vinst_ctrl |= BIT(0); } -static u64 etm4_get_access_type(struct etmv4_config *config) +static u64 etm4_get_ns_access_type(struct etmv4_config *config) { u64 access_type = 0; @@ -634,17 +635,26 @@ static u64 etm4_get_access_type(struct etmv4_config *config) * Bit[13] Exception level 1 - OS * Bit[14] Exception level 2 - Hypervisor * Bit[15] Never implemented - * - * Always stay away from hypervisor mode. */ - access_type = ETM_EXLEVEL_NS_HYP; - - if (config->mode & ETM_MODE_EXCL_KERN) - access_type |= ETM_EXLEVEL_NS_OS; + if (!is_kernel_in_hyp_mode()) { + /* Stay away from hypervisor mode for non-VHE */ + access_type = ETM_EXLEVEL_NS_HYP; + if (config->mode & ETM_MODE_EXCL_KERN) + access_type |= ETM_EXLEVEL_NS_OS; + } else if (config->mode & ETM_MODE_EXCL_KERN) { + access_type = ETM_EXLEVEL_NS_HYP; + } if (config->mode & ETM_MODE_EXCL_USER) access_type |= ETM_EXLEVEL_NS_APP; + return access_type; +} + +static u64 etm4_get_access_type(struct etmv4_config *config) +{ + u64 access_type = etm4_get_ns_access_type(config); + /* * EXLEVEL_S, bits[11:8], don't trace anything happening * in secure state. @@ -898,20 +908,10 @@ void etm4_config_trace_mode(struct etmv4_config *config) addr_acc = config->addr_acc[ETM_DEFAULT_ADDR_COMP]; /* clear default config */ - addr_acc &= ~(ETM_EXLEVEL_NS_APP | ETM_EXLEVEL_NS_OS); + addr_acc &= ~(ETM_EXLEVEL_NS_APP | ETM_EXLEVEL_NS_OS | + ETM_EXLEVEL_NS_HYP); - /* - * EXLEVEL_NS, bits[15:12] - * The Exception levels are: - * Bit[12] Exception level 0 - Application - * Bit[13] Exception level 1 - OS - * Bit[14] Exception level 2 - Hypervisor - * Bit[15] Never implemented - */ - if (mode & ETM_MODE_EXCL_KERN) - addr_acc |= ETM_EXLEVEL_NS_OS; - else - addr_acc |= ETM_EXLEVEL_NS_APP; + addr_acc |= etm4_get_ns_access_type(config); config->addr_acc[ETM_DEFAULT_ADDR_COMP] = addr_acc; config->addr_acc[ETM_DEFAULT_ADDR_COMP + 1] = addr_acc; -- 2.20.1