From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MKSJv-0006JM-RU for qemu-devel@nongnu.org; Sat, 27 Jun 2009 03:27:32 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MKSJq-0006I6-VT for qemu-devel@nongnu.org; Sat, 27 Jun 2009 03:27:30 -0400 Received: from [199.232.76.173] (port=46866 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MKSJq-0006I0-KW for qemu-devel@nongnu.org; Sat, 27 Jun 2009 03:27:26 -0400 Received: from mx20.gnu.org ([199.232.41.8]:38146) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MKSJp-0003OX-W7 for qemu-devel@nongnu.org; Sat, 27 Jun 2009 03:27:26 -0400 Received: from fmmailgate02.web.de ([217.72.192.227]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MKSJo-0007TH-Ke for qemu-devel@nongnu.org; Sat, 27 Jun 2009 03:27:25 -0400 Message-ID: <4A45C9DA.8030806@web.de> Date: Sat, 27 Jun 2009 09:27:22 +0200 From: Jan Kiszka MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigCE63E937567064DB52049920" Sender: jan.kiszka@web.de Subject: [Qemu-devel] [RESEND][PATCH] KVM: x86: Refactor persistent CPU state List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: qemu-devel , Avi Kivity This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigCE63E937567064DB52049920 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable This patch aligns the KVM-related layout and encoding of the CPU state to be saved to disk or migrated with qemu-kvm. The major differences are reordering of fields and a compressed interrupt_bitmap into a single number as there can be no more than one pending IRQ at a time. Signed-off-by: Jan Kiszka --- target-i386/machine.c | 30 +++++++++++++++++++++++------- 1 files changed, 23 insertions(+), 7 deletions(-) diff --git a/target-i386/machine.c b/target-i386/machine.c index bb8b9db..259302c 100644 --- a/target-i386/machine.c +++ b/target-i386/machine.c @@ -28,7 +28,8 @@ void cpu_save(QEMUFile *f, void *opaque) uint16_t fptag, fpus, fpuc, fpregs_format; uint32_t hflags; int32_t a20_mask; - int i; + int32_t pending_irq; + int i, bit; =20 cpu_synchronize_state(env, 0); =20 @@ -141,11 +142,21 @@ void cpu_save(QEMUFile *f, void *opaque) qemu_put_be64s(f, &env->mtrr_var[i].mask); } =20 - for (i =3D 0; i < sizeof(env->interrupt_bitmap)/8; i++) { - qemu_put_be64s(f, &env->interrupt_bitmap[i]); + /* KVM-related states */ + + /* There can only be one pending IRQ set in the bitmap at a time, so= try + to find it and save its number instead (-1 for none). */ + pending_irq =3D -1; + for (i =3D 0; i < ARRAY_SIZE(env->interrupt_bitmap); i++) { + bit =3D ffsll(env->interrupt_bitmap[i]); + if (bit) { + pending_irq =3D i * 64 + bit - 1; + break; + } } - qemu_put_be64s(f, &env->tsc); + qemu_put_sbe32s(f, &pending_irq); qemu_put_be32s(f, &env->mp_state); + qemu_put_be64s(f, &env->tsc); } =20 #ifdef USE_X86LDOUBLE @@ -179,6 +190,7 @@ int cpu_load(QEMUFile *f, void *opaque, int version_i= d) uint32_t hflags; uint16_t fpus, fpuc, fptag, fpregs_format; int32_t a20_mask; + int32_t pending_irq; =20 if (version_id < 3 || version_id > CPU_SAVE_VERSION) return -EINVAL; @@ -324,12 +336,16 @@ int cpu_load(QEMUFile *f, void *opaque, int version= _id) qemu_get_be64s(f, &env->mtrr_var[i].mask); } } + if (version_id >=3D 9) { - for (i =3D 0; i < sizeof(env->interrupt_bitmap)/8; i++) { - qemu_get_be64s(f, &env->interrupt_bitmap[i]); + qemu_get_sbe32s(f, &pending_irq); + memset(&env->interrupt_bitmap, 0, sizeof(env->interrupt_bitmap))= ; + if (pending_irq >=3D 0) { + env->interrupt_bitmap[pending_irq / 64] |=3D + (uint64_t)1 << (pending_irq % 64); } - qemu_get_be64s(f, &env->tsc); qemu_get_be32s(f, &env->mp_state); + qemu_get_be64s(f, &env->tsc); } =20 /* XXX: ensure compatiblity for halted bit ? */ --------------enigCE63E937567064DB52049920 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org iEYEARECAAYFAkpFydsACgkQniDOoMHTA+kd+ACbBONZ1ytWB5N7PZ4bebEsD5y3 Um8AnRdLzJzQLoQ0xBaOnPD5eAQt8p73 =aUH9 -----END PGP SIGNATURE----- --------------enigCE63E937567064DB52049920--