From patchwork Fri Mar 16 19:41:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Clark X-Patchwork-Id: 10289983 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 CF82B601A0 for ; Fri, 16 Mar 2018 19:55:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C02A02847E for ; Fri, 16 Mar 2018 19:55:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B4F8F29088; Fri, 16 Mar 2018 19:55:30 +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 32F372847E for ; Fri, 16 Mar 2018 19:55:30 +0000 (UTC) Received: from localhost ([::1]:59269 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ewvRp-0001i3-4i for patchwork-qemu-devel@patchwork.kernel.org; Fri, 16 Mar 2018 15:55:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40465) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ewvFR-0007ek-2b for qemu-devel@nongnu.org; Fri, 16 Mar 2018 15:42:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ewvFM-0003qL-VG for qemu-devel@nongnu.org; Fri, 16 Mar 2018 15:42:41 -0400 Received: from mail-pl0-x244.google.com ([2607:f8b0:400e:c01::244]:43231) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ewvFM-0003px-Ht for qemu-devel@nongnu.org; Fri, 16 Mar 2018 15:42:36 -0400 Received: by mail-pl0-x244.google.com with SMTP id f23-v6so6498942plr.10 for ; Fri, 16 Mar 2018 12:42:36 -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=bt2M/AHC9Y7szQPwhX3hgmhil+uRswKhQTDlPUwKQgg=; b=UVBIWTRJMg5/0kVkYdwwyLXgb5gX0RQIapfZXOvr+dW+SRUYCICW+9p7eXQE8FM+Au aYunBPiQ/WeHzzlHUvtsP+mgPzIpIOoNvO/FWHAp/m5gOOCJ2AyKZTB88QAqOxOKmVf5 KTafZT7kjcO1CNzcDXw1ATjDG+C46Oz75+oQtI3jMgd8jP3ze8fZkLLkF4ssQxtE/V5B Boh41FbISHMYQuU/g1K4pWR7aIqRA8fppSpvuYi8ddE/R0XEpRnFHaxcIPE0LRTyA5T3 SCU5/kB6LMubckR91lityx99Qq5r0nIlew3eYnPc2zJrFfDgC5E9wtcPeJOaRTMYCHie t7Cw== 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=lbMrizMuFcdVikYRgMiUd+4NYktKpfozGEZIhDHWC7xIKHz6rWUacSB1tXFy7hvLg5 NVoF0qE6y50fT9/6pUmbORSij259hdljk1hscdkY8QJe5j8FRhz8iOOaalxQ5VRg8SO2 k8agynp2U/eIAsv5rogDNFHwkXX17q3JfKCWcVxCzdNdUl6/ewWdlSxDrmxa1VJTwE3S cLCInNGtRiPotuUqmvvj8nc9PNIalp+TAKSr1oXbCBB8ZJi6fqt1D6klyBG9Cvn1hQZL +za9ztLUaDeRG5mq63ZQuxj2ao18bx3FmoAC7fIoh+SyOWFpe1UXi9Z9ezlQPga9dI6+ u+eQ== X-Gm-Message-State: AElRT7H0jiA4iWVnAHbdHFylt1aWfQv+M1zauuHnxV/HZgpyKNf0R5S7 C3sLaSmRtw7oKQklpGJjUKAuDcLvTiM= X-Google-Smtp-Source: AG47ELsdLqmBv3K4EZn09u1cd23kYc9LS5GQwa7A0nxzdbcZDc30oS6ItcQOHTMLohFkkndfnqcBOw== X-Received: by 2002:a17:902:82c2:: with SMTP id u2-v6mr3252117plz.401.1521229355545; Fri, 16 Mar 2018 12:42:35 -0700 (PDT) Received: from monty.com ([12.206.222.5]) by smtp.gmail.com with ESMTPSA id k24sm13780469pff.77.2018.03.16.12.42.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 16 Mar 2018 12:42:35 -0700 (PDT) From: Michael Clark To: qemu-devel@nongnu.org Date: Fri, 16 Mar 2018 12:41:17 -0700 Message-Id: <1521229281-73637-21-git-send-email-mjc@sifive.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1521229281-73637-1-git-send-email-mjc@sifive.com> References: <1521229281-73637-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:c01::244 Subject: [Qemu-devel] [PATCH v3 20/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..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;