From patchwork Fri Mar 9 04:12:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Clark X-Patchwork-Id: 10269661 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 017EC60236 for ; Fri, 9 Mar 2018 04:27:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DE4A529C70 for ; Fri, 9 Mar 2018 04:27:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D327529CB5; Fri, 9 Mar 2018 04:27:24 +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 7BFCB29C70 for ; Fri, 9 Mar 2018 04:27:24 +0000 (UTC) Received: from localhost ([::1]:43162 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eu9cp-0005aa-O5 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 08 Mar 2018 23:27:23 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55870) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eu9Qs-0004Sn-6P for qemu-devel@nongnu.org; Thu, 08 Mar 2018 23:15:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eu9Qr-00076n-CS for qemu-devel@nongnu.org; Thu, 08 Mar 2018 23:15:02 -0500 Received: from mail-pl0-x244.google.com ([2607:f8b0:400e:c01::244]:33551) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eu9Qr-00076Y-6F for qemu-devel@nongnu.org; Thu, 08 Mar 2018 23:15:01 -0500 Received: by mail-pl0-x244.google.com with SMTP id c11-v6so4623402plo.0 for ; Thu, 08 Mar 2018 20:15:01 -0800 (PST) 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=lwd3Hew1zQZhyL60M7r/jzQVZFLudaqvDjD5W/bDx/gOBGSKDg6TBBtTSdzU2SfA46 fgbwR1wZB3jnQyQN6pZ6FypKhrFu+CuALZ/URvbwnICTFKO4md3q1UBI472F0Fl4Q340 YIBAxDTWY+DluvOl44ywaOUOxO7GgodQQDqNFMuSOGL6KgTOtDIQwUwtWRNpO4LT/4zG 8ydnzb9K7vDRTLOzVMkl0oqYfLEgUJSjk5pqudZlny225xXH4U5GdOjSyGxg/5z/SDXQ Fn8A32jtefuAwM/e/edZDneSRC+DbVPVWYg1ImcCpHwt2mhDK/J65Ugvz0fH/rEjSjqK hc/A== 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=GKZMvINw/A+jO3PknPocxvuL7R0hjZC64ZgpXAogU3D5DnPbu7mi90TgbP9TIPp30I 5V/K+kl1zaN5LgmMbuel8twvVPKnq8cKZ59Wh11RjQbiEemrL55cNzCi4WWQd5YhvF0+ 0uHmr7Du2d1eKtVUO28mdlcoRMHw7C61JaZNwK7mLs+u1KY/aoq2BtdsgcRsyVdfYM/P j4x1o+9DsBBy8vhKrsCEFh26pEIPwgqu+fq8rE0obNxOGO6CYS7xkuYwpNiZqwo5b8kh N5HVOun1xzQ/JHTOSoKCiTzYMK/+o89SsQvd7u4l89iGPH7hxRGz/YaeQRrQ1RZARtl1 doYQ== X-Gm-Message-State: APf1xPDjsQS4gYoGr4mchBTJ/unQsQMoISbPdZ92AxYoPV7nuta735T7 nkqhtjncwcMQ0p9K7AbjYQ2grIjlGdE= X-Google-Smtp-Source: AG47ELs8RRCgKnUYaW4dijscSGPmC9GuAERIU9HY+aGNhqOqIUq48gYozIC9Z0Gc7rsF0suikXjjnA== X-Received: by 2002:a17:902:780c:: with SMTP id p12-v6mr26812900pll.161.1520568900345; Thu, 08 Mar 2018 20:15:00 -0800 (PST) Received: from localhost.localdomain (125-237-39-90-fibre.bb.spark.co.nz. [125.237.39.90]) by smtp.gmail.com with ESMTPSA id h15sm334141pfi.56.2018.03.08.20.14.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 08 Mar 2018 20:14:59 -0800 (PST) From: Michael Clark To: qemu-devel@nongnu.org Date: Fri, 9 Mar 2018 17:12:39 +1300 Message-Id: <1520568765-58189-18-git-send-email-mjc@sifive.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1520568765-58189-1-git-send-email-mjc@sifive.com> References: <1520568765-58189-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:c01::244 Subject: [Qemu-devel] [PATCH v2 17/23] 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: Bastian Koppelmann , Michael Clark , Palmer Dabbelt , Sagar Karandikar 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 {