From patchwork Thu Mar 17 05:04:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 552212 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp876178mag; Wed, 16 Mar 2022 22:14:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwMV1IEi4GRbcY/rdA6cVZPg/i6jsBQ1MKLInet6qQEuUA9n5mtD2FfXZ+5EPCruO5SPNV6 X-Received: by 2002:a05:620a:1925:b0:67d:93f9:3c0 with SMTP id bj37-20020a05620a192500b0067d93f903c0mr1851278qkb.256.1647494075164; Wed, 16 Mar 2022 22:14:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647494075; cv=none; d=google.com; s=arc-20160816; b=KvSRKrGkuPfxeqrJ5iEt5BJwcq8TXTxcVhZsViRqwck9u2PZtEZdlIeLovN6nUgKhP 4taozQIqsOOCWRfZ5dhmnCGGVyvIRAsgsKfKm6X/gCSv+/ux3JSpDgt7kTaQ+0ofPQSG xtFyjxIbrEYP4L9pw3FFkGTfVdZ5i/ybn/rKiOvxF+4VG/z9fOclCvim2ViDOUmEXBxj 4yDnF2j6iKvgEm6CVHF46s+aVerMegUO4zB93B3BaJtjMv5Gfv08U5QdhvIL/QXZO4wh lceXExGO3lX4eY506tVk1itpU6iMWIV6tdGJQ7g8a7zPR/JB1QXQ0o2v6EDpUxnQeaMK HUhA== 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=bz8zlZqp+XNpUuV3WS3uKIWPzFVnLucU6nOyII1L55M=; b=m5wf4JrFt/XSkzdDzBx03codPY8QXK9yyU+exmH1ssan5sgTp0+GUkBoXbAs5/zw5h 3HDqr+JJSRGlaPzKRGfkghVTGP9ZN7auHeMjv/HbdbPGef3KH8rtfCTJGMLpNf7DCKsS jbS1/B2BnKyAqXXa+oXfWmAezTfafGxj0q6LjndlVe/9QzNosdSDBYFu2MRNnJXVF9yR kh2CQvqXuXQSV9JqKkUyvXbPCaUye2umeRRkqGW6wJtxBOE1k29VN/Bh8irTl1KFFxwL 75LBOsFZHX3V4Jmi7pnZgRaPPps/IrT+Ja/qm7nTbFbrHQNzl0GQjn2uwj3ynO3X8I1z 4Jsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=BHf8zlCw; 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 s10-20020a05620a0bca00b00479261dcdfasi1011733qki.603.2022.03.16.22.14.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 16 Mar 2022 22:14:35 -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=BHf8zlCw; 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]:60088 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nUiT4-0003oR-Nm for patch@linaro.org; Thu, 17 Mar 2022 01:14:34 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50498) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nUiKX-0000K5-Ul for qemu-devel@nongnu.org; Thu, 17 Mar 2022 01:05:45 -0400 Received: from [2607:f8b0:4864:20::629] (port=35606 helo=mail-pl1-x629.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nUiKW-0002CA-F1 for qemu-devel@nongnu.org; Thu, 17 Mar 2022 01:05:45 -0400 Received: by mail-pl1-x629.google.com with SMTP id n15so3573187plh.2 for ; Wed, 16 Mar 2022 22:05:43 -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=bz8zlZqp+XNpUuV3WS3uKIWPzFVnLucU6nOyII1L55M=; b=BHf8zlCwCgR3BgKLndonE1HLKnPfGWzrvrCDDjBn/42kR5/1y2TiySGOw4Bk8qcibh QTQ2Kz9YH9lHvNy3SofonXilLnN560QeaZHCWpFh3qmKArIUro22Rq6q3T2iHiVvc62E jE3c+gEl1rKnPL9ufHj2mV/164xRQa0Fvn3/xaWvGubGw5SsuTJWJmXq/CJfyzE0Pilq cb449LpRwP1fvXaHkPowFIL2v6FXRcIb19y5VS1yUbH5Bj/R8A9wn9IhZDRSWnW4Ab1B Hxd5qiMwps3gAXDVLy1g9peaZ+YyduSbCSts1V74t3HfHeZLKblrOuHnzHdIaamzz+2+ MfIg== 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=bz8zlZqp+XNpUuV3WS3uKIWPzFVnLucU6nOyII1L55M=; b=qNyRpKTD86wsg3YiPsC+5Bl/wA2vmXWEiz7dwTmP9dDvqVFOVUocqSnhsl6HS5f+sW nuoyElXenAm2sf/sIMV7jjQqdfnOsYJDPmjV5RYM6a/nI4nnAQSgNftuOpwF2L083AvK YlFZ7kaTVbxQCcR5nvt8jfPcaRL9e47HsQRd5g04JCmk6bLUdjslSQldm0wPgcyIBMVT Fkps4MpXwwxQiv9WAqFRyqqQ4OBrbucQTTih0C6vbdBYvosyVbZjOT/zRr4DakVwDZGW 4HAvhF6NUvkITuUfWowbxxAF1M2UxnGCkx5tbf+OcmlISLf0rQ2Qr4+ldVxco8RcbDmx K5pg== X-Gm-Message-State: AOAM533wX/n91CmRyNqTVj6H9ffzpH3XOVlHYkwCkfGXRHgZhVVND/nE 5j2l1RZHQI9SA6PK87meZeC2+VstTw+iVg== X-Received: by 2002:a17:90b:3b89:b0:1c6:56a2:1397 with SMTP id pc9-20020a17090b3b8900b001c656a21397mr3333431pjb.239.1647493543033; Wed, 16 Mar 2022 22:05:43 -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.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Mar 2022 22:05:42 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH for-7.1 v6 03/51] target/nios2: Stop generating code if gen_check_supervisor fails Date: Wed, 16 Mar 2022 22:04:50 -0700 Message-Id: <20220317050538.924111-4-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::629 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::629; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x629.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" Whether the cpu is in user-mode or not is something that we know at translation-time. We do not need to generate code after having raised an exception. Suggested-by: Peter Maydell Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/nios2/translate.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/target/nios2/translate.c b/target/nios2/translate.c index 341f3a8273..1e0ab686dc 100644 --- a/target/nios2/translate.c +++ b/target/nios2/translate.c @@ -169,12 +169,14 @@ static void gen_excp(DisasContext *dc, uint32_t code, uint32_t flags) t_gen_helper_raise_exception(dc, flags); } -static void gen_check_supervisor(DisasContext *dc) +static bool gen_check_supervisor(DisasContext *dc) { if (dc->base.tb->flags & CR_STATUS_U) { /* CPU in user mode, privileged instruction called, stop. */ t_gen_helper_raise_exception(dc, EXCP_SUPERI); + return false; } + return true; } /* @@ -384,7 +386,9 @@ static const Nios2Instruction i_type_instructions[] = { */ static void eret(DisasContext *dc, uint32_t code, uint32_t flags) { - gen_check_supervisor(dc); + if (!gen_check_supervisor(dc)) { + return; + } tcg_gen_mov_tl(cpu_R[CR_STATUS], cpu_R[CR_ESTATUS]); tcg_gen_mov_tl(cpu_R[R_PC], cpu_R[R_EA]); @@ -447,7 +451,9 @@ static void rdctl(DisasContext *dc, uint32_t code, uint32_t flags) { R_TYPE(instr, code); - gen_check_supervisor(dc); + if (!gen_check_supervisor(dc)) { + return; + } if (unlikely(instr.c == R_ZERO)) { return; @@ -474,9 +480,13 @@ static void rdctl(DisasContext *dc, uint32_t code, uint32_t flags) /* ctlN <- rA */ static void wrctl(DisasContext *dc, uint32_t code, uint32_t flags) { - gen_check_supervisor(dc); + if (!gen_check_supervisor(dc)) { + return; + } -#ifndef CONFIG_USER_ONLY +#ifdef CONFIG_USER_ONLY + g_assert_not_reached(); +#else R_TYPE(instr, code); TCGv v = load_gpr(dc, instr.a);