From patchwork Thu Mar 10 11:26:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 550090 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp901794mag; Thu, 10 Mar 2022 03:32:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJwcsk9WxCZ6l3zVpNS1sRsTy5L9SLoM0oCYYW8rJEmRMKRJIEVU8pN0jAToUNFu0geRUji/ X-Received: by 2002:a25:7407:0:b0:628:97bf:39e5 with SMTP id p7-20020a257407000000b0062897bf39e5mr3249251ybc.597.1646911970338; Thu, 10 Mar 2022 03:32:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646911970; cv=none; d=google.com; s=arc-20160816; b=CRl1JVQIL8h9Eulp/XcAgGWxpg53i/fPnZXmMonipltanVm2pzDSXw5rcPSmbvQ5nA wWcIkFIZcpPCCSfsWinAgR1ffdZZqUamMZF6D4by6NsbEH2hOHrAmZT+2+fbrU3IjR9o 7BrCDMmPXDIFvEdKhxNp6hScLNqRKHuszF7zHMaqBEzm9ywlML+80U8vag1XjAM2Ih25 qnr3ExURDgrpcukaXc0/GuHBAwYbkPvZNmvfk4FYpWV2ossRB3sphqp+w2CuDMJw4mMp fCWZ1GPeCGQPDmVg0Iy2QzFxLi5SeiSxY1jk9SwNgKsC0td0uQSXbvAqQbOC0a0Gxp+I 447w== 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=sLj6JkBIZs+pNXo0KcbHngyos4ugjFtFayVOvZJfdpk=; b=QEMZrXvMm/QOQKanMFCG6lIQfoIPCjNLNIUzUgcfHGLbcSakxujkbysHwDC9vdoFKk C8dI11gdJZdtKiz/DagbY8SjHNdqrs5E8HzCV45jNDR7InKf2yDmE1EMChhB/ouv+g7U 5VoFmrd9GwLM4L5AarC/zIZOIZRgoHJNEVDf4To/4vfoJwuTCHTUIx07KhzfcYaBQIEM aIjQwHQ/QIR+u1RB4Fo13e0K8pxFz5UDnEtl4ioQjE4llKa2XcdoNsdSCAUOCXJCx1Xt XGJ6segoUThOTwwclCuN6+qrUN3bbv+VSxBhCMOIkAtRg+UiwXMSnHubK3yEBHqq0Rv7 nvfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=LdGuY8oX; 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 n11-20020a5b048b000000b0062b774623e9si2893974ybp.181.2022.03.10.03.32.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Mar 2022 03:32:50 -0800 (PST) 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=LdGuY8oX; 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]:37828 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSH2H-0002Uc-PT for patch@linaro.org; Thu, 10 Mar 2022 06:32:49 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50598) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSGxE-00050l-RQ for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:27:37 -0500 Received: from [2607:f8b0:4864:20::42e] (port=46757 helo=mail-pf1-x42e.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nSGxD-0007vY-9e for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:27:36 -0500 Received: by mail-pf1-x42e.google.com with SMTP id s11so4812792pfu.13 for ; Thu, 10 Mar 2022 03:27:34 -0800 (PST) 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=sLj6JkBIZs+pNXo0KcbHngyos4ugjFtFayVOvZJfdpk=; b=LdGuY8oX8KCnL3VZ0f5HoKPlY+taKpgKAemBRuz+nuarsPBkwzGRYtMslizFfwc4ja +QVqUVmc/VhETytNP9gxvJCkNg3YkR/Cibd+R7teLbYIUAaEDyJa0gURCAtoQW5HNqI8 CzS1ev6A392a7MNm6VVY0lanXFQcBMXInRw0C3ISgD9hfttydPizy3UXATA4AgC+Tbgi tqxLMPSfKr2vPOqPINmucUVNtIpgn2wg0ASoBIlmMItViOA28jRrh1GdFA31gUScwkMU znb/oZqT4ywuwDpNKV9bseuC38pyd6TPTzW0KvwXvnO5W2nR4By69E6D71UEOdQNJnHD wb0Q== 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=sLj6JkBIZs+pNXo0KcbHngyos4ugjFtFayVOvZJfdpk=; b=5bj2uPSE8UZ8V2vrUgsda+2YyXUtjTa9UF0T1H20nYs5AcF9f7gQ/H7i6l+7OtyIbJ GVFJPW3gny3VEWzyt7linlZnugtyyynGdT4o0y2ZGnlq341w21vqEDYudXILNp7IQTcu iaveK0p8ZAGWq/mLS/LezR8PB+UDwa06bcsyb1yNkwNKVQrfsmVESEnJDpRzGu2O1Fqh EoLDprJrJYtXORThOvtWbxXongiKz7Cg+S2EGLjEALWgHZTfQ3rrItbVWRJDrW9uQCx/ je+u9wRVf1IdQgFau2AxPoWIAqDnaSLq21FatMEjf+BYqkL4NtBaDg8MSzlIyJFaBHc6 r9mg== X-Gm-Message-State: AOAM530q9xrY3R57L1OizTBOBQ7CMkJg+9c5FJGn+I8P5vrf+hi3Djof dgQJx80m6DNBydKLYkM5LD31jVS0XBsTdA== X-Received: by 2002:a63:1c8:0:b0:380:189b:1e66 with SMTP id 191-20020a6301c8000000b00380189b1e66mr3599120pgb.71.1646911653938; Thu, 10 Mar 2022 03:27:33 -0800 (PST) Received: from localhost.localdomain (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id js15-20020a17090b148f00b001bfc8614b93sm3114977pjb.1.2022.03.10.03.27.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Mar 2022 03:27:33 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 06/48] target/nios2: Fix BRET instruction Date: Thu, 10 Mar 2022 03:26:43 -0800 Message-Id: <20220310112725.570053-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220310112725.570053-1-richard.henderson@linaro.org> References: <20220310112725.570053-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::42e (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::42e; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42e.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@linaro.org, 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. Reported-by: Peter Maydell Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- 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 */