From patchwork Wed Apr 25 23:45:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Clark X-Patchwork-Id: 10364419 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 7EE506032C for ; Thu, 26 Apr 2018 00:09:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6DC2728FDF for ; Thu, 26 Apr 2018 00:09:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 616DE29028; Thu, 26 Apr 2018 00:09: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=-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 C857B28FDF for ; Thu, 26 Apr 2018 00:09:36 +0000 (UTC) Received: from localhost ([::1]:39672 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fBUTg-0006iY-2G for patchwork-qemu-devel@patchwork.kernel.org; Wed, 25 Apr 2018 20:09:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46579) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fBU8s-000548-3u for qemu-devel@nongnu.org; Wed, 25 Apr 2018 19:48:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fBU8r-0005AH-6Z for qemu-devel@nongnu.org; Wed, 25 Apr 2018 19:48:06 -0400 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]:33120) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fBU8r-00059x-1A for qemu-devel@nongnu.org; Wed, 25 Apr 2018 19:48:05 -0400 Received: by mail-pf0-x243.google.com with SMTP id f15so16597052pfn.0 for ; Wed, 25 Apr 2018 16:48:04 -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=tdxboXn1ordKW3kArOm8KpU0pLAOfbBEFeh3482wzcY=; b=aKjmHLMs1q9Rt58g5/TQXt/3GibbsEwxI0qJLQ0b8poEPwXaqTu+ecEEKgUJqWduLJ 2fXdesTPYgv/DTH8nyv95PA/PL4lo0L6t6v1hTs7RJLPghQDwKQm23dcCliVqY3uRvkB vV0ErIjx3KieK+J85ZuQUbZCH939ihYe8gJ+Hpve/oKNZmSEfqsC4RiwpNK4gtv/8Xoo 7wCsnI3aOQXJR7fgTBfD7gEXZnm+Ax1t8QenA3CgOAHW8b/YYTlum1Kin/Nt4vm5Iyqe JDGwgoh0i1MgpR5ZN2/wGGUtZSZOk20Mk9r0NzuiX7ZMnfVDN9yb0CYyIvmxGbDka9UY 9dTw== 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=tdxboXn1ordKW3kArOm8KpU0pLAOfbBEFeh3482wzcY=; b=WpbnAHV2HZaC35HjFzje0sovWK5mI8fb0/oz6yUZLJGASnfCMKPj9h3L2QfnV6kjBZ TXFXds5L9RtHuLi62VwfJ3eoVAkkog1gHpXKd/zObssOCRNJ3t3DcnPnyJ6uxpVY0rHu 0brzC+VprvKDoJ6QMd+N5A6jruZ0P6ZOzuWKoZR/zk9iYX23ziSiOgnl97fIxEBNCBZn bEB0C6ezTixDDIdBTeeMi04N3nAic6pdR4h1NusbN/Mrt4GUyvlMmtniwrZIl1igfNVb rJuCFbjQNGLs24eq2NMEt8hBVJ+BjzECeIIhsOohReJeaHcGhTA+1twzGbBdJA4S2sHL ZYtw== X-Gm-Message-State: ALQs6tCIZFLan+sN9B+ofJd+SXjWkT6+gz2zwjroutWSJ7o2YO0DsmLi m1weywSr9F1csqWlIDvAXvX7eynoeyY= X-Google-Smtp-Source: AB8JxZoyDcn0kiXtUMVKKR9Jw4qJIkHNtN3auIVXEEL6Fv28XeDn1wVx3SNo4+50AfX+igYTc8ZPrg== X-Received: by 2002:a17:902:b945:: with SMTP id h5-v6mr9279233pls.321.1524700084061; Wed, 25 Apr 2018 16:48:04 -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 e10sm29577549pfn.67.2018.04.25.16.48.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 25 Apr 2018 16:48:03 -0700 (PDT) From: Michael Clark To: qemu-devel@nongnu.org Date: Thu, 26 Apr 2018 11:45:19 +1200 Message-Id: <1524699938-6764-17-git-send-email-mjc@sifive.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1524699938-6764-1-git-send-email-mjc@sifive.com> References: <1524699938-6764-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] [PATCH v8 16/35] 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, 6 insertions(+), 8 deletions(-) diff --git a/target/riscv/op_helper.c b/target/riscv/op_helper.c index 101dac1..828f20c 100644 --- a/target/riscv/op_helper.c +++ b/target/riscv/op_helper.c @@ -276,11 +276,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; @@ -298,11 +297,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;