From nobody Mon Nov 10 19:12:31 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=wdc.com ARC-Seal: i=1; a=rsa-sha256; t=1558131343; cv=none; d=zoho.com; s=zohoarc; b=lDdjS5Q2lO32NR/m7rI1CKUHXTkbLRC3/qvZEd5HGugxxXZ9KNRDzMH4WUaS040ySLS47WzeZHIag1HmbnveLWy9EnuofR4G5ma24YFflYzFeGEi1pVnTmiXrk5dq4tQoWO8zBtdc+sMmID2nTL3hf+oL5RrWuk19hav3PQYLkg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558131343; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=KvuhrySpeb2Eavr68cqF8hfldtdGZn4QPq1qI2AcMG4=; b=mc1+voBY6gXgTDKmqk8RwfXiI/+MYI2WlMowtcdEb4YYluyl85BXSshcxBZqdxuDQ6UUmtW8IjQFYA9lGmW/j4f727x7b4t+OM28Mz1iq5xrVH9n0Nf8aKrkis7aqxOi9tnyojbStDcWroaxLbV8ljdbzuZFGO6Fu+OtJWVei8I= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail header.i=@wdc.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1558131343639123.35945825353997; Fri, 17 May 2019 15:15:43 -0700 (PDT) Received: from localhost ([127.0.0.1]:54323 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hRl81-0000cz-83 for importer@patchew.org; Fri, 17 May 2019 18:15:01 -0400 Received: from eggs.gnu.org ([209.51.188.92]:37034) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hRl5z-0007tX-LH for qemu-devel@nongnu.org; Fri, 17 May 2019 18:12:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hRl5w-0007IJ-NX for qemu-devel@nongnu.org; Fri, 17 May 2019 18:12:54 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:41010) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hRl5u-0007Ep-U8; Fri, 17 May 2019 18:12:51 -0400 Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 18 May 2019 06:12:46 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP; 17 May 2019 14:48:15 -0700 Received: from risc6-mainframe.sdcorp.global.sandisk.com (HELO risc6-mainframe.int.fusionio.com) ([10.196.157.140]) by uls-op-cesaip01.wdc.com with ESMTP; 17 May 2019 15:12:45 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1558131171; x=1589667171; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1P5qQVKzrpTrWYHCy5Y+UMpW1pxkR7dCHPH3WsXz+P8=; b=OvaFUob+wZt67Yv/mblaaxSjuUoe4miSuwRkVHHZCDKRlUPSW52TTuwr QKKwbLm6moWJyIfr4TbF2UY4eyvFfsBVTdyn4r7zXvX/J4CRMT3opdSCW VHGTiITNUk4qqh4BSrHP5/kH7FlspVRFcIED7GoZgVpi6tg+0RvIAhaa1 iiGtxy/d1i66/NoYEMRhM8rfLFcqegbM2rswBurHxcPUlxxKGlNHQeOUr vWdZXq/HKB2MN8JCL+QxPs5QJpDogKCNmgM0Wa5gWrUSUUTkEGkyr9yYg MaFYF2GY6P4XvCicBiZD/1IN95dQlB2SPNPXr1gKdKM/L+M+ZJsdbaCRP A==; X-IronPort-AV: E=Sophos;i="5.60,481,1549900800"; d="scan'208";a="110242474" IronPort-SDR: o3M2jrXjyaPSCri3UE3ELuMYg7Kqs5Iuh9xPGJFDy/WnMbQ4ZPakLSg3jTqLy8DIVcDvcukT/K E7+CH+q2oKRyxj8mfo6qChu0jX4UIrUEkYrWeUSiHUf3lmx6Rx+pnMeVjBUXaFHXoFsaFDvOPs kb5JTBWutv7LH2vLTpRa0+MhR21C8MLQjV+sxBBR8zbRmycmQoYEcKauMIcYQ/K5w34VxjGFlz ArJE7tX+M6znBeLRxa3rht/XC7Hz4i50YnLykG/Xy3rRZ7YDGUA22JUx1fvQtF6UtvEJ2VR+z1 UcYNyo/OXZah1Wb+GJJAhHJi IronPort-SDR: iO/Mcn4Z0aOYIqHXKCpsljROJ4JsxDQNKRw4JTLJAkeNoSdzWk7g7n/PITcgsHDFI24DBlX2Gz vMbJy4n+Efy3FRKEN71Xw0cQmz9Hh49SjrRJktPIDYuDqJN72iRsz36Axt66tuXHns6fXUpCvt ZVyAGoiyZaG1kPvAYZmFOKQu3jRaVAU1tlclhc5XTMRXw/4QVv62wiRvAEznIUG20K+FxudiZ0 JD7HGjD/Q4XpfC4f+Fgz5ClpvzZ9JGUUpVJH/qFO4RLItuwZzmhHzAcKltDlH1JUFpY9yzApuK 7WY= From: Alistair Francis To: qemu-devel@nongnu.org, qemu-riscv@nongnu.org Date: Fri, 17 May 2019 15:10:58 -0700 Message-Id: X-Mailer: git-send-email 2.21.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 216.71.154.45 Subject: [Qemu-devel] [PATCH v1 1/4] target/riscv: Fix PMP range boundary address bug 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: alistair23@gmail.com, palmer@sifive.com, alistair.francis@wdc.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Dayeol Lee A wrong address is passed to `pmp_is_in_range` while checking if a memory access is within a PMP range. Since the ending address of the pmp range (i.e., pmp_state.addr[i].ea) is set to the last address in the range (i.e., pmp base + pmp size - 1), memory accesses containg the last address in the range will always fail. For example, assume that a PMP range is 4KB from 0x87654000 such that the last address within the range is 0x87654fff. 1-byte access to 0x87654fff should be considered to be fully inside the PMP range. However the access now fails and complains partial inclusion because pmp_is_in_range(env, i, addr + size) returns 0 whereas pmp_is_in_range(env, i, addr) returns 1. Signed-off-by: Dayeol Lee Reviewed-by: Alistair Francis Reviewed-by: Michael Clark Signed-off-by: Alistair Francis --- 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 b11c4ae22f..a2fcc90d73 100644 --- a/target/riscv/pmp.c +++ b/target/riscv/pmp.c @@ -246,7 +246,7 @@ bool pmp_hart_has_privs(CPURISCVState *env, target_ulon= g addr, from low to high */ for (i =3D 0; i < MAX_RISCV_PMPS; i++) { s =3D pmp_is_in_range(env, i, addr); - e =3D pmp_is_in_range(env, i, addr + size); + e =3D pmp_is_in_range(env, i, addr + size - 1); =20 /* partially inside */ if ((s + e) =3D=3D 1) { --=20 2.21.0