From patchwork Wed Apr 25 23:45:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Clark X-Patchwork-Id: 10364395 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 636266032C for ; Thu, 26 Apr 2018 00:00:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3F188290F5 for ; Thu, 26 Apr 2018 00:00:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3D23A290B2; Thu, 26 Apr 2018 00:00:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 92C1829082 for ; Thu, 26 Apr 2018 00:00:11 +0000 (UTC) Received: from localhost ([::1]:39615 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fBUKX-0007Kl-Uo for patchwork-qemu-devel@patchwork.kernel.org; Wed, 25 Apr 2018 20:00:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46646) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fBU90-0005DW-1E for qemu-devel@nongnu.org; Wed, 25 Apr 2018 19:48:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fBU8z-0005E8-52 for qemu-devel@nongnu.org; Wed, 25 Apr 2018 19:48:14 -0400 Received: from mail-pg0-x244.google.com ([2607:f8b0:400e:c05::244]:45671) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fBU8y-0005Dp-Vw for qemu-devel@nongnu.org; Wed, 25 Apr 2018 19:48:13 -0400 Received: by mail-pg0-x244.google.com with SMTP id i29so12947377pgn.12 for ; Wed, 25 Apr 2018 16:48:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6inVQnqpbDTOY8zvW/0ia53C/vDKW+Uc4mF28CPuDqA=; b=JCBDnEJFQ43mRV59ICkwXNZxsWlh+Geha+7UTErzlKTSAq9kLxr2q0j/QhPqaAd7GW jZcpxpifug9up1XGwJLFLrFWYAoLH+ROvyjpF5A71mAgspaZPUlxT2Ll8h/w/QRnmzTV 5Gh/jViwwUsuCBXv9/BtBhTtsi/RH5WFnPGSv6SBN+CvdBHrsn5LDNE/KUslD7GMjxru 8awOeKhl5cv0kmQRulOqPLpeO+ihh2g5wo9W1cyx5LSkBgD8ZZuJm7xbzD3lDtUBeFia 9q5Zo29ZRFuhzycyzWDOwo0tiKt1dyvo8wYR8VQcE1z3ltUQVo4ht21BZuz16PfitCnc S1uw== 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; bh=6inVQnqpbDTOY8zvW/0ia53C/vDKW+Uc4mF28CPuDqA=; b=mhF3sSQL+vIRSk4yIjLMLCvsVR20/MqYoWrZWYxpFqtd0SnQWLxKJGhn5CHXv+zYKB w1dt6Oz+2PRlswaTSzcTo54nMlUBibr8C8bZfcpM10AVFDmFfk+myjXXUmv37BVF7kQ5 M3VvOLvSE7VZjyTafFdPkPhTvPfj7XgO6fsRJ+y7XEQsM4wn3bCMaI4L1N109tiwVDPS kG4RLuzw+GF0rkoFQ58Un9d5UgS4OP4BYngfYxPoF717C9CvCURRIa6moWBV2I/+g4/8 x0vTpPZ8ftG40wSFWqxh3PzLxpEJ/6J8Egu+kgD2AIBqmnjRV3W34WcFsTHMwqo6ycYt gf8A== X-Gm-Message-State: ALQs6tDCS2GDxYN/29chB/ZVEjlPzG9YMH7zwABFvPk8ONHEWLRYLEow UxjluvTosKtmq4ytksYKpeymp2TxIh8= X-Google-Smtp-Source: AIpwx4/CEO3/wHc0fr2LIg+MlWkx8P0/jhG12q5yfmwuvnjR2rcVXkDvCrukRITZIFmWdtUM8QmotA== X-Received: by 2002:a17:902:6b02:: with SMTP id o2-v6mr31078624plk.6.1524700092017; Wed, 25 Apr 2018 16:48:12 -0700 (PDT) Received: from localhost.localdomain (122-58-167-38-fibre.bb.spark.co.nz. [122.58.167.38]) by smtp.gmail.com with ESMTPSA id e10sm29577549pfn.67.2018.04.25.16.48.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 25 Apr 2018 16:48:11 -0700 (PDT) From: Michael Clark To: qemu-devel@nongnu.org Date: Thu, 26 Apr 2018 11:45:21 +1200 Message-Id: <1524699938-6764-19-git-send-email-mjc@sifive.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1524699938-6764-1-git-send-email-mjc@sifive.com> References: <1524699938-6764-1-git-send-email-mjc@sifive.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::244 Subject: [Qemu-devel] [PATCH v8 18/35] RISC-V: Clear mtval/stval on exceptions without info X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sagar Karandikar , Bastian Koppelmann , Palmer Dabbelt , Michael Clark , Alistair Francis , patches@groups.riscv.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP mtval/stval must be set on all exceptions but zero is a legal value if there is no exception specific info. Placing the instruction bytes for illegal instruction exceptions in mtval/stval is an optional feature and is currently not supported by QEMU RISC-V. Cc: Sagar Karandikar Cc: Bastian Koppelmann Cc: Palmer Dabbelt Cc: Alistair Francis Signed-off-by: Michael Clark Reviewed-by: Alistair Francis --- target/riscv/helper.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/target/riscv/helper.c b/target/riscv/helper.c index 459fc97..3b57e13 100644 --- a/target/riscv/helper.c +++ b/target/riscv/helper.c @@ -492,6 +492,10 @@ void riscv_cpu_do_interrupt(CPUState *cs) ": badaddr 0x" TARGET_FMT_lx, env->mhartid, env->badaddr); } env->sbadaddr = env->badaddr; + } else { + /* otherwise we must clear sbadaddr/stval + * todo: support populating stval on illegal instructions */ + env->sbadaddr = 0; } target_ulong s = env->mstatus; @@ -513,6 +517,10 @@ void riscv_cpu_do_interrupt(CPUState *cs) ": badaddr 0x" TARGET_FMT_lx, env->mhartid, env->badaddr); } env->mbadaddr = env->badaddr; + } else { + /* otherwise we must clear mbadaddr/mtval + * todo: support populating mtval on illegal instructions */ + env->mbadaddr = 0; } target_ulong s = env->mstatus;