From nobody Tue Oct 28 12:38:30 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1522981117549810.9847815279505; Thu, 5 Apr 2018 19:18:37 -0700 (PDT) Received: from localhost ([::1]:44014 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f4GxY-0006TX-N1 for importer@patchew.org; Thu, 05 Apr 2018 22:18:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58408) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f4GsL-0002G8-4K for qemu-devel@nongnu.org; Thu, 05 Apr 2018 22:13:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f4GsJ-0003Ut-DA for qemu-devel@nongnu.org; Thu, 05 Apr 2018 22:13:13 -0400 Received: from out5-smtp.messagingengine.com ([66.111.4.29]:48677) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f4GsJ-0003UL-7P for qemu-devel@nongnu.org; Thu, 05 Apr 2018 22:13:11 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id E1D4020B49; Thu, 5 Apr 2018 22:13:10 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Thu, 05 Apr 2018 22:13:10 -0400 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id A5D57E47F2; Thu, 5 Apr 2018 22:13:10 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=mesmtp; bh=DYQhoCXYz6knjCoh3M9zPNV5kv 7E18y5ZIFLZtuC7Pk=; b=2CJKoK4Up6AUH8hFMNsIoBZlGNv/+YZJlH2zp9dh3j CYtktSlbH1VI3BQCtbxoMQ4GBsNOCof6fBDdWBersHaNVcvi6AphnnBhMGdtPQW6 BEDmzFqrfd9iz+aUYgsvtt7gjCRUWsf0V9oNDc3HGh8+BJfyg1k9/4Fiso7tMlQ/ 0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=DYQhoC XYz6knjCoh3M9zPNV5kv7E18y5ZIFLZtuC7Pk=; b=E5hNzXbKpRKz2WD9WAifaT fg+uOC2/Ayp6JgTYUZ8kiSVw2nygzIFix/06Pc6q85XpPsmvHzY/zFUw7/3dmx36 s0EPJkI8JOXJuydIQmS9BCME8WzWJp8EZeE2sBaKBxTqZ3fclgEa1K/EfOBcz6dE VmBdP05mPENmiQZwet4mAp7gPjPIwCLBU2//agV+JAA4yP289NXDTZF9nRAV77bf 5EGt0O5TaI7ebBIkqIUBTWLnRwadxS6/CTifxB3X3XUolRbm22iX775D0lMn4KDH pst58/NIfyvGUfWUBhzLfK4CKv7YwUgFhZlgh1PyoJZFTBaFr60IzTknLGB9iiFw == X-ME-Sender: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Thu, 5 Apr 2018 22:12:59 -0400 Message-Id: <1522980788-1252-9-git-send-email-cota@braap.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1522980788-1252-1-git-send-email-cota@braap.org> References: <1522980788-1252-1-git-send-email-cota@braap.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.111.4.29 Subject: [Qemu-devel] [PATCH v2 08/17] translate-all: work page-by-page in tb_invalidate_phys_range_1 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: Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 So that we pass a same-page range to tb_invalidate_phys_page_range, instead of always passing an end address that could be on a different page. As discussed with Peter Maydell on the list [1], tb_invalidate_phys_page_ra= nge doesn't actually do much with 'end', which explains why we have never hit a bug despite going against what the comment on top of tb_invalidate_phys_page_range requires: > * Invalidate all TBs which intersect with the target physical address ran= ge > * [start;end[. NOTE: start and end must refer to the *same* physical page. The appended honours the comment, which avoids confusion. While at it, rework the loop into a for loop, which is less error prone (e.g. "continue" won't result in an infinite loop). [1] https://lists.gnu.org/archive/html/qemu-devel/2017-07/msg09165.html Reviewed-by: Richard Henderson Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Emilio G. Cota --- accel/tcg/translate-all.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 7c72354..b27aacc 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -1378,10 +1378,14 @@ TranslationBlock *tb_gen_code(CPUState *cpu, */ static void tb_invalidate_phys_range_1(tb_page_addr_t start, tb_page_addr_= t end) { - while (start < end) { - tb_invalidate_phys_page_range(start, end, 0); - start &=3D TARGET_PAGE_MASK; - start +=3D TARGET_PAGE_SIZE; + tb_page_addr_t next; + + for (next =3D (start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE; + start < end; + start =3D next, next +=3D TARGET_PAGE_SIZE) { + tb_page_addr_t bound =3D MIN(next, end); + + tb_invalidate_phys_page_range(start, bound, 0); } } =20 --=20 2.7.4