From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49768) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eJpjX-0003IB-JD for qemu-devel@nongnu.org; Tue, 28 Nov 2017 18:56:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eJpjS-0004n1-OA for qemu-devel@nongnu.org; Tue, 28 Nov 2017 18:56:11 -0500 Message-ID: <1511913359.2513.0.camel@gmail.com> From: Suraj Jitindar Singh Date: Wed, 29 Nov 2017 10:55:59 +1100 In-Reply-To: References: <20171128174310.15700-1-lvivier@redhat.com> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [Qemu-ppc] [PATCH v2] pseries: fix TCG migration List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Daniel Henrique Barboza , Laurent Vivier , qemu-devel@nongnu.org Cc: David Gibson , qemu-ppc@nongnu.org, Bharata B Rao On Tue, 2017-11-28 at 17:26 -0200, Daniel Henrique Barboza wrote: > > On 11/28/2017 03:43 PM, Laurent Vivier wrote: > > Migration of pseries is broken with TCG because > > QEMU tries to restore KVM MMU state unconditionally. > > > > The result is a SIGSEGV in kvm_vm_ioctl(): > > > > #0 kvm_vm_ioctl (s=0x0, type=-2146390353) > > at qemu/accel/kvm/kvm-all.c:2032 > > #1 0x00000001003e3e2c in kvmppc_configure_v3_mmu > > (cpu=, > > radix=, gtse=, > > proc_tbl=) > > at qemu/target/ppc/kvm.c:396 > > #2 0x00000001002f8b88 in spapr_post_load (opaque=0x1019103c0, > > version_id=) at qemu/hw/ppc/spapr.c:1578 > > #3 0x000000010059e4cc in vmstate_load_state (f=0x106230000, > > vmsd=0x1009479e0 , opaque=0x1019103c0, > > version_id=) at qemu/migration/vmstate.c:165 > > #4 0x00000001005987e0 in vmstate_load (f=, > > se=) > > at qemu/migration/savevm.c:748 > > > > This patch fixes the problem by not calling the KVM function with > > the > > TCG mode. > > > > Fixes: d39c90f5f3 ("spapr: Fix migration of Radix guests") > > Signed-off-by: Laurent Vivier > > --- > > v2: fix the comment to keep GDB backtrace lines starting with '#' > > > > hw/ppc/spapr.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c > > index 9efddeaee5..a471de6cab 100644 > > --- a/hw/ppc/spapr.c > > +++ b/hw/ppc/spapr.c > > @@ -1570,7 +1570,7 @@ static int spapr_post_load(void *opaque, int > > version_id) > > err = spapr_rtc_import_offset(&spapr->rtc, spapr- > > >rtc_offset); > > } > > > > - if (spapr->patb_entry) { > > + if (kvm_enabled() && spapr->patb_entry) { > > As an alternative, I believe you can also do: > > if (!!spapr->patb_entry) { > > because the !! will return false if patb_entry is either undefined > (as in Hmmm, no. patb_entry is definately used in tcg > TCG) or zero (as set in spapr_reallocate_hpt). This is the same logic > used > in spapr_patb_entry_needed too. > > But I am fine with what you did and it's also clearer, so > > > Reviewed-by: Daniel Henrique Barboza > > > > > PowerPCCPU *cpu = POWERPC_CPU(first_cpu); > > bool radix = !!(spapr->patb_entry & PATBE1_GR); > > bool gtse = !!(cpu->env.spr[SPR_LPCR] & LPCR_GTSE); > >