ANDROID: KVM: arm64: Fix reset for hyp tracefs

While resetting the hypervisor tracing, the head page pointer wasn't
updated as well at the stamp and lost events. This might leave the
buffer in a corrupted state.

While at it, strengthen the reset test to check for timestamp and lost
events.

Bug: 357781595
Fixes: a368d579d1 ("FROMLIST: KVM: arm64: Add trace interface for hyp tracefs")
Change-Id: Ia5dac9634bcb3a2afea9db72ac6b2eda1d9a9730
Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
This commit is contained in:
Vincent Donnefort
2025-02-11 11:29:43 +00:00
parent a8c9f6dff6
commit 7395cf8455
2 changed files with 11 additions and 2 deletions
+8
View File
@@ -339,6 +339,11 @@ static int rb_cpu_reset(struct hyp_rb_per_cpu *cpu_buffer)
prev_status = rb_cpu_disable_writing(cpu_buffer);
if (!rb_set_head_page(cpu_buffer))
return -ENODEV;
cpu_buffer->tail_page = cpu_buffer->head_page;
bpage = cpu_buffer->head_page;
do {
rb_page_reset(bpage);
@@ -347,6 +352,9 @@ static int rb_cpu_reset(struct hyp_rb_per_cpu *cpu_buffer)
rb_page_reset(cpu_buffer->reader_page);
cpu_buffer->last_overrun = 0;
cpu_buffer->write_stamp = 0;
cpu_buffer->meta->reader.read = 0;
cpu_buffer->meta->reader.lost_events = 0;
cpu_buffer->meta->entries = 0;
@@ -208,8 +208,9 @@ test_reset()
echo "Test Reset..."
setup_hyp_trace
write_events 5
write_events 1000
echo 0 > trace
clock_before=$(host_clock)
write_events 5
pid=$(consuming_read $tmp)
@@ -217,7 +218,7 @@ test_reset()
stop_hyp_trace
kill $pid
validate_test $tmp 5 0 $(host_clock)
validate_test $tmp 5 $clock_before $(host_clock)
rm $tmp