From patchwork Thu Mar 17 05:04:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 552224 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp879951mag; Wed, 16 Mar 2022 22:23:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz4fQXxSfzFF1etMLI6LYtIaQGyGh0/DjpVLbKve/9HkpdxQsMx6S8yAU8ecQu4iBQHrFSK X-Received: by 2002:a05:622a:48e:b0:2e0:706f:1d4 with SMTP id p14-20020a05622a048e00b002e0706f01d4mr2407963qtx.326.1647494592500; Wed, 16 Mar 2022 22:23:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647494592; cv=none; d=google.com; s=arc-20160816; b=uqk4vLx90A3q+vnW6Uvr6CDBzWlwGgH8Dv2DvhYqbAKNOTM41cri/tFZg8mTyb/jWP Qqkk8L29wBVMnlZc/vAAZuQgQlDkdgbtuGHZlkV+xiiHMQ6Q3zlF+NRNirl3IbvYrOnc +ybegyV4o3GOj+IANt/4a8tJoVXeHkCbxIDMYcoafzFR7WBXh4iGP+qgoRBUaEZhzRNP 4sMg/qvgFyxxfCGOT5i9HerhzOVrnDB/GJED5MpEZHBnmALrJXy3y9HuiZmZSQ5C4Sq+ gorOJKx7dGTzi2TWSw/sdyKr7HEl4Tkq6jU6903fslWVBt/aSTR29cbY8mJWqFdSW+RP QeBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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:to:from :dkim-signature; bh=L+hHIFlWfBTWBYr3FWgA0oFT6zz/eF9rCjwaIxiotag=; b=O9zwF6Xy+R+U8dmiiGCWGd+6V6Lejtn0zSGXQkpia+g6qo5Lz2QSioc7AhbzuWIsWb Q7pw1oj8BVbyGuFrVeTNqXokyntLA99zsbtEqan2Hjo5ch6WMukr1hwButofC2y6J2Gc GpM3u1KJwCjj85bH52+UnjZZtiWA+vVJPouLfIcyYE698vITgqKd/fj8Z/w9m+3wk9fH IjzZQ4/RVx4iGgB3uFWpjPehsYUiZd8nNjOBVNfM/t4sETXc0tvRBnn4YnK/2WHQ6vFv 8pqHaGiajKFiM46WaetJFdp8tW7F6JjgfgkmhBSiWEb3mfRppZc3y2cPVWfZp0Ooyymj 2kqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=CBkjPBEj; 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"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id a14-20020a05620a438e00b0067dca16335bsi1002466qkp.624.2022.03.16.22.23.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 16 Mar 2022 22:23:12 -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; dkim=fail header.i=@linaro.org header.s=google header.b=CBkjPBEj; 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"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:57514 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nUibQ-0004Eu-3y for patch@linaro.org; Thu, 17 Mar 2022 01:23:12 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50622) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nUiKc-0000Us-An for qemu-devel@nongnu.org; Thu, 17 Mar 2022 01:05:50 -0400 Received: from [2607:f8b0:4864:20::62a] (port=38572 helo=mail-pl1-x62a.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nUiKa-0002DA-L9 for qemu-devel@nongnu.org; Thu, 17 Mar 2022 01:05:50 -0400 Received: by mail-pl1-x62a.google.com with SMTP id n18so3559966plg.5 for ; Wed, 16 Mar 2022 22:05:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=L+hHIFlWfBTWBYr3FWgA0oFT6zz/eF9rCjwaIxiotag=; b=CBkjPBEjEnkCygb/TQ0Lwvh9voa/HM7X3RdQUdZZ9PzDHMESJy6LNFS1bOwRID5Y2/ 1N9c+UQ9LBtmCoBPxLOdbKIerT8eIgw4rtbIReTLgViBQbh3mgjWJPN5855mS7l4l/RU rjjnEFBvbnxzGcbxSY5eJK30s3Q5pVRZprq9bZfXJX+dJqsugKz82YpWn7YlgDozVLIb qNgCByblyQg57GbGZsprAsMyG3J9MdmUxYJgxD3IOud2qobvbb5AjCNcBJgTTBE09lrH DDlOSpB4b3orVtYc6Vk3e9Ci6Mr2GhysNBze6DgQU07xqy2THADhrCpeK/dLvJtWEha0 zkPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=L+hHIFlWfBTWBYr3FWgA0oFT6zz/eF9rCjwaIxiotag=; b=xIuu5n/pIRN4Rg4PFVXh9jbjgU/SaCzljNNF/L2p13XpVZlh6xoJOoNHQcOI3cfx2N bme32xhq9g0PXW0DCyzGwxkwctjiy7bMJ6PAqX5FTf5beFXcM42a1zlbCB11IjOfse/r DUGMWPYccutJb7izy3ZABlh0dKbrEzbE+kI38tVdcz8SI7RojpcoVIcMH3e+hWigOMyT d6ssSTiQlTqINJC7rJkLwIB+1aUOjt041wkTjtPcnj3jaW1+OoQ9VIUDw3GnKSuPrmWo X8Z1e+l3q0zIaWUTV7kKULiSPDv0PWw9mbnWcH1Mjfyb1LbRNggdtMVmh9bFK94QmH6G 1FoQ== X-Gm-Message-State: AOAM531xz1R+14srLkUaSSXYpmaJ+MIIzQiCTRYOkmWFnKuQR53qrNGJ xHbq+zvySGLXYaBaPZBXKJMvWeFSkEb6CA== X-Received: by 2002:a17:903:240c:b0:153:c8df:7207 with SMTP id e12-20020a170903240c00b00153c8df7207mr2990519plo.44.1647493546831; Wed, 16 Mar 2022 22:05:46 -0700 (PDT) Received: from localhost.localdomain (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id h22-20020a056a001a5600b004f7c17b291asm5101357pfv.87.2022.03.16.22.05.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Mar 2022 22:05:46 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH for-7.1 v6 07/51] target/nios2: Fix BRET instruction Date: Wed, 16 Mar 2022 22:04:54 -0700 Message-Id: <20220317050538.924111-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220317050538.924111-1-richard.henderson@linaro.org> References: <20220317050538.924111-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::62a (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: marex@denx.de, Peter Maydell , amir.gonnen@neuroblade.ai Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We had failed to copy BSTATUS back to STATUS, and diagnose supervisor-only. The spec is light on the specifics of the implementation of bret, but it is an easy assumption that the restore into STATUS should work the same as eret. Therefore, reuse the existing helper_eret. Reviewed-by: Peter Maydell Reported-by: Peter Maydell Signed-off-by: Richard Henderson --- target/nios2/translate.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/target/nios2/translate.c b/target/nios2/translate.c index 7c2c430e99..3f7bbd6d7b 100644 --- a/target/nios2/translate.c +++ b/target/nios2/translate.c @@ -407,12 +407,22 @@ static void ret(DisasContext *dc, uint32_t code, uint32_t flags) dc->base.is_jmp = DISAS_JUMP; } -/* PC <- ba */ +/* + * status <- bstatus + * PC <- ba + */ static void bret(DisasContext *dc, uint32_t code, uint32_t flags) { - tcg_gen_mov_tl(cpu_pc, cpu_R[R_BA]); + if (!gen_check_supervisor(dc)) { + return; + } - dc->base.is_jmp = DISAS_JUMP; +#ifdef CONFIG_USER_ONLY + g_assert_not_reached(); +#else + gen_helper_eret(cpu_env, cpu_R[CR_BSTATUS], cpu_R[R_BA]); + dc->base.is_jmp = DISAS_NORETURN; +#endif } /* PC <- rA */