From patchwork Mon Mar 19 21:18:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Clark X-Patchwork-Id: 10295287 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 E3EA860385 for ; Mon, 19 Mar 2018 21:35:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D2868293FB for ; Mon, 19 Mar 2018 21:35:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C6A51294B1; Mon, 19 Mar 2018 21:35:28 +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 522FE293FB for ; Mon, 19 Mar 2018 21:35:28 +0000 (UTC) Received: from localhost ([::1]:44072 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ey2RD-0006qz-Jf for patchwork-qemu-devel@patchwork.kernel.org; Mon, 19 Mar 2018 17:35:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33361) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ey2CH-0001Um-Dj for qemu-devel@nongnu.org; Mon, 19 Mar 2018 17:20:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ey2CD-0002in-6m for qemu-devel@nongnu.org; Mon, 19 Mar 2018 17:20:01 -0400 Received: from mail-pg0-x243.google.com ([2607:f8b0:400e:c05::243]:43728) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ey2CD-0002iR-0e for qemu-devel@nongnu.org; Mon, 19 Mar 2018 17:19:57 -0400 Received: by mail-pg0-x243.google.com with SMTP id i9so1324506pgq.10 for ; Mon, 19 Mar 2018 14:19:56 -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=UA76l2jpaMaH69Y9df7gfWBFW64d59OIaBqkFvjxH8Di4oVEDP14pC/lBgxJvaloBc MZnFTzWugKswEDPKG3VSEuXZJ0gurFE2Ijjyb1ciIRNC051mPVKWd7Zxli38RW1qhoPY eSEFuk69Kxfq6dm1OCMfFdQC8VZVQKiEYJAwCEgaLIAGKtcAuyZfqrFHioiMfl9quX99 5Ghceb161+Jz91iTw/cU8muNLafyTq4o0UM8JJH0GrF3zg6cABn1gbFaWavSrnPtu1KZ jlXmJ6PmPmjO7priOpuQze9kYbAKuT4QmOMUjcPr6C0bH+Mo4Y5oJ1zNq3k9mtPb1M8z NJEA== 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=XIJ+H48GVTWWt0GZFQzgrsRCfFBKgtpTrv+EpcSxd6DZ1N1AHkSrK+gOy1hK1SLHmE qc/AoyFv40M9h2nnvBsksXrc+lsJwZvcZ/cU7MIh+yNB42kX3ZdCKaufUpH0qEddT8Q8 yaQ7Ei0N6sjQFeogdhd0+FPqsz+h5lCLifP2zyD7WlXEGfqJWASC4HF13SPRuevBIQSD /V+cGoS4V0C9/FgOEMVgWF83z+4Ypv3biHHWeTIABeCd/MqKiEsU11bomLAwXmPU8pTQ 6eBVI9L+yebPoHHcw+QKU2TIOrJBrjskP8xbewFc0z/BvW46wuPsZwOv6mmKOAjE3N4w 1m2g== X-Gm-Message-State: AElRT7H9U9aPPuXd3YzD/8uSAbu0KPvhrSn//sjVlL4M6O1Q+1RY9XV3 Oh3FBeU3Wq8oxTeGt9X+7XkNVQb8Pa0= X-Google-Smtp-Source: AG47ELso4kCxbNT9VZhp2P4W0lrADCMHYaGA5XCn6WPr1Q4vZ7D09+xPSs1RisaWKn+obleNNCDhxQ== X-Received: by 10.99.123.80 with SMTP id k16mr10250465pgn.173.1521494396100; Mon, 19 Mar 2018 14:19:56 -0700 (PDT) Received: from monty.com ([12.206.222.5]) by smtp.gmail.com with ESMTPSA id i127sm120500pfc.136.2018.03.19.14.19.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 19 Mar 2018 14:19:55 -0700 (PDT) From: Michael Clark To: qemu-devel@nongnu.org Date: Mon, 19 Mar 2018 14:18:40 -0700 Message-Id: <1521494329-19546-18-git-send-email-mjc@sifive.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1521494329-19546-1-git-send-email-mjc@sifive.com> References: <1521494329-19546-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::243 Subject: [Qemu-devel] [PATCH v4 17/26] 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 {