From: David Gibson <david@gibson.dropbear.id.au>
To: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Cc: qemu-devel@nongnu.org, qemu-ppc@nongnu.org, aik@ozlabs.ru,
lvivier@redhat.com
Subject: Re: [Qemu-devel] [PATCH 4/4] ppc: ensure we update the decrementer value during migration
Date: Wed, 13 Sep 2017 17:12:49 +1000 [thread overview]
Message-ID: <20170913071249.GI7550@umbus.fritz.box> (raw)
In-Reply-To: <1505054255-2990-5-git-send-email-mark.cave-ayland@ilande.co.uk>
[-- Attachment #1: Type: text/plain, Size: 2594 bytes --]
On Sun, Sep 10, 2017 at 03:37:35PM +0100, Mark Cave-Ayland wrote:
> During local testing with TCG, intermittent errors were found when trying to
> migrate Darwin OS images.
>
> The underlying cause was that Darwin resets the decrementer value to fairly
> small values on each interrupt. cpu_ppc_set_tb_clk() sets the default value
> of the decrementer to 0xffffffff during initialisation which typically
> corresponds to several seconds. Hence when restoring the image, the guest
> would effectively "lose" decrementer interrupts during this time causing
> confusion in the guest.
>
> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
This is subtly incorrect. It sets the DECR on load to exactly the
value that was saved. That effectively means that the DECR is frozen
for the migration downtime, which probably isn't what we want.
Instead we need to save the DECR as an offset from the timebase, and
restore it relative to the (downtime adjusted) timebase on the
destination.
The complication with that is that the timebase is generally migrated
at the machine level, not the cpu level: the timebase is generally
synchronized between cpus in the machine, and migrating it at the
individual cpu could break that. Which means we probably need a
machine level hook to handle the decrementer too, even though it
logically *is* per-cpu, because otherwise we'll be trying to restore
it before the timebase is restored.
> ---
> target/ppc/machine.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/target/ppc/machine.c b/target/ppc/machine.c
> index 10b3c41..a16a856 100644
> --- a/target/ppc/machine.c
> +++ b/target/ppc/machine.c
> @@ -176,6 +176,7 @@ static void cpu_pre_save(void *opaque)
> env->spr[SPR_CFAR] = env->cfar;
> #endif
> env->spr[SPR_BOOKE_SPEFSCR] = env->spe_fscr;
> + env->spr[SPR_DECR] = cpu_ppc_load_decr(env);
>
> for (i = 0; (i < 4) && (i < env->nb_BATs); i++) {
> env->spr[SPR_DBAT0U + 2*i] = env->DBAT[0][i];
> @@ -280,6 +281,7 @@ static int cpu_post_load(void *opaque, int version_id)
> env->cfar = env->spr[SPR_CFAR];
> #endif
> env->spe_fscr = env->spr[SPR_BOOKE_SPEFSCR];
> + cpu_ppc_store_decr(env, env->spr[SPR_DECR]);
>
> for (i = 0; (i < 4) && (i < env->nb_BATs); i++) {
> env->DBAT[0][i] = env->spr[SPR_DBAT0U + 2*i];
--
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:[~2017-09-13 7:28 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-10 14:37 [Qemu-devel] [PATCH 0/4] ppc: migration fixes for TCG Mark Cave-Ayland
2017-09-10 14:37 ` [Qemu-devel] [PATCH 1/4] ppc: change CPUPPCState access_type from int to uint8_t Mark Cave-Ayland
2017-09-10 16:30 ` Laurent Vivier
2017-09-10 18:00 ` Mark Cave-Ayland
2017-09-10 14:37 ` [Qemu-devel] [PATCH 2/4] ppc: add CPU IRQ state to PPC VMStateDescription Mark Cave-Ayland
2017-09-11 7:50 ` [Qemu-devel] [Qemu-ppc] " Greg Kurz
2017-09-11 9:30 ` Dr. David Alan Gilbert
2017-09-11 10:48 ` David Gibson
2017-09-11 16:46 ` Mark Cave-Ayland
2017-09-11 17:19 ` Dr. David Alan Gilbert
2017-09-13 7:03 ` David Gibson
2017-09-12 16:21 ` Dr. David Alan Gilbert
2017-09-12 16:41 ` Mark Cave-Ayland
2017-09-12 16:46 ` Mark Cave-Ayland
2017-09-13 2:23 ` Alexey Kardashevskiy
2017-09-13 6:02 ` David Gibson
2017-09-13 16:44 ` Mark Cave-Ayland
2017-09-13 17:13 ` Greg Kurz
2017-09-14 3:48 ` David Gibson
2017-09-14 3:30 ` David Gibson
2017-09-10 14:37 ` [Qemu-devel] [PATCH 3/4] ppc: add CPU access_type into the migration stream Mark Cave-Ayland
2017-09-11 10:57 ` David Gibson
2017-09-11 16:52 ` Mark Cave-Ayland
2017-09-13 7:19 ` David Gibson
2017-09-13 17:17 ` Mark Cave-Ayland
2017-09-14 3:54 ` David Gibson
2017-09-10 14:37 ` [Qemu-devel] [PATCH 4/4] ppc: ensure we update the decrementer value during migration Mark Cave-Ayland
2017-09-13 7:12 ` David Gibson [this message]
2017-09-13 17:11 ` Mark Cave-Ayland
2017-09-13 17:58 ` Laurent Vivier
2017-09-14 3:52 ` David Gibson
2017-09-15 12:45 ` Mark Cave-Ayland
2017-09-19 8:36 ` David Gibson
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=20170913071249.GI7550@umbus.fritz.box \
--to=david@gibson.dropbear.id.au \
--cc=aik@ozlabs.ru \
--cc=lvivier@redhat.com \
--cc=mark.cave-ayland@ilande.co.uk \
--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).