From nobody Wed Feb 11 12:05:35 2026 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1650649691; cv=none; d=zohomail.com; s=zohoarc; b=j0ztzSRKYVa6RPoeCQ1aFMD8QwOVTYJsmRPWfPgkOQCWYb8ui2jZlNjs7p3qoBtLVMxxOcv5b/u8i95cjYDjYqEG/yoM8VBvPfC70AHzTG8+rp6Wtu81yJ0z8NsTzj7hDvtzcKiUjmG4Ako0TcdRI2y78UyGQ5ae4ExTCq7l2ps= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1650649691; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=f3naWy5W9s9QUNBHvEd2IV7OasikpkGCP8dcpLW6o6A=; b=gQIXfbv108lKQJRQDz9TiyaEN62kRxDvNxbKVBtQgb7oewoNwb/cwLCmolWNq4vVREXla666iDXPe/eG5NU3S33I8pyu5fV/w3WwNjr6hjUzUntQowEDihY7Z6yAnW5i/o4JbcJg9FzWR+xVRyzXhDBZBtmAKZbdaoT24pfBcZg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1650649691058194.9342459119796; Fri, 22 Apr 2022 10:48:11 -0700 (PDT) Received: from localhost ([::1]:53316 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhxO5-0004Qe-Lb for importer2@patchew.org; Fri, 22 Apr 2022 13:48:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50238) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhwb4-0000YH-LH for qemu-devel@nongnu.org; Fri, 22 Apr 2022 12:57:30 -0400 Received: from mail-il1-x12f.google.com ([2607:f8b0:4864:20::12f]:36770) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhwb3-00083X-0Q for qemu-devel@nongnu.org; Fri, 22 Apr 2022 12:57:30 -0400 Received: by mail-il1-x12f.google.com with SMTP id k12so5429301ilv.3 for ; Fri, 22 Apr 2022 09:57:27 -0700 (PDT) Received: from stoup.. ([2607:fb90:27d0:b0f2:934d:3e2:9f8c:dd1]) by smtp.gmail.com with ESMTPSA id n23-20020a6b8b17000000b00649a2634725sm816380iod.17.2022.04.22.09.57.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 09:57:26 -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=f3naWy5W9s9QUNBHvEd2IV7OasikpkGCP8dcpLW6o6A=; b=jNdBMGRn+kzI3VFo/qjqiviZ7qwpUAsm5vJ6zRC9GFGttOXmLZ/WaXnG7WERQC5o6r Y2C4t8JA1Jb7abWWLWkV6W9GgJ9EdTBCrdUJ1aDuZZjZ2IjfP1MD83CCdxFu6Yh4JqPP KdCwidIpCIQbPgaE0HbW2fjhqnGOZ22fQ9cnd9Soyh8lVRL2ta7CbLM2Zt4oQ1w+3Wka pzX3r3HqlR+pQYZxUvEuf5atJqsUgE8QKkNO2TS4b5MQ/HSE3htoo10DdPrRy2txtQIR arHVIs3U0QPsh562fNpOnFStZeF8eYkOCD+UElHkCh2WcjUFExU0HaIgfxdPNTdmesYw xxAQ== 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=f3naWy5W9s9QUNBHvEd2IV7OasikpkGCP8dcpLW6o6A=; b=Ygr/+9+1anK87D+WVT26WdWOpkUdXeJgdesR1+JHxeK4CdWexxb1Wi1QrFqGjdZZbI mlBn3qzQAF/POy7cf6tO3uA4N8QHUaKE1fEi+nprZHEVQJtmTY8lYxsyDj825P14t5Qh 7hT1LYgmBAV1HrrHZR3ZEaySvuBEWOmKGyAhbaPGrX9hl9pjjHX1mddbtqwFoCA/MP2A Fv5hRHhGpC7sxziZXmtPEgYIAKTFbgDK0G9lf1rkMp+dYHeQIFPCNV/90rQDNqPw+57U agIjftoETaYNhf8603uBMc56eJoGf6RATkPXcvt0tbMzfWxYaFYalbxbxOlW1p1oqOfH +Gag== X-Gm-Message-State: AOAM530ZTsHlWEiuHXq8uK4NgsyOrvn5QIdjI+DWL/SrlmHVfmuC+vBy MeJH7TiVUlYs1nUsPy9IhChHaLu385JAtoLm X-Google-Smtp-Source: ABdhPJzZDbN3h6IMbNLjkwHZZepTlJm69sZJZr3aU1/6a61S6Yw+ukQupRIIvTNGZD8GwIATZYU+6Q== X-Received: by 2002:a92:cb4f:0:b0:2cb:fde0:b5c2 with SMTP id f15-20020a92cb4f000000b002cbfde0b5c2mr2251528ilq.274.1650646647288; Fri, 22 Apr 2022 09:57:27 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v8 59/68] target/nios2: Update helper_eret for shadow registers Date: Fri, 22 Apr 2022 09:52:29 -0700 Message-Id: <20220422165238.1971496-60-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220422165238.1971496-1-richard.henderson@linaro.org> References: <20220422165238.1971496-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::12f; envelope-from=richard.henderson@linaro.org; helo=mail-il1-x12f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: , Cc: Peter Maydell Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1650649691603100001 Content-Type: text/plain; charset="utf-8" When CRS =3D 0, we restore from estatus; otherwise from sstatus. Update for the new CRS. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Message-Id: <20220421151735.31996-56-richard.henderson@linaro.org> --- target/nios2/cpu.h | 1 + target/nios2/op_helper.c | 10 +++++++--- target/nios2/translate.c | 13 ++++++++----- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/target/nios2/cpu.h b/target/nios2/cpu.h index cca821cf80..eb171a33e6 100644 --- a/target/nios2/cpu.h +++ b/target/nios2/cpu.h @@ -82,6 +82,7 @@ enum { R_FP =3D 28, R_EA =3D 29, R_BA =3D 30, + R_SSTATUS =3D 30, R_RA =3D 31, }; =20 diff --git a/target/nios2/op_helper.c b/target/nios2/op_helper.c index a3164f5356..94040102f4 100644 --- a/target/nios2/op_helper.c +++ b/target/nios2/op_helper.c @@ -73,14 +73,18 @@ void helper_eret(CPUNios2State *env, uint32_t new_statu= s, uint32_t new_pc) } =20 /* - * Both estatus and bstatus have no constraints on write; + * None of estatus, bstatus, or sstatus have constraints on write; * do not allow reserved fields in status to be set. - * TODO: more than this is required for shadow registers. + * When shadow registers are enabled, eret *does* restore CRS. + * Rather than testing eic_present to decide, mask CRS out of + * the set of readonly fields. */ - new_status &=3D cpu->cr_state[CR_STATUS].writable; + new_status &=3D cpu->cr_state[CR_STATUS].writable | + (cpu->cr_state[CR_STATUS].readonly & R_CR_STATUS_CRS_MAS= K); =20 env->ctrl[CR_STATUS] =3D new_status; env->pc =3D new_pc; + nios2_update_crs(env); cpu_loop_exit(cs); } =20 diff --git a/target/nios2/translate.c b/target/nios2/translate.c index e566175db5..b52f98180d 100644 --- a/target/nios2/translate.c +++ b/target/nios2/translate.c @@ -496,11 +496,14 @@ static void eret(DisasContext *dc, uint32_t code, uin= t32_t flags) #ifdef CONFIG_USER_ONLY g_assert_not_reached(); #else - TCGv tmp =3D tcg_temp_new(); - tcg_gen_ld_tl(tmp, cpu_env, offsetof(CPUNios2State, ctrl[CR_ESTATUS])); - gen_helper_eret(cpu_env, tmp, load_gpr(dc, R_EA)); - tcg_temp_free(tmp); - + if (FIELD_EX32(dc->tb_flags, TBFLAGS, CRS0)) { + TCGv tmp =3D tcg_temp_new(); + tcg_gen_ld_tl(tmp, cpu_env, offsetof(CPUNios2State, ctrl[CR_ESTATU= S])); + gen_helper_eret(cpu_env, tmp, load_gpr(dc, R_EA)); + tcg_temp_free(tmp); + } else { + gen_helper_eret(cpu_env, load_gpr(dc, R_SSTATUS), load_gpr(dc, R_E= A)); + } dc->base.is_jmp =3D DISAS_NORETURN; #endif } --=20 2.34.1