From patchwork Tue Sep 4 14:20:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Nowicki X-Patchwork-Id: 10587387 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 754F3920 for ; Tue, 4 Sep 2018 14:22:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 616482993B for ; Tue, 4 Sep 2018 14:22:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5531529947; Tue, 4 Sep 2018 14:22:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9586E2993B for ; Tue, 4 Sep 2018 14:22:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=hDQkSX1VYVlwp43NNJt6f4oZpkqUp1+dY84Ct+sOtfs=; b=NT8rPiQzdAILZe yWktQzwOr0UthmhdAGIz8I+/1IKgHRRnpYjlgzLhTvnqSK74Q8qqVniWXNSAWwCw0wdlmtc/wS9as nxEunmepwA+Y4qEnfjimdZWv4XawzSnhb+Ch040hX4pNBFYPCj0rWn+qX7GUbiB1cU6m9TIOlW+do +MAc8fW8mdwgzqij5wGFElDiqoozKtECjCBuSxBCqKXnzOBeoW8eXhFaJf/luF3KYZoUc5rlYZeCg ktpDnXimMl4lLlevuxdM9vlMun3ZJPx58tNFXFDjeY46rzAlUUCHbnlquOzId4hvBIbiWJaj7gBea ANQB7ddGUOm4pf2mCJ1Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fxCDR-0002e1-Ib; Tue, 04 Sep 2018 14:22:01 +0000 Received: from mail-eopbgr710046.outbound.protection.outlook.com ([40.107.71.46] helo=NAM05-BY2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fxCCy-0002O1-Fc for linux-arm-kernel@lists.infradead.org; Tue, 04 Sep 2018 14:21:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZnQIZ8TypOamw+pd/TBUbRoil+bgC+/r9YIHxtSWaFM=; b=oLxz5IbKOUNRsbQsGpTzj9F0MUhJ4NoAc20r41xbI8BfYKivg9+oBszK3L0DNgtGeiTVusyungXrLLzv5u8rRxc3eRdzAI9m5Lk1mf9eij3LwZT/C7zg2w+UPvqM8QkOdkgtjKXsfgIqWBcFgZC80OjuLjF45kd2V1MIsDnpIN4= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Tomasz.Nowicki@cavium.com; Received: from camailhost1.cavium.com (80.244.146.33) by BN7PR07MB5170.namprd07.prod.outlook.com (2603:10b6:408:25::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1080.17; Tue, 4 Sep 2018 14:21:16 +0000 From: Tomasz Nowicki To: mathieu.poirier@linaro.org, alexander.shishkin@linux.intel.com Subject: [PATCH 1/1] coresight: etm4x: Configure EL2 exception level when kernel is running in HYP Date: Tue, 4 Sep 2018 16:20:34 +0200 Message-Id: <20180904142034.19116-1-tnowicki@caviumnetworks.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Originating-IP: [80.244.146.33] X-ClientProxiedBy: DM5PR07CA0104.namprd07.prod.outlook.com (2603:10b6:4:ae::33) To BN7PR07MB5170.namprd07.prod.outlook.com (2603:10b6:408:25::23) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 87ecbe57-2c4d-4caa-ec99-08d61271aeae X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:BN7PR07MB5170; X-Microsoft-Exchange-Diagnostics: 1; BN7PR07MB5170; 3:hNrQRW1ITcI635uTJHSwPK8bSRY+WDCFNDnB1Ytwq29zvQPL3zzkt+xhBwK5R0aRdyf40NNCukc0XOdNOAqfaMKHfrSX/IfVKVrLHJXvsGpQqqVBfe6zDW5+YHvw0iRZZSvkPkoLblKhVBdKH4M8NSkrW/Arki92jvAeZQrzKIYmm5bGS6VoFzCgOdw0CMhv4c09aXBj+uokgSvyrVO/GPj5HcMsi4S1r1HcvsVjVF4lt6kyuv8Xh7Rkk4ytzbC8; 25:4Wjh8jME3xvRoEI6nQYzNpwigDDSDJ0KG87vy0bjj3m6C1y3QG/9qMBAgzr582XzESbBYz+6+foMOQe7y8kq8Yri6zUca25y7s9zW0B24TTACpTJVZLzjV+oJxWmEh8h+W4xDMUbgx7gek+sg4CAPxgranH42BUr3/jNE8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FxjjSYN+nhSo=; 4:IUEqQtlsNCjr/Nt8eoWiZieNHch6ugoKKBLzxnVzbsd8Cw+gflOoamK7NcXcTRWYt/ReQC0s67t3QVM+Zcx/le33dK8e8GlfHapx+xpu1DPYwSvVLn9wCfzrk0vGRAqHhtayP+oOS3H/xqez+4MeCjwJX4f48DBk138qELYUkmXtK+RgXz1hRqoJ2q6H6feV4NTzQ35HoWSEc+QzvO/YhuTCfFn/cPB9zJwyi+aGSsWNPtj75BHGH5ImRfc3v38XTzyy5LDvAao0U8mhmo96zw== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(93006095)(10201501046)(3231311)(944501410)(52105095)(3002001)(149027)(150027)(6041310)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123558120)(20161123562045)(201708071742011)(7699016); SRVR:BN7PR07MB5170; BCL:0; PCL:0; RULEID:; SRVR:BN7PR07MB5170; X-Forefront-PRVS: 0785459C39 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(366004)(396003)(376002)(346002)(136003)(39860400002)(199004)(189003)(8676002)(476003)(81156014)(72206003)(2906002)(1076002)(66066001)(48376002)(486006)(4326008)(14444005)(47776003)(2616005)(16586007)(478600001)(50466002)(5660300001)(956004)(316002)(107886003)(81166006)(42882007)(305945005)(50226002)(6486002)(36756003)(7736002)(186003)(8936002)(68736007)(575784001)(6512007)(16526019)(25786009)(386003)(3846002)(97736004)(6116002)(69596002)(53936002)(53416004)(106356001)(52116002)(51416003)(6666003)(105586002)(6506007)(26005)(32563001); DIR:OUT; SFP:1101; SCL:1; SRVR:BN7PR07MB5170; H:camailhost1.cavium.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted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7DsSPzFUAIePXHf61u/z2Ik3vDmiUJ1Pq2poUIbKOQ9CbhR8JnEjkaHd7URqw60tzBmDMAWg==; 5:8dMImkmzXbsbO8Jbq7a/3m0yesDHkakiNXtLbOmIdfxkl+L/0q+iFZni6cMATIaGXkv0qYsWefRxFBSJ5n/FfRXqDekPC+ScAXgtCLsAnYIfeIZNGD5SQINPKg/SOFAN7pKG+Tlb/ka14TOo2KGxvw75l6vKCCdFipBJxjKo/Mk=; 7:BffS+B0ejxbuNpeO7gWIh1WCp+sc/TbGYDiUKta7emDkQpHWxZXV1QeB6SOEtZQA7AcmVz7bUJuDdMD2fx7tHDx6Ag+B2enMoiDQG2hWwJk8TznQ87aa9jmw93JJZFpDg2dYrcnRMKOD6Dfa9R3+BVP/y8dlMr3x9Pyp+695Fckd3lATouxFszNNpZoZ7PFMTYIc8NtXWilcWz7WrEA7XnSSat2HBOvCAZfiWq5jfwEbTcLnym1gyyJG0mU7Oqen SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Sep 2018 14:21:16.9372 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 87ecbe57-2c4d-4caa-ec99-08d61271aeae X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN7PR07MB5170 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180904_072132_574423_340B13BD X-CRM114-Status: GOOD ( 12.87 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jayachandran.Nair@cavium.com, Tomasz Nowicki , coresight@lists.linaro.org, linux@armlinux.org.uk, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- drivers/hwtracing/coresight/coresight-etm4x.c | 39 ++++++++++--------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-etm4x.c b/drivers/hwtracing/coresight/coresight-etm4x.c index f79b0ea85d76..5f495c942f99 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x.c +++ b/drivers/hwtracing/coresight/coresight-etm4x.c @@ -28,6 +28,7 @@ #include #include #include +#include #include "coresight-etm4x.h" #include "coresight-etm-perf.h" @@ -606,7 +607,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; @@ -617,17 +618,27 @@ 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. @@ -881,20 +892,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;