From nobody Fri Apr 26 10:00:01 2024 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; 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 Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1549643958105336.70801583408104; Fri, 8 Feb 2019 08:39:18 -0800 (PST) Received: from localhost ([127.0.0.1]:59169 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gs9BG-0000gR-Nz for importer@patchew.org; Fri, 08 Feb 2019 11:39:10 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38611) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gs9A1-00006V-FY for qemu-devel@nongnu.org; Fri, 08 Feb 2019 11:37:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gs99s-0005MP-5R for qemu-devel@nongnu.org; Fri, 08 Feb 2019 11:37:48 -0500 Received: from poy.remlab.net ([2001:41d0:2:5a1a::]:44306 helo=ns207790.ip-94-23-215.eu) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gs99j-00051w-Rp for qemu-devel@nongnu.org; Fri, 08 Feb 2019 11:37:38 -0500 Received: from basile.remlab.net (ip6-localhost [IPv6:::1]) by ns207790.ip-94-23-215.eu (Postfix) with ESMTP id 88F365FD99 for ; Fri, 8 Feb 2019 17:37:27 +0100 (CET) From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= To: qemu-devel@nongnu.org Date: Fri, 8 Feb 2019 18:37:27 +0200 Message-Id: <20190208163727.13733-1-remi@remlab.net> X-Mailer: git-send-email 2.20.1 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: 2001:41d0:2:5a1a:: Subject: [Qemu-devel] [PATCH] tcg: assert last byte is in guest space 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Rather than assert that the first byte of a checked range is within the guest address space, assert that the last byte is. The assertion is moved past the overflow check to ensure that the last byte is actually the one with the highest address. Signed-off-by: R=C3=A9mi Denis-Courmont --- accel/tcg/translate-all.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 8f593b926f..ea0c96af71 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -2515,13 +2515,6 @@ int page_check_range(target_ulong start, target_ulon= g len, int flags) target_ulong end; target_ulong addr; =20 - /* This function should never be called with addresses outside the - guest address space. If this assert fires, it probably indicates - a missing call to h2g_valid. */ -#if TARGET_ABI_BITS > L1_MAP_ADDR_SPACE_BITS - assert(start < ((target_ulong)1 << L1_MAP_ADDR_SPACE_BITS)); -#endif - if (len =3D=3D 0) { return 0; } @@ -2530,6 +2523,13 @@ int page_check_range(target_ulong start, target_ulon= g len, int flags) return -1; } =20 + /* This function should never be called with addresses outside the + guest address space. If this assert fires, it probably indicates + a missing call to h2g_valid. */ +#if TARGET_ABI_BITS > L1_MAP_ADDR_SPACE_BITS + assert((start + len - 1) < ((target_ulong)1 << L1_MAP_ADDR_SPACE_BITS)= ); +#endif + /* must do before we loose bits in the next step */ end =3D TARGET_PAGE_ALIGN(start + len); start =3D start & TARGET_PAGE_MASK; --=20 2.20.1