This is a combination of the RFC for nVHE here [1] and v3 of VHE version
here [2]. After a few of the review comments it seemed much simpler for
both versions to use the same interface and be in the same patchset.
FEAT_TRF is a Coresight feature that allows trace capture to be
completely filtered at different exception levels, unlike the existing
TRCVICTLR controls which may still emit target addresses of branches,
even if the following trace is filtered.
Without FEAT_TRF, it was possible to start a trace session on a host and
also collect trace from the guest as TRCVICTLR was never programmed to
exclude guests (and it could still emit target addresses even if it
was).
With FEAT_TRF, the current behavior of trace in guests exists depends on
whether nVHE or VHE are being used. Both of the examples below are from
the host's point of view, as Coresight isn't accessible from guests.
This patchset is only relevant to when FEAT_TRF exists, otherwise there
is no change.
nVHE:
Because the host and the guest are both using TRFCR_EL1, trace will be
generated in guests depending on the same filter rules the host is
using. For example if the host is tracing userspace only, then guest
userspace trace will also be collected.
(This is further limited by whether TRBE is used because an issue
with TRBE means that it's completely disabled in nVHE guests, but it's
possible to have other tracing components.)
VHE:
With VHE, the host filters will be in TRFCR_EL2, but the filters in
TRFCR_EL1 will be active when the guest is running. Because we don't
write to TRFCR_EL1, guest trace will be completely disabled.
With this change, the guest filtering rules from the Perf session are
honored for both nVHE and VHE modes. This is done by either writing to
TRFCR_EL12 at the start of the Perf session and doing nothing else
further, or caching the guest value and writing it at guest switch for
nVHE.
The first commit moves the register to sysreg because I add the EL12
version.
---
Changes since V2:
* Add a new iflag to signify presence of FEAT_TRF and keep the
existing TRBE iflag. This fixes the issue where TRBLIMITR_EL1 was
being accessed even if TRBE didn't exist
* Reword a commit message
Changes since V1:
* Squashed all the arm64/tools/sysreg changes into the first commit
* Add a new commit to move SPE and TRBE regs into the kvm sysreg array
* Add a comment above the TRFCR global that it's per host CPU rather
than vcpu
Changes since nVHE RFC [1]:
* Re-write just in terms of the register value to be written for the
host and the guest. This removes some logic from the hyp code and
a value of kvm_vcpu_arch:trfcr_el1 = 0 no longer means "don't
restore".
* Remove all the conditional compilation and new files.
* Change the kvm_etm_update_vcpu_events macro to a function.
* Re-use DEBUG_STATE_SAVE_TRFCR so iflags don't need to be expanded
anymore.
* Expand the cover letter.
Changes since VHE v3 [2]:
* Use the same interface as nVHE mode so TRFCR_EL12 is now written by
kvm.
[1]: https://lore.kernel.org/kvmarm/20230804101317.460697-1-james.clark@arm.com/
[2]: https://lore.kernel.org/kvmarm/20230905102117.2011094-1-james.clark@arm.com/
James Clark (6):
arm64/sysreg: Move TRFCR definitions to sysreg
arm64: KVM: Move SPE and trace registers to the sysreg array
arm64: KVM: Add iflag for FEAT_TRF
arm64: KVM: Add interface to set guest value for TRFCR register
arm64: KVM: Write TRFCR value on guest switch with nVHE
coresight: Pass guest TRFCR value to KVM
arch/arm64/include/asm/kvm_host.h | 13 +--
arch/arm64/include/asm/kvm_hyp.h | 6 +-
arch/arm64/include/asm/sysreg.h | 12 ---
arch/arm64/kvm/arm.c | 1 +
arch/arm64/kvm/debug.c | 48 +++++++++-
arch/arm64/kvm/hyp/nvhe/debug-sr.c | 88 +++++++++++--------
arch/arm64/kvm/hyp/nvhe/switch.c | 4 +-
arch/arm64/tools/sysreg | 41 +++++++++
.../coresight/coresight-etm4x-core.c | 42 +++++++--
drivers/hwtracing/coresight/coresight-etm4x.h | 2 +-
drivers/hwtracing/coresight/coresight-priv.h | 3 +
11 files changed, 192 insertions(+), 68 deletions(-)
--
2.34.1
On Tue, Nov 07, 2023 at 12:16:25PM +0200, Adrian Hunter wrote:
[...]
> >>>> "If users know" <- how would users know? Could the kernel
> >>>> or tools also figure it out?
> >>>
> >>> Adrian, I'm trying to go all the outstanding patches, do you still have
> >>> any issues with this series?
> >>
> >> No, although the question wasn't actually answered. I presume users
> >> just have to try the 'T' option and see if it helps.
> >
> > Sometimes, users are software developers in SoC companies, they can
> > know well for the hardware design but are confused why current
> > implementation cannot use timestamp trace. This is the main reason
> > I sent this patch set.
> >
> > An example hardware platform is DB410c [1], we know its CoreSight can
> > support timestamp trace, but if without this adding option 'T', we
> > have no chance to use it due to it its CPU arch is prior to Armv8.4.
>
> perf config might be better than an itrace option, but you decide.
I understand perf config is a better approach due to users don't need
to bother inputting options after set it once. I will look at it and
respin new patch set.
Thanks for suggestion!
Leo
This moves remaining AMBA ACPI devices into respective platform drivers for
enabling ACPI based power management support. This series applies on latest
coresight/next branch. This series has been built, and boot tested on a DT
based coresight platform. Although this still requires some more testing on
ACPI based coresight platforms.
Cc: Lorenzo Pieralisi <lpieralisi(a)kernel.org>
Cc: Sudeep Holla <sudeep.holla(a)arm.com>
Cc: Suzuki K Poulose <suzuki.poulose(a)arm.com>
Cc: Mike Leach <mike.leach(a)linaro.org>
Cc: James Clark <james.clark(a)arm.com>
Cc: Maxime Coquelin <mcoquelin.stm32(a)gmail.com>
Cc: Alexandre Torgue <alexandre.torgue(a)foss.st.com>
Cc: linux-acpi(a)vger.kernel.org
Cc: linux-arm-kernel(a)lists.infradead.org
Cc: linux-kernel(a)vger.kernel.org
Cc: coresight(a)lists.linaro.org
Cc: linux-stm32(a)st-md-mailman.stormreply.com
Changes in V1:
- Replaced all IS_ERR() instances with IS_ERR_OR_NULL() as per Suzuki
Changes in RFC:
https://lore.kernel.org/all/20230921042040.1334641-1-anshuman.khandual@arm.…
Anshuman Khandual (7):
coresight: replicator: Move ACPI support from AMBA driver to platform driver
coresight: funnel: Move ACPI support from AMBA driver to platform driver
coresight: catu: Move ACPI support from AMBA driver to platform driver
coresight: tpiu: Move ACPI support from AMBA driver to platform driver
coresight: tmc: Move ACPI support from AMBA driver to platform driver
coresight: stm: Move ACPI support from AMBA driver to platform driver
coresight: debug: Move ACPI support from AMBA driver to platform driver
drivers/acpi/arm64/amba.c | 8 --
drivers/hwtracing/coresight/coresight-catu.c | 136 ++++++++++++++++--
drivers/hwtracing/coresight/coresight-catu.h | 1 +
.../hwtracing/coresight/coresight-cpu-debug.c | 130 +++++++++++++++--
.../hwtracing/coresight/coresight-funnel.c | 49 ++++---
.../coresight/coresight-replicator.c | 44 +++---
drivers/hwtracing/coresight/coresight-stm.c | 80 +++++++++--
.../hwtracing/coresight/coresight-tmc-core.c | 127 ++++++++++++++--
drivers/hwtracing/coresight/coresight-tmc.h | 1 +
drivers/hwtracing/coresight/coresight-tpiu.c | 76 +++++++++-
10 files changed, 549 insertions(+), 103 deletions(-)
--
2.25.1
Hi Punit
On 15/11/2023 13:59, Punit Agrawal wrote:
> Hi,
>
> I am hitting some issues when capturing instruction trace using 'perf'
> on an Arm N2 based system.
>
> After enabling ACPI support[0] for TRBE on top of v6.6, the kernel
> successfully probes all the ETE and TRBE devices. I see "ete" and "trbe"
> device folders (one per CPU) in /sys/bus/coresight/devices.
Do you see all trbe devices corresponding to the number of CPUs ?
>
> When capturing trace using 'perf', I see the following error with no
> trace captured.
>
> # perf record -e cs_etm//u <workload>
> failed to mmap with 12 (Cannot allocate memory)
That looks like a problem when you don't have a sink to capture the
trace or there was an error in the allocation of memory.
>
> The error goes away if a cpu is specified using '-C' option to 'perf record'
>
> # perf record -e cs_etm//u -C 10 <workload>
>
> [...]
>
> [ perf record: Woken up 1 times to write data ]
> [ perf record: Captured and wrote 0.422 MB perf.data ]
That also looks suspicious as the size is too small. Does the perf
report show any AUX records ?
>
> Is this a known issue? Perhaps I am missing some required dependencies.
No, this is not.
>
> Thanks,
> Punit
>
> [0] https://lore.kernel.org/all/20230829135405.1159449-1-anshuman.khandual@arm.…
Fix the Three issues listed below and use guards to cleanup
a) Fixed the BUG of atomic-sleep
b) Fixed uninitialized before use buf_hw_base
c) Fixed use unreset SMB buffer
Changes since V2:
* Ignore the return value of smb_config_inport()
Link to V2: https://lore.kernel.org/lkml/20231021083822.18239-1-hejunhao3@huawei.com/
Changes since V1:
* Add comment for remove lock from smb_read()
* Move reset buffer to before register sink
* Remove patch "simplify the code for check to_copy valid"
* Add two new patches
Link to V1: https://lore.kernel.org/lkml/20231012094706.21565-1-hejunhao3@huawei.com/
Junhao He (4):
coresight: ultrasoc-smb: Fix sleep while close preempt in enable_smb
coresight: ultrasoc-smb: Config SMB buffer before register sink
coresight: ultrasoc-smb: Fix uninitialized before use buf_hw_base
coresight: ultrasoc-smb: Use guards to cleanup
drivers/hwtracing/coresight/ultrasoc-smb.c | 108 +++++++--------------
drivers/hwtracing/coresight/ultrasoc-smb.h | 6 +-
2 files changed, 38 insertions(+), 76 deletions(-)
--
2.33.0
Hi Uwe,
On 2023/11/9 21:11, Uwe Kleine-König wrote:
> On Thu, Nov 09, 2023 at 08:14:34PM +0800, hejunhao wrote:
>> On 2023/11/9 17:53, Uwe Kleine-König wrote:
>>> Hello,
>>>
>>> On Thu, Nov 09, 2023 at 05:41:55PM +0800, hejunhao wrote:
>>>> On 2023/11/8 4:28, Uwe Kleine-König wrote:
>>>>> If smb_config_inport() fails it's still necessary to unregister all
>>>>> resources. As smb_config_inport() already emits an error message on
>>>>> failure, there is no need to add another one. By not returning the error
>>>>> code, a second error message (about the return value being ignored) is
>>>>> suppressed.
>>>>>
>>>>> Fixes: 06f5c2926aaa ("drivers/coresight: Add UltraSoc System Memory Buffer driver")
>>>>> Signed-off-by: Uwe Kleine-König <u.kleine-koenig(a)pengutronix.de>
>>>> thanks, for the report. Can you try this patch and help review it?
>>>>
>>>> https://lore.kernel.org/linux-arm-kernel/20231021083822.18239-3-hejunhao3@h…
>>> Well, I cannot try it, but it improves things a bit. The remaining
>>> problem is that smb_remove() should return 0 even if smb_config_inport()
>>> fails.
>>>
>>> Best regards
>>> Uwe
>> Yes, I will do that.
>> By the way, Can I add patch 8.8 to my patchset? I think this is a good way
>> to resolve patch conflicts.
> I don't know how patch application works in drivers/hwtracing. I will
> probably check if these patches are in next in a few weeks and resend if
> they are not. If you adding patch #8 to your patch set needs more
> coordination, please tell me.
>
> Best regards
> Uwe
Forgive me for interrupting.
I sent v3 and it ignored the return value of smb_config_inport(). Can
you rebase to that?:-)
https://lore.kernel.org/lkml/20231114133346.30489-1-hejunhao3@huawei.com/
Best regards,
Junhao.