The helper task_is_in_root_ns() has been merged into the mainline kernel
(thanks Jakub Kicinski for merging the patches [1]).
On the other hand, there have 5 patches were left out in the patch
series v2 [2], this patch series is to resend these 5 patches so that
sub-module maintainers could pick patches without concerning dependency
issue.
This patch series can be cleanly applied on the mainline kernel with
latest commit dcb85f85fa6f ("gcc-plugins/stackleak: Use noinstr in favor
of notrace").
[1] https://lore.kernel.org/lkml/20220126050427.605628-1-leo.yan@linaro.org/
[2] https://lore.kernel.org/lkml/20211208083320.472503-1-leo.yan@linaro.org/
Changes from v2:
* Added review and ack tags.
* Dropped two merged patches and resend the left 5 patches.
Changes from v1:
* Renamed helper function from task_is_in_root_ns() to
task_is_in_init_pid_ns(). (Leon Romanovsky)
* Improved patches' commit logs for more neat.
Leo Yan (5):
coresight: etm3x: Use task_is_in_init_pid_ns()
coresight: etm4x: Use task_is_in_init_pid_ns()
coda: Use task_is_in_init_pid_ns()
audit: Use task_is_in_init_pid_ns()
taskstats: Use task_is_in_init_pid_ns()
drivers/hwtracing/coresight/coresight-etm3x-sysfs.c | 8 ++++----
drivers/hwtracing/coresight/coresight-etm4x-sysfs.c | 8 ++++----
fs/coda/inode.c | 2 +-
fs/coda/psdev.c | 2 +-
kernel/audit.c | 2 +-
kernel/taskstats.c | 2 +-
6 files changed, 12 insertions(+), 12 deletions(-)
--
2.25.1
On 03/02/2022 19:01, Sudeep Holla wrote:
> 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 <mathieu.poirier(a)linaro.org>
> Cc: Suzuki K Poulose <suzuki.poulose(a)arm.com>
> Cc: Mike Leach <mike.leach(a)linaro.org>
> Cc: Leo Yan <leo.yan(a)linaro.org>
> Cc: Anshuman Khandual <anshuman.khandual(a)arm.com>
> Cc: coresight(a)lists.linaro.org
> Signed-off-by: Sudeep Holla <sudeep.holla(a)arm.com>
Thanks, I have now queued this.
https://git.kernel.org/coresight/c/ebbce265bba164c4f0d5271c277a540bd3b2fd3c
Kind regards
Suzuki
While working on the branch broadcast change I found it difficult to search
for usages of registers and fields because of the magic numbers. I also
found it difficult to decide which style to make new code in because of the
varying ones used.
There was also a code review comment from Suzuki about replacing a magic
number so I'm proposing to refactor as many as possible into the style used
in sysreg.h which seems to be the new and most consistently used method.
For example it was used in the SPE and TRBE drivers.
This isn't an exhaustive refactor, but it does get all the basic accesses.
There are a couple of odd other cases remaining, mainly in the ETM3x code.
These can be found by searching for BMVAL.
There is one compromise to ensure this is a complete no-op and has
binary equivalence with the old version. I needed to keep two register
accesses here, where something like etmidr0 & TRCIDR0_INSTP0_LOAD_STORE
would be better:
- if (BMVAL(etmidr0, 1, 1) && BMVAL(etmidr0, 2, 2))
- drvdata->instrp0 = true;
- else
- drvdata->instrp0 = false;
-
+ drvdata->instrp0 = !!((REG_VAL(etmidr0, TRCIDR0_INSTP0) & 0b01) &&
+ (REG_VAL(etmidr0, TRCIDR0_INSTP0) & 0b10));
I think this change fixes quite a few issues like:
* Some registers aren't referred to by name but a different variable name.
For example eventctrl1 in mode_store() where TRCEVENTCTL1R isn't
mentioned in that function.
* Some bits aren't referred to by the name in the manual, even in the
comments. For example TRCCONFIGR.RS only occurs as /* bit[12], Return
stack enable bit */.
* Some bits in the same register are referred to either as magic numbers
or the publicly exported config macros, neiher of which are consistent
with any other register accesses. For example
config->cfg |= BIT(11);
config->cfg |= BIT(ETM4_CFG_BIT_CTXTID);
* Some fields are already partially referred to in the sysfs.h style way:
TRCVICTLR_EXLEVEL_... etc. But other fields in the same register are not
* Some fields are magic numbers that are repeated many times in different
functions. For example vinst_ctrl |= BIT(9)
* Some fields were referred to by magic numbers, even when there were
already existing #defines. For example ETMTECR1_INC_EXC
* Another benefit is that the #defines could be automatically checked
against the reference manual because the style is uniform.
Testing
=======
To test this I used gcc-11 which doesn't have a quirk about changing
register widths in some cases (as in w -> x). I also used elf_diff which
showed me exactly where I'd made a mistake when I did
(https://github.com/noseglasses/elf_diff). But now that there is no
difference, objdump and diff also work for validation.
make CC=gcc-11 modules
diff <(objdump -d drivers/hwtracing/coresight/coresight-etm4x.ko) <(objdump -d ../linux2/drivers/hwtracing/coresight/coresight-etm4x.ko)
diff <(objdump -d drivers/hwtracing/coresight/coresight.ko) <(objdump -d ../linux2/drivers/hwtracing/coresight/coresight.ko)
And for ETM3x (doesn't need gcc 11):
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- modules
diff <(objdump -d drivers/hwtracing/coresight/coresight-etm3x.ko) <(objdump -d ../linux2/drivers/hwtracing/coresight/coresight-etm3x.ko)
When there are no differences, the diff output looks like this with only
the filename listed:
< drivers/hwtracing/coresight/coresight-etm4x.ko: file format elf64-littleaarch64
---
> ../linux2/drivers/hwtracing/coresight/coresight-etm4x.ko: file format elf64-littleaarch64
Applies to coresight/next 30d1f1c71b
James Clark (15):
coresight: Make ETM4x TRCIDR0 register accesses consistent with
sysreg.h
coresight: Make ETM4x TRCIDR2 register accesses consistent with
sysreg.h
coresight: Make ETM4x TRCIDR3 register accesses consistent with
sysreg.h
coresight: Make ETM4x TRCIDR4 register accesses consistent with
sysreg.h
coresight: Make ETM4x TRCIDR5 register accesses consistent with
sysreg.h
coresight: Make ETM4x TRCCONFIGR register accesses consistent with
sysreg.h
coresight: Make ETM4x TRCEVENTCTL1R register accesses consistent with
sysreg.h
coresight: Make ETM4x TRCSTALLCTLR register accesses consistent with
sysreg.h
coresight: Make ETM4x TRCVICTLR register accesses consistent with
sysreg.h
coresight: Make ETM3x ETMTECR1 register accesses consistent with
sysreg.h
coresight: Make ETM4x TRCACATRn register accesses consistent with
sysreg.h
coresight: Make ETM4x TRCSSCCRn and TRCSSCSRn register accesses
consistent with sysreg.h
coresight: Make ETM4x TRCSSPCICRn register accesses consistent with
sysreg.h
coresight: Make ETM4x TRCBBCTLR register accesses consistent with
sysreg.h
coresight: Make ETM4x TRCRSCTLRn register accesses consistent with
sysreg.h
.../coresight/coresight-etm3x-core.c | 2 +-
.../coresight/coresight-etm3x-sysfs.c | 2 +-
.../coresight/coresight-etm4x-core.c | 135 +++++--------
.../coresight/coresight-etm4x-sysfs.c | 178 +++++++++---------
drivers/hwtracing/coresight/coresight-etm4x.h | 159 ++++++++++++++--
drivers/hwtracing/coresight/coresight-priv.h | 1 +
6 files changed, 283 insertions(+), 194 deletions(-)
--
2.28.0
On 03/02/2022 12:04, Sudeep Holla wrote:
> On Thu, Feb 03, 2022 at 11:55:58AM +0530, Anshuman Khandual wrote:
>>
>>
>> On 2/1/22 5:52 PM, Sudeep Holla wrote:
>>> Currently with the check present in the module initialisation, it shouts
>>> on all the systems irrespective of presence of coresight trace buffer
>>> extensions.
>>
>> IIUC a system with CONFIG_CORESIGHT_TRBE enabled but without a TRBE DT
>> i.e "arm,trace-buffer-extension" complains about kernel space unmapping
>> at EL0 (even though it does not even really have TRBE HW to initialize).
>
>
> Correct. Basically, this error will be seen on all systems(DT and ACPI) when
> the module is compiled. It really doesn't matter if the system supports TRBE.
>
>>>
>>> Similar to Arm SPE perf driver, move the check for kernelspace unmapping
>>> when running at EL0 to the device probe instead of module initialisation.
>>
>> Makes sense.
>>
>
> Thanks.
>
>>>
>>> Cc: Mathieu Poirier <mathieu.poirier(a)linaro.org>
>>> Cc: Suzuki K Poulose <suzuki.poulose(a)arm.com>
>>> Cc: Mike Leach <mike.leach(a)linaro.org>
>>> Cc: Leo Yan <leo.yan(a)linaro.org>
>>> Cc: Anshuman Khandual <anshuman.khandual(a)arm.com>
>>> Cc: coresight(a)lists.linaro.org
>>> Signed-off-by: Sudeep Holla <sudeep.holla(a)arm.com>
>>> ---
>>> drivers/hwtracing/coresight/coresight-trbe.c | 10 +++++-----
>>> 1 file changed, 5 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/drivers/hwtracing/coresight/coresight-trbe.c b/drivers/hwtracing/coresight/coresight-trbe.c
>>> index 276862c07e32..3fe2ce1ba5bf 100644
>>> --- a/drivers/hwtracing/coresight/coresight-trbe.c
>>> +++ b/drivers/hwtracing/coresight/coresight-trbe.c
>>> @@ -1423,6 +1423,11 @@ static int arm_trbe_device_probe(struct platform_device *pdev)
>>> struct device *dev = &pdev->dev;
>>> int ret;
>>>
>>
>> Could you please add a similar comment like SPE driver regarding how
>> the TRBE buffer will be inaccessible, if kernel gets unmapped at EL0
>> and trace capture will terminate.
>>
>
> Sure I can add that. But if the device probe fails, will you be able to even
> start the trace capture, sorry I didn't get what you mean by "trace capture
> will terminate". I assume it must be "trace capture is not possible or not
> allowed" IIUC.
>
"Trace capture is not possible with kernel page table isolation"
is good enough.
Thanks for making these changes
Cheers
Suzuki
In preparation for the bigger register refactor, simplify one of the
accesses otherwise it looked even more obfuscated after the refactor.
This can't be included in the main set because it causes a small change
in the binary, although functionally this refactor is also a no-op.
Applies to coresight/next 30d1f1c71b
James Clark (1):
coresight: no-op refactor to make INSTP0 check more idiomatic
drivers/hwtracing/coresight/coresight-etm4x-core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--
2.28.0
This set extends the configfs support to allow loading and unloading of
configurations as binary files via configfs.
Additional attributes - load, unload and last_load_status are provided to
implement the load functionality.
Routines to generate binary configuration files are supplied in
./samples/coresight.
Example generator and reader applications are provided.
Additional Makefile.host supplied to build the generator and reader
applications on the host system separate from a cross compiled kernel.
Documentation is updated to describe feature usage.
Applies and tested on latest coresight/next that includes the
previous coresight configuration dynamic load patchset.
Changes since v1:
1) Rebased to coresight/next - 5.16-rc1 with previous coresight config
set applied.
2) Makefile.host fixed to default to all target.
Mike Leach (6):
coresight: configfs: Add in functionality for load via configfs
coresight: configfs: Add in binary attributes to load files
coresight: configfs: Modify config files to allow userspace use
coresight: samples: Add an example config writer for configfs load
coresight: samples: Add coresight file reader sample program
Documentation: coresight: docs for config load via configfs
.../trace/coresight/coresight-config.rst | 151 +++++-
drivers/hwtracing/coresight/Makefile | 2 +-
.../coresight/coresight-config-file.c | 472 ++++++++++++++++++
.../coresight/coresight-config-file.h | 158 ++++++
.../hwtracing/coresight/coresight-config.h | 38 ++
.../coresight/coresight-syscfg-configfs.c | 148 +++++-
.../coresight/coresight-syscfg-configfs.h | 8 +
.../hwtracing/coresight/coresight-syscfg.c | 36 ++
.../hwtracing/coresight/coresight-syscfg.h | 2 +
samples/coresight/Makefile | 23 +
samples/coresight/Makefile.host | 47 ++
samples/coresight/coresight-cfg-bufw.c | 302 +++++++++++
samples/coresight/coresight-cfg-bufw.h | 24 +
samples/coresight/coresight-cfg-file-read.c | 191 +++++++
samples/coresight/coresight-cfg-filegen.c | 89 ++++
15 files changed, 1677 insertions(+), 14 deletions(-)
create mode 100644 drivers/hwtracing/coresight/coresight-config-file.c
create mode 100644 drivers/hwtracing/coresight/coresight-config-file.h
create mode 100644 samples/coresight/Makefile.host
create mode 100644 samples/coresight/coresight-cfg-bufw.c
create mode 100644 samples/coresight/coresight-cfg-bufw.h
create mode 100644 samples/coresight/coresight-cfg-file-read.c
create mode 100644 samples/coresight/coresight-cfg-filegen.c
--
2.17.1
On Mon, Jan 24, 2022 at 12:41:21PM +0000, Miaoqian Lin wrote:
> device_register() calls device_initialize(),
> according to doc of device_initialize:
>
> Use put_device() to give up your reference instead of freeing
> * @dev directly once you have called this function.
>
> To prevent potential memleak, use put_device() for error handling.
>
> Signed-off-by: Miaoqian Lin <linmq006(a)gmail.com>
> ---
> Changes in v2:
> - simply call put_device() instead of cscfg_dev_release() in the error
> path of cscfg_create_device.
> ---
> drivers/hwtracing/coresight/coresight-syscfg.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/hwtracing/coresight/coresight-syscfg.c b/drivers/hwtracing/coresight/coresight-syscfg.c
> index 43054568430f..c30989e0675f 100644
> --- a/drivers/hwtracing/coresight/coresight-syscfg.c
> +++ b/drivers/hwtracing/coresight/coresight-syscfg.c
> @@ -791,7 +791,7 @@ static int cscfg_create_device(void)
>
> err = device_register(dev);
> if (err)
> - cscfg_dev_release(dev);
> + put_device(dev);
Applied.
Thanks,
Mathieu
>
> create_dev_exit_unlock:
> mutex_unlock(&cscfg_mutex);
> --
> 2.17.1
>
Changes since v1:
* Add Mike's reviewed by tag
* Also make it impossible to write the reserved value of 0b10, regardless
of what is supplied by the user.
James Clark (1):
coresight: Fix TRCCONFIGR.QE sysfs interface
drivers/hwtracing/coresight/coresight-etm4x-sysfs.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
--
2.28.0