From patchwork Fri Apr 22 16:51:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 564858 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp672924map; Fri, 22 Apr 2022 10:14:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxKCNC+iXyesPrMiRmaTRpZcBLnWL1o9dPlhM9hD//u29KmTNX9kqHLYjgwXfWIVuoDcc4v X-Received: by 2002:a05:6214:5282:b0:443:e161:ef4a with SMTP id kj2-20020a056214528200b00443e161ef4amr4483684qvb.23.1650647676222; Fri, 22 Apr 2022 10:14:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650647676; cv=none; d=google.com; s=arc-20160816; b=wQzpqFdvX4lbDBnQQGLLYhT/NAp5UccjaVgmZsH9BoPFlEXzcJ6hdcmD3ovGFtnLkc +dtnmZjcA1M5PYxKi1QejaAGTqeLNs2htF1x2Agvbi5FyOhxPN1u2/DQbojC+lM6jnKR H+N5ekpQ6i+on43So2/rLyQ8Hl1YsXdki7Tku1z9JJH+dVbFDrUDNoODjAYyjvevxFSs lPoCvUk7hmzc2ESpjjWv/d/tAWD2hHuy/1GxALIOm89nxvCyi2/wjxDi8iByTR8L1c9g kxgiass1zJSJuneLSPGw08g76cewxSrbLYZCL/QuOFOlPY/W6FkxyKe1BOLt6rB7OsQk nkXg== 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=i+pIlq3Zf7Ct4aEs80TxFQjBRjx+ntMdX+PCJRolBhs=; b=vBhvaaZdxX3vJNL/yCSJnVV5bcNvcXZkwSNmC0JDoXy89wMSZk3SflixBoWJcZhVcq HD/OBnIgHTIiOA29UiwtHwm5VrltWhDvbAKSnNAl42mH/w8YViD1BkHJfvYtx1cnvyi9 Lq/o42ojhIuKr+FDGfSIqol+QuRxNSgkH8w10izYwm709hpK994FsYUmBP+55ltJCXyY aAdAIk0AQ4rvCoeyzvtQD0/cS+MPDEYReR1+yoigOkEjw5rXHU4DYMz+L0Vk40HyisSh 05X9eMl6hWcq9RsDuxD8pB5LRcBYPTjdUyA6+vRGkIn1Xm9F7aK5iHs7OEp0xjObLjn1 2dWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dlRi35B6; 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=pass (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 h5-20020a05620a284500b0069c8ca707a9si2584362qkp.260.2022.04.22.10.14.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 22 Apr 2022 10:14:36 -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=pass header.i=@linaro.org header.s=google header.b=dlRi35B6; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39488 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhwrb-0001po-Rb for patch@linaro.org; Fri, 22 Apr 2022 13:14:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48694) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhwWx-0000y4-Tk for qemu-devel@nongnu.org; Fri, 22 Apr 2022 12:53:17 -0400 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]:35424) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhwWw-0007Gp-FB for qemu-devel@nongnu.org; Fri, 22 Apr 2022 12:53:15 -0400 Received: by mail-pf1-x430.google.com with SMTP id w16so2091250pfj.2 for ; Fri, 22 Apr 2022 09:53:14 -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=i+pIlq3Zf7Ct4aEs80TxFQjBRjx+ntMdX+PCJRolBhs=; b=dlRi35B6+y8mOlotKTSTbLf5byMq1ZBN3LrwE8IS7agCTILK9bLEccNXxPTchb2HGu iUGTeS2GhBuhfoRMtIRnNNgWX+Ci+gTksi5KBmh2JXFGInos3Mo64PstH7srABnNkHdw iwm8C0NSHXoYZSJGL7IsYDXeTHGpdtIfMxvC8aRA548jCyluYN1UZd5c4PEVkuH3MgRJ DKjpUd8Kh9kFk1VEI1poFTB7iXNlBFF7Sikoy/FJgPALKbpGM5yZj2z0P5nkVyH2mFGv WnFrjkz7k4P5cN7qurMHAFim529vVBYVIxpKkGjTyRnUKPeXkkrCH1vbro5FXFv0BB/k ORaQ== 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=i+pIlq3Zf7Ct4aEs80TxFQjBRjx+ntMdX+PCJRolBhs=; b=dgAV/u+K35O9zYbemIjPMF2QUJk3LizVCvD5ADuzoECy9bpYVwxHI4K4xtZWxfo/Rj 76QTO8GLMoJsj9tjuUQazpHO97XsusbZS9pshkEs/P0xZnVFjFkd7dxuFAZsyzBq4LMe jsSrIWzID7GYi7fo7xwuQk+5tZ+f5qdpGHlmf6tdWZpH8R6hzkvkF8pp+5oi/uqNL7es 9nJNfqiVOJQ4juxNvcRe4cCoIX0DZehw/yz/BmmreDmYXKdDujd5T5k6jcMYRBddAHJN G+gvL3oYqehIEVl6xVLw0ovnSv3HZmwxHuz1eVfFJ9esCW6XvptugScIKLS9RRE7SdX8 67fg== X-Gm-Message-State: AOAM531wfN4Fr/7JhMhe8Xewb2sVXyavwpcVdqftEOSyrx9+6ebQ6G4P Dm+qqp1DKXwixp5yN9zjX5jjxXQMO2KIFx/U X-Received: by 2002:a05:6a00:1988:b0:50a:4aad:bbea with SMTP id d8-20020a056a00198800b0050a4aadbbeamr5869030pfl.20.1650646393243; Fri, 22 Apr 2022 09:53:13 -0700 (PDT) Received: from stoup.. ([2607:fb90:27d0:b0f2:934d:3e2:9f8c:dd1]) by smtp.gmail.com with ESMTPSA id 6-20020a17090a030600b001cd4989ff5fsm6835904pje.38.2022.04.22.09.53.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 09:53:12 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v8 18/68] target/nios2: Fix BRET instruction Date: Fri, 22 Apr 2022 09:51:48 -0700 Message-Id: <20220422165238.1971496-19-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 Received-SPF: pass client-ip=2607:f8b0:4864:20::430; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x430.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+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 Message-Id: <20220421151735.31996-19-richard.henderson@linaro.org> --- 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 53699ee088..3694f2503b 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 */