From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57217) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aQ3PA-0005kH-HK for qemu-devel@nongnu.org; Sun, 31 Jan 2016 20:35:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aQ3P6-0001c7-ST for qemu-devel@nongnu.org; Sun, 31 Jan 2016 20:35:48 -0500 Date: Mon, 1 Feb 2016 12:19:08 +1100 From: David Gibson Message-ID: <20160201011908.GA23043@voom.redhat.com> References: <1454267976-27242-1-git-send-email-mark.cave-ayland@ilande.co.uk> <1454267976-27242-3-git-send-email-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="PEpdcbHbO3kvNF3k" Content-Disposition: inline In-Reply-To: <1454267976-27242-3-git-send-email-mark.cave-ayland@ilande.co.uk> Subject: Re: [Qemu-devel] [PATCH 2/3] ppc: add support for timebase migration on non-PPC hosts List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Mark Cave-Ayland Cc: aik@ozlabs.ru, qemu-ppc@nongnu.org, qemu-devel@nongnu.org, agraf@suse.de --PEpdcbHbO3kvNF3k Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Jan 31, 2016 at 07:19:35PM +0000, Mark Cave-Ayland wrote: > This patch provides support for migration of the PPC guest timebase on no= n-PPC > host architectures (i.e those using QEMU's virtual emulated timebase). >=20 > Signed-off-by: Mark Cave-Ayland We shouldn't need an explicit test for a ppc host. Instead we should never be touching any host-dependent ticks values, only using host side interfaces which work in realtime units like ns. Worse, the ppc host variants here will still be wrong if the host has a different timebase frequency to the guest, which will always be true for a g3beige (16MHz) on a modern ppc host (512 MHz). > --- > hw/ppc/ppc.c | 33 +++++++++++++++++++++++++++------ > 1 file changed, 27 insertions(+), 6 deletions(-) >=20 > diff --git a/hw/ppc/ppc.c b/hw/ppc/ppc.c > index 19f4570..9b80c1d 100644 > --- a/hw/ppc/ppc.c > +++ b/hw/ppc/ppc.c > @@ -832,6 +832,15 @@ static void cpu_ppc_set_tb_clk (void *opaque, uint32= _t freq) > cpu_ppc_store_purr(cpu, 0x0000000000000000ULL); > } > =20 > +static int host_cpu_is_ppc(void) > +{ > +#if defined(_ARCH_PPC) > + return -1; > +#else > + return 0; > +#endif > +} > + > static void timebase_pre_save(void *opaque) > { > PPCTimebase *tb =3D opaque; > @@ -844,11 +853,16 @@ static void timebase_pre_save(void *opaque) > } > =20 > tb->time_of_the_day_ns =3D qemu_clock_get_ns(QEMU_CLOCK_HOST); > - /* > - * tb_offset is only expected to be changed by migration so > - * there is no need to update it from KVM here > - */ > - tb->guest_timebase =3D ticks + first_ppc_cpu->env.tb_env->tb_offset; > + > + if (host_cpu_is_ppc()) { > + /* > + * tb_offset is only expected to be changed by migration so > + * there is no need to update it from KVM here > + */ > + tb->guest_timebase =3D ticks + first_ppc_cpu->env.tb_env->tb_off= set; > + } else { > + tb->guest_timebase =3D cpu_ppc_load_tbl(&first_ppc_cpu->env); > + } > } > =20 > static int timebase_post_load(void *opaque, int version_id) > @@ -879,7 +893,14 @@ static int timebase_post_load(void *opaque, int vers= ion_id) > NANOSECONDS_PER_SECOND); > guest_tb =3D tb_remote->guest_timebase + migration_duration_tb; > =20 > - tb_off_adj =3D guest_tb - cpu_get_host_ticks(); > + if (host_cpu_is_ppc()) { > + /* Hardware timebase */ > + tb_off_adj =3D guest_tb - cpu_get_host_ticks(); > + } else { > + /* Software timebase */ > + tb_off_adj =3D guest_tb - muldiv64(qemu_clock_get_ns(QEMU_CLOCK_= VIRTUAL), > + freq, get_ticks_per_sec()); > + } > =20 > tb_off =3D first_ppc_cpu->env.tb_env->tb_offset; > trace_ppc_tb_adjust(tb_off, tb_off_adj, tb_off_adj - tb_off, --=20 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 --PEpdcbHbO3kvNF3k Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJWrrKMAAoJEGw4ysog2bOSAPsP/jnP1PcRZWNDwbsTSme23LyK 12CksypXAZ4eDfq92a9Q+KqfpPC9jctxXz2tHzlMH2Y1haa3TpHGMjZZUC0fzhzh 29xds0k5BWjCA0GYCKJ/3KOQzrwTj3jc10tvRHp3B1DwyDIA0vRBBsdvvaQkxBDr BEQ/okI+UVgiiokFt+iLXpAEISe2AiaVpg8uotnL4qXH5oKHNIZfxoQz/PlVQ4rP nRP9PxpwAiK7PYuVp0Trz7/CGIoI9+YiSoc6n2K95rghSv81Ow/gYNrpAEx3ePH8 0FOgSKHW1seuONPgVtoDsra250pq/kIs6moLtxKc3a4G+fjL5qIkryR+wIYDbKtm Qs68R8sWLDYa6TCh+SHEaAZRcOjWi4URp/ptOsviICAGthklSP1HrXpXlQGUgfBJ 493IkAynM0xr6VnyiD8VCVJ4HmivCZ8xiK5D1GL9y3u7Oi8KjZ3TkcPbH8OUCsBA oayEpmnXBGvBLxdMGQo1SCqdlOH/SyAeGcxNp9f0FdYTZLh4vGv+/jjXD427GQw5 iQu9A2w5aUJq/ezSsPq1WFHkvSBWGmAxB3s2dHKWpnwURtOLYJ6ZvpLdb4cIZIRb FXjWKDPdc0jVamFddUIEU6Iabgw2XpaMfhrm/pBPTmKQYQw8BUo6qiZ90NuXbCfF K9BsqdIpPgV6/bgLNUEw =sX+H -----END PGP SIGNATURE----- --PEpdcbHbO3kvNF3k--