From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54772) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YDxV2-0000Ny-43 for qemu-devel@nongnu.org; Wed, 21 Jan 2015 10:47:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YDxUx-0007BN-OJ for qemu-devel@nongnu.org; Wed, 21 Jan 2015 10:47:20 -0500 Message-ID: <54BFC1D9.6000800@ilande.co.uk> Date: Wed, 21 Jan 2015 15:12:25 +0000 From: Mark Cave-Ayland MIME-Version: 1.0 References: <1419294981-17368-1-git-send-email-mark.cave-ayland@ilande.co.uk> <1419294981-17368-6-git-send-email-mark.cave-ayland@ilande.co.uk> <54BE6DCC.5080609@redhat.com> In-Reply-To: <54BE6DCC.5080609@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 5/7] ppc: force update of all msr bits in cpu_post_load List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini , qemu-ppc@nongnu.org, qemu-devel@nongnu.org, agraf@suse.de On 20/01/15 15:01, Paolo Bonzini wrote: > On 23/12/2014 01:36, Mark Cave-Ayland wrote: >> Since env->msr has already been restored by the time cpu_post_load is called, >> make sure that ppc_store_msr() is explicitly called with all msr bits marked >> as invalid. >> >> This solves the issue where MSR flags aren't set correctly when restoring a VM >> snapshot, in particular the internal env->excp_prefix value when MSR_EP has >> been altered by a guest. >> >> Signed-off-by: Mark Cave-Ayland >> --- >> target-ppc/machine.c | 8 +++++++- >> 1 file changed, 7 insertions(+), 1 deletion(-) >> >> diff --git a/target-ppc/machine.c b/target-ppc/machine.c >> index c801b82..9669063 100644 >> --- a/target-ppc/machine.c >> +++ b/target-ppc/machine.c >> @@ -159,6 +159,7 @@ static int cpu_post_load(void *opaque, int version_id) >> PowerPCCPU *cpu = opaque; >> CPUPPCState *env = &cpu->env; >> int i; >> + target_ulong msr; >> >> /* >> * We always ignore the source PVR. The user or management >> @@ -190,7 +191,12 @@ static int cpu_post_load(void *opaque, int version_id) >> /* Restore htab_base and htab_mask variables */ >> ppc_store_sdr1(env, env->spr[SPR_SDR1]); >> } >> - hreg_compute_hflags(env); >> + >> + /* Mark all msr bits invalid before restoring */ >> + msr = env->msr; >> + env->msr = ~env->msr; >> + ppc_store_msr(env, msr); >> + >> hreg_compute_mem_idx(env); >> >> return 0; >> > > This is wrong for this line of hreg_store_msr: > > if (unlikely((env->flags & POWERPC_FLAG_TGPR) && > ((value ^ env->msr) & (1 << MSR_TGPR)))) { > /* Swap temporary saved registers with GPRs */ > hreg_swap_gpr_tgpr(env); > } > > I think you need to change the ~ with "^ ~(1 << MSR_TGPR)". It took me a little time to decipher how that worked, but yes it seems fine in my tests here. I'll resend the series with with your Reviewed-by added to the previous patch. Many thanks, Mark.