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 <ioffe@google.com>
This commit is contained in:
Nikita Ioffe
2023-02-15 12:45:43 +00:00
committed by Vincent Donnefort
parent 73bf84c36b
commit e80aeaf594

View File

@@ -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);