From 429edbe41929b626fb2742431cb2e1837e579d94 Mon Sep 17 00:00:00 2001 From: Nikita Ioffe Date: Wed, 15 Feb 2023 12:45:43 +0000 Subject: [PATCH] ANDROID: KVM: arm64: Add trace_clock for nVHE tracing Added userspace file that describes what clock is used for hyp tracing. Unlike tracefs root instance, the hyp tracing only supports boot clock, hence the trace_clock file is read-only. Bug: 249050813 Change-Id: Ib9cc1f582699245ed94cf745dae0888eb7556ced Signed-off-by: Nikita Ioffe --- arch/arm64/kvm/hyp_trace.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/arch/arm64/kvm/hyp_trace.c b/arch/arm64/kvm/hyp_trace.c index 888a3d360f69..212e21c556b7 100644 --- a/arch/arm64/kvm/hyp_trace.c +++ b/arch/arm64/kvm/hyp_trace.c @@ -988,6 +988,24 @@ static const struct file_operations hyp_trace_raw_fops = { .llseek = no_llseek, }; +static int hyp_trace_clock_show(struct seq_file *m, void *v) +{ + seq_printf(m, "[boot]\n"); + return 0; +} + +static int hyp_trace_clock_open(struct inode *inode, struct file *file) +{ + return single_open(file, hyp_trace_clock_show, NULL); +} + +static const struct file_operations hyp_trace_clock_fops = { + .open = hyp_trace_clock_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; + static void hyp_tracefs_create_cpu_file(const char *file_name, int cpu, umode_t mode, @@ -1028,6 +1046,11 @@ int init_hyp_tracefs(void) if (!d) pr_err("Failed to create tracefs "TRACEFS_DIR"/buffer_size_kb\n"); + d = tracefs_create_file("trace_clock", TRACEFS_MODE_READ, root_dir, NULL, + &hyp_trace_clock_fops); + if (!d) + pr_err("Failed to create tracefs "TRACEFS_DIR"/trace_clock\n"); + hyp_tracefs_create_cpu_file("trace", RING_BUFFER_ALL_CPUS, TRACEFS_MODE_WRITE, &hyp_trace_fops, root_dir);