From: David Gibson <david@gibson.dropbear.id.au>
To: Fabiano Rosas <farosas@linux.ibm.com>
Cc: aik@ozlabs.ru, danielhb413@gmail.com, qemu-devel@nongnu.org,
npiggin@gmail.com, qemu-ppc@nongnu.org, clg@kaod.org
Subject: Re: [RFC PATCH 3/4] hw/ppc: Take nested guest into account when saving timebase
Date: Fri, 25 Feb 2022 14:21:25 +1100 [thread overview]
Message-ID: <YhhLNVXO/Uj7XpVi@yekko> (raw)
In-Reply-To: <20220224185817.2207228-4-farosas@linux.ibm.com>
[-- Attachment #1: Type: text/plain, Size: 2594 bytes --]
On Thu, Feb 24, 2022 at 03:58:16PM -0300, Fabiano Rosas wrote:
> When saving the guest "timebase" we look to the first_cpu for its
> tb_offset. If that CPU happens to be running a nested guest at this
> time, the tb_offset will have the nested guest value.
>
> This was caught by code inspection.
This doesn't seem right. Isn't the real problem that nested_tb_offset
isn't being migrated? If you migrate that, shouldn't everything be
fixed up when the L1 cpu leaves the nested guest on the destination
host?
>
> Signed-off-by: Fabiano Rosas <farosas@linux.ibm.com>
> ---
> hw/ppc/ppc.c | 17 ++++++++++++++++-
> 1 file changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/hw/ppc/ppc.c b/hw/ppc/ppc.c
> index 9e99625ea9..093cd87014 100644
> --- a/hw/ppc/ppc.c
> +++ b/hw/ppc/ppc.c
> @@ -36,6 +36,7 @@
> #include "kvm_ppc.h"
> #include "migration/vmstate.h"
> #include "trace.h"
> +#include "hw/ppc/spapr_cpu_core.h"
>
> static void cpu_ppc_tb_stop (CPUPPCState *env);
> static void cpu_ppc_tb_start (CPUPPCState *env);
> @@ -961,19 +962,33 @@ static void timebase_save(PPCTimebase *tb)
> {
> uint64_t ticks = cpu_get_host_ticks();
> PowerPCCPU *first_ppc_cpu = POWERPC_CPU(first_cpu);
> + int64_t tb_offset;
>
> if (!first_ppc_cpu->env.tb_env) {
> error_report("No timebase object");
> return;
> }
>
> + tb_offset = first_ppc_cpu->env.tb_env->tb_offset;
> +
> + if (first_ppc_cpu->vhyp && vhyp_cpu_in_nested(first_ppc_cpu)) {
> + SpaprCpuState *spapr_cpu = spapr_cpu_state(first_ppc_cpu);
> +
> + /*
> + * If the first_cpu happens to be running a nested guest at
> + * this time, tb_env->tb_offset will contain the nested guest
> + * offset.
> + */
> + tb_offset -= spapr_cpu->nested_tb_offset;
> + }
> +
> /* not used anymore, we keep it for compatibility */
> tb->time_of_the_day_ns = qemu_clock_get_ns(QEMU_CLOCK_HOST);
> /*
> * tb_offset is only expected to be changed by QEMU so
> * there is no need to update it from KVM here
> */
> - tb->guest_timebase = ticks + first_ppc_cpu->env.tb_env->tb_offset;
> + tb->guest_timebase = ticks + tb_offset;
>
> tb->runstate_paused =
> runstate_check(RUN_STATE_PAUSED) || runstate_check(RUN_STATE_SAVE_VM);
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2022-02-25 4:11 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-24 18:58 [RFC PATCH 0/4] ppc: nested TCG migration (KVM-on-TCG) Fabiano Rosas
2022-02-24 18:58 ` [RFC PATCH 1/4] target/ppc: TCG: Migrate tb_offset and decr Fabiano Rosas
2022-02-24 20:06 ` Richard Henderson
2022-02-25 3:15 ` David Gibson
2022-02-25 16:08 ` Fabiano Rosas
2022-02-28 2:04 ` David Gibson
2022-02-24 18:58 ` [RFC PATCH 2/4] spapr: TCG: Migrate spapr_cpu->prod Fabiano Rosas
2022-02-25 3:17 ` David Gibson
2022-02-25 16:08 ` Fabiano Rosas
2022-02-24 18:58 ` [RFC PATCH 3/4] hw/ppc: Take nested guest into account when saving timebase Fabiano Rosas
2022-02-25 3:21 ` David Gibson [this message]
2022-02-25 16:08 ` Fabiano Rosas
2022-02-28 2:06 ` David Gibson
2022-02-24 18:58 ` [RFC PATCH 4/4] spapr: Add KVM-on-TCG migration support Fabiano Rosas
2022-02-25 0:51 ` Nicholas Piggin
2022-02-25 3:42 ` David Gibson
2022-02-25 10:57 ` Nicholas Piggin
2022-02-24 21:00 ` [RFC PATCH 0/4] ppc: nested TCG migration (KVM-on-TCG) Mark Cave-Ayland
2022-02-25 3:54 ` David Gibson
2022-02-25 16:11 ` Fabiano Rosas
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=YhhLNVXO/Uj7XpVi@yekko \
--to=david@gibson.dropbear.id.au \
--cc=aik@ozlabs.ru \
--cc=clg@kaod.org \
--cc=danielhb413@gmail.com \
--cc=farosas@linux.ibm.com \
--cc=npiggin@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).