From patchwork Wed Mar 21 20:46:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Clark X-Patchwork-Id: 10300399 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 3516E602B3 for ; Wed, 21 Mar 2018 20:58:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1E2B02842E for ; Wed, 21 Mar 2018 20:58:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 127D8297AF; Wed, 21 Mar 2018 20:58:14 +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 997C42842E for ; Wed, 21 Mar 2018 20:58:13 +0000 (UTC) Received: from localhost ([::1]:57403 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eykoG-0003RK-LT for patchwork-qemu-devel@patchwork.kernel.org; Wed, 21 Mar 2018 16:58:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53203) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eykeZ-0002BS-Pp for qemu-devel@nongnu.org; Wed, 21 Mar 2018 16:48:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eykeW-0002BA-Tn for qemu-devel@nongnu.org; Wed, 21 Mar 2018 16:48:11 -0400 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]:41387) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eykeW-0002An-NL for qemu-devel@nongnu.org; Wed, 21 Mar 2018 16:48:08 -0400 Received: by mail-pf0-x243.google.com with SMTP id f80so2457292pfa.8 for ; Wed, 21 Mar 2018 13:48:08 -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=bW3hpcchXCFFGJpWYsnx3XmXdEaKMv7y36cZmkIKBo4VdCNyFwyMzlxgirMh/4o1zx 9KhadCEld5ruXhbN0XqzGfD0pRkNRHp0JtsDy+3vqE9GIDja0ur6yoSm+ayDQWgoDJU7 KT1OQcPdEAG9e8aGkbjl7q8PYZwE0ESJbkszQ8SxRR/siJGia4xStnqg++secabsXKCC NyWUUpMOzXE/dOl30e7PJRysU/eq16/cUAe7secPLHmU/2a8YkI/QxHNPSq4kIf47EL7 /IsrxdkGM8a6U1OXJ4PC6D/4MzirOans8RL5duKlXPsO7MY/WU4wYwi4YnCGYUuqT1Ch x7BA== 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=ZDKEXojA8thYVRQ3CJgEuIVehdKpDCLS8aZAwgiccGJvW4VfymOS911TbFj6U7Ky7P g2vxi8V4/jLMTpThIn47Ri8ysXJSL2jV+xWpKZ9gG62cI601lKsU3lFid1RBulY5TN+Y eJbFieJ5dYIal6lhhrsqJumY9Hitv6qZ80vVdPltrvXKTxLrwJI0cbn4gpMw6pSkbjda B9VyH9cr3I6rfr7rMv9nPnjszL57+GqIKW4g1H+9t1akVN4Vo/8yc/zZzxv6FjrDfp4+ Wr1hqJGdc7pVpzwLfFqnLL98/as/XhRtskR/YlA0HYDdp/03V3upd9QMg+0prf89RscG oHRA== X-Gm-Message-State: AElRT7EZwUlLF3awKyqn0qqQmaR7Hvts/eRycFo/k9dMMKJO2Bf+U5PZ jVqBL7e7BLmTLcBfybqxCTw+PrLaBFg= X-Google-Smtp-Source: AG47ELtclol7KUXnB8U0ik3oXVBpQCn8CxunDE9uuk5cbnQ+cVqIfTfbvMG4S3PO7umb9kF5mRFWfg== X-Received: by 10.99.65.6 with SMTP id o6mr7296564pga.57.1521665287518; Wed, 21 Mar 2018 13:48:07 -0700 (PDT) Received: from monty.com ([12.206.222.5]) by smtp.gmail.com with ESMTPSA id w10sm8244499pgr.57.2018.03.21.13.48.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 21 Mar 2018 13:48:06 -0700 (PDT) From: Michael Clark To: qemu-devel@nongnu.org Date: Wed, 21 Mar 2018 13:46:55 -0700 Message-Id: <1521665220-3869-20-git-send-email-mjc@sifive.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1521665220-3869-1-git-send-email-mjc@sifive.com> References: <1521665220-3869-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::243 Subject: [Qemu-devel] [PULL 19/24] 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;