From patchwork Thu Nov 1 23:55:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Palmer Dabbelt X-Patchwork-Id: 10664825 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 C7A9613B5 for ; Thu, 1 Nov 2018 23:58:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A9B012BDA6 for ; Thu, 1 Nov 2018 23:58:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9A8302BE21; Thu, 1 Nov 2018 23:58:48 +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 464512BDA6 for ; Thu, 1 Nov 2018 23:58:48 +0000 (UTC) Received: from localhost ([::1]:47313 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gIMrP-0002O6-M1 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 01 Nov 2018 19:58:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49244) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gIMoa-0007Cc-Bt for qemu-devel@nongnu.org; Thu, 01 Nov 2018 19:55:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gIMoX-0005Ej-B3 for qemu-devel@nongnu.org; Thu, 01 Nov 2018 19:55:52 -0400 Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]:41778) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gIMoX-0005E4-2R for qemu-devel@nongnu.org; Thu, 01 Nov 2018 19:55:49 -0400 Received: by mail-pg1-x535.google.com with SMTP id k13so105539pga.8 for ; Thu, 01 Nov 2018 16:55:48 -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=MfjVXeUI91yMAL3zHg6i8pq5rZGiBxqU6QKW82ik6P1WIpZ5M3onU4xKAY9z8V8Gj/ tAXAav+MGzdDlwvYY52u3PwIJsV/hi15WAH6wTnaV0KfT1IvS9dvKcbXgRH1GBl4kAYI 8q8kG+RksD4C84hw+jyvYmle/ZQx1UcmP/CGGP/leR6wHvq45YKxX5Lrpg5jfKe0GkjT SYRi9XU23bvdoV5l40Y+HaOUyjGhRr3JBJfgd4IV5dOR5gmJ3hTU3k2MaFnqZ9RLi0l7 /+ZL2iFnr8iLvyAVB97SRppx3BNSHNYJ7OGmOZufrWr5x+ShjfBbleJVRIw34gvTi4qs 4ABg== 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=p6a54O13mqVKi5Ae8ZD832Z58DfdODg4Guban9DGtKL2h7FPl/xElamxk0UE6mWHNV KdDtOEtefRIbfRsGQ4p5jP8tonPWGopI3C/wAf9FuBzN7iXJxR8YII3OPoGW0dvv6st3 JIHTE3JhbZAU514BT5CC8b4D9Q6zq5YzN8SV77LQmDrpXbzd3uncyNFLFqUvIeryQfYU 1R/IlcjbVcCDAyYYfeL+/pGbYmNbtDJcjHXumCsP6Ot8+sDN2rC+aqclq7Zc/bB79u8o CDLSBsxOWO4SOGfVS3Y2uZRKXjTIs79le8QUpRUqR0ohBshuXom44UtLtSGfPddVzHsI CB/A== X-Gm-Message-State: AGRZ1gJ7kLp+AuishSppwIu9uDlKqhxbli9Bj+xhjnFq6UpFNaZd8Se4 45HM+ZsbcuyoonXSdiQZWVCLpg== X-Google-Smtp-Source: AJdET5fzvHW42HQ7P60catbkRTH+VMa3+f5j8XiVd2MKlc7+vqscn7FyMtmn66nKc6C6tIw6+YJl3w== X-Received: by 2002:a63:1e17:: with SMTP id e23mr8877289pge.130.1541116547950; Thu, 01 Nov 2018 16:55:47 -0700 (PDT) Received: from localhost (198-0-202-11-static.hfc.comcastbusiness.net. [198.0.202.11]) by smtp.gmail.com with ESMTPSA id o27-v6sm35037743pfk.85.2018.11.01.16.55.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Nov 2018 16:55:46 -0700 (PDT) Date: Thu, 1 Nov 2018 16:55:23 -0700 Message-Id: <20181101235525.29042-2-palmer@sifive.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20181101235525.29042-1-palmer@sifive.com> References: <20181101235525.29042-1-palmer@sifive.com> From: Palmer Dabbelt To: Peter Maydell X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::535 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-riscv@nongnu.org, 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);