mirror of
				https://github.com/torvalds/linux.git
				synced 2025-10-31 08:38:45 +02:00 
			
		
		
		
	 aaf69eff6c
			
		
	
	
		aaf69eff6c
		
	
	
	
	
		
			
			Currently the userspace and kernel filters for guests are never set, so
no trace will be generated for them. Add support for tracing guests by
passing the desired TRFCR value to KVM so it can be applied to the
guest.
By writing either E1TRE or E0TRE, filtering on either guest kernel or
guest userspace is also supported. And if both E1TRE and E0TRE are
cleared when exclude_guest is set, that option is supported too. This
change also brings exclude_host support which is difficult to add as a
separate commit without excess churn and resulting in no trace at all.
cpu_prohibit_trace() gets moved to TRBE because the ETM driver doesn't
need the read, it already has the base TRFCR value. TRBE only needs
the read to disable it and then restore.
Testing
=======
The addresses were counted with the following:
  $ perf report -D | grep -Eo 'EL2|EL1|EL0' | sort | uniq -c
Guest kernel only:
  $ perf record -e cs_etm//Gk -a -- true
    535 EL1
      1 EL2
Guest user only (only 5 addresses because the guest runs slowly in the
model):
  $ perf record -e cs_etm//Gu -a -- true
    5 EL0
Host kernel only:
  $  perf record -e cs_etm//Hk -a -- true
   3501 EL2
Host userspace only:
  $  perf record -e cs_etm//Hu -a -- true
    408 EL0
      1 EL2
Signed-off-by: James Clark <james.clark@arm.com>
Link: https://lore.kernel.org/r/20250106142446.628923-8-james.clark@linaro.org
Signed-off-by: Marc Zyngier <maz@kernel.org>
		
	
			
		
			
				
	
	
		
			24 lines
		
	
	
	
		
			443 B
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			24 lines
		
	
	
	
		
			443 B
		
	
	
	
		
			C
		
	
	
	
	
	
| /* SPDX-License-Identifier: GPL-2.0-only */
 | |
| /*
 | |
|  * Arm v8 Self-Hosted trace support.
 | |
|  *
 | |
|  * Copyright (C) 2021 ARM Ltd.
 | |
|  */
 | |
| 
 | |
| #ifndef __CORESIGHT_SELF_HOSTED_TRACE_H
 | |
| #define __CORESIGHT_SELF_HOSTED_TRACE_H
 | |
| 
 | |
| #include <asm/sysreg.h>
 | |
| 
 | |
| static inline u64 read_trfcr(void)
 | |
| {
 | |
| 	return read_sysreg_s(SYS_TRFCR_EL1);
 | |
| }
 | |
| 
 | |
| static inline void write_trfcr(u64 val)
 | |
| {
 | |
| 	write_sysreg_s(val, SYS_TRFCR_EL1);
 | |
| 	isb();
 | |
| }
 | |
| 
 | |
| #endif /*  __CORESIGHT_SELF_HOSTED_TRACE_H */
 |