From patchwork Wed Sep 21 15:52:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 607953 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2467894pvb; Wed, 21 Sep 2022 08:55:02 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7TezX8XAGFJBzVUM2zqKAgzKVifUU9dcP9KUKmSMhmDxijlI6RYbbrPVxRdjw5mv9W04MQ X-Received: by 2002:ae9:dc85:0:b0:6cd:ea8d:5113 with SMTP id q127-20020ae9dc85000000b006cdea8d5113mr20315119qkf.55.1663775702124; Wed, 21 Sep 2022 08:55:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663775702; cv=none; d=google.com; s=arc-20160816; b=oyx/lduVTmD/gD1Y8hQBumINxnAtOwuK2qkxlETuwwTI0FPIkCqkwstYLaJzGVNCyU uad7BUx7WguYziwrzOJYcDBoOn/bLuvr4NaRKUd0TUfOjc9/HwMC5gRwFspvInVqQKjQ NeIohPTelwBP7j9+e+XDw4RC2TZ8b/G+gRqzdXW0aQdwipwiI0DFt7vnby5ZTGnlirL8 3La3XtDr/f5MYNIGPRqF1Gx/3Xq0/qWUgwjrYV9rlA47fUeKRMeRr34yK468/sECt+6X K3A6Nbwmi93VjUhsCvmGwY7dmzXCDWEB5bSYLD3iwhsDpoihMVWVjTAqql4MqXkmfTV4 NitA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=W2OG8KHhjXzWvL8pyFVikGsQzxQeE7XZ5KZvk5D9oC0=; b=atsMSAcvvxx/myLQKR21qQgM3FBY/WzMKxam/YQLjr2Pu75uHhaTH4jTdD43K9lZAE xfqKMTtKKvUMBf42PFmXQueM655V/UhSLS0KuQj5aZLV3jBY4waydkx9BUeJ2jNOaVgA +E97Q8Esss9agbFALKsVixGtJ105tmUaDNB5rGjgYckEHhLwTX/Hby+imUdF7ZA40xob /8bh3aAvLzKC+a0xjOVAtOTCWajvorH9ECyxpzZ07h3eeZ5YFkrZrssG5luZRsr2tgLu /fmlwQJ2HzEvlWz6RmPSjXebvULbo+Ao5Vd+V8YnZczgFWSJVT4Flh8I/uQn2UWf90m/ XWEw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id l18-20020a05620a28d200b006ce3c82887csi1874748qkp.406.2022.09.21.08.55.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 21 Sep 2022 08:55:02 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1]:34718 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ob23x-0000u5-Mb for patch@linaro.org; Wed, 21 Sep 2022 11:55:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43864) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ob21J-0006UB-Pm for qemu-devel@nongnu.org; Wed, 21 Sep 2022 11:52:17 -0400 Received: from mout.kundenserver.de ([212.227.126.135]:49489) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ob21I-0006Bw-0F for qemu-devel@nongnu.org; Wed, 21 Sep 2022 11:52:17 -0400 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1Mdva2-1pAv4F3UTW-00b70D; Wed, 21 Sep 2022 17:52:14 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Laurent Vivier , Richard Henderson , Mark Cave-Ayland Subject: [PULL 3/5] target/m68k: Perform writback before modifying SR Date: Wed, 21 Sep 2022 17:52:09 +0200 Message-Id: <20220921155211.402559-4-laurent@vivier.eu> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220921155211.402559-1-laurent@vivier.eu> References: <20220921155211.402559-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:pzxou0mKXGsU7dP4/b0wxckJpZ5QMQKU1mHG1wVpJuHBOi3SOCL kHqxoxYvxwTFQ0G7zuKkPq5pEJiYjKFRd5qxsE6CSa2ha10PqJBNc7a2jOzLuViZS2aPrme fjHYrsKAlqYqH8oM43Ez3A+e7avbmg3MvcHCQhiH2jwQIE5lP0BmAlzQ4vizOWeOTWfr54x j41eo/vDqbbwOL7ZT4Sow== X-UI-Out-Filterresults: notjunk:1;V03:K0:jxz/plHLh+M=:xsXndB3r1UogomeNHTeF7+ 7W7OV8yC58bcwYFvCH3f0MqAw+21A0qhi9M+YOg6Geyy+hs2+UPRoyfpDFVKbfadYzySwdnxA Wqd7CiglZ5fOcIHxzPAqTaSrmHWqzwysksK3lLWV2Lj5D5qIUFqcOoVtGotpQBSI5JlYkyxXm wNStFxHAJJNWonxjPPEbFnHYiddyxn8/h85dLLSN35T9xJOzO8ULGUaqdFlyyIH9liOlLqSpe g+QUk1FFwK67ZVUsCtwntxOgn2RaxBdIfhaMdBvAIwA1QV+fYA6HCps6znF/pKSuK52D8EfLL BnbA9RW+BCJlC+eyBBgknTVpI9aAnOv5HoMEHXB3lZoE/Q4j64Vg0niXksamR0s+73w6c3MRI 4NwuktSfggm6Mc27mB3ueUEICjzOorz0VNoZSI2np58gvJsnQdCBhPxrAvZ25pNHka2GGZv37 MeOg+56JSYA/jaOuer5OsHaI5VkKh/GJmoYlxYaUP74klMTx4pFY1tpJrztwIfJI7eKN/wvr/ Wf5YxMywW2a2jNtg5iGhQVNKkhlBMjruXl506ECQqA/ohaD01sknE/oTq7DjWmGAhdtwJ3tgG LzKUY4ZcpKj0ljw26tevRrN0zZwEmzUx9fKRs9W54crzrXYPod47XlAbOnuQzZWRuSZ8M8ZZo IM4nGFQALnzYC2JCKyUE+/NYMjpHwBDgD8eeeM1AOD1yny+bbxmYNboASop6g+tF2wbHC9zAP 1XjInxOEbByRuZy1npDgtoUV48crYxG8bOVNFhZo+w7ok70eFsbl9CQIPzezAXj/fF8dpeR88 xA7L46B Received-SPF: none client-ip=212.227.126.135; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Writes to SR may change security state, which may involve a swap of %ssp with %usp as reflected in %a7. Finish the writeback of %sp@+ before swapping stack pointers. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1206 Signed-off-by: Richard Henderson Reviewed-by: Laurent Vivier Reviewed-by: Mark Cave-Ayland Message-Id: <20220913142818.7802-3-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- target/m68k/translate.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/target/m68k/translate.c b/target/m68k/translate.c index c9bb05380323..4640eadf78e1 100644 --- a/target/m68k/translate.c +++ b/target/m68k/translate.c @@ -2285,9 +2285,9 @@ static void gen_set_sr_im(DisasContext *s, uint16_t val, int ccr_only) tcg_gen_movi_i32(QREG_CC_N, val & CCF_N ? -1 : 0); tcg_gen_movi_i32(QREG_CC_X, val & CCF_X ? 1 : 0); } else { - TCGv sr = tcg_const_i32(val); - gen_helper_set_sr(cpu_env, sr); - tcg_temp_free(sr); + /* Must writeback before changing security state. */ + do_writebacks(s); + gen_helper_set_sr(cpu_env, tcg_constant_i32(val)); } set_cc_op(s, CC_OP_FLAGS); } @@ -2297,6 +2297,8 @@ static void gen_set_sr(DisasContext *s, TCGv val, int ccr_only) if (ccr_only) { gen_helper_set_ccr(cpu_env, val); } else { + /* Must writeback before changing security state. */ + do_writebacks(s); gen_helper_set_sr(cpu_env, val); } set_cc_op(s, CC_OP_FLAGS);