From patchwork Fri Dec 21 16:03:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Palmer Dabbelt X-Patchwork-Id: 10740669 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E207913B5 for ; Fri, 21 Dec 2018 16:10:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CFC2D28479 for ; Fri, 21 Dec 2018 16:10:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C249C2849D; Fri, 21 Dec 2018 16:10:42 +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.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 4700828479 for ; Fri, 21 Dec 2018 16:10:42 +0000 (UTC) Received: from localhost ([::1]:46449 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gaNNp-000850-3Y for patchwork-qemu-devel@patchwork.kernel.org; Fri, 21 Dec 2018 11:10:41 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53071) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gaNHP-0001gK-E6 for qemu-devel@nongnu.org; Fri, 21 Dec 2018 11:04:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gaNHO-0004Fi-13 for qemu-devel@nongnu.org; Fri, 21 Dec 2018 11:04:03 -0500 Received: from mail-qt1-x843.google.com ([2607:f8b0:4864:20::843]:45896) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gaNHN-00048c-KP for qemu-devel@nongnu.org; Fri, 21 Dec 2018 11:04:01 -0500 Received: by mail-qt1-x843.google.com with SMTP id e5so6154818qtr.12 for ; Fri, 21 Dec 2018 08:03:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=subject:date:message-id:in-reply-to:references:cc:from:to; bh=IWfZjYzkdRCs/v8ZQPYnDvi7qMZxCS9XtrTCN8xP4I8=; b=RUl6kom9WZe7dcJfGMvPHznB6POxbIX4uT5ZUpuHwderj3Qx1p4MHxPNPVxZJ9/Nsy JjrqZuXUOJeM8Nmd9shv/f6WkTNyln+sCG99yhSM+FMY9XP4mSATDwz2dhQJqvtom45Z OxpMKnHHQU4G5MnW6jvUD6HYk4nV3tgsAh3UjOFwCbYfEMfMU2gkVzY7oQEGBxAR+7Ku StBbWFyoZqNkFuW3TeLxXGrVvpsjgHHZwYAE1QFTxx9Ldn11RH8k/xJnuRCKkJnmnwr/ WtDCFMInmEYPztFM08YbI7zsj/5jJg0sc50/OZ2OS/sZdhtHLuqk7+9a50K1ehYYaBV4 EEPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:date:message-id:in-reply-to:references :cc:from:to; bh=IWfZjYzkdRCs/v8ZQPYnDvi7qMZxCS9XtrTCN8xP4I8=; b=JGqWSowyhdWMcMmUItRiJ/mNLU3EvS+3yyyE18tMfbrKg4gH/xfHMmxXBj+DY4db3Z zv2ET3Y8jyocibH2pjmbQ3seVc0ebz78AMBpfuYdROvCyospeEyNmPqj6NBNfXbE5Dfv iFxawJ1e8rin47jce17pDVkW5hdS/U+lESkpHptC8MS0Q7rwDFOd8gyONvoS/gwFZ6iL XsgMhOp29xlHeEOBXm4weKxsjjUNB+lADYBJUtvUqkoo9u376hQQSgAEKn9C96BwtWEW wi3+g/eWKbuvd+mNg1ftUB6soNWuWrx4Eat4Vtdsy1mjFbCRj2QhVgHFu/I/bFnB1ycK VzWA== X-Gm-Message-State: AA+aEWbU5WsFpEhTu/jT636bgF6Y4MoIe1Ha6g28y65WGD8pK27ygnhM gdVSi0sbaFyJ5aopIsVVONWO7NrzQOM= X-Google-Smtp-Source: ALg8bN4bx5aORwCfxDz8A0kliLD0avfzy2RbG7oc/VUtFu3Go44tnj6e37Jzrlwb89fA/eAbfpUa/g== X-Received: by 2002:aed:3784:: with SMTP id j4mr2922814qtb.50.1545408229232; Fri, 21 Dec 2018 08:03:49 -0800 (PST) Received: from localhost ([2601:182:c980:96c:8dd:4488:90b1:59d1]) by smtp.gmail.com with ESMTPSA id h35sm6519532qth.59.2018.12.21.08.03.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Dec 2018 08:03:48 -0800 (PST) Date: Fri, 21 Dec 2018 08:03:02 -0800 Message-Id: <20181221160307.14819-10-palmer@sifive.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20181221160307.14819-1-palmer@sifive.com> References: <20181221160307.14819-1-palmer@sifive.com> From: Palmer Dabbelt To: qemu-riscv@nongnu.org X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::843 Subject: [Qemu-devel] [PULL 09/14] 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 , qemu-devel@nongnu.org, Michael Clark , Alistair Francis Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Michael Clark 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 Signed-off-by: Alistair Francis Signed-off-by: Palmer Dabbelt --- 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 9cf9a1f98644..d12ec3fc9a54 100644 --- a/hw/riscv/sifive_plic.c +++ b/hw/riscv/sifive_plic.c @@ -214,7 +214,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]);