From patchwork Wed Apr 25 23:45:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Clark X-Patchwork-Id: 10364427 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 8BD4E6038F for ; Thu, 26 Apr 2018 00:11:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7CE1829026 for ; Thu, 26 Apr 2018 00:11:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7AE922905A; Thu, 26 Apr 2018 00:11:04 +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 79BAA29026 for ; Thu, 26 Apr 2018 00:11:03 +0000 (UTC) Received: from localhost ([::1]:39682 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fBUV4-0007nH-Fv for patchwork-qemu-devel@patchwork.kernel.org; Wed, 25 Apr 2018 20:11:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46676) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fBU93-0005Gv-Ha for qemu-devel@nongnu.org; Wed, 25 Apr 2018 19:48:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fBU92-0005GH-Oy for qemu-devel@nongnu.org; Wed, 25 Apr 2018 19:48:17 -0400 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]:45581) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fBU92-0005Fs-I1 for qemu-devel@nongnu.org; Wed, 25 Apr 2018 19:48:16 -0400 Received: by mail-pf0-x241.google.com with SMTP id l27so16584514pfk.12 for ; Wed, 25 Apr 2018 16:48:16 -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=FbEWnj3VkuBhlKLy3tEECqyltMHbHHGq63MjUGIgriE=; b=MPA/3fwxIioMELH7r2ndwKGOecBWAvlbzfhpVRPk3wVBIfOx6oGapuCUB8kZjrrSBr drwyxttNFmqX12ITFVqJjrphMdDRpCxDwazHe/TZV/ZJKzeTwu/MdIvB1h9W23FKH7nv i+WWfXPrKlm9vI4SDDp1nlTPvDMHwOlie+Qk+Lb8Ah6z/g09spds0+zMVWjWbnBWQTTm JDHoSBSJx3UfyFbCoyj0jJ+dhRDlU8/4JLj2WhgEXh0GdEsovoXESN3PcbME4h+J80tS UU6ED60+VmSktyM1QrgqngKTa70emSK30LwXigMIpaLfzKNQzfTkZpM5bCWlupxAa3Na 3P2w== 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=FbEWnj3VkuBhlKLy3tEECqyltMHbHHGq63MjUGIgriE=; b=KNIKrpAOTQgtMnnvBjF2+zn9s4oZb2/Xb9dCzTiQ2ah3TRTN9AynHBA3bDh0ApR1KS 85v7YtXQELeZ19Rign2mEm0/WyHRf68THUl6ZOZ4/wsHTn0ccK24tRSCAnFO67onUYkw 1+6yJXLDUuynnA00mRNeR/nr2PVUn8dnZAysW56LHDZhAWGbd5oJEdaC+d32Az4eThc7 UHav3ZE+6SWnrWTTUXXV0A9AEmKO9o0gxaDgcvGd+Xu74GiVtOA/5S6sjMGJsfw7KhaB jJsPfkHQj8ZI7RUm2WlENPEUSqnPH+UhTz4yzTW0sgMo/iNJuQ9rfxGZoalmfmQ47rUC DeLw== X-Gm-Message-State: ALQs6tDkLeqAYTq+Pcg3Vtd1N0PBHdWWq5y0NwuJZ88V8IK0ZehtFE8I QubusvoEolgr1OJQcELyXrxM65Uvm88= X-Google-Smtp-Source: AIpwx48ZuSVrprev/CuE/zjHMTqgpmmfIgrA6A2qowN0A1YB9+30BZ2uOGQDVvEyabkeW/K8tHgYBQ== X-Received: by 10.99.4.69 with SMTP id 66mr25800075pge.323.1524700095581; Wed, 25 Apr 2018 16:48:15 -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.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 25 Apr 2018 16:48:15 -0700 (PDT) From: Michael Clark To: qemu-devel@nongnu.org Date: Thu, 26 Apr 2018 11:45:22 +1200 Message-Id: <1524699938-6764-20-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:c00::241 Subject: [Qemu-devel] [PATCH v8 19/35] RISC-V: Allow S-mode mxr access when priv ISA >= v1.10 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 The mstatus.MXR alias in sstatus should only be writable by S-mode if the privileged ISA version >= v1.10. Also MXR was masked in sstatus CSR read but not sstatus CSR writes. Now we correctly mask sstatus.mxr in both read and write. 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 b81b9b6..88c263a 100644 --- a/target/riscv/op_helper.c +++ b/target/riscv/op_helper.c @@ -236,7 +236,10 @@ void csr_write_helper(CPURISCVState *env, target_ulong val_to_write, target_ulong ms = env->mstatus; target_ulong mask = SSTATUS_SIE | SSTATUS_SPIE | SSTATUS_UIE | SSTATUS_UPIE | SSTATUS_SPP | SSTATUS_FS | SSTATUS_XS - | SSTATUS_SUM | SSTATUS_MXR | SSTATUS_SD; + | SSTATUS_SUM | SSTATUS_SD; + if (env->priv_ver >= PRIV_VERSION_1_10_0) { + mask |= SSTATUS_MXR; + } ms = (ms & ~mask) | (val_to_write & mask); csr_write_helper(env, ms, CSR_MSTATUS); break; @@ -439,7 +442,7 @@ target_ulong csr_read_helper(CPURISCVState *env, target_ulong csrno) case CSR_SSTATUS: { target_ulong mask = SSTATUS_SIE | SSTATUS_SPIE | SSTATUS_UIE | SSTATUS_UPIE | SSTATUS_SPP | SSTATUS_FS | SSTATUS_XS - | SSTATUS_SUM | SSTATUS_SD; + | SSTATUS_SUM | SSTATUS_SD; if (env->priv_ver >= PRIV_VERSION_1_10_0) { mask |= SSTATUS_MXR; }