ANDROID: KVM: arm64: Add header_page userspace descriptor for nVHE tracing

Added userspace file that describes the content of each hyp tracing
ring-buffer page. This follows the same format as the descriptor found
in the tracefs root to ensure compatibility with userspace trace tools.

Bug: 229972309
Change-Id: Ideebf37cb285b581c4cbe2a991a0df8c7ed61c0f
Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
This commit is contained in:
Vincent Donnefort 2023-02-02 10:19:52 +00:00
parent 4731a6d3bc
commit 51ca8e8c72

View File

@ -236,6 +236,42 @@ static const struct file_operations hyp_event_format_fops = {
.release = single_release,
};
static int hyp_header_page_show(struct seq_file *m, void *v)
{
struct buffer_data_page bpage;
seq_printf(m, "\tfield: u64 timestamp;\t"
"offset:0;\tsize:%lu;\tsigned:%d;\n",
sizeof(bpage.time_stamp),
is_signed_type(u64));
seq_printf(m, "\tfield: local_t commit;\t"
"offset:%lu;\tsize:%lu;\tsigned:%d;\n",
offsetof(typeof(bpage), commit),
sizeof(bpage.commit),
is_signed_type(long));
seq_printf(m, "\tfield: char data;\t"
"offset:%lu;\tsize:%lu;\tsigned:%d;\n",
offsetof(typeof(bpage), data),
BUF_EXT_PAGE_SIZE,
is_signed_type(char));
return 0;
}
static int hyp_header_page_open(struct inode *inode, struct file *file)
{
return single_open(file, hyp_header_page_show, NULL);
}
static const struct file_operations hyp_header_page_fops = {
.open = hyp_header_page_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
static char early_events[COMMAND_LINE_SIZE];
static __init int setup_hyp_event_early(char *str)
@ -292,6 +328,12 @@ void kvm_hyp_init_events_tracefs(struct dentry *parent)
return;
}
d = tracefs_create_file("header_page", 0400, parent, NULL,
&hyp_header_page_fops);
if (!d)
pr_err("Failed to create events/header_page\n");
for (; (unsigned long)event < (unsigned long)__stop_hyp_events; event++) {
event_dir = tracefs_create_dir(event->name, parent);
if (!event_dir) {