Skip to contentSkip to conversation

coresight: trbe: Move check for kernel page table isolation from EL0 to probe

PATCH In review Sudeep Holla 3 participants 3 messages Feb 3, 2022 – Feb 4, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 coresight: trbe: Move check for kernel page table isolation from EL0 to probe

Currently with the check present in the module initialisation, it shouts on all the systems irrespective of presence of coresight trace buffer extensions.

Similar to Arm SPE perf driver, move the check for kernel page table isolation from EL0 to the device probe stage instead of the module initialisation so that it complains only on the systems that support TRBE.

Cc Mathieu Poirier <[email protected]>
Cc Suzuki K Poulose <[email protected]>
Cc Mike Leach <[email protected]>
Cc Leo Yan <[email protected]>
Cc Anshuman Khandual <[email protected]>
---
 drivers/hwtracing/coresight/coresight-trbe.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

v1[1]->v2:
- Added comment about trace capture being not possible with kernel page table isolation
[1] https://lore.kernel.org/r/[email protected]

drivers/hwtracing/coresight/coresight-trbe.c +6 -5
index 276862c07e32..3e37a63cb7d2 100644
@@ -1423,6 +1423,12 @@ static int arm_trbe_device_probe(struct platform_device *pdev)
 	struct device *dev = &pdev->dev;
 	int ret;
 
+	/* Trace capture is not possible with kernel page table isolation */
+	if (arm64_kernel_unmapped_at_el0()) {
+		pr_err("TRBE wouldn't work if kernel gets unmapped at EL0\n");
+		return -EOPNOTSUPP;
+	}
+
 	drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
 	if (!drvdata)
 		return -ENOMEM;
@@ -1484,11 +1490,6 @@ static int __init arm_trbe_init(void)
 {
 	int ret;
 
-	if (arm64_kernel_unmapped_at_el0()) {
-		pr_err("TRBE wouldn't work if kernel gets unmapped at EL0\n");
-		return -EOPNOTSUPP;
-	}
-
 	ret = platform_driver_register(&arm_trbe_driver);
 	if (!ret)
 		return 0;
Signature · 1 line
2.25.1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 44 lines · Sudeep Holla

Currently with the check present in the module initialisation, it shouts on all the systems irrespective of presence of coresight trace buffer extensions.

Similar to Arm SPE perf driver, move the check for kernel page table isolation from EL0 to the device probe stage instead of the module initialisation so that it complains only on the systems that support TRBE.

Cc Mathieu Poirier <[email protected]>
Cc Suzuki K Poulose <[email protected]>
Cc Mike Leach <[email protected]>
Cc Leo Yan <[email protected]>
Cc Anshuman Khandual <[email protected]>
---
 drivers/hwtracing/coresight/coresight-trbe.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

v1[1]->v2:
- Added comment about trace capture being not possible with kernel page table isolation
[1] https://lore.kernel.org/r/[email protected]

drivers/hwtracing/coresight/coresight-trbe.c +6 -0
index 276862c07e32..3e37a63cb7d2 100644
@@ -1423,6 +1423,12 @@ static int arm_trbe_device_probe(struct platform_device *pdev)
 	struct device *dev = &pdev->dev;
 	int ret;
 
+	/* Trace capture is not possible with kernel page table isolation */
+	if (arm64_kernel_unmapped_at_el0()) {
+		pr_err("TRBE wouldn't work if kernel gets unmapped at EL0\n");
+		return -EOPNOTSUPP;
+	}
+
 	drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
 	if (!drvdata)
 		return -ENOMEM;
@@ -1484,11 +1490,6 @@ static int __init arm_trbe_init(void)
 {

drivers/hwtracing/coresight/coresight-trbe.c static int __init arm_trbe_init(void) · line 1495

Quoted 10 lines
drivers/hwtracing/coresight/coresight-trbe.c +0 -5
 	int ret;
 
-	if (arm64_kernel_unmapped_at_el0()) {
-		pr_err("TRBE wouldn't work if kernel gets unmapped at EL0\n");
-		return -EOPNOTSUPP;
-	}
-
 	ret = platform_driver_register(&arm_trbe_driver);
 	if (!ret)
 		return 0;
maintainer
#2 lore raw
In reply to Sudeep Holla
Quoted 8 lines · Sudeep Holla

Currently with the check present in the module initialisation, it shouts on all the systems irrespective of presence of coresight trace buffer extensions.

Similar to Arm SPE perf driver, move the check for kernel page table isolation from EL0 to the device probe stage instead of the module initialisation so that it complains only on the systems that support TRBE.

Quoted 7 lines
Cc Mathieu Poirier <[email protected]>
Cc Suzuki K Poulose <[email protected]>
Cc Mike Leach <[email protected]>
Cc Leo Yan <[email protected]>
Cc Anshuman Khandual <[email protected]>

Thanks, I have now queued this.

https://git.kernel.org/coresight/c/ebbce265bba164c4f0d5271c277a540bd3b2fd3c

Kind regards
Suzuki