From: Michael Ellerman <mpe@ellerman.id.au>
To: Nicholas Piggin <npiggin@gmail.com>,
"Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>,
Athira Rajeev <atrajeev@linux.vnet.ibm.com>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Christophe Leroy <christophe.leroy@csgroup.eu>,
Frederic Weisbecker <frederic@kernel.org>,
Geert Uytterhoeven <geert+renesas@glider.be>,
Jordan Niethe <jniethe5@gmail.com>,
Leonardo Bras <leobras.c@gmail.com>,
Paul Mackerras <paulus@ozlabs.org>,
Thomas Gleixner <tglx@linutronix.de>
Cc: kvm-ppc@vger.kernel.org, linux-kernel@vger.kernel.org,
linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH v2 1/1] powerpc/kvm: Save Timebase Offset to fix sched_clock() while running guest code.
Date: Fri, 05 Feb 2021 23:32:58 +0000 [thread overview]
Message-ID: <878s82ozth.fsf@mpe.ellerman.id.au> (raw)
In-Reply-To: <1612506268.6rrvx34gzu.astroid@bobo.none>
Nicholas Piggin <npiggin@gmail.com> writes:
> Excerpts from Leonardo Bras's message of February 5, 2021 4:06 pm:
>> 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
WARNING: multiple messages have this Message-ID (diff)
From: Michael Ellerman <mpe@ellerman.id.au>
To: Nicholas Piggin <npiggin@gmail.com>,
"Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>,
Athira Rajeev <atrajeev@linux.vnet.ibm.com>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Christophe Leroy <christophe.leroy@csgroup.eu>,
Frederic Weisbecker <frederic@kernel.org>,
Geert Uytterhoeven <geert+renesas@glider.be>,
Jordan Niethe <jniethe5@gmail.com>,
Leonardo Bras <leobras.c@gmail.com>,
Paul Mackerras <paulus@ozlabs.org>,
Thomas Gleixner <tglx@linutronix.de>
Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org,
kvm-ppc@vger.kernel.org
Subject: Re: [PATCH v2 1/1] powerpc/kvm: Save Timebase Offset to fix sched_clock() while running guest code.
Date: Sat, 06 Feb 2021 10:32:58 +1100 [thread overview]
Message-ID: <878s82ozth.fsf@mpe.ellerman.id.au> (raw)
In-Reply-To: <1612506268.6rrvx34gzu.astroid@bobo.none>
Nicholas Piggin <npiggin@gmail.com> writes:
> Excerpts from Leonardo Bras's message of February 5, 2021 4:06 pm:
>> 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
WARNING: multiple messages have this Message-ID (diff)
From: Michael Ellerman <mpe@ellerman.id.au>
To: Nicholas Piggin <npiggin@gmail.com>,
"Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>,
Athira Rajeev <atrajeev@linux.vnet.ibm.com>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Christophe Leroy <christophe.leroy@csgroup.eu>,
Frederic Weisbecker <frederic@kernel.org>,
Geert Uytterhoeven <geert+renesas@glider.be>,
Jordan Niethe <jniethe5@gmail.com>,
Leonardo Bras <leobras.c@gmail.com>,
Paul Mackerras <paulus@ozlabs.org>,
Thomas Gleixner <tglx@linutronix.de>
Cc: kvm-ppc@vger.kernel.org, linux-kernel@vger.kernel.org,
linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH v2 1/1] powerpc/kvm: Save Timebase Offset to fix sched_clock() while running guest code.
Date: Sat, 06 Feb 2021 10:32:58 +1100 [thread overview]
Message-ID: <878s82ozth.fsf@mpe.ellerman.id.au> (raw)
In-Reply-To: <1612506268.6rrvx34gzu.astroid@bobo.none>
Nicholas Piggin <npiggin@gmail.com> writes:
> Excerpts from Leonardo Bras's message of February 5, 2021 4:06 pm:
>> 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
next prev parent reply other threads:[~2021-02-05 23:32 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-05 6:06 [PATCH v2 1/1] powerpc/kvm: Save Timebase Offset to fix sched_clock() while running guest code Leonardo Bras
2021-02-05 6:06 ` Leonardo Bras
2021-02-05 6:06 ` Leonardo Bras
2021-02-05 6:28 ` Nicholas Piggin
2021-02-05 6:28 ` Nicholas Piggin
2021-02-05 6:28 ` Nicholas Piggin
2021-02-05 7:01 ` Leonardo Bras
2021-02-05 7:01 ` Leonardo Bras
2021-02-05 7:01 ` Leonardo Bras
2021-02-06 3:03 ` Nicholas Piggin
2021-02-06 3:03 ` Nicholas Piggin
2021-02-06 3:03 ` Nicholas Piggin
2021-02-08 16:37 ` Leonardo Bras
2021-02-08 16:37 ` Leonardo Bras
2021-02-08 16:37 ` Leonardo Bras
2021-02-05 23:32 ` Michael Ellerman [this message]
2021-02-05 23:32 ` Michael Ellerman
2021-02-05 23:32 ` Michael Ellerman
2021-02-05 13:09 ` Fabiano Rosas
2021-02-05 13:09 ` Fabiano Rosas
2021-02-05 13:09 ` Fabiano Rosas
2021-02-05 20:35 ` Leonardo Bras
2021-02-05 20:35 ` Leonardo Bras
2021-02-05 20:35 ` Leonardo Bras
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=878s82ozth.fsf@mpe.ellerman.id.au \
--to=mpe@ellerman.id.au \
--cc=aneesh.kumar@linux.ibm.com \
--cc=atrajeev@linux.vnet.ibm.com \
--cc=benh@kernel.crashing.org \
--cc=christophe.leroy@csgroup.eu \
--cc=frederic@kernel.org \
--cc=geert+renesas@glider.be \
--cc=jniethe5@gmail.com \
--cc=kvm-ppc@vger.kernel.org \
--cc=leobras.c@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=npiggin@gmail.com \
--cc=paulus@ozlabs.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.