Thread (8 messages) flat view 8 messages, 4 authors, 2021-02-08

Re: [PATCH v2 1/1] powerpc/kvm: Save Timebase Offset to fix sched_clock() while running guest code.

From: Michael Ellerman <mpe@ellerman.id.au>
Date: 2021-02-06 02:57:39
Also in: lkml

Nicholas Piggin [off-list ref] writes:
Excerpts from Leonardo Bras's message of February 5, 2021 4:06 pm:
quoted
Before guest entry, TBU40 register is changed to reflect guest timebase.
After exitting guest, the register is reverted to it's original value.

If one tries to get the timestamp from host between those changes, it
will present an incorrect value.

An example would be trying to add a tracepoint in
kvmppc_guest_entry_inject_int(), which depending on last tracepoint
acquired could actually cause the host to crash.

Save the Timebase Offset to PACA and use it on sched_clock() to always
get the correct timestamp.
Ouch. Not sure how reasonable it is to half switch into guest registers 
and expect to call into the wider kernel, fixing things up as we go. 
Yeah it's not.

We need to disable tracing on those routines that are called in that
half-exited state.

cheers
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help