From nobody Mon Feb 9 07:55:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1587405279; cv=none; d=zohomail.com; s=zohoarc; b=fUNowXnskSRkUQz8MiG4iXgxpQkSWyP1JHUI1u7P6URmJZ3UP1idfnYbOZTezkNoJ3TT8QDnCCvAqp/kdtWkuot6uP8xyyGvtNrXhXraNHiDdHftXp/FlvWHHFnjzAVQwlKW4MGJs73LH0HSpCS7Ac2fwyTB6Q8fZAee54Ef7tI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587405279; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=lIa+NYujIRdCQSAiwPsqbHt3vidArGlASBdrTdsfVAk=; b=aTNAhMFWsPzAvAjStF5oL75coK0nVPU5XK1GpuEYBb06HUaKr4nWRC4s4GW0axkWlDd6RY6uhczmKH/LM+I9I06+St1rJoypDh3bZkA8cZ5XOSqH4x8Y3JxiEj3ZmOekGAL8Q8RjAYcnuQGEtED6KCX7dBWEW5JUu5VraFI4Plg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1587405279416724.9085644350091; Mon, 20 Apr 2020 10:54:39 -0700 (PDT) Received: from localhost ([::1]:39974 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jQacw-00009R-4H for importer@patchew.org; Mon, 20 Apr 2020 13:54:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36548 helo=eggs1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jQabK-0006ej-OE for qemu-devel@nongnu.org; Mon, 20 Apr 2020 13:52:59 -0400 Received: from Debian-exim by eggs1p.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jQabK-0003zN-6i for qemu-devel@nongnu.org; Mon, 20 Apr 2020 13:52:58 -0400 Received: from mail-lf1-x141.google.com ([2a00:1450:4864:20::141]:33416) by eggs1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jQabJ-0003wT-QL for qemu-devel@nongnu.org; Mon, 20 Apr 2020 13:52:57 -0400 Received: by mail-lf1-x141.google.com with SMTP id h6so8762420lfc.0 for ; Mon, 20 Apr 2020 10:52:57 -0700 (PDT) Received: from gmail.com (81-231-232-130-no39.tbcn.telia.com. [81.231.232.130]) by smtp.gmail.com with ESMTPSA id h7sm120349ljg.37.2020.04.20.10.52.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Apr 2020 10:52:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lIa+NYujIRdCQSAiwPsqbHt3vidArGlASBdrTdsfVAk=; b=fnClG/dBahvmawmXN38NLbAduafiM52pQLQSpfDtq6eYnnI3DpgxarO0OflMYUhTo9 3cyQ1H6cV7HXyikHcNo/HlLPlnDAbBXs7NFhbJZPAEW2Go5nvzrg7mrWWU85KfAtswbP J3/xqwXN1/v4SwcIE01pw40XhmzpMeYOwMgp+HAx9fF1OjodHuYW/4LxlybC4Hz++g20 MG6A3Pe8zEFlKVGE3Pd+hK0em3GzqEqdMOX3J/G0DgGf3jSK9E38gRXyGGyBJNW9XP0l AoNvzvsmy/3fRADFwaXO+CKRmYExKPze1xK6tvkvUFbJ5W7Mr9Y1BD+aJfi/7uYJKRyF 8xVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lIa+NYujIRdCQSAiwPsqbHt3vidArGlASBdrTdsfVAk=; b=fZdJm/XYQhs1C+HiUmslJ6CcT//Pr+ILE4lV8Bk71lfLl0HUB/rI9eFsR+IZhe4VTF si78Jp1P3EQsk6abHD7FbAgEo6V+VU5RjOgEAbIm/3tso/R8o8Ji+kL05697EvDLEM2/ LjAb8yiIdr5Y8a1N1l6Ob6GckfO/nNPY08Y5oOQkYi4hPh2FoUcgpkwjY5GTZGfpz4W3 cjbb9YmWm5LDyiW78lNeTFbf6IWWqnjue2Ik4Ij7cz5C90+16uK9BsDRaxwpMXp55dMB Ipl6D2h3GdUwdazw96/PeYwQGn3g9M/RuAXAiMc+GiP0NYPn7wzeOsCT51x1ZnkQzfqP 1s5A== X-Gm-Message-State: AGi0PuayF5ZXD7EXcO3gT02CbqJI+smkwHiJVb5qWsz+Ty5mYe7CRj3i C3WTOsH6+FlnqBVIi/mtreodPSQyaAs= X-Google-Smtp-Source: APiQypLXoGl8Vd/b0aR2Ub1Us6PB/1Bm+gPCDVaBW+Z/6RvWrT/MW6YtC0d3ZwFBhskr1dSEcf0plw== X-Received: by 2002:ac2:4d10:: with SMTP id r16mr11241063lfi.180.1587405176065; Mon, 20 Apr 2020 10:52:56 -0700 (PDT) From: "Edgar E. Iglesias" To: qemu-devel@nongnu.org Subject: [PATCH v2 3/6] target/microblaze: Add the div-zero-exception property Date: Mon, 20 Apr 2020 19:52:47 +0200 Message-Id: <20200420175250.25777-4-edgar.iglesias@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200420175250.25777-1-edgar.iglesias@gmail.com> References: <20200420175250.25777-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::141; envelope-from=edgar.iglesias@gmail.com; helo=mail-lf1-x141.google.com X-detected-operating-system: by eggs1p.gnu.org: Error: [-] PROGRAM ABORT : Malformed IPv6 address (bad octet value). Location : parse_addr6(), p0f-client.c:67 X-Received-From: 2a00:1450:4864:20::141 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: figlesia@xilinx.com, peter.maydell@linaro.org, sstabellini@kernel.org, edgar.iglesias@xilinx.com, sai.pavan.boddu@xilinx.com, frasse.iglesias@gmail.com, alistair@alistair23.me, richard.henderson@linaro.org, frederic.konrad@adacore.com, philmd@redhat.com, luc.michel@greensocs.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: "Edgar E. Iglesias" Add the div-zero-exception property to control if the core traps divizions by zero. Signed-off-by: Edgar E. Iglesias Reviewed-by: Alistair Francis Reviewed-by: Luc Michel --- target/microblaze/cpu.c | 4 ++++ target/microblaze/cpu.h | 1 + target/microblaze/op_helper.c | 5 +++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/target/microblaze/cpu.c b/target/microblaze/cpu.c index 36c20d9724..53e80f4e5d 100644 --- a/target/microblaze/cpu.c +++ b/target/microblaze/cpu.c @@ -207,6 +207,8 @@ static void mb_cpu_realizefn(DeviceState *dev, Error **= errp) PVR2_DOPB_BUS_EXC_MASK : = 0) | (cpu->cfg.iopb_bus_exception ? PVR2_IOPB_BUS_EXC_MASK : = 0) | + (cpu->cfg.div_zero_exception ? + PVR2_DIV_ZERO_EXC_MASK : = 0) | (cpu->cfg.illegal_opcode_exception ? PVR2_ILL_OPCODE_EXC_MASK := 0) | (cpu->cfg.opcode_0_illegal ? @@ -280,6 +282,8 @@ static Property mb_properties[] =3D { cfg.iopb_bus_exception, false), DEFINE_PROP_BOOL("ill-opcode-exception", MicroBlazeCPU, cfg.illegal_opcode_exception, false), + DEFINE_PROP_BOOL("div-zero-exception", MicroBlazeCPU, + cfg.div_zero_exception, false), DEFINE_PROP_BOOL("opcode-0x0-illegal", MicroBlazeCPU, cfg.opcode_0_illegal, false), DEFINE_PROP_STRING("version", MicroBlazeCPU, cfg.version), diff --git a/target/microblaze/cpu.h b/target/microblaze/cpu.h index 71d7317a58..3c07f9b3f7 100644 --- a/target/microblaze/cpu.h +++ b/target/microblaze/cpu.h @@ -305,6 +305,7 @@ struct MicroBlazeCPU { bool iopb_bus_exception; bool illegal_opcode_exception; bool opcode_0_illegal; + bool div_zero_exception; char *version; uint8_t pvr; } cfg; diff --git a/target/microblaze/op_helper.c b/target/microblaze/op_helper.c index 18677ddfca..f3b17a95b3 100644 --- a/target/microblaze/op_helper.c +++ b/target/microblaze/op_helper.c @@ -132,11 +132,12 @@ uint32_t helper_carry(uint32_t a, uint32_t b, uint32_= t cf) =20 static inline int div_prepare(CPUMBState *env, uint32_t a, uint32_t b) { + MicroBlazeCPU *cpu =3D env_archcpu(env); + if (b =3D=3D 0) { env->sregs[SR_MSR] |=3D MSR_DZ; =20 - if ((env->sregs[SR_MSR] & MSR_EE) - && !(env->pvr.regs[2] & PVR2_DIV_ZERO_EXC_MASK)) { + if ((env->sregs[SR_MSR] & MSR_EE) && cpu->cfg.div_zero_exception) { env->sregs[SR_ESR] =3D ESR_EC_DIVZERO; helper_raise_exception(env, EXCP_HW_EXCP); } --=20 2.20.1