From patchwork Mon Mar 19 21:18:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Clark X-Patchwork-Id: 10295325 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 296C260386 for ; Mon, 19 Mar 2018 21:40:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 17DF72923D for ; Mon, 19 Mar 2018 21:40:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0C5D82944C; Mon, 19 Mar 2018 21:40:37 +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 7EA602923D for ; Mon, 19 Mar 2018 21:40:36 +0000 (UTC) Received: from localhost ([::1]:44109 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ey2WB-0002uk-KA for patchwork-qemu-devel@patchwork.kernel.org; Mon, 19 Mar 2018 17:40:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33374) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ey2CI-0001Vg-7o for qemu-devel@nongnu.org; Mon, 19 Mar 2018 17:20:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ey2CF-0002kj-Pk for qemu-devel@nongnu.org; Mon, 19 Mar 2018 17:20:02 -0400 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:36986) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ey2CF-0002kB-JF for qemu-devel@nongnu.org; Mon, 19 Mar 2018 17:19:59 -0400 Received: by mail-pf0-x244.google.com with SMTP id h11so7559028pfn.4 for ; Mon, 19 Mar 2018 14:19:59 -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=t3lh++LxetnmSNNw07i/3UNn8XJU8Dt149LiPYmrn4o=; b=WZv05dJAc5zxetTiw9IGz1FNDn3TVloZvRlsgW5/oBwErjMFmIuB3SKoUrKUZbvkBd 5FXfWtmVqrM+OImoCeJOuwRw4470dk6B+8Th5TcpZDZ64NiOrgVUoNK92pOegBQhXeGF UPK8OGvtK1cR3BmG67yJVrGDWo68GGUNQEwvcpGmS8kADbqKPYaahNeIrxSRotlcKLsz nULXeviBOnDL+kucWCSRXp9P3m6Oy7ZnHauMkrqr/V4hAWfxWeuRKWCzVeVnLrFYxHZN HKA2Bsk0u+3eDXKMHgp1/SgoLfXKN/fMNUn20mKZgTWa56wEVEIR6WR5rJzQjYLHMWbL A8ew== 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=t3lh++LxetnmSNNw07i/3UNn8XJU8Dt149LiPYmrn4o=; b=TXEXti6iMZzc9CPeiPj80sc6s063Pgb2YzLdyerhCXApXiIWtWGtWYsHeebLz6uw8G UpNDSTW/OomvITvAf/ZjDLXC2YfXM5WRTOk8zrCcovhwBFBgjZ1rCZzoAHf8+iuVqzKk 1MyR4BKc2hsQ1Q+hwv+TO5bh3aJlHco1dOc59A2ZJ5fGcvAgYYUohAqn4kpIpYYU2h5S rERzB0gqp4pduk9cyK27ABoywvwFDVVtAqXFstYMICW462jFwxNNhgx54SAw772Y8fnE wWPdiRq5vXjcygSvUuXQ2j4ncS5uaaqq1nYmEOVzyGfAaR15fJVPkTQvtnH44inrb+BR ZVDg== X-Gm-Message-State: AElRT7HKUo2wIJj5fY/P/ULuFmuWcnACgtA0fGtogcQbNwd1rO/YOsHZ OOYaTIVj8y9q6pzOM+cghCdXSgRRCX4= X-Google-Smtp-Source: AG47ELvIA1sJgCR0tkZvUgiz0eIy6NPKGx69J3BOsTg115QzjeCn1SXeLEiLy7AU8KE8yUPtpV+wUg== X-Received: by 10.101.90.10 with SMTP id y10mr10179142pgs.34.1521494398710; Mon, 19 Mar 2018 14:19:58 -0700 (PDT) Received: from monty.com ([12.206.222.5]) by smtp.gmail.com with ESMTPSA id i127sm120500pfc.136.2018.03.19.14.19.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 19 Mar 2018 14:19:58 -0700 (PDT) From: Michael Clark To: qemu-devel@nongnu.org Date: Mon, 19 Mar 2018 14:18:43 -0700 Message-Id: <1521494329-19546-21-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:c00::244 Subject: [Qemu-devel] [PATCH v4 20/26] RISC-V: vectored traps are optional 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 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. Cc: Sagar Karandikar Cc: Bastian Koppelmann Signed-off-by: Michael Clark Signed-off-by: Palmer Dabbelt --- target/riscv/op_helper.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/target/riscv/op_helper.c b/target/riscv/op_helper.c index f79716a..36b9e8e 100644 --- a/target/riscv/op_helper.c +++ b/target/riscv/op_helper.c @@ -262,11 +262,10 @@ 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) { - qemu_log_mask(LOG_UNIMP, "CSR_STVEC: vectored traps not supported"); - goto do_illegal; + /* we do not support vectored traps for asynchrounous interrupts */ + if ((val_to_write & 3) == 0) { + env->stvec = val_to_write >> 2 << 2; } - env->stvec = val_to_write >> 2 << 2; break; case CSR_SCOUNTEREN: env->scounteren = val_to_write; @@ -284,11 +283,10 @@ 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) { - qemu_log_mask(LOG_UNIMP, "CSR_MTVEC: vectored traps not supported"); - goto do_illegal; + /* we do not support vectored traps for asynchrounous interrupts */ + if ((val_to_write & 3) == 0) { + env->mtvec = val_to_write >> 2 << 2; } - env->mtvec = val_to_write >> 2 << 2; break; case CSR_MCOUNTEREN: env->mcounteren = val_to_write;