From patchwork Wed Apr 25 23:45:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Clark X-Patchwork-Id: 10364389 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 D9A4F60249 for ; Wed, 25 Apr 2018 23:57:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C8C5328E38 for ; Wed, 25 Apr 2018 23:57:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BD25128FC2; Wed, 25 Apr 2018 23:57:26 +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 6C0A028E38 for ; Wed, 25 Apr 2018 23:57:26 +0000 (UTC) Received: from localhost ([::1]:39600 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fBUHt-0004pY-Hh for patchwork-qemu-devel@patchwork.kernel.org; Wed, 25 Apr 2018 19:57:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46547) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fBU8o-00050R-BP for qemu-devel@nongnu.org; Wed, 25 Apr 2018 19:48:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fBU8n-000578-IJ for qemu-devel@nongnu.org; Wed, 25 Apr 2018 19:48:02 -0400 Received: from mail-pg0-x242.google.com ([2607:f8b0:400e:c05::242]:46979) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fBU8n-00056m-DF for qemu-devel@nongnu.org; Wed, 25 Apr 2018 19:48:01 -0400 Received: by mail-pg0-x242.google.com with SMTP id z4so1557260pgu.13 for ; Wed, 25 Apr 2018 16:48:01 -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=Tb/TydrMj365yJTX1yULqN8PbAgNtGNAg/0B4L01JpU=; b=nAxrUeRlinQLKfmUE7Q6kclfoPiizEhKSDc3KIFwWjFAy0zkvHr7q7V+df4CtFwumt 3zunK/M2CqYio/XgkkhKhcnMgRXZaowtXyhlBNzSJS09K/nNBhdwi+Wxdry7QTuPjC0H 9l4f9cMHz7Ja456kY+ZIud7YGdoKTGZIXj48ZifsWI5jsWqhoJDDZ8tCzQK74OEp1Pq3 3xLnuK/cSxK9WGKkZklH4SvDSakTYcUEn4JKVDvCjldVxcG/J+SO+VB+gTukxhkx0glZ JKK0A36vSNW7fBz4XhAOJJDQqWqY2NwizMQP7okPB+DR6kHx5oGkRjXhMViVvzoLUKnN fSww== 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=Tb/TydrMj365yJTX1yULqN8PbAgNtGNAg/0B4L01JpU=; b=mKfJrZzXJRf6upM/AdnzKz7wFd/juhJk5NBZ5/jM0J8wlYJor3BoIM5R/cb8Msh5M7 KP9Ax2HNsjWpwdi5sIgkSoNq0VHG7zZUAlkZ6QEetsQAFC9QFIzvnCTfk75oayvNPOLt G6YItpQw6w9TMrUap6eKJ/MCG80bWhHt5chV9XmGVdUTvkTSTVxUS6w6ajDcndNpm5A/ TzJJLdDSCWmWZqQfX47dE4QvNYOi81MabowM98wH8ckXCPXR3tSx9XhOvJae34/1roAJ XQCa+89Li3jW68cdUJyo/FjES6S1kEb8+7T1O7R3krNn//WtBVShOrSUknTRO6IiNR5Z deZQ== X-Gm-Message-State: ALQs6tAmpdfO8pMd5a45+UNT4UvTJLhJXPtUDuIl9usWf9rKkMzDxhgp mmsRapcZkjUJjQXGyFkC6C/Y0im0rm0= X-Google-Smtp-Source: AB8JxZrHNCQ0QKZlqTsHCwprsMnWK/IatpW03s0WbJNzvavbrnJgIWvjgMOyZRkdIZHueMo5XHapyg== X-Received: by 2002:a17:902:7702:: with SMTP id n2-v6mr9578226pll.385.1524700080334; Wed, 25 Apr 2018 16:48:00 -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.47.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 25 Apr 2018 16:47:59 -0700 (PDT) From: Michael Clark To: qemu-devel@nongnu.org Date: Thu, 26 Apr 2018 11:45:18 +1200 Message-Id: <1524699938-6764-16-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::242 Subject: [Qemu-devel] [PATCH v8 15/35] 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: 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 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 Cc: Palmer Dabbelt Cc: Alistair Francis Signed-off-by: Michael Clark Reviewed-by: Alistair Francis --- 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 7c6068b..101dac1 100644 --- a/target/riscv/op_helper.c +++ b/target/riscv/op_helper.c @@ -255,7 +255,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)) { @@ -465,7 +465,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 {