From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45728) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ajQBA-00065X-DX for qemu-devel@nongnu.org; Fri, 25 Mar 2016 07:45:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ajQB7-0000tC-E2 for qemu-devel@nongnu.org; Fri, 25 Mar 2016 07:45:24 -0400 Received: from e06smtp05.uk.ibm.com ([195.75.94.101]:45853) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ajQB7-0000sm-5E for qemu-devel@nongnu.org; Fri, 25 Mar 2016 07:45:21 -0400 Received: from localhost by e06smtp05.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 25 Mar 2016 11:45:16 -0000 Date: Fri, 25 Mar 2016 12:45:10 +0100 From: Greg Kurz Message-ID: <20160325124510.43fe7d41@bahia.huguette.org> In-Reply-To: <1458833333-24103-1-git-send-email-clg@fr.ibm.com> References: <1458833333-24103-1-git-send-email-clg@fr.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [Qemu-ppc] [PATCH] spapr: compute interrupt vector address from LPCR List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?UTF-8?B?Q8OpZHJpYw==?= Le Goater Cc: Thomas Huth , qemu-ppc@nongnu.org, qemu-devel@nongnu.org, David Gibson Hi Cedric, On Thu, 24 Mar 2016 16:28:53 +0100 C=C3=A9dric 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=C3=A9dric 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; And how are we sure env contains the migrated register values ? Actually, this "works" because vmstate_ppc_cpu is registered before vmstate= _spapr, and the same ordering happens to be used when sending state over the wire, = but it looks wrong. The excp_prefix should be restored in cpu_post_load(), unless I'm missing something. Cheers. -- Greg > + 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; > } >=20 > 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; > + } > +} > + > 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