From patchwork Tue Oct 30 21:22:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Palmer Dabbelt X-Patchwork-Id: 10661601 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 DA0E114E2 for ; Tue, 30 Oct 2018 21:24:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CBCC12A548 for ; Tue, 30 Oct 2018 21:24:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C06672A5AE; Tue, 30 Oct 2018 21:24: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=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI 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 E0F0B2A548 for ; Tue, 30 Oct 2018 21:24:35 +0000 (UTC) Received: from localhost ([::1]:55648 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHbV4-0000sA-E3 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 30 Oct 2018 17:24:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48304) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHbTh-0008DZ-Nu for qemu-devel@nongnu.org; Tue, 30 Oct 2018 17:23:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHbTf-00065t-8A for qemu-devel@nongnu.org; Tue, 30 Oct 2018 17:23:09 -0400 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]:39990) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gHbTe-00065R-VU for qemu-devel@nongnu.org; Tue, 30 Oct 2018 17:23:07 -0400 Received: by mail-pf1-x42c.google.com with SMTP id g21-v6so6494498pfi.7 for ; Tue, 30 Oct 2018 14:23:06 -0700 (PDT) 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=Af8rVrWHdvztrVxLd6qw2DArsRBAN4E6UCg+lL/FuHw=; b=LP+WjAgIRkSz6tck0pT4Mx9Jcv/WIAI5+0zI+t4wOTIXVbbe7REXbPZKfEj4Zn/KIy kSReDjxmXjYi1Bcs/wBqO6HICYZAhKMAsHz3PHKagc5sAfyE9DYR6PmrMJmdeduZXfHT b78u+C1JXkWTTJjeT2P5pEk/NZqHpMAUUq+wxNif6DraI2rlDRvl8wvx7IJC3oJG/P5U dfBF/r2BPWPrNFXjsgXz/79OTjFl4DsCzcx4mGxtTVXzrASPM6bA32oceC+DkL4iDJJP Ks0ngKbc67rqHz1EcpF65yFwNvHZmSSkiXGlD29hxIFJcrJdI3AmjyZ660OJKEszrVEk V46A== 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=Af8rVrWHdvztrVxLd6qw2DArsRBAN4E6UCg+lL/FuHw=; b=Jk9qkCpzLkG+EljccQxhj6etRQ0M0Ah+4NFrfNQK7ROuoL2G5yYKaBmfj0TxMBifFI p5KxOQeRNc4G2GFfp06AXSLupC6Pd/K6Av4NjjjJI4Ez2EPOjlO4UnUHjge4Jp1jUgVt AnlWGYOux+lvuhYqnvjw4+XUSks52bbgA7JWilZW7B3Bmk4HAjqZDb/FXy54zSYsseE6 yzlk5eevpQOdUNEOMFnm3nJeZ/N544TUQHF5GJ4qeq8pkXEprBDoMSGQzh9TlNslJQcQ UxKs/djWJGbf6ojMt2+58u/xe05ZJNz683f/6WOFuiZTdK4fjZjTBi3pHuy67CvrdWY1 6a2g== X-Gm-Message-State: AGRZ1gJxL/INfBa/KTWSwKssUo6ovHTYN94b+bm0M9t+e+/YOvxstadx 9mueaFSb9JPeOhOMEQJp5+aLG02cB1E= X-Google-Smtp-Source: AJdET5fO9s85vlFd+CNennRODNnorqRW+giaIyoacywagKF7b3N8ePfMuabKrzGjFKdC326rJiSSHQ== X-Received: by 2002:aa7:80cd:: with SMTP id a13-v6mr389544pfn.86.1540934585590; Tue, 30 Oct 2018 14:23:05 -0700 (PDT) Received: from localhost ([12.206.222.5]) by smtp.gmail.com with ESMTPSA id g20-v6sm3892617pfj.145.2018.10.30.14.23.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Oct 2018 14:23:04 -0700 (PDT) Date: Tue, 30 Oct 2018 14:22:47 -0700 Message-Id: <20181030212249.7117-2-palmer@sifive.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20181030212249.7117-1-palmer@sifive.com> References: <20181030212249.7117-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::42c Subject: [Qemu-devel] [PULL 1/3] target/riscv/pmp.c: pmpcfg_csr_read returns bogus value on RV64 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: Dayeol Lee , Palmer Dabbelt , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Dayeol Lee pmp_read_cfg() returns 8-bit value, which is combined together to form a single pmpcfg CSR. The default promotion rules will result in an integer here ("i*8" is integer, which flows through) resulting in a 32-bit signed value on most hosts. That's bogus on RV64I, with the high bits of the CSR being wrong. Signed-off-by: Dayeol Lee Reviewed-by: Palmer Dabbelt Reviewed-by: Alistair Francis Signed-off-by: Palmer Dabbelt --- target/riscv/pmp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c index f432f3b7594b..03abd8fe5eb7 100644 --- a/target/riscv/pmp.c +++ b/target/riscv/pmp.c @@ -325,7 +325,7 @@ target_ulong pmpcfg_csr_read(CPURISCVState *env, uint32_t reg_index) { int i; target_ulong cfg_val = 0; - uint8_t val = 0; + target_ulong val = 0; for (i = 0; i < sizeof(target_ulong); i++) { val = pmp_read_cfg(env, (reg_index * sizeof(target_ulong)) + i);