From patchwork Wed Mar 21 20:46:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Clark X-Patchwork-Id: 10300393 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 5590F60386 for ; Wed, 21 Mar 2018 20:58:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3D89029791 for ; Wed, 21 Mar 2018 20:58:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 325EC297B5; Wed, 21 Mar 2018 20:58:08 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, 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 9E78729791 for ; Wed, 21 Mar 2018 20:58:07 +0000 (UTC) Received: from localhost ([::1]:57400 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eykoA-0003N1-DF for patchwork-qemu-devel@patchwork.kernel.org; Wed, 21 Mar 2018 16:58:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53153) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eykeU-000277-OF for qemu-devel@nongnu.org; Wed, 21 Mar 2018 16:48:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eykeT-00029X-Q5 for qemu-devel@nongnu.org; Wed, 21 Mar 2018 16:48:06 -0400 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]:43343) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eykeT-00029O-Jk for qemu-devel@nongnu.org; Wed, 21 Mar 2018 16:48:05 -0400 Received: by mail-pf0-x241.google.com with SMTP id j2so2456463pff.10 for ; Wed, 21 Mar 2018 13:48:05 -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=skhNLehqLx7INkCfB7WkgTioVOYa2VI4KQLj/TiEtYM=; b=I2yeoGsa7NB5QGFvLGbnXGaA9uIR2h2g+0PBFfCA+crYjKkwbdOcVnFmbc7VEFHMST 1fCR8rVe1W645lxPbO1hy8EMV35c0jBh39qAuUtxv+hjq8f3i3jG0KhKlx8GoiINcffh SlNTidG1D4L9xCB0a+xwIcUXLmddF9urhQhD/U1hFfCNXY7TxhpJUO8ns566VUVySzCS EuIYt5C2oqHk77rvA7VhAt16rJY1dpP4A+/E0p/SPwJQr/98Q9PtsEOOwiocaJ0oBzPm Xvkwn3J+lBEzcfQWN9q/c5SW9FKwgBhZneEHry9TJuMk2NwIi0dsgAxrcHq8tmYHalqV Gu/g== 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=skhNLehqLx7INkCfB7WkgTioVOYa2VI4KQLj/TiEtYM=; b=JZ37yBT3ZRdN7pPniSsQg5CEiGw0QAVvqCFyngIgY1x6DBk4FMnhQ0lrk/T2raN9fy ixNOiMjzRebuumajHngUpxAyVUnZ3/TrYz1jIg6UCqKAcqSY1gEgJaNUAvHJ6dVh6pYH ebrmm+ZAlkcNmlboUSngZkmCtYaSi7or5k7KmmJ9c5hjCC1ttYj/rDxM969QmmGem8tg H+8NkEbGgYbtWDiJ9m5TJYmw+/VigRSi3aTrSHeB9pyxLtyb+VHcy4m2JZZXU3QSKnNt kJJ3OypdzJec+0kx4oOEUX0efBqsLkFaeh6K6K2j8tX6NdgYEAxVhtkSgB3Mg479g70K 9i2Q== X-Gm-Message-State: AElRT7EElx2EDBWSDiiS+FWPbDw+fTmf9Ep+fZyGtI1MdYOMjkoOYEfj nolVdGRy9mHi2MEKGr26aJZKRoypuA0= X-Google-Smtp-Source: AG47ELtKS5v6UZej69pjvKmUzkUeH4jNMPi8H142sbalKsWmwFWalEG6oTo0EbRAZDB4LuAj8HMP/A== X-Received: by 10.99.110.133 with SMTP id j127mr16111080pgc.79.1521665284537; Wed, 21 Mar 2018 13:48:04 -0700 (PDT) Received: from monty.com ([12.206.222.5]) by smtp.gmail.com with ESMTPSA id w10sm8244499pgr.57.2018.03.21.13.48.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 21 Mar 2018 13:48:03 -0700 (PDT) From: Michael Clark To: qemu-devel@nongnu.org Date: Wed, 21 Mar 2018 13:46:52 -0700 Message-Id: <1521665220-3869-17-git-send-email-mjc@sifive.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1521665220-3869-1-git-send-email-mjc@sifive.com> References: <1521665220-3869-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:c00::241 Subject: [Qemu-devel] [PULL 16/24] RISC-V: Hardwire satp to 0 for no-mmu case 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: patches@groups.riscv.org, Michael Clark , Palmer Dabbelt , Sagar Karandikar , Bastian Koppelmann Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP satp is WARL so it should not trap on illegal writes, rather it can be hardwired to zero and silently ignore illegal writes. It seems the RISC-V WARL behaviour is preferred to having to trap overhead versus simply reading back the value and checking if the write took (saves hundreds of cycles and more complex trap handling code). Cc: Sagar Karandikar Cc: Bastian Koppelmann Signed-off-by: Michael Clark Signed-off-by: Palmer Dabbelt --- target/riscv/op_helper.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/target/riscv/op_helper.c b/target/riscv/op_helper.c index e34715d..dd3e417 100644 --- a/target/riscv/op_helper.c +++ b/target/riscv/op_helper.c @@ -242,7 +242,7 @@ void csr_write_helper(CPURISCVState *env, target_ulong val_to_write, } case CSR_SATP: /* CSR_SPTBR */ { if (!riscv_feature(env, RISCV_FEATURE_MMU)) { - goto do_illegal; + break; } if (env->priv_ver <= PRIV_VERSION_1_09_1 && (val_to_write ^ env->sptbr)) { @@ -452,7 +452,10 @@ target_ulong csr_read_helper(CPURISCVState *env, target_ulong csrno) return env->scounteren; case CSR_SCAUSE: return env->scause; - case CSR_SPTBR: + case CSR_SATP: /* CSR_SPTBR */ + if (!riscv_feature(env, RISCV_FEATURE_MMU)) { + return 0; + } if (env->priv_ver >= PRIV_VERSION_1_10_0) { return env->satp; } else {