From patchwork Thu Apr 21 15:16:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 564378 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp562326map; Thu, 21 Apr 2022 08:58:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+fpXApsryQ8f53CMeZhwmamY6KvIYIj2iWlQwbMteoAgvoLmSQg6bOX0OHgZRbdn5z12n X-Received: by 2002:a25:84c8:0:b0:645:6f45:3854 with SMTP id x8-20020a2584c8000000b006456f453854mr325294ybm.608.1650556721859; Thu, 21 Apr 2022 08:58:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650556721; cv=none; d=google.com; s=arc-20160816; b=o4eKSO0nH+8G7pOROGbwWTIlKiQRXLf3Exk0+1GMsmXl/bEfVk0EM40AolHTPM8s+N 2sg3mGbymWXb/xT7oDvsGyd3nBrz3/MpHGffukV9aCQ4V+CPLXftTvogeO2pP6yx5Rxs I+LVz/td/91a9XO7oBL77lI7eszZleXow7OjWlF/w5XUh1tZ/GjxhJSXGfc2aQKm+5ap hv99glHzp3+2LToCGJXN23cbCc6W+SAT7ftoTE5QBlDrfzkJtLM+Q5tt/BSLQiKORd24 ney9hDI+dYbvkU/+DEfbKzFX9wx3oo1A+GEW45UlsN2BFcrG5AbpB8S5/8nYNr4VVO4T QBFg== 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=fNAOMB88DY+Kw1JJ7inCrhRV3itMDCTZQXxLxXQ6rBA=; b=Z5pxFtOY5gblly6Ep46khLXyGskEFuh4v2urLENXL0o1yFgv6B8Z3w/nlnQCwymlgH o8JTdi0Oy5lIL+Bp+UleKrlLpYBWvyqEB+7j77CN21lZmZaS8cPxToifjstK0804nTEo pbqcedoMNQy0v771+uI1iNUKncd8ylNDCXuIL6JrFPPIMFjeLrPH72am/QM4cxETPuNK GzIVpgUYyHYvq02fPw5RvvZAWp8NbPZTZ7aewbjpJSPWlafp3v6Xc8F7O30zfhH/7tCK OkWb0EFjV1F6V2gSWYzGkU/VHis1K3a9oBcoDJndcS+ILR9LJxbx7ge6OD7FRk9nX8Z5 hhnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=N2w9LXf4; 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 u129-20020a25dd87000000b0063d9a0da198si2762031ybg.530.2022.04.21.08.58.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 Apr 2022 08:58:41 -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=N2w9LXf4; 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]:39604 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhZCb-0005x7-Cj for patch@linaro.org; Thu, 21 Apr 2022 11:58:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42866) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhYZN-0007M7-95 for qemu-devel@nongnu.org; Thu, 21 Apr 2022 11:18:11 -0400 Received: from mail-pg1-x52b.google.com ([2607:f8b0:4864:20::52b]:34337) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhYZL-0006Hq-F8 for qemu-devel@nongnu.org; Thu, 21 Apr 2022 11:18:08 -0400 Received: by mail-pg1-x52b.google.com with SMTP id t4so4920371pgc.1 for ; Thu, 21 Apr 2022 08:18:06 -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=fNAOMB88DY+Kw1JJ7inCrhRV3itMDCTZQXxLxXQ6rBA=; b=N2w9LXf4nU7Dku1VQuHKEnfY1roIbQltFUGQplbLRlrXXM42+LmzbGc+Q3faUM0eJw LYHOgSRFMrmRZEgo5fdZMWZwxyPEbqG/0CjzPkepDacDvbvRAahjO0trAEVASfzKNkTF ycSj5iZl/HxxxboS50DzHcIgTSbYFNCqdqFZLq1J/wlQoxWQ1k1zUsICQMIW+HlootNx xmhosXHQQzmSI4zCiRw/Y/EAvzlLMICBlVDkk9BX5QzYJJE4Ibl7jSZmJiHk5VPLcqYv sn3mkyO284y0HHmZV6QGuqYuc7jL0Psli3HOgMMpdVcut8nnYwwYu+U1NlmMQtfbpnHI yNDg== 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=fNAOMB88DY+Kw1JJ7inCrhRV3itMDCTZQXxLxXQ6rBA=; b=IuaMNGj5V34e/HjMaczQQHfNYw9VcQRZq3amEAp4NjAu0AhyjLaj4oFMp0f8z2CGLH h4TMElrTnoYeC66MwQ0a1jUE8qS/PWz9vpgpicH+tHy4h7aoXZcPQR3bozA4GkfTsLDU elRoWujsH3wwk31ZYyRIZ6U9U22FSmdplo8NjnIr2o6f3w90OzhdR+ZAvqCeTsHW93yt 86bYbYRqJL1S1pq7QxxiY34YAxmASudExbJWBhvqsq7KbkQ++xiM2h/gZYbmaLoDT7lD MhepeGpfElMZArLFui8xLJsCcuYWpqY+4L24IsMmb2UhfYwTUEhd6Etvyh6Af+xeeChJ JK0w== X-Gm-Message-State: AOAM531a4+1IZjvMWraViY64Bz3HUVrIxeSPlfrnl9nqABPi0cu6wP+O 3ge10HiLDg5gMrkC48c7jqWHBCMiqUCmVA== X-Received: by 2002:a05:6a00:c8f:b0:50a:77a3:e7b with SMTP id a15-20020a056a000c8f00b0050a77a30e7bmr130242pfv.41.1650554286065; Thu, 21 Apr 2022 08:18:06 -0700 (PDT) Received: from stoup.. ([2607:fb90:80c8:6cf3:a91a:4957:ba18:ac18]) by smtp.gmail.com with ESMTPSA id z16-20020a056a00241000b004f3a647ae89sm24616248pfh.174.2022.04.21.08.18.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Apr 2022 08:18:05 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 18/64] target/nios2: Fix BRET instruction Date: Thu, 21 Apr 2022 08:16:49 -0700 Message-Id: <20220421151735.31996-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220421151735.31996-1-richard.henderson@linaro.org> References: <20220421151735.31996-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52b; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52b.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 --- 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 */