From patchwork Fri Mar 9 04:12:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Clark X-Patchwork-Id: 10269665 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 152F560236 for ; Fri, 9 Mar 2018 04:29:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED69429C99 for ; Fri, 9 Mar 2018 04:29:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E159629CB5; Fri, 9 Mar 2018 04:29:31 +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 7F1CF29C99 for ; Fri, 9 Mar 2018 04:29:31 +0000 (UTC) Received: from localhost ([::1]:43173 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eu9es-0007az-QD for patchwork-qemu-devel@patchwork.kernel.org; Thu, 08 Mar 2018 23:29:30 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55963) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eu9R1-0004cR-3g for qemu-devel@nongnu.org; Thu, 08 Mar 2018 23:15:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eu9R0-0007AT-9C for qemu-devel@nongnu.org; Thu, 08 Mar 2018 23:15:11 -0500 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:46298) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eu9R0-0007AB-2w for qemu-devel@nongnu.org; Thu, 08 Mar 2018 23:15:10 -0500 Received: by mail-pf0-x244.google.com with SMTP id z10so826722pfh.13 for ; Thu, 08 Mar 2018 20:15:10 -0800 (PST) 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=bt2M/AHC9Y7szQPwhX3hgmhil+uRswKhQTDlPUwKQgg=; b=kHkjJfBLJyNMdNmEa/349DKw+myrx0FIoD1/zx0xHLjYQO0ozfOyALGVCC6QWYiSwG sBjDQHrb9/XFUoe30Nuz/xrM1vdZZHoStCCK6CunRLHFzpCyMD5mnHsaN1EQqxEpT5o3 yudfqUdvqinquWAQ2SHoAJIZv5FxefSmgzrxKjXBMrV5nfEGHUk5y+rEMOr5oAlRI5zG QxDG5ZPrca30raAn731yDihkvmbAWH7IUeVJKYW0iz9UKmB2g7JeuYkd0G2zuES4bfd6 ojpfpasRl9P+IKpRbRfS/p74cOc4muf/6qi0broMhyfDM6Q7bwjfJaJbO9K6mFGGf4ah 1qLA== 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=bt2M/AHC9Y7szQPwhX3hgmhil+uRswKhQTDlPUwKQgg=; b=HytP4RshesEY/2V3Z4mwuVu779h0ryUr28h0NSCRhWmljT7GHtovzoYkX71NPrPkIY NfjWFqQoTFChTByeR3yD1J/iF6/Q5oVvG1yxoNhEfWwiBVXhF2ZgfjJq3g5VJhkRnKJh JME26eErMuSWWTrazvF8mttw1BEAR2GL3rVj5me0lwy7ZZnprnkQB8888ujhUjM3DGFi LQfJ7n4q1nOd2HE1Yt3a/fVaqr7SlsZ5HM71AV1GxvKvcCS+zKr6JuPyIftoiahosazi TYkIWQphvgK0ufXnXoCKDZniiWi4vVzYZu7LdJ88LFyYgPscIQ8Mk1oOyeu6lYrO+6wK r0fg== X-Gm-Message-State: APf1xPBYI5on4FvWnWpRNBo16ZpuD+iGYLQRZ6TtbKf19LZ0Gf2C35WR Gnq8+YZwwKjsZw3oEbIkFJ0BKDyEzn0= X-Google-Smtp-Source: AG47ELs97y3tS4QV/3fRA8JRaXSaUN0+JMPjmUMfbXnGYfjiHLjp3K3Dxxj/oPbtB9GKe1uVY4ZjcQ== X-Received: by 10.101.100.208 with SMTP id t16mr22250767pgv.398.1520568909135; Thu, 08 Mar 2018 20:15:09 -0800 (PST) Received: from localhost.localdomain (125-237-39-90-fibre.bb.spark.co.nz. [125.237.39.90]) by smtp.gmail.com with ESMTPSA id h15sm334141pfi.56.2018.03.08.20.15.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 08 Mar 2018 20:15:08 -0800 (PST) From: Michael Clark To: qemu-devel@nongnu.org Date: Fri, 9 Mar 2018 17:12:42 +1300 Message-Id: <1520568765-58189-21-git-send-email-mjc@sifive.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1520568765-58189-1-git-send-email-mjc@sifive.com> References: <1520568765-58189-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 v2 20/23] 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: Bastian Koppelmann , Michael Clark , Palmer Dabbelt , Sagar Karandikar 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..aa101cc 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;