From patchwork Sat May 5 23:35:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Clark X-Patchwork-Id: 10382495 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 329F060318 for ; Sat, 5 May 2018 23:50:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2487C28DD4 for ; Sat, 5 May 2018 23:50:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 17EB328F79; Sat, 5 May 2018 23:50: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 AFEA528DD4 for ; Sat, 5 May 2018 23:50:03 +0000 (UTC) Received: from localhost ([::1]:40328 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fF6wE-0005p9-Vv for patchwork-qemu-devel@patchwork.kernel.org; Sat, 05 May 2018 19:50:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54561) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fF6kV-0004Vg-7v for qemu-devel@nongnu.org; Sat, 05 May 2018 19:37:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fF6kU-000489-9n for qemu-devel@nongnu.org; Sat, 05 May 2018 19:37:55 -0400 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:34193) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fF6kU-00047h-3l for qemu-devel@nongnu.org; Sat, 05 May 2018 19:37:54 -0400 Received: by mail-pf0-x242.google.com with SMTP id a14so20111150pfi.1 for ; Sat, 05 May 2018 16:37:53 -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=m0kPJd0pkX99zx3L0bIyb8JnX0eESKWYP56tQU57YJU=; b=FtJT/nsN/+/KW8JCRpUovMZT9kGP8u1BF6huCggL6+KNkwyLvWjBznqkpadvvQVMBs lrdoc5f0/iC99IkYWJe3SY8I0xMRDVyPkSCQnDziMssG5LvE7ncxp/NjSw9sMiav1atT CWYLTUidXA4JL6jUaGTOHxM6rG8iXxDeL+D9BUsJf6OilrrM018b5ncUDrHPgCE4tLtb yPpJEC6VVjOIm/gKaIxllNIgaiAmeRJFiin4SOAw/gZY+sqz3wkr+U65fiw019kTqj47 rudftJM3nBIS7Dk/WVuTSnEpokLMhLfL5jPt3aNSYVbwwIQi7FRYzpU8Dn1GgbBYkth3 kvCg== 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=m0kPJd0pkX99zx3L0bIyb8JnX0eESKWYP56tQU57YJU=; b=uJwUQ8E/vKuh7nz5XbhtxxMttHmBB+kkomdV8C8j39+Cijq+6Op213DaDkqP09i0XQ lT5yDL2qVs/vFpntZUOHlFXZH1fav82xNyLZ8uurUmcpZ/pjQSP/v8nQCDUpitqA/Jji tlNLs5jw9T+ZTKjX1cBjzFVuncp7zaETRC0grgLjHJVUoG17c7dbO3ebotXiUvolRHOk kCilhN6F6dXJ4qigsBf6tJWt/QkOOXflLrYmGgs6/pGDy2VI8R1ZvUs8gf/cF5vDKw6r xqp5f3mxhnx9AS5sGZmOqllj8f/HoigVY07lHbngKF8bpWPTnm1hkxdrzMC1DT6Uq7cF YSJQ== X-Gm-Message-State: ALQs6tDLDv/hsX+XBbc4KETPoD60Wowmv3TRXbsEOu1adfzNwRQ65/t0 6x7RVwET3LvBqOkb/j1+vbhsoCPfrJM= X-Google-Smtp-Source: AB8JxZrLFryO9p+nlf6wPrynrwInjVxYns9M2AiVC2E218s9t+StaBno5wjCIkp4rOlVfL1phktJrg== X-Received: by 2002:a17:902:6b0c:: with SMTP id o12-v6mr11662040plk.159.1525563473187; Sat, 05 May 2018 16:37:53 -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 x8sm47297094pfa.173.2018.05.05.16.37.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 05 May 2018 16:37:52 -0700 (PDT) From: Michael Clark To: qemu-devel@nongnu.org Date: Sun, 6 May 2018 11:35:23 +1200 Message-Id: <1525563325-62963-19-git-send-email-mjc@sifive.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1525563325-62963-1-git-send-email-mjc@sifive.com> References: <1525563325-62963-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::242 Subject: [Qemu-devel] [PULL 18/20] RISC-V: Make mtvec/stvec ignore vectored traps 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 Vectored traps for asynchrounous interrupts are optional. The mtvec/stvec mode field is WARL and hence does not trap if an illegal value is written. Illegal values are ignored. Later we can add RISCV_FEATURE_VECTORED_TRAPS however until then the correct behavior for WARL (Write Any, Read Legal) fields is to drop writes to unsupported bits. Cc: Sagar Karandikar Cc: Bastian Koppelmann Cc: Palmer Dabbelt Cc: Alistair Francis Signed-off-by: Michael Clark --- target/riscv/op_helper.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/target/riscv/op_helper.c b/target/riscv/op_helper.c index 3512462f4fd8..af0c52a48418 100644 --- a/target/riscv/op_helper.c +++ b/target/riscv/op_helper.c @@ -287,11 +287,12 @@ void csr_write_helper(CPURISCVState *env, target_ulong val_to_write, env->sepc = val_to_write; break; case CSR_STVEC: - if (val_to_write & 1) { + /* bits [1:0] encode mode; 0 = direct, 1 = vectored, 2 >= reserved */ + if ((val_to_write & 3) == 0) { + env->stvec = val_to_write >> 2 << 2; + } else { qemu_log_mask(LOG_UNIMP, "CSR_STVEC: vectored traps not supported"); - goto do_illegal; } - env->stvec = val_to_write >> 2 << 2; break; case CSR_SCOUNTEREN: if (env->priv_ver >= PRIV_VERSION_1_10_0) { @@ -313,11 +314,12 @@ void csr_write_helper(CPURISCVState *env, target_ulong val_to_write, env->mepc = val_to_write; break; case CSR_MTVEC: - if (val_to_write & 1) { + /* bits [1:0] indicate mode; 0 = direct, 1 = vectored, 2 >= reserved */ + if ((val_to_write & 3) == 0) { + env->mtvec = val_to_write >> 2 << 2; + } else { qemu_log_mask(LOG_UNIMP, "CSR_MTVEC: vectored traps not supported"); - goto do_illegal; } - env->mtvec = val_to_write >> 2 << 2; break; case CSR_MCOUNTEREN: if (env->priv_ver >= PRIV_VERSION_1_10_0) {