From nobody Fri Nov 14 19:45:40 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1761747568; cv=none; d=zohomail.com; s=zohoarc; b=iLRlq+xqT+cGCErAB+4YbqWnNvHxm2GXZSzIg3PWpUGU5+pFW3yMYI7ASHgl5AbLVex3G1tt6/VwJJj82y9L7WCUNeuFcJCgcqu/FDiPiGh4spmkm9a9N6f9LkJBGmZYeaYNfnQvC/qkQ0WCdnv52yER3MpCgxt5LaUmoVsDfO0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761747568; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=30doxA5irCh12lo/8IWh5zRedaxf2ZL44iw4b76NrZs=; b=WBgQQnpMC8G7PXmNvMn/Si4bde+dlbvZ3aMs806vAjmsu+XSAUxgLLRmNa9oWf9+50IhrUDpb7i6SLWORAW3UjbEoe35L5tiJlGN2iA/tjCgJXW7YkHL3FJmFbChPUcHdIQjKKLz8TF6DklDT0Sn1/X2zBd+mBAzi31OV+HvmIM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1761747568804489.39927338971177; Wed, 29 Oct 2025 07:19:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vE70K-00030o-Lv; Wed, 29 Oct 2025 10:18:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vE704-0002zc-6B for qemu-devel@nongnu.org; Wed, 29 Oct 2025 10:18:09 -0400 Received: from mail-lf1-x12e.google.com ([2a00:1450:4864:20::12e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vE6zx-0007WA-L6 for qemu-devel@nongnu.org; Wed, 29 Oct 2025 10:18:06 -0400 Received: by mail-lf1-x12e.google.com with SMTP id 2adb3069b0e04-592f098f7adso9398071e87.0 for ; Wed, 29 Oct 2025 07:17:59 -0700 (PDT) Received: from gmail.com (213-67-3-247-no600.tbcn.telia.com. [213.67.3.247]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-59302982cb2sm3726650e87.65.2025.10.29.07.17.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Oct 2025 07:17:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1761747476; x=1762352276; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=30doxA5irCh12lo/8IWh5zRedaxf2ZL44iw4b76NrZs=; b=FvdIsbisVCAAt3Snj/RMqEt+7UZUgY29Za6DrJKx0ggnLQaDTMhexF/8xjJRrg10AG pDTPlTBFgQp9fqHrKvNmivvrMOhqbDLSbPg+ENbfcxnRGVdRil077Tq03p7QkAOVVe1A LjewV8XtyJzBv4WeqktH7fJyr9mcOhQaLVvcPYhjnkZk/eN6+KJAr3BlLoeqr+OmN21H OccVO++Mhxx2B4swKtzxI/ziQ9Ck4crqicoQE9zfpql8b4kEb3PYkcI7U5pQ5jchUV8m alUL8l7yIqmSM4X2ok9nQtx86B7JA47ml8Bn3aa/gEg9dbeFqx+86xY2b1k/6mHtYeIX 6XTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761747476; x=1762352276; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=30doxA5irCh12lo/8IWh5zRedaxf2ZL44iw4b76NrZs=; b=ZXwfxaBJnghPLwa/qGk7gKV3L5eoANpTwKqrSSH/qTJZPTCT1wq2WHVy7aNwmsfCBl ypdgAN2tsNPKSuO4MlswPZlFctzAHSaPjRJxd+/JIPAm6mf1UyPv5pfwpzFmu5ht6VM2 oSM/uzLGZpe7UYnsx06HiGrEEQ1cFDw/2XKaysKNhJkM/E6z4nY6DsOcfNrf/ePHeIUq UkcVS8lsWvvVRDIOLOEC5Q68VtwnXDg7J1MG8XgtBAwX425JCJk8GHjZOwcITAiSn05s rEDcqIpRtbhXLMUW42Un7oSk89FxGjk06eoSKRl1lhoe2nsIEUvMTpBvC+jDryq2I7Up X/qA== X-Gm-Message-State: AOJu0Yxy5/MvxfqR+K17vdEh0Ax0CbptvLhhEa7cCrLSviVt5GAS1+Yr DFEzfBGheNtWOOl8W059zBRXBbcVFDT3ocVyE03hYkrdVdH4hN4c6Fi0p8gwy340CCc= X-Gm-Gg: ASbGncvaj26Gyj/IcVyP3xm87BC4YUJ0vm4UF6jZ+4AZmhVfPsNBPigUxYzmK6+vdf2 49Il4yGRPYvuNlU63ro7g0hrE1JktTpg5u0N2BebBiGbA4YGTHYzy9bekkRt3/uoP8Be0Qz5iha vbFjs6zddwbONqLjFWbp81xxjsHoZ0EKbnpdT1fMfuS66kKaY04Rwr4+WXKjZhX9AvwnLBaAL4T Tt12oJGoNyMY+9IOKvPIGwfWcWmbg2iR3oH1AdZatzfH7+qohFcU9obenk6i7SENw1MlieOiqA5 5BRvx//HFfoUe6J+EO5sZ8LCP6QUuBKCKtO6QEup/siH/h3xfasz5I2Fz7wWmv721NcfUny5Lxv jIXhGtcLz3g8gOcyrIGQ+0jSuznA4rYyMoEWBgfqsWeQkz3o09hAmJ2HrmbS6MuN3622DwQzGvD zFHKsofQZRTms/zm5toox7pK0lHkuNSdR6dWzjn2nARog5tq8= X-Google-Smtp-Source: AGHT+IGxGA4cIHrxBok0i7duBmZ1gh2TIocPUh3Tw209hvmszKW9+HNLnKzhxthMunLbg+U5uKxxow== X-Received: by 2002:a05:6512:3185:b0:57a:f38a:397b with SMTP id 2adb3069b0e04-5941286172fmr1019816e87.3.1761747476296; Wed, 29 Oct 2025 07:17:56 -0700 (PDT) From: "Edgar E. Iglesias" To: qemu-devel@nongnu.org, "Edgar E. Iglesias" Cc: richard.henderson@linaro.org, edgar.iglesias@amd.com, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL v1 1/3] target/microblaze: Remove unused arg from check_divz() Date: Wed, 29 Oct 2025 15:17:47 +0100 Message-ID: <20251029141749.1274729-2-edgar.iglesias@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251029141749.1274729-1-edgar.iglesias@gmail.com> References: <20251029141749.1274729-1-edgar.iglesias@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::12e; envelope-from=edgar.iglesias@gmail.com; helo=mail-lf1-x12e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1761747570461154100 From: "Edgar E. Iglesias" Remove unused arg from check_divz(). No functional change. Signed-off-by: Edgar E. Iglesias Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/microblaze/op_helper.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/target/microblaze/op_helper.c b/target/microblaze/op_helper.c index df93c4229d..886224df3c 100644 --- a/target/microblaze/op_helper.c +++ b/target/microblaze/op_helper.c @@ -69,7 +69,7 @@ void helper_raise_exception(CPUMBState *env, uint32_t ind= ex) cpu_loop_exit(cs); } =20 -static bool check_divz(CPUMBState *env, uint32_t a, uint32_t b, uintptr_t = ra) +static bool check_divz(CPUMBState *env, uint32_t b, uintptr_t ra) { if (unlikely(b =3D=3D 0)) { env->msr |=3D MSR_DZ; @@ -89,7 +89,7 @@ static bool check_divz(CPUMBState *env, uint32_t a, uint3= 2_t b, uintptr_t ra) =20 uint32_t helper_divs(CPUMBState *env, uint32_t a, uint32_t b) { - if (!check_divz(env, a, b, GETPC())) { + if (!check_divz(env, b, GETPC())) { return 0; } return (int32_t)a / (int32_t)b; @@ -97,7 +97,7 @@ uint32_t helper_divs(CPUMBState *env, uint32_t a, uint32_= t b) =20 uint32_t helper_divu(CPUMBState *env, uint32_t a, uint32_t b) { - if (!check_divz(env, a, b, GETPC())) { + if (!check_divz(env, b, GETPC())) { return 0; } return a / b; --=20 2.43.0 From nobody Fri Nov 14 19:45:40 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1761747588; cv=none; d=zohomail.com; s=zohoarc; b=gsn9e09meUEn07Pm3N/CwpRFS5yVn3r4IqlxLdP0AWbAEmPSb8XMSIIfrRqIM1ACi33weHuf0h5W4/G2OtzhstGijUWrvKqoke33cwcksm2YQMMJqDX8wxJJiVht6TSPzWSnqQPBDDW3a1pjK5sfPNdQiOhCs353wfbrH9wLXAk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761747588; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=EVn0sUQNQNSn8ZCiQSobP2QW4bk86yZD0BGFnx3OH2U=; b=dRFN4/tyXwCTf8Z5tc+/d6klrsYcZLJhUnYsu84H66YJA9XDWJvzmPO7NIWMHTvUKGwXvXJqy0YYaZ3UaqXxrdOQcmbJnNkF91sbPSom9BoT2+Vw4pcUkB2wsBxqmQpGCwseFd8i8K4YMM7DCN6pzA5rjXYmNHXPbBtV+eXGqwk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1761747588531322.23200088405554; Wed, 29 Oct 2025 07:19:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vE70b-00036Q-6e; Wed, 29 Oct 2025 10:18:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vE707-000317-QC for qemu-devel@nongnu.org; Wed, 29 Oct 2025 10:18:21 -0400 Received: from mail-lj1-x236.google.com ([2a00:1450:4864:20::236]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vE6zz-0007WS-Th for qemu-devel@nongnu.org; Wed, 29 Oct 2025 10:18:11 -0400 Received: by mail-lj1-x236.google.com with SMTP id 38308e7fff4ca-378e8d10494so60629091fa.2 for ; Wed, 29 Oct 2025 07:18:02 -0700 (PDT) Received: from gmail.com (213-67-3-247-no600.tbcn.telia.com. [213.67.3.247]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-378ee0da2acsm33304661fa.42.2025.10.29.07.17.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Oct 2025 07:17:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1761747480; x=1762352280; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=EVn0sUQNQNSn8ZCiQSobP2QW4bk86yZD0BGFnx3OH2U=; b=Lj8qmw5K4G55Kn9xS+7t2RcFQUHn6qsezo5wzG+Vkd2RBmdvY/+KV7zoB9P8eO3PNT xqwylE2Hu3IOSmqZh6Gd3FtiAEhnkc+D7rQwuiVOmXqj1UUyURZ/M0UiYAGZE61imoug UmxBgVoT4tNyP80ok7lOOfZj9R9gtXl2bDd51OGzbRVToN0BaODyDr5YiXIw19u6aoh9 5/9IF8dku11CRsouJoEm2EeqMPuPV20JgBIL9o2zkyq4ES0gsoOG5yX37mwp8o7XkQwk uUfLC9E1sreHeGKWcehiABkpaM2UtMScevyS/a4WUfj9mY7qDCSjt84ovPzk4MP3FW/1 OQaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761747480; x=1762352280; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EVn0sUQNQNSn8ZCiQSobP2QW4bk86yZD0BGFnx3OH2U=; b=TTXgXapN702i4LDzOQLFJ338acJ4Ty2MBpE3CoQaVo45AZqtm0ZmplOPcZ9wfswHNt pZoJ6lWNwmHPZEZOmdljhsZzQ5MqPYzZbetyvmanpN4A8gT211pVAa4lFW2eyOG/RyFE lbr6ONBexESL9VER0u54bU5KjW7J2mt0nPUgluPMc0afB6aISWxeZxs5VHJXutFRwCyP bIrLCC5MqLvdYvJ7QOFrw0jiSq9FxrifhExgFEXqCgIrAA0V+43WjhR7KKHaDwLdrmmM j1d0YNJR8q16ZZKLZl+suuAqq+0x3NHiVUeM0dp+STdzPHXjJ7xIl8kdISmMdUVGh0CQ mFBw== X-Gm-Message-State: AOJu0YwpVRAhreV6mPtWrQzUcd2glPwxVIVTzLwIPYnwb/ntv8YLRxeg quVQVqKLA/Z08XASOkxcvu743doQqahrYprS1Hc2gdCVQLUajk86T0CZKaC7wGKmY0A= X-Gm-Gg: ASbGncuKhVkBG8PX3ZPePGKokcPRLC2GeaB6fNz3F0p0WWo1VjXz3iO057bsQ6pZTwD jSGUrNAhYkd2IK/ghDvgdAAp2lJUdXXeH2oLnQ8ABxWkPofS62kTNyNovQZztG8r7jFJUvixzmq aaudAB8RKyONvg81b1XGzt5qjI0q6Z4PeRaAe296cenSvg5Nn6QN0LelET4XREUSFP6eYbKcEXI RHJVY1ekqA+G8r5K3Bt9D6mPaRqNdpJqkb7Pvy1CMt99JaQSAOIBk2yt6jUvgYJ/PMaXJR1VwTx 9wJL0oAUx9G6TmZMwg3ijayhhWST4NgK5HhUCGYruS4ZNq8o67erY3lv2JE/fG92fkddOwA5SZH pc8Wc0SlEDDjvwVjgSxctot6Br+gpwKnCwOVFwJ78Q9ugtfpgfvjEz0KM6NU8ZWg5s39j0Qrof6 7syPbbidAN+X9+wlnNMeXH76MDrAgVe2ha3tUr X-Google-Smtp-Source: AGHT+IG8oCd8E7MdQukwNoCNtKCL1omJvfX50gQ0WZ3coDiy9qvWN29mBc8jyvwW6bIEenisWg6SBQ== X-Received: by 2002:a05:651c:882:b0:379:782:1223 with SMTP id 38308e7fff4ca-37a023cdbacmr9271251fa.22.1761747479393; Wed, 29 Oct 2025 07:17:59 -0700 (PDT) From: "Edgar E. Iglesias" To: qemu-devel@nongnu.org, "Edgar E. Iglesias" Cc: richard.henderson@linaro.org, edgar.iglesias@amd.com, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL v1 2/3] target/microblaze: div: Break out raise_divzero() Date: Wed, 29 Oct 2025 15:17:48 +0100 Message-ID: <20251029141749.1274729-3-edgar.iglesias@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251029141749.1274729-1-edgar.iglesias@gmail.com> References: <20251029141749.1274729-1-edgar.iglesias@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::236; envelope-from=edgar.iglesias@gmail.com; helo=mail-lj1-x236.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1761747592650158500 From: "Edgar E. Iglesias" Break out raise_divzero() and take the opportunity to rename and reorder function args to better match with spec and pseudo code. No functional change. Signed-off-by: Edgar E. Iglesias Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/microblaze/op_helper.c | 38 +++++++++++++++++------------------ target/microblaze/translate.c | 12 ++--------- 2 files changed, 20 insertions(+), 30 deletions(-) diff --git a/target/microblaze/op_helper.c b/target/microblaze/op_helper.c index 886224df3c..d3f688e375 100644 --- a/target/microblaze/op_helper.c +++ b/target/microblaze/op_helper.c @@ -69,38 +69,36 @@ void helper_raise_exception(CPUMBState *env, uint32_t i= ndex) cpu_loop_exit(cs); } =20 -static bool check_divz(CPUMBState *env, uint32_t b, uintptr_t ra) +/* Raises ESR_EC_DIVZERO if exceptions are enabled. */ +static void raise_divzero(CPUMBState *env, uint32_t esr, uintptr_t unwind_= pc) { - if (unlikely(b =3D=3D 0)) { - env->msr |=3D MSR_DZ; - - if ((env->msr & MSR_EE) && - env_archcpu(env)->cfg.div_zero_exception) { - CPUState *cs =3D env_cpu(env); - - env->esr =3D ESR_EC_DIVZERO; - cs->exception_index =3D EXCP_HW_EXCP; - cpu_loop_exit_restore(cs, ra); - } - return false; + env->msr |=3D MSR_DZ; + + if ((env->msr & MSR_EE) && env_archcpu(env)->cfg.div_zero_exception) { + CPUState *cs =3D env_cpu(env); + + env->esr =3D esr; + cs->exception_index =3D EXCP_HW_EXCP; + cpu_loop_exit_restore(cs, unwind_pc); } - return true; } =20 -uint32_t helper_divs(CPUMBState *env, uint32_t a, uint32_t b) +uint32_t helper_divs(CPUMBState *env, uint32_t ra, uint32_t rb) { - if (!check_divz(env, b, GETPC())) { + if (!ra) { + raise_divzero(env, ESR_EC_DIVZERO, GETPC()); return 0; } - return (int32_t)a / (int32_t)b; + return (int32_t)rb / (int32_t)ra; } =20 -uint32_t helper_divu(CPUMBState *env, uint32_t a, uint32_t b) +uint32_t helper_divu(CPUMBState *env, uint32_t ra, uint32_t rb) { - if (!check_divz(env, b, GETPC())) { + if (!ra) { + raise_divzero(env, ESR_EC_DIVZERO, GETPC()); return 0; } - return a / b; + return rb / ra; } =20 /* raise FPU exception. */ diff --git a/target/microblaze/translate.c b/target/microblaze/translate.c index 6442a250c5..fefe5cb552 100644 --- a/target/microblaze/translate.c +++ b/target/microblaze/translate.c @@ -450,16 +450,8 @@ DO_TYPEA0_CFG(flt, use_fpu >=3D 2, true, gen_flt) DO_TYPEA0_CFG(fint, use_fpu >=3D 2, true, gen_fint) DO_TYPEA0_CFG(fsqrt, use_fpu >=3D 2, true, gen_fsqrt) =20 -/* Does not use ENV_WRAPPER3, because arguments are swapped as well. */ -static void gen_idiv(TCGv_i32 out, TCGv_i32 ina, TCGv_i32 inb) -{ - gen_helper_divs(out, tcg_env, inb, ina); -} - -static void gen_idivu(TCGv_i32 out, TCGv_i32 ina, TCGv_i32 inb) -{ - gen_helper_divu(out, tcg_env, inb, ina); -} +ENV_WRAPPER3(gen_idiv, gen_helper_divs) +ENV_WRAPPER3(gen_idivu, gen_helper_divu) =20 DO_TYPEA_CFG(idiv, use_div, true, gen_idiv) DO_TYPEA_CFG(idivu, use_div, true, gen_idivu) --=20 2.43.0 From nobody Fri Nov 14 19:45:40 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1761747590; cv=none; d=zohomail.com; s=zohoarc; b=XPNBUM0RxLFaxAiwiFnQkWzda9TY/9vgbJMuKdsA8KKckwEp4lwZrT4tKHL5feN/FT5cPcZvc1ONJpX7m1HhQW/oHjkVIrJ3w9CPG0sQkiUcnIhBihsA2evBEchdG0Sl4eGHOUusp91QrB96IcS+I8oNfZe/gd79dfV+gs5sKOM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761747590; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=poUkJzrIRnT1qAE62jh+3b2s1+llTl5d/4CRcHNKOhA=; b=XxRvpLlXN48RtZc9G9BZFXOFTVAGKSeSDJQ3B/5+cF+gfx7Ag832jnwV+refD859/ye5DrXNH11AZxa4eRfW74c/7lE1UpWYfhPrKucS8r3iJyLtVo8Ez9gERNlLsr15748g7XXTXgUpGUqbtT2P6IoPIbsf5wW0bU8Cm0A5MOo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1761747590856545.1194586829646; Wed, 29 Oct 2025 07:19:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vE70W-00033t-4W; Wed, 29 Oct 2025 10:18:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vE70E-00031R-1E for qemu-devel@nongnu.org; Wed, 29 Oct 2025 10:18:24 -0400 Received: from mail-lj1-x22a.google.com ([2a00:1450:4864:20::22a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vE702-0007Wk-Fy for qemu-devel@nongnu.org; Wed, 29 Oct 2025 10:18:14 -0400 Received: by mail-lj1-x22a.google.com with SMTP id 38308e7fff4ca-378d710caedso79876021fa.3 for ; Wed, 29 Oct 2025 07:18:04 -0700 (PDT) Received: from gmail.com (213-67-3-247-no600.tbcn.telia.com. [213.67.3.247]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-378ee0e5239sm35112611fa.53.2025.10.29.07.18.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Oct 2025 07:18:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1761747482; x=1762352282; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=poUkJzrIRnT1qAE62jh+3b2s1+llTl5d/4CRcHNKOhA=; b=lw5KxvALJl1Ii3ttu+bfGoim/EXbjFwzGgDJM4svgUvfmmKI622t7SyVZvJK3frv1T 5vPLy3kjoi4bGiEl5XB1JQltJvgHFj4ojUGwEG4yKXG0yOs5XHDHns+gH9xi6hTV1Uy9 5WBjQobTIfgK6cI9uOGszBu10Q6LQBls7CltgDndVKoZmkVKsI5BIovhY16FA/snwOLI wuVOEB615avHH8vjItuJLKuITLanaekuThNRKAd7jNQSGs7Svk49TaltT88fVVylNjd9 vTAjDKLbggGO+Mm41jdRyTOP+NVnMI89RjLUKTNomxjkbG2+xXn9+Dw8suqmODv1WEKO NHNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761747482; x=1762352282; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=poUkJzrIRnT1qAE62jh+3b2s1+llTl5d/4CRcHNKOhA=; b=kNecx5ji4VtsRP5OkQNMbilz9qcKrvTPiPRPN0+dnlmp6Ab7PGdcX+BFKoiacrrHpV EV+p14qa2xrFckckcDbSD+0M9XVE7EwQO1WL1QGbecg3GYQ4JIY0Iw8csgUYD+mWjnvn qzRN+XiwBQ6frMda0sSxkcz1O60XpBv9lHpJ34/seKP100U81oHL4YBpWPLu9n0yJ67F a9Jpwmtt/AjI3dt2nN074Mdv2IUMfaJyHmKewAy9SvuN90XHXKFfe0q+gAwOrQlstvAc 7LKZDX+eJkfo7HNqk1rKhbks/sxZjycPocZl3YGrJRTzNjRcJbSkFyQqiRjGG9EGmHzm 9mgA== X-Gm-Message-State: AOJu0YxyoK/rfG9DeLBljBb4hetYdM9IlnF+CktqmiRV9fBIBCwQIQYM HmW+9zREmOlE+qT2dptT7/CCWcz972T2ZSvmCIhVk/aPcFFuD4KA2tySp8MTyHyMJiI= X-Gm-Gg: ASbGncu2M4+9wBYV8um2sO/NmJmZwuwpoPpF+oeqzkB6t5wmjmcvbKzbNKb6YIxqgPg WKM+smUlSXUrCU6J7x3ggvC2JMLssBcC3QbyZhzxYW4JqsubqPk9iwBg4Ipnx5S/EKVT/fgd6d3 HL3vKnJAPok+2wNygBEmSwca9d/ZEg8v1FFeJ3jl5ZN0h+UDFbc/jQoLS7xXmbnIpMvd9IeTec5 q4wUpn4Gox/sYvblj3AARl6XX6T9B+YumO7GyjjsQ8lYKwXIcBCZr1tF4GV5/wn4cwCA9HePx5r zjd+109NMEIx8tJBjSwE6igAaNRy2/lC6Q+qqstrE8EaoRCfD7M7bQkUCxTPIr0XdD+YJLw8FpC yarg77h3sqEBrriXF0bcF7mfojyDqdS3LDXAR1Hgb/fYQ1nBOSSZKaI/YR4xfbBH9oXKWJF4eco SIy5HOhNmRq/RCdmQh3dpFjT4gm001c/Tmd2jYupIAJlfP01w= X-Google-Smtp-Source: AGHT+IGjQuKOriJDB2PpQsVZyQTy6Jb8FsvFirJckFgjTp07BXMdiOPC0Pj/93QkIynxp7iPfPN1Ng== X-Received: by 2002:a2e:bcc7:0:b0:37a:57c:adde with SMTP id 38308e7fff4ca-37a057caf49mr9578741fa.48.1761747481377; Wed, 29 Oct 2025 07:18:01 -0700 (PDT) From: "Edgar E. Iglesias" To: qemu-devel@nongnu.org, "Edgar E. Iglesias" Cc: richard.henderson@linaro.org, edgar.iglesias@amd.com Subject: [PULL v1 3/3] target/microblaze: Handle signed division overflows Date: Wed, 29 Oct 2025 15:17:49 +0100 Message-ID: <20251029141749.1274729-4-edgar.iglesias@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251029141749.1274729-1-edgar.iglesias@gmail.com> References: <20251029141749.1274729-1-edgar.iglesias@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::22a; envelope-from=edgar.iglesias@gmail.com; helo=mail-lj1-x22a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, T_SPF_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1761747592648154100 Content-Type: text/plain; charset="utf-8" From: "Edgar E. Iglesias" Handle signed division overflows as specified in UG984: https://docs.amd.com/r/en-US/ug984-vivado-microblaze-ref/idiv Signed-off-by: Edgar E. Iglesias Reviewed-by: Richard Henderson --- target/microblaze/cpu.h | 1 + target/microblaze/op_helper.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/target/microblaze/cpu.h b/target/microblaze/cpu.h index 14b107876a..d26b933b6d 100644 --- a/target/microblaze/cpu.h +++ b/target/microblaze/cpu.h @@ -87,6 +87,7 @@ typedef struct CPUArchState CPUMBState; #define ESR_ESS_FSL_OFFSET 5 =20 #define ESR_ESS_MASK (0x7f << 5) +#define ESR_ESS_DEC_OF (1 << 11) /* DEC: 0=3DDBZ, 1=3DOF */ =20 #define ESR_EC_FSL 0 #define ESR_EC_UNALIGNED_DATA 1 diff --git a/target/microblaze/op_helper.c b/target/microblaze/op_helper.c index d3f688e375..31da2c7c3a 100644 --- a/target/microblaze/op_helper.c +++ b/target/microblaze/op_helper.c @@ -89,6 +89,21 @@ uint32_t helper_divs(CPUMBState *env, uint32_t ra, uint3= 2_t rb) raise_divzero(env, ESR_EC_DIVZERO, GETPC()); return 0; } + + /* + * Check for division overflows. + * + * Spec: https://docs.amd.com/r/en-US/ug984-vivado-microblaze-ref/idiv + * UG984, Chapter 5 MicroBlaze Instruction Set Architecture, idiv. + * + * If the U bit is clear, the value of rA is -1, and the value of rB is + * -2147483648 (divide overflow), the DZO bit in MSR will be set and + * the value in rD will be -2147483648, unless an exception is generat= ed. + */ + if ((int32_t)ra =3D=3D -1 && (int32_t)rb =3D=3D INT32_MIN) { + raise_divzero(env, ESR_EC_DIVZERO | ESR_ESS_DEC_OF, GETPC()); + return INT32_MIN; + } return (int32_t)rb / (int32_t)ra; } =20 --=20 2.43.0