Received: from eggs.gnu.org ([2001:4830:134:3::10]:50259) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZOmYQ-0008FH-AT for qemu-devel@nongnu.org; Mon, 10 Aug 2015 08:51:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZOmYM-0006Pj-Ur for qemu-devel@nongnu.org; Mon, 10 Aug 2015 08:51:50 -0400 Received: from mnementh.archaic.org.uk ([2001:8b0:1d0::1]:34893) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZOmYM-0006PI-N5 for qemu-devel@nongnu.org; Mon, 10 Aug 2015 08:51:46 -0400 From: Peter Maydell Date: Mon, 10 Aug 2015 13:34:30 +0100 Message-Id: <1439210072-11028-3-git-send-email-peter.maydell@linaro.org> In-Reply-To: <1439210072-11028-1-git-send-email-peter.maydell@linaro.org> References: <1439210072-11028-1-git-send-email-peter.maydell@linaro.org> Subject: [Qemu-devel] [PATCH 2/4] target-sparc: Split cpu_put_psr into side-effect and no-side-effect parts List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Blue Swirl , Mark Cave-Ayland , =?UTF-8?q?Andreas=20F=C3=A4rber?= , patches@linaro.org For inbound migration we really want to be able to set the PSR without having any side effects, but cpu_put_psr() calls cpu_check_irqs() which might try to deliver CPU interrupts. Split cpu_put_psr() into the no-side-effect and side-effect parts. This includes reordering the cpu_check_irqs() to the end of cpu_put_psr(), because that function may actually end up calling cpu_interrupt(), which does not seem like a good thing to happen in the middle of updating the PSR. Suggested-by: Blue Swirl Signed-off-by: Peter Maydell --- target-sparc/cpu.h | 1 + target-sparc/win_helper.c | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/target-sparc/cpu.h b/target-sparc/cpu.h index 0522b65..9a4a010 100644 --- a/target-sparc/cpu.h +++ b/target-sparc/cpu.h @@ -542,6 +542,7 @@ int cpu_sparc_exec(CPUState *cpu); /* win_helper.c */ target_ulong cpu_get_psr(CPUSPARCState *env1); void cpu_put_psr(CPUSPARCState *env1, target_ulong val); +void cpu_put_psr_raw(CPUSPARCState *env1, target_ulong val); #ifdef TARGET_SPARC64 target_ulong cpu_get_ccr(CPUSPARCState *env1); void cpu_put_ccr(CPUSPARCState *env1, target_ulong val); diff --git a/target-sparc/win_helper.c b/target-sparc/win_helper.c index f01ae08..5b6d7b5 100644 --- a/target-sparc/win_helper.c +++ b/target-sparc/win_helper.c @@ -64,23 +64,28 @@ target_ulong cpu_get_psr(CPUSPARCState *env) #endif } -void cpu_put_psr(CPUSPARCState *env, target_ulong val) +void cpu_put_psr_raw(CPUSPARCState *env, target_ulong val) { env->psr = val & PSR_ICC; #if !defined(TARGET_SPARC64) env->psref = (val & PSR_EF) ? 1 : 0; env->psrpil = (val & PSR_PIL) >> 8; -#endif -#if ((!defined(TARGET_SPARC64)) && !defined(CONFIG_USER_ONLY)) - cpu_check_irqs(env); -#endif -#if !defined(TARGET_SPARC64) env->psrs = (val & PSR_S) ? 1 : 0; env->psrps = (val & PSR_PS) ? 1 : 0; env->psret = (val & PSR_ET) ? 1 : 0; - cpu_set_cwp(env, val & PSR_CWP); #endif env->cc_op = CC_OP_FLAGS; +#if !defined(TARGET_SPARC64) + cpu_set_cwp(env, val & PSR_CWP); +#endif +} + +void cpu_put_psr(CPUSPARCState *env, target_ulong val) +{ + cpu_put_psr_raw(env, val); +#if ((!defined(TARGET_SPARC64)) && !defined(CONFIG_USER_ONLY)) + cpu_check_irqs(env); +#endif } int cpu_cwp_inc(CPUSPARCState *env, int cwp) -- 1.9.1