From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33133) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aklMb-0004or-4L for qemu-devel@nongnu.org; Tue, 29 Mar 2016 00:34:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aklMZ-0007Kf-R1 for qemu-devel@nongnu.org; Tue, 29 Mar 2016 00:34:45 -0400 Date: Tue, 29 Mar 2016 15:35:48 +1100 From: David Gibson Message-ID: <20160329043548.GD15156@voom.fritz.box> References: <1458833333-24103-1-git-send-email-clg@fr.ibm.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="bajzpZikUji1w+G9" Content-Disposition: inline In-Reply-To: <1458833333-24103-1-git-send-email-clg@fr.ibm.com> Subject: Re: [Qemu-devel] [PATCH] spapr: compute interrupt vector address from LPCR List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?iso-8859-1?Q?C=E9dric?= Le Goater Cc: Thomas Huth , qemu-ppc@nongnu.org, qemu-devel@nongnu.org, Greg Kurz --bajzpZikUji1w+G9 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Mar 24, 2016 at 04:28:53PM +0100, C=E9dric Le Goater wrote: > This address is changed by the linux kernel using the H_SET_MODE hcall > and needs to be migrated in order to restart a spapr VM running in > TCG. This can be done using the AIL bits from the LPCR register. >=20 > The patch introduces a spapr_h_set_mode_resource_addr() helper to > share some code with the H_SET_MODE hcall. >=20 > Signed-off-by: C=E9dric Le Goater > --- > hw/ppc/spapr.c | 21 +++++++++++++++++++++ > hw/ppc/spapr_hcall.c | 13 ++----------- > include/hw/ppc/spapr.h | 14 ++++++++++++++ > 3 files changed, 37 insertions(+), 11 deletions(-) >=20 > Index: qemu-dgibson-for-2.6.git/hw/ppc/spapr.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- qemu-dgibson-for-2.6.git.orig/hw/ppc/spapr.c > +++ qemu-dgibson-for-2.6.git/hw/ppc/spapr.c > @@ -1244,6 +1244,24 @@ static bool spapr_vga_init(PCIBus *pci_b > } > } > =20 > +static int load_excp_prefix(void) > +{ > + CPUState *cs; > + > + CPU_FOREACH(cs) { > + CPUPPCState *env =3D &POWERPC_CPU(cs)->env; > + int ail =3D (env->spr[SPR_LPCR] & LPCR_AIL) >> LPCR_AIL_SHIFT; > + > + env->excp_prefix =3D spapr_h_set_mode_resource_addr(ail); > + if (env->excp_prefix =3D=3D H_UNSUPPORTED_FLAG) { > + error_report("LPCR has an invalid AIL value"); > + return -EINVAL; > + } > + } > + > + return 0; > +} > + > static int spapr_post_load(void *opaque, int version_id) > { > sPAPRMachineState *spapr =3D (sPAPRMachineState *)opaque; > @@ -1257,6 +1275,9 @@ static int spapr_post_load(void *opaque, > err =3D spapr_rtc_import_offset(spapr->rtc, spapr->rtc_offset); > } > =20 > + if (!err) { > + err =3D load_excp_prefix(); > + } > return err; > } As Greg says, it seems like this would make more sense in cpu_post_load(). > Index: qemu-dgibson-for-2.6.git/include/hw/ppc/spapr.h > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- qemu-dgibson-for-2.6.git.orig/include/hw/ppc/spapr.h > +++ qemu-dgibson-for-2.6.git/include/hw/ppc/spapr.h > @@ -561,6 +561,20 @@ struct sPAPREventLogEntry { > QTAILQ_ENTRY(sPAPREventLogEntry) next; > }; > =20 > +static inline target_ulong spapr_h_set_mode_resource_addr(target_ulong m= flags) > +{ > + switch (mflags) { > + case H_SET_MODE_ADDR_TRANS_NONE: > + return 0; > + case H_SET_MODE_ADDR_TRANS_0001_8000: > + return 0x18000; > + case H_SET_MODE_ADDR_TRANS_C000_0000_0000_4000: > + return 0xC000000000004000ULL; > + default: > + return H_UNSUPPORTED_FLAG; > + } > +} I'd like to see a different name for this function, and to move it into target-ppc, since I imagine we'll want to re-use it for mtlpcr (and/or mtmsr) once we do the powernv machine type. > void spapr_events_init(sPAPRMachineState *sm); > void spapr_events_fdt_skel(void *fdt, uint32_t epow_irq); > int spapr_h_cas_compose_response(sPAPRMachineState *sm, > Index: qemu-dgibson-for-2.6.git/hw/ppc/spapr_hcall.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- qemu-dgibson-for-2.6.git.orig/hw/ppc/spapr_hcall.c > +++ qemu-dgibson-for-2.6.git/hw/ppc/spapr_hcall.c > @@ -835,17 +835,8 @@ static target_ulong h_set_mode_resource_ > return H_P4; > } > =20 > - switch (mflags) { > - case H_SET_MODE_ADDR_TRANS_NONE: > - prefix =3D 0; > - break; > - case H_SET_MODE_ADDR_TRANS_0001_8000: > - prefix =3D 0x18000; > - break; > - case H_SET_MODE_ADDR_TRANS_C000_0000_0000_4000: > - prefix =3D 0xC000000000004000ULL; > - break; > - default: > + prefix =3D spapr_h_set_mode_resource_addr(mflags); > + if (prefix =3D=3D H_UNSUPPORTED_FLAG) { > return H_UNSUPPORTED_FLAG; > } > =20 >=20 --=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 --bajzpZikUji1w+G9 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJW+gYkAAoJEGw4ysog2bOSVfYQAKB9LtMYjK24BCR3MEhbvJr8 3F4DGyXXEmeStjn2a1WB3+WtsDO/cXpLgLlSbimrqk2YW6Q2REo1sy8ArIsZD09N LpDwcsfHm1Pa8xDbqcr4DQwKOmIIzjBMDcchruvSmFmX4+qm7+MzvexMLfYwqd+P OZ37skaWn9KcgxaGh3y7zj1PupExy5lRAWQHF6ce/yyriQYM/6sqlpDqbgAJ3UST nATfDj5gYF26iUzvyv8E18F3w0pHj4txwjPzE7hP8O4pb4MPvOXGAl3w3Hb5Jq8Q 0PsWE1uwgcHPIam8Wgm45aZmIYP620JBiE8RQwKw1/uI/keTPXFTC6oAcJovrGXj fWyoyxh7XnwiX6mX9ggm5MgYysLtH4ypJlRg8vsIKRKipA5J4KXQW1vHZ0seyp/R kQbuOrbJoYDJdkoKCAXDNtUw+iROnJ//3YOUo+cOescoZyW2CXdYIEJ87Ss8yxYU ct3vicMoK1hpQstRKkNcbjzUy7Jw4gcQu1lDH9ZS436c53Hg61TOSgT4rtmqE00/ i5RQrCOolbAMrmUN4neNQOufRTUJCbSaJBfektUj3z/DmR+DFZBWjR3VqI/1YrOO qp0qdWeBWD1r7qbeXS5cgmhWErl0Cl7SfjGZDPPZJWDx+aEOeOlnULXoPmEXGePZ UaAxyKSkWuXDte0L+ynW =9xRj -----END PGP SIGNATURE----- --bajzpZikUji1w+G9--