From patchwork Wed May 23 00:15:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Clark X-Patchwork-Id: 10419955 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 A35B86016C for ; Wed, 23 May 2018 00:33:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 92C51204C3 for ; Wed, 23 May 2018 00:33:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8739422F3E; Wed, 23 May 2018 00:33:25 +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 06124204C3 for ; Wed, 23 May 2018 00:33:24 +0000 (UTC) Received: from localhost ([::1]:58576 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fLHiW-0003qa-1d for patchwork-qemu-devel@patchwork.kernel.org; Tue, 22 May 2018 20:33:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42697) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fLHTs-0000NS-4p for qemu-devel@nongnu.org; Tue, 22 May 2018 20:18:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fLHTo-0001Hs-TE for qemu-devel@nongnu.org; Tue, 22 May 2018 20:18:16 -0400 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:35013) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fLHTo-0001HJ-LL for qemu-devel@nongnu.org; Tue, 22 May 2018 20:18:12 -0400 Received: by mail-pf0-x242.google.com with SMTP id x9-v6so9565322pfm.2 for ; Tue, 22 May 2018 17:18:12 -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=QymqFsIypWzjGDJfbfewp5VZL9NdaQid8o+O6lKZyFE=; b=atlrhgiuTTRhRzI2LpeHGeEk5lo6C/T3IMcLfQIdxyQU5xb7DMiFrsqFmgW+mSaGtt YsCGamul1sbyh0I3aoZBtkhLJYgI/mXvRcYgTCu1YXs3jBzVwdAnDg/DBD3kQAom0DWR MC5kNoBwjIMBULskIKU2kZxFB+KSrADmuMsNZvyHhc9z7bFxJAM1Z7Ka7Z88EcDyJmWB TE68LkB86PJat3GOQN0Lsxlc0dgdm3OipVSXBKGhAf780gSZMsbELsO+cfC6NakXvn54 m1xrdo0XTMGRbL3ZarfMPkZ6YBx3zhKdbnCaOL5suu+l5kZWyWGP+IJUPljFiKbcn6M2 hfGQ== 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=QymqFsIypWzjGDJfbfewp5VZL9NdaQid8o+O6lKZyFE=; b=f5PjnFWWjzTeD+phe1vQ5gjUWh4rA/N32MJ7zGhKvCCCrghjqbuJuqFP+3JWE11+cR CsMsV3tzOEhqm7IuRsNvTr9ye0HjU9RbG3hmBMDWtnlFyB4jRSpI80+TKxDxvzAAFpiZ glV0QFTX4w1qzJOEYrCoO80PAkUcXB9NIbWUCCctsIrDCJtwmFH9+TLiFl6YF2Jhh7Jf GNdz/ic7LbK6Lbpd+SeOKuEcL5jqSvEMrMqgobJK8ty3yer9ZT/eiszGm/RGzadSNDic nBjQuGkZSZstTBmUBZfgeC2nawY0YjCC4ZNXe6mE1G7SJYxaWCdN9wulZaG9v1s0YePS 5fEg== X-Gm-Message-State: ALKqPwcbE0LMGl7Y9Dx3P/UQLabEx2KfhH92tOPwTBAyOyxrlRvT34eM xwZd7np04+SyQsCbdw30OHc55lP718E= X-Google-Smtp-Source: AB8JxZrg9a9yGbPp4ILuJYbXJ8IqFD7NmJ66H8R5ACnAgX09EeDv3KRfM6y8SefHu9ygCnrRioblZw== X-Received: by 2002:a62:8dc9:: with SMTP id p70-v6mr604428pfk.72.1527034691761; Tue, 22 May 2018 17:18:11 -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.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 22 May 2018 17:18:11 -0700 (PDT) From: Michael Clark To: qemu-devel@nongnu.org Date: Wed, 23 May 2018 12:15:10 +1200 Message-Id: <1527034517-7851-24-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:c00::242 Subject: [Qemu-devel] [PATCH v1 23/30] RISC-V: Fix CLINT timecmp low 32-bit writes 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 A missing shift made updates to the low order bits of timecmp erroneously copy the old low order bits into the high order bits of the 64-bit timecmp register. Add the missing shift and rename timecmp local variables to timecmp_hi and timecmp_lo. This bug didn't show up as the low order bits are usually written first followed by the high order bits meaning the high order bits contained an invalid value between the timecmp_lo and timecmp_hi update. Cc: Palmer Dabbelt Cc: Sagar Karandikar Cc: Bastian Koppelmann Cc: Alistair Francis Co-Authored-by: Johannes Haring Signed-off-by: Michael Clark Reviewed-by: Alistair Francis --- hw/riscv/sifive_clint.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/riscv/sifive_clint.c b/hw/riscv/sifive_clint.c index 0d2fd52487e6..d4c159e93736 100644 --- a/hw/riscv/sifive_clint.c +++ b/hw/riscv/sifive_clint.c @@ -146,15 +146,15 @@ static void sifive_clint_write(void *opaque, hwaddr addr, uint64_t value, error_report("clint: invalid timecmp hartid: %zu", hartid); } else if ((addr & 0x7) == 0) { /* timecmp_lo */ - uint64_t timecmp = env->timecmp; + uint64_t timecmp_hi = env->timecmp >> 32; sifive_clint_write_timecmp(RISCV_CPU(cpu), - timecmp << 32 | (value & 0xFFFFFFFF)); + timecmp_hi << 32 | (value & 0xFFFFFFFF)); return; } else if ((addr & 0x7) == 4) { /* timecmp_hi */ - uint64_t timecmp = env->timecmp; + uint64_t timecmp_lo = env->timecmp; sifive_clint_write_timecmp(RISCV_CPU(cpu), - value << 32 | (timecmp & 0xFFFFFFFF)); + value << 32 | (timecmp_lo & 0xFFFFFFFF)); } else { error_report("clint: invalid timecmp write: %08x", (uint32_t)addr); }