Skip to content

Commit 054b883

Browse files
james-c-linaroMarc Zyngier
authored andcommitted
KVM: arm64: Support trace filtering for guests
For nVHE, switch the filter value in and out if the Coresight driver asks for it. This will support filters for guests when sinks other than TRBE are used. For VHE, just write the filter directly to TRFCR_EL1 where trace can be used even with TRBE sinks. Signed-off-by: James Clark <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Marc Zyngier <[email protected]>
1 parent a665e3b commit 054b883

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

arch/arm64/include/asm/kvm_host.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1388,6 +1388,7 @@ void kvm_clr_pmu_events(u64 clr);
13881388
bool kvm_set_pmuserenr(u64 val);
13891389
void kvm_enable_trbe(void);
13901390
void kvm_disable_trbe(void);
1391+
void kvm_tracing_set_el1_configuration(u64 trfcr_while_in_guest);
13911392
#else
13921393
static inline void kvm_set_pmu_events(u64 set, struct perf_event_attr *attr) {}
13931394
static inline void kvm_clr_pmu_events(u64 clr) {}
@@ -1397,6 +1398,7 @@ static inline bool kvm_set_pmuserenr(u64 val)
13971398
}
13981399
static inline void kvm_enable_trbe(void) {}
13991400
static inline void kvm_disable_trbe(void) {}
1401+
static inline void kvm_tracing_set_el1_configuration(u64 trfcr_while_in_guest) {}
14001402
#endif
14011403

14021404
void kvm_vcpu_load_vhe(struct kvm_vcpu *vcpu);

arch/arm64/kvm/debug.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,3 +245,21 @@ void kvm_disable_trbe(void)
245245
host_data_clear_flag(TRBE_ENABLED);
246246
}
247247
EXPORT_SYMBOL_GPL(kvm_disable_trbe);
248+
249+
void kvm_tracing_set_el1_configuration(u64 trfcr_while_in_guest)
250+
{
251+
if (is_protected_kvm_enabled() || WARN_ON_ONCE(preemptible()))
252+
return;
253+
254+
if (has_vhe()) {
255+
write_sysreg_s(trfcr_while_in_guest, SYS_TRFCR_EL12);
256+
return;
257+
}
258+
259+
*host_data_ptr(trfcr_while_in_guest) = trfcr_while_in_guest;
260+
if (read_sysreg_s(SYS_TRFCR_EL1) != trfcr_while_in_guest)
261+
host_data_set_flag(EL1_TRACING_CONFIGURED);
262+
else
263+
host_data_clear_flag(EL1_TRACING_CONFIGURED);
264+
}
265+
EXPORT_SYMBOL_GPL(kvm_tracing_set_el1_configuration);

0 commit comments

Comments
 (0)