aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwtracing
diff options
context:
space:
mode:
authorTomasz Nowicki <tnowicki@caviumnetworks.com>2018-09-20 15:18:00 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-09-25 14:09:18 -0400
commitb860801e3237ec4c74cf8de0be4816996757ae5c (patch)
treee80b40f0c22c108f1afeaaf1243e129c6ccec6aa /drivers/hwtracing
parentd4989fe88603367e5998af70ee638ae6790d42d1 (diff)
coresight: etm4x: Configure EL2 exception level when kernel is running in HYP
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 <tnowicki@caviumnetworks.com> Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/hwtracing')
-rw-r--r--drivers/hwtracing/coresight/coresight-etm4x.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/drivers/hwtracing/coresight/coresight-etm4x.c b/drivers/hwtracing/coresight/coresight-etm4x.c
index c1dcc7c289a5..b7379e9cfb30 100644
--- a/drivers/hwtracing/coresight/coresight-etm4x.c
+++ b/drivers/hwtracing/coresight/coresight-etm4x.c
@@ -28,6 +28,7 @@
28#include <linux/pm_runtime.h> 28#include <linux/pm_runtime.h>
29#include <asm/sections.h> 29#include <asm/sections.h>
30#include <asm/local.h> 30#include <asm/local.h>
31#include <asm/virt.h>
31 32
32#include "coresight-etm4x.h" 33#include "coresight-etm4x.h"
33#include "coresight-etm-perf.h" 34#include "coresight-etm-perf.h"
@@ -605,7 +606,7 @@ static void etm4_set_default_config(struct etmv4_config *config)
605 config->vinst_ctrl |= BIT(0); 606 config->vinst_ctrl |= BIT(0);
606} 607}
607 608
608static u64 etm4_get_access_type(struct etmv4_config *config) 609static u64 etm4_get_ns_access_type(struct etmv4_config *config)
609{ 610{
610 u64 access_type = 0; 611 u64 access_type = 0;
611 612
@@ -616,17 +617,26 @@ static u64 etm4_get_access_type(struct etmv4_config *config)
616 * Bit[13] Exception level 1 - OS 617 * Bit[13] Exception level 1 - OS
617 * Bit[14] Exception level 2 - Hypervisor 618 * Bit[14] Exception level 2 - Hypervisor
618 * Bit[15] Never implemented 619 * Bit[15] Never implemented
619 *
620 * Always stay away from hypervisor mode.
621 */ 620 */
622 access_type = ETM_EXLEVEL_NS_HYP; 621 if (!is_kernel_in_hyp_mode()) {
623 622 /* Stay away from hypervisor mode for non-VHE */
624 if (config->mode & ETM_MODE_EXCL_KERN) 623 access_type = ETM_EXLEVEL_NS_HYP;
625 access_type |= ETM_EXLEVEL_NS_OS; 624 if (config->mode & ETM_MODE_EXCL_KERN)
625 access_type |= ETM_EXLEVEL_NS_OS;
626 } else if (config->mode & ETM_MODE_EXCL_KERN) {
627 access_type = ETM_EXLEVEL_NS_HYP;
628 }
626 629
627 if (config->mode & ETM_MODE_EXCL_USER) 630 if (config->mode & ETM_MODE_EXCL_USER)
628 access_type |= ETM_EXLEVEL_NS_APP; 631 access_type |= ETM_EXLEVEL_NS_APP;
629 632
633 return access_type;
634}
635
636static u64 etm4_get_access_type(struct etmv4_config *config)
637{
638 u64 access_type = etm4_get_ns_access_type(config);
639
630 /* 640 /*
631 * EXLEVEL_S, bits[11:8], don't trace anything happening 641 * EXLEVEL_S, bits[11:8], don't trace anything happening
632 * in secure state. 642 * in secure state.
@@ -880,20 +890,10 @@ void etm4_config_trace_mode(struct etmv4_config *config)
880 890
881 addr_acc = config->addr_acc[ETM_DEFAULT_ADDR_COMP]; 891 addr_acc = config->addr_acc[ETM_DEFAULT_ADDR_COMP];
882 /* clear default config */ 892 /* clear default config */
883 addr_acc &= ~(ETM_EXLEVEL_NS_APP | ETM_EXLEVEL_NS_OS); 893 addr_acc &= ~(ETM_EXLEVEL_NS_APP | ETM_EXLEVEL_NS_OS |
894 ETM_EXLEVEL_NS_HYP);
884 895
885 /* 896 addr_acc |= etm4_get_ns_access_type(config);
886 * EXLEVEL_NS, bits[15:12]
887 * The Exception levels are:
888 * Bit[12] Exception level 0 - Application
889 * Bit[13] Exception level 1 - OS
890 * Bit[14] Exception level 2 - Hypervisor
891 * Bit[15] Never implemented
892 */
893 if (mode & ETM_MODE_EXCL_KERN)
894 addr_acc |= ETM_EXLEVEL_NS_OS;
895 else
896 addr_acc |= ETM_EXLEVEL_NS_APP;
897 897
898 config->addr_acc[ETM_DEFAULT_ADDR_COMP] = addr_acc; 898 config->addr_acc[ETM_DEFAULT_ADDR_COMP] = addr_acc;
899 config->addr_acc[ETM_DEFAULT_ADDR_COMP + 1] = addr_acc; 899 config->addr_acc[ETM_DEFAULT_ADDR_COMP + 1] = addr_acc;