From patchwork Thu Mar 10 11:26:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 550094 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp908570mag; Thu, 10 Mar 2022 03:41:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJzyonQKXFwBy58Yxd346NeHJ2UOXVCLNox5jCH/SrGAzOc6mrORs75WHrwSNIuMU81EqROQ X-Received: by 2002:a81:1043:0:b0:2dc:289f:9533 with SMTP id 64-20020a811043000000b002dc289f9533mr3399883ywq.467.1646912519526; Thu, 10 Mar 2022 03:41:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646912519; cv=none; d=google.com; s=arc-20160816; b=nNi4Km36kxhdB4MZ6cTu53yjcvvfJ7+L37oFmDDL5gWjVvFJ0aThLVF6lcdPIqGS3T wfoIAqVlwUVRJMbv7Bp7Agm+kHeftfZivq9P2Ue6QWABJuTASmuLyBbNGDucghsxeX6U p7fl5HK354Czt0Ejfg3LEo4/SWLt4w1KkRNNh1Tn/8RtU9Bcb5037/wOD05q730w8TxO 4iVf7gKjvnPX/OS4VFE0gmkpV7yDoDGR4jJKBdV8PaBavwMyJqVAhr2OGK8a6Wga7KtB yS7prlDo1Vhul5UrhJ0CU6nmmN2J8seVhJsAbYwxfVqz7D69QsejC4cWKVrbHEOL+lc8 WBYA== 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=NA9HskFqPeLh+02a0cXnYrdAXovGtw+F2Po8AxVhC7E=; b=SwqyFH4ZugeOC6QDmPTJGdGxuor4xzJ3ufOILP/nr9NkDodMnCiG8+cAFQO9LkbCvR jbJPEFsE0KEWLJ3BFifhxW+x+VJJ/3USyXBkfzx4UGfV9ZLLevjmIopItmwJvFmn4LWe Vu6cw24kKTMwlA7E059R/g72GyGT+o7Uo8AFMCr1KQbqeC1hz+q46zoDdQVMl806z1Qw 8R8ndOB1uA9++V02EaqkKslFZsy1e7c4OYTjyZEcl159ULgwVOLilP+uxS/5CztLMGx8 4NUgosxFR8X5sBQVu2PPQsMosScMB+HDJ70TAOicewFSZDlh2CYxxgp0brn6Vc+88fS5 F51Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=DZUuX833; 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 c125-20020a251c83000000b00623df2e9dd0si2759369ybc.227.2022.03.10.03.41.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Mar 2022 03:41:59 -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=DZUuX833; 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]:54132 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSHB9-0005KH-1s for patch@linaro.org; Thu, 10 Mar 2022 06:41:59 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50466) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSGx9-0004nP-Bd for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:27:31 -0500 Received: from [2607:f8b0:4864:20::102b] (port=35644 helo=mail-pj1-x102b.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nSGx7-0007tn-Ln for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:27:30 -0500 Received: by mail-pj1-x102b.google.com with SMTP id mg21-20020a17090b371500b001bef9e4657cso8014949pjb.0 for ; Thu, 10 Mar 2022 03:27:29 -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=NA9HskFqPeLh+02a0cXnYrdAXovGtw+F2Po8AxVhC7E=; b=DZUuX833jwyKf25fc16ZvWHBarUREFZrcPPZWxVd51RcBpv1SsMiqwtmWAM+VSSW6v ++FmquQQX8uKo/f33hbwCyCbF3YFC6Tsc2BQkxyV8ePOkV8yBNtNKWgGqoBzE6nd+aYi +MOqvYZGukQgsJgYD2+Hj6Df9M8AxZgFuiHONNkOt2gZoaVACXatJae755t841LnA6rl JdUqhGaTP8uaCjxViT6DHR1VVrx82CgRWATozFDVT7xqjJbHC5Huel7RVTfsUzgTc77Y VS3DqzvOvbJv1wwiZZKnJ/IMUj12T5EWMYn6t+SyvjS9oaMttM8tA/sLBME8QIupqsTn szxA== 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=NA9HskFqPeLh+02a0cXnYrdAXovGtw+F2Po8AxVhC7E=; b=aYeAlP2byz3lWpueidM1j2FQPW8iRA8Km+VuM1g9/Zb43X4I56pZNpAynpMOcwtkdL AdltOXAkHSDweNm/wERuClh//uh00DgWtGNZhdRLUgVrj+yXDYAUT70UP1yfxsVIGfX+ VJqFwcEKxc1OXuq+A/nteSV5f8hJRPrVjkKNj+wjezjU8DXK3+yglEdSRxXiiD7ySvv6 zMM5T8ISImQf4lYsojhS4hbmwjLyu4XnkYvDTgOqzh41EEWdEngWSjxx0A+29S+SL2oY FX0RUUnrgY/8DGnUWQOeGJOdEeZf/cUvmPnYksmrd9UO5S59VxGKlvzPJLOg1Zwxeant jycA== X-Gm-Message-State: AOAM531znU9OEmqVRX5oqWXRtIIjRRX+PnmQl1dY8SFjUX/uJkCyckyk /Y8h7hc0YPWYc8RuslvhlIqI6dW1Wq0vog== X-Received: by 2002:a17:902:8491:b0:14e:dad4:5ce5 with SMTP id c17-20020a170902849100b0014edad45ce5mr4505167plo.76.1646911648371; Thu, 10 Mar 2022 03:27:28 -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.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Mar 2022 03:27:27 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 01/48] target/nios2: Check supervisor on eret Date: Thu, 10 Mar 2022 03:26:38 -0800 Message-Id: <20220310112725.570053-2-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::102b (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::102b; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102b.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" From: Amir Gonnen eret instruction is only allowed in supervisor mode. Reviewed-by: Peter Maydell Reviewed-by: Richard Henderson Signed-off-by: Amir Gonnen Message-Id: <20220303153906.2024748-2-amir.gonnen@neuroblade.ai> Signed-off-by: Richard Henderson --- target/nios2/translate.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/target/nios2/translate.c b/target/nios2/translate.c index f89271dbed..341f3a8273 100644 --- a/target/nios2/translate.c +++ b/target/nios2/translate.c @@ -384,6 +384,8 @@ static const Nios2Instruction i_type_instructions[] = { */ static void eret(DisasContext *dc, uint32_t code, uint32_t flags) { + gen_check_supervisor(dc); + tcg_gen_mov_tl(cpu_R[CR_STATUS], cpu_R[CR_ESTATUS]); tcg_gen_mov_tl(cpu_R[R_PC], cpu_R[R_EA]); From patchwork Thu Mar 10 11:26:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 550107 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp916363mag; Thu, 10 Mar 2022 03:53:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJyNgJMhz3VMi+Oq0hd2f4f0+ryZwKMJkJWv4QJ2OxTQR8GY3I/zvY3f30hLw/vveXdADdGC X-Received: by 2002:a0d:e2c4:0:b0:2dc:53f0:7ef4 with SMTP id l187-20020a0de2c4000000b002dc53f07ef4mr3665096ywe.176.1646913187779; Thu, 10 Mar 2022 03:53:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646913187; cv=none; d=google.com; s=arc-20160816; b=jtjoFU+CIbmV6Qwl8o4POprrIS1wO0IuHC9rIn5GsZ2paGnuaf73cp3kZ0AHt2NIm1 rQlZd5m3o7PmkOn2lS/Yjl7+ddNw6l1uBroWb0dJTJ1fDC1HnKnB8X0zqLayvZ5pkbZ2 JSSmHmtPNNaVVBEQh3qZLRtA3yxJXU02ZpQ2siQtiBWxqeYy9K97HH/kT0jWapDgV7xm CXho0cxJFuxeSLhjXPVZNnxARGAU2ihvMLEzxG9GOh7I6FDuqvvLfAOXzGPziNBTn8sW XGrv8jajv+Mm/DRSHoBanf95UzQPx+IFYYJyj18IdyuaOEw+0unhP7HbGT4q6aoCXNT5 bGPQ== 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=RwsgdVuxNt0C+4hxONGviuuB1VTVhZLLw8DiSg1rfZsm0viXGeJJF3lqMkiiH9jp5H /gQffvxBK4O3y5IsQKLSIxRH+vKagdAutUd3EThi1xtHwF6w32srlU3UJ8BkGKLKWo6u gVSbr0aT+Z4tKOqqiACrqPj5KlOoBulqqUVb001IilKPnxLG0SUD/oksvOBqy4wjSgw8 /XhGUztcpoJvTdWQMj7/A3+dmOF7DRTLXeikH8x5nsEd8k7EMLGAqRbACZhFCP8FyRB/ ODSTYq2sokfG2hKn1fVE5Zd9u2tsx0vIn42SMI9C9Wu3wBO2avbOVvIUzTqyQSkuKy8b yxFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="RquWEd/R"; 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 w65-20020a25df44000000b00628b141779csi2961187ybg.555.2022.03.10.03.53.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Mar 2022 03:53:07 -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="RquWEd/R"; 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]:57030 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSHLv-0001Sx-AD for patch@linaro.org; Thu, 10 Mar 2022 06:53:07 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50508) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSGxA-0004q0-LB for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:27:32 -0500 Received: from [2607:f8b0:4864:20::102b] (port=33650 helo=mail-pj1-x102b.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nSGx8-0007u6-Hp for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:27:32 -0500 Received: by mail-pj1-x102b.google.com with SMTP id v1-20020a17090a088100b001bf25f97c6eso6399331pjc.0 for ; Thu, 10 Mar 2022 03:27:30 -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=bz8zlZqp+XNpUuV3WS3uKIWPzFVnLucU6nOyII1L55M=; b=RquWEd/RQnz2t0dcU7OLl46wGO6Id2FuSV+LR37+8Q+hx+Wb5XQ1DXkwOkszsAMVIL 12iuxBODnyH9s1oIXx/N4sxSbRAD83q7ie7Xzg29F5k5hM8yVBzEUDZe33WhzV9cniHr awO0sle25OFlylGkmg1SKSfCV2c0leJcABisPvrCt3y0dbdw1quDBiIyKSSAQkb9bNpc 7Z8NRCa0Zng8wc++HXtSHqkE4SOlGWzXwB1Xw5jcnFRhKuL86mC+ll0gBgbZt3/16fb3 LFCQr/mFfR4AGblBFBugB+ko9v5qK4yLwW7HSif6zBNGLTei59r7pKwFIBeDjM4aDIYj sr9w== 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=rvFbmD/7ZB9DJK32i73pUP7D8wxRP+KKLnsgjke5oF43f14XWyUa+svnwQjAky/m91 TqeIXvx/qvVHk+mpd/DISudsMvLh+M9JAQ7R2O/q7pWHKnnubSbHVPFkD4ta5UeVyP0a 5iAN1rSh/cEf/BpreXcxvaMvNmyelwrD05tMx2QyCZ04LTAU0X2pSwi35r6ETkvt1/hr qS4QvVF4JL+WOCSq7VUFSXeKqHl1WZsDhpCcfwZo9FihjTDxp6SUNiG+XFGY1NlsKxF4 UFsqfNiCaL2CiNTlSBhZUbh0wNRqj2eknDPo3pMvqgwTpYPPgM+E3l+HRv8DeouEMJPS vtRw== X-Gm-Message-State: AOAM530g+wnW1a2pEpB1PyyfwqwnRUpwwEIWisY/ZzFY/DVQlNyvKNRU 0UpHQwVyAqV5F5L6N976tf9eQcsctc0ZbQ== X-Received: by 2002:a17:902:c408:b0:153:176:19a4 with SMTP id k8-20020a170902c40800b00153017619a4mr4693416plk.18.1646911649276; Thu, 10 Mar 2022 03:27:29 -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.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Mar 2022 03:27:28 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 02/48] target/nios2: Stop generating code if gen_check_supervisor fails Date: Thu, 10 Mar 2022 03:26:39 -0800 Message-Id: <20220310112725.570053-3-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::102b (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::102b; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102b.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" 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); From patchwork Thu Mar 10 11:26:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 550097 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp910394mag; Thu, 10 Mar 2022 03:45:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJyQhrn1TnhjHau0CHAwa72pZaiCYSnaLtxk7u4JyRVwyEUib2Vi03utrNr1rJ1wvaxThUAD X-Received: by 2002:a81:6657:0:b0:2d6:b214:6569 with SMTP id a84-20020a816657000000b002d6b2146569mr3504744ywc.53.1646912700893; Thu, 10 Mar 2022 03:45:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646912700; cv=none; d=google.com; s=arc-20160816; b=OWQIWeZ9p4Czs5+fGyjc2Q8hTQJut9PKkw7BjdcZpGm3FnW7erjdd0HZ1re5bzj8oF sRJAQvUB95V4pwnRek0TZARpRqzctRxaZ9j6izDkZxMMKCwm6nhkCdwXFTg4nLbgv8Ga +35C+f2PjmnefdeqL0jZFHkhxBZz4g5SZ5xX1nW0TItMH2QMP8ENIMQm5K5TkfFXDzao XKmHhTrVJdTJcqVf6LLWouS8PB1oBGG37F7QPOzX4HqQLNbmDaYlKzIq6n3ARWnJkVIy aiYVAEacx6i5VPPWwS4BRQa6A+O8NbKETWakSzwXFo6v+vX4Cxjlmm93L4p8v1AVaXIE j1mQ== 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=tamfos1uvfrgy6OTL/hYTKA67kxVDj5ysduH3BCBsBo=; b=ULBJ4KTA7dQ2zm9tkmM6fTigiyBo0HkwY2ACY5g8/puB/hOfqq+sk7TgGOSCBz0Pha KUWuGI96AIWN6ncfGSk5DMzS/Xz7kGWQnIEAEjjkpkX8X/J1zX4pm/DhRDup473QbiYs j8QyzWpbOOGVogE+DKsyjOiRl25CkBnTxJyOfF+3TDxz1Ko8E06WQjMmDTRCfF6WIH3Z zqq61RvYtjzY/8ibRs7jfGXGAUzb0GBOtGaxNfTTvZ8or4ucpz57QrusVh3o/9zeQPQu 76Oes/06W2r7eP0n7GEok+/Wv3uOOZwIhqkRFbf1pKh1NpI42WKHpuoReZWJhf6E/foH qXiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=fzlO5ezH; 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 c16-20020a25a290000000b00628bfa340e8si2807858ybi.667.2022.03.10.03.45.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Mar 2022 03:45:00 -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=fzlO5ezH; 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]:34518 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSHE3-0002ev-Ub for patch@linaro.org; Thu, 10 Mar 2022 06:45:00 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50526) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSGxB-0004so-K3 for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:27:33 -0500 Received: from [2607:f8b0:4864:20::629] (port=38560 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 1nSGxA-0007ug-1C for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:27:33 -0500 Received: by mail-pl1-x629.google.com with SMTP id n18so1911358plg.5 for ; Thu, 10 Mar 2022 03:27:31 -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=tamfos1uvfrgy6OTL/hYTKA67kxVDj5ysduH3BCBsBo=; b=fzlO5ezHc+T+qu7VGgr9u06EGqUV5gVCp/LwBqeG8sXDfp3Er+vnfBg9wvxduT45P2 R/fUdwAGiW5csZDxdijov0r/Ec8jXJI1PZbqaEuxOILfCVitEd5L1Ye/Cl/SsJ+EQ0gi o8YW12wT27lTlUCWiKgSSS/zn9mBZEsfqwdm+8i2FKuNsijhKiLiAOCJRv2+XiI3aZKJ PVEjtQaH0rCL4ZcV/TXNEi1z24YB6YpYm3vxyb+Rp5EnQomD0oeQMkn59UT0KuGGSXIz gGczvDe37J1uAA44C+ApEKZUMhpC7WY+AKLRztNNk4MDNTuP+skvLcexpStZY1sVOKCY 5tOA== 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=tamfos1uvfrgy6OTL/hYTKA67kxVDj5ysduH3BCBsBo=; b=WOWzvn+HwMB8eIHT4IY2+BDRb2RQTHmT6hm/DU7Zpj/5Navk8qHG4DOH/pyOkP3OsC Rw87mo5wsaGP4cr03HO5eQpjgGLBaD5ZzXpOH6AWdB8FQAp86YO9X9sR4+Lr17EvKjYl 4Cmo6m3ozV0une65KY0IK22+KrHGzkw992n5Oxzo5Zafc1bobca9umX4PQ/T01ixA0U3 9c6+XTZfIPMr4Mf1mcM9a4094CcrOxtbRqcfAzuqPEAwMYKd3Uzgntd1u1n3zZJIyQX9 R8p2RHCZ2H67GTYz9Z6WveF7a7tCW7WU6i39mhuXgjvx5y2r0Spr70j0M0vCS8uFtWB+ wg7Q== X-Gm-Message-State: AOAM532oxIyJzjFGLouJdwo3vC2SvYUOabGADGYDx2x0+4L26bOLgsLu msRZUXy1u8pgUCg8ubeX0M+X4d5PBnJKzg== X-Received: by 2002:a17:90a:da02:b0:1bf:3919:f2a with SMTP id e2-20020a17090ada0200b001bf39190f2amr15435804pjv.208.1646911650188; Thu, 10 Mar 2022 03:27:30 -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.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Mar 2022 03:27:29 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 03/48] target/nios2: Add NUM_GP_REGS and NUM_CP_REGS Date: Thu, 10 Mar 2022 03:26:40 -0800 Message-Id: <20220310112725.570053-4-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::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@linaro.org, amir.gonnen@neuroblade.ai Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Amir Gonnen Split NUM_CORE_REGS into components that can be used elsewhere. Reviewed-by: Peter Maydell Signed-off-by: Amir Gonnen Message-Id: <20220303153906.2024748-3-amir.gonnen@neuroblade.ai> [rth: Split out of a larger patch for shadow register sets.] Signed-off-by: Richard Henderson --- target/nios2/cpu.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/target/nios2/cpu.h b/target/nios2/cpu.h index ca0f3420cd..adeb16377d 100644 --- a/target/nios2/cpu.h +++ b/target/nios2/cpu.h @@ -56,9 +56,11 @@ struct Nios2CPUClass { #define EXCEPTION_ADDRESS 0x00000004 #define FAST_TLB_MISS_ADDRESS 0x00000008 +#define NUM_GP_REGS 32 +#define NUM_CR_REGS 32 /* GP regs + CR regs + PC */ -#define NUM_CORE_REGS (32 + 32 + 1) +#define NUM_CORE_REGS (NUM_GP_REGS + NUM_CR_REGS + 1) /* General purpose register aliases */ #define R_ZERO 0 @@ -79,7 +81,7 @@ struct Nios2CPUClass { #define R_RA 31 /* Control register aliases */ -#define CR_BASE 32 +#define CR_BASE NUM_GP_REGS #define CR_STATUS (CR_BASE + 0) #define CR_STATUS_PIE (1 << 0) #define CR_STATUS_U (1 << 1) From patchwork Thu Mar 10 11:26:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 550112 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp919415mag; Thu, 10 Mar 2022 03:57:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJyi2dQMQnsJ9flOv19ma5cwUee12jFlTpUiFB22jmmYo2mNkVRFspeSj8RoAMvEppbxFGPs X-Received: by 2002:a0d:e001:0:b0:2dc:44cd:84da with SMTP id j1-20020a0de001000000b002dc44cd84damr3706176ywe.454.1646913463139; Thu, 10 Mar 2022 03:57:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646913463; cv=none; d=google.com; s=arc-20160816; b=Ki1xTA/NwjIr9/Jsp0U1W7lfszkplj5WWbrRgiWB0F9NsF6mEsZ8WiILG3xQUSR9vf FW4gST9lY3OwrNHlY8xCS3B5ntbJVHSqJ54gGCS4IvQX2JeV6B1e75iHZqrJlZ6KE6OJ g/dKQ/7rnPcgCtkfPOrpURg9SdFsKZhZY1nv88Vo70NUkl+IVJHvbFb/dDxITK5CzRIv S5zo/WJr8JJxGbgPAbGIwgtWggLrPCK/xwEqoy8wVjLr3PJmx9r9lksUpiVIExftqRqt l8ynPB1lQGldlwrWrefUqiPfLkD98kdzQCYihBQOO+TA5Kq+4OUH/cIvoeirwpiKqtTQ 1cnA== 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=bkOrHFoETWid+QekyrDcDE4JYVn7YyGDinnjYK+GH7Y=; b=Q4igKaBJzdiDlTd3O3VSpB/8FWDf1c6sWqkVY0fWodmQWcL1V/YCFinTku0BkrXc76 d8ur6c4HindVxI/yCuddlrSO1sVJ8Oh0H4hjhIlwIOTsOSmfZmeQ+emBZNllEjMi+oY1 3+8W9sE3mMyGD5T1ITkpqvm9tMdaMZPKTMUBGVmM3CJD+Su/7J3SQQz19xKnfMychOlw DWHlOAJc9BX4kr5ALD7xRuJquaM8MTkjmEN6Wr8TAjYZTWP+R+mHuB/ibxsW1kBdYJG+ pHSdE7Yvnr3ctXiPXL+YnIhROJMBC35Ynj2VCJJAiQfL6W5pQ+mIuEXOlLXfdOJUK7w1 NEeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=i1832peP; 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 m188-20020a0dfcc5000000b002dc304158edsi2875835ywf.269.2022.03.10.03.57.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Mar 2022 03:57:43 -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=i1832peP; 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]:39972 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSHQM-0000oW-JA for patch@linaro.org; Thu, 10 Mar 2022 06:57:42 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50582) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSGxD-0004yF-Si for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:27:35 -0500 Received: from [2607:f8b0:4864:20::531] (port=43903 helo=mail-pg1-x531.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nSGxB-0007v2-EJ for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:27:35 -0500 Received: by mail-pg1-x531.google.com with SMTP id 27so4470814pgk.10 for ; Thu, 10 Mar 2022 03:27:33 -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=bkOrHFoETWid+QekyrDcDE4JYVn7YyGDinnjYK+GH7Y=; b=i1832pePtU73jPJ/DoibxbSu9+UqfhXHsoinv8bbOdZWpM4frjP1Uvsky3J3N2ZyhP LIfAnXZftEaXbfGAPH2i+cCbRxgY8o6uDFiiFrhWbDyx/dQ3tFglWediP9P6NmjAwAbB Q3cBf0F7NWCgLlEUnwvFS+BK7DrUgVJ7zHvimFseEKGTkEpZJwrFiPsXT/dL9bXepYD8 6/YboK3NrfmN5my6CWHxufEJkrMtQhKnyMxdgPt94AbZITJDNniwhf8tdHjottbRG5Xa BiCMNnLLraIJUvAnnD6GP/+aIadoyy/Lbq8elY5eQ0k0Sy+eG81mfgdVgpZ58WRWdKgx lBMQ== 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=bkOrHFoETWid+QekyrDcDE4JYVn7YyGDinnjYK+GH7Y=; b=QyMb6uRn0hZMIhROWhp2ErDX1qpGbXbyr8B/YQnxmJqumfpG6zppgRI5AXn7oduiwk qPUYuXybJOF1YR95PpUP2gDwP1WWCl+Qrk5Ebe3KISp0+xvk6K/2vupLwYCza6qesXri nXHNenGF4PZFEHb+6TDJ/y1EDwV30fSgCFWX5z2C+fHOOJJhmlFfY68fMFNh9z6lazhJ KXamQreuBoYhNIfzuHan/gd29A4wtlnwHv/NiC1VMki/4oXjd1VRUIhwXytDogE7sVrz fevm5OnS7OuMcfXfuO0jw6X5Ba+BC2Ihpw8RtzFAE6lp7BrN4lKv6mG/hXgqfDQce7ut tSYQ== X-Gm-Message-State: AOAM530xGNaiCORD5hGFtqrzLhU1yfKqG7nCnfpYeCaOYS3l4pyCVidg t/V1ZoZCFVpKNRoCebg9AnxTiGNWgFrzIA== X-Received: by 2002:a63:85c8:0:b0:380:3444:d682 with SMTP id u191-20020a6385c8000000b003803444d682mr3651554pgd.163.1646911651864; Thu, 10 Mar 2022 03:27:31 -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.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Mar 2022 03:27:31 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 04/48] target/nios2: Split PC out of env->regs[] Date: Thu, 10 Mar 2022 03:26:41 -0800 Message-Id: <20220310112725.570053-5-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::531 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::531; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x531.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" It is cleaner to have a separate name for this variable. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/nios2/cpu.h | 10 +++----- linux-user/elfload.c | 2 +- linux-user/nios2/cpu_loop.c | 17 ++++++------- linux-user/nios2/signal.c | 6 ++--- target/nios2/cpu.c | 8 +++--- target/nios2/helper.c | 51 +++++++++++++++++-------------------- target/nios2/translate.c | 29 +++++++++++---------- 7 files changed, 58 insertions(+), 65 deletions(-) diff --git a/target/nios2/cpu.h b/target/nios2/cpu.h index adeb16377d..9be128d63a 100644 --- a/target/nios2/cpu.h +++ b/target/nios2/cpu.h @@ -59,8 +59,8 @@ struct Nios2CPUClass { #define NUM_GP_REGS 32 #define NUM_CR_REGS 32 -/* GP regs + CR regs + PC */ -#define NUM_CORE_REGS (NUM_GP_REGS + NUM_CR_REGS + 1) +/* GP regs + CR regs */ +#define NUM_CORE_REGS (NUM_GP_REGS + NUM_CR_REGS) /* General purpose register aliases */ #define R_ZERO 0 @@ -130,9 +130,6 @@ struct Nios2CPUClass { #define CR_MPUBASE (CR_BASE + 14) #define CR_MPUACC (CR_BASE + 15) -/* Other registers */ -#define R_PC 64 - /* Exceptions */ #define EXCP_BREAK 0x1000 #define EXCP_RESET 0 @@ -158,6 +155,7 @@ struct Nios2CPUClass { struct CPUArchState { uint32_t regs[NUM_CORE_REGS]; + uint32_t pc; #if !defined(CONFIG_USER_ONLY) Nios2MMU mmu; @@ -241,7 +239,7 @@ typedef Nios2CPU ArchCPU; static inline void cpu_get_tb_cpu_state(CPUNios2State *env, target_ulong *pc, target_ulong *cs_base, uint32_t *flags) { - *pc = env->regs[R_PC]; + *pc = env->pc; *cs_base = 0; *flags = (env->regs[CR_STATUS] & (CR_STATUS_EH | CR_STATUS_U)); } diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 9628a38361..23ff9659a5 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -1170,7 +1170,7 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs, (*regs)[30] = -1; /* R_SSTATUS */ (*regs)[31] = tswapreg(env->regs[R_RA]); - (*regs)[32] = tswapreg(env->regs[R_PC]); + (*regs)[32] = tswapreg(env->pc); (*regs)[33] = -1; /* R_STATUS */ (*regs)[34] = tswapreg(env->regs[CR_ESTATUS]); diff --git a/linux-user/nios2/cpu_loop.c b/linux-user/nios2/cpu_loop.c index 1e93ef34e6..7b20c024db 100644 --- a/linux-user/nios2/cpu_loop.c +++ b/linux-user/nios2/cpu_loop.c @@ -56,25 +56,24 @@ void cpu_loop(CPUNios2State *env) env->regs[2] = abs(ret); /* Return value is 0..4096 */ env->regs[7] = ret > 0xfffff000u; - env->regs[R_PC] += 4; + env->pc += 4; break; case 1: qemu_log_mask(CPU_LOG_INT, "\nTrap 1\n"); - force_sig_fault(TARGET_SIGUSR1, 0, env->regs[R_PC]); + force_sig_fault(TARGET_SIGUSR1, 0, env->pc); break; case 2: qemu_log_mask(CPU_LOG_INT, "\nTrap 2\n"); - force_sig_fault(TARGET_SIGUSR2, 0, env->regs[R_PC]); + force_sig_fault(TARGET_SIGUSR2, 0, env->pc); break; case 31: qemu_log_mask(CPU_LOG_INT, "\nTrap 31\n"); - force_sig_fault(TARGET_SIGTRAP, TARGET_TRAP_BRKPT, env->regs[R_PC]); + force_sig_fault(TARGET_SIGTRAP, TARGET_TRAP_BRKPT, env->pc); break; default: qemu_log_mask(CPU_LOG_INT, "\nTrap %d\n", env->error_code); - force_sig_fault(TARGET_SIGILL, TARGET_ILL_ILLTRP, - env->regs[R_PC]); + force_sig_fault(TARGET_SIGILL, TARGET_ILL_ILLTRP, env->pc); break; case 16: /* QEMU specific, for __kuser_cmpxchg */ @@ -99,7 +98,7 @@ void cpu_loop(CPUNios2State *env) o = env->regs[5]; n = env->regs[6]; env->regs[2] = qatomic_cmpxchg(h, o, n) - o; - env->regs[R_PC] += 4; + env->pc += 4; } break; } @@ -117,7 +116,7 @@ void cpu_loop(CPUNios2State *env) info.si_errno = 0; /* TODO: check env->error_code */ info.si_code = TARGET_SEGV_MAPERR; - info._sifields._sigfault._addr = env->regs[R_PC]; + info._sifields._sigfault._addr = env->pc; queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); } break; @@ -155,6 +154,6 @@ void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs) env->regs[R_SP] = regs->sp; env->regs[R_GP] = regs->gp; env->regs[CR_ESTATUS] = regs->estatus; - env->regs[R_PC] = regs->ea; + env->pc = regs->ea; /* TODO: unsigned long orig_r7; */ } diff --git a/linux-user/nios2/signal.c b/linux-user/nios2/signal.c index 517cd39270..ccfaa75d3b 100644 --- a/linux-user/nios2/signal.c +++ b/linux-user/nios2/signal.c @@ -73,7 +73,7 @@ static void rt_setup_ucontext(struct target_ucontext *uc, CPUNios2State *env) __put_user(env->regs[R_RA], &gregs[23]); __put_user(env->regs[R_FP], &gregs[24]); __put_user(env->regs[R_GP], &gregs[25]); - __put_user(env->regs[R_PC], &gregs[27]); + __put_user(env->pc, &gregs[27]); __put_user(env->regs[R_SP], &gregs[28]); } @@ -122,7 +122,7 @@ static int rt_restore_ucontext(CPUNios2State *env, struct target_ucontext *uc, __get_user(env->regs[R_GP], &gregs[25]); /* Not really necessary no user settable bits */ __get_user(temp, &gregs[26]); - __get_user(env->regs[R_PC], &gregs[27]); + __get_user(env->pc, &gregs[27]); __get_user(env->regs[R_RA], &gregs[23]); __get_user(env->regs[R_SP], &gregs[28]); @@ -180,7 +180,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, env->regs[4] = sig; env->regs[5] = frame_addr + offsetof(struct target_rt_sigframe, info); env->regs[6] = frame_addr + offsetof(struct target_rt_sigframe, uc); - env->regs[R_PC] = ka->_sa_handler; + env->pc = ka->_sa_handler; unlock_user_struct(frame, frame_addr, 1); } diff --git a/target/nios2/cpu.c b/target/nios2/cpu.c index 6975ae4bdb..40031c9f20 100644 --- a/target/nios2/cpu.c +++ b/target/nios2/cpu.c @@ -31,7 +31,7 @@ static void nios2_cpu_set_pc(CPUState *cs, vaddr value) Nios2CPU *cpu = NIOS2_CPU(cs); CPUNios2State *env = &cpu->env; - env->regs[R_PC] = value; + env->pc = value; } static bool nios2_cpu_has_work(CPUState *cs) @@ -54,7 +54,7 @@ static void nios2_cpu_reset(DeviceState *dev) ncc->parent_reset(dev); memset(env->regs, 0, sizeof(uint32_t) * NUM_CORE_REGS); - env->regs[R_PC] = cpu->reset_addr; + env->pc = cpu->reset_addr; #if defined(CONFIG_USER_ONLY) /* Start in user mode with interrupts enabled. */ @@ -161,7 +161,7 @@ static int nios2_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) if (n < 32) { /* GP regs */ return gdb_get_reg32(mem_buf, env->regs[n]); } else if (n == 32) { /* PC */ - return gdb_get_reg32(mem_buf, env->regs[R_PC]); + return gdb_get_reg32(mem_buf, env->pc); } else if (n < 49) { /* Status regs */ return gdb_get_reg32(mem_buf, env->regs[n - 1]); } @@ -183,7 +183,7 @@ static int nios2_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) if (n < 32) { /* GP regs */ env->regs[n] = ldl_p(mem_buf); } else if (n == 32) { /* PC */ - env->regs[R_PC] = ldl_p(mem_buf); + env->pc = ldl_p(mem_buf); } else if (n < 49) { /* Status regs */ env->regs[n - 1] = ldl_p(mem_buf); } diff --git a/target/nios2/helper.c b/target/nios2/helper.c index e5c98650e1..31cec29e89 100644 --- a/target/nios2/helper.c +++ b/target/nios2/helper.c @@ -35,7 +35,7 @@ void nios2_cpu_do_interrupt(CPUState *cs) Nios2CPU *cpu = NIOS2_CPU(cs); CPUNios2State *env = &cpu->env; cs->exception_index = -1; - env->regs[R_EA] = env->regs[R_PC] + 4; + env->regs[R_EA] = env->pc + 4; } void nios2_cpu_record_sigsegv(CPUState *cs, vaddr addr, @@ -58,7 +58,7 @@ void nios2_cpu_do_interrupt(CPUState *cs) case EXCP_IRQ: assert(env->regs[CR_STATUS] & CR_STATUS_PIE); - qemu_log_mask(CPU_LOG_INT, "interrupt at pc=%x\n", env->regs[R_PC]); + qemu_log_mask(CPU_LOG_INT, "interrupt at pc=%x\n", env->pc); env->regs[CR_ESTATUS] = env->regs[CR_STATUS]; env->regs[CR_STATUS] |= CR_STATUS_IH; @@ -67,14 +67,13 @@ void nios2_cpu_do_interrupt(CPUState *cs) env->regs[CR_EXCEPTION] &= ~(0x1F << 2); env->regs[CR_EXCEPTION] |= (cs->exception_index & 0x1F) << 2; - env->regs[R_EA] = env->regs[R_PC] + 4; - env->regs[R_PC] = cpu->exception_addr; + env->regs[R_EA] = env->pc + 4; + env->pc = cpu->exception_addr; break; case EXCP_TLBD: if ((env->regs[CR_STATUS] & CR_STATUS_EH) == 0) { - qemu_log_mask(CPU_LOG_INT, "TLB MISS (fast) at pc=%x\n", - env->regs[R_PC]); + qemu_log_mask(CPU_LOG_INT, "TLB MISS (fast) at pc=%x\n", env->pc); /* Fast TLB miss */ /* Variation from the spec. Table 3-35 of the cpu reference shows @@ -90,11 +89,10 @@ void nios2_cpu_do_interrupt(CPUState *cs) env->regs[CR_TLBMISC] &= ~CR_TLBMISC_DBL; env->regs[CR_TLBMISC] |= CR_TLBMISC_WR; - env->regs[R_EA] = env->regs[R_PC] + 4; - env->regs[R_PC] = cpu->fast_tlb_miss_addr; + env->regs[R_EA] = env->pc + 4; + env->pc = cpu->fast_tlb_miss_addr; } else { - qemu_log_mask(CPU_LOG_INT, "TLB MISS (double) at pc=%x\n", - env->regs[R_PC]); + qemu_log_mask(CPU_LOG_INT, "TLB MISS (double) at pc=%x\n", env->pc); /* Double TLB miss */ env->regs[CR_STATUS] |= CR_STATUS_EH; @@ -105,14 +103,14 @@ void nios2_cpu_do_interrupt(CPUState *cs) env->regs[CR_TLBMISC] |= CR_TLBMISC_DBL; - env->regs[R_PC] = cpu->exception_addr; + env->pc = cpu->exception_addr; } break; case EXCP_TLBR: case EXCP_TLBW: case EXCP_TLBX: - qemu_log_mask(CPU_LOG_INT, "TLB PERM at pc=%x\n", env->regs[R_PC]); + qemu_log_mask(CPU_LOG_INT, "TLB PERM at pc=%x\n", env->pc); env->regs[CR_ESTATUS] = env->regs[CR_STATUS]; env->regs[CR_STATUS] |= CR_STATUS_EH; @@ -125,19 +123,18 @@ void nios2_cpu_do_interrupt(CPUState *cs) env->regs[CR_TLBMISC] |= CR_TLBMISC_WR; } - env->regs[R_EA] = env->regs[R_PC] + 4; - env->regs[R_PC] = cpu->exception_addr; + env->regs[R_EA] = env->pc + 4; + env->pc = cpu->exception_addr; break; case EXCP_SUPERA: case EXCP_SUPERI: case EXCP_SUPERD: - qemu_log_mask(CPU_LOG_INT, "SUPERVISOR exception at pc=%x\n", - env->regs[R_PC]); + qemu_log_mask(CPU_LOG_INT, "SUPERVISOR exception at pc=%x\n", env->pc); if ((env->regs[CR_STATUS] & CR_STATUS_EH) == 0) { env->regs[CR_ESTATUS] = env->regs[CR_STATUS]; - env->regs[R_EA] = env->regs[R_PC] + 4; + env->regs[R_EA] = env->pc + 4; } env->regs[CR_STATUS] |= CR_STATUS_EH; @@ -146,17 +143,16 @@ void nios2_cpu_do_interrupt(CPUState *cs) env->regs[CR_EXCEPTION] &= ~(0x1F << 2); env->regs[CR_EXCEPTION] |= (cs->exception_index & 0x1F) << 2; - env->regs[R_PC] = cpu->exception_addr; + env->pc = cpu->exception_addr; break; case EXCP_ILLEGAL: case EXCP_TRAP: - qemu_log_mask(CPU_LOG_INT, "TRAP exception at pc=%x\n", - env->regs[R_PC]); + qemu_log_mask(CPU_LOG_INT, "TRAP exception at pc=%x\n", env->pc); if ((env->regs[CR_STATUS] & CR_STATUS_EH) == 0) { env->regs[CR_ESTATUS] = env->regs[CR_STATUS]; - env->regs[R_EA] = env->regs[R_PC] + 4; + env->regs[R_EA] = env->pc + 4; } env->regs[CR_STATUS] |= CR_STATUS_EH; @@ -165,24 +161,23 @@ void nios2_cpu_do_interrupt(CPUState *cs) env->regs[CR_EXCEPTION] &= ~(0x1F << 2); env->regs[CR_EXCEPTION] |= (cs->exception_index & 0x1F) << 2; - env->regs[R_PC] = cpu->exception_addr; + env->pc = cpu->exception_addr; break; case EXCP_BREAK: - qemu_log_mask(CPU_LOG_INT, "BREAK exception at pc=%x\n", - env->regs[R_PC]); + qemu_log_mask(CPU_LOG_INT, "BREAK exception at pc=%x\n", env->pc); /* The semihosting instruction is "break 1". */ if (semihosting_enabled() && - cpu_ldl_code(env, env->regs[R_PC]) == 0x003da07a) { + cpu_ldl_code(env, env->pc) == 0x003da07a) { qemu_log_mask(CPU_LOG_INT, "Entering semihosting\n"); - env->regs[R_PC] += 4; + env->pc += 4; do_nios2_semihosting(env); break; } if ((env->regs[CR_STATUS] & CR_STATUS_EH) == 0) { env->regs[CR_BSTATUS] = env->regs[CR_STATUS]; - env->regs[R_BA] = env->regs[R_PC] + 4; + env->regs[R_BA] = env->pc + 4; } env->regs[CR_STATUS] |= CR_STATUS_EH; @@ -191,7 +186,7 @@ void nios2_cpu_do_interrupt(CPUState *cs) env->regs[CR_EXCEPTION] &= ~(0x1F << 2); env->regs[CR_EXCEPTION] |= (cs->exception_index & 0x1F) << 2; - env->regs[R_PC] = cpu->exception_addr; + env->pc = cpu->exception_addr; break; default: diff --git a/target/nios2/translate.c b/target/nios2/translate.c index 1e0ab686dc..154ffacbea 100644 --- a/target/nios2/translate.c +++ b/target/nios2/translate.c @@ -104,6 +104,7 @@ typedef struct DisasContext { } DisasContext; static TCGv cpu_R[NUM_CORE_REGS]; +static TCGv cpu_pc; typedef struct Nios2Instruction { void (*handler)(DisasContext *dc, uint32_t code, uint32_t flags); @@ -144,7 +145,7 @@ static void t_gen_helper_raise_exception(DisasContext *dc, { TCGv_i32 tmp = tcg_const_i32(index); - tcg_gen_movi_tl(cpu_R[R_PC], dc->pc); + tcg_gen_movi_tl(cpu_pc, dc->pc); gen_helper_raise_exception(cpu_env, tmp); tcg_temp_free_i32(tmp); dc->base.is_jmp = DISAS_NORETURN; @@ -156,10 +157,10 @@ static void gen_goto_tb(DisasContext *dc, int n, uint32_t dest) if (translator_use_goto_tb(&dc->base, dest)) { tcg_gen_goto_tb(n); - tcg_gen_movi_tl(cpu_R[R_PC], dest); + tcg_gen_movi_tl(cpu_pc, dest); tcg_gen_exit_tb(tb, n); } else { - tcg_gen_movi_tl(cpu_R[R_PC], dest); + tcg_gen_movi_tl(cpu_pc, dest); tcg_gen_exit_tb(NULL, 0); } } @@ -391,7 +392,7 @@ static void eret(DisasContext *dc, uint32_t code, uint32_t flags) } tcg_gen_mov_tl(cpu_R[CR_STATUS], cpu_R[CR_ESTATUS]); - tcg_gen_mov_tl(cpu_R[R_PC], cpu_R[R_EA]); + tcg_gen_mov_tl(cpu_pc, cpu_R[R_EA]); dc->base.is_jmp = DISAS_JUMP; } @@ -399,7 +400,7 @@ static void eret(DisasContext *dc, uint32_t code, uint32_t flags) /* PC <- ra */ static void ret(DisasContext *dc, uint32_t code, uint32_t flags) { - tcg_gen_mov_tl(cpu_R[R_PC], cpu_R[R_RA]); + tcg_gen_mov_tl(cpu_pc, cpu_R[R_RA]); dc->base.is_jmp = DISAS_JUMP; } @@ -407,7 +408,7 @@ static void ret(DisasContext *dc, uint32_t code, uint32_t flags) /* PC <- ba */ static void bret(DisasContext *dc, uint32_t code, uint32_t flags) { - tcg_gen_mov_tl(cpu_R[R_PC], cpu_R[R_BA]); + tcg_gen_mov_tl(cpu_pc, cpu_R[R_BA]); dc->base.is_jmp = DISAS_JUMP; } @@ -417,7 +418,7 @@ static void jmp(DisasContext *dc, uint32_t code, uint32_t flags) { R_TYPE(instr, code); - tcg_gen_mov_tl(cpu_R[R_PC], load_gpr(dc, instr.a)); + tcg_gen_mov_tl(cpu_pc, load_gpr(dc, instr.a)); dc->base.is_jmp = DISAS_JUMP; } @@ -440,7 +441,7 @@ static void callr(DisasContext *dc, uint32_t code, uint32_t flags) { R_TYPE(instr, code); - tcg_gen_mov_tl(cpu_R[R_PC], load_gpr(dc, instr.a)); + tcg_gen_mov_tl(cpu_pc, load_gpr(dc, instr.a)); tcg_gen_movi_tl(cpu_R[R_RA], dc->base.pc_next); dc->base.is_jmp = DISAS_JUMP; @@ -742,7 +743,7 @@ illegal_op: t_gen_helper_raise_exception(dc, EXCP_ILLEGAL); } -static const char * const regnames[] = { +static const char * const regnames[NUM_CORE_REGS] = { "zero", "at", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", @@ -759,7 +760,6 @@ static const char * const regnames[] = { "reserved6", "reserved7", "reserved8", "reserved9", "reserved10", "reserved11", "reserved12", "reserved13", "reserved14", "reserved15", "reserved16", "reserved17", - "rpc" }; #include "exec/gen-icount.h" @@ -827,7 +827,7 @@ static void nios2_tr_tb_stop(DisasContextBase *dcbase, CPUState *cs) case DISAS_TOO_MANY: case DISAS_UPDATE: /* Save the current PC back into the CPU register */ - tcg_gen_movi_tl(cpu_R[R_PC], dc->base.pc_next); + tcg_gen_movi_tl(cpu_pc, dc->base.pc_next); tcg_gen_exit_tb(NULL, 0); break; @@ -876,8 +876,7 @@ void nios2_cpu_dump_state(CPUState *cs, FILE *f, int flags) return; } - qemu_fprintf(f, "IN: PC=%x %s\n", - env->regs[R_PC], lookup_symbol(env->regs[R_PC])); + qemu_fprintf(f, "IN: PC=%x %s\n", env->pc, lookup_symbol(env->pc)); for (i = 0; i < NUM_CORE_REGS; i++) { qemu_fprintf(f, "%9s=%8.8x ", regnames[i], env->regs[i]); @@ -903,10 +902,12 @@ void nios2_tcg_init(void) offsetof(CPUNios2State, regs[i]), regnames[i]); } + cpu_pc = tcg_global_mem_new(cpu_env, + offsetof(CPUNios2State, pc), "pc"); } void restore_state_to_opc(CPUNios2State *env, TranslationBlock *tb, target_ulong *data) { - env->regs[R_PC] = data[0]; + env->pc = data[0]; } From patchwork Thu Mar 10 11:26:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 550089 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp898638mag; Thu, 10 Mar 2022 03:29:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJw6gyP3ImGxX/KFpWQZSi5lkM5VvuQhqSm+IPFLAFTfmu/qexS0AacqbxBjfOs6lcr8CcHf X-Received: by 2002:a81:a842:0:b0:2db:562a:3f13 with SMTP id f63-20020a81a842000000b002db562a3f13mr3354870ywh.322.1646911742119; Thu, 10 Mar 2022 03:29:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646911742; cv=none; d=google.com; s=arc-20160816; b=yV7ibCHhVEbSvdVLSXRl9p8LpmwJhw6GKKZdh4nickVAty3FLuyZ7YCw9u5wArWWcN UWm+djhY5yhu6q76XGnZX6PDT5fPFHIYMsWPW+IctyDlWO+nH1w+cmEqIvsYsTBijDWf Yr6gv/jteLoh//wiMaBqzllrl/l2M7PWj2q9WKqZrIMjLN/Mp/E5dwltyImS18kpzNQb FpCT+ZY8JZlrMO+NcqXj2AqbJ7MzllXbMVQ2cE4g5XsOq8loGDPcuDHYKNRk2b7tp1lA xHp1ogKmyehuaVcxPgMOTCnaojOWZq8TIwBcUEa/Femq5R58UmaWz6pyjEbQlBimgVTb 0AwA== 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=JwvNUZim2yApAOIks/gNVf1oLVx5CVGA+91qmxfeNYY=; b=a33ozk0JB+ANzr6YZ6bzxwc+75+Es7GntLdtv1tWLURttJ7jpZ4hm32/aN9ZLv6qf7 /jO+QMHqv39nNo3MKj94dtUYERZ4z5yp1hOyvZVs7oNTg7mbvQmLNHNpLvFD/KACrHxq vBMWem5gm5zDR7feNhsbkYDuWleRBtLQc1ve5so6rcW2tXr8wQia+69bhpuoCU/DEpWx YUp/3aUmgehUDmADEU4HMV7Ax5rKmLxT97zeYNr1WYhLfTqA0qxKwtpLXZE9DGuzVwx7 lMzypFmjM+uVBv0I2I38aDNssO38jmKSdUSk3GmInn1tRBSjlbw+Q/gJ5O7nDwUAgNha I9ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="Ny/2s4jh"; 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 m81-20020a812654000000b002dc02646681si3101659ywm.75.2022.03.10.03.29.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Mar 2022 03:29:02 -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="Ny/2s4jh"; 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]:57620 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSGyb-00058f-K8 for patch@linaro.org; Thu, 10 Mar 2022 06:29:01 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50590) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSGxE-0004zZ-Cr for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:27:36 -0500 Received: from [2607:f8b0:4864:20::433] (port=35329 helo=mail-pf1-x433.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nSGxC-0007vK-AE for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:27:36 -0500 Received: by mail-pf1-x433.google.com with SMTP id a5so4867012pfv.2 for ; Thu, 10 Mar 2022 03:27:33 -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=JwvNUZim2yApAOIks/gNVf1oLVx5CVGA+91qmxfeNYY=; b=Ny/2s4jhqYmWx7BbT/XrJ3Nk6R4IBdravzVIYmVegrzcB1U6Bc9KKid3D5RCidAput UQUnoAHW+RxUN5087+3trXlIqgFgRQunH/hkw/1bto58uwNdK7pr86Aj6QYj/+9RfJDf U5x+mXvoS9Ruppx9ehGjtYAMOaEcBy3y+w9vi/dBNUdmL8nGzBDzM623027YJ6BqI330 omHcv35ay0fuXd9Cx5Rxo2TQd25oV1vE8q+DQjvzW9EGl4VGQsiQpyNaPUyDmlDehfk7 tFl7KxsnfUQAPQRkSzLDRvkQ7PSS0Nv4LaYNglGppcaUk52NsYXA+dshhZJC0LtT/XhC mTQw== 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=JwvNUZim2yApAOIks/gNVf1oLVx5CVGA+91qmxfeNYY=; b=KXPg/YmMgQUvxhjRoSO7QSgKBjSaRB+ydb6Uuoa/0XSssZWtWkxnLEMxgcbKmospIR H3qz3ZTbDjlhER+LQWXdUckUO2yHEbAZi1UlmSypWFvf+1dArj50V3y/a2WCH3f/SshC a9xnbQ4noSvUiMJNvAtTb8kdmk7wBrRxE3KX4gtJ4jKuJOastBExjJSc/AEZSB8+8BuS zd2ezfBS6Xs0M3Qz0bcIau1NswkYqp7pKJOvnbKVEfEmWTWocW2gzD4EUsF0TKwvSmSV OEWVfwoHaEDl5h/k/v1Bz1jhwCK+pCqfyKGsxFYiumcuyRubaIrKESilfbPDLgIeovwq is1g== X-Gm-Message-State: AOAM533M8j4Ma4tiYjpS45KNhJr+njFKDHdX40R2hHV3FlnJAp8nxGCB ZiICUr6vNrM3ZTSap8eWRiB1jqKELzzyKg== X-Received: by 2002:a62:7c58:0:b0:4f6:ebf1:e78d with SMTP id x85-20020a627c58000000b004f6ebf1e78dmr4625994pfc.18.1646911652862; Thu, 10 Mar 2022 03:27:32 -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.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Mar 2022 03:27:32 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 05/48] target/nios2: Split out helper for eret instruction Date: Thu, 10 Mar 2022 03:26:42 -0800 Message-Id: <20220310112725.570053-6-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::433 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::433; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x433.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" From: Amir Gonnen The implementation of eret will become much more complex with the introduction of shadow registers. Reviewed-by: Peter Maydell Signed-off-by: Amir Gonnen Message-Id: <20220303153906.2024748-3-amir.gonnen@neuroblade.ai> [rth: Split out of a larger patch for shadow register sets. Directly exit to the cpu loop from the helper.] Signed-off-by: Richard Henderson --- target/nios2/helper.h | 1 + target/nios2/op_helper.c | 9 +++++++++ target/nios2/translate.c | 10 ++++++---- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/target/nios2/helper.h b/target/nios2/helper.h index a44ecfdf7a..525b6b685b 100644 --- a/target/nios2/helper.h +++ b/target/nios2/helper.h @@ -21,6 +21,7 @@ DEF_HELPER_FLAGS_2(raise_exception, TCG_CALL_NO_WG, noreturn, env, i32) #if !defined(CONFIG_USER_ONLY) +DEF_HELPER_3(eret, noreturn, env, i32, i32) DEF_HELPER_2(mmu_write_tlbacc, void, env, i32) DEF_HELPER_2(mmu_write_tlbmisc, void, env, i32) DEF_HELPER_2(mmu_write_pteaddr, void, env, i32) diff --git a/target/nios2/op_helper.c b/target/nios2/op_helper.c index caa885f7b4..ee5ad8b23f 100644 --- a/target/nios2/op_helper.c +++ b/target/nios2/op_helper.c @@ -30,3 +30,12 @@ void helper_raise_exception(CPUNios2State *env, uint32_t index) cs->exception_index = index; cpu_loop_exit(cs); } + +#ifndef CONFIG_USER_ONLY +void helper_eret(CPUNios2State *env, uint32_t new_status, uint32_t new_pc) +{ + env->regs[CR_STATUS] = new_status; + env->pc = new_pc; + cpu_loop_exit(env_cpu(env)); +} +#endif /* !CONFIG_USER_ONLY */ diff --git a/target/nios2/translate.c b/target/nios2/translate.c index 154ffacbea..7c2c430e99 100644 --- a/target/nios2/translate.c +++ b/target/nios2/translate.c @@ -391,10 +391,12 @@ static void eret(DisasContext *dc, uint32_t code, uint32_t flags) return; } - tcg_gen_mov_tl(cpu_R[CR_STATUS], cpu_R[CR_ESTATUS]); - tcg_gen_mov_tl(cpu_pc, cpu_R[R_EA]); - - dc->base.is_jmp = DISAS_JUMP; +#ifdef CONFIG_USER_ONLY + g_assert_not_reached(); +#else + gen_helper_eret(cpu_env, cpu_R[CR_ESTATUS], cpu_R[R_EA]); + dc->base.is_jmp = DISAS_NORETURN; +#endif } /* PC <- ra */ 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 */ From patchwork Thu Mar 10 11:26:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 550091 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp901879mag; Thu, 10 Mar 2022 03:32:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJxyO+8mkBqRDuju0EYtR13eGSsssjBO9IDvuuaWp+8vOql0bx/D2bnfK/yKwyoOBOYcJNXK X-Received: by 2002:a05:6902:10b:b0:623:e011:97db with SMTP id o11-20020a056902010b00b00623e01197dbmr3392726ybh.79.1646911977404; Thu, 10 Mar 2022 03:32:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646911977; cv=none; d=google.com; s=arc-20160816; b=tZO6R7yUgpsAHGsXa4Ny6rowbcPmjF0OjuHaS2swbkCOBRRF/ghNZP2+XN7PmZz7O5 FJ4rX9/9bxbhuVSShqGmVpht2ZAG9TBwPO1lUjmjXVePTh9lZjGvc5IvPihAkzWVV1nM X5s09JbWR9qw3c6iOca/nj7FqiO3KPomNVRY2LalOTca0gic6ViEhwH79v0Qf/8Rj5+N LiPvdk507rVdsNcecIjxuh9ZIKY1dTSPsVxY+fCPJTeSfKqSSiau+Bm44y4wdvz4G9wy ooNiFcYJ2dQsyp/WDR8fls0vA9Cz9CnG6trWSVfuj7oKg3TsZP5Sn3zmAQp1nwLUJ6vu IBNg== 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=PuQXs01EVc8/4vklrwlVd1dwEAykk2bEYyKpnLalt08=; b=hclvYlXqAn1S6GgpZJ9axYu4NyPrXxpp0AQjGLQOQqaMeunUZ8bG9FRkzS1BVPrSqP oD7J08SsS0FX84/1a2CTM9G4cG0lvRICCQbq8zAypLwYye1sToIzcakMjgd0IKx7Yo8V AkSSOnNuXPJZOtULGM9+zRIxE4myJ7kPm866ExTV2Bloqfd/l3aaXxOZVjoeQHs4oFj6 +HHnP8oXnE6ovXdEjMWUKNU7IgbkiUx5v7rGuMdwjk5RefbNr6NcSjQOxVse6l16dfog aWSTPb4HTFA6hDRMC2U7jiR9mWBd4YRfn51pXe1zb9RvO6FgLQYsrSIfL7sWeB2Ng+pz DgkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=TkAxNSGW; 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 h18-20020a25be12000000b00628e0fecc65si2747004ybk.148.2022.03.10.03.32.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Mar 2022 03:32:57 -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=TkAxNSGW; 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]:37930 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSH2O-0002YF-Sd for patch@linaro.org; Thu, 10 Mar 2022 06:32:56 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50620) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSGxG-00053Y-00 for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:27:38 -0500 Received: from [2607:f8b0:4864:20::536] (port=39935 helo=mail-pg1-x536.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nSGxE-0007vj-Al for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:27:37 -0500 Received: by mail-pg1-x536.google.com with SMTP id q19so4486294pgm.6 for ; Thu, 10 Mar 2022 03:27:35 -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=PuQXs01EVc8/4vklrwlVd1dwEAykk2bEYyKpnLalt08=; b=TkAxNSGWlcC4O+XeqHAAQORvajDnfsn9h9ABW/3rbu19TooNxCvdFk7XP6LxydKBaz Gv774xRENsWsoOdg+uOXWLy8cuOcO0EsDOpLNl/qlR+r74JmgYZzcNvjtPSg9YerfZ1R GgvkKn3cR64ElkMnQpj0qcqm5qj4pIB0I2uwwyJHdYpP5ChZ0q3uU9Zimx17KGYFwb7K /vAPt6wbJGDoayfvrUsMAZJHyXX/YCBUX+LWtv5vrP8GQ9dHzajwC82fDv0i5dvhdhvY fu4Zgd+Nmh3PaeXg34U/tqnPi2oQIe+GGmpyzXocmbI4UzJTqlHNl1EmFvTyRKGDPiPC xtWA== 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=PuQXs01EVc8/4vklrwlVd1dwEAykk2bEYyKpnLalt08=; b=HtDtCED3gXFfhR/7f4juCMlotiv6Gcu3Y3Z34Vehz7VLYzffvM2CfqhqiC+8rTpRTn DE48PM0kwIgIc5GSc75/Ao2hOEofYi+Xg2ApwTYGEufZDI3tvjGgUCVWWE4ENFoJzPjE AhsMLJu/vwSisxKWTMegPKtApL2cF60vqXJIQ38sT+W1iC5N2hrtWeTaPP5nzsCy/GtT pGjrZpyhEeTehliBEmDy9LTCzKX36SVw+oNC2LXz6b4POOSCqSrtM6RFG7cvDIHjCTJa 9SJd4Tzl5hmaLcOlWWz7WJSnvN6OSDAjL4K8wnnN8yT//Z/F7e1wHjUoxAK6UpM0JZhf UYyQ== X-Gm-Message-State: AOAM5334XmxDTINMDGKbfRFiM0RlTo6Py3X86p0gpeSv+DVfKJSheVUv n+3HKMNJkbMZNrIF1U6GuXWbvhOeOGo/Tg== X-Received: by 2002:a63:515:0:b0:379:460f:7bda with SMTP id 21-20020a630515000000b00379460f7bdamr3713022pgf.534.1646911655070; Thu, 10 Mar 2022 03:27:35 -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.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Mar 2022 03:27:34 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 07/48] target/nios2: Do not create TCGv for control registers Date: Thu, 10 Mar 2022 03:26:44 -0800 Message-Id: <20220310112725.570053-8-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::536 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::536; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x536.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 don't need to reference them often, and when we do it is just as easy to load/store from cpu_env directly. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/nios2/translate.c | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/target/nios2/translate.c b/target/nios2/translate.c index 3f7bbd6d7b..e6e9a5ac6f 100644 --- a/target/nios2/translate.c +++ b/target/nios2/translate.c @@ -103,7 +103,7 @@ typedef struct DisasContext { int mem_idx; } DisasContext; -static TCGv cpu_R[NUM_CORE_REGS]; +static TCGv cpu_R[NUM_GP_REGS]; static TCGv cpu_pc; typedef struct Nios2Instruction { @@ -394,7 +394,11 @@ static void eret(DisasContext *dc, uint32_t code, uint32_t flags) #ifdef CONFIG_USER_ONLY g_assert_not_reached(); #else - gen_helper_eret(cpu_env, cpu_R[CR_ESTATUS], cpu_R[R_EA]); + TCGv tmp = tcg_temp_new(); + tcg_gen_ld_tl(tmp, cpu_env, offsetof(CPUNios2State, regs[CR_ESTATUS])); + gen_helper_eret(cpu_env, tmp, cpu_R[R_EA]); + tcg_temp_free(tmp); + dc->base.is_jmp = DISAS_NORETURN; #endif } @@ -420,7 +424,11 @@ static void bret(DisasContext *dc, uint32_t code, uint32_t flags) #ifdef CONFIG_USER_ONLY g_assert_not_reached(); #else - gen_helper_eret(cpu_env, cpu_R[CR_BSTATUS], cpu_R[R_BA]); + TCGv tmp = tcg_temp_new(); + tcg_gen_ld_tl(tmp, cpu_env, offsetof(CPUNios2State, regs[CR_BSTATUS])); + gen_helper_eret(cpu_env, tmp, cpu_R[R_BA]); + tcg_temp_free(tmp); + dc->base.is_jmp = DISAS_NORETURN; #endif } @@ -463,6 +471,7 @@ static void callr(DisasContext *dc, uint32_t code, uint32_t flags) static void rdctl(DisasContext *dc, uint32_t code, uint32_t flags) { R_TYPE(instr, code); + TCGv t1, t2; if (!gen_check_supervisor(dc)) { return; @@ -482,10 +491,19 @@ static void rdctl(DisasContext *dc, uint32_t code, uint32_t flags) * must perform the AND here, and anywhere else we need the * guest value of ipending. */ - tcg_gen_and_tl(cpu_R[instr.c], cpu_R[CR_IPENDING], cpu_R[CR_IENABLE]); + t1 = tcg_temp_new(); + t2 = tcg_temp_new(); + tcg_gen_ld_tl(t1, cpu_env, + offsetof(CPUNios2State, regs[CR_IPENDING])); + tcg_gen_ld_tl(t2, cpu_env, + offsetof(CPUNios2State, regs[CR_IENABLE])); + tcg_gen_and_tl(cpu_R[instr.c], t1, t2); + tcg_temp_free(t1); + tcg_temp_free(t2); break; default: - tcg_gen_mov_tl(cpu_R[instr.c], cpu_R[instr.imm5 + CR_BASE]); + tcg_gen_ld_tl(cpu_R[instr.c], cpu_env, + offsetof(CPUNios2State, regs[instr.imm5 + CR_BASE])); break; } } @@ -522,7 +540,8 @@ static void wrctl(DisasContext *dc, uint32_t code, uint32_t flags) dc->base.is_jmp = DISAS_UPDATE; /* fall through */ default: - tcg_gen_mov_tl(cpu_R[instr.imm5 + CR_BASE], v); + tcg_gen_st_tl(v, cpu_env, + offsetof(CPUNios2State, regs[instr.imm5 + CR_BASE])); break; } #endif @@ -909,7 +928,7 @@ void nios2_tcg_init(void) { int i; - for (i = 0; i < NUM_CORE_REGS; i++) { + for (i = 0; i < NUM_GP_REGS; i++) { cpu_R[i] = tcg_global_mem_new(cpu_env, offsetof(CPUNios2State, regs[i]), regnames[i]); From patchwork Thu Mar 10 11:26:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 550092 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp906403mag; Thu, 10 Mar 2022 03:39:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJwCQxDB5tik1/uCaUjDZIGqBfepzPGh8mQKuuS4v/ssDP2dC03ssZqHRXQpQbxxNaTY9ibz X-Received: by 2002:a0d:dd01:0:b0:2dc:2a9:9429 with SMTP id g1-20020a0ddd01000000b002dc02a99429mr3540284ywe.457.1646912350172; Thu, 10 Mar 2022 03:39:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646912350; cv=none; d=google.com; s=arc-20160816; b=yHJqmYMH2B+++rJCUdbZCxTc/SENETSkURkXL2lP2TdD/7KSo1w5loBP9r28HF1Rj4 hVvNPa4+SOEe5Ot03w83/KjBXg6RvyXUy68BH07dYghxIe2kjuD9Ci4GQaGgdS6KSTKJ v2xtcuocCbKENJT+BUrFe4+Mp4fPWSzyVioOP3JPF6331XegX+drqq3Dr4FouBWFE8k9 ukWzuezFB3hmDTryeOk9DuDtyPXKO5LOkyu6xu2CJx0bJpE7ylyjp2V3DrQQtwxfGyrf NquX38DA2NOBIYK5AdJ7d8ITHN/wu22xynX7oz2zx5uXK30wPYifhaAm0TbpMtgP2wF1 9uBQ== 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=hT9+kz2FAkTBjPGP7wP7XlOIGomdVd803xe/PZq0Q4s=; b=wWQ/QEQsUisZnat6dibMGNdYNzqDRoDK2GfaBRm94CxMoTS169QfdyX/t9tTQlSd+P Xtv/9EWwC7DHaNhjPTsopSMM25ge2Fuc8ZLDqYR/Ozuw46tWFnr9xrXerEINBgijIKOs 97msIZAnp99q1Y/3WxWRvTe7tG6myPwY+D51Auu4kAM5SJ5Wzj6JMpOAaq90D8G0to/e 04AHZubz/nyB7zdl1OoWHkdqVlJT8DUsVSxwUIgXPIQQYP2JitfdbgtwHWKMCYmMiuF5 H73V8aW2I5tE7v7kukSMxP4sAENXgOapEiLMfx+pb6D0SIxjRd74WWPZEvcwwF2By4DY sayw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=bWeHWB3v; 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 a11-20020a056902144b00b00627f468dd4bsi2965030ybv.602.2022.03.10.03.39.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Mar 2022 03:39:10 -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=bWeHWB3v; 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]:46270 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSH8P-0008TJ-Lr for patch@linaro.org; Thu, 10 Mar 2022 06:39:09 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50636) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSGxG-00055C-PQ for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:27:38 -0500 Received: from [2607:f8b0:4864:20::42f] (port=33513 helo=mail-pf1-x42f.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nSGxF-0007w0-6R for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:27:38 -0500 Received: by mail-pf1-x42f.google.com with SMTP id s42so4889778pfg.0 for ; Thu, 10 Mar 2022 03:27:36 -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=hT9+kz2FAkTBjPGP7wP7XlOIGomdVd803xe/PZq0Q4s=; b=bWeHWB3vjwbcZuJKqb7uF2HS60ggyIyHzls7IPzcRjRK9xxeKLRxRdWHhMuy+NNt6U vK8sjn1QWLsjA8sII0yg0LSIXaYoFFaRkmoXKJaaPeOcNYzv4KT80BX+a/xvcoR5dyDl zwrLeOG5mjRGasLC0MWsfjkc0XebbhCumbunuONl2IO6t2u8HufxYZitGon1WWlMXrFD IVDZPbDBWhBqM3ncR8h85YMFCkBuw5Onkjfk6VXXyDckB19MZIGUGAunfY64CXQPJsek DiMuMYzDcXzs1cW3ufOlz5fZ1Z48jxR+Ja8elMJq5T2uXQZPmDSlNRafNfd/t9wXSjgD jBkw== 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=hT9+kz2FAkTBjPGP7wP7XlOIGomdVd803xe/PZq0Q4s=; b=4MdOQFJBShuiiPQDK2R25BN9ZCjOb47jXvp8dyYW046cn8Avd6qMlg5uumb29sNnb+ hy4KHUu0xjN5OiXsP/XKHZIEziOiX/bMU3WPvNv4QxE8Qr2R3kKx/WO1X/BYzgoQQDu9 jGPDRVUka4aHVyRStSJJ6h0k9Q61iGPwPVF3mumnt4b4Rmbb9Wzh89+JGoHZIsJEraEl +6n2vvkk+kGAjY4S7EbklDKrz2f7VY6/Vec2rGDgmyqGrQ8bBcdgEfOVEOPRxCUKmMEW RexbdM9Qjuj9duJ6Io1hkavSuZCR53fhp+N69IO61WUSmfZwlrdOHL51lWAyb2eOjgbT fGOg== X-Gm-Message-State: AOAM533pihM4NgPoEQvxW6ynGwgCEQPmWqpsqMwSGfJXIAoR1uqL6Xs4 I5yR1ZiKNTwm3wCp617vhzW/kMj+qUXv1Q== X-Received: by 2002:a63:824a:0:b0:37c:94e3:e7de with SMTP id w71-20020a63824a000000b0037c94e3e7demr3723745pgd.496.1646911655857; Thu, 10 Mar 2022 03:27:35 -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.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Mar 2022 03:27:35 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 08/48] linux-user/nios2: Only initialize SP and PC in target_cpu_copy_regs Date: Thu, 10 Mar 2022 03:26:45 -0800 Message-Id: <20220310112725.570053-9-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::42f (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::42f; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42f.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" Drop the set of estatus in init_thread; it was clearly intended to be setting the value of CR_STATUS for the application, but we never actually performed that copy. However, the proper value is set in nios2_cpu_reset so we don't need to do anything here. We only initialize SP and EA in init_thread, there's no value in copying other uninitialized data into ENV. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- linux-user/elfload.c | 1 - linux-user/nios2/cpu_loop.c | 22 ---------------------- 2 files changed, 23 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 23ff9659a5..8c85c933b7 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -1096,7 +1096,6 @@ static void init_thread(struct target_pt_regs *regs, struct image_info *infop) { regs->ea = infop->entry; regs->sp = infop->start_stack; - regs->estatus = 0x3; } #define LO_COMMPAGE TARGET_PAGE_SIZE diff --git a/linux-user/nios2/cpu_loop.c b/linux-user/nios2/cpu_loop.c index 7b20c024db..fa234cb2af 100644 --- a/linux-user/nios2/cpu_loop.c +++ b/linux-user/nios2/cpu_loop.c @@ -132,28 +132,6 @@ void cpu_loop(CPUNios2State *env) void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs) { - env->regs[0] = 0; - env->regs[1] = regs->r1; - env->regs[2] = regs->r2; - env->regs[3] = regs->r3; - env->regs[4] = regs->r4; - env->regs[5] = regs->r5; - env->regs[6] = regs->r6; - env->regs[7] = regs->r7; - env->regs[8] = regs->r8; - env->regs[9] = regs->r9; - env->regs[10] = regs->r10; - env->regs[11] = regs->r11; - env->regs[12] = regs->r12; - env->regs[13] = regs->r13; - env->regs[14] = regs->r14; - env->regs[15] = regs->r15; - /* TODO: unsigned long orig_r2; */ - env->regs[R_RA] = regs->ra; - env->regs[R_FP] = regs->fp; env->regs[R_SP] = regs->sp; - env->regs[R_GP] = regs->gp; - env->regs[CR_ESTATUS] = regs->estatus; env->pc = regs->ea; - /* TODO: unsigned long orig_r7; */ } From patchwork Thu Mar 10 11:26:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 550115 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp921468mag; Thu, 10 Mar 2022 04:00:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJyhp+w0syHIfYaS/FM6eMHYLtY2wfjMyd+mckUCkjlIziAOqcitqCocNH5R/jEcurIWJDHL X-Received: by 2002:a81:5354:0:b0:2ca:287c:6b5e with SMTP id h81-20020a815354000000b002ca287c6b5emr3558063ywb.3.1646913640065; Thu, 10 Mar 2022 04:00:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646913640; cv=none; d=google.com; s=arc-20160816; b=lxgkuLVWtSDBwlicTuLVqNyWr39ytedXJSlHaxbDShFCQGtc3qjxCbdkT6rSzJOxm5 BagPn+KxquBPxCVTW3Bo9rOrruCjb04JUQ6H4Hl8Yd0pwKBuBUvuBTazDGhS18cvwqCq 8xzX4mj3pE1XMk1wgIpxsuPdQxM6Tbbsn+cz0wQZQs4cnPR1+UyzPW6CqSRtWXlDLy91 DJZWixTXIslpzX0L/UmYMDHdToPTaOkR+zOeXr1BgMbFY1nKM0vd4qI8DFJaCLew4EhO 1ZhrolIHhktz7C95igScfaSFKWvrprvqjnEdSYllP9uG3dWxg8pPXhxtbmP4fzFmYOgp R5rQ== 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=Cj1Mv1TK+d1R4GNVLpYWtLlcIcx/OqQSWvfjy4IfC40=; b=Z6fcmgb5rxue+mXQPTfYH4gsUdBoT7lVSMrawT6DsZRbwkfZetsIubSfAvaJDCci0u 5nLNbAWgbIYtXdAF7XU11fOyPsddAIuwDPbuEemSZA7wTnhegMJ5huH8imZBHPVZeduL BhMOI4T9hoPhH0qAQu58IvCxjQ1WDKaYpDdepcbL+VzF3OydLwkIfDNDbFGRePqhbTV6 /HFA78Tya/o5tAWf9SUtIQXSaZd8NHwgDDKn78oh9fI8kdnxxVjr9N9LhVGVx9I+qubi SFzW1506ge0dpWd87KC+WLPVpimXwuIkGKthc4eyyRGEhLcIH3b3heHU9tP1V3uTUW+W M4oA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=TyNW+pRT; 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 14-20020a25090e000000b006294011c58bsi2750823ybj.669.2022.03.10.04.00.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Mar 2022 04:00:40 -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=TyNW+pRT; 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]:48512 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSHTD-0006gm-GC for patch@linaro.org; Thu, 10 Mar 2022 07:00:39 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50648) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSGxH-00057e-MG for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:27:39 -0500 Received: from [2607:f8b0:4864:20::435] (port=38551 helo=mail-pf1-x435.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nSGxG-0007w9-0h for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:27:39 -0500 Received: by mail-pf1-x435.google.com with SMTP id f8so4847757pfj.5 for ; Thu, 10 Mar 2022 03:27:37 -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=Cj1Mv1TK+d1R4GNVLpYWtLlcIcx/OqQSWvfjy4IfC40=; b=TyNW+pRTW0n2lRdUpmRyrzv2a63QvMUHFkGeDvKbCpKE3RLEBRmaE6MMfJYeAryjxu V+J5+44WMIL7FWT7BVfvG4VcWGtrhNZa+i+yoX1pDNw8swhoULgwCGvlhNiV+BZtWdNI PjqdkJossw9DmX4fA6/PiR8/sVweL610j3czGq2gXzYOVMaKv/ZLYNmGy2l+DQEMCQlF sIjShuN+H6/SsWNFPugCPvxJQXbdx2+yoY/NdUfmSIAOx0w1PvZWc5Duq4Mew9GFoPfD W953yDjgssbrlzTtdt9M66FjCo+DYXsnPd0SQCwXI2EMSDTh1fwCQ4MHyKKFiJLp+iXj y33w== 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=Cj1Mv1TK+d1R4GNVLpYWtLlcIcx/OqQSWvfjy4IfC40=; b=BLwhnrQ8zxJnmZ44fGFs2pL6tW/+WD76oONDjIlZPNsOu/P11KXOiZ6yu3/7KmlExD LUFE8dMRfvziX5vfv4s0DkgdPUbfq10GeybW1RVwfI+kifpuWU9d+VxAJtCWvMNY1ers Me7bLMoFJdw9W/8OUGPLMqJ3z8EGsSJumP6bRo+x8llSGInktA2Z9fwvTrTbFHsYI79t KkAJKroPXkGLtQZyUUCZjXLhyUQ8QO9YeeduTXT1raX/IXPa6AHtadXiLJYp+9wcvzu8 zSk4P4oMaALAqEnMggXVKQFcc/+9lxlVovvjLXqJpne9ll7q600O5ckerU2JAm9iWLOW ED4A== X-Gm-Message-State: AOAM533DtOJVD/nzrQ9nJXg2T/c1DRqN79q8zkdqYI19GNF2BiaH1wiB c1B85PzccfsEJY5TRjputPlR/kDcgUyZKw== X-Received: by 2002:a63:4403:0:b0:375:6d5b:5aa7 with SMTP id r3-20020a634403000000b003756d5b5aa7mr3578406pga.269.1646911656721; Thu, 10 Mar 2022 03:27:36 -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.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Mar 2022 03:27:36 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 09/48] target/nios2: Remove cpu_interrupts_enabled Date: Thu, 10 Mar 2022 03:26:46 -0800 Message-Id: <20220310112725.570053-10-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::435 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::435; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x435.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" This function is unused. The real computation of this value is located in nios2_cpu_exec_interrupt. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/nios2/cpu.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/target/nios2/cpu.h b/target/nios2/cpu.h index 9be128d63a..59e950dae6 100644 --- a/target/nios2/cpu.h +++ b/target/nios2/cpu.h @@ -226,11 +226,6 @@ bool nios2_cpu_tlb_fill(CPUState *cs, vaddr address, int size, bool probe, uintptr_t retaddr); #endif -static inline int cpu_interrupts_enabled(CPUNios2State *env) -{ - return env->regs[CR_STATUS] & CR_STATUS_PIE; -} - typedef CPUNios2State CPUArchState; typedef Nios2CPU ArchCPU; From patchwork Thu Mar 10 11:26:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 550118 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp924179mag; Thu, 10 Mar 2022 04:03:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJzEMnrymbCzFmqiAYJn9xlb9KS2wftBzx4qlkSGU8a8p+M0iYhutxisYSAXa/VtRXi0st0x X-Received: by 2002:a0d:fe43:0:b0:2d0:b2b2:2ed4 with SMTP id o64-20020a0dfe43000000b002d0b2b22ed4mr3633245ywf.355.1646913814053; Thu, 10 Mar 2022 04:03:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646913814; cv=none; d=google.com; s=arc-20160816; b=n/3Eg13+DO2jMe5c+gNEShHPoCXXhmRBFbTp+cZV3haqGkr/9oeenMvmtVsI4+wyMn C0r8Sw3MJuIE1aSFKLhFu8TdsnYs05nhtbjG2/m6IBGqJcHs2EhkdMjqbBZlN/n/VEzU iywnIW19gT3NGCMRTYU0cfLkIJtBaWv2qoij4uFLZyER+Hb+pAUfXEKQ5/lMH2Tqodau vzXicnbkIZGefcNQE8yryoc866utwjtt12rcbnNIGkrSU3v4x/2mYmtiO7GvfeHql5qO jugvSIQbCuxoyQsYbi+3rjLiWPIaLP4KbOiZY53FaywTE9axvqFGsGopnqzXaQEVPudc 09/A== 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=ODzUuO9Bo/dCZ/z6T/TQX0tDH/2DhM3+AVV8gLtx3XM=; b=cQHxgH5ArjQIxAtApL+ndN6Gh9QKSzlv36saL6NnZFWFYmFxLClMurVeQiftxeZ754 bysJQGOrbM8Bgyv3p+oFTXRVjlGomVBDysEUqGV6/6Q6NLQvGxaTKRdqw+7kPB6idnGi /baCtHhEXTk89z35s1hMY+4RwDvXJKfQj8Dr+i5y/iaP4hlkwWwN2OngoyRiGgyhVwR7 0HOdAgmBiaMFv9grqdEhAkOHE5VaCAF2OpO13VZQT/VMy2eRbJLKr/2DntRb8LdDlzjh XmSOsO6Pg1S9ofFmB74DJheTmt9LAAfzaAz5tv7ybErRV0/oiInRlHuBByxjLOyZLoa1 biMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=eVWoLQwy; 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 r1-20020a25b981000000b0061e036b52fesi2771790ybg.634.2022.03.10.04.03.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Mar 2022 04:03:34 -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=eVWoLQwy; 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]:54970 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSHW1-0002gl-IO for patch@linaro.org; Thu, 10 Mar 2022 07:03:33 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50684) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSGxJ-0005EV-Uf for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:27:41 -0500 Received: from [2607:f8b0:4864:20::1031] (port=52820 helo=mail-pj1-x1031.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nSGxH-0007wT-9a for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:27:41 -0500 Received: by mail-pj1-x1031.google.com with SMTP id v4so4972215pjh.2 for ; Thu, 10 Mar 2022 03:27:38 -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=ODzUuO9Bo/dCZ/z6T/TQX0tDH/2DhM3+AVV8gLtx3XM=; b=eVWoLQwyg/RcC3ZBEEuEfTKXmo47wvJ3WOpnTwuKSOYvIJ6UiM/F16enk8wFrvyrB8 VoKb6KmgNgbeWIKdFNobV9hNvFb4QJUNniTWHsLvLfKKCeQJRG3ED77hmoyCGxOlQQv6 cNtwCWDIi0OwIBHfVyfpr4vh5GXrQlNBmYcjmWgJlX7g1MTjDSuzVOCKvWLLa3ATfxXG Fuz9G6fEUBamXbdYpK8OW3B++SFjgWuff0Vk5PN05tjtqcKWs7k9iVyulAxnk2/tls7t PtCCG3oKUQV4ATPxFbmpHS/jMxbgynKrDClhzcPJxKaCWS1K4WL0/jc2oqBzIHH2oKv/ lPyA== 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=ODzUuO9Bo/dCZ/z6T/TQX0tDH/2DhM3+AVV8gLtx3XM=; b=YfQkoFd8MLEAu8NCgjM2uR6tEhzxjin04reWe5+xjXFYkLqyOXSfU3AslFrj4AlS7g YL7WkCKdXJu6FoZGtsgEyfSMVYMKcN8tpGVhpWUB6D0VpQMeG8YJLQ3A0Hn6zlj7PCO1 HHu+pSfnypzAuze7SO4gvcgoI4kXgu2T9AbmRm8IBSIIzRMz7Yj6xF+3v7GIdfR6v9su md2slqj+2vA+efYGpPjU+5rBz3mRukDl+Jn0MFRb4zIoQ5H1b3lM1zcu/qyRXEEtrdDb BVXKNIMMLOJAraK3RxGcwFVjSCiYYggV3SXxwClhgpGx15JB/qUxV9kuqDef87WcLGeD Z6DQ== X-Gm-Message-State: AOAM530cCbsoKK9YxkoE2qjrbSc4rPaWxz879q5NoPQ04tPYPO5wfRah bXtHA9be0ZyshZCvVGi8TSetYE+rBOuoNQ== X-Received: by 2002:a17:90b:38c9:b0:1bf:8668:9399 with SMTP id nn9-20020a17090b38c900b001bf86689399mr15145597pjb.87.1646911657897; Thu, 10 Mar 2022 03:27:37 -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.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Mar 2022 03:27:37 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 10/48] target/nios2: Split control registers away from general registers Date: Thu, 10 Mar 2022 03:26:47 -0800 Message-Id: <20220310112725.570053-11-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::1031 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::1031; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1031.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" Place the control registers into their own array, env->ctrl[]. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/nios2/cpu.h | 43 ++++++++-------- target/nios2/cpu.c | 19 +++---- target/nios2/helper.c | 106 +++++++++++++++++++-------------------- target/nios2/mmu.c | 26 +++++----- target/nios2/op_helper.c | 2 +- target/nios2/translate.c | 35 +++++++------ 6 files changed, 118 insertions(+), 113 deletions(-) diff --git a/target/nios2/cpu.h b/target/nios2/cpu.h index 59e950dae6..1bcbc9ed63 100644 --- a/target/nios2/cpu.h +++ b/target/nios2/cpu.h @@ -59,9 +59,6 @@ struct Nios2CPUClass { #define NUM_GP_REGS 32 #define NUM_CR_REGS 32 -/* GP regs + CR regs */ -#define NUM_CORE_REGS (NUM_GP_REGS + NUM_CR_REGS) - /* General purpose register aliases */ #define R_ZERO 0 #define R_AT 1 @@ -81,8 +78,7 @@ struct Nios2CPUClass { #define R_RA 31 /* Control register aliases */ -#define CR_BASE NUM_GP_REGS -#define CR_STATUS (CR_BASE + 0) +#define CR_STATUS 0 #define CR_STATUS_PIE (1 << 0) #define CR_STATUS_U (1 << 1) #define CR_STATUS_EH (1 << 2) @@ -92,19 +88,19 @@ struct Nios2CPUClass { #define CR_STATUS_PRS (63 << 16) #define CR_STATUS_NMI (1 << 22) #define CR_STATUS_RSIE (1 << 23) -#define CR_ESTATUS (CR_BASE + 1) -#define CR_BSTATUS (CR_BASE + 2) -#define CR_IENABLE (CR_BASE + 3) -#define CR_IPENDING (CR_BASE + 4) -#define CR_CPUID (CR_BASE + 5) -#define CR_CTL6 (CR_BASE + 6) -#define CR_EXCEPTION (CR_BASE + 7) -#define CR_PTEADDR (CR_BASE + 8) +#define CR_ESTATUS 1 +#define CR_BSTATUS 2 +#define CR_IENABLE 3 +#define CR_IPENDING 4 +#define CR_CPUID 5 +#define CR_CTL6 6 +#define CR_EXCEPTION 7 +#define CR_PTEADDR 8 #define CR_PTEADDR_PTBASE_SHIFT 22 #define CR_PTEADDR_PTBASE_MASK (0x3FF << CR_PTEADDR_PTBASE_SHIFT) #define CR_PTEADDR_VPN_SHIFT 2 #define CR_PTEADDR_VPN_MASK (0xFFFFF << CR_PTEADDR_VPN_SHIFT) -#define CR_TLBACC (CR_BASE + 9) +#define CR_TLBACC 9 #define CR_TLBACC_IGN_SHIFT 25 #define CR_TLBACC_IGN_MASK (0x7F << CR_TLBACC_IGN_SHIFT) #define CR_TLBACC_C (1 << 24) @@ -113,7 +109,7 @@ struct Nios2CPUClass { #define CR_TLBACC_X (1 << 21) #define CR_TLBACC_G (1 << 20) #define CR_TLBACC_PFN_MASK 0x000FFFFF -#define CR_TLBMISC (CR_BASE + 10) +#define CR_TLBMISC 10 #define CR_TLBMISC_WAY_SHIFT 20 #define CR_TLBMISC_WAY_MASK (0xF << CR_TLBMISC_WAY_SHIFT) #define CR_TLBMISC_RD (1 << 19) @@ -124,11 +120,11 @@ struct Nios2CPUClass { #define CR_TLBMISC_BAD (1 << 2) #define CR_TLBMISC_PERM (1 << 1) #define CR_TLBMISC_D (1 << 0) -#define CR_ENCINJ (CR_BASE + 11) -#define CR_BADADDR (CR_BASE + 12) -#define CR_CONFIG (CR_BASE + 13) -#define CR_MPUBASE (CR_BASE + 14) -#define CR_MPUACC (CR_BASE + 15) +#define CR_ENCINJ 11 +#define CR_BADADDR 12 +#define CR_CONFIG 13 +#define CR_MPUBASE 14 +#define CR_MPUACC 15 /* Exceptions */ #define EXCP_BREAK 0x1000 @@ -154,7 +150,8 @@ struct Nios2CPUClass { #define CPU_INTERRUPT_NMI CPU_INTERRUPT_TGT_EXT_3 struct CPUArchState { - uint32_t regs[NUM_CORE_REGS]; + uint32_t regs[NUM_GP_REGS]; + uint32_t ctrl[NUM_CR_REGS]; uint32_t pc; #if !defined(CONFIG_USER_ONLY) @@ -212,7 +209,7 @@ void do_nios2_semihosting(CPUNios2State *env); static inline int cpu_mmu_index(CPUNios2State *env, bool ifetch) { - return (env->regs[CR_STATUS] & CR_STATUS_U) ? MMU_USER_IDX : + return (env->ctrl[CR_STATUS] & CR_STATUS_U) ? MMU_USER_IDX : MMU_SUPERVISOR_IDX; } @@ -236,7 +233,7 @@ static inline void cpu_get_tb_cpu_state(CPUNios2State *env, target_ulong *pc, { *pc = env->pc; *cs_base = 0; - *flags = (env->regs[CR_STATUS] & (CR_STATUS_EH | CR_STATUS_U)); + *flags = env->ctrl[CR_STATUS] & (CR_STATUS_EH | CR_STATUS_U); } #endif /* NIOS2_CPU_H */ diff --git a/target/nios2/cpu.c b/target/nios2/cpu.c index 40031c9f20..182ddcc18f 100644 --- a/target/nios2/cpu.c +++ b/target/nios2/cpu.c @@ -53,14 +53,15 @@ static void nios2_cpu_reset(DeviceState *dev) ncc->parent_reset(dev); - memset(env->regs, 0, sizeof(uint32_t) * NUM_CORE_REGS); + memset(env->regs, 0, sizeof(env->regs)); + memset(env->ctrl, 0, sizeof(env->ctrl)); env->pc = cpu->reset_addr; #if defined(CONFIG_USER_ONLY) /* Start in user mode with interrupts enabled. */ - env->regs[CR_STATUS] = CR_STATUS_U | CR_STATUS_PIE; + env->ctrl[CR_STATUS] = CR_STATUS_U | CR_STATUS_PIE; #else - env->regs[CR_STATUS] = 0; + env->ctrl[CR_STATUS] = 0; #endif } @@ -71,9 +72,9 @@ static void nios2_cpu_set_irq(void *opaque, int irq, int level) CPUNios2State *env = &cpu->env; CPUState *cs = CPU(cpu); - env->regs[CR_IPENDING] = deposit32(env->regs[CR_IPENDING], irq, 1, !!level); + env->ctrl[CR_IPENDING] = deposit32(env->ctrl[CR_IPENDING], irq, 1, !!level); - if (env->regs[CR_IPENDING]) { + if (env->ctrl[CR_IPENDING]) { cpu_interrupt(cs, CPU_INTERRUPT_HARD); } else { cpu_reset_interrupt(cs, CPU_INTERRUPT_HARD); @@ -131,8 +132,8 @@ static bool nios2_cpu_exec_interrupt(CPUState *cs, int interrupt_request) CPUNios2State *env = &cpu->env; if ((interrupt_request & CPU_INTERRUPT_HARD) && - (env->regs[CR_STATUS] & CR_STATUS_PIE) && - (env->regs[CR_IPENDING] & env->regs[CR_IENABLE])) { + (env->ctrl[CR_STATUS] & CR_STATUS_PIE) && + (env->ctrl[CR_IPENDING] & env->ctrl[CR_IENABLE])) { cs->exception_index = EXCP_IRQ; nios2_cpu_do_interrupt(cs); return true; @@ -163,7 +164,7 @@ static int nios2_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) } else if (n == 32) { /* PC */ return gdb_get_reg32(mem_buf, env->pc); } else if (n < 49) { /* Status regs */ - return gdb_get_reg32(mem_buf, env->regs[n - 1]); + return gdb_get_reg32(mem_buf, env->ctrl[n - 33]); } /* Invalid regs */ @@ -185,7 +186,7 @@ static int nios2_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) } else if (n == 32) { /* PC */ env->pc = ldl_p(mem_buf); } else if (n < 49) { /* Status regs */ - env->regs[n - 1] = ldl_p(mem_buf); + env->ctrl[n - 33] = ldl_p(mem_buf); } return 4; diff --git a/target/nios2/helper.c b/target/nios2/helper.c index 31cec29e89..90f918524e 100644 --- a/target/nios2/helper.c +++ b/target/nios2/helper.c @@ -56,38 +56,38 @@ void nios2_cpu_do_interrupt(CPUState *cs) switch (cs->exception_index) { case EXCP_IRQ: - assert(env->regs[CR_STATUS] & CR_STATUS_PIE); + assert(env->ctrl[CR_STATUS] & CR_STATUS_PIE); qemu_log_mask(CPU_LOG_INT, "interrupt at pc=%x\n", env->pc); - env->regs[CR_ESTATUS] = env->regs[CR_STATUS]; - env->regs[CR_STATUS] |= CR_STATUS_IH; - env->regs[CR_STATUS] &= ~(CR_STATUS_PIE | CR_STATUS_U); + env->ctrl[CR_ESTATUS] = env->ctrl[CR_STATUS]; + env->ctrl[CR_STATUS] |= CR_STATUS_IH; + env->ctrl[CR_STATUS] &= ~(CR_STATUS_PIE | CR_STATUS_U); - env->regs[CR_EXCEPTION] &= ~(0x1F << 2); - env->regs[CR_EXCEPTION] |= (cs->exception_index & 0x1F) << 2; + env->ctrl[CR_EXCEPTION] &= ~(0x1F << 2); + env->ctrl[CR_EXCEPTION] |= (cs->exception_index & 0x1F) << 2; env->regs[R_EA] = env->pc + 4; env->pc = cpu->exception_addr; break; case EXCP_TLBD: - if ((env->regs[CR_STATUS] & CR_STATUS_EH) == 0) { + if ((env->ctrl[CR_STATUS] & CR_STATUS_EH) == 0) { qemu_log_mask(CPU_LOG_INT, "TLB MISS (fast) at pc=%x\n", env->pc); /* Fast TLB miss */ /* Variation from the spec. Table 3-35 of the cpu reference shows * estatus not being changed for TLB miss but this appears to * be incorrect. */ - env->regs[CR_ESTATUS] = env->regs[CR_STATUS]; - env->regs[CR_STATUS] |= CR_STATUS_EH; - env->regs[CR_STATUS] &= ~(CR_STATUS_PIE | CR_STATUS_U); + env->ctrl[CR_ESTATUS] = env->ctrl[CR_STATUS]; + env->ctrl[CR_STATUS] |= CR_STATUS_EH; + env->ctrl[CR_STATUS] &= ~(CR_STATUS_PIE | CR_STATUS_U); - env->regs[CR_EXCEPTION] &= ~(0x1F << 2); - env->regs[CR_EXCEPTION] |= (cs->exception_index & 0x1F) << 2; + env->ctrl[CR_EXCEPTION] &= ~(0x1F << 2); + env->ctrl[CR_EXCEPTION] |= (cs->exception_index & 0x1F) << 2; - env->regs[CR_TLBMISC] &= ~CR_TLBMISC_DBL; - env->regs[CR_TLBMISC] |= CR_TLBMISC_WR; + env->ctrl[CR_TLBMISC] &= ~CR_TLBMISC_DBL; + env->ctrl[CR_TLBMISC] |= CR_TLBMISC_WR; env->regs[R_EA] = env->pc + 4; env->pc = cpu->fast_tlb_miss_addr; @@ -95,13 +95,13 @@ void nios2_cpu_do_interrupt(CPUState *cs) qemu_log_mask(CPU_LOG_INT, "TLB MISS (double) at pc=%x\n", env->pc); /* Double TLB miss */ - env->regs[CR_STATUS] |= CR_STATUS_EH; - env->regs[CR_STATUS] &= ~(CR_STATUS_PIE | CR_STATUS_U); + env->ctrl[CR_STATUS] |= CR_STATUS_EH; + env->ctrl[CR_STATUS] &= ~(CR_STATUS_PIE | CR_STATUS_U); - env->regs[CR_EXCEPTION] &= ~(0x1F << 2); - env->regs[CR_EXCEPTION] |= (cs->exception_index & 0x1F) << 2; + env->ctrl[CR_EXCEPTION] &= ~(0x1F << 2); + env->ctrl[CR_EXCEPTION] |= (cs->exception_index & 0x1F) << 2; - env->regs[CR_TLBMISC] |= CR_TLBMISC_DBL; + env->ctrl[CR_TLBMISC] |= CR_TLBMISC_DBL; env->pc = cpu->exception_addr; } @@ -112,15 +112,15 @@ void nios2_cpu_do_interrupt(CPUState *cs) case EXCP_TLBX: qemu_log_mask(CPU_LOG_INT, "TLB PERM at pc=%x\n", env->pc); - env->regs[CR_ESTATUS] = env->regs[CR_STATUS]; - env->regs[CR_STATUS] |= CR_STATUS_EH; - env->regs[CR_STATUS] &= ~(CR_STATUS_PIE | CR_STATUS_U); + env->ctrl[CR_ESTATUS] = env->ctrl[CR_STATUS]; + env->ctrl[CR_STATUS] |= CR_STATUS_EH; + env->ctrl[CR_STATUS] &= ~(CR_STATUS_PIE | CR_STATUS_U); - env->regs[CR_EXCEPTION] &= ~(0x1F << 2); - env->regs[CR_EXCEPTION] |= (cs->exception_index & 0x1F) << 2; + env->ctrl[CR_EXCEPTION] &= ~(0x1F << 2); + env->ctrl[CR_EXCEPTION] |= (cs->exception_index & 0x1F) << 2; - if ((env->regs[CR_STATUS] & CR_STATUS_EH) == 0) { - env->regs[CR_TLBMISC] |= CR_TLBMISC_WR; + if ((env->ctrl[CR_STATUS] & CR_STATUS_EH) == 0) { + env->ctrl[CR_TLBMISC] |= CR_TLBMISC_WR; } env->regs[R_EA] = env->pc + 4; @@ -132,16 +132,16 @@ void nios2_cpu_do_interrupt(CPUState *cs) case EXCP_SUPERD: qemu_log_mask(CPU_LOG_INT, "SUPERVISOR exception at pc=%x\n", env->pc); - if ((env->regs[CR_STATUS] & CR_STATUS_EH) == 0) { - env->regs[CR_ESTATUS] = env->regs[CR_STATUS]; + if ((env->ctrl[CR_STATUS] & CR_STATUS_EH) == 0) { + env->ctrl[CR_ESTATUS] = env->ctrl[CR_STATUS]; env->regs[R_EA] = env->pc + 4; } - env->regs[CR_STATUS] |= CR_STATUS_EH; - env->regs[CR_STATUS] &= ~(CR_STATUS_PIE | CR_STATUS_U); + env->ctrl[CR_STATUS] |= CR_STATUS_EH; + env->ctrl[CR_STATUS] &= ~(CR_STATUS_PIE | CR_STATUS_U); - env->regs[CR_EXCEPTION] &= ~(0x1F << 2); - env->regs[CR_EXCEPTION] |= (cs->exception_index & 0x1F) << 2; + env->ctrl[CR_EXCEPTION] &= ~(0x1F << 2); + env->ctrl[CR_EXCEPTION] |= (cs->exception_index & 0x1F) << 2; env->pc = cpu->exception_addr; break; @@ -150,16 +150,16 @@ void nios2_cpu_do_interrupt(CPUState *cs) case EXCP_TRAP: qemu_log_mask(CPU_LOG_INT, "TRAP exception at pc=%x\n", env->pc); - if ((env->regs[CR_STATUS] & CR_STATUS_EH) == 0) { - env->regs[CR_ESTATUS] = env->regs[CR_STATUS]; + if ((env->ctrl[CR_STATUS] & CR_STATUS_EH) == 0) { + env->ctrl[CR_ESTATUS] = env->ctrl[CR_STATUS]; env->regs[R_EA] = env->pc + 4; } - env->regs[CR_STATUS] |= CR_STATUS_EH; - env->regs[CR_STATUS] &= ~(CR_STATUS_PIE | CR_STATUS_U); + env->ctrl[CR_STATUS] |= CR_STATUS_EH; + env->ctrl[CR_STATUS] &= ~(CR_STATUS_PIE | CR_STATUS_U); - env->regs[CR_EXCEPTION] &= ~(0x1F << 2); - env->regs[CR_EXCEPTION] |= (cs->exception_index & 0x1F) << 2; + env->ctrl[CR_EXCEPTION] &= ~(0x1F << 2); + env->ctrl[CR_EXCEPTION] |= (cs->exception_index & 0x1F) << 2; env->pc = cpu->exception_addr; break; @@ -175,16 +175,16 @@ void nios2_cpu_do_interrupt(CPUState *cs) break; } - if ((env->regs[CR_STATUS] & CR_STATUS_EH) == 0) { - env->regs[CR_BSTATUS] = env->regs[CR_STATUS]; + if ((env->ctrl[CR_STATUS] & CR_STATUS_EH) == 0) { + env->ctrl[CR_BSTATUS] = env->ctrl[CR_STATUS]; env->regs[R_BA] = env->pc + 4; } - env->regs[CR_STATUS] |= CR_STATUS_EH; - env->regs[CR_STATUS] &= ~(CR_STATUS_PIE | CR_STATUS_U); + env->ctrl[CR_STATUS] |= CR_STATUS_EH; + env->ctrl[CR_STATUS] &= ~(CR_STATUS_PIE | CR_STATUS_U); - env->regs[CR_EXCEPTION] &= ~(0x1F << 2); - env->regs[CR_EXCEPTION] |= (cs->exception_index & 0x1F) << 2; + env->ctrl[CR_EXCEPTION] &= ~(0x1F << 2); + env->ctrl[CR_EXCEPTION] |= (cs->exception_index & 0x1F) << 2; env->pc = cpu->exception_addr; break; @@ -227,8 +227,8 @@ void nios2_cpu_do_unaligned_access(CPUState *cs, vaddr addr, Nios2CPU *cpu = NIOS2_CPU(cs); CPUNios2State *env = &cpu->env; - env->regs[CR_BADADDR] = addr; - env->regs[CR_EXCEPTION] = EXCP_UNALIGN << 2; + env->ctrl[CR_BADADDR] = addr; + env->ctrl[CR_EXCEPTION] = EXCP_UNALIGN << 2; helper_raise_exception(env, EXCP_UNALIGN); } @@ -266,7 +266,7 @@ bool nios2_cpu_tlb_fill(CPUState *cs, vaddr address, int size, return false; } cs->exception_index = EXCP_SUPERA; - env->regs[CR_BADADDR] = address; + env->ctrl[CR_BADADDR] = address; cpu_loop_exit_restore(cs, retaddr); } } @@ -295,16 +295,16 @@ bool nios2_cpu_tlb_fill(CPUState *cs, vaddr address, int size, } if (access_type == MMU_INST_FETCH) { - env->regs[CR_TLBMISC] &= ~CR_TLBMISC_D; + env->ctrl[CR_TLBMISC] &= ~CR_TLBMISC_D; } else { - env->regs[CR_TLBMISC] |= CR_TLBMISC_D; + env->ctrl[CR_TLBMISC] |= CR_TLBMISC_D; } - env->regs[CR_PTEADDR] &= CR_PTEADDR_PTBASE_MASK; - env->regs[CR_PTEADDR] |= (address >> 10) & CR_PTEADDR_VPN_MASK; - env->mmu.pteaddr_wr = env->regs[CR_PTEADDR]; + env->ctrl[CR_PTEADDR] &= CR_PTEADDR_PTBASE_MASK; + env->ctrl[CR_PTEADDR] |= (address >> 10) & CR_PTEADDR_VPN_MASK; + env->mmu.pteaddr_wr = env->ctrl[CR_PTEADDR]; cs->exception_index = excp; - env->regs[CR_BADADDR] = address; + env->ctrl[CR_BADADDR] = address; cpu_loop_exit_restore(cs, retaddr); } #endif /* !CONFIG_USER_ONLY */ diff --git a/target/nios2/mmu.c b/target/nios2/mmu.c index 4daab2a7ab..95900724e8 100644 --- a/target/nios2/mmu.c +++ b/target/nios2/mmu.c @@ -95,8 +95,8 @@ void helper_mmu_write_tlbacc(CPUNios2State *env, uint32_t v) v & CR_TLBACC_PFN_MASK); /* if tlbmisc.WE == 1 then trigger a TLB write on writes to TLBACC */ - if (env->regs[CR_TLBMISC] & CR_TLBMISC_WR) { - int way = (env->regs[CR_TLBMISC] >> CR_TLBMISC_WAY_SHIFT); + if (env->ctrl[CR_TLBMISC] & CR_TLBMISC_WR) { + int way = (env->ctrl[CR_TLBMISC] >> CR_TLBMISC_WAY_SHIFT); int vpn = (env->mmu.pteaddr_wr & CR_PTEADDR_VPN_MASK) >> 2; int pid = (env->mmu.tlbmisc_wr & CR_TLBMISC_PID_MASK) >> 4; int g = (v & CR_TLBACC_G) ? 1 : 0; @@ -117,8 +117,8 @@ void helper_mmu_write_tlbacc(CPUNios2State *env, uint32_t v) entry->data = newData; } /* Auto-increment tlbmisc.WAY */ - env->regs[CR_TLBMISC] = - (env->regs[CR_TLBMISC] & ~CR_TLBMISC_WAY_MASK) | + env->ctrl[CR_TLBMISC] = + (env->ctrl[CR_TLBMISC] & ~CR_TLBMISC_WAY_MASK) | (((way + 1) & (cpu->tlb_num_ways - 1)) << CR_TLBMISC_WAY_SHIFT); } @@ -153,17 +153,17 @@ void helper_mmu_write_tlbmisc(CPUNios2State *env, uint32_t v) &env->mmu.tlb[(way * cpu->tlb_num_ways) + (vpn & env->mmu.tlb_entry_mask)]; - env->regs[CR_TLBACC] &= CR_TLBACC_IGN_MASK; - env->regs[CR_TLBACC] |= entry->data; - env->regs[CR_TLBACC] |= (entry->tag & (1 << 11)) ? CR_TLBACC_G : 0; - env->regs[CR_TLBMISC] = + env->ctrl[CR_TLBACC] &= CR_TLBACC_IGN_MASK; + env->ctrl[CR_TLBACC] |= entry->data; + env->ctrl[CR_TLBACC] |= (entry->tag & (1 << 11)) ? CR_TLBACC_G : 0; + env->ctrl[CR_TLBMISC] = (v & ~CR_TLBMISC_PID_MASK) | ((entry->tag & ((1 << cpu->pid_num_bits) - 1)) << CR_TLBMISC_PID_SHIFT); - env->regs[CR_PTEADDR] &= ~CR_PTEADDR_VPN_MASK; - env->regs[CR_PTEADDR] |= (entry->tag >> 12) << CR_PTEADDR_VPN_SHIFT; + env->ctrl[CR_PTEADDR] &= ~CR_PTEADDR_VPN_MASK; + env->ctrl[CR_PTEADDR] |= (entry->tag >> 12) << CR_PTEADDR_VPN_SHIFT; } else { - env->regs[CR_TLBMISC] = v; + env->ctrl[CR_TLBMISC] = v; } env->mmu.tlbmisc_wr = v; @@ -175,8 +175,8 @@ void helper_mmu_write_pteaddr(CPUNios2State *env, uint32_t v) (v & CR_PTEADDR_VPN_MASK) >> CR_PTEADDR_VPN_SHIFT); /* Writes to PTEADDR don't change the read-back VPN value */ - env->regs[CR_PTEADDR] = (v & ~CR_PTEADDR_VPN_MASK) | - (env->regs[CR_PTEADDR] & CR_PTEADDR_VPN_MASK); + env->ctrl[CR_PTEADDR] = ((v & ~CR_PTEADDR_VPN_MASK) | + (env->ctrl[CR_PTEADDR] & CR_PTEADDR_VPN_MASK)); env->mmu.pteaddr_wr = v; } diff --git a/target/nios2/op_helper.c b/target/nios2/op_helper.c index ee5ad8b23f..08ed3b4598 100644 --- a/target/nios2/op_helper.c +++ b/target/nios2/op_helper.c @@ -34,7 +34,7 @@ void helper_raise_exception(CPUNios2State *env, uint32_t index) #ifndef CONFIG_USER_ONLY void helper_eret(CPUNios2State *env, uint32_t new_status, uint32_t new_pc) { - env->regs[CR_STATUS] = new_status; + env->ctrl[CR_STATUS] = new_status; env->pc = new_pc; cpu_loop_exit(env_cpu(env)); } diff --git a/target/nios2/translate.c b/target/nios2/translate.c index e6e9a5ac6f..2e486651f5 100644 --- a/target/nios2/translate.c +++ b/target/nios2/translate.c @@ -395,7 +395,7 @@ static void eret(DisasContext *dc, uint32_t code, uint32_t flags) g_assert_not_reached(); #else TCGv tmp = tcg_temp_new(); - tcg_gen_ld_tl(tmp, cpu_env, offsetof(CPUNios2State, regs[CR_ESTATUS])); + tcg_gen_ld_tl(tmp, cpu_env, offsetof(CPUNios2State, ctrl[CR_ESTATUS])); gen_helper_eret(cpu_env, tmp, cpu_R[R_EA]); tcg_temp_free(tmp); @@ -425,7 +425,7 @@ static void bret(DisasContext *dc, uint32_t code, uint32_t flags) g_assert_not_reached(); #else TCGv tmp = tcg_temp_new(); - tcg_gen_ld_tl(tmp, cpu_env, offsetof(CPUNios2State, regs[CR_BSTATUS])); + tcg_gen_ld_tl(tmp, cpu_env, offsetof(CPUNios2State, ctrl[CR_BSTATUS])); gen_helper_eret(cpu_env, tmp, cpu_R[R_BA]); tcg_temp_free(tmp); @@ -481,7 +481,7 @@ static void rdctl(DisasContext *dc, uint32_t code, uint32_t flags) return; } - switch (instr.imm5 + CR_BASE) { + switch (instr.imm5) { case CR_IPENDING: /* * The value of the ipending register is synthetic. @@ -493,17 +493,15 @@ static void rdctl(DisasContext *dc, uint32_t code, uint32_t flags) */ t1 = tcg_temp_new(); t2 = tcg_temp_new(); - tcg_gen_ld_tl(t1, cpu_env, - offsetof(CPUNios2State, regs[CR_IPENDING])); - tcg_gen_ld_tl(t2, cpu_env, - offsetof(CPUNios2State, regs[CR_IENABLE])); + tcg_gen_ld_tl(t1, cpu_env, offsetof(CPUNios2State, ctrl[CR_IPENDING])); + tcg_gen_ld_tl(t2, cpu_env, offsetof(CPUNios2State, ctrl[CR_IENABLE])); tcg_gen_and_tl(cpu_R[instr.c], t1, t2); tcg_temp_free(t1); tcg_temp_free(t2); break; default: tcg_gen_ld_tl(cpu_R[instr.c], cpu_env, - offsetof(CPUNios2State, regs[instr.imm5 + CR_BASE])); + offsetof(CPUNios2State, ctrl[instr.imm5])); break; } } @@ -521,7 +519,7 @@ static void wrctl(DisasContext *dc, uint32_t code, uint32_t flags) R_TYPE(instr, code); TCGv v = load_gpr(dc, instr.a); - switch (instr.imm5 + CR_BASE) { + switch (instr.imm5) { case CR_PTEADDR: gen_helper_mmu_write_pteaddr(cpu_env, v); break; @@ -541,7 +539,7 @@ static void wrctl(DisasContext *dc, uint32_t code, uint32_t flags) /* fall through */ default: tcg_gen_st_tl(v, cpu_env, - offsetof(CPUNios2State, regs[instr.imm5 + CR_BASE])); + offsetof(CPUNios2State, ctrl[instr.imm5])); break; } #endif @@ -774,7 +772,7 @@ illegal_op: t_gen_helper_raise_exception(dc, EXCP_ILLEGAL); } -static const char * const regnames[NUM_CORE_REGS] = { +static const char * const gr_regnames[NUM_GP_REGS] = { "zero", "at", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", @@ -783,6 +781,9 @@ static const char * const regnames[NUM_CORE_REGS] = { "r20", "r21", "r22", "r23", "et", "bt", "gp", "sp", "fp", "ea", "ba", "ra", +}; + +static const char * const cr_regnames[NUM_CR_REGS] = { "status", "estatus", "bstatus", "ienable", "ipending", "cpuid", "reserved0", "exception", "pteaddr", "tlbacc", "tlbmisc", "reserved1", @@ -909,8 +910,14 @@ void nios2_cpu_dump_state(CPUState *cs, FILE *f, int flags) qemu_fprintf(f, "IN: PC=%x %s\n", env->pc, lookup_symbol(env->pc)); - for (i = 0; i < NUM_CORE_REGS; i++) { - qemu_fprintf(f, "%9s=%8.8x ", regnames[i], env->regs[i]); + for (i = 0; i < NUM_GP_REGS; i++) { + qemu_fprintf(f, "%9s=%8.8x ", gr_regnames[i], env->regs[i]); + if ((i + 1) % 4 == 0) { + qemu_fprintf(f, "\n"); + } + } + for (i = 0; i < NUM_CR_REGS; i++) { + qemu_fprintf(f, "%9s=%8.8x ", cr_regnames[i], env->ctrl[i]); if ((i + 1) % 4 == 0) { qemu_fprintf(f, "\n"); } @@ -931,7 +938,7 @@ void nios2_tcg_init(void) for (i = 0; i < NUM_GP_REGS; i++) { cpu_R[i] = tcg_global_mem_new(cpu_env, offsetof(CPUNios2State, regs[i]), - regnames[i]); + gr_regnames[i]); } cpu_pc = tcg_global_mem_new(cpu_env, offsetof(CPUNios2State, pc), "pc"); From patchwork Thu Mar 10 11:26: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: 550095 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp908772mag; Thu, 10 Mar 2022 03:42:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJy+c5VKCNZ16Bd/pNdDdsscf3x7DwjGbRfBhj2Vy6YhhxzDBdiMlme9IMsuXLXXDFrvKz1U X-Received: by 2002:a25:3bcf:0:b0:628:c396:67c7 with SMTP id i198-20020a253bcf000000b00628c39667c7mr3495669yba.46.1646912541527; Thu, 10 Mar 2022 03:42:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646912541; cv=none; d=google.com; s=arc-20160816; b=JwUilxcFWTiCnkRtcwJQDof1id/1igi3MsNzGn/IrJxPIZ+6LyTdGHabDAe8nEWJs/ RZq7VtGqCZ/mcDLK5RdXp82DGdHx8WVXiCjdfLBBKOq/0VIlgqlgC7SHQReoaHpfrCVN smZNw6D83HTINv/8KEDl+OGueD13kdfdWx93DV3eZZz+uhyT+k4nV6otWuuSg/tmrn/p JJill9pu4vFZ4f49twsmk4+v7Elp8vD1L+iNWH0rgvyHFRVSjyJ3PZB8HbTYEr13R58w C4xOuM6v5x/ZqO2YRRt55IklFyXyjQwNOAs/hfeLPp+jyzW19hDnvPpRvfrLk94IeOfE b5DA== 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=FucOuRxzk9AY38GO4hr3Q5xePPb7ussh8W5FYQ6tFWc=; b=LN9DF+Rp3XPHjt+X+Bm4mZ38zQIfLbSjKX6gWwH225oIRD/SHHNEsCMjK5AmRLsZka SuQzCtTZ0LbL+mEsuINJGf8gq2sjEOS5lKGX+VrgSswhx/YKlidSlpbnD1+hbqGNODsS nP6QWKBxQu0kK0LLRzTrhbQsroLsI8uAgM90wf5z/PzqP/pn5ymh3WVYalujhjJbLnEx DCr7ZDxAljKVPmGsPVnabkgJDBElBHLyeqILt4nvvccl5XZ7/D58HuV/guGZanvK0xhG JG6kzYnxCvRDiIBrd+iY76zwhJhMhrim2D5YQBkyMvUSZaU5o0jo2ORjUdgBMW/LWqcg hRgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=zxPuKA7H; 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 z30-20020a25a121000000b0062487d43b06si2947557ybh.212.2022.03.10.03.42.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Mar 2022 03:42:21 -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=zxPuKA7H; 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]:54768 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSHBU-0005lm-Dh for patch@linaro.org; Thu, 10 Mar 2022 06:42:21 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50680) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSGxJ-0005E6-Qd for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:27:41 -0500 Received: from [2607:f8b0:4864:20::434] (port=45825 helo=mail-pf1-x434.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nSGxI-0007wj-BT for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:27:41 -0500 Received: by mail-pf1-x434.google.com with SMTP id s8so4819018pfk.12 for ; Thu, 10 Mar 2022 03:27:39 -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=FucOuRxzk9AY38GO4hr3Q5xePPb7ussh8W5FYQ6tFWc=; b=zxPuKA7Hj06xHJ9eBovLJbCbsSSPPteW3CWWNEGxJ1MFPYRQ15Up0u0mCBdHZHGvtO DciqIydZWgrmWTGcihDoJchF1tcbSqvo1dIivGv0lUIWOgRVYMdKnRVlNdAerCi34J9G tsak0K0J7G4FWSONXN2c0NwGsINxFyoOVK1MOk2EFYWWyOmVCBcEMBfxAENo6K/lB/to GlWI0YQUT/YDAO9oOiPvAvC+6ok+9z0xXUQxdUK2spQB1lJa2fAf8cMBA3QinF4rpkAr g1ZKhW0UtEYJNxzOIXvVg0YPe+5iAbkOWnsdBb1KByLHTqDDH607YwabpdbGEdXCfcT0 MO+Q== 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=FucOuRxzk9AY38GO4hr3Q5xePPb7ussh8W5FYQ6tFWc=; b=gTWKYaUS4cRWwRrPCtSQvNr+Cq9jg3FV8wQxmGnoDXe4rcRlY7I+akKzo3cQPp6VnI NRnbiMGJb48B4tXLd5JeKU2FhshueyOMTk/kbYqRuAoj7yAseuDmzfF0vPS5vVArDebW d2AeMxObrwH26gQggsvBXE6kcWsQx2wANebkL41oprfhNDaG+yKdpvL68LLgn43TNr0/ ye5p6jph9cj6l4GTX/i58J0gkUbyku2V57uMk/DI7OrJONIOpqaIpuY19FQLeXNW/M76 +ldz4yz0FFYyJPO2IVcymo6RPl+tS7ogiez9MVZMNO6jH5MU7snp9kKjezT3xKafbSfd 4+lQ== X-Gm-Message-State: AOAM5318OI6SF9bjnv105NzXsphI8e6EqG+D02aFORobqC/RODzXMBFe X6D6nf/8GZePg1BZCC8x53zxlwVPMQPZ6g== X-Received: by 2002:a63:34c1:0:b0:380:c330:64c6 with SMTP id b184-20020a6334c1000000b00380c33064c6mr3700460pga.442.1646911659089; Thu, 10 Mar 2022 03:27:39 -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.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Mar 2022 03:27:38 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 11/48] target/nios2: Do not zero the general registers on reset Date: Thu, 10 Mar 2022 03:26:48 -0800 Message-Id: <20220310112725.570053-12-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::434 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::434; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x434.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" The bulk of the general register set is undefined on reset. The zero register is for the most part special-cased in translate, but the slot is still exposed to gdbstub and nios2_cpu_dump_state, so continue to make sure that's zeroed. Signed-off-by: Richard Henderson --- target/nios2/cpu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/target/nios2/cpu.c b/target/nios2/cpu.c index 182ddcc18f..97bdc0a61b 100644 --- a/target/nios2/cpu.c +++ b/target/nios2/cpu.c @@ -53,16 +53,16 @@ static void nios2_cpu_reset(DeviceState *dev) ncc->parent_reset(dev); - memset(env->regs, 0, sizeof(env->regs)); memset(env->ctrl, 0, sizeof(env->ctrl)); - env->pc = cpu->reset_addr; - #if defined(CONFIG_USER_ONLY) /* Start in user mode with interrupts enabled. */ env->ctrl[CR_STATUS] = CR_STATUS_U | CR_STATUS_PIE; #else env->ctrl[CR_STATUS] = 0; #endif + + env->regs[R_ZERO] = 0; + env->pc = cpu->reset_addr; } #ifndef CONFIG_USER_ONLY From patchwork Thu Mar 10 11:26: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: 550098 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp910791mag; Thu, 10 Mar 2022 03:45:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJy77DV7xo8D8jVIMs3krHLit66NnSvItpt/JNeYVzc7apl1kO9+XwJ7wVdCmJY94XZPdSZ3 X-Received: by 2002:a25:d181:0:b0:629:1919:d8e5 with SMTP id i123-20020a25d181000000b006291919d8e5mr3421749ybg.85.1646912739175; Thu, 10 Mar 2022 03:45:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646912739; cv=none; d=google.com; s=arc-20160816; b=eg4jk/0U4ny0RUA/ROFW7tRewBzv8uon4a34bZm7pHug+Auz9VJcN/mgX4kRpHgbmY DQDwmmR4BLWp2dwwO92KJNoWtp52csFAcEMTFHkNTOgAGO/trqPqwZFKPaAAPaM7DVel x9/ogrBiJYrTMJWL2zhifAb9Mh4ZYQ0g0BaAsSYiNZ5BODRwUpS3qYs4VCH+cH4AOqh1 IqJOVIgbdgHsiViQ0y/JOXs+cSo2EWMQy/AfVCO3cpFU+r+vtkTXxr0e2OLCqg7KJ/Li cBqSgjoUZdWoju/I/Ukb75AOtX8Y5ZqZxg7cNcX6fpVYj5D4RfboR/zWGPDrc416hoUu pD1Q== 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=NO5qDCidg6tXT/kBs+ctrp9mOI+zlSE5VUcpn5RQSbI=; b=RWAtoo0jrxswqPvO+i6jCxYlh7h7J7xBoXbGT876cqkM/l7IbjnYYaIquoN9P5ls5v Y/3325HNxsMWF6+/hnbaY9IiC+lzJj6VxktqXl2Hx+46wwinRIIioKQO1myn4ZWzWWvh IfVIoA8EGp+qTlc1dSfrkpD4VHdT4kfKZGx0Hdw/tixF0jQQeC7f4H0GLQno/ZoojfPZ AJkEBEgJPWfj5U6PaVra1YLaabKixrjqXORuFhTWWCLv78KFhmXGuOW6cB96bjgmv6RV hJ6MuHuK+sFBQ7U9gnyTtftRjSQKnSsryz+0/t4VXWlkpAOt90f4+/9oXklKxc0/LaWD pYJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Mq0oxVi4; 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 c203-20020a251cd4000000b006246c88a1adsi2960695ybc.399.2022.03.10.03.45.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Mar 2022 03:45:39 -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=Mq0oxVi4; 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]:35078 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSHEg-00031W-My for patch@linaro.org; Thu, 10 Mar 2022 06:45:38 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50696) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSGxK-0005Ge-Q5 for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:27:42 -0500 Received: from [2607:f8b0:4864:20::102b] (port=35645 helo=mail-pj1-x102b.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nSGxJ-0007wr-7t for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:27:42 -0500 Received: by mail-pj1-x102b.google.com with SMTP id mg21-20020a17090b371500b001bef9e4657cso8015301pjb.0 for ; Thu, 10 Mar 2022 03:27:40 -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=NO5qDCidg6tXT/kBs+ctrp9mOI+zlSE5VUcpn5RQSbI=; b=Mq0oxVi4HUaSZ9l0SxP5Z2LoFJrv2mz+s/HxKiAVEp/qeJo93dDTlWsohwcdFsZe4W rzybK2xVNehIfg3GyhEjNQBhmY3vUrvV8NskGfvI8EznR0iFSB7CeEonGkrI+8W2+sZa Sy2WskG3gl44gi9fXvsolAieLNWPAZaHSH+W2stOZkIZPhQuDrFajUXgXFR94348kbZN 5OnTOqhH236pASucXt12FNnq7hAkE34S8p8PqdYYbOE6TY88o/wjqSQfoh7acQRBo7tF /awe3sb9g1oIeMBXsI+lf5/9eJ5x01ai7Bi3mb2zWC0z3Fn2Ur2FR2OOhhP++Y/v1JIw l5Uw== 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=NO5qDCidg6tXT/kBs+ctrp9mOI+zlSE5VUcpn5RQSbI=; b=zyib/qOz2JwjhzWos8WwMTa/Uk1f1VTrCKVFj91EYBsWio9767iTmtMpb85mBZxNJ/ rQovL6Yjg+B5zUCwPLKyczyrSnMYcCjrIL3xZkAsVVbknut7itWQxTds+ZyhyA+86agL umRUdisw+lZmUKCudGY3Tsz0A53Rd0v/ASvDqyV0xSsGVk/rWCZ/n+6ToJZ2I4U6R7jp pf4jExfRamh5wOPpwRON49WzObxbdmUb+NcfrS6XS+QLR4Dt2zTybsDpV88pYwYbXhA+ mm1PXMIP2lO64N4eFaQbQyapYX8wuHYGtMC07lsK5+iqpC9JZYRmQoCVDkKvk1L6FMde 1qrg== X-Gm-Message-State: AOAM530SKVIA8PjyoDmhSzW3pJxwzBpni6ffF1rUlkFKU0ywczAx7/hT gIqqjntawZH4HvIPrqFpKnvjzwhBIkpgMQ== X-Received: by 2002:a17:902:ab4c:b0:151:eb86:dcb5 with SMTP id ij12-20020a170902ab4c00b00151eb86dcb5mr4470962plb.126.1646911659982; Thu, 10 Mar 2022 03:27:39 -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.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Mar 2022 03:27:39 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 12/48] target/nios2: Clean up nios2_cpu_dump_state Date: Thu, 10 Mar 2022 03:26:49 -0800 Message-Id: <20220310112725.570053-13-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::102b (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::102b; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102b.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" Do not print control registers for user-only mode. Rename reserved control registers to "resN", where N is the control register index. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/nios2/translate.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/target/nios2/translate.c b/target/nios2/translate.c index 2e486651f5..45fe2f9a05 100644 --- a/target/nios2/translate.c +++ b/target/nios2/translate.c @@ -783,16 +783,18 @@ static const char * const gr_regnames[NUM_GP_REGS] = { "fp", "ea", "ba", "ra", }; +#ifndef CONFIG_USER_ONLY static const char * const cr_regnames[NUM_CR_REGS] = { "status", "estatus", "bstatus", "ienable", - "ipending", "cpuid", "reserved0", "exception", + "ipending", "cpuid", "res6", "exception", "pteaddr", "tlbacc", "tlbmisc", "reserved1", "badaddr", "config", "mpubase", "mpuacc", - "reserved2", "reserved3", "reserved4", "reserved5", - "reserved6", "reserved7", "reserved8", "reserved9", - "reserved10", "reserved11", "reserved12", "reserved13", - "reserved14", "reserved15", "reserved16", "reserved17", + "res16", "res17", "res18", "res19", + "res20", "res21", "res22", "res23", + "res24", "res25", "res26", "res27", + "res28", "res29", "res30", "res31", }; +#endif #include "exec/gen-icount.h" @@ -904,10 +906,6 @@ void nios2_cpu_dump_state(CPUState *cs, FILE *f, int flags) CPUNios2State *env = &cpu->env; int i; - if (!env) { - return; - } - qemu_fprintf(f, "IN: PC=%x %s\n", env->pc, lookup_symbol(env->pc)); for (i = 0; i < NUM_GP_REGS; i++) { @@ -916,13 +914,14 @@ void nios2_cpu_dump_state(CPUState *cs, FILE *f, int flags) qemu_fprintf(f, "\n"); } } + +#if !defined(CONFIG_USER_ONLY) for (i = 0; i < NUM_CR_REGS; i++) { qemu_fprintf(f, "%9s=%8.8x ", cr_regnames[i], env->ctrl[i]); if ((i + 1) % 4 == 0) { qemu_fprintf(f, "\n"); } } -#if !defined(CONFIG_USER_ONLY) qemu_fprintf(f, " mmu write: VPN=%05X PID %02X TLBACC %08X\n", env->mmu.pteaddr_wr & CR_PTEADDR_VPN_MASK, (env->mmu.tlbmisc_wr & CR_TLBMISC_PID_MASK) >> 4, From patchwork Thu Mar 10 11:26: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: 550100 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp913298mag; Thu, 10 Mar 2022 03:48:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJxTH8r7tDuBvuRtNv9rygbX/P/4Sv+0XNanGHvnIbyPPs/uQJDXEEdTtIvYVe1QvFIY85dV X-Received: by 2002:a81:4958:0:b0:2dc:62b7:8629 with SMTP id w85-20020a814958000000b002dc62b78629mr3534966ywa.48.1646912931379; Thu, 10 Mar 2022 03:48:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646912931; cv=none; d=google.com; s=arc-20160816; b=hNrRtZj8gPOA9wtu/WjujRMF7tBd+Y08Pp/qSneyXB55mx9yEtdQrJdFYd9MeUDNS8 0X8NdwZwfI6SvD9SBO8Cp4mV20bOAXTMJzqHqzsEfuqBlX7kfk6u3a5mcHIpb5n05hit VPOGxMf1wRuOtTt4+k1rjNDj5dxBTp//47s9qtkEnonAOOnsonBSCE7z3dyNGtHl6J2n CNzzJqgm1CY/zSsRLE+3GZN5wwRqjhKAJbdUhWXANdM3bvxv/N5r1dH9lbpPuAl44NAj ZYezI8QaIMaWifc3Th+OooJPYobqoQFjsKzw4EkG7y7+Q+hpwo5qdgroSJZHOD3v67AD Df2w== 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=Gt6Df7YFZj3yIOaHOAXNxeneFRB5t2HH9HYYGKeZPd8=; b=tC9JdZ+dCrKR3eBFCzzBddlrNVcXUjeN4iWSapCV8+wntXZGnig7umSwNz/4QTUduq HLLy/5D97azuRBRMqsMScw8QrQ9uZpvJKnNHm+iKuhfIk6CGeiziTEVOl9zSdFjsbLt1 iUl8u15cSfBtlCIBUQvavT/BsJNTD6ermYnq9LZT8Zc0TFAsKwNQV3jzRxL3WGuFOQAe XQRWy868hruxqSo3jHS88ntXBA74lJIa1abZ4KWSDqAEard2MMAXEO2d6p6SvHYgbdtd Rqq8WuwakZKJVlKfZh8kn1It2DKh9eYctT5huDf7APJ8KU0jqPUn+ngzAXa+LMD2Kp8Q U9dA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=AQQXji4r; 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 n5-20020a81c805000000b002d6464c229bsi2974172ywi.3.2022.03.10.03.48.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Mar 2022 03:48:51 -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=AQQXji4r; 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]:42920 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSHHm-0008Vp-Tr for patch@linaro.org; Thu, 10 Mar 2022 06:48:50 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50712) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSGxL-0005K0-T2 for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:27:43 -0500 Received: from [2607:f8b0:4864:20::1034] (port=50878 helo=mail-pj1-x1034.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nSGxK-0007x0-Cw for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:27:43 -0500 Received: by mail-pj1-x1034.google.com with SMTP id m22so5002437pja.0 for ; Thu, 10 Mar 2022 03:27:41 -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=Gt6Df7YFZj3yIOaHOAXNxeneFRB5t2HH9HYYGKeZPd8=; b=AQQXji4rnhgAAQr38u97QZIOMNlTdasBbQ7aHHiB8yScDZKedi6AtTrbId/+2BcOCO dN5wqSTiaIBg8UMqHOCHu5CKdm0JDCd1R4IC4v6mGaJdc77XQP2JLJ4yTBbRfHUwvNYt C/Fwc9cY9atZVRMlq7DgpRsJZmn78YUbSI/p5uQ6AG7InqVG3/6kZm78TjCYR7O/tF6Z 87ZqLw9rwQ18H2vRNSJ8K52hrsTiuL+J/c6gnnsgX6frGiTodXbLZLMwzpAeBYxvNNNc p7HjteW6o52zyO1dJB2mxkktP2yen9yAfjtF4zI7kvQVU52agMo+441sWsj3nfeFyTvt UlFA== 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=Gt6Df7YFZj3yIOaHOAXNxeneFRB5t2HH9HYYGKeZPd8=; b=pgug3/BGsuh63Wn6NI/HUF5axexjTQ6mz0IRwB84pSK0p1XDtvM6CA6fhP9Y/nMrxq HegeFRbgxu2BbP9gcE2oNkEscPJ/gLcXJzeqbfmLiFm8HZqKoOQtA+tEKd+x9/ox6PC7 EOh8b05LBp+Gx6P9vwoQBCZCHI81Nl4Aztdv4gq85LJaLd3Jk3RZf5CkHTCGDabPlz52 FVJfMhXBXOWrr7oBDE8nltuFrAFdyQDSW3zS/C0ete7sT4zRZ1aMhUKa3AnjdzXMGEQT vQha4ENLBLeTJKkVptaEqDmkK7E6P7GOQfMgYW1UWWPrsoVYKrSuwn3PweeeYOTs9koB 5bwQ== X-Gm-Message-State: AOAM532zdCBnLr2eYTxEwnNFZU8qkWGs+0hJlDlHhcNnEynQBAbGlswl l9p5IJhei/+dkPJoUlv9QYvKt4sQ1zXfZA== X-Received: by 2002:a17:90b:4a07:b0:1bf:b159:185 with SMTP id kk7-20020a17090b4a0700b001bfb1590185mr4537730pjb.65.1646911661058; Thu, 10 Mar 2022 03:27:41 -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.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Mar 2022 03:27:40 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 13/48] target/nios2: Use hw/registerfields.h for CR_STATUS fields Date: Thu, 10 Mar 2022 03:26:50 -0800 Message-Id: <20220310112725.570053-14-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::1034 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::1034; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1034.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" Add all fields; retain the helper macros for single bit fields. So far there are no uses of the multi-bit status fields. Signed-off-by: Richard Henderson --- target/nios2/cpu.h | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/target/nios2/cpu.h b/target/nios2/cpu.h index 1bcbc9ed63..ecf8cc929f 100644 --- a/target/nios2/cpu.h +++ b/target/nios2/cpu.h @@ -23,6 +23,7 @@ #include "exec/cpu-defs.h" #include "hw/core/cpu.h" +#include "hw/registerfields.h" #include "qom/object.h" typedef struct CPUArchState CPUNios2State; @@ -79,15 +80,24 @@ struct Nios2CPUClass { /* Control register aliases */ #define CR_STATUS 0 -#define CR_STATUS_PIE (1 << 0) -#define CR_STATUS_U (1 << 1) -#define CR_STATUS_EH (1 << 2) -#define CR_STATUS_IH (1 << 3) -#define CR_STATUS_IL (63 << 4) -#define CR_STATUS_CRS (63 << 10) -#define CR_STATUS_PRS (63 << 16) -#define CR_STATUS_NMI (1 << 22) -#define CR_STATUS_RSIE (1 << 23) + +FIELD(CR_STATUS, PIE, 0, 1) +FIELD(CR_STATUS, U, 1, 1) +FIELD(CR_STATUS, EH, 2, 1) +FIELD(CR_STATUS, IH, 3, 1) +FIELD(CR_STATUS, IL, 4, 6) +FIELD(CR_STATUS, CRS, 10, 6) +FIELD(CR_STATUS, PRS, 16, 6) +FIELD(CR_STATUS, NMI, 22, 1) +FIELD(CR_STATUS, RSIE, 23, 1) + +#define CR_STATUS_PIE R_CR_STATUS_PIE_MASK +#define CR_STATUS_U R_CR_STATUS_U_MASK +#define CR_STATUS_EH R_CR_STATUS_EH_MASK +#define CR_STATUS_IH R_CR_STATUS_IH_MASK +#define CR_STATUS_NMI R_CR_STATUS_NMI_MASK +#define CR_STATUS_RSIE R_CR_STATUS_RSIE_MASK + #define CR_ESTATUS 1 #define CR_BSTATUS 2 #define CR_IENABLE 3 From patchwork Thu Mar 10 11:26:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 550101 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp913340mag; Thu, 10 Mar 2022 03:48:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJwgXaZFaIyxGC/XuOtlWCRtXz4R1u3MFqSGdXq6kGJn244ZiUidhiWeB+exI0K3KOz0KgTe X-Received: by 2002:a81:244a:0:b0:2d6:954a:5d0e with SMTP id k71-20020a81244a000000b002d6954a5d0emr3617678ywk.56.1646912936426; Thu, 10 Mar 2022 03:48:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646912936; cv=none; d=google.com; s=arc-20160816; b=U6B7nEWrVe7XCWlMh7rHYBVY9cOhNjTwIZQHLZy/u2RHrpfV1fZsEfgSK8Bcx2kD4J rNZ9XpAZFAhdLbjaOe1h2tp7wkTOjV/O4fnR32xnJDjlnT27rMezgo7p5wz6k4fH8hfe tCwT8L84oQMXm4Vj1lMGGVdxWeD41nEZKCv76J6dKbEpblfUKGI2AELrP5IQSy6cD1hP LQyuKeSiASCdoq1NxhFvTqzFeXVnevX6F7KK5RSBgCnGOV7P6AUdIirUneft+cYhDX8o cNZX0NnQpFO8hmtHGpmNgUbrr9QCyIBMy4gghm1HI6BHwFDhAVua4sQMGMjs9tIgVyu4 yMVg== 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=8buwJrjtMj1NFA6rdKhvKicQJO4j8m6F/Eaj8v2A0XQ=; b=CWjsRRTbmEFqW0aSClTLggTedQxnbGbpyBO8HLac9nF67+4IzuapMQX0D9workGJXp WnBaYWTsLDlnocGtuazhTcVynz+rTBByJivwjT8nIXN/CqkYOh7PQ8AoIRyb7PNhdTpK cm+fYpAf24YIxJWD3hRB9J3uTgs5FIFX4AMI3EVPs6aUwSglNxQ+T2TUqUItJRsNB1bu dUkstEqKvE6luP5NEnVMFshjTdrz5HSd79md8zkStufntdT28QyRXkZqVWw7SwuFShZ4 s1o+cwArNKgBLm4HUdcvEjn3MqzqePd+AsywWbr7a+QyS2p2u7HxT8HhuLR0ILFkrfUN EWFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=rpeX2oFd; 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 bu15-20020a056902090f00b00623f52a510fsi2706078ybb.684.2022.03.10.03.48.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Mar 2022 03:48:56 -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=rpeX2oFd; 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]:43438 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSHHr-0000Qx-Sr for patch@linaro.org; Thu, 10 Mar 2022 06:48:55 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50734) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSGxN-0005Mt-9u for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:27:45 -0500 Received: from [2607:f8b0:4864:20::102a] (port=37402 helo=mail-pj1-x102a.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nSGxL-0007xG-DO for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:27:44 -0500 Received: by mail-pj1-x102a.google.com with SMTP id lj8-20020a17090b344800b001bfaa46bca3so4845809pjb.2 for ; Thu, 10 Mar 2022 03:27:43 -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=8buwJrjtMj1NFA6rdKhvKicQJO4j8m6F/Eaj8v2A0XQ=; b=rpeX2oFdmtOBiqvjxZnpGTTd+MUcOTawUQr2eSvq47qEy3yJlu5klzqVEO4eMSd5e1 uLw8Vb7chgDYw720chxwBgBM9r12CqT6a8EHnqx8xpe5YjFdqpQrosM53mpbErKC3V6I /Ol/zZb4dytC4ap7ssx8jRIX9PpFjNHZtWt6LfrChRh+W2KSLuI9zKRPq4gv4xRTqAws DGLhlts9pfB/FrRxJ78aqcI6MqAjceyiV8iVJJRZ+b9Y/PvrkBZUce7Lqs4l6NVOL981 3kwOs4exPQffmvgC1YYpzTWVafTjxcX0G43GrrUhA27rnzWhvmvrV6Batw/l7/kkBP57 24tg== 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=8buwJrjtMj1NFA6rdKhvKicQJO4j8m6F/Eaj8v2A0XQ=; b=guXNtGAmMUg6qI50sEkLx1ewsb9EjRYAN6C2MVR8I8v/aYpPPXZI2PN+iC9tb+Xs5z c3Q6rKIXe9Ba7zoQK+l0EWhZEUZ9JbHzsIEuJbYKY8f9nrg6+ZViJ1orP3jB1Dtg2Qut WIkCKSkuf/onF9g9dl4VJsBZThzq+lAPOsQyz/usJTEDHh9G/x1437CbLCaTSkfDzvw8 PoYsZL4qtloRQp0xBhGdWPo2DDt6q4BgtN4URy4QYz0aIv6sJP/ZmTBKUZDiaguUSkWW BmG0WT0I10aLl/Zgf5b10l0+c5vD/HemB7EHO/ZARtaJDebFUNaNItfVvLYkxHvRo8Z0 VsDA== X-Gm-Message-State: AOAM531ThWEdOsUoFRnyvpYjg6p9oOntWnHVJ0ix5IIxjL4j6z8Sadth E/yyZOWv+p2Vk1mrNW/E3k2ZB9DViuN01Q== X-Received: by 2002:a17:902:cec7:b0:151:bb1b:5c9d with SMTP id d7-20020a170902cec700b00151bb1b5c9dmr4535242plg.41.1646911662081; Thu, 10 Mar 2022 03:27:42 -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.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Mar 2022 03:27:41 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 14/48] target/nios2: Use hw/registerfields.h for CR_EXCEPTION fields Date: Thu, 10 Mar 2022 03:26:51 -0800 Message-Id: <20220310112725.570053-15-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::102a (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::102a; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102a.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" Use FIELD_DP32 instead of manual shifting and masking. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- target/nios2/cpu.h | 4 ++++ target/nios2/helper.c | 37 ++++++++++++++++++++++--------------- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/target/nios2/cpu.h b/target/nios2/cpu.h index ecf8cc929f..963cdec161 100644 --- a/target/nios2/cpu.h +++ b/target/nios2/cpu.h @@ -105,6 +105,10 @@ FIELD(CR_STATUS, RSIE, 23, 1) #define CR_CPUID 5 #define CR_CTL6 6 #define CR_EXCEPTION 7 + +FIELD(CR_EXCEPTION, CAUSE, 2, 5) +FIELD(CR_EXCEPTION, ECCFTL, 31, 1) + #define CR_PTEADDR 8 #define CR_PTEADDR_PTBASE_SHIFT 22 #define CR_PTEADDR_PTBASE_MASK (0x3FF << CR_PTEADDR_PTBASE_SHIFT) diff --git a/target/nios2/helper.c b/target/nios2/helper.c index 90f918524e..54458a5447 100644 --- a/target/nios2/helper.c +++ b/target/nios2/helper.c @@ -64,8 +64,9 @@ void nios2_cpu_do_interrupt(CPUState *cs) env->ctrl[CR_STATUS] |= CR_STATUS_IH; env->ctrl[CR_STATUS] &= ~(CR_STATUS_PIE | CR_STATUS_U); - env->ctrl[CR_EXCEPTION] &= ~(0x1F << 2); - env->ctrl[CR_EXCEPTION] |= (cs->exception_index & 0x1F) << 2; + env->ctrl[CR_EXCEPTION] = FIELD_DP32(env->ctrl[CR_EXCEPTION], + CR_EXCEPTION, CAUSE, + cs->exception_index); env->regs[R_EA] = env->pc + 4; env->pc = cpu->exception_addr; @@ -83,8 +84,9 @@ void nios2_cpu_do_interrupt(CPUState *cs) env->ctrl[CR_STATUS] |= CR_STATUS_EH; env->ctrl[CR_STATUS] &= ~(CR_STATUS_PIE | CR_STATUS_U); - env->ctrl[CR_EXCEPTION] &= ~(0x1F << 2); - env->ctrl[CR_EXCEPTION] |= (cs->exception_index & 0x1F) << 2; + env->ctrl[CR_EXCEPTION] = FIELD_DP32(env->ctrl[CR_EXCEPTION], + CR_EXCEPTION, CAUSE, + cs->exception_index); env->ctrl[CR_TLBMISC] &= ~CR_TLBMISC_DBL; env->ctrl[CR_TLBMISC] |= CR_TLBMISC_WR; @@ -98,8 +100,9 @@ void nios2_cpu_do_interrupt(CPUState *cs) env->ctrl[CR_STATUS] |= CR_STATUS_EH; env->ctrl[CR_STATUS] &= ~(CR_STATUS_PIE | CR_STATUS_U); - env->ctrl[CR_EXCEPTION] &= ~(0x1F << 2); - env->ctrl[CR_EXCEPTION] |= (cs->exception_index & 0x1F) << 2; + env->ctrl[CR_EXCEPTION] = FIELD_DP32(env->ctrl[CR_EXCEPTION], + CR_EXCEPTION, CAUSE, + cs->exception_index); env->ctrl[CR_TLBMISC] |= CR_TLBMISC_DBL; @@ -116,8 +119,9 @@ void nios2_cpu_do_interrupt(CPUState *cs) env->ctrl[CR_STATUS] |= CR_STATUS_EH; env->ctrl[CR_STATUS] &= ~(CR_STATUS_PIE | CR_STATUS_U); - env->ctrl[CR_EXCEPTION] &= ~(0x1F << 2); - env->ctrl[CR_EXCEPTION] |= (cs->exception_index & 0x1F) << 2; + env->ctrl[CR_EXCEPTION] = FIELD_DP32(env->ctrl[CR_EXCEPTION], + CR_EXCEPTION, CAUSE, + cs->exception_index); if ((env->ctrl[CR_STATUS] & CR_STATUS_EH) == 0) { env->ctrl[CR_TLBMISC] |= CR_TLBMISC_WR; @@ -140,8 +144,9 @@ void nios2_cpu_do_interrupt(CPUState *cs) env->ctrl[CR_STATUS] |= CR_STATUS_EH; env->ctrl[CR_STATUS] &= ~(CR_STATUS_PIE | CR_STATUS_U); - env->ctrl[CR_EXCEPTION] &= ~(0x1F << 2); - env->ctrl[CR_EXCEPTION] |= (cs->exception_index & 0x1F) << 2; + env->ctrl[CR_EXCEPTION] = FIELD_DP32(env->ctrl[CR_EXCEPTION], + CR_EXCEPTION, CAUSE, + cs->exception_index); env->pc = cpu->exception_addr; break; @@ -158,8 +163,9 @@ void nios2_cpu_do_interrupt(CPUState *cs) env->ctrl[CR_STATUS] |= CR_STATUS_EH; env->ctrl[CR_STATUS] &= ~(CR_STATUS_PIE | CR_STATUS_U); - env->ctrl[CR_EXCEPTION] &= ~(0x1F << 2); - env->ctrl[CR_EXCEPTION] |= (cs->exception_index & 0x1F) << 2; + env->ctrl[CR_EXCEPTION] = FIELD_DP32(env->ctrl[CR_EXCEPTION], + CR_EXCEPTION, CAUSE, + cs->exception_index); env->pc = cpu->exception_addr; break; @@ -183,8 +189,9 @@ void nios2_cpu_do_interrupt(CPUState *cs) env->ctrl[CR_STATUS] |= CR_STATUS_EH; env->ctrl[CR_STATUS] &= ~(CR_STATUS_PIE | CR_STATUS_U); - env->ctrl[CR_EXCEPTION] &= ~(0x1F << 2); - env->ctrl[CR_EXCEPTION] |= (cs->exception_index & 0x1F) << 2; + env->ctrl[CR_EXCEPTION] = FIELD_DP32(env->ctrl[CR_EXCEPTION], + CR_EXCEPTION, CAUSE, + cs->exception_index); env->pc = cpu->exception_addr; break; @@ -228,7 +235,7 @@ void nios2_cpu_do_unaligned_access(CPUState *cs, vaddr addr, CPUNios2State *env = &cpu->env; env->ctrl[CR_BADADDR] = addr; - env->ctrl[CR_EXCEPTION] = EXCP_UNALIGN << 2; + env->ctrl[CR_EXCEPTION] = FIELD_DP32(0, CR_EXCEPTION, CAUSE, EXCP_UNALIGN); helper_raise_exception(env, EXCP_UNALIGN); } From patchwork Thu Mar 10 11:26:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 550105 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp915673mag; Thu, 10 Mar 2022 03:52:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJyNAtRnu0nw755g6FrcJLi1nGrkfODKjLHwJl3NFoxvlg5N+XfkVH9/15ATXMM+FgPg/MVl X-Received: by 2002:a5b:1d1:0:b0:628:a2f1:dd40 with SMTP id f17-20020a5b01d1000000b00628a2f1dd40mr3507194ybp.563.1646913129755; Thu, 10 Mar 2022 03:52:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646913129; cv=none; d=google.com; s=arc-20160816; b=a/N+JXeTufYIkzaieuo1fJ7mWDw3Ie8Og9S+ikYD68m1wLBJArrH4yWhCZu6zYdNIh c4M6EDJ17RJubaoYuuHRBOwAN4qc6E/jt9Rxv3uuOz3HGFHMI4LHvj/imNOAx29rof5u Fa19OAwuQCO0JXHBDqdk/qJxMt9LHY8Q9KpL4TVc4MFt7+qtZ1q7o/45yOYXTDWJ14e1 lPOaGQwQx4sb72F/3r2cnTq9qp0+jsUNOy0Q/awWLFUyZRAn4+FXBntvfDaj5CviVLQn FlUyERzU4CtXOWU0bQbCNc33TnBRn2F8XmiXcq0Wkw8Wx1p/qwgfE6xE3p2QG04ykNQp 7/8w== 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=f9kEO6gPHdFHbcVjWJEx3cRnSvZ1MpAPY6GCaaYYMWU=; b=L63qoObZGPrs1/uXXl2Gw4S5nylpN9EEg4v8x+wqyJb8UXKAIc+/eUsNLuYqCFxDbR oKJMjohzAcLujypxgfZJbFp9jLYYgYiNmyXAtWET6MYhbFo14XK88Ig+3pGqdvUb9/sx SQ0Vmz9n0HDjDEHHuo5NNNp2y4kiUeQK9bjx5Si/rQDoqxt7aM+W7ZANhm0JK9dI4hPk dahOjkCeeyx221g2+SYqdcaUGx+6Oa6mqdwrfrM1vWB6sftyUFkdAKbNk2JoJJiLcUuB z4Qv1yz8LG/vJe0ThN6tYX0DCO6BLzBKin1P9R6bmb34aWQ6bAK/D46N2nOIo4kg+eal +kzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=v8U0sjgF; 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 c200-20020a811cd1000000b002dc314ef7fdsi2490129ywc.256.2022.03.10.03.52.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Mar 2022 03:52:09 -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=v8U0sjgF; 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]:51786 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSHKz-0006Iu-8p for patch@linaro.org; Thu, 10 Mar 2022 06:52:09 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50742) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSGxN-0005PD-VD for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:27:46 -0500 Received: from [2607:f8b0:4864:20::635] (port=33544 helo=mail-pl1-x635.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nSGxM-0007xW-AO for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:27:45 -0500 Received: by mail-pl1-x635.google.com with SMTP id m2so4642091pll.0 for ; Thu, 10 Mar 2022 03:27:43 -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=f9kEO6gPHdFHbcVjWJEx3cRnSvZ1MpAPY6GCaaYYMWU=; b=v8U0sjgFWHyqvmqJGP/YPh3JcCGOqJHBjXqaxDD6pnBcgtV0GI5adzXGXDgnqmJSos NXjmn/UN8cobecQslh9/+UgzBr9ev+OuCaYMKfb3ua2KFXCSj2SanDatw0YS6DAPiH/f l2/KOejZBXxxUdJ75zqPaD00uiz8oSOQyq/v6SRpfulaluqsFJFhOndIwXqpgLEOQCov O7oT827s9Y0wQ/SHOzFLN0ruoVYFC1zYluU8y4mNtJlzlpLXDnVen88xIXarTfPOzzBY 3aMP5Q6kM5fUvGRa7z7RqB/uSdLb0JGREvSBl/zCyYh1Xib86ucA26pfaYJWWp/8nhWu AfQA== 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=f9kEO6gPHdFHbcVjWJEx3cRnSvZ1MpAPY6GCaaYYMWU=; b=ZFmk315DH9dYSoh6jFXvWtyWZIusmnp9vUa1ZX6VfTVHa+HQ2bb5PMFejJBq8Nc6o7 flNmxqmy9+c/kRK4p84fheTPPpqIhbW8d+7wW2fMxRHviE2zWTymc1jTFxTR0WdFCqRE 5lWjscI+hsJB32vh8mAP836hUKYeqRuqWnS4tmdcg2Zq9lt1mJe0tOq4vpZ/xZo8AEpg 1u9ttNXZXp+DusWZ+PEHWhE2Xa02t9QkrSFLK3kJu06IHTsQ1h3dDTZmeRD2t1fRpaGj pzVgOVa0Gc3SOnxMteFgyC5B22e/ee1XXFwSbMzSCP8wkqCM6kx48RPtXjjNzlln7mrL 7PjA== X-Gm-Message-State: AOAM531bznT8OZrs8paDK/K0zNnhoASHRZJLMMUqs3BX2bKbORPEBfzS mXh0WCnGLgCmmKHQNI84ZKmq0aU57yekDA== X-Received: by 2002:a17:902:6b8b:b0:14d:66c4:f704 with SMTP id p11-20020a1709026b8b00b0014d66c4f704mr4617398plk.53.1646911663043; Thu, 10 Mar 2022 03:27:43 -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.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Mar 2022 03:27:42 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 15/48] target/nios2: Use hw/registerfields.h for CR_TLBADDR fields Date: Thu, 10 Mar 2022 03:26:52 -0800 Message-Id: <20220310112725.570053-16-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::635 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::635; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x635.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" Use FIELD_EX32 and FIELD_DP32 instead of manual manipulation of the fields. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/nios2/cpu.h | 8 ++++---- target/nios2/helper.c | 4 ++-- target/nios2/mmu.c | 17 +++++++++-------- target/nios2/translate.c | 2 +- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/target/nios2/cpu.h b/target/nios2/cpu.h index 963cdec161..e1c2bf8c31 100644 --- a/target/nios2/cpu.h +++ b/target/nios2/cpu.h @@ -110,10 +110,10 @@ FIELD(CR_EXCEPTION, CAUSE, 2, 5) FIELD(CR_EXCEPTION, ECCFTL, 31, 1) #define CR_PTEADDR 8 -#define CR_PTEADDR_PTBASE_SHIFT 22 -#define CR_PTEADDR_PTBASE_MASK (0x3FF << CR_PTEADDR_PTBASE_SHIFT) -#define CR_PTEADDR_VPN_SHIFT 2 -#define CR_PTEADDR_VPN_MASK (0xFFFFF << CR_PTEADDR_VPN_SHIFT) + +FIELD(CR_PTEADDR, VPN, 2, 20) +FIELD(CR_PTEADDR, PTBASE, 22, 10) + #define CR_TLBACC 9 #define CR_TLBACC_IGN_SHIFT 25 #define CR_TLBACC_IGN_MASK (0x7F << CR_TLBACC_IGN_SHIFT) diff --git a/target/nios2/helper.c b/target/nios2/helper.c index 54458a5447..da3a289fc7 100644 --- a/target/nios2/helper.c +++ b/target/nios2/helper.c @@ -306,8 +306,8 @@ bool nios2_cpu_tlb_fill(CPUState *cs, vaddr address, int size, } else { env->ctrl[CR_TLBMISC] |= CR_TLBMISC_D; } - env->ctrl[CR_PTEADDR] &= CR_PTEADDR_PTBASE_MASK; - env->ctrl[CR_PTEADDR] |= (address >> 10) & CR_PTEADDR_VPN_MASK; + env->ctrl[CR_PTEADDR] = FIELD_DP32(env->ctrl[CR_PTEADDR], CR_PTEADDR, VPN, + address >> TARGET_PAGE_BITS); env->mmu.pteaddr_wr = env->ctrl[CR_PTEADDR]; cs->exception_index = excp; diff --git a/target/nios2/mmu.c b/target/nios2/mmu.c index 95900724e8..75afc56daf 100644 --- a/target/nios2/mmu.c +++ b/target/nios2/mmu.c @@ -97,7 +97,7 @@ void helper_mmu_write_tlbacc(CPUNios2State *env, uint32_t v) /* if tlbmisc.WE == 1 then trigger a TLB write on writes to TLBACC */ if (env->ctrl[CR_TLBMISC] & CR_TLBMISC_WR) { int way = (env->ctrl[CR_TLBMISC] >> CR_TLBMISC_WAY_SHIFT); - int vpn = (env->mmu.pteaddr_wr & CR_PTEADDR_VPN_MASK) >> 2; + int vpn = FIELD_EX32(env->mmu.pteaddr_wr, CR_PTEADDR, VPN); int pid = (env->mmu.tlbmisc_wr & CR_TLBMISC_PID_MASK) >> 4; int g = (v & CR_TLBACC_G) ? 1 : 0; int valid = ((vpn & CR_TLBACC_PFN_MASK) < 0xC0000) ? 1 : 0; @@ -148,7 +148,7 @@ void helper_mmu_write_tlbmisc(CPUNios2State *env, uint32_t v) /* if tlbmisc.RD == 1 then trigger a TLB read on writes to TLBMISC */ if (v & CR_TLBMISC_RD) { int way = (v >> CR_TLBMISC_WAY_SHIFT); - int vpn = (env->mmu.pteaddr_wr & CR_PTEADDR_VPN_MASK) >> 2; + int vpn = FIELD_EX32(env->mmu.pteaddr_wr, CR_PTEADDR, VPN); Nios2TLBEntry *entry = &env->mmu.tlb[(way * cpu->tlb_num_ways) + (vpn & env->mmu.tlb_entry_mask)]; @@ -160,8 +160,9 @@ void helper_mmu_write_tlbmisc(CPUNios2State *env, uint32_t v) (v & ~CR_TLBMISC_PID_MASK) | ((entry->tag & ((1 << cpu->pid_num_bits) - 1)) << CR_TLBMISC_PID_SHIFT); - env->ctrl[CR_PTEADDR] &= ~CR_PTEADDR_VPN_MASK; - env->ctrl[CR_PTEADDR] |= (entry->tag >> 12) << CR_PTEADDR_VPN_SHIFT; + env->ctrl[CR_PTEADDR] = FIELD_DP32(env->ctrl[CR_PTEADDR], + CR_PTEADDR, VPN, + entry->tag >> TARGET_PAGE_BITS); } else { env->ctrl[CR_TLBMISC] = v; } @@ -171,12 +172,12 @@ void helper_mmu_write_tlbmisc(CPUNios2State *env, uint32_t v) void helper_mmu_write_pteaddr(CPUNios2State *env, uint32_t v) { - trace_nios2_mmu_write_pteaddr(v >> CR_PTEADDR_PTBASE_SHIFT, - (v & CR_PTEADDR_VPN_MASK) >> CR_PTEADDR_VPN_SHIFT); + trace_nios2_mmu_write_pteaddr(FIELD_EX32(v, CR_PTEADDR, PTBASE), + FIELD_EX32(v, CR_PTEADDR, VPN)); /* Writes to PTEADDR don't change the read-back VPN value */ - env->ctrl[CR_PTEADDR] = ((v & ~CR_PTEADDR_VPN_MASK) | - (env->ctrl[CR_PTEADDR] & CR_PTEADDR_VPN_MASK)); + env->ctrl[CR_PTEADDR] = ((v & ~R_CR_PTEADDR_VPN_MASK) | + (env->ctrl[CR_PTEADDR] & R_CR_PTEADDR_VPN_MASK)); env->mmu.pteaddr_wr = v; } diff --git a/target/nios2/translate.c b/target/nios2/translate.c index 45fe2f9a05..9b81a2b29e 100644 --- a/target/nios2/translate.c +++ b/target/nios2/translate.c @@ -923,7 +923,7 @@ void nios2_cpu_dump_state(CPUState *cs, FILE *f, int flags) } } qemu_fprintf(f, " mmu write: VPN=%05X PID %02X TLBACC %08X\n", - env->mmu.pteaddr_wr & CR_PTEADDR_VPN_MASK, + env->mmu.pteaddr_wr & R_CR_PTEADDR_VPN_MASK, (env->mmu.tlbmisc_wr & CR_TLBMISC_PID_MASK) >> 4, env->mmu.tlbacc_wr); #endif From patchwork Thu Mar 10 11:26:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 550104 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp915586mag; Thu, 10 Mar 2022 03:52:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJxYGixjxPso7ZIehjeBTSN/6EYbJpZUVXG206oZ+R6XXlQIA52itBcXr7cRJybu6ucHNdhM X-Received: by 2002:a25:e54a:0:b0:628:b77e:5352 with SMTP id c71-20020a25e54a000000b00628b77e5352mr3336516ybh.445.1646913122694; Thu, 10 Mar 2022 03:52:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646913122; cv=none; d=google.com; s=arc-20160816; b=Zx+DSUvd8bzjFNq3qtk0dJGSgIwgIcCTr1G4jGCyJ2CKkdXOw/46kTCXOOPsyjlXI+ jCi16cTNlWB0z8p1fq/SGAGXqO7Q8yV0h7cYV2fpwsN4GxLZ0URc6e8c8U+ZiSsWUoDP GUMF2DEWPeZL4bbJ6JmIxOqJ4/T6r+cc4siLv1k0o9TdOivIRdMH7toZh7lNYiaMyN1P i7EF756MiPnvTb256FXGmWJNLkXGKGPrydis2ZChEYlYEbWCB7exyzCHDNhCCjmc/Bsm 4ahxye+JMC36oNqcA7on/00rk1V/unuUolxH30Z2K5K5XqR09eeEeZlTisaLoh2RhPTv pE/w== 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=GKFLxmbTYTFJV6/p4TM5MrilKQbtlOw6w8FSPR9X89E=; b=pwRiTQH4RiFvjWsjN+qMrYLaipAmXeeGG8FFdJiRXB5d+7soMRhMfB/vh1ClB5IDZi 3TTWdc7+UYEUzblkrGx2tAC0/9jtBu8U0Wrff4WsbQS7iDWBKSs6xPSCE431H0yAEsDh zvIwp/3CVtOSLxcidFsKzBhjx3X2wMVUxJQ65YA6miSabJjfuTcCNERhIaBd30uZVqcf nwz8MSdkuJtoEfomNKwfElroZ2TSASWZ/n7EK2tXlLLtW8q14OP0TeGgFCtyCsuoGxHA wjgC0qrYNmC+6Y6OwmmyDksiRKaoPBGtfIK8/p6bd4Xz1e+/UpQrAuVQGRpp5Cp+raXW Divg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=tZ4DQVvo; 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 o17-20020a814111000000b002d6ba92f72fsi2859280ywa.66.2022.03.10.03.52.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Mar 2022 03:52:02 -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=tZ4DQVvo; 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]:51292 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSHKs-0005yL-4W for patch@linaro.org; Thu, 10 Mar 2022 06:52:02 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50782) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSGxQ-0005WW-Bv for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:27:48 -0500 Received: from [2607:f8b0:4864:20::1032] (port=46629 helo=mail-pj1-x1032.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nSGxO-0007xy-F4 for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:27:48 -0500 Received: by mail-pj1-x1032.google.com with SMTP id 15-20020a17090a098f00b001bef0376d5cso4935041pjo.5 for ; Thu, 10 Mar 2022 03:27:46 -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=GKFLxmbTYTFJV6/p4TM5MrilKQbtlOw6w8FSPR9X89E=; b=tZ4DQVvoX5L7A3EfnKywYn5U04oPGL4UjZiVynQh/Banf+iRUlCBJx+o5qyna2Vnt7 i2G/p9qSGSib7PwifHawl2QNmftQSsWu0vSz1lhBf8WjuD1rU40EXd41SCrDABZAPOx3 8Qj8f7ODd/gADspqmzdq861CTeMRjrWCfdPSNyxR6EXW0nH4NknbRl+ZgAYe8LMnAdOO G6vJ6NXwDxOp+joiJfWAGLxyjEf6wgQKombPLt3aaW87ENgwZ65HSIGTozjjeCR8wAwU 3W7R+sD4pHUJiJRAPWTNYuRnQjLlo8uCWJrpPEv93DQuzF583N0f1G95SqTFTZxQ655J sjCA== 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=GKFLxmbTYTFJV6/p4TM5MrilKQbtlOw6w8FSPR9X89E=; b=CiTvjvc7IBg2eRszh2LLFY0DBfrS7tPvNDfQo8f0etFokPK25uWD+vDARxAhY/Cb3v 8Kcxj8VTYJJSnfom/Qkc5oRNU8kegGi2kEsT7CrXpUoU0+XGFEHpphrDvjdDhGlhcweL bzTZy+LM0QkEoEjqVMN42C9D6DDyidCDK8Pz7BHI7l/rCzdLSQ24oEIqazyR8Hamgje0 aSMQvcRMUakAym8OA53QOjRD01RvOXkj4yET7/EI4CiJnAU9SeQ3AZBQyr7SgOSJXFQ/ szEuUF8bKCNdts8jEV9thpw21VlsCaGH5dqAZSNUKgwOyZJUPIqcLN8L/mWmqOl9Au3D 8qYw== X-Gm-Message-State: AOAM531TFxWgvN5Z+B4dfuaAOPMjJ/LZ1ufg54NV7O3yp8KarWFh697N mskPevhhK7OrFmcvXwC/JZ3c1dMRpNXyaw== X-Received: by 2002:a17:902:d492:b0:151:86ac:bc7b with SMTP id c18-20020a170902d49200b0015186acbc7bmr4477089plg.52.1646911664109; Thu, 10 Mar 2022 03:27:44 -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.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Mar 2022 03:27:43 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 16/48] target/nios2: Use hw/registerfields.h for CR_TLBACC fields Date: Thu, 10 Mar 2022 03:26:53 -0800 Message-Id: <20220310112725.570053-17-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::1032 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::1032; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1032.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" Retain the helper macros for single bit fields as aliases to the longer R_*_MASK names. Use FIELD_EX32 and FIELD_DP32 instead of manually manipulating the fields. Since we're rewriting the references to CR_TLBACC_IGN_* anyway, we correct the name of this field to IG, which is its name in the official CPU documentation. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/nios2/cpu.h | 23 +++++++++++++++-------- target/nios2/mmu.c | 16 ++++++++-------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/target/nios2/cpu.h b/target/nios2/cpu.h index e1c2bf8c31..25b77916ca 100644 --- a/target/nios2/cpu.h +++ b/target/nios2/cpu.h @@ -115,14 +115,21 @@ FIELD(CR_PTEADDR, VPN, 2, 20) FIELD(CR_PTEADDR, PTBASE, 22, 10) #define CR_TLBACC 9 -#define CR_TLBACC_IGN_SHIFT 25 -#define CR_TLBACC_IGN_MASK (0x7F << CR_TLBACC_IGN_SHIFT) -#define CR_TLBACC_C (1 << 24) -#define CR_TLBACC_R (1 << 23) -#define CR_TLBACC_W (1 << 22) -#define CR_TLBACC_X (1 << 21) -#define CR_TLBACC_G (1 << 20) -#define CR_TLBACC_PFN_MASK 0x000FFFFF + +FIELD(CR_TLBACC, PFN, 0, 20) +FIELD(CR_TLBACC, G, 20, 1) +FIELD(CR_TLBACC, X, 21, 1) +FIELD(CR_TLBACC, W, 22, 1) +FIELD(CR_TLBACC, R, 23, 1) +FIELD(CR_TLBACC, C, 24, 1) +FIELD(CR_TLBACC, IG, 25, 7) + +#define CR_TLBACC_C R_CR_TLBACC_C_MASK +#define CR_TLBACC_R R_CR_TLBACC_R_MASK +#define CR_TLBACC_W R_CR_TLBACC_W_MASK +#define CR_TLBACC_X R_CR_TLBACC_X_MASK +#define CR_TLBACC_G R_CR_TLBACC_G_MASK + #define CR_TLBMISC 10 #define CR_TLBMISC_WAY_SHIFT 20 #define CR_TLBMISC_WAY_MASK (0xF << CR_TLBMISC_WAY_SHIFT) diff --git a/target/nios2/mmu.c b/target/nios2/mmu.c index 75afc56daf..826cd2afb4 100644 --- a/target/nios2/mmu.c +++ b/target/nios2/mmu.c @@ -49,7 +49,7 @@ unsigned int mmu_translate(CPUNios2State *env, } lu->vaddr = vaddr & TARGET_PAGE_MASK; - lu->paddr = (entry->data & CR_TLBACC_PFN_MASK) << TARGET_PAGE_BITS; + lu->paddr = FIELD_EX32(entry->data, CR_TLBACC, PFN) << TARGET_PAGE_BITS; lu->prot = ((entry->data & CR_TLBACC_R) ? PAGE_READ : 0) | ((entry->data & CR_TLBACC_W) ? PAGE_WRITE : 0) | ((entry->data & CR_TLBACC_X) ? PAGE_EXEC : 0); @@ -86,27 +86,27 @@ void helper_mmu_write_tlbacc(CPUNios2State *env, uint32_t v) CPUState *cs = env_cpu(env); Nios2CPU *cpu = env_archcpu(env); - trace_nios2_mmu_write_tlbacc(v >> CR_TLBACC_IGN_SHIFT, + trace_nios2_mmu_write_tlbacc(FIELD_EX32(v, CR_TLBACC, IG), (v & CR_TLBACC_C) ? 'C' : '.', (v & CR_TLBACC_R) ? 'R' : '.', (v & CR_TLBACC_W) ? 'W' : '.', (v & CR_TLBACC_X) ? 'X' : '.', (v & CR_TLBACC_G) ? 'G' : '.', - v & CR_TLBACC_PFN_MASK); + FIELD_EX32(v, CR_TLBACC, PFN)); /* if tlbmisc.WE == 1 then trigger a TLB write on writes to TLBACC */ if (env->ctrl[CR_TLBMISC] & CR_TLBMISC_WR) { int way = (env->ctrl[CR_TLBMISC] >> CR_TLBMISC_WAY_SHIFT); int vpn = FIELD_EX32(env->mmu.pteaddr_wr, CR_PTEADDR, VPN); int pid = (env->mmu.tlbmisc_wr & CR_TLBMISC_PID_MASK) >> 4; - int g = (v & CR_TLBACC_G) ? 1 : 0; - int valid = ((vpn & CR_TLBACC_PFN_MASK) < 0xC0000) ? 1 : 0; + int g = FIELD_EX32(v, CR_TLBACC, G); + int valid = FIELD_EX32(vpn, CR_TLBACC, PFN) < 0xC0000; Nios2TLBEntry *entry = &env->mmu.tlb[(way * cpu->tlb_num_ways) + (vpn & env->mmu.tlb_entry_mask)]; uint32_t newTag = (vpn << 12) | (g << 11) | (valid << 10) | pid; uint32_t newData = v & (CR_TLBACC_C | CR_TLBACC_R | CR_TLBACC_W | - CR_TLBACC_X | CR_TLBACC_PFN_MASK); + CR_TLBACC_X | R_CR_TLBACC_PFN_MASK); if ((entry->tag != newTag) || (entry->data != newData)) { if (entry->tag & (1 << 10)) { @@ -153,7 +153,7 @@ void helper_mmu_write_tlbmisc(CPUNios2State *env, uint32_t v) &env->mmu.tlb[(way * cpu->tlb_num_ways) + (vpn & env->mmu.tlb_entry_mask)]; - env->ctrl[CR_TLBACC] &= CR_TLBACC_IGN_MASK; + env->ctrl[CR_TLBACC] &= R_CR_TLBACC_IG_MASK; env->ctrl[CR_TLBACC] |= entry->data; env->ctrl[CR_TLBACC] |= (entry->tag & (1 << 11)) ? CR_TLBACC_G : 0; env->ctrl[CR_TLBMISC] = @@ -208,7 +208,7 @@ void dump_mmu(CPUNios2State *env) entry->tag >> 12, entry->tag & ((1 << cpu->pid_num_bits) - 1), (entry->tag & (1 << 11)) ? 'G' : '-', - entry->data & CR_TLBACC_PFN_MASK, + FIELD_EX32(entry->data, CR_TLBACC, PFN), (entry->data & CR_TLBACC_C) ? 'C' : '-', (entry->data & CR_TLBACC_R) ? 'R' : '-', (entry->data & CR_TLBACC_W) ? 'W' : '-', From patchwork Thu Mar 10 11:26:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 550109 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp917376mag; Thu, 10 Mar 2022 03:54:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJwQknz75bQeqiTpcy6kA4TgbEpp4UhMijSsm8+oqL8CbeVpPVEKfbqMTH5Xs0jBLqR7J3E2 X-Received: by 2002:a25:dc8c:0:b0:628:df7f:424b with SMTP id y134-20020a25dc8c000000b00628df7f424bmr3480157ybe.620.1646913279236; Thu, 10 Mar 2022 03:54:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646913279; cv=none; d=google.com; s=arc-20160816; b=c3dGOFNDG9pDBGR5HQuUqpBs0Vusv3iZsnyE4g+Nwmd69H+ESMAgVVJZHDHPOxFVNi SB+m08Y/CDc+SfjW/GqcngfUea1BqJibqeO4jFW8xGHO2JHb09+wFaIOdJfdC9YF9fJB dhuKA1FrDqByE+T2udgmvylZfFgCqjVsUwqKldIBVvTV+V7GSHaWCMxaN9KmZ2n4FSjy OiUdtWcGcKHSD2ItuHhxo9q11PF3ir9lNAOvV6HE3yjwYkL2S+ixbjuM+fJKNe4CLC1g AmVZGTTmepRo4HSaINyNNoXUUyXcxdWwAVSEXdu7gLtE9C6IDN/W/AEYrM+NyIM5c36J d4Gw== 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=jwiItv/W7hsxOLFZ9QGpLLDQ+Ql5lsRDNyYEtGuJ3Fw=; b=K15HQazsHPZvS077DhSY8U1/CMtHiznJ8g2XU0ng3vBBVi9NEkOnlPyk4wQrjYHJrF 7GuU/x6ioj/tmREm4N5lIpY8fPOTcXIOBCAJ/6xueYikQQxYnY476qD3Zqq1GwEFoT76 SQtnQqQuuLZ3YXNFJLSSlnUVfvZKGzY2OLTL5XEBfHpYJLlGDwI80abnW9m3Wpzd78zC 2k7zYab4BTSml3cxmqwvXjpPHxWrnAUA+QPmf8vShInUSX0tKkh52nZXx90zjTx4i71Z 3F/onnqUiDoA3ASPaea2kgwnzj7uW5OrRsWwomlcDj7uyB4dMMx0xZkHI/5fwbGXrnAH x8IA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=FkDhEB3I; 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 83-20020a810a56000000b002dd291fcc15si2542833ywk.309.2022.03.10.03.54.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Mar 2022 03:54:39 -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=FkDhEB3I; 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]:59994 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSHNN-0003TD-CN for patch@linaro.org; Thu, 10 Mar 2022 06:54:37 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50778) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSGxP-0005Ve-VF for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:27:48 -0500 Received: from [2607:f8b0:4864:20::102f] (port=37407 helo=mail-pj1-x102f.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nSGxO-0007xx-DA for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:27:47 -0500 Received: by mail-pj1-x102f.google.com with SMTP id lj8-20020a17090b344800b001bfaa46bca3so4845918pjb.2 for ; Thu, 10 Mar 2022 03:27:45 -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=jwiItv/W7hsxOLFZ9QGpLLDQ+Ql5lsRDNyYEtGuJ3Fw=; b=FkDhEB3IcWan3V3kWqpwhPQvXxZ2qI4GcEYWup1wW6KvBTnnpKiyMMP1gwsTn0hcZY HGfgSmo7T72CF37rbgV2Zvy41GktfbxgbvChpx9AEpVxFBpqzpuJ52zZ9QYRSidOVppS oEARLXXysz5zEPECV89fiZDAEmXH6Hg6zK8PO9HojQOh1u/FwzUjmJhGIkkvypkQIf6w nxoKpWbb9jVE2AqC4mllnQgheqey7kazC6VYnNOvAJ2tRA5PJ6BQAIX+ndH3AX1lDbGp GjbUtnowcnhlmBQubbb15+78mqYhu4KoUuXqXjKEUhEqYIgOd4gGVyaNdI5kaF0M/Ld3 amkg== 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=jwiItv/W7hsxOLFZ9QGpLLDQ+Ql5lsRDNyYEtGuJ3Fw=; b=1iO+j9n8kspwO4Jq53q3zWEjQHOA3Nr33mRM+D4R8qg9GaiNxf9rwvtmL/D0T0b67R lCbBRta9pRO8NERTLW+YMhZkOkkd7cgWDAnkhVsc1+mViuAWsz93WOLjewjbw4BtBAlo XDfarDNmuxbzWj7XHV1kNAPjEPqzCTrZPqTDe3Zk7PFmx85WYDNa7r98KwO4WFon5Emv kdBq4HDDUOdk0P4KdHWx4kSOt/jieUns0Wiv1N7cb+OueORM2d7WYB0t35jBmdBvHjno aizyjen3dQKyrxHpr3MGIXo9Zot9VCOfEXrWrbXno0VaTfZirpXern4QMdnEIG0/dgak eQ5A== X-Gm-Message-State: AOAM531VUKibk5MUgkONr8VjWXPufeuDcjebL8DcUR2PulV/rbRUxKon sPkMnnipcRKy5FV7GQBNt3fB2ARD9+IszA== X-Received: by 2002:a17:903:4a:b0:151:be09:3de9 with SMTP id l10-20020a170903004a00b00151be093de9mr4464030pla.138.1646911665149; Thu, 10 Mar 2022 03:27:45 -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.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Mar 2022 03:27:44 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 17/48] target/nios2: Rename CR_TLBMISC_WR to CR_TLBMISC_WE Date: Thu, 10 Mar 2022 03:26:54 -0800 Message-Id: <20220310112725.570053-18-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::102f (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::102f; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102f.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 is the architectural name of the field, not WR. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- target/nios2/cpu.h | 2 +- target/nios2/helper.c | 4 ++-- target/nios2/mmu.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/target/nios2/cpu.h b/target/nios2/cpu.h index 25b77916ca..81472be686 100644 --- a/target/nios2/cpu.h +++ b/target/nios2/cpu.h @@ -134,7 +134,7 @@ FIELD(CR_TLBACC, IG, 25, 7) #define CR_TLBMISC_WAY_SHIFT 20 #define CR_TLBMISC_WAY_MASK (0xF << CR_TLBMISC_WAY_SHIFT) #define CR_TLBMISC_RD (1 << 19) -#define CR_TLBMISC_WR (1 << 18) +#define CR_TLBMISC_WE (1 << 18) #define CR_TLBMISC_PID_SHIFT 4 #define CR_TLBMISC_PID_MASK (0x3FFF << CR_TLBMISC_PID_SHIFT) #define CR_TLBMISC_DBL (1 << 3) diff --git a/target/nios2/helper.c b/target/nios2/helper.c index da3a289fc7..308d66ad93 100644 --- a/target/nios2/helper.c +++ b/target/nios2/helper.c @@ -89,7 +89,7 @@ void nios2_cpu_do_interrupt(CPUState *cs) cs->exception_index); env->ctrl[CR_TLBMISC] &= ~CR_TLBMISC_DBL; - env->ctrl[CR_TLBMISC] |= CR_TLBMISC_WR; + env->ctrl[CR_TLBMISC] |= CR_TLBMISC_WE; env->regs[R_EA] = env->pc + 4; env->pc = cpu->fast_tlb_miss_addr; @@ -124,7 +124,7 @@ void nios2_cpu_do_interrupt(CPUState *cs) cs->exception_index); if ((env->ctrl[CR_STATUS] & CR_STATUS_EH) == 0) { - env->ctrl[CR_TLBMISC] |= CR_TLBMISC_WR; + env->ctrl[CR_TLBMISC] |= CR_TLBMISC_WE; } env->regs[R_EA] = env->pc + 4; diff --git a/target/nios2/mmu.c b/target/nios2/mmu.c index 826cd2afb4..0f33ea5e04 100644 --- a/target/nios2/mmu.c +++ b/target/nios2/mmu.c @@ -95,7 +95,7 @@ void helper_mmu_write_tlbacc(CPUNios2State *env, uint32_t v) FIELD_EX32(v, CR_TLBACC, PFN)); /* if tlbmisc.WE == 1 then trigger a TLB write on writes to TLBACC */ - if (env->ctrl[CR_TLBMISC] & CR_TLBMISC_WR) { + if (env->ctrl[CR_TLBMISC] & CR_TLBMISC_WE) { int way = (env->ctrl[CR_TLBMISC] >> CR_TLBMISC_WAY_SHIFT); int vpn = FIELD_EX32(env->mmu.pteaddr_wr, CR_PTEADDR, VPN); int pid = (env->mmu.tlbmisc_wr & CR_TLBMISC_PID_MASK) >> 4; @@ -133,7 +133,7 @@ void helper_mmu_write_tlbmisc(CPUNios2State *env, uint32_t v) trace_nios2_mmu_write_tlbmisc(v >> CR_TLBMISC_WAY_SHIFT, (v & CR_TLBMISC_RD) ? 'R' : '.', - (v & CR_TLBMISC_WR) ? 'W' : '.', + (v & CR_TLBMISC_WE) ? 'W' : '.', (v & CR_TLBMISC_DBL) ? '2' : '.', (v & CR_TLBMISC_BAD) ? 'B' : '.', (v & CR_TLBMISC_PERM) ? 'P' : '.', From patchwork Thu Mar 10 11:26:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 550121 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp926819mag; Thu, 10 Mar 2022 04:06:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJyzYaiZKBgIjiWLk+HI0Y9D28Zb0F+/kZc8hRoNBoXmgj931AVP10PW9jDn2B/gaVzh4Rzl X-Received: by 2002:a25:ba0c:0:b0:61a:79a6:fd0 with SMTP id t12-20020a25ba0c000000b0061a79a60fd0mr3553017ybg.45.1646913987790; Thu, 10 Mar 2022 04:06:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646913987; cv=none; d=google.com; s=arc-20160816; b=ivcbqAvNVfjXpwrTQ9jsf0aFG7pEKj8/a1emF/AuFlNqH4Vl+Ok/sKxk0EZYwl8F0h kAal1oiGzDlZwChcxN1cqBp9t4VRTGzZVaSdp+hqL6IahNGVyV5On7LAVm9soVzrbMAq AP4+sNi7O2iJnEKPJ5Lpfiu6FD/Y7iwlKNz1rCxENW+ehYcOl9LqEeltkvC9v4tiZ0Ki +Mdkauf5NlB5ZmxWkG78ZkRAjzQiaRg55Al1tJo8rrtbjtRETg6Ex/iNCKdoNVPkKYIl c+0wECLuiMLM0+HGBCj39W5q3jpctVD8AXYuIgqBEDUjMRtixb/PAOF7FXMHKcwETPmR UuEQ== 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=GADV/jExPWz+mF0nwm5rQZ+l5e8TEkrJvePYWSdN3A0=; b=0Y3GX0s2laxPU6mkRMDjXXCGXWlk0WwLOifcPS/r9Vw0imf0i7t2TFpl4KPejmDxHV 3lOK0Jxjw8YnspXpWO+iowvuHVO5cpLaiH26tm/7Q69nDmSviw5eYb4ieRxRg4G79XgF 23mPehz2vK6J4u7mJUseyNmUy03U/wULqSdOYpp0xgMkJxdVDBMu8rDOxpOfBcuq3SBB /b1lNr/u2Hg9SenhIS61juJKcqk+2mfEpHKcTxvP2QAdxLs1UhFPDBqaiQ0VzrK4rDQB zAOKsCiJqjJ6yO8DU6kzp3Z8nNHA778YMRamlHRVR++CcXsSXuYBAJ384A06T9C7+MGk dAHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=RE03IV6b; 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 c132-20020a81358a000000b002dc02a06c4esi2774983ywa.517.2022.03.10.04.06.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Mar 2022 04:06:27 -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=RE03IV6b; 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]:33414 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSHYp-0007OG-8X for patch@linaro.org; Thu, 10 Mar 2022 07:06:27 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50802) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSGxR-0005aP-Jd for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:27:49 -0500 Received: from [2607:f8b0:4864:20::1036] (port=34514 helo=mail-pj1-x1036.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nSGxP-0007yF-QC for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:27:49 -0500 Received: by mail-pj1-x1036.google.com with SMTP id k5-20020a17090a3cc500b001befa0d3102so6092030pjd.1 for ; Thu, 10 Mar 2022 03:27:47 -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=GADV/jExPWz+mF0nwm5rQZ+l5e8TEkrJvePYWSdN3A0=; b=RE03IV6b/3dyMzGnR7wG72Vp3/nmdtJZcyuEzlSI82IEs73wUWWmSTNgbwMHzQpDOP ryUM1/Fbj3KbuFfXDm/1N0TPUBP3kW/SyuPrRPyXph/DAaWNQGmk/CbLr5CecRzZlb+8 szr4N2FXhTz7fFegQBo/SP8K/ahvgjzSvAAeMkwQZYqpgAlBWYZdUIDjD51KO0HnvYCI Bwc92zX1c+lj8mErM3CKFDv3+svmiEuxVSQCjOY0WCpyNtufQah+Y/cQP9F6ASBnEIT9 4lxhuyH38B6LiDnCt/nnFAtAfj1Ao9KnfRRyu4JzjTCO3283caHTauIrUurGnEoEoG2Q B2Xw== 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=GADV/jExPWz+mF0nwm5rQZ+l5e8TEkrJvePYWSdN3A0=; b=eVBIPOe25JNT6fL20fPAVD1KW5xHX8sD9v4lMYznnCNmxvGXiZ20yYj5VYe9XtUgyk q9p7Pdp9mlRszyIVqvRIkcmkjYS4GTBNJo6dAPE7rEOmTMXcX1+5c/1HzuqSxjSS3zWq R5M08DpkksHtj4BGQ/p87BVSgARmQwxeNgcKGnyZl1QNnWwgoQgxXDi8W0/D+KV6Ruov l/kTBMz95qrlwQ911Bxz7JoxpsDfQsJWVT3wgYORDDkAOv6Vmsnlu7yoJyo697Vjun9W VT44E7WqmUeoX7/XPC4r0APtgXSBjBagMyTybpPbFiROCBs2ltY6i5pTxwWiE2WIAqBd HnOA== X-Gm-Message-State: AOAM531bFRVjFWV6U0DwSyXj8MoscvT9T57gECDCVE4nPom6XctpN8EH Nc7mCQk2FRxiRpT9cCfMh9Lc6GVmkRNlhA== X-Received: by 2002:a17:902:9a0a:b0:14a:199:bc5c with SMTP id v10-20020a1709029a0a00b0014a0199bc5cmr4424586plp.10.1646911666313; Thu, 10 Mar 2022 03:27:46 -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.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Mar 2022 03:27:45 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 18/48] target/nios2: Use hw/registerfields.h for CR_TLBMISC fields Date: Thu, 10 Mar 2022 03:26:55 -0800 Message-Id: <20220310112725.570053-19-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::1036 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::1036; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1036.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" Use FIELD_EX32 and FIELD_DP32 instead of managing the masking by hand. Signed-off-by: Richard Henderson --- target/nios2/cpu.h | 29 +++++++++++++++++++---------- target/nios2/helper.c | 7 ++----- target/nios2/mmu.c | 35 +++++++++++++++++------------------ target/nios2/translate.c | 2 +- 4 files changed, 39 insertions(+), 34 deletions(-) diff --git a/target/nios2/cpu.h b/target/nios2/cpu.h index 81472be686..7f805a933e 100644 --- a/target/nios2/cpu.h +++ b/target/nios2/cpu.h @@ -131,16 +131,25 @@ FIELD(CR_TLBACC, IG, 25, 7) #define CR_TLBACC_G R_CR_TLBACC_G_MASK #define CR_TLBMISC 10 -#define CR_TLBMISC_WAY_SHIFT 20 -#define CR_TLBMISC_WAY_MASK (0xF << CR_TLBMISC_WAY_SHIFT) -#define CR_TLBMISC_RD (1 << 19) -#define CR_TLBMISC_WE (1 << 18) -#define CR_TLBMISC_PID_SHIFT 4 -#define CR_TLBMISC_PID_MASK (0x3FFF << CR_TLBMISC_PID_SHIFT) -#define CR_TLBMISC_DBL (1 << 3) -#define CR_TLBMISC_BAD (1 << 2) -#define CR_TLBMISC_PERM (1 << 1) -#define CR_TLBMISC_D (1 << 0) + +FIELD(CR_TLBMISC, D, 0, 1) +FIELD(CR_TLBMISC, PERM, 1, 1) +FIELD(CR_TLBMISC, BAD, 2, 1) +FIELD(CR_TLBMISC, DBL, 3, 1) +FIELD(CR_TLBMISC, PID, 4, 14) +FIELD(CR_TLBMISC, WE, 18, 1) +FIELD(CR_TLBMISC, RD, 19, 1) +FIELD(CR_TLBMISC, WAY, 20, 4) +FIELD(CR_TLBMISC, EE, 24, 1) + +#define CR_TLBMISC_EE R_CR_TLBMISC_EE_MASK +#define CR_TLBMISC_RD R_CR_TLBMISC_RD_MASK +#define CR_TLBMISC_WE R_CR_TLBMISC_WE_MASK +#define CR_TLBMISC_DBL R_CR_TLBMISC_DBL_MASK +#define CR_TLBMISC_BAD R_CR_TLBMISC_BAD_MASK +#define CR_TLBMISC_PERM R_CR_TLBMISC_PERM_MASK +#define CR_TLBMISC_D R_CR_TLBMISC_D_MASK + #define CR_ENCINJ 11 #define CR_BADADDR 12 #define CR_CONFIG 13 diff --git a/target/nios2/helper.c b/target/nios2/helper.c index 308d66ad93..52a49f7ead 100644 --- a/target/nios2/helper.c +++ b/target/nios2/helper.c @@ -301,11 +301,8 @@ bool nios2_cpu_tlb_fill(CPUState *cs, vaddr address, int size, return false; } - if (access_type == MMU_INST_FETCH) { - env->ctrl[CR_TLBMISC] &= ~CR_TLBMISC_D; - } else { - env->ctrl[CR_TLBMISC] |= CR_TLBMISC_D; - } + env->ctrl[CR_TLBMISC] = FIELD_DP32(env->ctrl[CR_TLBMISC], CR_TLBMISC, D, + access_type != MMU_INST_FETCH); env->ctrl[CR_PTEADDR] = FIELD_DP32(env->ctrl[CR_PTEADDR], CR_PTEADDR, VPN, address >> TARGET_PAGE_BITS); env->mmu.pteaddr_wr = env->ctrl[CR_PTEADDR]; diff --git a/target/nios2/mmu.c b/target/nios2/mmu.c index 0f33ea5e04..d9b690b78e 100644 --- a/target/nios2/mmu.c +++ b/target/nios2/mmu.c @@ -33,7 +33,7 @@ unsigned int mmu_translate(CPUNios2State *env, target_ulong vaddr, int rw, int mmu_idx) { Nios2CPU *cpu = env_archcpu(env); - int pid = (env->mmu.tlbmisc_wr & CR_TLBMISC_PID_MASK) >> 4; + int pid = FIELD_EX32(env->mmu.tlbmisc_wr, CR_TLBMISC, PID); int vpn = vaddr >> 12; int way, n_ways = cpu->tlb_num_ways; @@ -96,9 +96,9 @@ void helper_mmu_write_tlbacc(CPUNios2State *env, uint32_t v) /* if tlbmisc.WE == 1 then trigger a TLB write on writes to TLBACC */ if (env->ctrl[CR_TLBMISC] & CR_TLBMISC_WE) { - int way = (env->ctrl[CR_TLBMISC] >> CR_TLBMISC_WAY_SHIFT); + int way = FIELD_EX32(env->ctrl[CR_TLBMISC], CR_TLBMISC, WAY); int vpn = FIELD_EX32(env->mmu.pteaddr_wr, CR_PTEADDR, VPN); - int pid = (env->mmu.tlbmisc_wr & CR_TLBMISC_PID_MASK) >> 4; + int pid = FIELD_EX32(env->mmu.tlbmisc_wr, CR_TLBMISC, PID); int g = FIELD_EX32(v, CR_TLBACC, G); int valid = FIELD_EX32(vpn, CR_TLBACC, PFN) < 0xC0000; Nios2TLBEntry *entry = @@ -117,10 +117,9 @@ void helper_mmu_write_tlbacc(CPUNios2State *env, uint32_t v) entry->data = newData; } /* Auto-increment tlbmisc.WAY */ - env->ctrl[CR_TLBMISC] = - (env->ctrl[CR_TLBMISC] & ~CR_TLBMISC_WAY_MASK) | - (((way + 1) & (cpu->tlb_num_ways - 1)) << - CR_TLBMISC_WAY_SHIFT); + env->ctrl[CR_TLBMISC] = FIELD_DP32(env->ctrl[CR_TLBMISC], + CR_TLBMISC, WAY, + (way + 1) & (cpu->tlb_num_ways - 1)); } /* Writes to TLBACC don't change the read-back value */ @@ -130,24 +129,25 @@ void helper_mmu_write_tlbacc(CPUNios2State *env, uint32_t v) void helper_mmu_write_tlbmisc(CPUNios2State *env, uint32_t v) { Nios2CPU *cpu = env_archcpu(env); + uint32_t new_pid = FIELD_EX32(v, CR_TLBMISC, PID); + uint32_t old_pid = FIELD_EX32(env->mmu.tlbmisc_wr, CR_TLBMISC, PID); + uint32_t way = FIELD_EX32(v, CR_TLBMISC, WAY); - trace_nios2_mmu_write_tlbmisc(v >> CR_TLBMISC_WAY_SHIFT, + trace_nios2_mmu_write_tlbmisc(way, (v & CR_TLBMISC_RD) ? 'R' : '.', (v & CR_TLBMISC_WE) ? 'W' : '.', (v & CR_TLBMISC_DBL) ? '2' : '.', (v & CR_TLBMISC_BAD) ? 'B' : '.', (v & CR_TLBMISC_PERM) ? 'P' : '.', (v & CR_TLBMISC_D) ? 'D' : '.', - (v & CR_TLBMISC_PID_MASK) >> 4); + new_pid); - if ((v & CR_TLBMISC_PID_MASK) != - (env->mmu.tlbmisc_wr & CR_TLBMISC_PID_MASK)) { - mmu_flush_pid(env, (env->mmu.tlbmisc_wr & CR_TLBMISC_PID_MASK) >> - CR_TLBMISC_PID_SHIFT); + if (new_pid != old_pid) { + mmu_flush_pid(env, old_pid); } + /* if tlbmisc.RD == 1 then trigger a TLB read on writes to TLBMISC */ if (v & CR_TLBMISC_RD) { - int way = (v >> CR_TLBMISC_WAY_SHIFT); int vpn = FIELD_EX32(env->mmu.pteaddr_wr, CR_PTEADDR, VPN); Nios2TLBEntry *entry = &env->mmu.tlb[(way * cpu->tlb_num_ways) + @@ -156,10 +156,9 @@ void helper_mmu_write_tlbmisc(CPUNios2State *env, uint32_t v) env->ctrl[CR_TLBACC] &= R_CR_TLBACC_IG_MASK; env->ctrl[CR_TLBACC] |= entry->data; env->ctrl[CR_TLBACC] |= (entry->tag & (1 << 11)) ? CR_TLBACC_G : 0; - env->ctrl[CR_TLBMISC] = - (v & ~CR_TLBMISC_PID_MASK) | - ((entry->tag & ((1 << cpu->pid_num_bits) - 1)) << - CR_TLBMISC_PID_SHIFT); + env->ctrl[CR_TLBMISC] = FIELD_DP32(v, CR_TLBMISC, PID, + entry->tag & + ((1 << cpu->pid_num_bits) - 1)); env->ctrl[CR_PTEADDR] = FIELD_DP32(env->ctrl[CR_PTEADDR], CR_PTEADDR, VPN, entry->tag >> TARGET_PAGE_BITS); diff --git a/target/nios2/translate.c b/target/nios2/translate.c index 9b81a2b29e..459e30b338 100644 --- a/target/nios2/translate.c +++ b/target/nios2/translate.c @@ -924,7 +924,7 @@ void nios2_cpu_dump_state(CPUState *cs, FILE *f, int flags) } qemu_fprintf(f, " mmu write: VPN=%05X PID %02X TLBACC %08X\n", env->mmu.pteaddr_wr & R_CR_PTEADDR_VPN_MASK, - (env->mmu.tlbmisc_wr & CR_TLBMISC_PID_MASK) >> 4, + FIELD_EX32(env->mmu.tlbmisc_wr, CR_TLBMISC, PID), env->mmu.tlbacc_wr); #endif qemu_fprintf(f, "\n\n"); From patchwork Thu Mar 10 11:26:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 550108 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp917256mag; Thu, 10 Mar 2022 03:54:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJwLzg9hZyHw+HswtawEoF+pXU0U2lSkdb0OKSHWoIbgCJyh/Zstl0EM0sZKxOOJyIDLW86U X-Received: by 2002:a81:6307:0:b0:2d6:6aee:dc75 with SMTP id x7-20020a816307000000b002d66aeedc75mr3607806ywb.249.1646913268290; Thu, 10 Mar 2022 03:54:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646913268; cv=none; d=google.com; s=arc-20160816; b=o3etSQSJjj3aSMXHQKp8CShTgUdzn3qTNr6BBHFqzxm/S/aKKW6BGwDFLGgl4Wd4Cz h4tjUka8IGQOsQTLmMPdnAy7nNc6K7+/UC8OXbCAJ5HtxgtoYmdl/RIUHSe/wRjPmfEv 8a1iD6A8L5IAh2zqIz3tIIv3Gig9Xr3zgjVDbjoLkCc54OaZg6qCUbRhWWzVBg7hFUot fczpqIBD78VEThRkf3wWiID3fjIA7bpyNabjmBI11m5zP8ShD3QAsNifQWm9pJYYLs9T B2JDEFqb3EqY9bFGL7j/y8xHpkXWc0Ot36KEt4KzwiZ1V0vnhnAKkB6/CYKZPmy9/4da BtYw== 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=e6sq5+VxzJ+iyeBdvkBx4ESzy/gdXULWUf0uyVhwts4=; b=AUbH9FTjmzXe0lTWt88rUzElj+7ZC/44iB7Z0LkFt5SgfoR8re4dMHZDh2Pjffvtd+ r9dRaRnTFZmnjYH0kTduv+CdxzNRJUMxlA+vLf+QRO5iIKvyncpkhDwRr02e8PLQHh6F mZF0kMzzBFhB0rrAKoV3DGLvE1Cr9SNzhV9KTLkrFytj2eIqsek8644fTU7S6sasS8Lp 7n1MsHe4F1/dQypsX3OLnuIcDtaboHaOxVDZz7qkOOWzs+MroQD/edwpc+RgyMp5JlOG eILcQ9SdwJs5RouZl4dLA1NqR8asSddlp0rCaw0vB21EZHRyhNaC/dE4Jtwt3P348x0d EDvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ckV13nbA; 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 r66-20020a818145000000b002dd4191a176si2134989ywf.346.2022.03.10.03.54.28 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Mar 2022 03:54:28 -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=ckV13nbA; 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]:59494 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSHND-00037z-Kq for patch@linaro.org; Thu, 10 Mar 2022 06:54:27 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50818) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSGxS-0005cR-IM for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:27:50 -0500 Received: from [2607:f8b0:4864:20::1031] (port=46034 helo=mail-pj1-x1031.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nSGxQ-0007yV-VT for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:27:50 -0500 Received: by mail-pj1-x1031.google.com with SMTP id m11-20020a17090a7f8b00b001beef6143a8so4944991pjl.4 for ; Thu, 10 Mar 2022 03:27:48 -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=e6sq5+VxzJ+iyeBdvkBx4ESzy/gdXULWUf0uyVhwts4=; b=ckV13nbAONqcjv7XIU0kL0eomQJTYp8RKRCHlrhu6he+2yvYE3j93z33QptmbrQpoe IezDqRCDeABj0npYedzBT877LqywYC7/kE/+CC0JXCCwESg4lqyXXEFLaMsPvL5GYX5j gkiBSmcserLjGcMSYUur+JEvOcv4VKDLqpTOOoA0+5p4xs/YN9IlQR2UeSyZjPBlQWRZ bnLyENDq7Is1kfC8Kuud/4SHWFDuoQIj94AfsNbao/fFoc8cGTpVtSxKWUqi+VCPhc+V YbUJJv449CMjG/BSnZEoB7sf0vD9fczIuUaQBiMekxuJdgOpKDps2UDwTGn0IE8a/1HU MTrg== 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=e6sq5+VxzJ+iyeBdvkBx4ESzy/gdXULWUf0uyVhwts4=; b=rxmIOAftXctnoiDvxbo8Jra6F6UWJSr1OW0ZCuBEmHcJmN4Nni8ZcI3mMRsgJpWE0T xHt1MR2KYrhPq2btIW88Wn2B1FOwymyA450RPOoDWdRl+dIm8sqcBI9j/urMaNhRFw9e e3ZfGHICCzSLiWu6bFxdWq77AJjLtTwROoPin/JYr6mbVjbOi0vUqR+rdAT5pyDw4T14 ISyCOEz3WCVAqFBam7pYgmPnTl50rGZRnkkK28vDiXtmOTDYCRgf/d/TZEoUl/pgKFHH dTkrqfm6bUCYgHvbr7OYB6Sr0R2OqUUk0WR2f+ofF62AdA8O9ip5On0VEm0Za9uFqcG5 IJ2g== X-Gm-Message-State: AOAM531Zn5tfSuDpPp1zTvN4R5VAvJrRgSFxg0xjQSFrDQU8QkgeW273 nkXxmBq2mpWseTvBEDFpxtPao5YCLRbxbQ== X-Received: by 2002:a17:902:d482:b0:151:ef7f:f5aa with SMTP id c2-20020a170902d48200b00151ef7ff5aamr4456489plg.58.1646911667698; Thu, 10 Mar 2022 03:27:47 -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.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Mar 2022 03:27:47 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 19/48] target/nios2: Move R_FOO and CR_BAR into enumerations Date: Thu, 10 Mar 2022 03:26:56 -0800 Message-Id: <20220310112725.570053-20-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::1031 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::1031; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1031.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, UPPERCASE_50_75=0.008 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" These symbols become available to the debugger. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/nios2/cpu.h | 72 ++++++++++++++++++++++------------------------ 1 file changed, 35 insertions(+), 37 deletions(-) diff --git a/target/nios2/cpu.h b/target/nios2/cpu.h index 7f805a933e..555972fe6b 100644 --- a/target/nios2/cpu.h +++ b/target/nios2/cpu.h @@ -61,25 +61,43 @@ struct Nios2CPUClass { #define NUM_CR_REGS 32 /* General purpose register aliases */ -#define R_ZERO 0 -#define R_AT 1 -#define R_RET0 2 -#define R_RET1 3 -#define R_ARG0 4 -#define R_ARG1 5 -#define R_ARG2 6 -#define R_ARG3 7 -#define R_ET 24 -#define R_BT 25 -#define R_GP 26 -#define R_SP 27 -#define R_FP 28 -#define R_EA 29 -#define R_BA 30 -#define R_RA 31 +enum { + R_ZERO = 0, + R_AT = 1, + R_RET0 = 2, + R_RET1 = 3, + R_ARG0 = 4, + R_ARG1 = 5, + R_ARG2 = 6, + R_ARG3 = 7, + R_ET = 24, + R_BT = 25, + R_GP = 26, + R_SP = 27, + R_FP = 28, + R_EA = 29, + R_BA = 30, + R_RA = 31, +}; /* Control register aliases */ -#define CR_STATUS 0 +enum { + CR_STATUS = 0, + CR_ESTATUS = 1, + CR_BSTATUS = 2, + CR_IENABLE = 3, + CR_IPENDING = 4, + CR_CPUID = 5, + CR_EXCEPTION = 7, + CR_PTEADDR = 8, + CR_TLBACC = 9, + CR_TLBMISC = 10, + CR_ENCINJ = 11, + CR_BADADDR = 12, + CR_CONFIG = 13, + CR_MPUBASE = 14, + CR_MPUACC = 15, +}; FIELD(CR_STATUS, PIE, 0, 1) FIELD(CR_STATUS, U, 1, 1) @@ -98,24 +116,12 @@ FIELD(CR_STATUS, RSIE, 23, 1) #define CR_STATUS_NMI R_CR_STATUS_NMI_MASK #define CR_STATUS_RSIE R_CR_STATUS_RSIE_MASK -#define CR_ESTATUS 1 -#define CR_BSTATUS 2 -#define CR_IENABLE 3 -#define CR_IPENDING 4 -#define CR_CPUID 5 -#define CR_CTL6 6 -#define CR_EXCEPTION 7 - FIELD(CR_EXCEPTION, CAUSE, 2, 5) FIELD(CR_EXCEPTION, ECCFTL, 31, 1) -#define CR_PTEADDR 8 - FIELD(CR_PTEADDR, VPN, 2, 20) FIELD(CR_PTEADDR, PTBASE, 22, 10) -#define CR_TLBACC 9 - FIELD(CR_TLBACC, PFN, 0, 20) FIELD(CR_TLBACC, G, 20, 1) FIELD(CR_TLBACC, X, 21, 1) @@ -130,8 +136,6 @@ FIELD(CR_TLBACC, IG, 25, 7) #define CR_TLBACC_X R_CR_TLBACC_X_MASK #define CR_TLBACC_G R_CR_TLBACC_G_MASK -#define CR_TLBMISC 10 - FIELD(CR_TLBMISC, D, 0, 1) FIELD(CR_TLBMISC, PERM, 1, 1) FIELD(CR_TLBMISC, BAD, 2, 1) @@ -150,12 +154,6 @@ FIELD(CR_TLBMISC, EE, 24, 1) #define CR_TLBMISC_PERM R_CR_TLBMISC_PERM_MASK #define CR_TLBMISC_D R_CR_TLBMISC_D_MASK -#define CR_ENCINJ 11 -#define CR_BADADDR 12 -#define CR_CONFIG 13 -#define CR_MPUBASE 14 -#define CR_MPUACC 15 - /* Exceptions */ #define EXCP_BREAK 0x1000 #define EXCP_RESET 0 From patchwork Thu Mar 10 11:26:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 550110 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp919304mag; Thu, 10 Mar 2022 03:57:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJzq3xDg794vnTXQQ0xhvxg5ZkTTVRO7Mq3ZYvpTUBBf5tCZFP4rgQWLbI2shUHnewZqKrCq X-Received: by 2002:a81:a055:0:b0:2dc:5771:1c4e with SMTP id x82-20020a81a055000000b002dc57711c4emr3448738ywg.351.1646913452691; Thu, 10 Mar 2022 03:57:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646913452; cv=none; d=google.com; s=arc-20160816; b=vv9ROlFk3DeBhlTOZadXytt+hNtwKzeIR7Q/9iuccX51IftjKDG3kR/FqtwtsoS7te KB8XfSvriRjpIuxY52MYLsujoItwtiiIRBA6F0K4So8JXeMdIpWd9nq4TmUqokv093YN hrFg5Zu3rlnryXJ0PuIOHXLp7HNICxz4/EBDgIjQoeJgFXB45Nr5Nm7wcCg317aPv8uU M7LzokK4JfMpTlfYJzrZiaQ9difOKgHrNaTMVizcpgsLCJNmTHJLc1La3M+Cl5h3Q3YY vY5cBchItmNQ+3ndhlZD28DquUg2KheSrkkYqtiol4u/Zq5LHcGk7HNvbHpTJ5ztJs22 APkA== 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=62d8othJIfgAKm86Avncs/clZTnNTHcuD30Oj5z4NnM=; b=My6DFbWkB4IGLgUW7wSuqXR3Uo26gT3tUQSX64L3Rj0DhZVK/UPInF1KSHKmdpgUOk bTWSkslVt9aRrOFhxlhEJScJ+yr/CsvIyqnSKYoHiSf5H9zQFGGILoAYvQkVz99Bpb// Ik4nNqcpbUgi+mnqZavrnvNMRU/ulc+UvLkM7+qrdIDOQCAO6WOm2LY1ICusJWyqfGX3 RIF6Qc0BxK03w3ii/tnx60XdL0EdacTKiU6F1ns79EdKNfNzGF1Yybb+6cWfTQUxL4nb spgOi2JvcWXddlCMZMcN3ThXcqc5XGroKPEJ2DCIRdqudE/sMK/F4pv+odfO+1EvKV5N h5Xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Js6I3+tl; 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 188-20020a8117c5000000b002dc08d98021si2628560ywx.28.2022.03.10.03.57.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Mar 2022 03:57:32 -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=Js6I3+tl; 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]:39474 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSHQC-0000U4-72 for patch@linaro.org; Thu, 10 Mar 2022 06:57:32 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50832) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSGxT-0005fI-Jb for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:27:51 -0500 Received: from [2607:f8b0:4864:20::102f] (port=34508 helo=mail-pj1-x102f.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nSGxR-0007yn-UL for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:27:51 -0500 Received: by mail-pj1-x102f.google.com with SMTP id k5-20020a17090a3cc500b001befa0d3102so6092114pjd.1 for ; Thu, 10 Mar 2022 03:27:49 -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=62d8othJIfgAKm86Avncs/clZTnNTHcuD30Oj5z4NnM=; b=Js6I3+tl4MgfPZk/1FQAe90hI3aIBtY49Q94ebm322DRaLmAJ9Ksyvtr7dURWTgy1P ARrvEyba6AnWjQYuBuvyUzJISjkldJE+69zTgZxCX7bbmlGTwo+XVGhEtL89OJ2stAU2 7fp6u5vcAzDSBG0Uv6aBjSlamlT0BqBxWJGH2vImsMfbqKzVOp6s/2Js7u5OBzk4wlBO tf9Nqqs3wkCK75/xHbfK9sr8ec7+ZJBUwVXfBVmMDM9ZQS2/Kcb7UJIZaQ4+an0j1DYD wTjPl3pUeyBS8bWTalptZPBFtF2Attf2deUY28E8Wrp9g5zId1C0TcEaerCnd9R9hrVj +z0g== 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=62d8othJIfgAKm86Avncs/clZTnNTHcuD30Oj5z4NnM=; b=0t5SB9rqR+9n8DeFJc8ODFm11ZcPeekge2UXgPcLeV4kMLfcvwuWEVShRmtrodQRen mUzfepf1fWUNY0msKxaO/Hjk185E0UslC7vPODt/PhHrkCA/DMhjNdh53bxZyLNjXacE sQ7W6QY66fspZHohqFx/d4+ATFoPcK5nh+9Zr5hNRDIu8NmbEGz91GZbzmSCaISPiJS5 BQU3q8FFueNUtBEbAK63TBtGIXAHzEcE+VHobFyJTSwit3entJOflC+mvXLJE0dR/kcL nYWHw9BOzwdcTg6p9FN98XhzlgG0Dje1lmc64A8mlNj4hUnUvBmTYvscu8j0gzTpZ6sb DDpw== X-Gm-Message-State: AOAM531uuOBK4KNelF9A6EZsBcRFVFIk8ZaUU6aZeD6awhIvDcd6XWA6 9kW/WlStRI+DifkAl4rihadz2hYq/37o7g== X-Received: by 2002:a17:902:c40a:b0:151:a792:71f2 with SMTP id k10-20020a170902c40a00b00151a79271f2mr4631360plk.36.1646911668699; Thu, 10 Mar 2022 03:27:48 -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.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Mar 2022 03:27:48 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 20/48] target/nios2: Create EXCP_SEMIHOST for semi-hosting Date: Thu, 10 Mar 2022 03:26:57 -0800 Message-Id: <20220310112725.570053-21-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::102f (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::102f; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102f.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" Decode 'break 1' during translation, rather than doing it again during exception processing. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/nios2/cpu.h | 1 + target/nios2/helper.c | 14 ++++++-------- target/nios2/translate.c | 17 ++++++++++++++++- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/target/nios2/cpu.h b/target/nios2/cpu.h index 555972fe6b..d003af5afc 100644 --- a/target/nios2/cpu.h +++ b/target/nios2/cpu.h @@ -156,6 +156,7 @@ FIELD(CR_TLBMISC, EE, 24, 1) /* Exceptions */ #define EXCP_BREAK 0x1000 +#define EXCP_SEMIHOST 0x1001 #define EXCP_RESET 0 #define EXCP_PRESET 1 #define EXCP_IRQ 2 diff --git a/target/nios2/helper.c b/target/nios2/helper.c index 52a49f7ead..eeff032379 100644 --- a/target/nios2/helper.c +++ b/target/nios2/helper.c @@ -172,14 +172,6 @@ void nios2_cpu_do_interrupt(CPUState *cs) case EXCP_BREAK: qemu_log_mask(CPU_LOG_INT, "BREAK exception at pc=%x\n", env->pc); - /* The semihosting instruction is "break 1". */ - if (semihosting_enabled() && - cpu_ldl_code(env, env->pc) == 0x003da07a) { - qemu_log_mask(CPU_LOG_INT, "Entering semihosting\n"); - env->pc += 4; - do_nios2_semihosting(env); - break; - } if ((env->ctrl[CR_STATUS] & CR_STATUS_EH) == 0) { env->ctrl[CR_BSTATUS] = env->ctrl[CR_STATUS]; @@ -196,6 +188,12 @@ void nios2_cpu_do_interrupt(CPUState *cs) env->pc = cpu->exception_addr; break; + case EXCP_SEMIHOST: + qemu_log_mask(CPU_LOG_INT, "BREAK semihosting at pc=%x\n", env->pc); + env->pc += 4; + do_nios2_semihosting(env); + break; + default: cpu_abort(cs, "unhandled exception type=%d\n", cs->exception_index); diff --git a/target/nios2/translate.c b/target/nios2/translate.c index 459e30b338..cfad110186 100644 --- a/target/nios2/translate.c +++ b/target/nios2/translate.c @@ -33,6 +33,7 @@ #include "exec/translator.h" #include "qemu/qemu-print.h" #include "exec/gen-icount.h" +#include "semihosting/semihost.h" /* is_jmp field values */ #define DISAS_JUMP DISAS_TARGET_0 /* only pc was modified dynamically */ @@ -686,6 +687,20 @@ static void trap(DisasContext *dc, uint32_t code, uint32_t flags) t_gen_helper_raise_exception(dc, EXCP_TRAP); } +static void gen_break(DisasContext *dc, uint32_t code, uint32_t flags) +{ +#ifndef CONFIG_USER_ONLY + /* The semihosting instruction is "break 1". */ + R_TYPE(instr, code); + if (semihosting_enabled() && instr.imm5 == 1) { + t_gen_helper_raise_exception(dc, EXCP_SEMIHOST); + return; + } +#endif + + t_gen_helper_raise_exception(dc, EXCP_BREAK); +} + static const Nios2Instruction r_type_instructions[] = { INSTRUCTION_ILLEGAL(), INSTRUCTION(eret), /* eret */ @@ -739,7 +754,7 @@ static const Nios2Instruction r_type_instructions[] = { INSTRUCTION(add), /* add */ INSTRUCTION_ILLEGAL(), INSTRUCTION_ILLEGAL(), - INSTRUCTION_FLG(gen_excp, EXCP_BREAK), /* break */ + INSTRUCTION(gen_break), /* break */ INSTRUCTION_ILLEGAL(), INSTRUCTION(nop), /* nop */ INSTRUCTION_ILLEGAL(), From patchwork Thu Mar 10 11:26:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 550111 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp919421mag; Thu, 10 Mar 2022 03:57:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJyPjW2S+cu7/0iNP3HOmhZry1F2Oz+ZweH7HcwcAhLkUly7Oz1S34JrCjGysUAek5nav1A7 X-Received: by 2002:a81:a005:0:b0:2db:f425:3dd2 with SMTP id x5-20020a81a005000000b002dbf4253dd2mr3535046ywg.269.1646913463338; Thu, 10 Mar 2022 03:57:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646913463; cv=none; d=google.com; s=arc-20160816; b=yJk525xdphA6ohK4UdpHhLX2FHgVMj2bTdSLVtYt/ndV++nn2CZJYALEXWW60QxL10 PPN9nTznwayyu1dvnhb0UxVBNrEX7hC2B5YogP3V0pM89eHWZGYf8TGIRD9xAvg5Qn76 ZtUIE7pTXbeXiMnbo+i5poQ5nKu9PNRQNFZa75rtDOza06Cm800qftABo4q9mKx2lGPJ urx7COnHF2zJ41d4272YEJidBghz0QnwUiy1cioHzITDS0f8ZkmcFfl6+qI616d6Yu6h 58LbjHhNiSiDQS8ohAVBIHzcLGWI2KWoJTpVaOFmSRAK83ZjHxthjutKro9VjG9wPtMV VkdQ== 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=rza+S9dP6OxTxmW7BN1PpFg5SK23R8f/DSGJ4keNmyI=; b=X8evtR9oq1xjRYep/Jd9/oG3HsSTmHJ/yMCx6NIF2LIbG1bl4JvU6hAFeYG1bRRph7 xI+HAyGD6zUkxDcbO4xYgLRohjMSykUXawrZ+sifURG6aU25QMXKvxrdN3D1/93GQ4Sc GsPbfo9bOw/3dpPUGR9gHyDo1TaciIdNuVym5VCXvS+TehboSbRA++uvqBn/m/qbohiV TH4aAHJxiRjj7xBuToNi+Kx8O1SI6RfFk9C93UNU5bojj++nvax/tOm6S6JSnLgqMoBE YiWWSosMX3qgMMgvWw5OhzzUN4aAQ+xtDdpI4/wIPeUjp4qgyDZo07FltzMQotwjvIBD MP6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=CNrSCPn8; 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 m204-20020a8158d5000000b002dca4e39ff9si2470794ywb.420.2022.03.10.03.57.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Mar 2022 03:57:43 -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=CNrSCPn8; 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]:40110 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSHQM-0000uT-PO for patch@linaro.org; Thu, 10 Mar 2022 06:57:42 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50852) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSGxV-0005iw-2f for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:27:53 -0500 Received: from [2607:f8b0:4864:20::630] (port=33540 helo=mail-pl1-x630.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nSGxT-0007z0-71 for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:27:52 -0500 Received: by mail-pl1-x630.google.com with SMTP id m2so4642307pll.0 for ; Thu, 10 Mar 2022 03:27:50 -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=rza+S9dP6OxTxmW7BN1PpFg5SK23R8f/DSGJ4keNmyI=; b=CNrSCPn850CBlkthbD1oNj9qQdzV15JoyNkOrxknFIqBWArr+h9n+JEe+fTQsrh8ty JhaBUKiMEwGR50NYBgvXViqhh4aUjFIdStI6CO63d2Pzrp0qK2Ph4Jm3LeKG+WpXxSn3 0vXYOHcCmC8Bwtp3wQTf9AdvTsfgYb+6If861AFwn1JQTXuMT3M+dsSg8k0ZCA77yWHO FO/AAqJ/AcLxqDnMnaGdHSVL/qoni56b7w+Az41T4GKRhe7QYQgl9+8nQBZo1ynonwn9 kPBBPSmR6rqdQUV8cAG3kBpI0Kq9a0TAFMEgt4vY2lWVL23paHw9kOrH7c+YfvWQ9PeL 2Z9A== 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=rza+S9dP6OxTxmW7BN1PpFg5SK23R8f/DSGJ4keNmyI=; b=uTHqZ/uIcjh2TLhrAbz9/q2n7u8fwjSi/sRlr50cO7gk/xGkhwtnHewZjNNjPCM0Bu LvxD+f/T7G1lCxmRr733V58mYBRjy7TA92/gRaXqhM1jjCbD7orjm/mbJOHHIzl5Zyiw AZ9Lrvtq7IEp+gzynIn5HvlzooqoJy/vWWa/JCKpkM9N+FxZIUawdjCcwaEYrlj/SGaT 21MG0ZdQiiKNH5ojjhIDNXwevjTc6vdLxbZ8iPzLQC2EfQfjcU//cgZlX3LODzXQ1xw3 t4jt73aZHZED/yRiX0yfFENLnn7THdCXaMrexm/AGR6Z0095Ao4Cmqif7nzJrfTviv9m +ygw== X-Gm-Message-State: AOAM531w8tYqWKa2BlZlcpOqAEsZfHWcfPnxiu83m2raxTvXAoRX1BzO /bLOiPh1xQHTtBZHEGbzrCIErPWTE7TxOw== X-Received: by 2002:a17:902:9308:b0:14e:def5:e6b5 with SMTP id bc8-20020a170902930800b0014edef5e6b5mr4490447plb.73.1646911669835; Thu, 10 Mar 2022 03:27:49 -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.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Mar 2022 03:27:49 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 21/48] target/nios2: Clean up nios2_cpu_do_interrupt Date: Thu, 10 Mar 2022 03:26:58 -0800 Message-Id: <20220310112725.570053-22-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::630 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::630; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x630.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" Split out do_exception and do_iic_irq to handle bulk of the interrupt and exception processing. Parameterize the changes required to cpu state. The status.EH bit, which protects some data against double-faults, is only present with the MMU. Several exception cases did not check for status.EH being set, as required. The status.IH bit, which had been set by EXCP_IRQ, is exclusive to the external interrupt controller, which we do not yet implement. The internal interrupt controller, when the MMU is also present, sets the status.EH bit. Signed-off-by: Richard Henderson --- target/nios2/helper.c | 141 +++++++++++++----------------------------- 1 file changed, 44 insertions(+), 97 deletions(-) diff --git a/target/nios2/helper.c b/target/nios2/helper.c index eeff032379..6019e2443b 100644 --- a/target/nios2/helper.c +++ b/target/nios2/helper.c @@ -49,6 +49,42 @@ void nios2_cpu_record_sigsegv(CPUState *cs, vaddr addr, #else /* !CONFIG_USER_ONLY */ +static void do_exception(Nios2CPU *cpu, uint32_t exception_addr, bool is_break) +{ + CPUNios2State *env = &cpu->env; + CPUState *cs = CPU(cpu); + uint32_t old_status = env->ctrl[CR_STATUS]; + uint32_t new_status = old_status; + + if ((old_status & CR_STATUS_EH) == 0) { + int r_ea = R_EA, cr_es = CR_ESTATUS; + + if (is_break) { + r_ea = R_BA; + cr_es = CR_BSTATUS; + } + env->ctrl[cr_es] = old_status; + env->regs[r_ea] = env->pc + 4; + + if (cpu->mmu_present) { + new_status |= CR_STATUS_EH; + } + } + + new_status &= ~(CR_STATUS_PIE | CR_STATUS_U); + + env->ctrl[CR_STATUS] = new_status; + env->ctrl[CR_EXCEPTION] = FIELD_DP32(env->ctrl[CR_EXCEPTION], + CR_EXCEPTION, CAUSE, + cs->exception_index); + env->pc = exception_addr; +} + +static void do_iic_irq(Nios2CPU *cpu) +{ + do_exception(cpu, cpu->exception_addr, false); +} + void nios2_cpu_do_interrupt(CPUState *cs) { Nios2CPU *cpu = NIOS2_CPU(cs); @@ -56,57 +92,20 @@ void nios2_cpu_do_interrupt(CPUState *cs) switch (cs->exception_index) { case EXCP_IRQ: - assert(env->ctrl[CR_STATUS] & CR_STATUS_PIE); - qemu_log_mask(CPU_LOG_INT, "interrupt at pc=%x\n", env->pc); - - env->ctrl[CR_ESTATUS] = env->ctrl[CR_STATUS]; - env->ctrl[CR_STATUS] |= CR_STATUS_IH; - env->ctrl[CR_STATUS] &= ~(CR_STATUS_PIE | CR_STATUS_U); - - env->ctrl[CR_EXCEPTION] = FIELD_DP32(env->ctrl[CR_EXCEPTION], - CR_EXCEPTION, CAUSE, - cs->exception_index); - - env->regs[R_EA] = env->pc + 4; - env->pc = cpu->exception_addr; + do_iic_irq(cpu); break; case EXCP_TLBD: if ((env->ctrl[CR_STATUS] & CR_STATUS_EH) == 0) { qemu_log_mask(CPU_LOG_INT, "TLB MISS (fast) at pc=%x\n", env->pc); - - /* Fast TLB miss */ - /* Variation from the spec. Table 3-35 of the cpu reference shows - * estatus not being changed for TLB miss but this appears to - * be incorrect. */ - env->ctrl[CR_ESTATUS] = env->ctrl[CR_STATUS]; - env->ctrl[CR_STATUS] |= CR_STATUS_EH; - env->ctrl[CR_STATUS] &= ~(CR_STATUS_PIE | CR_STATUS_U); - - env->ctrl[CR_EXCEPTION] = FIELD_DP32(env->ctrl[CR_EXCEPTION], - CR_EXCEPTION, CAUSE, - cs->exception_index); - env->ctrl[CR_TLBMISC] &= ~CR_TLBMISC_DBL; env->ctrl[CR_TLBMISC] |= CR_TLBMISC_WE; - - env->regs[R_EA] = env->pc + 4; - env->pc = cpu->fast_tlb_miss_addr; + do_exception(cpu, cpu->fast_tlb_miss_addr, false); } else { qemu_log_mask(CPU_LOG_INT, "TLB MISS (double) at pc=%x\n", env->pc); - - /* Double TLB miss */ - env->ctrl[CR_STATUS] |= CR_STATUS_EH; - env->ctrl[CR_STATUS] &= ~(CR_STATUS_PIE | CR_STATUS_U); - - env->ctrl[CR_EXCEPTION] = FIELD_DP32(env->ctrl[CR_EXCEPTION], - CR_EXCEPTION, CAUSE, - cs->exception_index); - env->ctrl[CR_TLBMISC] |= CR_TLBMISC_DBL; - - env->pc = cpu->exception_addr; + do_exception(cpu, cpu->exception_addr, false); } break; @@ -114,78 +113,28 @@ void nios2_cpu_do_interrupt(CPUState *cs) case EXCP_TLBW: case EXCP_TLBX: qemu_log_mask(CPU_LOG_INT, "TLB PERM at pc=%x\n", env->pc); - - env->ctrl[CR_ESTATUS] = env->ctrl[CR_STATUS]; - env->ctrl[CR_STATUS] |= CR_STATUS_EH; - env->ctrl[CR_STATUS] &= ~(CR_STATUS_PIE | CR_STATUS_U); - - env->ctrl[CR_EXCEPTION] = FIELD_DP32(env->ctrl[CR_EXCEPTION], - CR_EXCEPTION, CAUSE, - cs->exception_index); - if ((env->ctrl[CR_STATUS] & CR_STATUS_EH) == 0) { env->ctrl[CR_TLBMISC] |= CR_TLBMISC_WE; } - - env->regs[R_EA] = env->pc + 4; - env->pc = cpu->exception_addr; + do_exception(cpu, cpu->exception_addr, false); break; case EXCP_SUPERA: case EXCP_SUPERI: case EXCP_SUPERD: qemu_log_mask(CPU_LOG_INT, "SUPERVISOR exception at pc=%x\n", env->pc); - - if ((env->ctrl[CR_STATUS] & CR_STATUS_EH) == 0) { - env->ctrl[CR_ESTATUS] = env->ctrl[CR_STATUS]; - env->regs[R_EA] = env->pc + 4; - } - - env->ctrl[CR_STATUS] |= CR_STATUS_EH; - env->ctrl[CR_STATUS] &= ~(CR_STATUS_PIE | CR_STATUS_U); - - env->ctrl[CR_EXCEPTION] = FIELD_DP32(env->ctrl[CR_EXCEPTION], - CR_EXCEPTION, CAUSE, - cs->exception_index); - - env->pc = cpu->exception_addr; + do_exception(cpu, cpu->exception_addr, false); break; case EXCP_ILLEGAL: case EXCP_TRAP: qemu_log_mask(CPU_LOG_INT, "TRAP exception at pc=%x\n", env->pc); - - if ((env->ctrl[CR_STATUS] & CR_STATUS_EH) == 0) { - env->ctrl[CR_ESTATUS] = env->ctrl[CR_STATUS]; - env->regs[R_EA] = env->pc + 4; - } - - env->ctrl[CR_STATUS] |= CR_STATUS_EH; - env->ctrl[CR_STATUS] &= ~(CR_STATUS_PIE | CR_STATUS_U); - - env->ctrl[CR_EXCEPTION] = FIELD_DP32(env->ctrl[CR_EXCEPTION], - CR_EXCEPTION, CAUSE, - cs->exception_index); - - env->pc = cpu->exception_addr; + do_exception(cpu, cpu->exception_addr, false); break; case EXCP_BREAK: qemu_log_mask(CPU_LOG_INT, "BREAK exception at pc=%x\n", env->pc); - - if ((env->ctrl[CR_STATUS] & CR_STATUS_EH) == 0) { - env->ctrl[CR_BSTATUS] = env->ctrl[CR_STATUS]; - env->regs[R_BA] = env->pc + 4; - } - - env->ctrl[CR_STATUS] |= CR_STATUS_EH; - env->ctrl[CR_STATUS] &= ~(CR_STATUS_PIE | CR_STATUS_U); - - env->ctrl[CR_EXCEPTION] = FIELD_DP32(env->ctrl[CR_EXCEPTION], - CR_EXCEPTION, CAUSE, - cs->exception_index); - - env->pc = cpu->exception_addr; + do_exception(cpu, cpu->exception_addr, true); break; case EXCP_SEMIHOST: @@ -195,9 +144,7 @@ void nios2_cpu_do_interrupt(CPUState *cs) break; default: - cpu_abort(cs, "unhandled exception type=%d\n", - cs->exception_index); - break; + cpu_abort(cs, "unhandled exception type=%d\n", cs->exception_index); } } From patchwork Thu Mar 10 11:26:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 550114 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp921457mag; Thu, 10 Mar 2022 04:00:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJz1CHU6S//UR8o+FzN+bg+S0yTABW0dCBcG19q04CC+4qg9ONBSs8eKWlMC7suM5KMFsxLW X-Received: by 2002:a25:403:0:b0:628:920b:155c with SMTP id 3-20020a250403000000b00628920b155cmr3659285ybe.377.1646913639455; Thu, 10 Mar 2022 04:00:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646913639; cv=none; d=google.com; s=arc-20160816; b=WD76Juzz/CSqsesp0L40K0Wv73kjgINXe0/QMxaR4lciOpTS/AmLVz0zmQ47K1jTyi oiP/SH91gnzVTXr0aF2VB3vYBR/PLDceutYiMxLXNhw05oiwlsVD5ADAu4HzSHaDNbQo J7d/HElC5uyPEz3Z3sTv2PKqPvRXwvLDVth9KhKVIF2JLceFmbqPZAQEVuF/oT1UyoHP 0J8xZ1GtXIXBwfGKcpO0unT3weeuCpZijMbNQCnAg+CPl9W1EoKWeTMsX13+CE3OB89u 24qPnCdiDV5TTFTLITcYUkjTfyqSWN5PpjSdhXfW/heJXnppjhgTPTuuiZv5vlXHOniK BElA== 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=CrZNI1SxmaS+Q1Ja/qtDT6B5V9ddvf4cp0nG/uUGkSI=; b=gEceNSaPI8DKVwRKRDYFDKJsl1UwI1LahmX/nvwbSy3iG+uO/ILU5Ode+Asj8WIbG4 BW51omNLUNMMA1KUD/0lhWepmP8v+YW8V8HQsHNYprHFVP1JdVzxrDdkr78+wX8FPIJf 8T+BHkGrVdV1vYJPKEgFQs3i/y3kAT988al4uoXFJ3BJ3N7oh+qEHL0pbO7j1B8IfEt4 +HIG3JcMxSwXJzfIXnQ4FQtPz8n9Dv01X4GMr9Pn9p0IY7C1PEV17hG2k2DBkU31GHaT iOyMXyr1OJ47EPLU4o4Yo88xs1TjcND4V24WbfQ6FiGNDVbAME704+V6QC+1tKXbADQA nzfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=vYrEtOkZ; 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 e65-20020a25d344000000b006294876653dsi3373456ybf.474.2022.03.10.04.00.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Mar 2022 04:00:39 -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=vYrEtOkZ; 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]:48524 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSHTC-0006h6-Tm for patch@linaro.org; Thu, 10 Mar 2022 07:00:38 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50858) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSGxV-0005kO-TO for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:27:53 -0500 Received: from [2607:f8b0:4864:20::102f] (port=56234 helo=mail-pj1-x102f.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nSGxU-0007zH-AD for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:27:53 -0500 Received: by mail-pj1-x102f.google.com with SMTP id e3so4812671pjm.5 for ; Thu, 10 Mar 2022 03:27:51 -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=CrZNI1SxmaS+Q1Ja/qtDT6B5V9ddvf4cp0nG/uUGkSI=; b=vYrEtOkZvnsHvUObs23VxdT1EAqQKFFhCaHLdLJn540Cz4BByKl70igKU5xKjPk9AE VMBIzgJcTSEwOOIi6Wy6DyU8wVt96Hxye3Q70uaOnnAFMtISzwaustld1rpfAUhKwNKD 0JAr2xIM/SaofA2XXLR1JWepPRjyW6bpQQafKPfdUFVInQ7HrwS16Xb+2I/zLtKh640Z vlcbsc200a4DnoIpL+c11XcSew5x+QEUiTNAp7DFhsvmVqA2PAepziQTKk5yUullIkFs meZdpaBFfI6OIbd2oDtsencypQlXYhw89rBbfaebXM0QIYpyaC6yawKPel6dvJ00amkX rJuA== 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=CrZNI1SxmaS+Q1Ja/qtDT6B5V9ddvf4cp0nG/uUGkSI=; b=C1pNl7ri2W9k6SX9RLXhm2G0hR7HDEec+2KyI6GJNHA6SVMJ5uDNqRUfoDduH2ZoDL 2oCPiVJf6qdxdV6fSCAOxumZy3HR+iZzuew/7LrWN8YlvsZO6zLcycD4BhNysdotHcwu zkIq2YV4182qX8Vju0uyr9wkqXfL8/Tdp3olBuyChtQTKmrmCurasmYis78Eqzrt8XH5 DleOKnNIMEGmGEBaWNgc/+ZTBDr1NARuHiTEpuKOclxLvci2ADR1S1DDsf0txadZIbTr vaAUcqiNK+R9crwcgDrdO25JZQcWxKPU+W1tQ1QfnfUMlRmtg+JcYV5F5zJZvemJo7ic j9yA== X-Gm-Message-State: AOAM530kqcv7+Ue0L4qUikg9D97Zopr/3bIJ3FoCtO6Ftzo7oj1/kqZ4 xb/qbt64TgayTzyff9pHNseLa0hNzvYSLw== X-Received: by 2002:a17:902:e74e:b0:151:c46f:6e18 with SMTP id p14-20020a170902e74e00b00151c46f6e18mr4491481plf.32.1646911670987; Thu, 10 Mar 2022 03:27:50 -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.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Mar 2022 03:27:50 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 22/48] target/nios2: Hoist CPU_LOG_INT logging Date: Thu, 10 Mar 2022 03:26:59 -0800 Message-Id: <20220310112725.570053-23-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::102f (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::102f; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102f.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" Performing this early means that we can merge more cases within the non-logging switch statement. Signed-off-by: Richard Henderson --- target/nios2/helper.c | 58 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 47 insertions(+), 11 deletions(-) diff --git a/target/nios2/helper.c b/target/nios2/helper.c index 6019e2443b..285f3aae1d 100644 --- a/target/nios2/helper.c +++ b/target/nios2/helper.c @@ -90,20 +90,64 @@ void nios2_cpu_do_interrupt(CPUState *cs) Nios2CPU *cpu = NIOS2_CPU(cs); CPUNios2State *env = &cpu->env; + if (qemu_loglevel_mask(CPU_LOG_INT)) { + const char *name = NULL; + + switch (cs->exception_index) { + case EXCP_IRQ: + name = "interrupt"; + break; + case EXCP_TLBD: + if (env->ctrl[CR_STATUS] & CR_STATUS_EH) { + name = "TLB MISS (double)"; + } else { + name = "TLB MISS (fast)"; + } + break; + case EXCP_TLBR: + case EXCP_TLBW: + case EXCP_TLBX: + name = "TLB PERM"; + break; + case EXCP_SUPERA: + case EXCP_SUPERD: + name = "SUPERVISOR (address)"; + break; + case EXCP_SUPERI: + name = "SUPERVISOR (insn)"; + break; + case EXCP_ILLEGAL: + name = "ILLEGAL insn"; + break; + case EXCP_TRAP: + name = "TRAP insn"; + break; + case EXCP_BREAK: + name = "TRAP insn"; + break; + case EXCP_SEMIHOST: + name = "SEMIHOST insn"; + break; + } + if (name) { + qemu_log("%s at pc=0x%08x\n", name, env->pc); + } else { + qemu_log("Unknown exception %d at pc=0x%08x\n", + cs->exception_index, env->pc); + } + } + switch (cs->exception_index) { case EXCP_IRQ: - qemu_log_mask(CPU_LOG_INT, "interrupt at pc=%x\n", env->pc); do_iic_irq(cpu); break; case EXCP_TLBD: if ((env->ctrl[CR_STATUS] & CR_STATUS_EH) == 0) { - qemu_log_mask(CPU_LOG_INT, "TLB MISS (fast) at pc=%x\n", env->pc); env->ctrl[CR_TLBMISC] &= ~CR_TLBMISC_DBL; env->ctrl[CR_TLBMISC] |= CR_TLBMISC_WE; do_exception(cpu, cpu->fast_tlb_miss_addr, false); } else { - qemu_log_mask(CPU_LOG_INT, "TLB MISS (double) at pc=%x\n", env->pc); env->ctrl[CR_TLBMISC] |= CR_TLBMISC_DBL; do_exception(cpu, cpu->exception_addr, false); } @@ -112,7 +156,6 @@ void nios2_cpu_do_interrupt(CPUState *cs) case EXCP_TLBR: case EXCP_TLBW: case EXCP_TLBX: - qemu_log_mask(CPU_LOG_INT, "TLB PERM at pc=%x\n", env->pc); if ((env->ctrl[CR_STATUS] & CR_STATUS_EH) == 0) { env->ctrl[CR_TLBMISC] |= CR_TLBMISC_WE; } @@ -122,23 +165,16 @@ void nios2_cpu_do_interrupt(CPUState *cs) case EXCP_SUPERA: case EXCP_SUPERI: case EXCP_SUPERD: - qemu_log_mask(CPU_LOG_INT, "SUPERVISOR exception at pc=%x\n", env->pc); - do_exception(cpu, cpu->exception_addr, false); - break; - case EXCP_ILLEGAL: case EXCP_TRAP: - qemu_log_mask(CPU_LOG_INT, "TRAP exception at pc=%x\n", env->pc); do_exception(cpu, cpu->exception_addr, false); break; case EXCP_BREAK: - qemu_log_mask(CPU_LOG_INT, "BREAK exception at pc=%x\n", env->pc); do_exception(cpu, cpu->exception_addr, true); break; case EXCP_SEMIHOST: - qemu_log_mask(CPU_LOG_INT, "BREAK semihosting at pc=%x\n", env->pc); env->pc += 4; do_nios2_semihosting(env); break; From patchwork Thu Mar 10 11:27:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 550124 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp930950mag; Thu, 10 Mar 2022 04:11:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJx0udaiHfunrhdcZz7VsDWlVotXba0qFA2z2d0x2KJ2mlaxMBuLald/O9Nf4Q/apCfHpkR8 X-Received: by 2002:a25:cc8b:0:b0:628:9263:38ba with SMTP id l133-20020a25cc8b000000b00628926338bamr3561838ybf.291.1646914301396; Thu, 10 Mar 2022 04:11:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646914301; cv=none; d=google.com; s=arc-20160816; b=H6QOtr2xAvOQP27z/J+ddCXpxFYgC+tBC5eE1ZUfmwfLh7ySngQXFjemhs5tJOlTqc JZ+KwwDS/EBQtnzS2PuQX6VihlNtWXoHTvysJylrE878evm/84b5tnpAZzcxVmf8N/8+ e6fOHNZr2jJOv9nWp45iPQkuZo9AKosX7FEv+hxUQP+lKEHwzxR9ugZfrRl+sLD69hZe u3KZ64ZFL9lMRWvlb8+Po39iEtUidGr9PGuQk2D/3x7CPE739/B9Uk0yBGtd69P9ZOuV sa4NO84PTVoT7X03TNtWyq2l4dYsxZgNNXHr1TePdDTIV4uj4KzVyXzuzDS85S8qp+GQ 7Q4g== 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=GQKtq5EmgHv2pf8acDMhuJ8SB17+NoN37aNM30IhfvE=; b=m5vKyuDTXaN7ChADOd2GpXvRua6cFdPkNID504Ly0KYDzv1F3l8d/oPQ9pwqQbvTaf 5DgC9Q8GAjScsMJUTpRZtyDBYS8YlithWqVbQrxqvQrI3PRRAZF1vnSnnyMknIRHMk4F KMML7KSwzc6mwYm/OHLY8HLgaCZaSwAVvkty8ag/BdMltoAYjtNi1IVUGsb/e+aqHiqt oyaVFSNaqHFu8ZGNxQqQ8LIT+P35u2D4uVPTSwChL/m68otd7Axrbs1mEnQ5qP2TCNdy isJMB0ueJOiD6Y9X4phGAftYmxeoXS3f50Hg23BKWy/KNYPXPlR/cQ1pSfDPCAWD19pU NKKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=jtOiGy3F; 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 w4-20020a25ef44000000b00624417cd8aesi2624754ybm.72.2022.03.10.04.11.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Mar 2022 04:11:41 -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=jtOiGy3F; 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]:39970 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSHds-0003qq-V7 for patch@linaro.org; Thu, 10 Mar 2022 07:11:40 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50874) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSGxX-0005nW-6e for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:27:55 -0500 Received: from [2607:f8b0:4864:20::1036] (port=42533 helo=mail-pj1-x1036.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nSGxV-0007zS-PS for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:27:54 -0500 Received: by mail-pj1-x1036.google.com with SMTP id c16-20020a17090aa61000b001befad2bfaaso4970182pjq.1 for ; Thu, 10 Mar 2022 03:27:53 -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=GQKtq5EmgHv2pf8acDMhuJ8SB17+NoN37aNM30IhfvE=; b=jtOiGy3FYwQP3MCPQKueM36CjJDClkhfzP7GS1+H6iFjFbaIXyJp1fZpmcMN5vi1JW qhuify425kryo/WWX5g5MFg9FAHMSm6N0SVWagC2XWw25AFjw89Xqa/NnVXZneZpCGgH N15S6EBfr/5VKd9Q9GcD8taM7E3w+wpHQ+FKxE9W2ePy3jht47IGi95b4dz3kE44Ii6z tdzNlpZRh7DUWpWPqUWW9WGK3iB4FgFfaGtW7Qi1ehVWHxwtHUYISBM3yvxWQLAFLJLr O0QRVJrWth9FgbsTf+A9sg4N5TBt/MMoYuK3aaKKsBCKxXzRUIKQcBfS8PF9W9OcWu1M HwyA== 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=GQKtq5EmgHv2pf8acDMhuJ8SB17+NoN37aNM30IhfvE=; b=hjHS8HWjYQr5vKPiMRlfE/QSTH6EDkGr92jpIaUKZteMvxuUUGGXrMcUZdpfMCNr4n PRgXoPd5PMw3OPWVZATo7HorTLBOOkCOcQnQtejB1+50NHwTp4b8A+nJ70cJx63FkBeH Gs216/ZSarLT+dgdPEodCRF2KIfSxYSW8l2i+A/PKSYkMtldsQSUXy4BfXZA2ALiY7sT QhsMT7wZww7JxeIv4HgQMn1kmrhHnjchCrEsiUtB5PH8arynwBGXXBWPlnIQluB3tRE7 7C4XQuJEAbuSUbCHG8+VwjOpnJP2QyvJuQGNr5r/nn4tfy7tunsGKBW5PTfyBW4Lnv+h 1bvA== X-Gm-Message-State: AOAM530jmoGLqLDR0tIeCXUyIqeXvVkljgEC39AWGkjUKqpxMZ4ezWn/ HG4XSqnrA1jl8SLLlEYUfgg6mSBruA6MHw== X-Received: by 2002:a17:90b:788:b0:1bf:41d:a9ff with SMTP id l8-20020a17090b078800b001bf041da9ffmr4456639pjz.116.1646911672487; Thu, 10 Mar 2022 03:27:52 -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.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Mar 2022 03:27:51 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 23/48] target/nios2: Handle EXCP_UNALIGN and EXCP_UALIGND Date: Thu, 10 Mar 2022 03:27:00 -0800 Message-Id: <20220310112725.570053-24-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::1036 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::1036; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1036.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" These misaligned data and misaligned destination exceptions are defined, but not currently raised. Signed-off-by: Richard Henderson --- target/nios2/helper.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/target/nios2/helper.c b/target/nios2/helper.c index 285f3aae1d..0392c0ea84 100644 --- a/target/nios2/helper.c +++ b/target/nios2/helper.c @@ -119,6 +119,12 @@ void nios2_cpu_do_interrupt(CPUState *cs) case EXCP_ILLEGAL: name = "ILLEGAL insn"; break; + case EXCP_UNALIGN: + name = "Misaligned (data)"; + break; + case EXCP_UNALIGND: + name = "Misaligned (destination)"; + break; case EXCP_TRAP: name = "TRAP insn"; break; @@ -167,6 +173,8 @@ void nios2_cpu_do_interrupt(CPUState *cs) case EXCP_SUPERD: case EXCP_ILLEGAL: case EXCP_TRAP: + case EXCP_UNALIGN: + case EXCP_UNALIGND: do_exception(cpu, cpu->exception_addr, false); break; From patchwork Thu Mar 10 11:27:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 550126 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp933373mag; Thu, 10 Mar 2022 04:14:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJypjpjjMaKij4m6rN/HDghKza7JgyahJsfliFo/7qKyVW+YcEsaBIHZiLeowF6R1JIZARm/ X-Received: by 2002:a25:c246:0:b0:622:4c1a:d4b2 with SMTP id s67-20020a25c246000000b006224c1ad4b2mr3410275ybf.268.1646914486005; Thu, 10 Mar 2022 04:14:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646914486; cv=none; d=google.com; s=arc-20160816; b=uifdanw9mIuKbLE1oZSzk0RMcO5pjq0e08T9SDAbw630C6rSAAATEEUIKTtMzIQvmo sgCbXaF6opMN5o2L5vLjun31FOXQmraxcfdqp6UdGTb+3Yi32HI0GmSkl9/OOKHQRnz6 kBJuIEu7ZcaQJBlAGTjLQB0yxB0YQP//822CZzJPhpaFdSO/PKVj70/5NnKu7pcnMJxn y+SuiTEaWGsMAasdSuEshBRZoTtVRHtZI7fOdPzO9YUOw0NNH488Hd7oVR3TqYasUeY7 KWKp7e83u+nHx8I32iRoZnS2Fwt08iQtxEHBKOx/1OJ5uyi+QbWN1QAlSvO8WbBASpbY 4Wug== 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=kC6IYNjsGbxQ1O1vqjxYEFxpw4YN+TjfQjKfECaeneY=; b=nvxgAWRVwPN41Wz5lhChjqgLNL2env2Ry9lkI3abLvlFHzR4LI93n7pMn5Jmv8GCIb rUwAhK28g7CzKAZOd9b/tMNnEzjdDVv8mmLmE58JNr4vjwDnEfbFbni7FVd7XIo3GdX6 UL3m/z37XL6DFiSdueMXwioxugEWr/9l9673nw07vcakkvdD1kgPae6yWqqrRhLmWhWL Shz59tNQRwrrD53MaWcJHJ48hCBDCLilI320WFYrbCKNErWP1kZcd6FKp2A76Waom91a XcitbHpxEPo9td/PC/xMISl7QAoSlLwJYS0pPcSjbqVEK8fFPrdRaX1BAH27mytLV/Ub z8/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=E+FqzeML; 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 q136-20020a25d98e000000b006287dbe1eadsi2719446ybg.398.2022.03.10.04.14.45 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Mar 2022 04:14:45 -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=E+FqzeML; 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]:46490 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSHgr-0000JC-IN for patch@linaro.org; Thu, 10 Mar 2022 07:14:45 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50890) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSGxY-0005sT-Tu for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:27:56 -0500 Received: from [2607:f8b0:4864:20::62d] (port=35569 helo=mail-pl1-x62d.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nSGxX-0007ze-8v for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:27:56 -0500 Received: by mail-pl1-x62d.google.com with SMTP id n15so4609254plh.2 for ; Thu, 10 Mar 2022 03:27:54 -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=kC6IYNjsGbxQ1O1vqjxYEFxpw4YN+TjfQjKfECaeneY=; b=E+FqzeMLYkMsGZA46EH5rxCmD2SIxJ64cuBJoFwAqf5xmz6H73ANYIFCxyKAJ7SgH0 DDYkf6nzX/ODRTrt2MbcnmWSoMTtgKi9zcjIxqvH4zbblq9mhdG3ew7f9e8jk+QpQzqN H7bW7ls/UK3ZSUmH/lwEUkNawNe6G9rig9yc8xgx9Lb2M7sKxwg4xgv+hhA3IR1p1S6o GiF/YFqrBtJGqJZPUQl5N8pNBy+9ZZAkecj7TtSA597c19Q/anPdRTq96RZvk48D4/+u aUe5iu2lFzs8OyPW7QIuHurt/TEYeyRJxA3a13k8MmouQnSYFLJOjYV15d/nREFN0SW5 M6lw== 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=kC6IYNjsGbxQ1O1vqjxYEFxpw4YN+TjfQjKfECaeneY=; b=JGK3t2DPuqXNyGGdI7d1CKVMs+MCZalaq+Qdg+wbMI5BWI8Nl/WMCGvJb/u2+kT9Er vrVrfm1q0P3RdBBmkrfSnFHPQp82Dg/6sucULgDo5Fxg2vIQSIfRq/AIoii4qJS/tmnD 8XbdesU4KCUnzFR7rO/zxBoR8z6CQBfMB1/BshBw1H178RKs/1ggo9+7BhuMbVb6SVy+ kCURpOjfSA2bB9anc3hPYv7qFNArc9uFU3uhvxcBrWh6MNOhqUV2RerM4HOYaIovRSm1 9NLL/C2h7LhY5294CjNTbPELnZ4zzaGsX4xC5yBg9deffxLOtly+jTdU923I+eJcq8wu a62A== X-Gm-Message-State: AOAM532UlDsFq+fsyA5SCH6nOdgfNDs7axFngbOMe8guX69WEatMLDLe qYsLrygxOoP4vScobSO2kqlD4k6dZBXkQA== X-Received: by 2002:a17:902:720a:b0:151:d7d7:6ac0 with SMTP id ba10-20020a170902720a00b00151d7d76ac0mr4410040plb.128.1646911673955; Thu, 10 Mar 2022 03:27:53 -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.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Mar 2022 03:27:53 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 24/48] target/nios2: Cleanup set of CR_EXCEPTION for do_interrupt Date: Thu, 10 Mar 2022 03:27:01 -0800 Message-Id: <20220310112725.570053-25-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::62d (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::62d; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62d.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" The register is entirely read-only for software, and we do not implement ECC, so we need not deposit the cause into an existing value; just create a new value from scratch. Furthermore, exception.CAUSE is not written for break exceptions. Signed-off-by: Richard Henderson --- target/nios2/helper.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/target/nios2/helper.c b/target/nios2/helper.c index 0392c0ea84..afbafd1fdc 100644 --- a/target/nios2/helper.c +++ b/target/nios2/helper.c @@ -74,9 +74,10 @@ static void do_exception(Nios2CPU *cpu, uint32_t exception_addr, bool is_break) new_status &= ~(CR_STATUS_PIE | CR_STATUS_U); env->ctrl[CR_STATUS] = new_status; - env->ctrl[CR_EXCEPTION] = FIELD_DP32(env->ctrl[CR_EXCEPTION], - CR_EXCEPTION, CAUSE, - cs->exception_index); + if (!is_break) { + env->ctrl[CR_EXCEPTION] = FIELD_DP32(0, CR_EXCEPTION, CAUSE, + cs->exception_index); + } env->pc = exception_addr; } From patchwork Thu Mar 10 11:27:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 550127 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp938108mag; Thu, 10 Mar 2022 04:19:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJybswgMfgabqD6terB4td8InRfGDDhC+Yugo+SjS3yjnT8MvrNvoozT7zrAYksDbHiT3jBr X-Received: by 2002:a25:9001:0:b0:628:755e:f6bd with SMTP id s1-20020a259001000000b00628755ef6bdmr3598882ybl.481.1646914787596; Thu, 10 Mar 2022 04:19:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646914787; cv=none; d=google.com; s=arc-20160816; b=jDkfqf40QmN/BdvrhPqHXdj/f6HdPIlvlDRfg5LoPCkxN1Wi1xjC0fbHTrec0qSLN4 WjACC3hae3BPQomigLjwXHOya2BCeiihikAaQ5z5oRZb0XTmNjVhgxBPJn5daPR9OjZ1 eLuwHM/m2j3e34yZgyDO7mwiybTxF9bsTQoCCuXc03SAELQ79tZ3eXgpox5MkGg7+rzY vkpqw4FY+YJbG0Af2zUgFG2kOAOJlvmG2MXuv1rmKBLC9EHLisvXSJYcHF/NVwdbPXEJ 4ioIPXaZei05jZXaUsvgi1PXm1ZNFAhqW7th7UZ7CqEEpHO7qAIdRGTmbWYkWuKBkutc d/zw== 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=EnAEYpcIY00+k1hPlmrXoRht11ltOEwUcRv8uGR7V3g=; b=FcLStBvhu+z4dMV4cH8zuqh7G7MqaDVRo7rsayEHCOQs39uCtmkF9zuzIAL79gyr4i cQsCDmahYYDQeBmEhGz7XqDnEWTpkGAtxs183HtWt8CN62PMmSYbwoW2QDpOWcrjoYMS yMHfD5BHhUgk27p87WRaeEXaPOftuTmeBep4XmivrKuD66NAhp9AV1qS0LJ8Zn8YC/b5 Q94afwLrsDMZ/byLjAZWQPq/6YwwzpmzqJgXI/PDlpX/zQj5BNXVPBfzAFbc7FW+l0jy vyHHybtuvrFC/ZZDFJgE6vJxD2Fh1Mnddag6ljSIHdquB6ajJfCcBNhyuMap9UGPWjJO +aXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="HZRH8/99"; 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 n190-20020a0de4c7000000b002d035ccfa1dsi2611541ywe.193.2022.03.10.04.19.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Mar 2022 04:19:47 -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="HZRH8/99"; 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]:54368 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSHli-0005NU-WA for patch@linaro.org; Thu, 10 Mar 2022 07:19:47 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50924) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSGxb-0005xO-92 for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:27:59 -0500 Received: from [2607:f8b0:4864:20::630] (port=42704 helo=mail-pl1-x630.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nSGxZ-0007zt-CU for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:27:58 -0500 Received: by mail-pl1-x630.google.com with SMTP id p17so4584086plo.9 for ; Thu, 10 Mar 2022 03:27:56 -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=EnAEYpcIY00+k1hPlmrXoRht11ltOEwUcRv8uGR7V3g=; b=HZRH8/99MaZQociLL7QMujn/GJYzHrvrrxLteENWlYL5pJb5vO3nGvXr1zjmifN+W+ 4NBuOWqrVe4IGYhUr+yPikV0MyNanVWM/qU46tfV2LqmnMngU4bB9HTIUcafG2Bt5FKO MIHzYaQInSDHM9yFepi+1McJkSCyU+TobnV49K1o/93ruaeo54WOcAHBo53yAn+0Pd1r LMLFCrrxsY+prSftKYhSfDR/D6gGk4fz2xuXT+2bd6jqHJhJkkBkay/gSIR8O1pbBwcl ZdrbOWctCqgTp4pXSmeV8RUv1M5WxoUZI6+jRVgD6JSth3uEbCA9bIx47ifTilkNkRGq oZzA== 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=EnAEYpcIY00+k1hPlmrXoRht11ltOEwUcRv8uGR7V3g=; b=1pb1q+z8JNHBbvHqxs6zmdWX4XJn4YRqvej/NsbpayW8Zhm23k/s6DtPs148YS+vTU 98KkFLqzohllWnc6ENF3rskl79tRii2ABZ89Nc/3yt+Tmld1MVM3gK0L+YFimIun4EzN o0VVnI44zhFqrADmE3d14PiPiCb0wJY6YymksDuF0Lgjqbhn1vaAhRcoXQPujHKjq8Wh +A3TCnL1MCRPue1mPzFfYcU97+3JOQy//AxUBFgp8O2Cy6x8dmhQrkoP67saYHvYVTyC 9BsNws6g7httQ4KhQVHiug3Wtsm23pur16AO5l3gpvTfj1qQSQvmrRE18ucDwhqLX0nr sIfA== X-Gm-Message-State: AOAM533iRb0yfWh1NHVAAdI1hxKwY47leUaaLTR2Ver2A/eD07OX+sm5 OTS4wydVEDgW48B0v3boVQyRWe1b1Ma5Yg== X-Received: by 2002:a17:90b:1d04:b0:1bf:cd14:d3ff with SMTP id on4-20020a17090b1d0400b001bfcd14d3ffmr3628606pjb.67.1646911675257; Thu, 10 Mar 2022 03:27:55 -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.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Mar 2022 03:27:54 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 25/48] target/nios2: Clean up handling of tlbmisc in do_exception Date: Thu, 10 Mar 2022 03:27:02 -0800 Message-Id: <20220310112725.570053-26-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::630 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::630; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x630.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" The 4 lower bits, D, PERM, BAD, DBL, are unconditionally set on any exception with EH=0, or so says Table 42 (Processor Status After Taking Exception). We currently do not set PERM or BAD at all, and only set/clear DBL for tlb miss, and do not clear DBL for any other exception. It is a bit confusing to set D in tlb_fill and the rest during do_interrupt, so move the setting of D to do_interrupt as well. To do this, split EXP_TLBD into two cases, EXCP_TLB_X and EXCP_TLB_D, which allows us to distinguish them during do_interrupt. Choose a value for EXCP_TLB_D such that when truncated it produces the correct value for exception.CAUSE. Rename EXCP_TLB[RWX] to EXCP_PERM_[RWX], to emphasize that the exception is permissions related. Rename EXCP_SUPER[AD] to EXCP_SUPERA_[DX] to emphasize that they are both "supervisor address" exceptions, data and execute. Retain the setting of tlbmisc.WE for the fast-tlb-miss path, as it is being relied upon, but remove it from the permission path. Signed-off-by: Richard Henderson --- target/nios2/cpu.h | 13 +++--- target/nios2/helper.c | 102 +++++++++++++++++++++++++++++------------- 2 files changed, 77 insertions(+), 38 deletions(-) diff --git a/target/nios2/cpu.h b/target/nios2/cpu.h index d003af5afc..c925cdd8e3 100644 --- a/target/nios2/cpu.h +++ b/target/nios2/cpu.h @@ -166,13 +166,14 @@ FIELD(CR_TLBMISC, EE, 24, 1) #define EXCP_UNALIGN 6 #define EXCP_UNALIGND 7 #define EXCP_DIV 8 -#define EXCP_SUPERA 9 +#define EXCP_SUPERA_X 9 #define EXCP_SUPERI 10 -#define EXCP_SUPERD 11 -#define EXCP_TLBD 12 -#define EXCP_TLBX 13 -#define EXCP_TLBR 14 -#define EXCP_TLBW 15 +#define EXCP_SUPERA_D 11 +#define EXCP_TLB_X 12 +#define EXCP_TLB_D (0x1000 | EXCP_TLB_X) +#define EXCP_PERM_X 13 +#define EXCP_PERM_R 14 +#define EXCP_PERM_W 15 #define EXCP_MPUI 16 #define EXCP_MPUD 17 diff --git a/target/nios2/helper.c b/target/nios2/helper.c index afbafd1fdc..8b69918ba3 100644 --- a/target/nios2/helper.c +++ b/target/nios2/helper.c @@ -49,7 +49,8 @@ void nios2_cpu_record_sigsegv(CPUState *cs, vaddr addr, #else /* !CONFIG_USER_ONLY */ -static void do_exception(Nios2CPU *cpu, uint32_t exception_addr, bool is_break) +static void do_exception(Nios2CPU *cpu, uint32_t exception_addr, + uint32_t tlbmisc_set, bool is_break) { CPUNios2State *env = &cpu->env; CPUState *cs = CPU(cpu); @@ -68,6 +69,16 @@ static void do_exception(Nios2CPU *cpu, uint32_t exception_addr, bool is_break) if (cpu->mmu_present) { new_status |= CR_STATUS_EH; + + /* + * There are 4 bits that are always written. + * Explicitly clear them, to be set via the argument. + */ + env->ctrl[CR_TLBMISC] &= ~(CR_TLBMISC_D | + CR_TLBMISC_PERM | + CR_TLBMISC_BAD | + CR_TLBMISC_DBL); + env->ctrl[CR_TLBMISC] |= tlbmisc_set; } } @@ -83,13 +94,14 @@ static void do_exception(Nios2CPU *cpu, uint32_t exception_addr, bool is_break) static void do_iic_irq(Nios2CPU *cpu) { - do_exception(cpu, cpu->exception_addr, false); + do_exception(cpu, cpu->exception_addr, 0, false); } void nios2_cpu_do_interrupt(CPUState *cs) { Nios2CPU *cpu = NIOS2_CPU(cs); CPUNios2State *env = &cpu->env; + uint32_t tlbmisc_set = 0; if (qemu_loglevel_mask(CPU_LOG_INT)) { const char *name = NULL; @@ -98,20 +110,21 @@ void nios2_cpu_do_interrupt(CPUState *cs) case EXCP_IRQ: name = "interrupt"; break; - case EXCP_TLBD: + case EXCP_TLB_X: + case EXCP_TLB_D: if (env->ctrl[CR_STATUS] & CR_STATUS_EH) { name = "TLB MISS (double)"; } else { name = "TLB MISS (fast)"; } break; - case EXCP_TLBR: - case EXCP_TLBW: - case EXCP_TLBX: + case EXCP_PERM_R: + case EXCP_PERM_W: + case EXCP_PERM_X: name = "TLB PERM"; break; - case EXCP_SUPERA: - case EXCP_SUPERD: + case EXCP_SUPERA_X: + case EXCP_SUPERA_D: name = "SUPERVISOR (address)"; break; case EXCP_SUPERI: @@ -149,38 +162,60 @@ void nios2_cpu_do_interrupt(CPUState *cs) do_iic_irq(cpu); break; - case EXCP_TLBD: - if ((env->ctrl[CR_STATUS] & CR_STATUS_EH) == 0) { - env->ctrl[CR_TLBMISC] &= ~CR_TLBMISC_DBL; - env->ctrl[CR_TLBMISC] |= CR_TLBMISC_WE; - do_exception(cpu, cpu->fast_tlb_miss_addr, false); + case EXCP_TLB_D: + tlbmisc_set = CR_TLBMISC_D; + /* fall through */ + case EXCP_TLB_X: + if (env->ctrl[CR_STATUS] & CR_STATUS_EH) { + tlbmisc_set |= CR_TLBMISC_DBL; + /* + * Normally, we don't write to tlbmisc unless !EH, + * so do it manually for the double-tlb miss exception. + */ + env->ctrl[CR_TLBMISC] &= ~(CR_TLBMISC_D | + CR_TLBMISC_PERM | + CR_TLBMISC_BAD); + env->ctrl[CR_TLBMISC] |= tlbmisc_set; + do_exception(cpu, cpu->exception_addr, 0, false); } else { - env->ctrl[CR_TLBMISC] |= CR_TLBMISC_DBL; - do_exception(cpu, cpu->exception_addr, false); + /* + * ??? Implicitly setting tlbmisc.WE for the fast-tlb-miss + * handler appears to be out of spec. But, the linux kernel + * handler relies on it, writing to tlbacc without first + * setting tlbmisc.WE. + */ + tlbmisc_set |= CR_TLBMISC_WE; + do_exception(cpu, cpu->fast_tlb_miss_addr, tlbmisc_set, false); } break; - case EXCP_TLBR: - case EXCP_TLBW: - case EXCP_TLBX: - if ((env->ctrl[CR_STATUS] & CR_STATUS_EH) == 0) { - env->ctrl[CR_TLBMISC] |= CR_TLBMISC_WE; - } - do_exception(cpu, cpu->exception_addr, false); + case EXCP_PERM_R: + case EXCP_PERM_W: + tlbmisc_set = CR_TLBMISC_D; + /* fall through */ + case EXCP_PERM_X: + tlbmisc_set |= CR_TLBMISC_PERM; + do_exception(cpu, cpu->exception_addr, tlbmisc_set, false); + break; + + case EXCP_SUPERA_D: + case EXCP_UNALIGN: + tlbmisc_set = CR_TLBMISC_D; + /* fall through */ + case EXCP_SUPERA_X: + case EXCP_UNALIGND: + tlbmisc_set |= CR_TLBMISC_BAD; + do_exception(cpu, cpu->exception_addr, tlbmisc_set, false); break; - case EXCP_SUPERA: case EXCP_SUPERI: - case EXCP_SUPERD: case EXCP_ILLEGAL: case EXCP_TRAP: - case EXCP_UNALIGN: - case EXCP_UNALIGND: - do_exception(cpu, cpu->exception_addr, false); + do_exception(cpu, cpu->exception_addr, 0, false); break; case EXCP_BREAK: - do_exception(cpu, cpu->exception_addr, true); + do_exception(cpu, cpu->exception_addr, 0, true); break; case EXCP_SEMIHOST: @@ -235,7 +270,7 @@ bool nios2_cpu_tlb_fill(CPUState *cs, vaddr address, int size, { Nios2CPU *cpu = NIOS2_CPU(cs); CPUNios2State *env = &cpu->env; - unsigned int excp = EXCP_TLBD; + unsigned int excp; target_ulong vaddr, paddr; Nios2MMULookup lu; unsigned int hit; @@ -262,7 +297,8 @@ bool nios2_cpu_tlb_fill(CPUState *cs, vaddr address, int size, if (probe) { return false; } - cs->exception_index = EXCP_SUPERA; + cs->exception_index = (access_type == MMU_INST_FETCH + ? EXCP_SUPERA_X : EXCP_SUPERA_D); env->ctrl[CR_BADADDR] = address; cpu_loop_exit_restore(cs, retaddr); } @@ -283,8 +319,10 @@ bool nios2_cpu_tlb_fill(CPUState *cs, vaddr address, int size, } /* Permission violation */ - excp = (access_type == MMU_DATA_LOAD ? EXCP_TLBR : - access_type == MMU_DATA_STORE ? EXCP_TLBW : EXCP_TLBX); + excp = (access_type == MMU_DATA_LOAD ? EXCP_PERM_R : + access_type == MMU_DATA_STORE ? EXCP_PERM_W : EXCP_PERM_X); + } else { + excp = (access_type == MMU_INST_FETCH ? EXCP_TLB_X: EXCP_TLB_D); } if (probe) { From patchwork Thu Mar 10 11:27:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 550120 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp926762mag; Thu, 10 Mar 2022 04:06:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJykWJmgYNUReKiizi6jwZs1gGYG8dsHz8cbm/c80V0oIHM+H+GW5k+h9eZjJXdRgbZo4zq2 X-Received: by 2002:a81:f0f:0:b0:2dc:5846:1ab3 with SMTP id 15-20020a810f0f000000b002dc58461ab3mr3690960ywp.216.1646913983306; Thu, 10 Mar 2022 04:06:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646913983; cv=none; d=google.com; s=arc-20160816; b=S9+lj8tOXCYUUc5goCK5DR+1b7S31Tz3XGwhyyOmC0+Tt5c6eFKwA9Di96w+o5KaPp BPBwc5KGdqtBQLKeNLAjYCGanDJywk5aL2sIn2RLc6WnJCRiNOjP0r/cFWJ4Zk7N/JCI DFjYmtnlmj0sW0hojm7x7mM0511dPLH67EQjweH0aY99rwTiwBKZMNXoL7oaGoTEoMpf GFtGT9ay5YfD1I5UjHDA/oDH9hLXWwIqZ5sKf3NXuqgIgfbSuF5V/fnk8OAi4tC4RZAW 4AjTlvoW/pnhSPLw0yah/Dbx3QXrxwti499D/+PiL2OaHCYQmnXyKGJ1RI+nNKAp82Ee h8Jg== 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=t6Arg14tlq3SbtAOWylBKjkAobqm1S/G3HUBx+owul4=; b=etjLHlc906tnwpA5m3QrmTvthO65jHcVf8WryyT892HeS0x9UbzV+5RFX4HsA0Z0gB iOSxQGkTS5V5fT8fXhU3+tOonthIGZkzeRXrPU/QSDN6E0S+y11GmG3DdHtBCdcF5sV/ Pt4dKlqo7nU4d6+xCf3GPGLIrz3BnCnl1eZ1VK17VKRBpLoCt1PDhuM0F2qN6mX0yj+M 8Hy9RpRoRxghReORG3W/IfOwIQH/FcWpFf/ON0TFIoaha4O3IIq8l1aj1zGLTmKzSyG7 OySwm453cu5XwJ1mj5rnIsn82qnSd2bTufX8QmQM6dcr7tKr6qSDJIwKgMjGMjxxmlwP U/uA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=u4d07xsx; 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 138-20020a810c90000000b002dc49d9db55si2734837ywm.126.2022.03.10.04.06.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Mar 2022 04:06:23 -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=u4d07xsx; 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]:33080 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSHYk-0007AS-MV for patch@linaro.org; Thu, 10 Mar 2022 07:06:22 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50968) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSGxd-00064X-Q4 for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:28:01 -0500 Received: from [2607:f8b0:4864:20::62b] (port=36634 helo=mail-pl1-x62b.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nSGxb-00080G-OE for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:28:01 -0500 Received: by mail-pl1-x62b.google.com with SMTP id e13so4606203plh.3 for ; Thu, 10 Mar 2022 03:27:59 -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=t6Arg14tlq3SbtAOWylBKjkAobqm1S/G3HUBx+owul4=; b=u4d07xsxDZllfiLr6CNgW1eikocieJMlubrrLduuaUQtmWWhFyGFao/R48KBo8DUlK TLne3Z67I/hEctA1Ra/BW6l6DkftdC5GGZgNj5GB41uIT7UaTChs8C3IGIqxvSudCsbm Jxr0Alm7BX2J43VqXUkvM+8Z9coYGGQK5ZDnhzYPBEUhp9KVJd5UPUaKrNIaUhTBpST2 xSwslrOiQI50dSxe+WE4uet3Xy6M08JqUFV+NXv8KSWWB9PHOBr6IGqIQPfpiOAlxrSF uKljG+szVZnwBsfZALeLTTh2nlbOdPyZhaQDk/r0bFdz2a5viXpHZpvEDymG1qLv3ww+ 0j8A== 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=t6Arg14tlq3SbtAOWylBKjkAobqm1S/G3HUBx+owul4=; b=Wp/dpT4ZVhqJ6zrA3/8FBEGsxb0/OguQEBNfNm5A35Is8YEl+euupnQTohDH61r8hN E2XqUaCpM3qjk2queZCajvBdORevmOttSdW4XVfW/E+0j5GP6GBCWueb7qSsOx69QBob M5Q24RvngY1utVc8+FXFRSK/gUs7CtGjS56Y3pnZMmW6xl6giB4qoJpCNHid1TWhiuMF 1fJjczZ285nDtiK+G6UlXqpdGWN+rzNz1Q7+1zBIQ/CXtL4JZBH5ZctLCXNzVVBsIQFE u8ulb97PCVID95cF96+tzt0MIqOApnX7jkLYLJzF4rMRzzs6WIGrCkAaFUwgBGKMQpHT A0hA== X-Gm-Message-State: AOAM532IVBSjs9TR2U23EAEwZkQA2tGIIpe1ljBvasOmhsW2pYI7gN5o cJ/BN2DTnz3nyK16I1c0z+sH4EFXHaM2JA== X-Received: by 2002:a17:90a:4d07:b0:1bf:6ac4:b94a with SMTP id c7-20020a17090a4d0700b001bf6ac4b94amr15292489pjg.89.1646911676546; Thu, 10 Mar 2022 03:27:56 -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.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Mar 2022 03:27:55 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 26/48] target/nios2: Prevent writes to read-only or reserved control fields Date: Thu, 10 Mar 2022 03:27:03 -0800 Message-Id: <20220310112725.570053-27-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::62b (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.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" Create an array of masks which detail the writable and readonly bits for each control register. Apply them when writing to control registers, including the write to status during eret. Signed-off-by: Richard Henderson --- target/nios2/cpu.h | 13 ++++++ target/nios2/cpu.c | 94 +++++++++++++++++++++++++++++++++------- target/nios2/op_helper.c | 9 ++++ target/nios2/translate.c | 80 +++++++++++++++++++++++++++------- 4 files changed, 165 insertions(+), 31 deletions(-) diff --git a/target/nios2/cpu.h b/target/nios2/cpu.h index c925cdd8e3..410e76ccbb 100644 --- a/target/nios2/cpu.h +++ b/target/nios2/cpu.h @@ -190,6 +190,11 @@ struct CPUArchState { int error_code; }; +typedef struct { + uint32_t writable; + uint32_t readonly; +} ControlRegState; + /** * Nios2CPU: * @env: #CPUNios2State @@ -213,9 +218,17 @@ struct ArchCPU { uint32_t reset_addr; uint32_t exception_addr; uint32_t fast_tlb_miss_addr; + + /* Bits within each control register which are reserved or readonly. */ + ControlRegState cr_state[NUM_CR_REGS]; }; +static inline bool nios2_cr_reserved(const ControlRegState *s) +{ + return (s->writable | s->readonly) == 0; +} + void nios2_tcg_init(void); void nios2_cpu_do_interrupt(CPUState *cs); void dump_mmu(CPUNios2State *env); diff --git a/target/nios2/cpu.c b/target/nios2/cpu.c index 97bdc0a61b..ce2b0c6493 100644 --- a/target/nios2/cpu.c +++ b/target/nios2/cpu.c @@ -88,6 +88,59 @@ static void nios2_cpu_initfn(Object *obj) cpu_set_cpustate_pointers(cpu); + /* Begin with all fields of all registers are reserved. */ + memset(cpu->cr_state, 0, sizeof(cpu->cr_state)); + + /* + * The combination of writable and readonly is the set of all + * non-reserved fields. We apply writable as a mask to bits, + * and merge in existing readonly bits, before storing. + */ +#define WR_REG(C) cpu->cr_state[C].writable = -1 +#define RO_REG(C) cpu->cr_state[C].readonly = -1 +#define WR_FIELD(C, F) cpu->cr_state[C].writable |= R_##C##_##F##_MASK +#define RO_FIELD(C, F) cpu->cr_state[C].readonly |= R_##C##_##F##_MASK + + WR_FIELD(CR_STATUS, PIE); + WR_REG(CR_ESTATUS); + WR_REG(CR_BSTATUS); + RO_REG(CR_CPUID); + RO_REG(CR_EXCEPTION); + WR_REG(CR_BADADDR); + + /* TODO: These control registers are not present with the EIC. */ + WR_REG(CR_IENABLE); + RO_REG(CR_IPENDING); + + if (cpu->mmu_present) { + WR_FIELD(CR_STATUS, U); + WR_FIELD(CR_STATUS, EH); + + WR_FIELD(CR_PTEADDR, VPN); + WR_FIELD(CR_PTEADDR, PTBASE); + + RO_FIELD(CR_TLBMISC, D); + RO_FIELD(CR_TLBMISC, PERM); + RO_FIELD(CR_TLBMISC, BAD); + RO_FIELD(CR_TLBMISC, DBL); + WR_FIELD(CR_TLBMISC, PID); + WR_FIELD(CR_TLBMISC, WE); + WR_FIELD(CR_TLBMISC, RD); + WR_FIELD(CR_TLBMISC, WAY); + + WR_REG(CR_TLBACC); + } + + /* + * TODO: ECC (config, eccinj) and MPU (config, mpubase, mpuacc) are + * unimplemented, so their corresponding control regs remain reserved. + */ + +#undef WR_REG +#undef RO_REG +#undef WR_FIELD +#undef RO_FIELD + #if !defined(CONFIG_USER_ONLY) mmu_init(&cpu->env); @@ -152,23 +205,26 @@ static void nios2_cpu_disas_set_info(CPUState *cpu, disassemble_info *info) static int nios2_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { Nios2CPU *cpu = NIOS2_CPU(cs); - CPUClass *cc = CPU_GET_CLASS(cs); CPUNios2State *env = &cpu->env; + uint32_t val; - if (n > cc->gdb_num_core_regs) { + if (n < 32) { /* GP regs */ + val = env->regs[n]; + } else if (n == 32) { /* PC */ + val = env->pc; + } else if (n < 49) { /* Status regs */ + unsigned cr = n - 33; + if (nios2_cr_reserved(&cpu->cr_state[cr])) { + val = 0; + } else { + val = env->ctrl[n - 33]; + } + } else { + /* Invalid regs */ return 0; } - if (n < 32) { /* GP regs */ - return gdb_get_reg32(mem_buf, env->regs[n]); - } else if (n == 32) { /* PC */ - return gdb_get_reg32(mem_buf, env->pc); - } else if (n < 49) { /* Status regs */ - return gdb_get_reg32(mem_buf, env->ctrl[n - 33]); - } - - /* Invalid regs */ - return 0; + return gdb_get_reg32(mem_buf, val); } static int nios2_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) @@ -176,17 +232,25 @@ static int nios2_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) Nios2CPU *cpu = NIOS2_CPU(cs); CPUClass *cc = CPU_GET_CLASS(cs); CPUNios2State *env = &cpu->env; + uint32_t val; if (n > cc->gdb_num_core_regs) { return 0; } + val = ldl_p(mem_buf); if (n < 32) { /* GP regs */ - env->regs[n] = ldl_p(mem_buf); + env->regs[n] = val; } else if (n == 32) { /* PC */ - env->pc = ldl_p(mem_buf); + env->pc = val; } else if (n < 49) { /* Status regs */ - env->ctrl[n - 33] = ldl_p(mem_buf); + unsigned cr = n - 33; + /* ??? Maybe allow the debugger to write to readonly fields. */ + val &= cpu->cr_state[cr].writable; + val |= cpu->cr_state[cr].readonly & env->ctrl[cr]; + env->ctrl[cr] = val; + } else { + g_assert_not_reached(); } return 4; diff --git a/target/nios2/op_helper.c b/target/nios2/op_helper.c index 08ed3b4598..c56fc15283 100644 --- a/target/nios2/op_helper.c +++ b/target/nios2/op_helper.c @@ -34,6 +34,15 @@ void helper_raise_exception(CPUNios2State *env, uint32_t index) #ifndef CONFIG_USER_ONLY void helper_eret(CPUNios2State *env, uint32_t new_status, uint32_t new_pc) { + Nios2CPU *cpu = env_archcpu(env); + + /* + * Both estatus and bstatus have no constraints on write; + * do not allow reserved fields in status to be set. + */ + new_status &= (cpu->cr_state[CR_STATUS].writable | + cpu->cr_state[CR_STATUS].readonly); + env->ctrl[CR_STATUS] = new_status; env->pc = new_pc; cpu_loop_exit(env_cpu(env)); diff --git a/target/nios2/translate.c b/target/nios2/translate.c index cfad110186..21dc6947cf 100644 --- a/target/nios2/translate.c +++ b/target/nios2/translate.c @@ -102,6 +102,7 @@ typedef struct DisasContext { TCGv_i32 zero; target_ulong pc; int mem_idx; + const ControlRegState *cr_state; } DisasContext; static TCGv cpu_R[NUM_GP_REGS]; @@ -471,17 +472,26 @@ static void callr(DisasContext *dc, uint32_t code, uint32_t flags) /* rC <- ctlN */ static void rdctl(DisasContext *dc, uint32_t code, uint32_t flags) { - R_TYPE(instr, code); - TCGv t1, t2; - if (!gen_check_supervisor(dc)) { return; } +#ifdef CONFIG_USER_ONLY + g_assert_not_reached(); +#else + R_TYPE(instr, code); + TCGv t1, t2; + if (unlikely(instr.c == R_ZERO)) { return; } + /* Reserved registers read as zero. */ + if (nios2_cr_reserved(&dc->cr_state[instr.imm5])) { + tcg_gen_movi_tl(cpu_R[instr.c], 0); + return; + } + switch (instr.imm5) { case CR_IPENDING: /* @@ -505,6 +515,7 @@ static void rdctl(DisasContext *dc, uint32_t code, uint32_t flags) offsetof(CPUNios2State, ctrl[instr.imm5])); break; } +#endif } /* ctlN <- rA */ @@ -519,6 +530,14 @@ static void wrctl(DisasContext *dc, uint32_t code, uint32_t flags) #else R_TYPE(instr, code); TCGv v = load_gpr(dc, instr.a); + uint32_t ofs = offsetof(CPUNios2State, ctrl[instr.imm5]); + uint32_t wr = dc->cr_state[instr.imm5].writable; + uint32_t ro = dc->cr_state[instr.imm5].readonly; + + /* Skip reserved or readonly registers. */ + if (wr == 0) { + return; + } switch (instr.imm5) { case CR_PTEADDR: @@ -530,17 +549,35 @@ static void wrctl(DisasContext *dc, uint32_t code, uint32_t flags) case CR_TLBMISC: gen_helper_mmu_write_tlbmisc(cpu_env, v); break; - case CR_IPENDING: - /* ipending is read only, writes ignored. */ - break; case CR_STATUS: case CR_IENABLE: /* If interrupts were enabled using WRCTL, trigger them. */ dc->base.is_jmp = DISAS_UPDATE; /* fall through */ default: - tcg_gen_st_tl(v, cpu_env, - offsetof(CPUNios2State, ctrl[instr.imm5])); + if (wr == -1) { + /* The register is entirely writable. */ + tcg_gen_st_tl(v, cpu_env, ofs); + } else { + /* + * The register is partially read-only or reserved: + * merge the value. + */ + TCGv n = tcg_temp_new(); + + tcg_gen_andi_tl(n, v, wr); + + if (ro != 0) { + TCGv o = tcg_temp_new(); + tcg_gen_ld_tl(o, cpu_env, ofs); + tcg_gen_andi_tl(o, o, ro); + tcg_gen_or_tl(n, n, o); + tcg_temp_free(o); + } + + tcg_gen_st_tl(n, cpu_env, ofs); + tcg_temp_free(n); + } break; } #endif @@ -818,9 +855,11 @@ static void nios2_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) { DisasContext *dc = container_of(dcbase, DisasContext, base); CPUNios2State *env = cs->env_ptr; + Nios2CPU *cpu = env_archcpu(env); int page_insns; dc->mem_idx = cpu_mmu_index(env, false); + dc->cr_state = cpu->cr_state; /* Bound the number of insns to execute to those left on the page. */ page_insns = -(dc->base.pc_first | TARGET_PAGE_MASK) / 4; @@ -931,16 +970,25 @@ void nios2_cpu_dump_state(CPUState *cs, FILE *f, int flags) } #if !defined(CONFIG_USER_ONLY) - for (i = 0; i < NUM_CR_REGS; i++) { - qemu_fprintf(f, "%9s=%8.8x ", cr_regnames[i], env->ctrl[i]); - if ((i + 1) % 4 == 0) { - qemu_fprintf(f, "\n"); + int j; + + for (i = j = 0; i < NUM_CR_REGS; i++) { + if (!nios2_cr_reserved(&cpu->cr_state[i])) { + qemu_fprintf(f, "%9s=%8.8x ", cr_regnames[i], env->ctrl[i]); + if (++j % 4 == 0) { + qemu_fprintf(f, "\n"); + } } } - qemu_fprintf(f, " mmu write: VPN=%05X PID %02X TLBACC %08X\n", - env->mmu.pteaddr_wr & R_CR_PTEADDR_VPN_MASK, - FIELD_EX32(env->mmu.tlbmisc_wr, CR_TLBMISC, PID), - env->mmu.tlbacc_wr); + if (j % 4 != 0) { + qemu_fprintf(f, "\n"); + } + if (cpu->mmu_present) { + qemu_fprintf(f, " mmu write: VPN=%05X PID %02X TLBACC %08X\n", + env->mmu.pteaddr_wr & R_CR_PTEADDR_VPN_MASK, + FIELD_EX32(env->mmu.tlbmisc_wr, CR_TLBMISC, PID), + env->mmu.tlbacc_wr); + } #endif qemu_fprintf(f, "\n\n"); } From patchwork Thu Mar 10 11:27:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 550117 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp924151mag; Thu, 10 Mar 2022 04:03:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJyujxKXgCJNbSkZ33I38+wHn5uyLojNe3jlqoPAcnreHED0aJX+XpN8WKodCa2EzhP5l31s X-Received: by 2002:a81:9210:0:b0:2dc:27d2:292e with SMTP id j16-20020a819210000000b002dc27d2292emr3619369ywg.20.1646913812288; Thu, 10 Mar 2022 04:03:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646913812; cv=none; d=google.com; s=arc-20160816; b=ucUu15D+uJAGfYv9wd5iDJmtYobUN04lpRgwhHfan+O8RLw8a4MIBU6ghs0iPl0DKH oAd4hCpmI2gAXLEow5kTJ0IkkROZkA+z5oyDPRi7r0B8l8gDO26uXcYxmx8YmjQ23EY/ 4ShNx45ydCZEERB4TRU1KqUery8AxsOHkQNIKVlt2WYQXTvi17c01ErYwDtK6OMWSOAh BjxlTq5ux38w6WPyEONBmU+2PYG2TE3a21Q5/929bPlTkxiJ+NfuF6Hx+A8Ns4mvKAG9 Uvg3zw5nax6cMUEq1EsBhfy7SiOzRI//pPnUN95naW8l9uu0L1xMIMZXkZ59f0JjkSAt FwOA== 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=O8yV5sFKZ931fgVLOgWvtxvBKBH4NQ4GdxvxJ8ycVLk=; b=uZyowYnHH5+eyW28y84KJnM3pLT4O7FJZRRSx44ism4R80IQK+QwyhK6zAPz866z2R OgoMvv3OAJ0yMCPtP3D/mLJK/OB5ldtjaav4K9RqxIOhziqUmvqG0Dukahdscv3USKNI TJd7UK8v3F9tcp0v9Q6pMGsBXM7C7EXME7UkZAMgEmH7oeG7SGbfHgfHF7aPqUB4uh5k pv9lS6jSH88/Ow8/+sPCyqdgK4SM3C5V92h7T6gyBmh6ZJdWmw6bMv98cy3Z1msWaBJi EECrJU7Ol+5I5J//K2JMhyXphb30ntLCH/HLWY6BsnhYtrdwxMigzb7B4b7hWrtAX65G EGbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Uusg49HL; 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 y10-20020a25bb8a000000b006288f4913edsi2694489ybg.123.2022.03.10.04.03.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Mar 2022 04:03:32 -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=Uusg49HL; 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]:54984 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSHVz-0002hF-On for patch@linaro.org; Thu, 10 Mar 2022 07:03:31 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50944) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSGxc-00061M-Ij for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:28:00 -0500 Received: from [2607:f8b0:4864:20::52e] (port=42543 helo=mail-pg1-x52e.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nSGxb-000807-4h for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:28:00 -0500 Received: by mail-pg1-x52e.google.com with SMTP id o8so4480891pgf.9 for ; Thu, 10 Mar 2022 03:27:58 -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=O8yV5sFKZ931fgVLOgWvtxvBKBH4NQ4GdxvxJ8ycVLk=; b=Uusg49HLaN7UQ4M88l8vhFOywqJSuEhV9EX6T87hxr0jthadi0Dobf2qSbTqwz/aAu EdjUc1/518Pxa1NkOh6bayAEUlaTKEIfdaxfHU4MFrirZI42nhkLD4dxTrjY4++Zlzr1 PgwGV1R0CBK9/nyICcxRbuOTytfyuAKMv1j8VShbhcYVFzVrQ/bVdS5xzdBbBbMz2Sbz nk0MGTCbA4YCd3kHPQLQ3rJMYcuy9zxAFYhdGJvTAagLRbNl8PQfKZXHciAmpsSMNkq3 DAmMCInKS6NAmOwQmZEMsOasH/tEgY/zJK3CxgN7PBdSebSJNwIacY6gjs58ur3Wwd4A tt5Q== 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=O8yV5sFKZ931fgVLOgWvtxvBKBH4NQ4GdxvxJ8ycVLk=; b=YFSjpD2m81tjnqaoIayRNH5S5jyuHgCCwf0Vio4Xxs51CgDutRdKYYlmG/O6e5qVlQ ZtZqQNYtKdtJjvAQ6uVjlHYbphRL+cl7xkotQ/eZq4SqfDpVW5DHvH0VpDYqcEue8B6U I4Ad9BuWY2I4x9Mce7YYIYonYxpS00KcDsqihh/y8tRV6dciZU+zJiYGMPvAN+FMHT6r GI0hNeMm70Uh+e59mGGjH45pwbAVfUp7No76EBAM4YRbdY+8sKnTZ5dqmRZw4S49agW2 OMIEAwS++DvBa56vhzUkt+flnIB6kUOsHfRNslmTGJDwtfTuikI4AftdiZXm7JvvWLTu WVcA== X-Gm-Message-State: AOAM530aTepBTQLzxuLJdGQlyCT8NIQhQA8fHR8f78r+9R6x+2YuY9hG TUHIETSTYCYjWFnSwdIZh8Mct8eTvhjuFw== X-Received: by 2002:a63:7c5c:0:b0:380:7412:341b with SMTP id l28-20020a637c5c000000b003807412341bmr3701409pgn.38.1646911677833; Thu, 10 Mar 2022 03:27:57 -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.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Mar 2022 03:27:57 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 27/48] target/nios2: Implement cpuid Date: Thu, 10 Mar 2022 03:27:04 -0800 Message-Id: <20220310112725.570053-28-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::52e (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::52e; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52e.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" Copy the existing cpu_index into the space reserved for CR_CPUID. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/nios2/cpu.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/target/nios2/cpu.c b/target/nios2/cpu.c index ce2b0c6493..d491360973 100644 --- a/target/nios2/cpu.c +++ b/target/nios2/cpu.c @@ -163,6 +163,7 @@ static ObjectClass *nios2_cpu_class_by_name(const char *cpu_model) static void nios2_cpu_realizefn(DeviceState *dev, Error **errp) { CPUState *cs = CPU(dev); + Nios2CPU *cpu = NIOS2_CPU(cs); Nios2CPUClass *ncc = NIOS2_CPU_GET_CLASS(dev); Error *local_err = NULL; @@ -175,6 +176,9 @@ static void nios2_cpu_realizefn(DeviceState *dev, Error **errp) qemu_init_vcpu(cs); cpu_reset(cs); + /* We have reserved storage for cpuid; might as well use it. */ + cpu->env.ctrl[CR_CPUID] = cs->cpu_index; + ncc->parent_realize(dev, errp); } From patchwork Thu Mar 10 11:27:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 550123 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp930433mag; Thu, 10 Mar 2022 04:10:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJwnz6M6mhykfjbuK1fBgWX0xst7XD/SxdJiFjy0TE+L8VF1dPlN4H0sV0dOit05SFfUg28W X-Received: by 2002:a81:c443:0:b0:2d0:dfa3:9ed9 with SMTP id s3-20020a81c443000000b002d0dfa39ed9mr3643987ywj.220.1646914259360; Thu, 10 Mar 2022 04:10:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646914259; cv=none; d=google.com; s=arc-20160816; b=ojjiFuf09IBb5dRbb6b/WGFn3BdEjlzG2x9dk44mQc93lyPXJZ8JX7VeTaoeGKu036 idrJPui56kFcdLqmGeSR7WK4+fENRjMB/CajaX47sjx2+nLnsowL9a1td+R+BUyxOyUo aPj8KW1Xmcn6hOqPF3JyhVR9QbJgIG1ocj/9Xxk5xAwLbsccz5TvYJkKw9xpRcf9L3is mYs0Psvy/bkrzPZ/JugXW6/2olKPZdsUbj5zXcbhTt8kr1jaO3f71voFjttkv9JX/TQN Elwp3D6xfu+R/bT8qrTyMM2nk11dQKW85cVWHNvn8XRXlLc1nFPxmYvPpBmu+LI+Ea7L IePw== 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=/Bkn+M8H5Sg7KsSEJjzM7NcRnu8uA0epSOYEx1aHzNA=; b=jjR5422s9cBehiaSHO4Tww0q+J1ZgwIUJWWzKql9FYLBigcnvqNAmVQ/rfqmOzLtHs OcHfmhNcBvSIKT2SIIeG9j4r1evRtNoDCkC/yF1VBYuuF1Pj0ePY8UkEB5rhgzl46GDe oMDDkLTfnxruJPU3zsnlweprX3gad5fgMImLxGLQKkfhjIOArxPEJ7bLCkUB1xaFAhQh uLCOuqorAeqfwSaRas12/msqlvr1Ahkp2DoOi8qPpH4pnTTd8H/up8SnWFWEBZqP/UWP 0ZLweurj5fkNXKa646c9CxVRjST+mrBmeuuVkzo99Me8HZs0O2f8ESAbetH02M9lIKSc GrQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=XmJyrFeH; 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 b140-20020a81a492000000b002dc31aaaef2si2674155ywh.208.2022.03.10.04.10.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Mar 2022 04:10:59 -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=XmJyrFeH; 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]:39608 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSHd4-0003Zu-UA for patch@linaro.org; Thu, 10 Mar 2022 07:10:51 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50980) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSGxe-00065D-6Z for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:28:02 -0500 Received: from [2607:f8b0:4864:20::52f] (port=42544 helo=mail-pg1-x52f.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nSGxc-00080R-HR for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:28:01 -0500 Received: by mail-pg1-x52f.google.com with SMTP id o8so4480933pgf.9 for ; Thu, 10 Mar 2022 03:28:00 -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=/Bkn+M8H5Sg7KsSEJjzM7NcRnu8uA0epSOYEx1aHzNA=; b=XmJyrFeH3FCnsweb9OB80hyfGlrS4hcMEAeHrT7uRfkYCpYS/hwQr16W7mnPOPtW4q tcAU+Gsek5hKjxBDXp2XoRlXX5BbiRiaZxfF94ESM+9zV+Oyzatk5HOOwTYkiNk181wZ s4guo0dUAXXjzNR0mspMRB9R1+36pTVG3mVsRbM8MUi76d3CNbKCheRYgbANttvdXJ6e CerWfr9TmJ1J/VYy3xD9vuiHLptz7LgY+H9F5ycwDyP6UadsxsMWwyJasr6V1/a81RJg YCcQQWgmDycQHMEY3i7C+QNtQwe/7+QR/LVuX0BxtrzCOOytXptHU5K3J5vMaDRrxz9E HSjQ== 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=/Bkn+M8H5Sg7KsSEJjzM7NcRnu8uA0epSOYEx1aHzNA=; b=6ZFyHYzzxV9NMq0H637iKLDVlmxIKRb1mwW0Zeehpi1q5ADJVbWrksZAwwREy3+7ij MKKW965UkDY7l+Rqdf0rE0jjIET6KBHWeqrmYBCveb9uAGiW8/gndEa9ZyCPQHXiIf9+ XvGy4S3G4zf6MVtHTySndXOS3J3L4nksv7aSmGok/PxFcIrZjGvhTd/J08EvqKnd5Hr0 bZbJFNMA7OVIlrWPD5srQDDq6pYcLx+zddcRrs9NWIqzOcnXCf+6KkvximhJSZOWH8Nf H0dCLOztSqJb2Pzm11eWo3POyfQNHRGHpFVLGoD3cmAvU+ZAv5sDj6E6CXi09WKHHFLj iFsg== X-Gm-Message-State: AOAM533xT7dMNcUoQxBmncssMQ0+40bnEHH19cSM1QScSK+y2pQ6ejJU LZ7JbRB3XNl/TNwjf5Yd31oZUTJZNoecUg== X-Received: by 2002:a63:1665:0:b0:378:ba21:ddb9 with SMTP id 37-20020a631665000000b00378ba21ddb9mr3659626pgw.268.1646911679120; Thu, 10 Mar 2022 03:27:59 -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.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Mar 2022 03:27:58 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 28/48] target/nios2: Implement CR_STATUS.RSIE Date: Thu, 10 Mar 2022 03:27:05 -0800 Message-Id: <20220310112725.570053-29-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::52f (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::52f; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52f.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" Without EIC, this bit is RES1. So set the bit at reset, and add it to the readonly fields of CR_STATUS. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/nios2/cpu.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/target/nios2/cpu.c b/target/nios2/cpu.c index d491360973..64dc916ed2 100644 --- a/target/nios2/cpu.c +++ b/target/nios2/cpu.c @@ -56,9 +56,9 @@ static void nios2_cpu_reset(DeviceState *dev) memset(env->ctrl, 0, sizeof(env->ctrl)); #if defined(CONFIG_USER_ONLY) /* Start in user mode with interrupts enabled. */ - env->ctrl[CR_STATUS] = CR_STATUS_U | CR_STATUS_PIE; + env->ctrl[CR_STATUS] = CR_STATUS_RSIE | CR_STATUS_U | CR_STATUS_PIE; #else - env->ctrl[CR_STATUS] = 0; + env->ctrl[CR_STATUS] = CR_STATUS_RSIE; #endif env->regs[R_ZERO] = 0; @@ -109,6 +109,7 @@ static void nios2_cpu_initfn(Object *obj) WR_REG(CR_BADADDR); /* TODO: These control registers are not present with the EIC. */ + RO_FIELD(CR_STATUS, RSIE); WR_REG(CR_IENABLE); RO_REG(CR_IPENDING); From patchwork Thu Mar 10 11:27:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 550129 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp941926mag; Thu, 10 Mar 2022 04:24:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJzXIF5Oax2EtFcsiXuuWzMwuyAVK/mgQS5fg/d6/I/hfqfgvg0VwNH3Ho20BKu+meVS+xRj X-Received: by 2002:a81:7586:0:b0:2dc:14a7:ced2 with SMTP id q128-20020a817586000000b002dc14a7ced2mr3611274ywc.443.1646915073161; Thu, 10 Mar 2022 04:24:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646915073; cv=none; d=google.com; s=arc-20160816; b=wIVKXYPE5mfr4wxmzWrCMFpI777ruVU4O8BIe3yaD0Ocbn+1Rc2QktvjaaG33e/jAG vsd6/r5v92omDIn2u2LzibmnarXyECeT1jStVRdR7zAyJW2mqN22ujVG7YEGxu/25Xxf eI0h8cNVjltdhQRkkDpqfJN6+eYf+2fy3rRTYzdjR/eHzXWSxaKUVCuy9/h5YymgAvRK VQNUw++4IRfS5xbMzMoayiYcmcbuvawFBmmhN4TmHAtd3EIgRoJJKTHpbma9Ywdn41l0 6HAyRlJW4++FaGzHxTsO6OKjxwviMTHlfD3di7y363DwUKY/RQFegemgezbP2+z1mJnW D/NA== 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=X9NHWUxVFbhUbKp9xmQLehwV/i5chUkMUmRvZ87Nmy4=; b=BpGM850a5Tc1ExsO/Fd0aqAx93b3jRbfEshGFxup4mwYU5wKRt1CNxgq5Z/0AS7wmu 2n2kfhdX5aqjF54M8p3RYITDKrczA53E9BxZdtxHm2eFPiMcgT6CIr0jAiXA35QOa6f3 SeJkh7wcea77uH0i1VISi7NSGiAkw8XCTXaKr0NJkPfNUttqlajAbt5Vg6JFzl7y8iAT CXBBkwiOCpsZc6gKugk65K5jeEd5SYBzA7ROXI5efgAJcvBmdJUWzSjEeV3HEx4vzY5u jT3WXJvJPgX4ZObe2V8En6HNxGD+rS2e/tB3f3pMTSYEa7cGrVMzsC1MOIiqcWPTrKOk Jdng== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=bz9XmRB8; 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 t3-20020a814603000000b002d6aefa55aasi2607378ywa.454.2022.03.10.04.24.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Mar 2022 04:24:33 -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=bz9XmRB8; 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]:34748 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSHqK-0003YB-Ki for patch@linaro.org; Thu, 10 Mar 2022 07:24:32 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50998) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSGxf-000689-7N for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:28:03 -0500 Received: from [2607:f8b0:4864:20::62b] (port=43855 helo=mail-pl1-x62b.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-00080c-Mv for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:28:02 -0500 Received: by mail-pl1-x62b.google.com with SMTP id e2so4579794pls.10 for ; Thu, 10 Mar 2022 03:28:01 -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=X9NHWUxVFbhUbKp9xmQLehwV/i5chUkMUmRvZ87Nmy4=; b=bz9XmRB8VQu6dOEwqenN5EROsQoUuMV9GjtKCMFTATg2HEfFfOG0HrYrVO133bBDu4 +JG/Xeg6SnDerwDp1ZUQa7RhmCHT5fV5Sbq+QlSQy6efBuVC1OFEo97FQ9Csnp4ya2hP g+RWC5uhYBoGVcJgGqXa0+BW/fA8/iM3UTWyfDX/BIq1N5AaoDpkm56oKCRoLzsDVfzB s+/2cEf6s9I6KQ6FEb4s8+iimH/DY8SUyqubVGQ/4mdL8YLk9buK5xgDuigCSZ4GuZRw 3ixjAFQZIkfWajTTudDKcUjAlgy0zjl3OCFKLFms0q0X3UCHmNPy0Y9b1smz1hLl3hlY Lx2Q== 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=X9NHWUxVFbhUbKp9xmQLehwV/i5chUkMUmRvZ87Nmy4=; b=iLgnqI3EexicANQicFtdssV48bCpgSvWQNh4/EqEbAYhv9ubxqDI4J93zn440zuT3O wfhrRktgv2EYLccSa+0FFnFa/RRItdqTlLZNsLkQjmKrL3vG8+tgRcjuwf7TCjzQkFRp opyemJddyQEIRIdR8Lt/JW38G4qdmSaCCbL1TXB1tJWGESsnYKVgrTUOEHTR+y7x3mKE CIEb5jLZcGzFG2ffpu93OKe15oyZwsAIvvo5qxxqArFXUtC2R5zzVxs0V73SDwOh2jqE leq5n+tRPsSsQd4HLgNpIIWUV4q9xB0kK4shBbXwFUf+CwvDVKadW4BVeIS/HWAxvprD 8rXQ== X-Gm-Message-State: AOAM530WCsdcSNhlr5rh/pFFwJgmjDk0DOAVzyjVa3wgGGyDs30ydivB RhDsfNhDKOElgzKKe1YEqc4gXzDC3sHUZA== X-Received: by 2002:a17:903:40c3:b0:151:c8a2:1c46 with SMTP id t3-20020a17090340c300b00151c8a21c46mr4605705pld.141.1646911680374; Thu, 10 Mar 2022 03:28:00 -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.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Mar 2022 03:27:59 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 29/48] target/nios2: Remove CPU_INTERRUPT_NMI Date: Thu, 10 Mar 2022 03:27:06 -0800 Message-Id: <20220310112725.570053-30-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::62b (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.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" This interrupt bit is never set, so testing it in nios2_cpu_has_work is pointless. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/nios2/cpu.h | 2 -- target/nios2/cpu.c | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/target/nios2/cpu.h b/target/nios2/cpu.h index 410e76ccbb..161f8efe82 100644 --- a/target/nios2/cpu.h +++ b/target/nios2/cpu.h @@ -177,8 +177,6 @@ FIELD(CR_TLBMISC, EE, 24, 1) #define EXCP_MPUI 16 #define EXCP_MPUD 17 -#define CPU_INTERRUPT_NMI CPU_INTERRUPT_TGT_EXT_3 - struct CPUArchState { uint32_t regs[NUM_GP_REGS]; uint32_t ctrl[NUM_CR_REGS]; diff --git a/target/nios2/cpu.c b/target/nios2/cpu.c index 64dc916ed2..745a583f9d 100644 --- a/target/nios2/cpu.c +++ b/target/nios2/cpu.c @@ -36,7 +36,7 @@ static void nios2_cpu_set_pc(CPUState *cs, vaddr value) static bool nios2_cpu_has_work(CPUState *cs) { - return cs->interrupt_request & (CPU_INTERRUPT_HARD | CPU_INTERRUPT_NMI); + return cs->interrupt_request & CPU_INTERRUPT_HARD; } static void nios2_cpu_reset(DeviceState *dev) From patchwork Thu Mar 10 11:27:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 550125 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp933177mag; Thu, 10 Mar 2022 04:14:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJwoyIum/RoP8b9pJZ9BLgCD2ncKIRsCOlU7kc5rnkzth1nB/DCbutyk1Opa7JAi7ufwjGz9 X-Received: by 2002:a0d:df50:0:b0:2db:f473:344f with SMTP id i77-20020a0ddf50000000b002dbf473344fmr3483472ywe.283.1646914470660; Thu, 10 Mar 2022 04:14:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646914470; cv=none; d=google.com; s=arc-20160816; b=I5WYfebJQ+V9+4IFeMrXO0C9o/YrP505Noda+G1EPfM/dCCofaXlBuv0WUw1FfbpbM Hwop0UhHutNlvUP9suPeXP85sCxTRhTcZz77yA8EhgTfeje7+z3IEeShCjEXPdoMODs6 HC6+XTuXCdLekBwN6y87uC/6nKc0bLhwcI+Rp2zjGUxBdC05uOEGkg6uVVD+YZjtBTiO Kikq54iiTNS5MWeOLPfdnjFTFFecNxANqUhxT2gVd9ztkdBy1JO2uQ2bIPiZm9GZkuV2 f+x6PjxAhAdDizMaztZBFoez5K7ZSvH5huYMLdfinXppGcalBK2c9wsrIdyFPLjK4wb6 y3gA== 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=PvVjJW4JNMk/C3CxxpvaZU1mv/KFzjzrkRcyiH8whDc=; b=VYlKBzWXex5NIoD05jUybpKZ8pykT8IwtrCsrT/bz/lzGvk4PpP0a5MVLApC3kn2eQ MweSeHA+HnlO+7K2C3eEGq3Z/u4JzsK8mj7JGA1EDE6uY41k+t8B7U8pLtuVxTW9M3tg Ts97wNV4BDhAifn7X76QVzQJgO0TDvAX5MWLVaSBPwcZtwR+aOHVPB3F8qzAJpqp7mJh iYNx/SCHGdoyyMNrRcSHjSuIwNlrub0sARoe56EIpuflWUMnKPTk8hUxR8EJBCf9OJIf StfI9Cn1VRb/8014uYZcDTdJ/rzbelknUUZm2maoCUd0yHTKChBRH6LhWzueNqC3ybUQ lTfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=tjkEhfJx; 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 12-20020a25050c000000b00628fbd78af4si3012893ybf.333.2022.03.10.04.14.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Mar 2022 04:14:30 -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=tjkEhfJx; 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]:46016 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSHgc-0008QS-4f for patch@linaro.org; Thu, 10 Mar 2022 07:14:30 -0500 Received: from eggs.gnu.org ([209.51.188.92]:51026) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSGxg-0006BY-Ty for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:28:04 -0500 Received: from [2607:f8b0:4864:20::529] (port=35714 helo=mail-pg1-x529.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nSGxe-00080w-T8 for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:28:04 -0500 Received: by mail-pg1-x529.google.com with SMTP id e6so4501193pgn.2 for ; Thu, 10 Mar 2022 03:28:02 -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=PvVjJW4JNMk/C3CxxpvaZU1mv/KFzjzrkRcyiH8whDc=; b=tjkEhfJxD4TAgJh8t7FY6PDRv9n2hM0/UjnEDfWrUaX9HktSyYl07qdFmIr1JW1jPi mQNZpIcRlppC4vDQ7jr8i8gW2/LBo2cOsgqZ5lwZ3whiyFwoe1OL9jTgKyLctraTb+BR zhzG40TGgsWOuhBkq9dPiKzibehI4vmUf2Rld+aHg9d8GoP/sIEhCDVIsSrwpbfZnuuU MX898mTztam9Oz49zJyaQTaibz2+I9y6eUwfZIbthidYJvKEEpBnfMXsSINm+oi3j4pT vNJKXEwUmKZNxLBuNskTJh8wXgnNPeQ3AepRosR7ulfUQ2YXT0pK2PdRMUHCopuzo/lI RqNA== 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=PvVjJW4JNMk/C3CxxpvaZU1mv/KFzjzrkRcyiH8whDc=; b=qXkY3sEC3VKwBVVbmwwvDFHHzS3FK/GBSLCWQM8JhglgO4cf0ubTXtL75Lij0kYTy9 xD4wWHpFBdv7GjrI6Pbm7vYS2ClxIXpcb8wEwsYLllIei4l2k7OtdIH7Kh2yvRK5g8Gv 1gOFjODiqj56RciDr470P+c2T9buim00nt/vyj+TbQEGxRycHiEXdGmSIVkamYIAspql x7oWBcZDl+foP+8udk5uJS3rOPgEBH9W87+VkTqCeRdbkrdrQDgNzfQxru9BY9l3JCzn y3NYLbxucDu283NoP9WMOxqHU7kA+90cIROXrmFfPXboojZQX6ap+zkK10NmVePrMiZm AaQA== X-Gm-Message-State: AOAM533mse0IVHHAM/WeIgGarMQfjKMfUxHB1TKxeXdrbCck4CM3BjoX P//aQ3uZ0KaCOkF4CwuXvfAC4pciVjSMEQ== X-Received: by 2002:a63:1321:0:b0:376:333b:3ed with SMTP id i33-20020a631321000000b00376333b03edmr3577341pgl.283.1646911681397; Thu, 10 Mar 2022 03:28:01 -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.28.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Mar 2022 03:28:00 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 30/48] target/nios2: Support division error exception Date: Thu, 10 Mar 2022 03:27:07 -0800 Message-Id: <20220310112725.570053-31-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::529 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::529; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x529.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" Division may (optionally) raise a division exception. Since the linux kernel has been prepared for this for some time, enable it by default. Signed-off-by: Richard Henderson --- target/nios2/cpu.h | 2 ++ target/nios2/helper.h | 2 ++ linux-user/nios2/cpu_loop.c | 4 +++ target/nios2/cpu.c | 1 + target/nios2/helper.c | 4 +++ target/nios2/op_helper.c | 29 ++++++++++++++++++ target/nios2/translate.c | 60 +++++++++++++------------------------ 7 files changed, 62 insertions(+), 40 deletions(-) diff --git a/target/nios2/cpu.h b/target/nios2/cpu.h index 161f8efe82..95079c186c 100644 --- a/target/nios2/cpu.h +++ b/target/nios2/cpu.h @@ -207,7 +207,9 @@ struct ArchCPU { CPUNegativeOffsetState neg; CPUNios2State env; + bool diverr_present; bool mmu_present; + uint32_t pid_num_bits; uint32_t tlb_num_ways; uint32_t tlb_num_entries; diff --git a/target/nios2/helper.h b/target/nios2/helper.h index 525b6b685b..6f5ec60b0d 100644 --- a/target/nios2/helper.h +++ b/target/nios2/helper.h @@ -19,6 +19,8 @@ */ DEF_HELPER_FLAGS_2(raise_exception, TCG_CALL_NO_WG, noreturn, env, i32) +DEF_HELPER_FLAGS_3(divs, TCG_CALL_NO_WG, s32, env, s32, s32) +DEF_HELPER_FLAGS_3(divu, TCG_CALL_NO_WG, i32, env, i32, i32) #if !defined(CONFIG_USER_ONLY) DEF_HELPER_3(eret, noreturn, env, i32, i32) diff --git a/linux-user/nios2/cpu_loop.c b/linux-user/nios2/cpu_loop.c index fa234cb2af..ea364b7d1f 100644 --- a/linux-user/nios2/cpu_loop.c +++ b/linux-user/nios2/cpu_loop.c @@ -39,6 +39,10 @@ void cpu_loop(CPUNios2State *env) /* just indicate that signals should be handled asap */ break; + case EXCP_DIV: + force_sig_fault(TARGET_SIGFPE, TARGET_FPE_INTDIV, env->pc); + break; + case EXCP_TRAP: switch (env->error_code) { case 0: diff --git a/target/nios2/cpu.c b/target/nios2/cpu.c index 745a583f9d..b8410d8447 100644 --- a/target/nios2/cpu.c +++ b/target/nios2/cpu.c @@ -262,6 +262,7 @@ static int nios2_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) } static Property nios2_properties[] = { + DEFINE_PROP_BOOL("diverr_present", Nios2CPU, diverr_present, true), DEFINE_PROP_BOOL("mmu_present", Nios2CPU, mmu_present, true), /* ALTR,pid-num-bits */ DEFINE_PROP_UINT32("mmu_pid_num_bits", Nios2CPU, pid_num_bits, 8), diff --git a/target/nios2/helper.c b/target/nios2/helper.c index 8b69918ba3..460032adc0 100644 --- a/target/nios2/helper.c +++ b/target/nios2/helper.c @@ -139,6 +139,9 @@ void nios2_cpu_do_interrupt(CPUState *cs) case EXCP_UNALIGND: name = "Misaligned (destination)"; break; + case EXCP_DIV: + name = "DIV error"; + break; case EXCP_TRAP: name = "TRAP insn"; break; @@ -210,6 +213,7 @@ void nios2_cpu_do_interrupt(CPUState *cs) case EXCP_SUPERI: case EXCP_ILLEGAL: + case EXCP_DIV: case EXCP_TRAP: do_exception(cpu, cpu->exception_addr, 0, false); break; diff --git a/target/nios2/op_helper.c b/target/nios2/op_helper.c index c56fc15283..c93b66c9aa 100644 --- a/target/nios2/op_helper.c +++ b/target/nios2/op_helper.c @@ -31,6 +31,35 @@ void helper_raise_exception(CPUNios2State *env, uint32_t index) cpu_loop_exit(cs); } +static void maybe_raise_div(CPUNios2State *env, uintptr_t ra) +{ + Nios2CPU *cpu = env_archcpu(env); + CPUState *cs = env_cpu(env); + + if (cpu->diverr_present) { + cs->exception_index = EXCP_DIV; + cpu_loop_exit_restore(cs, ra); + } +} + +int32_t helper_divs(CPUNios2State *env, int32_t num, int32_t den) +{ + if (unlikely(den == 0) || unlikely(den == -1 && num == INT32_MIN)) { + maybe_raise_div(env, GETPC()); + return num; /* undefined */ + } + return num / den; +} + +uint32_t helper_divu(CPUNios2State *env, uint32_t num, uint32_t den) +{ + if (unlikely(den == 0)) { + maybe_raise_div(env, GETPC()); + return num; /* undefined */ + } + return num / den; +} + #ifndef CONFIG_USER_ONLY void helper_eret(CPUNios2State *env, uint32_t new_status, uint32_t new_pc) { diff --git a/target/nios2/translate.c b/target/nios2/translate.c index 21dc6947cf..c8fb05a9cb 100644 --- a/target/nios2/translate.c +++ b/target/nios2/translate.c @@ -654,59 +654,39 @@ gen_r_shift_s(ror, rotr_tl) static void divs(DisasContext *dc, uint32_t code, uint32_t flags) { R_TYPE(instr, (code)); + TCGv dest; - /* Stores into R_ZERO are ignored */ - if (unlikely(instr.c == R_ZERO)) { - return; + if (instr.c == R_ZERO) { + dest = tcg_temp_new(); + } else { + dest = cpu_R[instr.c]; } - TCGv t0 = tcg_temp_new(); - TCGv t1 = tcg_temp_new(); - TCGv t2 = tcg_temp_new(); - TCGv t3 = tcg_temp_new(); + gen_helper_divs(dest, cpu_env, + load_gpr(dc, instr.a), load_gpr(dc, instr.b)); - tcg_gen_ext32s_tl(t0, load_gpr(dc, instr.a)); - tcg_gen_ext32s_tl(t1, load_gpr(dc, instr.b)); - tcg_gen_setcondi_tl(TCG_COND_EQ, t2, t0, INT_MIN); - tcg_gen_setcondi_tl(TCG_COND_EQ, t3, t1, -1); - tcg_gen_and_tl(t2, t2, t3); - tcg_gen_setcondi_tl(TCG_COND_EQ, t3, t1, 0); - tcg_gen_or_tl(t2, t2, t3); - tcg_gen_movi_tl(t3, 0); - tcg_gen_movcond_tl(TCG_COND_NE, t1, t2, t3, t2, t1); - tcg_gen_div_tl(cpu_R[instr.c], t0, t1); - tcg_gen_ext32s_tl(cpu_R[instr.c], cpu_R[instr.c]); - - tcg_temp_free(t3); - tcg_temp_free(t2); - tcg_temp_free(t1); - tcg_temp_free(t0); + if (instr.c == R_ZERO) { + tcg_temp_free(dest); + } } static void divu(DisasContext *dc, uint32_t code, uint32_t flags) { R_TYPE(instr, (code)); + TCGv dest; - /* Stores into R_ZERO are ignored */ - if (unlikely(instr.c == R_ZERO)) { - return; + if (instr.c == R_ZERO) { + dest = tcg_temp_new(); + } else { + dest = cpu_R[instr.c]; } - TCGv t0 = tcg_temp_new(); - TCGv t1 = tcg_temp_new(); - TCGv t2 = tcg_const_tl(0); - TCGv t3 = tcg_const_tl(1); + gen_helper_divu(dest, cpu_env, + load_gpr(dc, instr.a), load_gpr(dc, instr.b)); - tcg_gen_ext32u_tl(t0, load_gpr(dc, instr.a)); - tcg_gen_ext32u_tl(t1, load_gpr(dc, instr.b)); - tcg_gen_movcond_tl(TCG_COND_EQ, t1, t1, t2, t3, t1); - tcg_gen_divu_tl(cpu_R[instr.c], t0, t1); - tcg_gen_ext32s_tl(cpu_R[instr.c], cpu_R[instr.c]); - - tcg_temp_free(t3); - tcg_temp_free(t2); - tcg_temp_free(t1); - tcg_temp_free(t0); + if (instr.c == R_ZERO) { + tcg_temp_free(dest); + } } static void trap(DisasContext *dc, uint32_t code, uint32_t flags) From patchwork Thu Mar 10 11:27:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 550093 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp907438mag; Thu, 10 Mar 2022 03:40:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJwQw9KTX355kvz0asTrc0VF56Q6iUOY8ZzXaUmwgVfP4ClHL6Tk++Gbhs3WKdOWBb1y/l8M X-Received: by 2002:a25:7903:0:b0:622:3940:7c7c with SMTP id u3-20020a257903000000b0062239407c7cmr3633600ybc.334.1646912428487; Thu, 10 Mar 2022 03:40:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646912428; cv=none; d=google.com; s=arc-20160816; b=zTU9hDqeIFeEiO//9avo3P2izG1UubzfKCDRqwOEIlejELLV477fYS2HOD0kVJiD1w ySlzAA696YU55d+yDhrBMT8UpKrYF01wV29cmttbQRt6wAkbltIruzYgfDpHPM9fDPkA VGjjHr9/opZFUGWwLAXCVonxxsLcEIrj1zL9/wbaMlZ240ZrgW+CTAI/dhblisqxulw9 QCkGv/dw3J+Fg6MHoZTmZqy42n+gBoziM6V7Kj2fBoNJchowFPG1Pf7hQeKgOIYQJiIw RpFUAyA/HynbNCoVoW5TcKAFoRcj6erVEn7JYjqHAyldtd1WyD4ZY0qdVvZoQ9Wm3+nG F8Yg== 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=ryxSDJJrKjueVH0OEsU0bn5y9v3EMgUpEWxAYhSIfi0=; b=EPcZPkDulg6MDlDTOrs8/eu+mQQqNbe2DgGQ/qvsW5JNnkb7VKg3HjtZRQJWveT6lF 5oopvZo5YW/EqUkf9V5HRb7ADlfYoTQaM4zXkw4vZmVCiVVVxfdlxzEJL0ybeTicRnQB OJrVKxEZbm9F2KZz/+UdV2FLTFk1s+jwxNER7LVdZIEyTDJQ9yYOWPjtK+ahkr1WsbN9 Mym9FDApF9ANyJpt1RL+TOVb6UGw920hhFxtnI24c2FPJph8BsSt6UDyTO64zszotzNN UOVl1aOi4EyX3X+i76akQZISLMXTJEbB9Qfb6AORXxA9MQwDFHnR/sCCAp2Tj+BANR/g 1yoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ZZviliMd; 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 193-20020a8119ca000000b002dc241ceafbsi2597157ywz.375.2022.03.10.03.40.28 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Mar 2022 03:40:28 -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=ZZviliMd; 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]:49320 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSH9f-00024w-VQ for patch@linaro.org; Thu, 10 Mar 2022 06:40:28 -0500 Received: from eggs.gnu.org ([209.51.188.92]:51052) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSGxi-0006EL-2q for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:28:06 -0500 Received: from [2607:f8b0:4864:20::102b] (port=33653 helo=mail-pj1-x102b.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nSGxg-00081A-4K for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:28:05 -0500 Received: by mail-pj1-x102b.google.com with SMTP id v1-20020a17090a088100b001bf25f97c6eso6400303pjc.0 for ; Thu, 10 Mar 2022 03:28:03 -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=ryxSDJJrKjueVH0OEsU0bn5y9v3EMgUpEWxAYhSIfi0=; b=ZZviliMdA7iS9Uc5FMCSioqYhTyyTd8R7dbXt3Q3LXy7YzbF8GWjTw8hrFX1dTPDcG qPPY6evnzpt0tnZIQ2ABrnmCERRGora9dtIvXCD+4RZtvGdfAH9VFTqCGIo9MyikxW4f ufarYiBKyYCCcgZM/sd0sOmMCnh7BUfucYrHsJHhvOppxRvSMEo4GBZs9XbVlMBrAbWR f9Zie1av6XRQ3Rzlun1UKKlfnZrzUde5aRXjHGt6IZ9JvqyJwV7hNtu09u1681ixpZtl 39Nlr/dlVoIefqlPaIcplMM160M1HSqzSk9i72HsejtqKeMxTvEKQerr6iVAHhVJgOGU 26CQ== 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=ryxSDJJrKjueVH0OEsU0bn5y9v3EMgUpEWxAYhSIfi0=; b=z41Tg099BVuii6URjjDRm7mdp6CtFQ2E5UpXo0lPTZ4MN1or0P09W10NFdPSNIYXa2 E2FvfTHBD9DLsUUDesaekq2/EOx3IlfIrpI54lqgqrHOM+tx7F02vGCL5HMO3eOn/bX8 l9AqyRb/kDkM0rUm2xtBwHyohAFeoVhfij49h6+jiDFibHzOx+k6Xq/oVlTfb00WV4zU 0BBn3LSQ14ccsjMb+RH0hM2nS6E87E+0ADnMKqgfTPhpCK8em5vlg1v5Q9967kXcQ5M8 OZyxivGvg0f78PJeepzYGvQPIYzZLn0jqQsJM7PY8VsLUGxkBXX2DwMHV5JGfbFaBwfd LPjA== X-Gm-Message-State: AOAM533VqfH/ahiEIoEoY38nnzL3QmuAXLj50WZJC64S9D4z1HaHKCQT u0YqVEyFPPzfN4hLSyCnEpGceQ0ggW27Pw== X-Received: by 2002:a17:90a:6543:b0:1b9:1dce:a23d with SMTP id f3-20020a17090a654300b001b91dcea23dmr4416244pjs.243.1646911682793; Thu, 10 Mar 2022 03:28:02 -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.28.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Mar 2022 03:28:02 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 31/48] target/nios2: Use tcg_constant_tl Date: Thu, 10 Mar 2022 03:27:08 -0800 Message-Id: <20220310112725.570053-32-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::102b (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::102b; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102b.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" Replace current uses of tcg_const_tl, and remove the frees. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/nios2/translate.c | 30 ++++++------------------------ 1 file changed, 6 insertions(+), 24 deletions(-) diff --git a/target/nios2/translate.c b/target/nios2/translate.c index c8fb05a9cb..4ad47bb966 100644 --- a/target/nios2/translate.c +++ b/target/nios2/translate.c @@ -99,7 +99,6 @@ typedef struct DisasContext { DisasContextBase base; - TCGv_i32 zero; target_ulong pc; int mem_idx; const ControlRegState *cr_state; @@ -125,31 +124,20 @@ static uint8_t get_opxcode(uint32_t code) return instr.opx; } -static TCGv load_zero(DisasContext *dc) +static TCGv load_gpr(DisasContext *dc, unsigned reg) { - if (!dc->zero) { - dc->zero = tcg_const_i32(0); - } - return dc->zero; -} - -static TCGv load_gpr(DisasContext *dc, uint8_t reg) -{ - if (likely(reg != R_ZERO)) { - return cpu_R[reg]; - } else { - return load_zero(dc); + assert(reg < NUM_GP_REGS); + if (unlikely(reg == R_ZERO)) { + return tcg_constant_tl(0); } + return cpu_R[reg]; } static void t_gen_helper_raise_exception(DisasContext *dc, uint32_t index) { - TCGv_i32 tmp = tcg_const_i32(index); - tcg_gen_movi_tl(cpu_pc, dc->pc); - gen_helper_raise_exception(cpu_env, tmp); - tcg_temp_free_i32(tmp); + gen_helper_raise_exception(cpu_env, tcg_constant_i32(index)); dc->base.is_jmp = DISAS_NORETURN; } @@ -876,14 +864,8 @@ static void nios2_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs) return; } - dc->zero = NULL; - instr = &i_type_instructions[op]; instr->handler(dc, code, instr->flags); - - if (dc->zero) { - tcg_temp_free(dc->zero); - } } static void nios2_tr_tb_stop(DisasContextBase *dcbase, CPUState *cs) From patchwork Thu Mar 10 11:27:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 550113 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp921280mag; Thu, 10 Mar 2022 04:00:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJz4leBLRx+hvVanaWakiNzmJfnk3AcRoL2VfDou9Y592DRxFnwH1jXh34DJCGYk2Ze0j4S4 X-Received: by 2002:a81:1797:0:b0:2dc:2c83:8fb6 with SMTP id 145-20020a811797000000b002dc2c838fb6mr3680678ywx.188.1646913626929; Thu, 10 Mar 2022 04:00:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646913626; cv=none; d=google.com; s=arc-20160816; b=P/nPCbUMRPIhGWb0apjCUoQ15bjytH7JHQbaaOczzf/jL07Yz/VsamF1DePf/zNWFP m9T6eMsLhVmZgPF30CcGKo0nKabRDs1/OadhaNCKfnw5rDIMmGJu3U+dqogg+af9rCkt npxWIgyG5/q5YWzMA+lA44FjE1Ish3eGG8/jGE8pnKT2lnoEMxnhyLWDI4CAfPMWHzi8 7t46HEQt0tEqQ7B9HwVijwB19SKZ23QD4tIUTUtZQoEF7IEXeEQ1TBmsNo1M222UoDCP AFg7K+HFtWbtT07OYzI5kZ+RTmlMtm/gtcoupfY6L/7Gc8dvtXeh3ECV+c16oEIyVywi JLjQ== 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=rjl4pB0UOR++7sXmU/aZUMTVos+sgfIbyM2Yn1YOAwo=; b=OJqlTzAHFVFvj/dG6+o6KokLJ8AmrR/u9yPM8Fgro7/DFg3cqBrG35C6aGQccBhsER dt0p2jedIcUg4iCHMk7n3LK/5/D14hCjYnfS0/5Q6i5XFG2+bFRVjPvUADM8JBB7YKtf v6xu9qjv0IkBvEUpCvSIc3g8H/wFsD9KmNLYwk7oFDR1sglK0dmQHA72ZH88O2g9/EwD 20bi4jE7utot2qCSMqtFJN6azr9+6NK1cxt3oUPX0glsrJWnf8bV+s8QVsMg+BNo4atp F+AhJXZBWCdpfSVBrqoUQDZYG0z/TyO3/00t1CYGxElRT7wu6rW872+GADHu2p0TnOrO FEOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=PdzvJM+a; 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 c126-20020a814e84000000b002dc346cadb8si3116315ywb.120.2022.03.10.04.00.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Mar 2022 04:00:26 -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=PdzvJM+a; 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]:47804 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSHT0-0006Dv-CH for patch@linaro.org; Thu, 10 Mar 2022 07:00:26 -0500 Received: from eggs.gnu.org ([209.51.188.92]:51076) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSGxj-0006Et-6W for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:28:08 -0500 Received: from [2607:f8b0:4864:20::62f] (port=44793 helo=mail-pl1-x62f.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nSGxh-00081I-70 for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:28:06 -0500 Received: by mail-pl1-x62f.google.com with SMTP id q11so4571389pln.11 for ; Thu, 10 Mar 2022 03:28:04 -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=rjl4pB0UOR++7sXmU/aZUMTVos+sgfIbyM2Yn1YOAwo=; b=PdzvJM+aG+amviE2rU06oocexqlR5KZxMmh442vNxzmNq1J1YAaGgKfwLekAol9NtE yoSnSQKlLJQolHyCSWTWMQJp0dwa0BzHhNI0JRZ/Nq2K/1rsR+GCyu34jii2FYYT+f5Z zcsISBlgegNOlqNqSXVRDI4PaSogr3tsD5aqd7S94V5hFsKoaMECcj1HjyTRhP0hZhj5 yceBWV/fEQWqzlgL/PyxjJ+T+bZNtg07cbBvRyQ6izcTa7mWP8eqOjDPJUi7j/LJ/Vg1 Suz4QEZM3cCZOtMHH34CjpPUoKXF99S0vMWoHFeKTcDn7zeJ9eHnDiDY2jckAqKUGnr6 qRKg== 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=rjl4pB0UOR++7sXmU/aZUMTVos+sgfIbyM2Yn1YOAwo=; b=va5/YWunOMyudK+oqdkFQhH+d3wJJheQMk0bRxVvrJb/U29qLtgync6YMTb41IIXXX g4UzyrMyLzxCrx+zyJaA5UGV/L6eubGljNOx4z3+jlEEm4vVMiGhk/SADMG2RvlXt2eP 2DhAbK5Xwg07HFWjy8v4z2o+aDPOBffqeo/ypt1d2u+2O5fSzkrqKdBHi+FBFUpv4zwx aWftoxyCEpv8+ntSKAf8A7kVZT0av8NeGbxs01S3Zj7vxi7qpI8/8QdYlWkSeV/v5cbV EHeZZYeyK1AniU7Z1smNVYaC3Z2RXTSIx7sXOeK4Ab2hYm3krvh7k0Z8vN+J4Tg+dJzn MChQ== X-Gm-Message-State: AOAM531gqscREzUMVzV5zDctKcoXxS5RkYgnVUw9RAE73yO2CWS3ZVa4 gPkvI4yCpDUby6UC/bWzOgmWAuKWTJqpMA== X-Received: by 2002:a17:902:ab4c:b0:151:eb86:dcb5 with SMTP id ij12-20020a170902ab4c00b00151eb86dcb5mr4472762plb.126.1646911683796; Thu, 10 Mar 2022 03:28:03 -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.28.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Mar 2022 03:28:03 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 32/48] target/nios2: Introduce dest_gpr Date: Thu, 10 Mar 2022 03:27:09 -0800 Message-Id: <20220310112725.570053-33-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::62f (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::62f; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62f.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" Constrain all references to cpu_R[] to load_gpr and dest_gpr. This will be required for supporting shadow register sets. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/nios2/translate.c | 153 ++++++++++++++------------------------- 1 file changed, 55 insertions(+), 98 deletions(-) diff --git a/target/nios2/translate.c b/target/nios2/translate.c index 4ad47bb966..d5f2e98de9 100644 --- a/target/nios2/translate.c +++ b/target/nios2/translate.c @@ -101,6 +101,7 @@ typedef struct DisasContext { DisasContextBase base; target_ulong pc; int mem_idx; + TCGv sink; const ControlRegState *cr_state; } DisasContext; @@ -133,6 +134,18 @@ static TCGv load_gpr(DisasContext *dc, unsigned reg) return cpu_R[reg]; } +static TCGv dest_gpr(DisasContext *dc, unsigned reg) +{ + assert(reg < NUM_GP_REGS); + if (unlikely(reg == R_ZERO)) { + if (dc->sink == NULL) { + dc->sink = tcg_temp_new(); + } + return dc->sink; + } + return cpu_R[reg]; +} + static void t_gen_helper_raise_exception(DisasContext *dc, uint32_t index) { @@ -191,7 +204,7 @@ static void jmpi(DisasContext *dc, uint32_t code, uint32_t flags) static void call(DisasContext *dc, uint32_t code, uint32_t flags) { - tcg_gen_movi_tl(cpu_R[R_RA], dc->base.pc_next); + tcg_gen_movi_tl(dest_gpr(dc, R_RA), dc->base.pc_next); jmpi(dc, code, flags); } @@ -204,27 +217,10 @@ static void gen_ldx(DisasContext *dc, uint32_t code, uint32_t flags) I_TYPE(instr, code); TCGv addr = tcg_temp_new(); - TCGv data; - - /* - * WARNING: Loads into R_ZERO are ignored, but we must generate the - * memory access itself to emulate the CPU precisely. Load - * from a protected page to R_ZERO will cause SIGSEGV on - * the Nios2 CPU. - */ - if (likely(instr.b != R_ZERO)) { - data = cpu_R[instr.b]; - } else { - data = tcg_temp_new(); - } + TCGv data = dest_gpr(dc, instr.b); tcg_gen_addi_tl(addr, load_gpr(dc, instr.a), instr.imm16.s); tcg_gen_qemu_ld_tl(data, addr, dc->mem_idx, flags); - - if (unlikely(instr.b == R_ZERO)) { - tcg_temp_free(data); - } - tcg_temp_free(addr); } @@ -254,7 +250,7 @@ static void gen_bxx(DisasContext *dc, uint32_t code, uint32_t flags) I_TYPE(instr, code); TCGLabel *l1 = gen_new_label(); - tcg_gen_brcond_tl(flags, cpu_R[instr.a], cpu_R[instr.b], l1); + tcg_gen_brcond_tl(flags, load_gpr(dc, instr.a), load_gpr(dc, instr.b), l1); gen_goto_tb(dc, 0, dc->base.pc_next); gen_set_label(l1); gen_goto_tb(dc, 1, dc->base.pc_next + (instr.imm16.s & -4)); @@ -262,11 +258,12 @@ static void gen_bxx(DisasContext *dc, uint32_t code, uint32_t flags) } /* Comparison instructions */ -#define gen_i_cmpxx(fname, op3) \ -static void (fname)(DisasContext *dc, uint32_t code, uint32_t flags) \ -{ \ - I_TYPE(instr, (code)); \ - tcg_gen_setcondi_tl(flags, cpu_R[instr.b], cpu_R[instr.a], (op3)); \ +#define gen_i_cmpxx(fname, op3) \ +static void (fname)(DisasContext *dc, uint32_t code, uint32_t flags) \ +{ \ + I_TYPE(instr, (code)); \ + tcg_gen_setcondi_tl(flags, dest_gpr(dc, instr.b), \ + load_gpr(dc, instr.a), (op3)); \ } gen_i_cmpxx(gen_cmpxxsi, instr.imm16.s) @@ -277,13 +274,7 @@ gen_i_cmpxx(gen_cmpxxui, instr.imm16.u) static void (fname)(DisasContext *dc, uint32_t code, uint32_t flags) \ { \ I_TYPE(instr, (code)); \ - if (unlikely(instr.b == R_ZERO)) { /* Store to R_ZERO is ignored */ \ - return; \ - } else if (instr.a == R_ZERO) { /* MOVxI optimizations */ \ - tcg_gen_movi_tl(cpu_R[instr.b], (resimm) ? (op3) : 0); \ - } else { \ - tcg_gen_##insn##_tl(cpu_R[instr.b], cpu_R[instr.a], (op3)); \ - } \ + tcg_gen_##insn##_tl(dest_gpr(dc, instr.b), load_gpr(dc, instr.a), (op3)); \ } gen_i_math_logic(addi, addi, 1, instr.imm16.s) @@ -386,7 +377,7 @@ static void eret(DisasContext *dc, uint32_t code, uint32_t flags) #else TCGv tmp = tcg_temp_new(); tcg_gen_ld_tl(tmp, cpu_env, offsetof(CPUNios2State, ctrl[CR_ESTATUS])); - gen_helper_eret(cpu_env, tmp, cpu_R[R_EA]); + gen_helper_eret(cpu_env, tmp, load_gpr(dc, R_EA)); tcg_temp_free(tmp); dc->base.is_jmp = DISAS_NORETURN; @@ -396,8 +387,7 @@ static void eret(DisasContext *dc, uint32_t code, uint32_t flags) /* PC <- ra */ static void ret(DisasContext *dc, uint32_t code, uint32_t flags) { - tcg_gen_mov_tl(cpu_pc, cpu_R[R_RA]); - + tcg_gen_mov_tl(cpu_pc, load_gpr(dc, R_RA)); dc->base.is_jmp = DISAS_JUMP; } @@ -416,7 +406,7 @@ static void bret(DisasContext *dc, uint32_t code, uint32_t flags) #else TCGv tmp = tcg_temp_new(); tcg_gen_ld_tl(tmp, cpu_env, offsetof(CPUNios2State, ctrl[CR_BSTATUS])); - gen_helper_eret(cpu_env, tmp, cpu_R[R_BA]); + gen_helper_eret(cpu_env, tmp, load_gpr(dc, R_BA)); tcg_temp_free(tmp); dc->base.is_jmp = DISAS_NORETURN; @@ -429,7 +419,6 @@ static void jmp(DisasContext *dc, uint32_t code, uint32_t flags) R_TYPE(instr, code); tcg_gen_mov_tl(cpu_pc, load_gpr(dc, instr.a)); - dc->base.is_jmp = DISAS_JUMP; } @@ -438,9 +427,7 @@ static void nextpc(DisasContext *dc, uint32_t code, uint32_t flags) { R_TYPE(instr, code); - if (likely(instr.c != R_ZERO)) { - tcg_gen_movi_tl(cpu_R[instr.c], dc->base.pc_next); - } + tcg_gen_movi_tl(dest_gpr(dc, instr.c), dc->base.pc_next); } /* @@ -452,7 +439,7 @@ static void callr(DisasContext *dc, uint32_t code, uint32_t flags) R_TYPE(instr, code); tcg_gen_mov_tl(cpu_pc, load_gpr(dc, instr.a)); - tcg_gen_movi_tl(cpu_R[R_RA], dc->base.pc_next); + tcg_gen_movi_tl(dest_gpr(dc, R_RA), dc->base.pc_next); dc->base.is_jmp = DISAS_JUMP; } @@ -468,15 +455,11 @@ static void rdctl(DisasContext *dc, uint32_t code, uint32_t flags) g_assert_not_reached(); #else R_TYPE(instr, code); - TCGv t1, t2; - - if (unlikely(instr.c == R_ZERO)) { - return; - } + TCGv t1, t2, dest = dest_gpr(dc, instr.c); /* Reserved registers read as zero. */ if (nios2_cr_reserved(&dc->cr_state[instr.imm5])) { - tcg_gen_movi_tl(cpu_R[instr.c], 0); + tcg_gen_movi_tl(dest, 0); return; } @@ -494,12 +477,12 @@ static void rdctl(DisasContext *dc, uint32_t code, uint32_t flags) t2 = tcg_temp_new(); tcg_gen_ld_tl(t1, cpu_env, offsetof(CPUNios2State, ctrl[CR_IPENDING])); tcg_gen_ld_tl(t2, cpu_env, offsetof(CPUNios2State, ctrl[CR_IENABLE])); - tcg_gen_and_tl(cpu_R[instr.c], t1, t2); + tcg_gen_and_tl(dest, t1, t2); tcg_temp_free(t1); tcg_temp_free(t2); break; default: - tcg_gen_ld_tl(cpu_R[instr.c], cpu_env, + tcg_gen_ld_tl(dest, cpu_env, offsetof(CPUNios2State, ctrl[instr.imm5])); break; } @@ -575,10 +558,8 @@ static void wrctl(DisasContext *dc, uint32_t code, uint32_t flags) static void gen_cmpxx(DisasContext *dc, uint32_t code, uint32_t flags) { R_TYPE(instr, code); - if (likely(instr.c != R_ZERO)) { - tcg_gen_setcond_tl(flags, cpu_R[instr.c], cpu_R[instr.a], - cpu_R[instr.b]); - } + tcg_gen_setcond_tl(flags, dest_gpr(dc, instr.c), + load_gpr(dc, instr.a), load_gpr(dc, instr.b)); } /* Math/logic instructions */ @@ -586,9 +567,7 @@ static void gen_cmpxx(DisasContext *dc, uint32_t code, uint32_t flags) static void (fname)(DisasContext *dc, uint32_t code, uint32_t flags) \ { \ R_TYPE(instr, (code)); \ - if (likely(instr.c != R_ZERO)) { \ - tcg_gen_##insn(cpu_R[instr.c], load_gpr((dc), instr.a), (op3)); \ - } \ + tcg_gen_##insn(dest_gpr(dc, instr.c), load_gpr(dc, instr.a), (op3)); \ } gen_r_math_logic(add, add_tl, load_gpr(dc, instr.b)) @@ -609,28 +588,24 @@ gen_r_math_logic(roli, rotli_tl, instr.imm5) static void (fname)(DisasContext *dc, uint32_t code, uint32_t flags) \ { \ R_TYPE(instr, (code)); \ - if (likely(instr.c != R_ZERO)) { \ - TCGv t0 = tcg_temp_new(); \ - tcg_gen_##insn(t0, cpu_R[instr.c], \ - load_gpr(dc, instr.a), load_gpr(dc, instr.b)); \ - tcg_temp_free(t0); \ - } \ + TCGv t0 = tcg_temp_new(); \ + tcg_gen_##insn(t0, dest_gpr(dc, instr.c), \ + load_gpr(dc, instr.a), load_gpr(dc, instr.b)); \ + tcg_temp_free(t0); \ } gen_r_mul(mulxss, muls2_tl) gen_r_mul(mulxuu, mulu2_tl) gen_r_mul(mulxsu, mulsu2_tl) -#define gen_r_shift_s(fname, insn) \ -static void (fname)(DisasContext *dc, uint32_t code, uint32_t flags) \ -{ \ - R_TYPE(instr, (code)); \ - if (likely(instr.c != R_ZERO)) { \ - TCGv t0 = tcg_temp_new(); \ - tcg_gen_andi_tl(t0, load_gpr((dc), instr.b), 31); \ - tcg_gen_##insn(cpu_R[instr.c], load_gpr((dc), instr.a), t0); \ - tcg_temp_free(t0); \ - } \ +#define gen_r_shift_s(fname, insn) \ +static void (fname)(DisasContext *dc, uint32_t code, uint32_t flags) \ +{ \ + R_TYPE(instr, (code)); \ + TCGv t0 = tcg_temp_new(); \ + tcg_gen_andi_tl(t0, load_gpr(dc, instr.b), 31); \ + tcg_gen_##insn(dest_gpr(dc, instr.c), load_gpr(dc, instr.a), t0); \ + tcg_temp_free(t0); \ } gen_r_shift_s(sra, sar_tl) @@ -642,39 +617,15 @@ gen_r_shift_s(ror, rotr_tl) static void divs(DisasContext *dc, uint32_t code, uint32_t flags) { R_TYPE(instr, (code)); - TCGv dest; - - if (instr.c == R_ZERO) { - dest = tcg_temp_new(); - } else { - dest = cpu_R[instr.c]; - } - - gen_helper_divs(dest, cpu_env, + gen_helper_divs(dest_gpr(dc, instr.c), cpu_env, load_gpr(dc, instr.a), load_gpr(dc, instr.b)); - - if (instr.c == R_ZERO) { - tcg_temp_free(dest); - } } static void divu(DisasContext *dc, uint32_t code, uint32_t flags) { R_TYPE(instr, (code)); - TCGv dest; - - if (instr.c == R_ZERO) { - dest = tcg_temp_new(); - } else { - dest = cpu_R[instr.c]; - } - - gen_helper_divu(dest, cpu_env, + gen_helper_divu(dest_gpr(dc, instr.c), cpu_env, load_gpr(dc, instr.a), load_gpr(dc, instr.b)); - - if (instr.c == R_ZERO) { - tcg_temp_free(dest); - } } static void trap(DisasContext *dc, uint32_t code, uint32_t flags) @@ -864,8 +815,14 @@ static void nios2_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs) return; } + dc->sink = NULL; + instr = &i_type_instructions[op]; instr->handler(dc, code, instr->flags); + + if (dc->sink) { + tcg_temp_free(dc->sink); + } } static void nios2_tr_tb_stop(DisasContextBase *dcbase, CPUState *cs) From patchwork Thu Mar 10 11:27:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 550096 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp909244mag; Thu, 10 Mar 2022 03:43:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJx4amnXQTca6e9/cqgCv6ytEiMVWVJb1kwFgb+F30kPpKKnCRZr+ismhZyDVdIYobFHhlV4 X-Received: by 2002:a81:6746:0:b0:2dc:5660:c73e with SMTP id b67-20020a816746000000b002dc5660c73emr3503210ywc.307.1646912592508; Thu, 10 Mar 2022 03:43:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646912592; cv=none; d=google.com; s=arc-20160816; b=dgPRdKPrl3UMqwpJLu+B/L19kJp/2VmBSASkf0ppbMqDAO1lgzLNvV/ejd/2OftwKw 66j/uk9UfsWiu7cTf1nM8NRrSd6OwMbPOopFjjdk5+njgnikobX6HvRJPQ2+0VAX8WLi 8fqyBvse1GdPJryBycz5PMiRHWGWBY8Zy4lpYyXkLYND+9GA0J10p6BwJz29GaAVd8Wq b++MVrogwuSyA1ELWLlsVRXJkvMEWHZ8Bz23ozb1CaVl2+ZZuUZ7HDJovaehRaOZ5FG8 63V/nMPFXAaJnh1/WVyVj/02swoPuiftHS7s2Ou+2dBsvTtR+OfugtTG9Dm+uUjU7wH6 75Ug== 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=lGnYRwLa1Sdp2FVEXMpjEqak7lSPIuu/eJVT8HDcZLI=; b=zS0z3Vd4gJCxYrHpFz7dy91moMUJZQAceHkMXZf1wwy5GJA7QX082VgcArFlYq7IF5 l/lSDgJZQ+N3YPlgdY61AgxrDFtE+G3qC98jVnkBtiZ0F8ueggnK+0NWosc9+VX7OTla hb7l1dUTYMbx/UJToyRoNR4SrXGQduTquamKjB8EUGRHETzdkBnbHLbGSa2QE1yyGyby OYfXZItNlSGDquwAQuYA099ToRHqg9XRWE0R1CjBvhgIr3JHLotAyWmzhIN3R+H2p5UQ UglaUqFKXJEbVI9w8b4Ptdzn3LF1YNLNFzuHJkOSjpKxvDGqEkaSck5fXTeKXuxlImHp jNzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=t8ugzzGh; 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 k13-20020a056902070d00b006292df698c0si3536975ybt.95.2022.03.10.03.43.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Mar 2022 03:43:12 -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=t8ugzzGh; 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]:57862 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSHCJ-0007pk-Uv for patch@linaro.org; Thu, 10 Mar 2022 06:43:11 -0500 Received: from eggs.gnu.org ([209.51.188.92]:51078) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSGxj-0006Ev-HN for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:28:08 -0500 Received: from [2607:f8b0:4864:20::42f] (port=42634 helo=mail-pf1-x42f.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nSGxi-00081X-7p for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:28:07 -0500 Received: by mail-pf1-x42f.google.com with SMTP id g19so4839499pfc.9 for ; Thu, 10 Mar 2022 03:28:05 -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=lGnYRwLa1Sdp2FVEXMpjEqak7lSPIuu/eJVT8HDcZLI=; b=t8ugzzGh13hhzZytrFxNNz1j5VkeLVl5fucfXPS6xKlXoQKx6LizIzxJXmG5yqmIPH +WGbtryS4gevTA8bfsJEVgE1TC6Y5Cjg284JNaiOdlNG5z9ZwSR4DnKCYGniuFGePXuG JA6iZnbUOS7RrEb67tG5HaumwwP62AvZi6o2jCXqc9peNobDCZ5bnxiU1YZhEDFCGhKJ o3PcVfyvH9GD+OySY3GKKSkKffwuKiGw8qFVsLAmEhAug30fhtMPfnn5Iox5xnKpghbd 1TPeWqxIYYykJ7cD7vmeJcdYDy9+CI5QlnFMcNIVUC0hebNy1adpBz+V2g6joyz7j1eV LqBA== 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=lGnYRwLa1Sdp2FVEXMpjEqak7lSPIuu/eJVT8HDcZLI=; b=ZCH329eCaebLFAyIJwhemeu3o1FI7xsQ1hHbxUfgq9YbAtNwNESlsequ45r08kgj7+ /TpYRL3fyu3XIY9LTxA0SQPUIZ91z/O1L94y/qNrHGBG6XJsrPQuQ8u7QfAxdk0C+3id Cbfj0giRTSdRcZ/6MfJFYT3klJ/uOWud1QL+GnRhqhgRq5nmETIS3E5MLgxaSE32BNgD Ma0DvefBq64gK6Qg6qk7swIrgfbsvMWtPabluCMwqGNE5UElvxIC34po9CnMP8rUzndb Ykip+89CZxBA1xSkRODX+IQ4GtcZuW7z0caLvNAyqnNbyPBu7NBM4GB6zcq8msEyJFUO zDJA== X-Gm-Message-State: AOAM533FH4WIGWeQl6FaIEHA8kHTUKBbfEbZGMY+CkxLKRkivDzr0fLu KUJCPgLmu1EUF2x2AoyNSgiX8fpZ1sq73g== X-Received: by 2002:a05:6a00:acf:b0:4e1:9222:1ef3 with SMTP id c15-20020a056a000acf00b004e192221ef3mr4355358pfl.18.1646911685015; Thu, 10 Mar 2022 03:28:05 -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.28.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Mar 2022 03:28:04 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 33/48] target/nios2: Drop CR_STATUS_EH from tb->flags Date: Thu, 10 Mar 2022 03:27:10 -0800 Message-Id: <20220310112725.570053-34-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::42f (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::42f; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42f.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" There's nothing about EH that affects translation, so there's no need to include it in tb->flags. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/nios2/cpu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/nios2/cpu.h b/target/nios2/cpu.h index 95079c186c..d5255e9e76 100644 --- a/target/nios2/cpu.h +++ b/target/nios2/cpu.h @@ -276,7 +276,7 @@ static inline void cpu_get_tb_cpu_state(CPUNios2State *env, target_ulong *pc, { *pc = env->pc; *cs_base = 0; - *flags = env->ctrl[CR_STATUS] & (CR_STATUS_EH | CR_STATUS_U); + *flags = env->ctrl[CR_STATUS] & CR_STATUS_U; } #endif /* NIOS2_CPU_H */ From patchwork Thu Mar 10 11:27:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 550116 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp923985mag; Thu, 10 Mar 2022 04:03:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJxz3yVWqwpedBCtgaoxwysliU0Wj1XnQ1kcfpj672iJcFyVncyXxoDsVi4KCtyfYmG4bvGD X-Received: by 2002:a05:6902:2c3:b0:624:4a88:d7a2 with SMTP id w3-20020a05690202c300b006244a88d7a2mr3464663ybh.145.1646913801716; Thu, 10 Mar 2022 04:03:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646913801; cv=none; d=google.com; s=arc-20160816; b=iHXjSXBkvHjdidUz0fENKeaw3Qfgl8b1X5c7tuDj04ZfsyYrp6F5KVzZB778x5fGd3 so8oGNR+WEo9eprjSzEWG2BjCqCq5DBmbBl253qvBPEEKyeD3mMs+NyC5BVSO9vCZYr6 yoQQgaAg45A9i2gwVAXzUQmJ9gHpOAQ5ViTxv8gE0cUj/O8ytJD5crYHMdjLgDmsBK0b bwSYorar9MviJ0Z+pyCB4z1YG3MRd9V6Az5JtJSAP3aSeqIX9a0mHBYTA5T443B7puE6 n4l2bZwLxGQg5ipGXfugzg4G48WJeifILAlwDJmz+XDxqLE0MTxRidUS++PznUXqTeoc GfDg== 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=Q//3kePGgY2lzpncF0BtSDXigvkTy7INMFgUKN7BKXk=; b=fevcr4yl0M4hl86aVNIV6PWGrc9WqP6faC/6nryAJo/1YU3wr3M9axap+XwHXEyWg7 NlkkY+Vm27eJ/MsLhBeqXdRbU3992XRHd2zErqGL0VnZ5OV0CUUh5RmFTEAZH2L0mr6/ UBop3DcKHPIqrV5rN1TA6TwJLHD0XMLf+a4azobCbEFoCP49RWn3F/+s1gnMMyTUY5Ds wXQG3UQ5J4UyMiXWu57Zae4T+zEAqA2MvZwBoRinNsZEr+WB1t2EEJH46IP4ycXDLz5/ v0EML6RJFfw/ay4CKWC8jvb706+vHlZYiMAhVybfuP8T4j6o/dlJG5wNYvldflUzc4zC 5XOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="TJ6zZ/qs"; 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 x10-20020a25e00a000000b00629214beed6si2946551ybg.467.2022.03.10.04.03.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Mar 2022 04:03:21 -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="TJ6zZ/qs"; 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]:54560 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSHVp-0002Pg-51 for patch@linaro.org; Thu, 10 Mar 2022 07:03:21 -0500 Received: from eggs.gnu.org ([209.51.188.92]:51108) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSGxl-0006Gy-B6 for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:28:10 -0500 Received: from [2607:f8b0:4864:20::435] (port=36601 helo=mail-pf1-x435.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nSGxj-00081p-Rx for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:28:09 -0500 Received: by mail-pf1-x435.google.com with SMTP id z16so4860814pfh.3 for ; Thu, 10 Mar 2022 03:28:07 -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=Q//3kePGgY2lzpncF0BtSDXigvkTy7INMFgUKN7BKXk=; b=TJ6zZ/qsnRY/oDfupoqzP27kParNBnJekeH6TmOs+t2BijfY5Yy/U+cN8QjXbTIOSN tzo0lI1nO8GiwpdYGJIRIbEQ1h/LqRTFXui4QVjgD6hAXfxpzqX1BA1GWjomYmFgf9UN g9KK6KnNpbGBu6hTzhz+uzfMU28CqrFnMmKcMngVWYQIzabZAt3w2/nx3PIrJ7vM054Z vfBew+O4c63rDg/9YS7ScLfdqL54mgD0VBQBvwFl5V6gUDdij1mMlPNVApzsDLpIayeO tsQat+gcn2LKJ7ijgvLk1BokcIHVA92NAmoEhlfvSGccyXSc31ExDthNUQMnGG4+LvV5 lLDg== 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=Q//3kePGgY2lzpncF0BtSDXigvkTy7INMFgUKN7BKXk=; b=KA3pS8/oWTYQdbuQ2GpOpnkc7NJywV7zPeZxgOjBehUUIIOBLf9JreqkveKZ1Rrrja g01CpL9Yq+Z9Zux+KZTENczpWTnykK+e2mon6hd+cJXn3V23Fb2XOGq7fOnprqMS8dCN gwQ3oGgTUAQMezUBo5/5UvVdJlW5HfekbGf8cV/0eLPIdYJSpsyIRbTHtuj9+dMGHLzF AmjBUdqC4U1q1Q7GjP8skvftBo9kGXCcurbquGJCUtxXU+rvmpfwD6GgSFWhMjRJybUy T8X5AYgp5TpC2sxCXen5Pn9EC7RcDi8w604yTVkrXW98zedYmsPaQ0utoQrFGPAItXbJ HdPw== X-Gm-Message-State: AOAM531QQEhPOBeyZo8J257qLPkVOnlV+UumiZaWa1eJ8HTFeCCMe7BJ LyS3wzxJfukSDIcNHhUEYZx2qkjrnKUSEw== X-Received: by 2002:a05:6a00:2166:b0:4f6:67fe:a336 with SMTP id r6-20020a056a00216600b004f667fea336mr4533678pff.17.1646911686072; Thu, 10 Mar 2022 03:28:06 -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.28.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Mar 2022 03:28:05 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 34/48] target/nios2: Enable unaligned traps for system mode Date: Thu, 10 Mar 2022 03:27:11 -0800 Message-Id: <20220310112725.570053-35-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::435 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::435; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x435.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" Unaligned traps are optional, but required with an mmu. Turn them on always, because the fallback behaviour is not documented (though presumably it discards low bits). Enable alignment checks in the config file. Unwind the guest pc properly from do_unaligned_access. Signed-off-by: Richard Henderson --- configs/targets/nios2-softmmu.mak | 1 + target/nios2/helper.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/configs/targets/nios2-softmmu.mak b/configs/targets/nios2-softmmu.mak index 9a372f0717..1e93b54cd1 100644 --- a/configs/targets/nios2-softmmu.mak +++ b/configs/targets/nios2-softmmu.mak @@ -1 +1,2 @@ TARGET_ARCH=nios2 +TARGET_ALIGNED_ONLY=y diff --git a/target/nios2/helper.c b/target/nios2/helper.c index 460032adc0..bf40cff779 100644 --- a/target/nios2/helper.c +++ b/target/nios2/helper.c @@ -264,8 +264,8 @@ void nios2_cpu_do_unaligned_access(CPUState *cs, vaddr addr, CPUNios2State *env = &cpu->env; env->ctrl[CR_BADADDR] = addr; - env->ctrl[CR_EXCEPTION] = FIELD_DP32(0, CR_EXCEPTION, CAUSE, EXCP_UNALIGN); - helper_raise_exception(env, EXCP_UNALIGN); + cs->exception_index = EXCP_UNALIGN; + cpu_loop_exit_restore(cs, retaddr); } bool nios2_cpu_tlb_fill(CPUState *cs, vaddr address, int size, From patchwork Thu Mar 10 11:27:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 550128 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp939508mag; Thu, 10 Mar 2022 04:21:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJwSAs9uqoWZ+lcJiF5mKPvLdWJacjannxV0o9vHvs1HSq5HscE+SE6egRqt6CZ18DLGWQJC X-Received: by 2002:a25:8c10:0:b0:61d:b17e:703d with SMTP id k16-20020a258c10000000b0061db17e703dmr3526418ybl.154.1646914871720; Thu, 10 Mar 2022 04:21:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646914871; cv=none; d=google.com; s=arc-20160816; b=rvYQMzL3dThS8270L02YezF5Njiab4Y1lsJJK7MG1DzGmEzr4hPfvWIKhJgaPJgw2v pwb74XubMvbkWmuhm2gkeSTtE76dV75Ho7sZ8Vi8q9/TvDLRzqMa7jD6PzH/QGtm+ife 7JHuMxfimb+Y3vj+Ogdq5ezO66Vufk+N3FDplDn+R5MJM3qQEVlvtW5JOE05PLMkmodG ZOgPTFUU/0PkxzUFVqHCTkrC5P/f1xRbElkrWHAMg5jc6WtkIxCK7eJFr3sJoEOJ+1rr GEt1gPazgH9rTZ3KkGxmnaAGr9Arx3JI4DwaLKiNtnQfU2srhyLhCqQQJaOgV9B9YFKG S15w== 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=a0Y1+UOzMYE465JAg/1XZp8FHRvlzNh9RDhixInPs2c=; b=HakZ1em994d+7H2SizyleDzw2vznSfPZrtJGfiilfYqeUqh9vaopm7vQ9ZhHLuAYZX hHzhDYMbYupfZPFS2Eseq3aTGLSKtuMjIgDS6QJjKjUT1BDkqtdiUK1TrHCgJS85KtBo EjWxTfkHOs0/OBjLNuc5BWMP1tqCos94aLFymborHzK70bC8sYPt8c/57lFYwFn9cn1D dfkTv9cK/DxuTmmUIX3qjEOd/kw7shI27EgQU3b7wu1RpbTvF3ZcTebQObbbKZi/rv9A HxAIEVvc9jnLwV2Y/IjHT1MV4+sKYeo4XFBLLyuTQzX10Ur5EpAb5G8k8R463y2W38v1 0ZIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=UxensK2T; 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 f8-20020a251f08000000b0061e0b190dc7si2813541ybf.658.2022.03.10.04.21.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Mar 2022 04:21:11 -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=UxensK2T; 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]:56558 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSHn5-00074R-6H for patch@linaro.org; Thu, 10 Mar 2022 07:21:11 -0500 Received: from eggs.gnu.org ([209.51.188.92]:51116) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSGxm-0006HQ-AU for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:28:10 -0500 Received: from [2607:f8b0:4864:20::531] (port=41818 helo=mail-pg1-x531.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nSGxk-00081x-CC for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:28:09 -0500 Received: by mail-pg1-x531.google.com with SMTP id o26so4484750pgb.8 for ; Thu, 10 Mar 2022 03:28:07 -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=a0Y1+UOzMYE465JAg/1XZp8FHRvlzNh9RDhixInPs2c=; b=UxensK2TuV6aJUw6wTkkqlJOX4X1PpGUrf6kigLv44qOCxM2YeMsKdl4RG6dcmsFle 7lpRu9muFb1Qdh4bxAmsWJD45LlgSn1lRCckHuYXfbrBBlbNDfFLHwVGfcDADMuXn4vJ j1RDFZMXSk+9162990JnbnR6+FTqCh9Hv/YRmqYq3O0jZHJJULbqaoiOMHZJ53nXat5k F6UF5LrkOcxAK1FZBFpx5dS27XMBl/rBxgFTkZl3ZREhf5ocI5ved3veinggAn9UEnQA b0OyAHskLQsD2r7MgCxoNASr9WNK6nBty3344Xo4q/24RVryzdpvBBBR0Y43cVJhrsZp eRXw== 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=a0Y1+UOzMYE465JAg/1XZp8FHRvlzNh9RDhixInPs2c=; b=eW38fODZRL+gX1GU7wFTcCultpWuS/tmsz2RMEjdphjvBPF1Ki4Yv+pPD1o39y5qgQ ZuO2KaAzwEcaMwSWrXu/76WPSdKuVuvfTQ291cjywAc3qlftfEhJyQ7crFo+8n1pXZRr 2dwSRHNE4xmytdDVFZt05wqftrKfoCQHIYKxPpxfdNN3dzl8zOeJiQcvHE2bR9GHl2o4 nsng3FoU5W2R+OEure3QUUmCe+Vn/k8RCvNzDARswsE9s5ebyGMy+ttvvhkJC094gz8K gUepMZqicYlGG+V53QgCU8ULv3EGiUsz4TDGP1UicgRIn6c29/xGoV56xo2D5N8CLAGn FYcA== X-Gm-Message-State: AOAM532c9FZvXC7Iv8M4j8B1WSNoxwUPXztjeE2XE343hh4eond47xEA 2wJdYIVHNXYyDRS4yWT5qMokh/2rRlZ0og== X-Received: by 2002:a65:4845:0:b0:325:c147:146d with SMTP id i5-20020a654845000000b00325c147146dmr3769599pgs.140.1646911687159; Thu, 10 Mar 2022 03:28:07 -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.28.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Mar 2022 03:28:06 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 35/48] target/nios2: Create gen_jumpr Date: Thu, 10 Mar 2022 03:27:12 -0800 Message-Id: <20220310112725.570053-36-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::531 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::531; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x531.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" Split out a function to perform an indirect branch. Signed-off-by: Richard Henderson --- target/nios2/translate.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/target/nios2/translate.c b/target/nios2/translate.c index d5f2e98de9..f61ba92052 100644 --- a/target/nios2/translate.c +++ b/target/nios2/translate.c @@ -36,7 +36,6 @@ #include "semihosting/semihost.h" /* is_jmp field values */ -#define DISAS_JUMP DISAS_TARGET_0 /* only pc was modified dynamically */ #define DISAS_UPDATE DISAS_TARGET_1 /* cpu state was modified dynamically */ #define INSTRUCTION_FLG(func, flags) { (func), (flags) } @@ -168,6 +167,16 @@ static void gen_goto_tb(DisasContext *dc, int n, uint32_t dest) } } +static void gen_jumpr(DisasContext *dc, int regno, bool is_call) +{ + tcg_gen_mov_tl(cpu_pc, load_gpr(dc, regno)); + if (is_call) { + tcg_gen_movi_tl(dest_gpr(dc, R_RA), dc->base.pc_next); + } + tcg_gen_exit_tb(NULL, 0); + dc->base.is_jmp = DISAS_NORETURN; +} + static void gen_excp(DisasContext *dc, uint32_t code, uint32_t flags) { t_gen_helper_raise_exception(dc, flags); @@ -387,8 +396,7 @@ static void eret(DisasContext *dc, uint32_t code, uint32_t flags) /* PC <- ra */ static void ret(DisasContext *dc, uint32_t code, uint32_t flags) { - tcg_gen_mov_tl(cpu_pc, load_gpr(dc, R_RA)); - dc->base.is_jmp = DISAS_JUMP; + gen_jumpr(dc, R_RA, false); } /* @@ -418,8 +426,7 @@ static void jmp(DisasContext *dc, uint32_t code, uint32_t flags) { R_TYPE(instr, code); - tcg_gen_mov_tl(cpu_pc, load_gpr(dc, instr.a)); - dc->base.is_jmp = DISAS_JUMP; + gen_jumpr(dc, instr.a, false); } /* rC <- PC + 4 */ @@ -438,10 +445,7 @@ static void callr(DisasContext *dc, uint32_t code, uint32_t flags) { R_TYPE(instr, code); - tcg_gen_mov_tl(cpu_pc, load_gpr(dc, instr.a)); - tcg_gen_movi_tl(dest_gpr(dc, R_RA), dc->base.pc_next); - - dc->base.is_jmp = DISAS_JUMP; + gen_jumpr(dc, instr.a, true); } /* rC <- ctlN */ @@ -838,11 +842,6 @@ static void nios2_tr_tb_stop(DisasContextBase *dcbase, CPUState *cs) tcg_gen_exit_tb(NULL, 0); break; - case DISAS_JUMP: - /* The jump will already have updated the PC register */ - tcg_gen_exit_tb(NULL, 0); - break; - case DISAS_NORETURN: /* nothing more to generate */ break; From patchwork Thu Mar 10 11:27:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 550131 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp943591mag; Thu, 10 Mar 2022 04:26:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJwqVPSHgGzWhHfCeFmIaSUuikTImQ7QjB8LLFC3OEvKyhq2mVAQqUJ07IJ4yxqS6Toqlhry X-Received: by 2002:a81:4c57:0:b0:2dc:c7e:605c with SMTP id z84-20020a814c57000000b002dc0c7e605cmr3891384ywa.342.1646915209923; Thu, 10 Mar 2022 04:26:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646915209; cv=none; d=google.com; s=arc-20160816; b=eWrBIhvKjoJFA6TSzEcNuvaPNh+ulHWTApLxZutB4qb9ykryoDovnX4tIyISEa5Uxq LB/DikA86Ml8Y6VeZZgRvKt8P34mkryWuQ+TyWHX38q6npFAFJvAikxDoelnpiQXEm2q SqG6eEZSQ2JJ6ZAq4zYhyoXCdlNCstnnRLxZGYqDPFiYyJFjp7j3ylx/MssAXB44HvAb KdbpcNzuidZbpoH+CXfN2d92relOA9tveKMp+fzs5h34btdWeqwIU5aSmqlSXztMzmzk +jeirrPez3T4udYe9lWlypmfVtKkO03mLB0hPkLNn5BzzPixzjv/i4qE9AJ6zM7P1BhW BbzQ== 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=PHMXz9q73HVjYaAorTgnEhJkrDs42cYUdRyVosZEm/k=; b=MNjLwZ0Bi/rJM2EenZu4IstLS3nLy4SNMd9G1+o8e2vqfMdYJ1HOxR5vuq7wSzegYs MU+WR1LfIJfEPhaGXDae/QHBYgpsuVSoYp0X2LjYxXsXnIBgO68znfv4FhSTDt1NSdyK RASQJsLdz/voJVfxUScAIMfJJcVKOVutNz0V8fX5XE/J2s1RyxvZjcrwW/cLaF7NETy0 SAgBR38XWc3GpUWylk6luaD8Z+BLPye6H6EedPXZNxKgxh4s7PnzDAVkIU6x5/T/96m7 MxQT1R9pz84ekhLcnYs2W2h1HPWLzOIE2OQ4Wc659M+y2a6Zb0IopiR6J4k2eLTACsnH mywg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=UO36UmZn; 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 130-20020a810888000000b002d68040a00asi2606463ywi.404.2022.03.10.04.26.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Mar 2022 04:26:49 -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=UO36UmZn; 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]:42312 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSHsX-0000QD-Ex for patch@linaro.org; Thu, 10 Mar 2022 07:26:49 -0500 Received: from eggs.gnu.org ([209.51.188.92]:51154) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSGxo-0006K4-Ih for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:28:14 -0500 Received: from [2607:f8b0:4864:20::532] (port=41819 helo=mail-pg1-x532.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nSGxl-00082B-CO for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:28:11 -0500 Received: by mail-pg1-x532.google.com with SMTP id o26so4484785pgb.8 for ; Thu, 10 Mar 2022 03:28:09 -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=PHMXz9q73HVjYaAorTgnEhJkrDs42cYUdRyVosZEm/k=; b=UO36UmZntZvgjIPv5B0+rQ27YUeBJ/Iwa7/nvsUwT9IeiWn6KzBiy45kZl5URtgXjT JXKE60W8g3Ug8Tp0ec9wcUFp/s1cfrLQk6cm9pA0DRTFIkHGi28UWMI6sttspZR55nUw J4PeriBNbi5prGQaBGec8oSyAd3SD7Np5lWhwHFL9lgxEGs43IVnLND85mPjfVoMPcrH Khsl/s05OF+X+ldvqz9PkCsCkSpWaFb236PQECBc/72vS/e9dIQkMRb1cO1sVgGMUXal zTp9ltfQuJyIxt8RFnMjFQEPsyoYyVOG9mMIzZ1UTs0Ea8s+RRt17io5KjFjCZdW/70Z GDcQ== 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=PHMXz9q73HVjYaAorTgnEhJkrDs42cYUdRyVosZEm/k=; b=Omf1Rxb1Sv3npqywiKF8q6Q/ZrdQr9/jWDXvoKk97fwXLbOVhLEH94Ghhs3Z2KCmdV ONeS+7fHIj45xjdZnGd1IlhwspBt4MC9ssJFVvdEMlO2AKdStASm42HR7DMo2GLUt3xT 7JNRqqrF1uzlLJT04cWgUKDqawYj/qTFF99XfAqlxPYgXdPZHLhRy+oux+SqIfra8q9O EArXkD9+khCHfc4QudlPPHv8lL/51zYAM8kKgaz4m2HxgvNfBu98IFctMP3uz1AwjMWl bh9nx5/QSRHlLBSZQVIYi/hC5ZNjvqVfnKe889uaaKkrAvKgE9upxTJEdoulKhRT1Uiv VKpA== X-Gm-Message-State: AOAM531Y/eWppf8BqAkwQ1oA1aIQVs+nu56Fb+wrqOsru8R4jSa4St1T JzMtZsjqp7Gk1xKSxSwOA2/Bhc9MR/jsCw== X-Received: by 2002:a05:6a00:a8f:b0:4e1:2619:11a2 with SMTP id b15-20020a056a000a8f00b004e1261911a2mr4483830pfl.53.1646911688184; Thu, 10 Mar 2022 03:28:08 -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.28.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Mar 2022 03:28:07 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 36/48] target/nios2: Hoist set of is_jmp into gen_goto_tb Date: Thu, 10 Mar 2022 03:27:13 -0800 Message-Id: <20220310112725.570053-37-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::532 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::532; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x532.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" Rather than force all callers to set this, do it within the subroutine. Signed-off-by: Richard Henderson --- target/nios2/translate.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/target/nios2/translate.c b/target/nios2/translate.c index f61ba92052..51907586ab 100644 --- a/target/nios2/translate.c +++ b/target/nios2/translate.c @@ -165,6 +165,7 @@ static void gen_goto_tb(DisasContext *dc, int n, uint32_t dest) tcg_gen_movi_tl(cpu_pc, dest); tcg_gen_exit_tb(NULL, 0); } + dc->base.is_jmp = DISAS_NORETURN; } static void gen_jumpr(DisasContext *dc, int regno, bool is_call) @@ -208,7 +209,6 @@ static void jmpi(DisasContext *dc, uint32_t code, uint32_t flags) { J_TYPE(instr, code); gen_goto_tb(dc, 0, (dc->pc & 0xF0000000) | (instr.imm26 << 2)); - dc->base.is_jmp = DISAS_NORETURN; } static void call(DisasContext *dc, uint32_t code, uint32_t flags) @@ -251,7 +251,6 @@ static void br(DisasContext *dc, uint32_t code, uint32_t flags) I_TYPE(instr, code); gen_goto_tb(dc, 0, dc->base.pc_next + (instr.imm16.s & -4)); - dc->base.is_jmp = DISAS_NORETURN; } static void gen_bxx(DisasContext *dc, uint32_t code, uint32_t flags) @@ -263,7 +262,6 @@ static void gen_bxx(DisasContext *dc, uint32_t code, uint32_t flags) gen_goto_tb(dc, 0, dc->base.pc_next); gen_set_label(l1); gen_goto_tb(dc, 1, dc->base.pc_next + (instr.imm16.s & -4)); - dc->base.is_jmp = DISAS_NORETURN; } /* Comparison instructions */ From patchwork Thu Mar 10 11:27:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 550119 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp926288mag; Thu, 10 Mar 2022 04:05:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJzNibmmGJrYCEVLJ2Oc1uh9XOh5mvg/j2hlrFzuLG/dgk9Z0mA4JJlkMzjk1MGJ0MJh7gd9 X-Received: by 2002:a25:ab8e:0:b0:628:7c01:de65 with SMTP id v14-20020a25ab8e000000b006287c01de65mr3608474ybi.524.1646913951274; Thu, 10 Mar 2022 04:05:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646913951; cv=none; d=google.com; s=arc-20160816; b=XRxyhUuCrkPf1ZvTUPbiv8APZzz2W6Yo0jQVF/WlCa0F8JZq6XN1PmeSI/7zFLIjgq JsPyLj4DxSwQ6x+Eqq1aKh+LEVrE3U/VX4lHH0+MA2hu7UEXjVdmjzBCycDCDHzDY3BA rYThUP5kSjn+7SCWsz32bDR6lq1gLGrybFINes7vhOl/i9Qu3D7tVTeFbFsGv8gc7IY9 eRiqQMTmLVQBP+SJXX6SFwn2XtBnrEFeSUXv+xsT3y3oLUkT9DmrI3pmHWELrQME6NKT pBmtaD82ns7/JGH2ke5hS/U9ICQajJ8lj5FT1X59vc/LVyv1j2crFhkOBaCthGW/65ME IjCg== 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=3YCeMoFSIPOtuFxyHW9qCFQJFQUeLRVbZvCIxi8q4XE=; b=O3sb63PjqSayJGPhIjYWT8X9ucIpdxc29uf8E4znz7IGcvI33OEUZUsQ+s24LMA7IF iFs8JeD0fbsejZ01zwGfFFJlwin51FsZ8gp7aOOJoGwOGn0ZTaEm1EK8MVsGkDseZDOB tFpm/A2xRbl2zurD84CP6lxRLbNE/CLowzHTP6Ozw+WaSCl57ChStxI70oIjUiY3mjQR K3wlJ34Z7DIGFQw3tvuLamfFqJmhsh04gYsW/iQ4qKeaCov6YDAS31BM/Vk2QVNVgmVm STKryfULbb2cFJHvg59vyYdf9iBoqD02wScMZB9q9aQnacJLsO6+XyLTHjMJP8CxPkR0 7mKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=FINuLbuz; 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 p84-20020a819857000000b002d6360ac595si2685762ywg.9.2022.03.10.04.05.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Mar 2022 04:05:51 -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=FINuLbuz; 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]:60916 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSHYE-0006tE-Ii for patch@linaro.org; Thu, 10 Mar 2022 07:05:50 -0500 Received: from eggs.gnu.org ([209.51.188.92]:51158) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSGxo-0006K8-Kq for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:28:14 -0500 Received: from [2607:f8b0:4864:20::52d] (port=45863 helo=mail-pg1-x52d.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nSGxm-00083U-GB for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:28:11 -0500 Received: by mail-pg1-x52d.google.com with SMTP id z4so4467905pgh.12 for ; Thu, 10 Mar 2022 03:28:10 -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=3YCeMoFSIPOtuFxyHW9qCFQJFQUeLRVbZvCIxi8q4XE=; b=FINuLbuz155DTpUngqqhLnixH2INKODooSjzfWh2RnsW6z4Mk4N6E7OlDKQ7hMKbPI pAozDFYy2B2meSoYAEyn2mzN03pae7B85xy7eG7dgKzoYULFQfAVOYBZ/AQvV6E4Cy06 xyO+BNTG0iFhB+GaUlC1FZgsrbr7II/av3RKgAzKWVdC4MIflnrSBbYqkv5SSRt46esY sqXPDbCaGfVbQAQqBvCoMAOy9Nydjixzh9xagjVXuiUpA0Q7g/YUElBZlndEh08o14Tp vYkxSj0f0gHHcv+ZVy8OmW3rHmrlARUDw3lh8f5HdgPg45e/7fW0drPa5HBCkYobJbgA JIjg== 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=3YCeMoFSIPOtuFxyHW9qCFQJFQUeLRVbZvCIxi8q4XE=; b=tR2eEXmBQlqY6CFqqoF3LX/3qutHsCeCJaKuRQeUXMbnkqIVp170oX/kQdqK4b4wun MDpri7/ZwtVbDrwS5zEEUT91GqXO/6mt7i4CVDfwzgZzSQ4JambKnsBdA71MLCqFoXKR KzsBvFAMgQXaIeolsJFl0Hn0eoClXPQuWc3kcFSK0Jd+ApOkO5qpzPCz6Ua65INpY0Dn xy4CN2LtWQGBUX6hL4JGvs1V/iGlii1lEYcxcPIzsSIqZau+jWJU/TTlYHn3XWCFctMr TqRneSyi5FddEMs6ZspspF5VzoyuQHZUd23bNLiCdL378IV0ut9FBSCMhKK1T3fDfPqi t6bA== X-Gm-Message-State: AOAM531OD0cEF+GK+4UQg2Q2id3V6Cdwv3g1qMcHCNUieqsVpHkXPmWP aSWHJDqel3W13LvzRryAArAqluD3WYZm+w== X-Received: by 2002:a05:6a00:24c4:b0:4f7:2fc6:50e8 with SMTP id d4-20020a056a0024c400b004f72fc650e8mr4176073pfv.63.1646911689247; Thu, 10 Mar 2022 03:28:09 -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.28.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Mar 2022 03:28:08 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 37/48] target/nios2: Use gen_goto_tb for DISAS_TOO_MANY Date: Thu, 10 Mar 2022 03:27:14 -0800 Message-Id: <20220310112725.570053-38-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::52d (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::52d; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52d.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" Depending on the reason for ending the TB, we can chain to the next TB because the PC is constant. Signed-off-by: Richard Henderson --- target/nios2/translate.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/target/nios2/translate.c b/target/nios2/translate.c index 51907586ab..6f31b6cc50 100644 --- a/target/nios2/translate.c +++ b/target/nios2/translate.c @@ -834,8 +834,11 @@ static void nios2_tr_tb_stop(DisasContextBase *dcbase, CPUState *cs) /* Indicate where the next block should start */ switch (dc->base.is_jmp) { case DISAS_TOO_MANY: + gen_goto_tb(dc, 0, dc->base.pc_next); + break; + case DISAS_UPDATE: - /* Save the current PC back into the CPU register */ + /* Save the current PC, and return to the main loop. */ tcg_gen_movi_tl(cpu_pc, dc->base.pc_next); tcg_gen_exit_tb(NULL, 0); break; From patchwork Thu Mar 10 11:27:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 550132 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp944034mag; Thu, 10 Mar 2022 04:27:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJwQOqV8At3C88ZS57qM9BxggUAVpKWbE2xKBuRWy2jfBBMnXHCB3wt5dMcGJ0G/bvQlooe2 X-Received: by 2002:a25:d714:0:b0:628:dc7b:cf9 with SMTP id o20-20020a25d714000000b00628dc7b0cf9mr3538258ybg.77.1646915246006; Thu, 10 Mar 2022 04:27:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646915246; cv=none; d=google.com; s=arc-20160816; b=ebdvKmTkg3sSb8eD88kHjSyFd1Pfq6IpULnv+2UAYFXRlLDoeVMmt9FrM7kIw2u4c9 ODGDxorTKlr10L7iXO3UYPtmxJ4krQewwhlS8IFAYr1LypL6THm48wrKaFjeysLTJGYe np4+pFCD4rGXOFi2Ya65aRHQvabUbhvc2ZPg+kmOKECe7BQN6Aab6dwWtbUNJSlBZT9/ hEpT6FqXLGDu03LapkrY7kl1Y+J8lV9MtP7XMOKC4Rb33cM/LTejChPSmNs8ntTQ6fa9 zJ4fESqjMeYt6d/hkr8ZLoz94TiKYZXh+RFwHKx+a564mb2zcZMnu9y6VM58/+ed+0fC 0JCQ== 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=QMOimEYkivNn0EOtJQFRq+oOiueoNqaCGaU7AEWQQss=; b=qLgShtJdRyV2IiMyf0lepks2abqMmdKThhcWu/7Y9n8Yrpc6fE3Ju+z7wj87IIF6vv jRtsdVdfr1+Us0snvhthay7JH3SENc26Hsuf9fedBY+JoNLiQQrlpE0fInFSadG8ZfOO PuMwCGUrfZv1TiE93Xq/CPZzxUVfNbGBgEtGKaEudTlQj600MfnlXAUHdFHNGNVdOMJU Dbcokg6c5MkR7ZqXHekuyhD+AQLuPnrYcHO8Ft1gW/1RW1BBefL+RV5lZ0HbAmkPML4K 31wpDiLMwkiTQdSveUCIVBJV/0+8XaajUpunPyHjaqsiZBfc9711yE2RGVy3M4zFREaf Mqdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Byn5Go+L; 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 21-20020a250415000000b00628beb0917asi2813403ybe.292.2022.03.10.04.27.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Mar 2022 04:27:25 -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=Byn5Go+L; 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]:43432 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSHt7-0001H1-FZ for patch@linaro.org; Thu, 10 Mar 2022 07:27:25 -0500 Received: from eggs.gnu.org ([209.51.188.92]:51180) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSGxq-0006Ka-Ie for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:28:14 -0500 Received: from [2607:f8b0:4864:20::42c] (port=33513 helo=mail-pf1-x42c.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nSGxo-00083n-A6 for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:28:13 -0500 Received: by mail-pf1-x42c.google.com with SMTP id s42so4890849pfg.0 for ; Thu, 10 Mar 2022 03:28:11 -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=QMOimEYkivNn0EOtJQFRq+oOiueoNqaCGaU7AEWQQss=; b=Byn5Go+LYQ2Av8Mi3qz+Sgft9F2TIfzHppda4474BXPpc/YF00oQaTNplQ4nLg4s6s hN81MvLAtXwaxAlB6QDXkjukpR+jTQapcQ9odadgwkv+NqRsFO4+Nkd00467hFQoWul/ jMBoc/GT05z3+LkGF8nPbG1XxJiJ14V7chtG5Xgd6RL8p1F5MpMSb1f/Tjn9z/yCY0Pq 7fJRkqxSs/5PjzgiMgyobduEgknCUDyEjPNx8AEk7y4TSQqqbDfj6aOuE9rdHBgTsdYt 9LpMdbhMsF10nKZKYTfjV0V1FhA6LKneMcfJwuTOC4zfycXwC/3wVZAPKwY0JxPH4dQ8 poCg== 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=QMOimEYkivNn0EOtJQFRq+oOiueoNqaCGaU7AEWQQss=; b=wYzhODRRP2Qhn6GbxVK7yQ8zQE5Z6gxNnYoqkdfUwki0HC+48ZL1uwbNhnq5AbXZ8Y oYFWyKzWlsUV4XZgNHsAtGnflg4uGMRJr8x28Tj3keICCifFcrlT+1ArSWpqEVH3Xq1W vkkYJ27XgRQuO0a9ciZfQT4+VB+GO1HkirISUwLg03l7yzcJZ+IcxuxZKoHqrHtLlmHd RyEaG/EMGp+rcD7kfe/D/fya45f0j7HEToLAK3KQKwX/28qINLgr8X7CE1nqBjzc4kWg aV4NTI+AlRAHYZVdJ7TV1oXxKwQer3As9xO8JA7z+9OQbGwVHsI7RFO0SPRWCPYXbuun m43A== X-Gm-Message-State: AOAM532I3JuLY6nv53K9Ik2cxp5OUS4xMN/NaWixo2zT+10BVpsKcQWr Cua7PltO/sRtMP1FDfzYEnvtXW7Y5P2LyA== X-Received: by 2002:a63:724b:0:b0:378:7967:e45c with SMTP id c11-20020a63724b000000b003787967e45cmr3753719pgn.602.1646911690234; Thu, 10 Mar 2022 03:28:10 -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.28.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Mar 2022 03:28:09 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 38/48] target/nios2: Use tcg_gen_lookup_and_goto_ptr Date: Thu, 10 Mar 2022 03:27:15 -0800 Message-Id: <20220310112725.570053-39-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::42c (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::42c; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42c.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" Use lookup_and_goto_ptr for indirect chaining between TBs. Signed-off-by: Richard Henderson --- target/nios2/translate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/nios2/translate.c b/target/nios2/translate.c index 6f31b6cc50..f7bab0908b 100644 --- a/target/nios2/translate.c +++ b/target/nios2/translate.c @@ -163,7 +163,7 @@ static void gen_goto_tb(DisasContext *dc, int n, uint32_t dest) tcg_gen_exit_tb(tb, n); } else { tcg_gen_movi_tl(cpu_pc, dest); - tcg_gen_exit_tb(NULL, 0); + tcg_gen_lookup_and_goto_ptr(); } dc->base.is_jmp = DISAS_NORETURN; } @@ -174,7 +174,7 @@ static void gen_jumpr(DisasContext *dc, int regno, bool is_call) if (is_call) { tcg_gen_movi_tl(dest_gpr(dc, R_RA), dc->base.pc_next); } - tcg_gen_exit_tb(NULL, 0); + tcg_gen_lookup_and_goto_ptr(); dc->base.is_jmp = DISAS_NORETURN; } From patchwork Thu Mar 10 11:27:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 550130 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp942186mag; Thu, 10 Mar 2022 04:24:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJyL8eT95lwnxthybSSDYyNvjp5aPmTcSHNotJr7QOPEODqErfE3Rdihh4ZXN7CIUzV4OhED X-Received: by 2002:a81:bc48:0:b0:2d6:99c7:b76c with SMTP id b8-20020a81bc48000000b002d699c7b76cmr3709487ywl.98.1646915096482; Thu, 10 Mar 2022 04:24:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646915096; cv=none; d=google.com; s=arc-20160816; b=vBUJODf0yYujKsjYC//P0dRGJ3aJvaFVIEIDACE0vP/BIUCfWsVpzRvLpnwXpxXQ1q 5vOIy93QPFBSynmzDMhvQqDKCwMef77nfCh50hsMdwrG2KZFky22SfJ91pXmWlpiFj1z GAJl0uY4nq6TSJxZdDFh6Ve9rveo8Xrju6vSaNK7YGYdblql4I34Fg8GzUKYEVyBkgaK IpE1EbWw7wqJqI66htpMgQqVY9Szc26tc9X63trHjTe9NXIxlLCM4loXNMhcDV1mZp1P XAi0lCA2gYGaTsH4h0zgIKqXWkWHZuyJL6tauyMdlk2Mr22PFsDtK8M833QRzumi3t1l 6Kbw== 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=LTuw5YwD7AAqbGDKsXNMlzx47tIusaHPWNHDAjQuUEg=; b=Tc5rM8gYNrAYRHvBBG/9PUgnKmZevGm/q/ryNJZouVNLXn53tHeRNYdMFeirEFPo5p aZzv384Ip/pWmceUftCZtlAXx7xTdpSvX5avhqY37MUBuBl1KEPMrNF1weC/61Z86Sj1 ORqAVC0prWlanPqCLrGnYk5zZiho8fD8+7vcUEYWO+Cv4sJLE1DbQjLzDkVZ3TYjEkdd THqC28K7RUbWNIn+e2T7SjSZ3jW8Nktd0ieKBYKCucItA14c84R7vQ14UQl7jFJEPMpn sl0qXltVdQQUqOm14x/ps8VatEx/BjzbmI9byui60scfHAY2LEAD3zRwRFpjuyIRu9Qc nJzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Hl+PbNhu; 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 n126-20020a0dfd84000000b002d68c65e314si2702347ywf.433.2022.03.10.04.24.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Mar 2022 04:24:56 -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=Hl+PbNhu; 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]:37032 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSHqh-000582-W8 for patch@linaro.org; Thu, 10 Mar 2022 07:24:56 -0500 Received: from eggs.gnu.org ([209.51.188.92]:51178) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSGxq-0006KZ-Ht for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:28:14 -0500 Received: from [2607:f8b0:4864:20::62f] (port=47055 helo=mail-pl1-x62f.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nSGxo-00083z-Ds for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:28:13 -0500 Received: by mail-pl1-x62f.google.com with SMTP id w4so4560095ply.13 for ; Thu, 10 Mar 2022 03:28:12 -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=LTuw5YwD7AAqbGDKsXNMlzx47tIusaHPWNHDAjQuUEg=; b=Hl+PbNhubeLhz963N5yNtLp0Vln4ixO4efwemAj7Q7Gfv5gN177fqK+69jmfFI55SQ ieFrAht5Kv08VZmz2peZdGT6MGYYqkTo5oDH0lbBUpgWPldawIlUn0PTBoBaOe+SZQYU n1GAZHgu1lK6hdviOSEUKs0mh4QWja7II6YCyEGdQuEdaITdz4HCDxkGZHPrcHm+7mVM 3kKISdZoeO3XNNA3ysw1mSchUzSNIBXenqPXSHrXLAhhuvmdh4PfoXyYW9nW6KUkjhgs eGLhrOmWIylI1PrMuRbwYDD3dDShnjpXF1IOq7d5MULttSVdFFoFfa7l2gsyKqHagI46 9IWw== 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=LTuw5YwD7AAqbGDKsXNMlzx47tIusaHPWNHDAjQuUEg=; b=i8NCPTjjk2HumkBvA3fCha93+XrUYLpVppGEl6ukXCSNlzr/PcP4fktpfqmG10ermv tOB2rzWhYyGICsCY1NVShL9vxeVLW2vWQc2hucJ97ZnKU1SkQPN+pn7AgILh9xzYX6U3 sDzLSTS3oorq0VorEVJo/d88sIlhN0Ze18PS0AqeUapMvgl5e2TUVuQ8bilCcJ1u08kD SW+zBuON2Gu4vZUl9+WdU7ad/RDjI4VKJJD3kIP+tl+t8sREEPAA5puN4P18jNQ8I89Q QQfSZqME9fBlkYDIbmsB3KCM9HPLDrDhcqaec0mmPn/WhI676QmFdlPSUMVbDDPVlLqA N6MQ== X-Gm-Message-State: AOAM530ajzWcZVRrmoCa9favmcwPkorIst9nvR8u0XNyF2WbgkXDS/Fp FrRqA0ZgASZ6WTWQghx9elnhM9R2I/mntg== X-Received: by 2002:a17:90b:1e0a:b0:1bf:4d46:741c with SMTP id pg10-20020a17090b1e0a00b001bf4d46741cmr15430919pjb.116.1646911691197; Thu, 10 Mar 2022 03:28:11 -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.28.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Mar 2022 03:28:10 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 39/48] target/nios2: Implement Misaligned destination exception Date: Thu, 10 Mar 2022 03:27:16 -0800 Message-Id: <20220310112725.570053-40-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::62f (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::62f; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62f.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" Indirect branches, plus eret and bret optionally raise an exception when branching to a misaligned address. The exception is required when an mmu is enabled, but enable it always because the fallback behaviour is not documented (though presumably it discards low bits). For the purposes of the linux-user cpu loop, if EXCP_UNALIGN (misaligned data) were to arrive, it would be treated the same as EXCP_UNALIGND (misaligned destination). See the !defined(CONFIG_NIOS2_ALIGNMENT_TRAP) block in kernel/traps.c. Signed-off-by: Richard Henderson --- linux-user/nios2/cpu_loop.c | 6 ++++++ target/nios2/op_helper.c | 9 ++++++++- target/nios2/translate.c | 15 ++++++++++++++- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/linux-user/nios2/cpu_loop.c b/linux-user/nios2/cpu_loop.c index ea364b7d1f..67220128aa 100644 --- a/linux-user/nios2/cpu_loop.c +++ b/linux-user/nios2/cpu_loop.c @@ -43,6 +43,12 @@ void cpu_loop(CPUNios2State *env) force_sig_fault(TARGET_SIGFPE, TARGET_FPE_INTDIV, env->pc); break; + case EXCP_UNALIGN: + case EXCP_UNALIGND: + force_sig_fault(TARGET_SIGBUS, TARGET_BUS_ADRALN, + env->ctrl[CR_BADADDR]); + break; + case EXCP_TRAP: switch (env->error_code) { case 0: diff --git a/target/nios2/op_helper.c b/target/nios2/op_helper.c index c93b66c9aa..849867becd 100644 --- a/target/nios2/op_helper.c +++ b/target/nios2/op_helper.c @@ -64,6 +64,13 @@ uint32_t helper_divu(CPUNios2State *env, uint32_t num, uint32_t den) void helper_eret(CPUNios2State *env, uint32_t new_status, uint32_t new_pc) { Nios2CPU *cpu = env_archcpu(env); + CPUState *cs = env_cpu(env); + + if (unlikely(new_pc & 3)) { + env->ctrl[CR_BADADDR] = new_pc; + cs->exception_index = EXCP_UNALIGND; + cpu_loop_exit_restore(cs, GETPC()); + } /* * Both estatus and bstatus have no constraints on write; @@ -74,6 +81,6 @@ void helper_eret(CPUNios2State *env, uint32_t new_status, uint32_t new_pc) env->ctrl[CR_STATUS] = new_status; env->pc = new_pc; - cpu_loop_exit(env_cpu(env)); + cpu_loop_exit(cs); } #endif /* !CONFIG_USER_ONLY */ diff --git a/target/nios2/translate.c b/target/nios2/translate.c index f7bab0908b..1e784c8a37 100644 --- a/target/nios2/translate.c +++ b/target/nios2/translate.c @@ -170,11 +170,24 @@ static void gen_goto_tb(DisasContext *dc, int n, uint32_t dest) static void gen_jumpr(DisasContext *dc, int regno, bool is_call) { - tcg_gen_mov_tl(cpu_pc, load_gpr(dc, regno)); + TCGLabel *l = gen_new_label(); + TCGv test = tcg_temp_new(); + TCGv dest = load_gpr(dc, regno); + + tcg_gen_andi_tl(test, dest, 3); + tcg_gen_brcondi_tl(TCG_COND_NE, test, 0, l); + tcg_temp_free(test); + + tcg_gen_mov_tl(cpu_pc, dest); if (is_call) { tcg_gen_movi_tl(dest_gpr(dc, R_RA), dc->base.pc_next); } tcg_gen_lookup_and_goto_ptr(); + + gen_set_label(l); + tcg_gen_st_tl(dest, cpu_env, offsetof(CPUNios2State, ctrl[CR_BADADDR])); + t_gen_helper_raise_exception(dc, EXCP_UNALIGND); + dc->base.is_jmp = DISAS_NORETURN; } From patchwork Thu Mar 10 11:27:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 550133 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp945572mag; Thu, 10 Mar 2022 04:29:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJzZ/mmR9Sb/uVY5iTHPyjcjD+k8F3MwfOWfOb1PpjF8TayhnKFcZc0pe9SFCFn01bA69+ob X-Received: by 2002:a25:dc51:0:b0:628:8cbe:b1bc with SMTP id y78-20020a25dc51000000b006288cbeb1bcmr3754140ybe.582.1646915381913; Thu, 10 Mar 2022 04:29:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646915381; cv=none; d=google.com; s=arc-20160816; b=n1ckA/oAn+tmsmHJFQExbYTHehiohuSBeFS6/wVD0LkVNdbYVRm/B4yVZ0jwIsxZpZ CCaHDHKpZDpwr78cXXHrCDhO2XmKtiX5jTkPoQFn+Y5yKq+ypsv8uCursixov6EQwVek HB7uqLbtRzLU5ir9hPbPbGsThlha/1sqNDxct1wCUJO4cN6HYiAmyWw5AKMVEcvA32+c Fmyr/KZJQUOM7LINbu2m0QGjSDNKqoHfDN18CU5G1zQx/kdXQnZuFV7O2fyHVeIoHaN/ 7hd23jyyeK9kUKHOOjPvclBY46PvorJCTEg2+XZqrmn8kA8SCmgV/Vj5cmM0n0XHAUoN AXzw== 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=aUIv8mPilapal9RFUm8fJDHj8xhqXeKP3105ESvQPFk=; b=z1E1oz4eyIsnBDdYSFwTsG5BKruToAv7gbRJMzBXg08oCls4Yrw3XAyaNJWHUD7Jzb 71InImrVsbu93nycku7n9wtccBJ1voIHI7DvsKNL2F3VmVBXF48U/QoQAnK/BI+0t3z/ TdR5wkaz8WdZWq1saoTUmAQ6cpp4ATve9Zj1/GbmMHLpeHcqIe8ulTELOoXjsl4i9qXA yvE8Pers4T81nJ2DEU5b4zRVaeUYMDEpr3D1duGm/V6LrtlYwmm9GdTVJ7AQx90ybCKr EUyeRJ0YPZbY9vZVaTxDH8NHzm3J2qRXyGmxIB41mLlZJWiPdtlJjrLN3apJK8OrABKF Ri6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=rJQWPPJX; 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 a70-20020a25ca49000000b0062f86158b01si4409ybg.648.2022.03.10.04.29.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Mar 2022 04:29:41 -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=rJQWPPJX; 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]:46736 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSHvJ-0003aA-D4 for patch@linaro.org; Thu, 10 Mar 2022 07:29:41 -0500 Received: from eggs.gnu.org ([209.51.188.92]:51740) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSH0m-0002Vt-OI for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:31:17 -0500 Received: from [2607:f8b0:4864:20::1029] (port=34518 helo=mail-pj1-x1029.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nSH0l-0008Sq-8Y for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:31:16 -0500 Received: by mail-pj1-x1029.google.com with SMTP id k5-20020a17090a3cc500b001befa0d3102so6097687pjd.1 for ; Thu, 10 Mar 2022 03:31:13 -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=aUIv8mPilapal9RFUm8fJDHj8xhqXeKP3105ESvQPFk=; b=rJQWPPJXwXzp9TRp24MRTjirq45N7llzkfCJ+J7PrKc0wAgDdUm7iJ36QOEAz91ed5 qy9CySuBpZJKUVt0T5ho7SdjC/7o5cdka+t/ZAzGP29Q1OxVvAORXGVe1mZ5RKvP8s2k F7+A7m0Sri8sCUWRoNlK7/+j8y+dlZzykRZA/EnPa47Lr73L/5N1XyKhE0MzKGpPj41B z6nwkYeDiRwdgROUOOuCHPd+GTu5SZAkfBkOyI/k8vDNl62UVaN14TGPuZO2QEJOEvdI FdTLYyPKcGLYTsyM4ByASPZQTW/4ZRORHKZL6v9E8VxhAbR6swi2VCq7ntiTqEZ4l54f YOEA== 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=aUIv8mPilapal9RFUm8fJDHj8xhqXeKP3105ESvQPFk=; b=eZ49sl2iTPp6bQZtJRQWvYyUc8f0FlEKpCw0LsqrG+SZ5+NCIGYympcDs/YlSWRAu/ YdXHAj5xLZectueDAHlzX3EjqNMtM6AtjuUWrkniJM0IRKcHxGDrGqPaoEktZbQdzQfi SvRB9GLkOdN388NALnBJ8p/gUQDTLXEmijHJXvvxqIIqzjR7blp/8mlJmNNtT3mQj/Rh rGVhCItq98JYHI/4R3BEM/YpKtOUn8EZMBgQrZhjYFm/479q8vdyIR5XDCJJieaDNmbJ 4PnDneJcyu9n1dW5OGLiMymr3Sj7Gvwl0kpjw6o0tWQ1J4Sdbm+83CiOrEn6uNxHpb0g wgcw== X-Gm-Message-State: AOAM530FfE6WvjJnIS8ZRmgi6iOMmWXjxTX29PJZuQVgl74jJ7aq7UkM KpJaIk+fpmj5Nz8KF/gqgGunmfSzQRcwzQ== X-Received: by 2002:a17:90a:9ac:b0:1bf:a3e2:3f5c with SMTP id 41-20020a17090a09ac00b001bfa3e23f5cmr4506913pjo.105.1646911872818; Thu, 10 Mar 2022 03:31:12 -0800 (PST) Received: from localhost.localdomain (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id e14-20020a056a001a8e00b004f75cf1ab6csm6011246pfv.206.2022.03.10.03.31.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Mar 2022 03:31:12 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 40/48] linux-user/nios2: Handle various SIGILL exceptions Date: Thu, 10 Mar 2022 03:27:17 -0800 Message-Id: <20220310112725.570053-41-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::1029 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::1029; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1029.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 missed out on a couple of exception types that may legitimately be raised by a userland program. Signed-off-by: Richard Henderson --- linux-user/nios2/cpu_loop.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/linux-user/nios2/cpu_loop.c b/linux-user/nios2/cpu_loop.c index 67220128aa..f223238275 100644 --- a/linux-user/nios2/cpu_loop.c +++ b/linux-user/nios2/cpu_loop.c @@ -49,6 +49,14 @@ void cpu_loop(CPUNios2State *env) env->ctrl[CR_BADADDR]); break; + case EXCP_ILLEGAL: + case EXCP_UNIMPL: + force_sig_fault(TARGET_SIGILL, TARGET_ILL_ILLOPC, env->pc); + break; + case EXCP_SUPERI: + force_sig_fault(TARGET_SIGILL, TARGET_ILL_PRVOPC, env->pc); + break; + case EXCP_TRAP: switch (env->error_code) { case 0: From patchwork Thu Mar 10 11:27:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 550135 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp948186mag; Thu, 10 Mar 2022 04:32:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJyXB3T5eHAa4nL2fRHpD20uacHQRLn+IXk0AMGa64VpnBLCk99uERyx73il/4LRivgSWwvn X-Received: by 2002:a0d:cfc5:0:b0:2dc:48db:dda1 with SMTP id r188-20020a0dcfc5000000b002dc48dbdda1mr3628408ywd.83.1646915578389; Thu, 10 Mar 2022 04:32:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646915578; cv=none; d=google.com; s=arc-20160816; b=RUjTLXlM64rAr3jSkwAH0k+/PNDY7QZ22aLSvyC4ZnjqYcLkftDQMHUi+u/eqzGN32 q9B18jWgnljwVT+4IXPqI12khgc9UmRM7jtibdgUTtuKUyw76tECYGToXlrcMONiukRn 0B8G4UHz3npW5T81uLCO4WBikSz3Bxi2bg/ofm+gUvJalOatTqXsTxdK2z2lwtDx3iux /CTo9tFmbFrF6ksy9o4c0FP55ioDGdK7UvTNW7qHK1FhCnVn97rjeVzlI6brJW4ctP3e MOZaccndwhTbkEmXxPTcfhEugH8sQ1OGMT/Xd0GlzKedFDIqbvgqk4PblWNUSS4oBViJ ysKw== 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=ItyhHSiGdc58HAGraU/SXIWa8zv4816zOwkBCWpNHUs=; b=wYOlGJbOn/EQPaYpkowu7nFNZuuug+9cCPeK4Vw1FdGbR/mvCC6FiW0l8WRBrxDTJ8 PvMq29v4qQ7zvbNbBANlCvEVejonRVlSZddkEoPEMN6jc/w+UqEhHfXeyn/pBpBE1t63 Jbg3RRrUhIG+9H79KiEaLWE9FUyBq7gaWN7ZWZVgb+h/ypFLxYHSvWnLDStAclmur4tg x6+PD+zi+zRh5rmD1XZD/iau/ufy/IWP5QYZgUnqXcX21n625YgVq9RoNGpMcDiO7pRJ 1QyvKMaSaKdrZ/XHRrQMJXsi0KsCWbWTO80jE8jPclJeyGx1438fys2aKUvrwA5c5qNx 4HaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="uXnYCF/c"; 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 p4-20020a056902114400b0062e6e61acfesi519853ybu.373.2022.03.10.04.32.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Mar 2022 04:32:58 -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="uXnYCF/c"; 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]:53188 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSHyT-0000AE-T1 for patch@linaro.org; Thu, 10 Mar 2022 07:32:57 -0500 Received: from eggs.gnu.org ([209.51.188.92]:51748) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSH0n-0002Vw-A2 for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:31:17 -0500 Received: from [2607:f8b0:4864:20::52a] (port=46778 helo=mail-pg1-x52a.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nSH0l-0008Sv-Dt for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:31:16 -0500 Received: by mail-pg1-x52a.google.com with SMTP id o23so4464899pgk.13 for ; Thu, 10 Mar 2022 03:31:15 -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=ItyhHSiGdc58HAGraU/SXIWa8zv4816zOwkBCWpNHUs=; b=uXnYCF/cLCJx51+LWAIwgtC7Pt9tyU+PxtALMfCYqGei4QUx48rKku9+IwUQAEQhWV gcdi4APUpaiJArwEbJkMcHVS/VyUZs53ss87AMISA/BJTwyP7abHroFjc9Xzmt+3snYS oc14U3psHKdasi/7MaJDNSSKdlsLvCEaL2vyKeiCFiP+eqaTWQUe/GGlg+96GKgycx9X k23/5XJxUZAKeeRRb4po1ZAp2fwjfErNr+sjc0P31VUpwGreEOqYhDh0dKXo03FNgcmr qjNl5XY9BnGNvansItTF++5t2SHGTfV1oia0KzrjBOtafsQttQaM4C0aUQg+OMUpkuBz OnYw== 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=ItyhHSiGdc58HAGraU/SXIWa8zv4816zOwkBCWpNHUs=; b=3xvlBi4dXET6wYu91CUSra/t5zrrpof94ZhXkEmVFQbmE0WCqKh3PtaEvunA785cLe vZCPCaIAjlxwuMsZFzBS9Zr+So46NngYhJVW4LAi7cQpxCi3bl+6CaOzRw59yBKLSD3F cCF5L6A0JcvXzW88NW76T6VmisZXvBmDG0pNBRgtiNzAVBUTqQUkVR3a/0UnjXrlp0zB j4ztkpZl0QXBMjIjEt91QgioKTAXimkwqBa4MDg4H9ZpXUIblPFyxnd0dRsdr8J3ZjAA qjTydQP4hD6N+6HMjk8/Pfj/vv/Na9usxnoty5Ac072p9RPQ3J+gv1MM840NEHqmWn2a UfmQ== X-Gm-Message-State: AOAM5315aEagMo3TN9G/wN3jc6GPzo1xz6QdD2hLXjjxpE7hTbgjBMhg hMZONEQWAm93aKJB2fr3ZyECg1I3aZl45Q== X-Received: by 2002:a62:402:0:b0:4f7:81a3:7c47 with SMTP id 2-20020a620402000000b004f781a37c47mr617181pfe.9.1646911873933; Thu, 10 Mar 2022 03:31:13 -0800 (PST) Received: from localhost.localdomain (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id e14-20020a056a001a8e00b004f75cf1ab6csm6011246pfv.206.2022.03.10.03.31.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Mar 2022 03:31:13 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 41/48] target/nios2: Introduce shadow register sets Date: Thu, 10 Mar 2022 03:27:18 -0800 Message-Id: <20220310112725.570053-42-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::52a (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::52a; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52a.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" Do not actually enable them so far, but add all of the plumbing to address them. Do not enable them for user-only. Add an env->regs pointer that handles the indirection to the current register set. The naming of the pointer hides the difference between old and new, user-only and sysemu. >From the notes on wrprs, which states that r0 must be initialized before use in shadow register sets, infer that R_ZERO is *not* hardwired to zero in shadow register sets. Adjust load_gpr and dest_gpr to reflect this. At the same time we might as well special case crs == 0 to avoid the indirection through env->regs during translation as well. Given that this is intended to be the most common case for non-interrupt handlers. Init env->regs at reset. Signed-off-by: Richard Henderson --- target/nios2/cpu.h | 24 +++++++++++++++++ target/nios2/cpu.c | 1 + target/nios2/translate.c | 58 +++++++++++++++++++++++++++++++--------- 3 files changed, 70 insertions(+), 13 deletions(-) diff --git a/target/nios2/cpu.h b/target/nios2/cpu.h index d5255e9e76..e32bebe9b7 100644 --- a/target/nios2/cpu.h +++ b/target/nios2/cpu.h @@ -60,6 +60,11 @@ struct Nios2CPUClass { #define NUM_GP_REGS 32 #define NUM_CR_REGS 32 +#ifndef CONFIG_USER_ONLY +/* 63 shadow register sets; index 0 is the primary register set. */ +#define NUM_REG_SETS 64 +#endif + /* General purpose register aliases */ enum { R_ZERO = 0, @@ -178,7 +183,13 @@ FIELD(CR_TLBMISC, EE, 24, 1) #define EXCP_MPUD 17 struct CPUArchState { +#ifdef CONFIG_USER_ONLY uint32_t regs[NUM_GP_REGS]; +#else + uint32_t shadow_regs[NUM_REG_SETS][NUM_GP_REGS]; + /* Pointer into shadow_regs for the current register set. */ + uint32_t *regs; +#endif uint32_t ctrl[NUM_CR_REGS]; uint32_t pc; @@ -229,6 +240,14 @@ static inline bool nios2_cr_reserved(const ControlRegState *s) return (s->writable | s->readonly) == 0; } +static inline void nios2_update_crs(CPUNios2State *env) +{ +#ifndef CONFIG_USER_ONLY + unsigned crs = FIELD_EX32(env->ctrl[CR_STATUS], CR_STATUS, CRS); + env->regs = env->shadow_regs[crs]; +#endif +} + void nios2_tcg_init(void); void nios2_cpu_do_interrupt(CPUState *cs); void dump_mmu(CPUNios2State *env); @@ -271,12 +290,17 @@ typedef Nios2CPU ArchCPU; #include "exec/cpu-all.h" +FIELD(TBFLAGS, CRS0, 0, 1) /* Set if CRS == 0. */ +FIELD(TBFLAGS, U, 1, 1) /* Overlaps CR_STATUS_U */ + static inline void cpu_get_tb_cpu_state(CPUNios2State *env, target_ulong *pc, target_ulong *cs_base, uint32_t *flags) { *pc = env->pc; *cs_base = 0; *flags = env->ctrl[CR_STATUS] & CR_STATUS_U; + *flags |= (env->ctrl[CR_STATUS] & R_CR_STATUS_CRS_MASK + ? 0 : R_TBFLAGS_CRS0_MASK); } #endif /* NIOS2_CPU_H */ diff --git a/target/nios2/cpu.c b/target/nios2/cpu.c index b8410d8447..efd6a21a8e 100644 --- a/target/nios2/cpu.c +++ b/target/nios2/cpu.c @@ -59,6 +59,7 @@ static void nios2_cpu_reset(DeviceState *dev) env->ctrl[CR_STATUS] = CR_STATUS_RSIE | CR_STATUS_U | CR_STATUS_PIE; #else env->ctrl[CR_STATUS] = CR_STATUS_RSIE; + nios2_update_crs(env); #endif env->regs[R_ZERO] = 0; diff --git a/target/nios2/translate.c b/target/nios2/translate.c index 1e784c8a37..525df7b023 100644 --- a/target/nios2/translate.c +++ b/target/nios2/translate.c @@ -100,12 +100,16 @@ typedef struct DisasContext { DisasContextBase base; target_ulong pc; int mem_idx; + bool crs0; TCGv sink; const ControlRegState *cr_state; } DisasContext; static TCGv cpu_R[NUM_GP_REGS]; static TCGv cpu_pc; +#ifndef CONFIG_USER_ONLY +static TCGv cpu_crs_R[NUM_GP_REGS]; +#endif typedef struct Nios2Instruction { void (*handler)(DisasContext *dc, uint32_t code, uint32_t flags); @@ -127,22 +131,36 @@ static uint8_t get_opxcode(uint32_t code) static TCGv load_gpr(DisasContext *dc, unsigned reg) { assert(reg < NUM_GP_REGS); - if (unlikely(reg == R_ZERO)) { - return tcg_constant_tl(0); + if (dc->crs0) { + if (unlikely(reg == R_ZERO)) { + return tcg_constant_tl(0); + } + return cpu_R[reg]; } - return cpu_R[reg]; +#ifdef CONFIG_USER_ONLY + g_assert_not_reached(); +#else + return cpu_crs_R[reg]; +#endif } static TCGv dest_gpr(DisasContext *dc, unsigned reg) { assert(reg < NUM_GP_REGS); - if (unlikely(reg == R_ZERO)) { - if (dc->sink == NULL) { - dc->sink = tcg_temp_new(); + if (dc->crs0) { + if (unlikely(reg == R_ZERO)) { + if (dc->sink == NULL) { + dc->sink = tcg_temp_new(); + } + return dc->sink; } - return dc->sink; + return cpu_R[reg]; } - return cpu_R[reg]; +#ifdef CONFIG_USER_ONLY + g_assert_not_reached(); +#else + return cpu_crs_R[reg]; +#endif } static void t_gen_helper_raise_exception(DisasContext *dc, @@ -198,7 +216,7 @@ static void gen_excp(DisasContext *dc, uint32_t code, uint32_t flags) static bool gen_check_supervisor(DisasContext *dc) { - if (dc->base.tb->flags & CR_STATUS_U) { + if (dc->base.tb->flags & R_TBFLAGS_U_MASK) { /* CPU in user mode, privileged instruction called, stop. */ t_gen_helper_raise_exception(dc, EXCP_SUPERI); return false; @@ -794,6 +812,7 @@ static void nios2_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) dc->mem_idx = cpu_mmu_index(env, false); dc->cr_state = cpu->cr_state; + dc->crs0 = FIELD_EX32(dc->base.tb->flags, TBFLAGS, CRS0); /* Bound the number of insns to execute to those left on the page. */ page_insns = -(dc->base.pc_first | TARGET_PAGE_MASK) / 4; @@ -927,13 +946,26 @@ void nios2_cpu_dump_state(CPUState *cs, FILE *f, int flags) void nios2_tcg_init(void) { - int i; +#ifndef CONFIG_USER_ONLY + TCGv_ptr crs = tcg_global_mem_new_ptr(cpu_env, + offsetof(CPUNios2State, regs), "crs"); - for (i = 0; i < NUM_GP_REGS; i++) { - cpu_R[i] = tcg_global_mem_new(cpu_env, - offsetof(CPUNios2State, regs[i]), + for (int i = 0; i < NUM_GP_REGS; i++) { + cpu_crs_R[i] = tcg_global_mem_new(crs, 4 * i, gr_regnames[i]); + } + +#define offsetof_regs0(N) offsetof(CPUNios2State, shadow_regs[0][N]) +#else +#define offsetof_regs0(N) offsetof(CPUNios2State, regs[N]) +#endif + + for (int i = 0; i < NUM_GP_REGS; i++) { + cpu_R[i] = tcg_global_mem_new(cpu_env, offsetof_regs0(i), gr_regnames[i]); } + +#undef offsetof_regs0 + cpu_pc = tcg_global_mem_new(cpu_env, offsetof(CPUNios2State, pc), "pc"); } From patchwork Thu Mar 10 11:27:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 550134 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp946743mag; Thu, 10 Mar 2022 04:31:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJwWpsPoFLvPAgTcucFOeWh3R6QNKiDDkGz4O9vSkOGP08nWzsIkVdAJnMSAkLhht+Dlf63C X-Received: by 2002:a0d:f347:0:b0:2d6:916b:eb3f with SMTP id c68-20020a0df347000000b002d6916beb3fmr3702010ywf.141.1646915471414; Thu, 10 Mar 2022 04:31:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646915471; cv=none; d=google.com; s=arc-20160816; b=gd7zaiOfhJ9dQcPp8wn48um09lfM4Y6qESd+OUd0ww2FlVtpmhRNKUzQ11RzABoMzm dFW5lX/Qxmzafn0ILc/P+yIUSu16iYo7qU9VWi7edSgiKAmqLMiYQ1wx/Ravjo6GGH6p cKhz1Ky8pZTC+GdxsZ9UL719JITtO4YpLkWGjAY67qKA4tx3oX7qNcWDjYIN7NFYa9Lk QM9ThcQUS5bbCssO5caeBCYN0SksAwsp85X9ix02D1KSrG0gxUfCQbm/c6OJbhkHwiym hOl8D5UvzZYzwAKIpV2uMBRJWEYVClpY0qqDMBilxcZi3apeAAgzKC9/b73WC/RuhOOh Z/pQ== 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=zL4ULUAZFLG4NiZ2Xxof4c8+aeBvBkKbH83Le8PjFIE=; b=Yl4DKEsdD1NZAq8FD3WcMFBDmd7DsJ80XYuUnoOG7zuC/4Zv7kE+xv2Fib19kjX8tR 9sdykuMvc2TbaYt0X7jP6tMm8gyCAazf/Qm/1vyD5NRQ0t1QEBXZ+uWgKmtlMkWAs3zJ 7HB/LCJKu10ol4JOzkeejK/UrC8IR+dJo3LCez8267sQpUE5n6u6t3PQRPU3h5fiAqtb 72ChEuIdr2X2SXmmLLurfnjSH5ZdPaBu2fguoTBzhsMm1dA/k1+ncBDGV1Ig4Szj5QQu p0FgyypYzQm1s3856o/IfUM20u307TkOisvMRYG7ESmFImqY/6fGzd2lkdVjXdpxGfYS VxWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=NQbcez9B; 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 i136-20020a25d18e000000b00628b7740711si2614172ybg.115.2022.03.10.04.31.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Mar 2022 04:31:11 -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=NQbcez9B; 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]:48168 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSHwk-0004gR-LM for patch@linaro.org; Thu, 10 Mar 2022 07:31:10 -0500 Received: from eggs.gnu.org ([209.51.188.92]:51772) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSH0o-0002Wl-I1 for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:31:21 -0500 Received: from [2607:f8b0:4864:20::632] (port=41562 helo=mail-pl1-x632.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nSH0m-0008T3-OI for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:31:18 -0500 Received: by mail-pl1-x632.google.com with SMTP id z3so4599401plg.8 for ; Thu, 10 Mar 2022 03:31:16 -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=zL4ULUAZFLG4NiZ2Xxof4c8+aeBvBkKbH83Le8PjFIE=; b=NQbcez9BQoOX6fuFu7cB1PvBsES3In949mJVL6L4weQ7seculiM5aQH1YKxx5dBSKf pn6v8hJPRcb0NTeddGJLtf6Ik098cHS9QLinWBcnTCC8i5iv8rQ2ulK8janGVDXjUrHZ +L+RX/p72nfZpgo/i9d5D3M9dpKrJFPnjKoSJ8uT2PxqyM1J/59vFuKmygBq33rCGr2l 4a25RORcANPrFF20XzqMNMgk4p8YdZQALnVB2SNBsKCTonDxG68r37Yz/7RScWkjcR/4 h6GmU46qkNUXt52z9TENl3xPXNAuMmvppOLqusLwQHWgaXn6Qp6XVzhDqKqmLnm9uV4E RRCA== 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=zL4ULUAZFLG4NiZ2Xxof4c8+aeBvBkKbH83Le8PjFIE=; b=ZYjofjYfOe1eEyzcZJkWQbvgpgzxIMFtKdKyZCXhLGnB7OHi84OqX7OOIjPn8mdIq0 cSGHaJcVv6poycsCTHPw+sS9+KDmV7brutqrMLhzy+/eYog233xR9wnC7eZfnon95eR4 k1TUKyAh+aY8FF8QC+kYzFOv2bAak38ywBKG+iQ5q7/45GtBAySXCNddPjuf9Hd4DSnh afkOGwFvgsUO+OmwvvvPcyr3ae0ZP2fHr4IzJTEc7R6TbfBlEVI6ffrWrQOdN5izELAW Sv3BaEccn1CSktUZdaslmUaeEynl4uKYRqReTWOJm+AFBz80xI/qhCR2PAhcoGhHOXp0 gJdA== X-Gm-Message-State: AOAM532S8Wj6bn/YZB2gZrR2UoC3LvcXFgpvVkZuTT4gA3YW+tbcg+2K 8WUWccLR00fYy4t4kifmAm+rCd5cilew+w== X-Received: by 2002:a17:90b:4c87:b0:1bf:7ff7:4f39 with SMTP id my7-20020a17090b4c8700b001bf7ff74f39mr15460413pjb.163.1646911875374; Thu, 10 Mar 2022 03:31:15 -0800 (PST) Received: from localhost.localdomain (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id e14-20020a056a001a8e00b004f75cf1ab6csm6011246pfv.206.2022.03.10.03.31.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Mar 2022 03:31:14 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 42/48] target/nios2: Implement rdprs, wrprs Date: Thu, 10 Mar 2022 03:27:19 -0800 Message-Id: <20220310112725.570053-43-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::632 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::632; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x632.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" Implement these out of line, so that tcg global temps (aka the architectural registers) are synced back to tcg storage as required. This makes sure that we get the proper results when status.PRS == status.CRS. Signed-off-by: Richard Henderson --- target/nios2/cpu.h | 1 + target/nios2/helper.h | 2 ++ target/nios2/op_helper.c | 12 ++++++++++ target/nios2/translate.c | 47 ++++++++++++++++++++++++++++++++++++++-- 4 files changed, 60 insertions(+), 2 deletions(-) diff --git a/target/nios2/cpu.h b/target/nios2/cpu.h index e32bebe9b7..26d4dcfe12 100644 --- a/target/nios2/cpu.h +++ b/target/nios2/cpu.h @@ -220,6 +220,7 @@ struct ArchCPU { bool diverr_present; bool mmu_present; + bool eic_present; uint32_t pid_num_bits; uint32_t tlb_num_ways; diff --git a/target/nios2/helper.h b/target/nios2/helper.h index 6f5ec60b0d..1648d76ade 100644 --- a/target/nios2/helper.h +++ b/target/nios2/helper.h @@ -24,6 +24,8 @@ DEF_HELPER_FLAGS_3(divu, TCG_CALL_NO_WG, i32, env, i32, i32) #if !defined(CONFIG_USER_ONLY) DEF_HELPER_3(eret, noreturn, env, i32, i32) +DEF_HELPER_FLAGS_2(rdprs, TCG_CALL_NO_WG, i32, env, i32) +DEF_HELPER_3(wrprs, void, env, i32, i32) DEF_HELPER_2(mmu_write_tlbacc, void, env, i32) DEF_HELPER_2(mmu_write_tlbmisc, void, env, i32) DEF_HELPER_2(mmu_write_pteaddr, void, env, i32) diff --git a/target/nios2/op_helper.c b/target/nios2/op_helper.c index 849867becd..e5e70268da 100644 --- a/target/nios2/op_helper.c +++ b/target/nios2/op_helper.c @@ -83,4 +83,16 @@ void helper_eret(CPUNios2State *env, uint32_t new_status, uint32_t new_pc) env->pc = new_pc; cpu_loop_exit(cs); } + +uint32_t helper_rdprs(CPUNios2State *env, uint32_t regno) +{ + unsigned prs = FIELD_EX32(env->ctrl[CR_STATUS], CR_STATUS, PRS); + return env->shadow_regs[prs][regno]; +} + +void helper_wrprs(CPUNios2State *env, uint32_t regno, uint32_t val) +{ + unsigned prs = FIELD_EX32(env->ctrl[CR_STATUS], CR_STATUS, PRS); + env->shadow_regs[prs][regno] = val; +} #endif /* !CONFIG_USER_ONLY */ diff --git a/target/nios2/translate.c b/target/nios2/translate.c index 525df7b023..2b2f528e00 100644 --- a/target/nios2/translate.c +++ b/target/nios2/translate.c @@ -103,6 +103,7 @@ typedef struct DisasContext { bool crs0; TCGv sink; const ControlRegState *cr_state; + bool eic_present; } DisasContext; static TCGv cpu_R[NUM_GP_REGS]; @@ -326,6 +327,27 @@ gen_i_math_logic(andhi, andi, 0, instr.imm16.u << 16) gen_i_math_logic(orhi , ori, 1, instr.imm16.u << 16) gen_i_math_logic(xorhi, xori, 1, instr.imm16.u << 16) +/* rB <- prs.rA + sigma(IMM16) */ +static void rdprs(DisasContext *dc, uint32_t code, uint32_t flags) +{ + if (!dc->eic_present) { + t_gen_helper_raise_exception(dc, EXCP_ILLEGAL); + return; + } + if (!gen_check_supervisor(dc)) { + return; + } + +#ifdef CONFIG_USER_ONLY + g_assert_not_reached(); +#else + I_TYPE(instr, code); + TCGv dest = dest_gpr(dc, instr.b); + gen_helper_rdprs(dest, cpu_env, tcg_constant_i32(instr.a)); + tcg_gen_addi_tl(dest, dest, instr.imm16.s); +#endif +} + /* Prototype only, defined below */ static void handle_r_type_instr(DisasContext *dc, uint32_t code, uint32_t flags); @@ -387,7 +409,7 @@ static const Nios2Instruction i_type_instructions[] = { INSTRUCTION_FLG(gen_stx, MO_SL), /* stwio */ INSTRUCTION_FLG(gen_bxx, TCG_COND_LTU), /* bltu */ INSTRUCTION_FLG(gen_ldx, MO_UL), /* ldwio */ - INSTRUCTION_UNIMPLEMENTED(), /* rdprs */ + INSTRUCTION(rdprs), /* rdprs */ INSTRUCTION_ILLEGAL(), INSTRUCTION_FLG(handle_r_type_instr, 0), /* R-Type */ INSTRUCTION_NOP(), /* flushd */ @@ -587,6 +609,26 @@ static void wrctl(DisasContext *dc, uint32_t code, uint32_t flags) #endif } +/* prs.rC <- rA */ +static void wrprs(DisasContext *dc, uint32_t code, uint32_t flags) +{ + if (!dc->eic_present) { + t_gen_helper_raise_exception(dc, EXCP_ILLEGAL); + return; + } + if (!gen_check_supervisor(dc)) { + return; + } + +#ifdef CONFIG_USER_ONLY + g_assert_not_reached(); +#else + R_TYPE(instr, code); + gen_helper_wrprs(cpu_env, tcg_constant_i32(instr.c), + load_gpr(dc, instr.a)); +#endif +} + /* Comparison instructions */ static void gen_cmpxx(DisasContext *dc, uint32_t code, uint32_t flags) { @@ -711,7 +753,7 @@ static const Nios2Instruction r_type_instructions[] = { INSTRUCTION_ILLEGAL(), INSTRUCTION(slli), /* slli */ INSTRUCTION(sll), /* sll */ - INSTRUCTION_UNIMPLEMENTED(), /* wrprs */ + INSTRUCTION(wrprs), /* wrprs */ INSTRUCTION_ILLEGAL(), INSTRUCTION(or), /* or */ INSTRUCTION(mulxsu), /* mulxsu */ @@ -812,6 +854,7 @@ static void nios2_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) dc->mem_idx = cpu_mmu_index(env, false); dc->cr_state = cpu->cr_state; + dc->eic_present = cpu->eic_present; dc->crs0 = FIELD_EX32(dc->base.tb->flags, TBFLAGS, CRS0); /* Bound the number of insns to execute to those left on the page. */ From patchwork Thu Mar 10 11:27:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 550136 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp949968mag; Thu, 10 Mar 2022 04:35:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJzxtkorYmX2tLzAPKagryOosGbHGqmFIUCQbhIGv6QaJknjQzYUVzUTxEJ8HHTIQwz5EGpg X-Received: by 2002:a81:ad0:0:b0:2dc:86d2:1d6c with SMTP id 199-20020a810ad0000000b002dc86d21d6cmr3689739ywk.498.1646915704302; Thu, 10 Mar 2022 04:35:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646915704; cv=none; d=google.com; s=arc-20160816; b=Q0T4UDLfHgapoq7mJzGh9ZwrTzK57HEUOSlhdOJpy3c4L68YwEJHSycFlTOS5VpptN rXXzbtRTkDCRrkLiBeUkQMvGoptXjOD+oZoj1lvBSseH2ZTuk9vR/OpDhm1Q1GVGtmXu mCoz4l6pWTD0CBhk6TcnVekYM4OaUGqJtq4p5+OFhETC3BWIGLmdabdhXUJRQjIl/5qk S/Dp1+mZAzbcgGJDHifxruZ6EQBOBLeTb7n5suQiiJ/+mr0v1Wg2H3o+qTGf8U1ilqw7 Z5KMvLS7XFJVlXRoqsA60hmCdB3hWiDxsJ2oP5QvPSoPOIEwvIfJA3x5f0URnT8inGfa 76bw== 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=MVyC4ASoKbDoWqWtQ6it33/tXOmFXiabY9tyAWzkgHg=; b=Ace7iU4oAGHr5OWQlzOOTensoryn0BXOMD2iTS0A45gs/0xtJaOhXWGmucNGaTX1hn 9CBN7GGeVcpKQOM4FZ8jMOYjafN4tmmtSi3EU72haPA96mLOTlvXi7IuqFnOnirehfkZ ST7FAJvYflZqnROxwErXeAJiCbvIWuR5glmHG1DY8QoTuWsvpS4aCr46SqdPMUbMPcwT KzLavxKw1SeZ5aEaYEzOv9tbocNLfEFHQCWCQa/cL/d4aUZ4BSyuQfNsGHFt61/FnsNV MllQCGiiw2ElxmA8PnnZ84OaOBl7OTYF9xZXrlFFxJ7QTd1cpzAFPrYFiJaLyJwVs2BS PAnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="G8JdJh/m"; 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 d17-20020a5b00d1000000b006220e248ea7si2798060ybp.433.2022.03.10.04.35.04 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Mar 2022 04:35:04 -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="G8JdJh/m"; 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]:59862 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSI0V-0004gk-Qj for patch@linaro.org; Thu, 10 Mar 2022 07:35:03 -0500 Received: from eggs.gnu.org ([209.51.188.92]:51784) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSH0p-0002Wo-LO for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:31:23 -0500 Received: from [2607:f8b0:4864:20::1033] (port=56259 helo=mail-pj1-x1033.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nSH0n-0008TK-LN for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:31:18 -0500 Received: by mail-pj1-x1033.google.com with SMTP id e3so4819678pjm.5 for ; Thu, 10 Mar 2022 03:31:17 -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=MVyC4ASoKbDoWqWtQ6it33/tXOmFXiabY9tyAWzkgHg=; b=G8JdJh/mnLXGyv0MmsQUXsBl2mSG8XRFkAfJkovZ7cMY5SO2XK1KepvXOvx/qw6xaV H/i1LoUqECvKwAomO8Sq7L5nDRmPYL6AoUeYwwxqAbR4a944LtZZNEA5HCqMJrhVV7TY g7l1V22dox1xdc9hgRZYmlwj8ZtlYTc7VFeMrdGV9hKdZOT57yrI4jaCTOV/hk3+WO88 bFYnBAAFpYvNez9Cb00nUyzjEsArwyOFgEh6cJXfVJRkpZAhBcsQh8sQgvvuuGSJ4mHb 99vkcEKCNETxJwaNxytiuW1SKTTIkt5rrcMuaymXLYVzw1t22LUGOKBzgQVdi68GAowU c4VA== 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=MVyC4ASoKbDoWqWtQ6it33/tXOmFXiabY9tyAWzkgHg=; b=mi2Oat6Q7j8o1058hVA5hN5TGcTvkgLnW8dG5zPYyoibB6kgiV2MFE9CItkG9zqPtk DYYDHUojEqZhAqjdh8Pett9WM1tLNwJWuN8De+dqPPHEQM9Use8xN7V+9o6VGRBLEjbK wCJdtgzpl/gPVklHHFpiPbojJ3y7rrI+7SPcf5yiTEjwaOstmqnhuj5byUZp4hwydSCu 0oBYHSkVx5OTG73YEv2At1OC2uUKs1SKikyzbraDC1wqMChvNkRsaQUT166BIPn9mrpF 4oy1hvpDHihUJ7OIyaXg4q/qeaAYjGB2fRbqW071ajQjPmDyXVhka8xL4tgE00M9x6XZ cj3g== X-Gm-Message-State: AOAM53198l37cePNd8L/8s4aFlGdCToBREXV5C48Q8099zaET4Vbl3WB d+tidbS1kc+qfCB59eNxOxuEsgSKwJwFHA== X-Received: by 2002:a17:90a:a78f:b0:1bc:8042:9330 with SMTP id f15-20020a17090aa78f00b001bc80429330mr15339983pjq.229.1646911876397; Thu, 10 Mar 2022 03:31:16 -0800 (PST) Received: from localhost.localdomain (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id e14-20020a056a001a8e00b004f75cf1ab6csm6011246pfv.206.2022.03.10.03.31.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Mar 2022 03:31:15 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 43/48] target/nios2: Update helper_eret for shadow registers Date: Thu, 10 Mar 2022 03:27:20 -0800 Message-Id: <20220310112725.570053-44-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::1033 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::1033; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1033.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" When CRS = 0, we restore from estatus; otherwise from sstatus. Update for the new CRS. Signed-off-by: Richard Henderson --- target/nios2/cpu.h | 1 + target/nios2/op_helper.c | 3 ++- target/nios2/translate.c | 13 ++++++++----- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/target/nios2/cpu.h b/target/nios2/cpu.h index 26d4dcfe12..62a73c7b32 100644 --- a/target/nios2/cpu.h +++ b/target/nios2/cpu.h @@ -82,6 +82,7 @@ enum { R_FP = 28, R_EA = 29, R_BA = 30, + R_SSTATUS = 30, R_RA = 31, }; diff --git a/target/nios2/op_helper.c b/target/nios2/op_helper.c index e5e70268da..2eac957f68 100644 --- a/target/nios2/op_helper.c +++ b/target/nios2/op_helper.c @@ -73,7 +73,7 @@ void helper_eret(CPUNios2State *env, uint32_t new_status, uint32_t new_pc) } /* - * 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. */ new_status &= (cpu->cr_state[CR_STATUS].writable | @@ -81,6 +81,7 @@ void helper_eret(CPUNios2State *env, uint32_t new_status, uint32_t new_pc) env->ctrl[CR_STATUS] = new_status; env->pc = new_pc; + nios2_update_crs(env); cpu_loop_exit(cs); } diff --git a/target/nios2/translate.c b/target/nios2/translate.c index 2b2f528e00..7a25c864e2 100644 --- a/target/nios2/translate.c +++ b/target/nios2/translate.c @@ -435,11 +435,14 @@ static void eret(DisasContext *dc, uint32_t code, uint32_t flags) #ifdef CONFIG_USER_ONLY g_assert_not_reached(); #else - TCGv tmp = 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 (dc->crs0) { + TCGv tmp = 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); + } else { + gen_helper_eret(cpu_env, load_gpr(dc, R_SSTATUS), load_gpr(dc, R_EA)); + } dc->base.is_jmp = DISAS_NORETURN; #endif } From patchwork Thu Mar 10 11:27:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 550099 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp911993mag; Thu, 10 Mar 2022 03:47:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJx793NJpTyDuwShqUasbU3a0HQlK+d/fMvJjsZRrCvO3HyGJM3CVp87APu6Xq90GGs/Zx3d X-Received: by 2002:a25:4b84:0:b0:628:bc07:5fad with SMTP id y126-20020a254b84000000b00628bc075fadmr3330520yba.247.1646912827955; Thu, 10 Mar 2022 03:47:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646912827; cv=none; d=google.com; s=arc-20160816; b=fd4BWqEMwERwxaoBhVX/XAXyAd/WRJM1cVXJ+hnUZS9+dA/n0D3UMa5nrVdw+emqx4 ctk9Y1z3OI0B77O5fHO5kkB8RjMfw/kokWK6XHnDDuXVafygDAcNmHRxSOx9PEty1iVA ke7EPodyTJklLcGEm5NXCnvmarCc/AB8F1Hl2mJ8VB0aHMBRYSgMAFHLfMOdPEBwQEjA QneUQcERr34mk/4CzzVQBw+k1/xYzTAO6RhLl60LuEfuxO5uMY0g8OzZreXcz/zqdfpH J4W9Q9kD4KJRVSD/BsBY9DeJSiKpwpYHr2TZrSCdSycNY+acM7WP1kC0jJWcDEBnK06f O4Hw== 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=Jku9bPh0YVOaP+OMjPsiDbVlpEa9BNiPKSyQ8r6I0fM=; b=bEYYqXR7BEtj5pVM33IWTdvuEqu6Y//fboHheCpOPP4szCbRwhRRMRud/j8r7d+fEn +029jgAnt/1V3fXxBZJxtWidNnotDdYCSfKjQaRDTt35KVKwyRmzQ6bh9NwiNDS0o12w 5hnX5yBsuuttY9UzSMnQ31VPi86UT51BRQwG4pgK2WWLbkyYdEu+zQPTzPHdwsX0Ow7o J3OWoGo4kwlMetaAcVV7oHN1zRTFc7/HsmfLOxESfB1JNH08V9igOLOwxNmC2k7KZ8vI mO+BBL0cum7qyOWVL2rWsCjULnT0COlUgHMLwRU1Oyjfhettjnrz+3yiKzvlyYzIXYXD xWQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=DokEgmWa; 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 h20-20020a81b654000000b002dbc3590913si2521584ywk.532.2022.03.10.03.47.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Mar 2022 03:47:07 -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=DokEgmWa; 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]:38412 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSHG7-0005Je-8y for patch@linaro.org; Thu, 10 Mar 2022 06:47:07 -0500 Received: from eggs.gnu.org ([209.51.188.92]:51802) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSH0q-0002Wq-LO for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:31:23 -0500 Received: from [2607:f8b0:4864:20::42b] (port=44785 helo=mail-pf1-x42b.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nSH0o-0008TU-Op for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:31:20 -0500 Received: by mail-pf1-x42b.google.com with SMTP id u17so2670152pfk.11 for ; Thu, 10 Mar 2022 03:31:18 -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=Jku9bPh0YVOaP+OMjPsiDbVlpEa9BNiPKSyQ8r6I0fM=; b=DokEgmWacpFOEZFsBX84n8leKjhyCAeXfXd8wT/xpzawETwDokEOGB/2nxAUBaZ1sO rD1DsqJl95gA5EQrwD9mqVL16t747aFpfkHaMa1Iaksf7xt/a4lQf6VxCQk/Qb/LpN3G 9pDtyXK7qByXXe6LWm6k/YVcsWOA4SKNWh4ODM/FaQhA5l9hq/tOT3aU44Si3MLZmFmG B8Vlpkjsx19IvdyymsRD3eRFnVTNHGJUE0MrGcBK6lBZowihDOo1mjdb3blCXi+vwRr4 3hWOdHPjZkPN4KkAIZpJi5UuLoLx6Jx2S+6ezYN9OjJRiqbVPtd5UOwgVw7WyvzT/Dpk XtMw== 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=Jku9bPh0YVOaP+OMjPsiDbVlpEa9BNiPKSyQ8r6I0fM=; b=O9M5Pv74G8jXoR+roUV9e06qIf296G9YdZF+3yIajCdUGDqkwr9c/RLAniwJ9Mn/ks bSxj9Q+BesFG8yiv/BcKPcr9tmnevlB7BxSD5eNejYhAFOEwlJ/FOCw1ECZ0gN+IMVJB m0x6Sg9KStL+efTSDJt3uEnuAh2Qu2aykHFNmlwL03s85FEO0poN5dh5hX+fB0uHi2gO Q8HAclmGOE1nQY6JejODVN4mP7phlA0fvB2hK8RhdDDLP0Dl1btcCiIJmqsYhjMzmHyz w+Pu+vMwFThsjprbeMOGJMM4LSy+e7LXUIx/fZhGgSRhgnYTrt+wn+VFoeJ9iig8oIkL ceIQ== X-Gm-Message-State: AOAM531u3NT93AqCT2dDz+P7NZ2ilN0YDgQuyWH/bDz6Kpf7nFKHT3Ug ZvcMISkW4tCVKuN+tuwgtLBjPTAH4S8/kg== X-Received: by 2002:a62:8481:0:b0:4f7:4d4:f592 with SMTP id k123-20020a628481000000b004f704d4f592mr4484057pfd.3.1646911877472; Thu, 10 Mar 2022 03:31:17 -0800 (PST) Received: from localhost.localdomain (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id e14-20020a056a001a8e00b004f75cf1ab6csm6011246pfv.206.2022.03.10.03.31.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Mar 2022 03:31:16 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 44/48] target/nios2: Implement EIC interrupt processing Date: Thu, 10 Mar 2022 03:27:21 -0800 Message-Id: <20220310112725.570053-45-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::42b (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::42b; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42b.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" This is the cpu side of the operation. Register one irq line, called EIC. Split out the rather different processing to a separate function. Delay initialization of gpio irqs until realize. We need to provide a window after init in which the board can set eic_present. Signed-off-by: Richard Henderson --- target/nios2/cpu.h | 8 ++++ target/nios2/cpu.c | 92 +++++++++++++++++++++++++++++++++---------- target/nios2/helper.c | 47 ++++++++++++++++++++-- 3 files changed, 123 insertions(+), 24 deletions(-) diff --git a/target/nios2/cpu.h b/target/nios2/cpu.h index 62a73c7b32..c9356416e2 100644 --- a/target/nios2/cpu.h +++ b/target/nios2/cpu.h @@ -114,6 +114,7 @@ FIELD(CR_STATUS, CRS, 10, 6) FIELD(CR_STATUS, PRS, 16, 6) FIELD(CR_STATUS, NMI, 22, 1) FIELD(CR_STATUS, RSIE, 23, 1) +FIELD(CR_STATUS, SRS, 31, 1) /* only in sstatus */ #define CR_STATUS_PIE R_CR_STATUS_PIE_MASK #define CR_STATUS_U R_CR_STATUS_U_MASK @@ -121,6 +122,7 @@ FIELD(CR_STATUS, RSIE, 23, 1) #define CR_STATUS_IH R_CR_STATUS_IH_MASK #define CR_STATUS_NMI R_CR_STATUS_NMI_MASK #define CR_STATUS_RSIE R_CR_STATUS_RSIE_MASK +#define CR_STATUS_SRS R_CR_STATUS_SRS_MASK FIELD(CR_EXCEPTION, CAUSE, 2, 5) FIELD(CR_EXCEPTION, ECCFTL, 31, 1) @@ -234,6 +236,12 @@ struct ArchCPU { /* Bits within each control register which are reserved or readonly. */ ControlRegState cr_state[NUM_CR_REGS]; + + /* External Interrupt Controller Interface */ + uint32_t rha; /* Requested handler address */ + uint32_t ril; /* Requested interrupt level */ + uint32_t rrs; /* Requested register set */ + bool rnmi; /* Requested nonmaskable interrupt */ }; diff --git a/target/nios2/cpu.c b/target/nios2/cpu.c index efd6a21a8e..c5025d32f4 100644 --- a/target/nios2/cpu.c +++ b/target/nios2/cpu.c @@ -67,7 +67,19 @@ static void nios2_cpu_reset(DeviceState *dev) } #ifndef CONFIG_USER_ONLY -static void nios2_cpu_set_irq(void *opaque, int irq, int level) +static void eic_set_irq(void *opaque, int irq, int level) +{ + Nios2CPU *cpu = opaque; + CPUState *cs = CPU(cpu); + + if (level) { + cpu_interrupt(cs, CPU_INTERRUPT_HARD); + } else { + cpu_reset_interrupt(cs, CPU_INTERRUPT_HARD); + } +} + +static void iic_set_irq(void *opaque, int irq, int level) { Nios2CPU *cpu = opaque; CPUNios2State *env = &cpu->env; @@ -109,10 +121,18 @@ static void nios2_cpu_initfn(Object *obj) RO_REG(CR_EXCEPTION); WR_REG(CR_BADADDR); - /* TODO: These control registers are not present with the EIC. */ - RO_FIELD(CR_STATUS, RSIE); - WR_REG(CR_IENABLE); - RO_REG(CR_IPENDING); + if (cpu->eic_present) { + WR_FIELD(CR_STATUS, RSIE); + RO_FIELD(CR_STATUS, NMI); + WR_FIELD(CR_STATUS, PRS); + RO_FIELD(CR_STATUS, CRS); + WR_FIELD(CR_STATUS, IL); + WR_FIELD(CR_STATUS, IH); + } else { + RO_FIELD(CR_STATUS, RSIE); + WR_REG(CR_IENABLE); + RO_REG(CR_IPENDING); + } if (cpu->mmu_present) { WR_FIELD(CR_STATUS, U); @@ -145,15 +165,6 @@ static void nios2_cpu_initfn(Object *obj) #if !defined(CONFIG_USER_ONLY) mmu_init(&cpu->env); - - /* - * These interrupt lines model the IIC (internal interrupt - * controller). QEMU does not currently support the EIC - * (external interrupt controller) -- if we did it would be - * a separate device in hw/intc with a custom interface to - * the CPU, and boards using it would not wire up these IRQ lines. - */ - qdev_init_gpio_in_named(DEVICE(cpu), nios2_cpu_set_irq, "IRQ", 32); #endif } @@ -169,6 +180,14 @@ static void nios2_cpu_realizefn(DeviceState *dev, Error **errp) Nios2CPUClass *ncc = NIOS2_CPU_GET_CLASS(dev); Error *local_err = NULL; +#ifndef CONFIG_USER_ONLY + if (cpu->eic_present) { + qdev_init_gpio_in_named(DEVICE(cpu), eic_set_irq, "EIC", 1); + } else { + qdev_init_gpio_in_named(DEVICE(cpu), iic_set_irq, "IRQ", 32); + } +#endif + cpu_exec_realizefn(cs, &local_err); if (local_err != NULL) { error_propagate(errp, local_err); @@ -185,17 +204,48 @@ static void nios2_cpu_realizefn(DeviceState *dev, Error **errp) } #ifndef CONFIG_USER_ONLY +static bool eic_take_interrupt(Nios2CPU *cpu) +{ + CPUNios2State *env = &cpu->env; + const uint32_t status = env->ctrl[CR_STATUS]; + + if (cpu->rnmi) { + return !(status & CR_STATUS_NMI); + } + if (!(status & CR_STATUS_PIE)) { + return false; + } + if (cpu->ril <= FIELD_EX32(status, CR_STATUS, IL)) { + return false; + } + if (cpu->rrs != FIELD_EX32(status, CR_STATUS, CRS)) { + return true; + } + return status & CR_STATUS_RSIE; +} + +static bool iic_take_interrupt(Nios2CPU *cpu) +{ + CPUNios2State *env = &cpu->env; + + if (!(env->ctrl[CR_STATUS] & CR_STATUS_PIE)) { + return false; + } + return env->ctrl[CR_IPENDING] & env->ctrl[CR_IENABLE]; +} + static bool nios2_cpu_exec_interrupt(CPUState *cs, int interrupt_request) { Nios2CPU *cpu = NIOS2_CPU(cs); - CPUNios2State *env = &cpu->env; - if ((interrupt_request & CPU_INTERRUPT_HARD) && - (env->ctrl[CR_STATUS] & CR_STATUS_PIE) && - (env->ctrl[CR_IPENDING] & env->ctrl[CR_IENABLE])) { - cs->exception_index = EXCP_IRQ; - nios2_cpu_do_interrupt(cs); - return true; + if (interrupt_request & CPU_INTERRUPT_HARD) { + if (cpu->eic_present + ? eic_take_interrupt(cpu) + : iic_take_interrupt(cpu)) { + cs->exception_index = EXCP_IRQ; + nios2_cpu_do_interrupt(cs); + return true; + } } return false; } diff --git a/target/nios2/helper.c b/target/nios2/helper.c index bf40cff779..00f27165d9 100644 --- a/target/nios2/helper.c +++ b/target/nios2/helper.c @@ -57,6 +57,9 @@ static void do_exception(Nios2CPU *cpu, uint32_t exception_addr, uint32_t old_status = env->ctrl[CR_STATUS]; uint32_t new_status = old_status; + /* With shadow regs, exceptions are always taken into CRS 0. */ + new_status &= ~R_CR_STATUS_CRS_MASK; + if ((old_status & CR_STATUS_EH) == 0) { int r_ea = R_EA, cr_es = CR_ESTATUS; @@ -65,7 +68,7 @@ static void do_exception(Nios2CPU *cpu, uint32_t exception_addr, cr_es = CR_BSTATUS; } env->ctrl[cr_es] = old_status; - env->regs[r_ea] = env->pc + 4; + env->shadow_regs[0][r_ea] = env->pc + 4; if (cpu->mmu_present) { new_status |= CR_STATUS_EH; @@ -83,8 +86,9 @@ static void do_exception(Nios2CPU *cpu, uint32_t exception_addr, } new_status &= ~(CR_STATUS_PIE | CR_STATUS_U); - env->ctrl[CR_STATUS] = new_status; + nios2_update_crs(env); + if (!is_break) { env->ctrl[CR_EXCEPTION] = FIELD_DP32(0, CR_EXCEPTION, CAUSE, cs->exception_index); @@ -97,6 +101,39 @@ static void do_iic_irq(Nios2CPU *cpu) do_exception(cpu, cpu->exception_addr, 0, false); } +static void do_eic_irq(Nios2CPU *cpu) +{ + CPUNios2State *env = &cpu->env; + uint32_t old_status = env->ctrl[CR_STATUS]; + uint32_t new_status = old_status; + uint32_t old_rs = FIELD_EX32(old_status, CR_STATUS, CRS); + uint32_t new_rs = cpu->rrs; + + new_status = FIELD_DP32(new_status, CR_STATUS, CRS, new_rs); + new_status = FIELD_DP32(new_status, CR_STATUS, IL, cpu->ril); + new_status = FIELD_DP32(new_status, CR_STATUS, NMI, cpu->rnmi); + new_status &= ~(CR_STATUS_RSIE | CR_STATUS_U); + new_status |= CR_STATUS_IH; + + if (!(new_status & CR_STATUS_EH)) { + new_status = FIELD_DP32(new_status, CR_STATUS, PRS, old_rs); + if (new_rs == 0) { + env->ctrl[CR_ESTATUS] = old_status; + } else { + if (new_rs != old_rs) { + old_status |= CR_STATUS_SRS; + } + env->shadow_regs[new_rs][R_SSTATUS] = old_status; + } + env->shadow_regs[new_rs][R_EA] = env->pc + 4; + } + + env->ctrl[CR_STATUS] = new_status; + nios2_update_crs(env); + + env->pc = cpu->rha; +} + void nios2_cpu_do_interrupt(CPUState *cs) { Nios2CPU *cpu = NIOS2_CPU(cs); @@ -162,7 +199,11 @@ void nios2_cpu_do_interrupt(CPUState *cs) switch (cs->exception_index) { case EXCP_IRQ: - do_iic_irq(cpu); + if (cpu->eic_present) { + do_eic_irq(cpu); + } else { + do_iic_irq(cpu); + } break; case EXCP_TLB_D: From patchwork Thu Mar 10 11:27:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 550102 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp914481mag; Thu, 10 Mar 2022 03:50:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJxf941C/YIYYn0Omh0+M0SpupQZ2GQq4oc1IV2xMiMslwsYdy1iT+Ad9o1L1oLcsaVTdFbk X-Received: by 2002:a81:7056:0:b0:2dc:4f0d:47fd with SMTP id l83-20020a817056000000b002dc4f0d47fdmr3469321ywc.435.1646913027259; Thu, 10 Mar 2022 03:50:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646913027; cv=none; d=google.com; s=arc-20160816; b=FPlFyrF0cy68gpstYvhinm9SUdTsM80sddulkLam1yqFwwbBXDOvScF/Rk0pOpHulb F1WjDSYivVTYvfhLfBiDPedA6ftPLeTZnFs5mO27fZCG1Pr8UOl1c+Usxg9HNH+wP9IY ZVzKfr7Q5vLCLJGeTaTBkURfp52TdvnBdEl7U9WMYpAUdQWi/qykXAVRakq5RxUGovQF IgPeED5KY3Av6iq3TlWBEjx95EBha9OZFKVPCRvMZDZ7rhr0t5MFNwezoFDtOVp0gug9 FbsNggioldjGBl6i+JHbxxunxoqafIl9PX2IMnuHFrT2sc0c5qDVgZlI/2YBE1kbwdxR aITg== 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=Oq3+WovLC1U0SsWCHamcVpyHHoEeCG/N4mUqpqq0Etc=; b=IIQqdhqlU3SQdUQu3bIGJAN5qEcws2uAdlA7yIxVxldA5jmlrBy0xHI83Glw72FHKJ 7IzYVMXbKhb9CjTjcc5vMXY0rq4C8KADbULtax75MnFiIszF1BOKxTQoPPt3E5kyqF+w Sn+fKjKpldJnegEqzniVdJhQyX+YDIBZS8q3gH3Dq+WGNhdqJJM1NP3OeZtk/vGNSdC/ Kk4UdMitaJLarpxkL1K3UstnFF1gCmuBcY+8gNeAfYQO3JtgggoQsLDcYo09McQer23D rdSvC4GX7OvmvmTjQQnestvQAxUyQPEnyMKxQMlAZL1HIc9LpA6PG2PVOVyYiSUIwIUI Lb7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Q+j1LZaU; 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 a6-20020a0df106000000b002d65bdec9c2si2505797ywf.376.2022.03.10.03.50.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Mar 2022 03:50:27 -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=Q+j1LZaU; 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]:46818 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSHJK-0002iv-N3 for patch@linaro.org; Thu, 10 Mar 2022 06:50:26 -0500 Received: from eggs.gnu.org ([209.51.188.92]:51840) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSH0s-0002X5-Pt for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:31:23 -0500 Received: from [2607:f8b0:4864:20::102f] (port=40786 helo=mail-pj1-x102f.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nSH0q-0008Tg-6t for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:31:22 -0500 Received: by mail-pj1-x102f.google.com with SMTP id mv5-20020a17090b198500b001bf2a039831so7931459pjb.5 for ; Thu, 10 Mar 2022 03:31:19 -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=Oq3+WovLC1U0SsWCHamcVpyHHoEeCG/N4mUqpqq0Etc=; b=Q+j1LZaUt5kCKClYxVzBJDlvY057auBmkhZ7pSSOGEZfb0XlhiZwg4uAxYZV9dqe9j pojytAhUgqniYs8dccZs7VRoA/a2U2+j2vJqRyi1EzOFJl6YkFLb87iDORfcZ05jEWPX U2G3nsHckRbGfQ+RwzEoNJtUWNt6oV1lkMEOthC+eRSM7mdCzRicbMK57mRJcMPnUrtc yI5INGtp8qkJrIcF3gOhR7bQi8Fow4AlWdLXqTAVY2VzV23AZxQMlg613N9peKGoTTur Ttd7vAjU5nBgpi+ljox8+ZqtIzS9esWzHehYbAJ+iRB2lEULzN3sh1g3oWP5b2PT5iB9 YJMw== 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=Oq3+WovLC1U0SsWCHamcVpyHHoEeCG/N4mUqpqq0Etc=; b=TEdjcqbk5rwSdzDIApO3zMzl+NuJTxrv75RpTE3r4HNWbu0rOmUxnB92ezdsSp0vZ1 1TkbrkOvxE6opqqT/RhdErFLIs20kywgPzlolXSf5sjyus+XPsQeorjQhU9ktHi+rpM9 17b2rB4Nr4XrCN8vBm7+YESGqqgcaT9ztdAKBJsD6yYWgcSehOY1cA0/opGEwVMu3m5H K21EyJtOYnLw9A6XfyNnsMOxGlGN+RYj8otrRHsgmgTkqfN4oKjFJxygNFDG/7yz0zDq uoKfoW483nPIwnZom56kO+00wzAp+AHo63wDFgPrQXPg1ACrXzwHC896eOTEFr2CcvNi fM9g== X-Gm-Message-State: AOAM5302LijbAoCZHLg3Ow0bqcq2Kdb6KPwwUdomaOeJ4qPQRpsCuiUd 2dhGcmuu7srPNMPy8V6nP/Um5dSvHiRW0g== X-Received: by 2002:a17:90a:4749:b0:1be:ea64:4348 with SMTP id y9-20020a17090a474900b001beea644348mr15386292pjg.231.1646911878786; Thu, 10 Mar 2022 03:31:18 -0800 (PST) Received: from localhost.localdomain (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id e14-20020a056a001a8e00b004f75cf1ab6csm6011246pfv.206.2022.03.10.03.31.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Mar 2022 03:31:18 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 45/48] hw/intc: Vectored Interrupt Controller (VIC) Date: Thu, 10 Mar 2022 03:27:22 -0800 Message-Id: <20220310112725.570053-46-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::102f (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::102f; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102f.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" From: Amir Gonnen Implement nios2 Vectored Interrupt Controller (VIC). VIC is connected to EIC. It needs to update rha, ril, rrs and rnmi fields on Nios2CPU before raising an IRQ. For that purpose, VIC has a "cpu" property which should refer to the nios2 cpu and set by the board that connects VIC. Reviewed-by: Peter Maydell Signed-off-by: Amir Gonnen Message-Id: <20220303153906.2024748-5-amir.gonnen@neuroblade.ai> [rth: Split out nios2_vic.h] Signed-off-by: Richard Henderson --- include/hw/intc/nios2_vic.h | 64 ++++++++ hw/intc/nios2_vic.c | 313 ++++++++++++++++++++++++++++++++++++ hw/intc/Kconfig | 3 + hw/intc/meson.build | 1 + 4 files changed, 381 insertions(+) create mode 100644 include/hw/intc/nios2_vic.h create mode 100644 hw/intc/nios2_vic.c diff --git a/include/hw/intc/nios2_vic.h b/include/hw/intc/nios2_vic.h new file mode 100644 index 0000000000..af1517a967 --- /dev/null +++ b/include/hw/intc/nios2_vic.h @@ -0,0 +1,64 @@ +/* + * Vectored Interrupt Controller for nios2 processor + * + * Copyright (c) 2022 Neuroblade + * + * Interface: + * QOM property "cpu": link to the Nios2 CPU (must be set) + * Unnamed GPIO inputs 0..NIOS2_VIC_MAX_IRQ-1: input IRQ lines + * IRQ should be connected to nios2 IRQ0. + * + * Reference: "Embedded Peripherals IP User Guide + * for Intel® Quartus® Prime Design Suite: 21.4" + * Chapter 38 "Vectored Interrupt Controller Core" + * See: https://www.intel.com/content/www/us/en/docs/programmable/683130/21-4/vectored-interrupt-controller-core.html + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef HW_INTC_NIOS2_VIC +#define HW_INTC_NIOS2_VIC + +#define TYPE_NIOS2_VIC "nios2-vic" +OBJECT_DECLARE_SIMPLE_TYPE(Nios2VIC, NIOS2_VIC) + +#define NIOS2_VIC_MAX_IRQ 32 + +struct Nios2VIC { + /*< private >*/ + SysBusDevice parent_obj; + + /*< public >*/ + qemu_irq output_int; + + /* properties */ + CPUState *cpu; + MemoryRegion csr; + + uint32_t int_config[NIOS2_VIC_MAX_IRQ]; + uint32_t vic_config; + uint32_t int_raw_status; + uint32_t int_enable; + uint32_t sw_int; + uint32_t vic_status; + uint32_t vec_tbl_base; + uint32_t vec_tbl_addr; +}; + +#endif /* HW_INTC_NIOS2_VIC */ diff --git a/hw/intc/nios2_vic.c b/hw/intc/nios2_vic.c new file mode 100644 index 0000000000..cf63212a88 --- /dev/null +++ b/hw/intc/nios2_vic.c @@ -0,0 +1,313 @@ +/* + * Vectored Interrupt Controller for nios2 processor + * + * Copyright (c) 2022 Neuroblade + * + * Interface: + * QOM property "cpu": link to the Nios2 CPU (must be set) + * Unnamed GPIO inputs 0..NIOS2_VIC_MAX_IRQ-1: input IRQ lines + * IRQ should be connected to nios2 IRQ0. + * + * Reference: "Embedded Peripherals IP User Guide + * for Intel® Quartus® Prime Design Suite: 21.4" + * Chapter 38 "Vectored Interrupt Controller Core" + * See: https://www.intel.com/content/www/us/en/docs/programmable/683130/21-4/vectored-interrupt-controller-core.html + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "qemu/osdep.h" + +#include "hw/irq.h" +#include "hw/qdev-properties.h" +#include "hw/sysbus.h" +#include "migration/vmstate.h" +#include "qapi/error.h" +#include "qemu/bitops.h" +#include "qemu/log.h" +#include "qom/object.h" +#include "hw/intc/nios2_vic.h" +#include "cpu.h" + + +enum { + INT_CONFIG0 = 0, + INT_CONFIG31 = 31, + INT_ENABLE = 32, + INT_ENABLE_SET = 33, + INT_ENABLE_CLR = 34, + INT_PENDING = 35, + INT_RAW_STATUS = 36, + SW_INTERRUPT = 37, + SW_INTERRUPT_SET = 38, + SW_INTERRUPT_CLR = 39, + VIC_CONFIG = 40, + VIC_STATUS = 41, + VEC_TBL_BASE = 42, + VEC_TBL_ADDR = 43, + CSR_COUNT /* Last! */ +}; + +/* Requested interrupt level (INT_CONFIG[0:5]) */ +static inline uint32_t vic_int_config_ril(const Nios2VIC *vic, int irq_num) +{ + return extract32(vic->int_config[irq_num], 0, 6); +} + +/* Requested NMI (INT_CONFIG[6]) */ +static inline uint32_t vic_int_config_rnmi(const Nios2VIC *vic, int irq_num) +{ + return extract32(vic->int_config[irq_num], 6, 1); +} + +/* Requested register set (INT_CONFIG[7:12]) */ +static inline uint32_t vic_int_config_rrs(const Nios2VIC *vic, int irq_num) +{ + return extract32(vic->int_config[irq_num], 7, 6); +} + +static inline uint32_t vic_config_vec_size(const Nios2VIC *vic) +{ + return 1 << (2 + extract32(vic->vic_config, 0, 3)); +} + +static inline uint32_t vic_int_pending(const Nios2VIC *vic) +{ + return (vic->int_raw_status | vic->sw_int) & vic->int_enable; +} + +static void vic_update_irq(Nios2VIC *vic) +{ + Nios2CPU *cpu = NIOS2_CPU(vic->cpu); + uint32_t pending = vic_int_pending(vic); + int irq = -1; + int max_ril = 0; + /* Note that if RIL is 0 for an interrupt it is effectively disabled */ + + vic->vec_tbl_addr = 0; + vic->vic_status = 0; + + if (pending == 0) { + qemu_irq_lower(vic->output_int); + return; + } + + for (int i = 0; i < NIOS2_VIC_MAX_IRQ; i++) { + if (pending & BIT(i)) { + int ril = vic_int_config_ril(vic, i); + if (ril > max_ril) { + irq = i; + max_ril = ril; + } + } + } + + if (irq < 0) { + qemu_irq_lower(vic->output_int); + return; + } + + vic->vec_tbl_addr = irq * vic_config_vec_size(vic) + vic->vec_tbl_base; + vic->vic_status = irq | BIT(31); + + /* + * In hardware, the interface between the VIC and the CPU is via the + * External Interrupt Controller interface, where the interrupt controller + * presents the CPU with a packet of data containing: + * - Requested Handler Address (RHA): 32 bits + * - Requested Register Set (RRS) : 6 bits + * - Requested Interrupt Level (RIL) : 6 bits + * - Requested NMI flag (RNMI) : 1 bit + * In our emulation, we implement this by writing the data directly to + * fields in the CPU object and then raising the IRQ line to tell + * the CPU that we've done so. + */ + + cpu->rha = vic->vec_tbl_addr; + cpu->ril = max_ril; + cpu->rrs = vic_int_config_rrs(vic, irq); + cpu->rnmi = vic_int_config_rnmi(vic, irq); + + qemu_irq_raise(vic->output_int); +} + +static void vic_set_irq(void *opaque, int irq_num, int level) +{ + Nios2VIC *vic = opaque; + + vic->int_raw_status = deposit32(vic->int_raw_status, irq_num, 1, !!level); + vic_update_irq(vic); +} + +static void nios2_vic_reset(DeviceState *dev) +{ + Nios2VIC *vic = NIOS2_VIC(dev); + + memset(&vic->int_config, 0, sizeof(vic->int_config)); + vic->vic_config = 0; + vic->int_raw_status = 0; + vic->int_enable = 0; + vic->sw_int = 0; + vic->vic_status = 0; + vic->vec_tbl_base = 0; + vic->vec_tbl_addr = 0; +} + +static uint64_t nios2_vic_csr_read(void *opaque, hwaddr offset, unsigned size) +{ + Nios2VIC *vic = opaque; + int index = offset / 4; + + switch (index) { + case INT_CONFIG0 ... INT_CONFIG31: + return vic->int_config[index - INT_CONFIG0]; + case INT_ENABLE: + return vic->int_enable; + case INT_PENDING: + return vic_int_pending(vic); + case INT_RAW_STATUS: + return vic->int_raw_status; + case SW_INTERRUPT: + return vic->sw_int; + case VIC_CONFIG: + return vic->vic_config; + case VIC_STATUS: + return vic->vic_status; + case VEC_TBL_BASE: + return vic->vec_tbl_base; + case VEC_TBL_ADDR: + return vic->vec_tbl_addr; + default: + return 0; + } +} + +static void nios2_vic_csr_write(void *opaque, hwaddr offset, uint64_t value, + unsigned size) +{ + Nios2VIC *vic = opaque; + int index = offset / 4; + + switch (index) { + case INT_CONFIG0 ... INT_CONFIG31: + vic->int_config[index - INT_CONFIG0] = value; + break; + case INT_ENABLE: + vic->int_enable = value; + break; + case INT_ENABLE_SET: + vic->int_enable |= value; + break; + case INT_ENABLE_CLR: + vic->int_enable &= ~value; + break; + case SW_INTERRUPT: + vic->sw_int = value; + break; + case SW_INTERRUPT_SET: + vic->sw_int |= value; + break; + case SW_INTERRUPT_CLR: + vic->sw_int &= ~value; + break; + case VIC_CONFIG: + vic->vic_config = value; + break; + case VEC_TBL_BASE: + vic->vec_tbl_base = value; + break; + default: + qemu_log_mask(LOG_GUEST_ERROR, + "nios2-vic: write to invalid CSR address %#" + HWADDR_PRIx "\n", offset); + } + + vic_update_irq(vic); +} + +static const MemoryRegionOps nios2_vic_csr_ops = { + .read = nios2_vic_csr_read, + .write = nios2_vic_csr_write, + .endianness = DEVICE_LITTLE_ENDIAN, + .valid = { .min_access_size = 4, .max_access_size = 4 } +}; + +static void nios2_vic_realize(DeviceState *dev, Error **errp) +{ + Nios2VIC *vic = NIOS2_VIC(dev); + + if (!vic->cpu) { + /* This is a programming error in the code using this device */ + error_setg(errp, "nios2-vic 'cpu' link property was not set"); + return; + } + + sysbus_init_irq(SYS_BUS_DEVICE(dev), &vic->output_int); + qdev_init_gpio_in(dev, vic_set_irq, NIOS2_VIC_MAX_IRQ); + + memory_region_init_io(&vic->csr, OBJECT(dev), &nios2_vic_csr_ops, vic, + "nios2.vic.csr", CSR_COUNT * sizeof(uint32_t)); + sysbus_init_mmio(SYS_BUS_DEVICE(dev), &vic->csr); +} + +static Property nios2_vic_properties[] = { + DEFINE_PROP_LINK("cpu", Nios2VIC, cpu, TYPE_CPU, CPUState *), + DEFINE_PROP_END_OF_LIST() +}; + +static const VMStateDescription nios2_vic_vmstate = { + .name = "nios2-vic", + .version_id = 1, + .minimum_version_id = 1, + .fields = (VMStateField[]){ + VMSTATE_UINT32_ARRAY(int_config, Nios2VIC, 32), + VMSTATE_UINT32(vic_config, Nios2VIC), + VMSTATE_UINT32(int_raw_status, Nios2VIC), + VMSTATE_UINT32(int_enable, Nios2VIC), + VMSTATE_UINT32(sw_int, Nios2VIC), + VMSTATE_UINT32(vic_status, Nios2VIC), + VMSTATE_UINT32(vec_tbl_base, Nios2VIC), + VMSTATE_UINT32(vec_tbl_addr, Nios2VIC), + VMSTATE_END_OF_LIST() + }, +}; + +static void nios2_vic_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(klass); + + dc->reset = nios2_vic_reset; + dc->realize = nios2_vic_realize; + dc->vmsd = &nios2_vic_vmstate; + device_class_set_props(dc, nios2_vic_properties); +} + +static const TypeInfo nios2_vic_info = { + .name = TYPE_NIOS2_VIC, + .parent = TYPE_SYS_BUS_DEVICE, + .instance_size = sizeof(Nios2VIC), + .class_init = nios2_vic_class_init, +}; + +static void nios2_vic_register_types(void) +{ + type_register_static(&nios2_vic_info); +} + +type_init(nios2_vic_register_types); diff --git a/hw/intc/Kconfig b/hw/intc/Kconfig index ec8d4cec29..eeb2d6f428 100644 --- a/hw/intc/Kconfig +++ b/hw/intc/Kconfig @@ -84,3 +84,6 @@ config GOLDFISH_PIC config M68K_IRQC bool + +config NIOS2_VIC + bool diff --git a/hw/intc/meson.build b/hw/intc/meson.build index 81ccdb0d78..167755ac64 100644 --- a/hw/intc/meson.build +++ b/hw/intc/meson.build @@ -62,3 +62,4 @@ specific_ss.add(when: ['CONFIG_KVM', 'CONFIG_XIVE'], if_true: files('spapr_xive_kvm.c')) specific_ss.add(when: 'CONFIG_GOLDFISH_PIC', if_true: files('goldfish_pic.c')) specific_ss.add(when: 'CONFIG_M68K_IRQC', if_true: files('m68k_irqc.c')) +specific_ss.add(when: 'CONFIG_NIOS2_VIC', if_true: files('nios2_vic.c')) From patchwork Thu Mar 10 11:27:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 550137 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp951741mag; Thu, 10 Mar 2022 04:37:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJyP4NO5iXaGhEjgyl850P8RZAAwa/7xVloO+M+DfrnMetntz053bbGhe/5FC88jO3IxfJoB X-Received: by 2002:a25:d7c2:0:b0:628:9d06:457b with SMTP id o185-20020a25d7c2000000b006289d06457bmr3603410ybg.137.1646915846477; Thu, 10 Mar 2022 04:37:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646915846; cv=none; d=google.com; s=arc-20160816; b=DPi0iFeoZS8idCGNaVM11vITUwk/4fUFk/+HGZvRV+tsAMVJyu3qYE6A8lbfNjjVhr Hl9tKY+RmszycYN6pqWN7ag0sF6LiVE1MOt+2j+SeEMuxBzgMoUkzlygsj/9RiT8kiOU n434WT+cJ4pxMkasHmzY12SsOQuBZPU4yZ5NYW+TrqoN4FrpB56m6qs2bCTMK/5D2JB6 BeNgWrtTeaVflygfHulwarshX4EL3fO8bSp7KCW/wyS1qhTXf9/6DuoEPRcpsUNfb/G0 76QDsesyqwNidQs63se0g+CQCr1XavUdw38YEezhu8fIWhVqR6C6oxZiee/TmtglgyPp TaXA== 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=v1XH3xOuF9Qfk4MizuEs6gkvLNvCljLe8Yi99oh17Cc=; b=P0g2d0qZjs19Sa2uNT+WcF9sFhalUkpIpyClzXjcodXCz5nrNg0XMCxcjy/Y/cCcHk +2giVm9zpMNJj5StVOirt+rY3mOUhFs9f+JwTiD26M7D8sH7/1g0w9l2ioHOjvrHUB+d c1zDgxHAFCZ0qaLoGRMyUN5tsjds14YMuY8XkRxEWaFnLqPxx+ezCVUby7xmnsNtqV16 2jJjc9wBu2s2oIfb+TVqS9TFbWxnLjoKJa8238DhR3DLXDDYAdFBg+h/l4z9YZE2wHdk XZzhdssxjrLjnfVR+99VehgDVhjGQ8IdDEL3FnwMKnsdqPhPakn6JpFV5mQB8vQHfEBI 8q1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=wbkYzWOR; 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 y80-20020a81a153000000b002dce977f5f4si3284780ywg.139.2022.03.10.04.37.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Mar 2022 04:37:26 -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=wbkYzWOR; 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]:38222 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSI2o-0000jP-0y for patch@linaro.org; Thu, 10 Mar 2022 07:37:26 -0500 Received: from eggs.gnu.org ([209.51.188.92]:51846) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSH0t-0002X7-5n for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:31:23 -0500 Received: from [2607:f8b0:4864:20::102d] (port=55228 helo=mail-pj1-x102d.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nSH0r-0008Ty-FR for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:31:22 -0500 Received: by mail-pj1-x102d.google.com with SMTP id b8so4954376pjb.4 for ; Thu, 10 Mar 2022 03:31:21 -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=v1XH3xOuF9Qfk4MizuEs6gkvLNvCljLe8Yi99oh17Cc=; b=wbkYzWORkFfhf9aL67Y6p1aACPbx+KFgYsOMUAm/Uk9oOmbXj9XxAxGLIpOlhOg4AD fn9pu65rRH+XWKqrzE9YQhSFYMC56hgR+Hc51r9GQrRTNaKk64hIva3JZ6m4UJeZTuTE h+ajaV1hnSrhBOZLCnbfRYhmJseXWv4FWL6M3vvJGBN9QJoLYxnZThTJLoYY0jQojqS1 MX3SF2MsX35xTyFO4VQX7oag5I/Q3g+sD3+3JCu0cG8nj/i6+qdE1Tfg6j7CpyGsz0ym anFkhHIdW47/GYZ91l9CwYtTV+50AcnYLVZkO+TS8izugjJKkaomNkhQHEGA7NSRCgq7 eLSQ== 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=v1XH3xOuF9Qfk4MizuEs6gkvLNvCljLe8Yi99oh17Cc=; b=olRZF9/mzCPqXuSpkSAi33u0nEaF+TDHJi4N/yJqe1h+dUOnvCcSmJI8q4wGIIWJDG bN3/kn9SOy8arIvKr0YYtkLC6vaxnckqxW6tJ+dptHqvBhjKnHNKXYTcfjJGWImlRLyP xmz7kmGKZ+QmolW0BNg+JBSMVh0TwpheWFhRrgs0cOSJ2qE+gTKd5P3L5pG8385IDoO3 kcboH0raI3irujMoBbR0vJ1XEl8BTjOJqjIkeHckSfFTBwRZ/hSJ+Q0zBCR/2GzmfXyb a7w6ZXCpcjVhDg/A84mo+cKDdbAkumwcyBmIJYmsxx4TuoJYh24kN6noXjmO793FPCuJ qVzA== X-Gm-Message-State: AOAM532Tx9OE3n5fUxQMF4NCcSIkF1/RYFXe1ZdKIMS03iJl+vwbjDMz 4NpBJIStr15/+jOPSERPBObV9njVUUupDw== X-Received: by 2002:a17:90a:2dc6:b0:1bf:654e:e17f with SMTP id q6-20020a17090a2dc600b001bf654ee17fmr4511869pjm.64.1646911880118; Thu, 10 Mar 2022 03:31:20 -0800 (PST) Received: from localhost.localdomain (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id e14-20020a056a001a8e00b004f75cf1ab6csm6011246pfv.206.2022.03.10.03.31.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Mar 2022 03:31:19 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 46/48] hw/nios2: Introduce Nios2MachineState Date: Thu, 10 Mar 2022 03:27:23 -0800 Message-Id: <20220310112725.570053-47-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::102d (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::102d; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102d.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 want to move data from the heap into Nios2MachineState, which is not possible with DEFINE_MACHINE. Signed-off-by: Richard Henderson Reviewed-by: Mark Cave-Ayland --- hw/nios2/10m50_devboard.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/hw/nios2/10m50_devboard.c b/hw/nios2/10m50_devboard.c index 3d1205b8bd..bdc3ffd50d 100644 --- a/hw/nios2/10m50_devboard.c +++ b/hw/nios2/10m50_devboard.c @@ -36,6 +36,13 @@ #include "boot.h" +struct Nios2MachineState { + MachineState parent_obj; +}; + +#define TYPE_NIOS2_MACHINE MACHINE_TYPE_NAME("10m50-ghrd") +OBJECT_DECLARE_TYPE(Nios2MachineState, MachineClass, NIOS2_MACHINE) + #define BINARY_DEVICE_TREE_FILE "10m50-devboard.dtb" static void nios2_10m50_ghrd_init(MachineState *machine) @@ -105,11 +112,24 @@ static void nios2_10m50_ghrd_init(MachineState *machine) BINARY_DEVICE_TREE_FILE, NULL); } -static void nios2_10m50_ghrd_machine_init(struct MachineClass *mc) +static void nios2_10m50_ghrd_class_init(ObjectClass *oc, void *data) { + MachineClass *mc = MACHINE_CLASS(oc); + mc->desc = "Altera 10M50 GHRD Nios II design"; mc->init = nios2_10m50_ghrd_init; mc->is_default = true; } -DEFINE_MACHINE("10m50-ghrd", nios2_10m50_ghrd_machine_init); +static const TypeInfo nios2_10m50_ghrd_type_info = { + .name = TYPE_NIOS2_MACHINE, + .parent = TYPE_MACHINE, + .instance_size = sizeof(Nios2MachineState), + .class_init = nios2_10m50_ghrd_class_init, +}; + +static void nios2_10m50_ghrd_type_init(void) +{ + type_register_static(&nios2_10m50_ghrd_type_info); +} +type_init(nios2_10m50_ghrd_type_init); From patchwork Thu Mar 10 11:27:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 550106 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp916120mag; Thu, 10 Mar 2022 03:52:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJwMPzTk2dtNLuSKmKlnuXQj0luDjH1A5+/Jm6AM1eMRvmsF1HsFL14lDVtDIqxqjo8mNwr+ X-Received: by 2002:a25:3857:0:b0:628:9c0d:442f with SMTP id f84-20020a253857000000b006289c0d442fmr3310188yba.461.1646913168557; Thu, 10 Mar 2022 03:52:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646913168; cv=none; d=google.com; s=arc-20160816; b=g6rm5VnSXb9k3AG5vzN6PwNj1XiRFJHhga1bVk83V1tn8m+18pHf/pYvImDDKF1S9K m3tLzJ6RTbeJKmgwlxPq6tCIKIpmBfXIVPMrsYMJoC5TtDGWeYWsFa3Zl+XNPDOMEAws mFKip9D8QM4oZVwnhUg3YkTKgV4BGKqYTV++KIOeBZj1flzVsZ+1SDSmSOL1bEBEYl4Y lh3FmtnuhL3DwYL/FTAgu0x7bePfD06B3uIuEoIcxXbHz7qPbbhoOEyKu4h6+sBQ7jbj wHeYPQaS6RUnYFTfPR5cfMw5eNJLoqoB38RPGd4RHFJ8IIzIdngyknE/j7+H5xG+Y8qb XIYA== 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=k4ozRW6iziM8OJ2TKPPCOH7wy/AQ7zg7VeU+iBKaQYA=; b=w1PwMlTiS9ON9o3b5MpUtoAPtGEDFUWkDts/JBt0t20jbBZYcmHHcOUAJ/KSeo8Ze1 k2YMvRCCI9fKCiMlQ0R4XDlKM7UChxS5yqH5oh1F0lgeBFiGuauZCqUqrbB9Ni4PGhoN 2IRo+zBH4VfEVXnFnMktbG9uxVDzXOVq7SNXrsm8rxJz6jPcctty+Q+HQEiQpZJy9tLE TYxL1QolnuCCgrFpJk8D/Dr3TKs5jxl7Jt4s5m33NfJeslYpkM3vw2bXbHjltby4N28G xZjEgae3iMr/8077sPL2V2meGUMNc0Z8Cd+wPG8RFuQ7vrmL1i5QrYib9zF8GSEF3gMA Iknw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=j4lwk9V1; 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 m8-20020a814048000000b002d6dd8cf807si2792667ywn.282.2022.03.10.03.52.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Mar 2022 03:52:48 -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=j4lwk9V1; 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]:55300 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSHLc-0000GK-0G for patch@linaro.org; Thu, 10 Mar 2022 06:52:48 -0500 Received: from eggs.gnu.org ([209.51.188.92]:51860) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSH0u-0002Y2-9p for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:31:25 -0500 Received: from [2607:f8b0:4864:20::533] (port=42570 helo=mail-pg1-x533.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nSH0s-0008U2-Hs for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:31:23 -0500 Received: by mail-pg1-x533.google.com with SMTP id o8so4487759pgf.9 for ; Thu, 10 Mar 2022 03:31:22 -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=k4ozRW6iziM8OJ2TKPPCOH7wy/AQ7zg7VeU+iBKaQYA=; b=j4lwk9V1TdTmTDoAFxfTNgp6AGeLFbXKuUZn5R82+4y+UIvpqL8WKEhFQIFWVF2a3v z281tf0lirswi4TUjXIuaIcRbFAGMzAFZBfIz216ffOtl9GfLFkgRWqpEupCapbWtPWZ +hWZQN95ZDYQQO0jG6/Cc7p3RaGt0G7887ylQxiKIQg9zFCrLrv0NvDh0D56/CPo/tYO jPORA0m5XmtK7a/FRLSoFssWQ0eEvJEwWlycIMbYbkbG/Bk40VloOpHjvPnVo8xYBt1n edIo4xlUxPOc8OLZs7c9506TWnFn5vEIFYAqB7uCK5j/vPrMmZ+VZjWTulBqQ0jm5LCj 1xqQ== 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=k4ozRW6iziM8OJ2TKPPCOH7wy/AQ7zg7VeU+iBKaQYA=; b=WbW9u729+EoNojWIYx+e57D7sSR1/tWGayxr0bPEGLR2RKfKaAaVSdHtReMF4aCAKI 7NX8HHCicHV+0vhjC+uLQ4oKuPGopzUo+3bJuxgiNLGes034crPZKxOA7T0p8VaRTP+9 2dJpEDxFx26sS1fELPB9vckf0DGkureqR1PO/tRAUVDSo6K/yScVetsCWnuTzdBf/Pcs UwtV+jGEh13QM7r+STnVMQs/zubIYr63m7hyL4XHUHdjn/DRaVGjJhO+E/TGb+87hyP4 v+oc2AJ48CNSxOwropL34LL3z1nqT/edfP/IHz4OTLVlGf4jmAmHnPaGWemOo0c2Vws4 LddA== X-Gm-Message-State: AOAM530CIBGtNT+8iUbJ3H0vJg61NS/OjXAo5Ql5dTfZZeBTlN2yqM9G Hlxp7IP5vrTDf1FxesB5ocO6RAJx2sbiBw== X-Received: by 2002:a62:30c4:0:b0:4f7:2b29:984 with SMTP id w187-20020a6230c4000000b004f72b290984mr4597010pfw.11.1646911881286; Thu, 10 Mar 2022 03:31:21 -0800 (PST) Received: from localhost.localdomain (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id e14-20020a056a001a8e00b004f75cf1ab6csm6011246pfv.206.2022.03.10.03.31.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Mar 2022 03:31:20 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 47/48] hw/nios2: Move memory regions into Nios2Machine Date: Thu, 10 Mar 2022 03:27:24 -0800 Message-Id: <20220310112725.570053-48-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::533 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::533; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x533.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, Mark Cave-Ayland Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Convert to contiguous allocation, as much as possible so far. The two timer objects are not exposed for subobject allocation. Reviewed-by: Mark Cave-Ayland Signed-off-by: Richard Henderson --- hw/nios2/10m50_devboard.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/hw/nios2/10m50_devboard.c b/hw/nios2/10m50_devboard.c index bdc3ffd50d..dda4ab2bf5 100644 --- a/hw/nios2/10m50_devboard.c +++ b/hw/nios2/10m50_devboard.c @@ -38,6 +38,11 @@ struct Nios2MachineState { MachineState parent_obj; + + MemoryRegion phys_tcm; + MemoryRegion phys_tcm_alias; + MemoryRegion phys_ram; + MemoryRegion phys_ram_alias; }; #define TYPE_NIOS2_MACHINE MACHINE_TYPE_NAME("10m50-ghrd") @@ -47,13 +52,10 @@ OBJECT_DECLARE_TYPE(Nios2MachineState, MachineClass, NIOS2_MACHINE) static void nios2_10m50_ghrd_init(MachineState *machine) { + Nios2MachineState *nms = NIOS2_MACHINE(machine); Nios2CPU *cpu; DeviceState *dev; MemoryRegion *address_space_mem = get_system_memory(); - MemoryRegion *phys_tcm = g_new(MemoryRegion, 1); - MemoryRegion *phys_tcm_alias = g_new(MemoryRegion, 1); - MemoryRegion *phys_ram = g_new(MemoryRegion, 1); - MemoryRegion *phys_ram_alias = g_new(MemoryRegion, 1); ram_addr_t tcm_base = 0x0; ram_addr_t tcm_size = 0x1000; /* 1 kiB, but QEMU limit is 4 kiB */ ram_addr_t ram_base = 0x08000000; @@ -62,22 +64,22 @@ static void nios2_10m50_ghrd_init(MachineState *machine) int i; /* Physical TCM (tb_ram_1k) with alias at 0xc0000000 */ - memory_region_init_ram(phys_tcm, NULL, "nios2.tcm", tcm_size, + memory_region_init_ram(&nms->phys_tcm, NULL, "nios2.tcm", tcm_size, &error_abort); - memory_region_init_alias(phys_tcm_alias, NULL, "nios2.tcm.alias", - phys_tcm, 0, tcm_size); - memory_region_add_subregion(address_space_mem, tcm_base, phys_tcm); + memory_region_init_alias(&nms->phys_tcm_alias, NULL, "nios2.tcm.alias", + &nms->phys_tcm, 0, tcm_size); + memory_region_add_subregion(address_space_mem, tcm_base, &nms->phys_tcm); memory_region_add_subregion(address_space_mem, 0xc0000000 + tcm_base, - phys_tcm_alias); + &nms->phys_tcm_alias); /* Physical DRAM with alias at 0xc0000000 */ - memory_region_init_ram(phys_ram, NULL, "nios2.ram", ram_size, + memory_region_init_ram(&nms->phys_ram, NULL, "nios2.ram", ram_size, &error_abort); - memory_region_init_alias(phys_ram_alias, NULL, "nios2.ram.alias", - phys_ram, 0, ram_size); - memory_region_add_subregion(address_space_mem, ram_base, phys_ram); + memory_region_init_alias(&nms->phys_ram_alias, NULL, "nios2.ram.alias", + &nms->phys_ram, 0, ram_size); + memory_region_add_subregion(address_space_mem, ram_base, &nms->phys_ram); memory_region_add_subregion(address_space_mem, 0xc0000000 + ram_base, - phys_ram_alias); + &nms->phys_ram_alias); /* Create CPU -- FIXME */ cpu = NIOS2_CPU(cpu_create(TYPE_NIOS2_CPU)); From patchwork Thu Mar 10 11:27:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 550122 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp930177mag; Thu, 10 Mar 2022 04:10:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJyzJicn+vnZ3RoMH5gjEwBvNxuAxas+hGVmW5Xdt6qXbN+hv9Gp6/LJ30VQhj9UxjPVFk1H X-Received: by 2002:a25:9d81:0:b0:622:7df3:ff6c with SMTP id v1-20020a259d81000000b006227df3ff6cmr3490910ybp.617.1646914237117; Thu, 10 Mar 2022 04:10:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646914237; cv=none; d=google.com; s=arc-20160816; b=YCVOnZT+xiarQaIYFo3MhsopxWOR1BXtf0KZqgGmMYE5l/krNu3xlAsO60vdwGdsZ4 8sddFQzuDkPXQmSTEdx+k18pgsIo/PyhQcbkb+IYEfXV/pJpGmEAU/hqjuYqEpfFD/5E paqjBjVlf9nBDV4UyzomNzhHhvDPTQwdM7YDmsCvV2yRXAWjn0DQUc7agTiAei/nVJMa c5yZcMYabL7ZOc2qgfskPEYUiviOGKbAxAAOO4+uN6SJb9W+K8O4FdvTMm6EVCWhe4kv 0dC/lMLMZhAPOyENvag2yrW1Eyr7WqzQg8ddfGQ1Wb8P4uDA3ormPyM5NHpFc4na5uLW ZkjQ== 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=FgJtqezNi81L0SadvxdIqrQdrL90cWo0N9YQo1orZhs=; b=mscYjHZKRnYlJsktlNc61Y3FYP9HvNyNrBg8HPYU/MSlQWZpSdY2F/b7uePZKWxfu/ DUI4NQBJa1g+/Ev0ALBiuKJl/giCogHoPv3xpSrw2sKd8NLmFUwaXb1urkMeizMCS02Z 7uGmgZXFXcUmiIhjr8eL2z6kLwrb2pmznycBA2LtwPzIe9txyGCXtGtKM8CKqwwUY/Eg hcLnMdq3X11xptdr/eEnqjYYx2Vt4YE4H/QlxVlS6YZFL3BB0+PNFeziwylkbRs9uxcU cGnvPs8pQnSCgZ85ahK5i5FPWTBI2YDtnRGbFO8o8yzJPFR0tKb5/vkCS68e9NfNiikY /IhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=sPPRs6mT; 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 k143-20020a813d95000000b002d639ab08d2si2563376ywa.342.2022.03.10.04.10.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Mar 2022 04:10:37 -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=sPPRs6mT; 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]:39138 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSHcq-0003F3-JG for patch@linaro.org; Thu, 10 Mar 2022 07:10:36 -0500 Received: from eggs.gnu.org ([209.51.188.92]:51890) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSH0v-0002Yg-HN for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:31:25 -0500 Received: from [2607:f8b0:4864:20::1033] (port=36514 helo=mail-pj1-x1033.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nSH0t-0008UG-Mf for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:31:25 -0500 Received: by mail-pj1-x1033.google.com with SMTP id kx6-20020a17090b228600b001bf859159bfso7973681pjb.1 for ; Thu, 10 Mar 2022 03:31:23 -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=FgJtqezNi81L0SadvxdIqrQdrL90cWo0N9YQo1orZhs=; b=sPPRs6mT0fiwfzhP1UotP2B8QCP+1RNBxDq7vT/kSmnE/z1/wZr6aaXCYAPIVntblY dRzcQWbsOoNnQdD0VYNJi9SjHEAqh3QlokDl8+VSzoQeHPxDAl3/90TkYIRAR9HMLLlO 4rrsOv60/aBUOfCVgsc15wXKXZdDOJ3nujuWD086txbVn3fLUZer34Pe8HhCd4EQTUyA Ui76LUGAVxZh072vjneC6WTQPYqkayn131KuhpzdPnyAQgAzebsVBE1oZpwsbYAAyxDy uJkQO5qSztDT+oVQB541jGRz3hRn3i3zV2q2fBce90FCNPP7RfRJ2GzorCOiShfSJgUy wSMQ== 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=FgJtqezNi81L0SadvxdIqrQdrL90cWo0N9YQo1orZhs=; b=j0cb2Pw0LlIdI0Ov1R4gUUcbmt7pc/j8rOPgUqii4hDeffb7RVAf5eMa4MdoSOJ8cM KZ5DhLX7r+f8FBpyo+b5HoFH3YGG7cvgZLQKDj7rncphj+h4UUNtHVcQwqVmgzB+Fuf+ wQdh25kVYgo41Z16dZb4JRkN9KbvHZLvsvuPEZikCdbhsftbn3AbibmOq581OE4gFjoZ Sywv5V6bOL3MzBiU7mTXIQaIx7/boJJhyDL2BP3BmcBIlaKUoLqzqhlB6bpiGaAsm8Wm jqq0jl0gkg9RuhBlCkTuhhYYNdENOW2p0i/V852+7pVjW5kA9LKByAfgMzJvuDvA7eFJ s3Ug== X-Gm-Message-State: AOAM533gKCmMnucx7UBsIFr6/RWEfo2llX8pwrl4eMcYSaYySM1j4mGt wgw/7A9fHVZ3gipHG+lvsojKSGg5CE9kug== X-Received: by 2002:a17:902:c1d4:b0:151:b56c:41ef with SMTP id c20-20020a170902c1d400b00151b56c41efmr4404907plc.77.1646911882431; Thu, 10 Mar 2022 03:31:22 -0800 (PST) Received: from localhost.localdomain (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id e14-20020a056a001a8e00b004f75cf1ab6csm6011246pfv.206.2022.03.10.03.31.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Mar 2022 03:31:21 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 48/48] hw/nios2: Machine with a Vectored Interrupt Controller Date: Thu, 10 Mar 2022 03:27:25 -0800 Message-Id: <20220310112725.570053-49-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::1033 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::1033; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1033.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" From: Amir Gonnen Demonstrate how to use nios2 VIC on a machine. Introduce a new machine property to attach a VIC. When VIC is present, let the CPU know that it should use the External Interrupt Interface instead of the Internal Interrupt Interface. The devices on the machine are attached to the VIC and not directly to cpu. To allow VIC update EIC fields, we set the "cpu" property of the VIC with a reference to the nios2 cpu. Signed-off-by: Amir Gonnen Message-Id: <20220303153906.2024748-6-amir.gonnen@neuroblade.ai> [rth: Put a property on the 10m50-ghrd machine, rather than create a new machine class.] Signed-off-by: Richard Henderson Reviewed-by: Mark Cave-Ayland --- hw/nios2/10m50_devboard.c | 61 +++++++++++++++++++++++++++++++++------ hw/nios2/Kconfig | 1 + 2 files changed, 53 insertions(+), 9 deletions(-) diff --git a/hw/nios2/10m50_devboard.c b/hw/nios2/10m50_devboard.c index dda4ab2bf5..91383fb097 100644 --- a/hw/nios2/10m50_devboard.c +++ b/hw/nios2/10m50_devboard.c @@ -27,6 +27,7 @@ #include "hw/sysbus.h" #include "hw/char/serial.h" +#include "hw/intc/nios2_vic.h" #include "hw/qdev-properties.h" #include "sysemu/sysemu.h" #include "hw/boards.h" @@ -43,6 +44,8 @@ struct Nios2MachineState { MemoryRegion phys_tcm_alias; MemoryRegion phys_ram; MemoryRegion phys_ram_alias; + + bool vic; }; #define TYPE_NIOS2_MACHINE MACHINE_TYPE_NAME("10m50-ghrd") @@ -81,10 +84,39 @@ static void nios2_10m50_ghrd_init(MachineState *machine) memory_region_add_subregion(address_space_mem, 0xc0000000 + ram_base, &nms->phys_ram_alias); - /* Create CPU -- FIXME */ - cpu = NIOS2_CPU(cpu_create(TYPE_NIOS2_CPU)); - for (i = 0; i < 32; i++) { - irq[i] = qdev_get_gpio_in_named(DEVICE(cpu), "IRQ", i); + /* Create CPU. We need to set eic_present between init and realize. */ + cpu = NIOS2_CPU(object_new(TYPE_NIOS2_CPU)); + + /* Enable the External Interrupt Controller within the CPU. */ + cpu->eic_present = nms->vic; + + /* Configure new exception vectors. */ + cpu->reset_addr = 0xd4000000; + cpu->exception_addr = 0xc8000120; + cpu->fast_tlb_miss_addr = 0xc0000100; + + qdev_realize_and_unref(DEVICE(cpu), NULL, &error_fatal); + + if (nms->vic) { + DeviceState *dev = qdev_new(TYPE_NIOS2_VIC); + MemoryRegion *dev_mr; + qemu_irq cpu_irq; + + object_property_set_link(OBJECT(dev), "cpu", OBJECT(cpu), &error_fatal); + sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); + + cpu_irq = qdev_get_gpio_in_named(DEVICE(cpu), "EIC", 0); + sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, cpu_irq); + for (int i = 0; i < 32; i++) { + irq[i] = qdev_get_gpio_in(dev, i); + } + + dev_mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 0); + memory_region_add_subregion(address_space_mem, 0x18002000, dev_mr); + } else { + for (i = 0; i < 32; i++) { + irq[i] = qdev_get_gpio_in_named(DEVICE(cpu), "IRQ", i); + } } /* Register: Altera 16550 UART */ @@ -105,15 +137,22 @@ static void nios2_10m50_ghrd_init(MachineState *machine) sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, 0xe0000880); sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, irq[5]); - /* Configure new exception vectors and reset CPU for it to take effect. */ - cpu->reset_addr = 0xd4000000; - cpu->exception_addr = 0xc8000120; - cpu->fast_tlb_miss_addr = 0xc0000100; - nios2_load_kernel(cpu, ram_base, ram_size, machine->initrd_filename, BINARY_DEVICE_TREE_FILE, NULL); } +static bool get_vic(Object *obj, Error **errp) +{ + Nios2MachineState *nms = NIOS2_MACHINE(obj); + return nms->vic; +} + +static void set_vic(Object *obj, bool value, Error **errp) +{ + Nios2MachineState *nms = NIOS2_MACHINE(obj); + nms->vic = value; +} + static void nios2_10m50_ghrd_class_init(ObjectClass *oc, void *data) { MachineClass *mc = MACHINE_CLASS(oc); @@ -121,6 +160,10 @@ static void nios2_10m50_ghrd_class_init(ObjectClass *oc, void *data) mc->desc = "Altera 10M50 GHRD Nios II design"; mc->init = nios2_10m50_ghrd_init; mc->is_default = true; + + object_class_property_add_bool(oc, "vic", get_vic, set_vic); + object_class_property_set_description(oc, "vic", + "Set on/off to enable/disable the Vectored Interrupt Controller"); } static const TypeInfo nios2_10m50_ghrd_type_info = { diff --git a/hw/nios2/Kconfig b/hw/nios2/Kconfig index b10ea640da..4748ae27b6 100644 --- a/hw/nios2/Kconfig +++ b/hw/nios2/Kconfig @@ -3,6 +3,7 @@ config NIOS2_10M50 select NIOS2 select SERIAL select ALTERA_TIMER + select NIOS2_VIC config NIOS2_GENERIC_NOMMU bool