From patchwork Wed May 23 00:15:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Clark X-Patchwork-Id: 10419961 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 C7BE2600CC for ; Wed, 23 May 2018 00:36:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B6B9D28E55 for ; Wed, 23 May 2018 00:36:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AAE9628E87; Wed, 23 May 2018 00:36:15 +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 224B728E55 for ; Wed, 23 May 2018 00:36:14 +0000 (UTC) Received: from localhost ([::1]:58591 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fLHlG-00061e-4s for patchwork-qemu-devel@patchwork.kernel.org; Tue, 22 May 2018 20:36:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42718) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fLHTt-0000Ob-MS for qemu-devel@nongnu.org; Tue, 22 May 2018 20:18:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fLHTs-0001Kh-BZ for qemu-devel@nongnu.org; Tue, 22 May 2018 20:18:17 -0400 Received: from mail-pl0-x244.google.com ([2607:f8b0:400e:c01::244]:38970) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fLHTs-0001K2-4z for qemu-devel@nongnu.org; Tue, 22 May 2018 20:18:16 -0400 Received: by mail-pl0-x244.google.com with SMTP id c19-v6so11868988pls.6 for ; Tue, 22 May 2018 17:18:16 -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=taYtIJl+TbWB6gdlGPePjMF/8T2XgVAgi50MybMNB2I=; b=MmFox87XThmjIKghtcg6sLsOLqBnMakk3PFFxebXyGVV9/3eCit41W3m6t4nPJEIIT nYlwPgr+sISqd9Q/ZdLepNiRRvyjZxadN8cYcegqzMx/mFW1p3kOj+lVSQpXll5lTnOI bUvAfoUAGlhyqYf44vqZC8t/x8SsXzSBvBQp2Ax1JqBKpQMZopylfBGBTJMbmenffFaU +RImQDoME/OcYAzFtvnh02vI1ftHqXry9/hwWKTwd0LlH3h1P6SWWSnuuS0RLp8gQMZS W+u1ff8rLA5wmcbci99A0pqViuHt6dW6qKw9gu/Gvf4ZeIRBLe+xzlkQgbh9gXICl98t XY3w== 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=taYtIJl+TbWB6gdlGPePjMF/8T2XgVAgi50MybMNB2I=; b=Z2/21x6is3JHyPFl8IgJqifWCoSMjXniiUYAHTIjmxFJ5SfiPLZg0GKdy+qSU7Nr2G /3djIdZQ5/tLCpu+j1iEjCoxGLD+9U2SZ2aGouxuRY8nXMD00ZzgCVnP9ePUq099NSk/ xMb7i9ggU5WO28rS8LSzHjDYYefDeAlSXcEdVRDNpPtdIeEdVZs6cyVnVX4ZrBUGaDe4 BAWBJmc64E56CKAXvbrpz3HRyQRlfnHoX0lFvXDjFC31+3FznGJaD44PYsQbIwwZ1/ds WuuSmlSzSA8onQN9G7Y9Vl4BsCRlKoxvHJiC5XSjH/BwnRySkZ81wbmQVRatgTmGyHxb fWxA== X-Gm-Message-State: ALKqPwdGEph3zn3mgKib+qwsb96Q6IfnF9idDTZQJPT08ThieDLbAg2+ 50HnzbjjlbzNI9s2Uw1uuoZzaSg+tm0= X-Google-Smtp-Source: AB8JxZqt8/xzP88KCiYMP881MXbsagqVFqV4XD/jOe2/pbOEnQ5b+qf2eKoLOpr9zYCE82paebdvBg== X-Received: by 2002:a17:902:5502:: with SMTP id f2-v6mr630583pli.108.1527034695295; Tue, 22 May 2018 17:18:15 -0700 (PDT) Received: from localhost.localdomain (122-58-167-22-fibre.bb.spark.co.nz. [122.58.167.22]) by smtp.gmail.com with ESMTPSA id j1-v6sm28935626pfh.95.2018.05.22.17.18.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 22 May 2018 17:18:14 -0700 (PDT) From: Michael Clark To: qemu-devel@nongnu.org Date: Wed, 23 May 2018 12:15:11 +1200 Message-Id: <1527034517-7851-25-git-send-email-mjc@sifive.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1527034517-7851-1-git-send-email-mjc@sifive.com> References: <1527034517-7851-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 v1 24/30] RISC-V: Fix PLIC pending bitfield reads 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 The address calculation for the pending bitfield had a copy paste bug. This bug went unnoticed because the Linux PLIC driver does not read the pending bitfield, rather it reads pending interrupt numbers from the claim register and writes acknowledgements back to the claim register. Cc: Palmer Dabbelt Cc: Sagar Karandikar Cc: Bastian Koppelmann Cc: Alistair Francis Reported-by: Vincent Siles Signed-off-by: Michael Clark Reviewed-by: Alistair Francis --- hw/riscv/sifive_plic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/riscv/sifive_plic.c b/hw/riscv/sifive_plic.c index 28e28d932f7c..b81d29faff99 100644 --- a/hw/riscv/sifive_plic.c +++ b/hw/riscv/sifive_plic.c @@ -215,7 +215,7 @@ static uint64_t sifive_plic_read(void *opaque, hwaddr addr, unsigned size) } else if (addr >= plic->pending_base && /* 1 bit per source */ addr < plic->pending_base + (plic->num_sources >> 3)) { - uint32_t word = (addr - plic->priority_base) >> 2; + uint32_t word = (addr - plic->pending_base) >> 2; if (RISCV_DEBUG_PLIC) { qemu_log("plic: read pending: word=%d value=%d\n", word, plic->pending[word]);