From patchwork Mon Aug 10 12:34:30 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 52229 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by patches.linaro.org (Postfix) with ESMTPS id AA5D62152A for ; Mon, 10 Aug 2015 12:34:44 +0000 (UTC) Received: by labia3 with SMTP id ia3sf39164269lab.1 for ; Mon, 10 Aug 2015 05:34:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=axSW8S9uqItOnB+/ZI63IZ9j6SGtcAJROBhfoOsDn3s=; b=RwRHoc+fCAHKvDyb3/qwzRo8/s+H6L4+LlIMsXCCwqE6/gZoXAbX7YZW45apUXTeFU ut7Y3SaAR08whNvLCi2d5ddsWbA2Te9P/bSkh/VFtzZv9ePohh3XseaU8QMST17v0qwx tRALg+rK2ewhXR5gL20mtR+1ukgrWF+WDHO4uvl3+qyLYUg2/SM+3BqhPxehvNKimDS6 T8QT9Y8HaQwjDCT9F+1aksgM1gnnWcE1w4Wv92ST+KAPcz+6fciHYIRj6xMU90e4+Tvt en0nQC5PpvFjuw0pAH2MMr76O77mD2zKyAOdsfm4qt6A0cBvexxNLTzETi7yYhI/xfeg wYeQ== X-Gm-Message-State: ALoCoQmhjCBU1s70CBv59qxMUprteyUn30Qq4ZCyV88om0pKa1Fv822w0+94b8rcXiJmO67Ybrkk X-Received: by 10.112.50.10 with SMTP id y10mr6277395lbn.10.1439210083424; Mon, 10 Aug 2015 05:34:43 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.204.9 with SMTP id ku9ls671188lac.37.gmail; Mon, 10 Aug 2015 05:34:43 -0700 (PDT) X-Received: by 10.112.168.102 with SMTP id zv6mr20099484lbb.45.1439210083271; Mon, 10 Aug 2015 05:34:43 -0700 (PDT) Received: from mail-lb0-f177.google.com (mail-lb0-f177.google.com. [209.85.217.177]) by mx.google.com with ESMTPS id lm12si13957108lac.61.2015.08.10.05.34.43 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Aug 2015 05:34:43 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) client-ip=209.85.217.177; Received: by lbbsx3 with SMTP id sx3so10475241lbb.0 for ; Mon, 10 Aug 2015 05:34:43 -0700 (PDT) X-Received: by 10.112.131.98 with SMTP id ol2mr20193770lbb.56.1439210083176; Mon, 10 Aug 2015 05:34:43 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.7.198 with SMTP id l6csp1906881lba; Mon, 10 Aug 2015 05:34:42 -0700 (PDT) X-Received: by 10.68.174.35 with SMTP id bp3mr44542634pbc.124.1439210079382; Mon, 10 Aug 2015 05:34:39 -0700 (PDT) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id bd11si16366825pac.187.2015.08.10.05.34.37 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 10 Aug 2015 05:34:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::1 as permitted sender) client-ip=2001:8b0:1d0::1; Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1ZOmHg-0002sT-Aj; Mon, 10 Aug 2015 13:34:32 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Blue Swirl , Mark Cave-Ayland , =?UTF-8?q?Andreas=20F=C3=A4rber?= Subject: [PATCH 2/4] target-sparc: Split cpu_put_psr into side-effect and no-side-effect parts Date: Mon, 10 Aug 2015 13:34:30 +0100 Message-Id: <1439210072-11028-3-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1439210072-11028-1-git-send-email-peter.maydell@linaro.org> References: <1439210072-11028-1-git-send-email-peter.maydell@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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)