Merge tag 'pci-v5.18-changes-2' of git://git.kernel.org/pub/scm/linux/kernel/git...
[sfrench/cifs-2.6.git] / drivers / hwtracing / coresight / coresight-etm4x-core.c
index bf18128cf5ded1a51c9460644326c6619cd47006..7f416a12000eb653ef2199dfe87696eb5658e021 100644 (file)
@@ -656,7 +656,9 @@ static int etm4_parse_event_config(struct coresight_device *csdev,
                config->cfg |= BIT(11);
        }
 
-       if (attr->config & BIT(ETM_OPT_CTXTID))
+       /* Only trace contextID when runs in root PID namespace */
+       if ((attr->config & BIT(ETM_OPT_CTXTID)) &&
+           task_is_in_init_pid_ns(current))
                /* bit[6], Context ID tracing bit */
                config->cfg |= BIT(ETM4_CFG_BIT_CTXTID);
 
@@ -670,7 +672,11 @@ static int etm4_parse_event_config(struct coresight_device *csdev,
                        ret = -EINVAL;
                        goto out;
                }
-               config->cfg |= BIT(ETM4_CFG_BIT_VMID) | BIT(ETM4_CFG_BIT_VMID_OPT);
+
+               /* Only trace virtual contextID when runs in root PID namespace */
+               if (task_is_in_init_pid_ns(current))
+                       config->cfg |= BIT(ETM4_CFG_BIT_VMID) |
+                                      BIT(ETM4_CFG_BIT_VMID_OPT);
        }
 
        /* return stack - enable if selected and supported */
@@ -1091,7 +1097,7 @@ static void etm4_init_arch_data(void *info)
        etmidr0 = etm4x_relaxed_read32(csa, TRCIDR0);
 
        /* INSTP0, bits[2:1] P0 tracing support field */
-       if (BMVAL(etmidr0, 1, 1) && BMVAL(etmidr0, 2, 2))
+       if (BMVAL(etmidr0, 1, 2) == 0b11)
                drvdata->instrp0 = true;
        else
                drvdata->instrp0 = false;