From nobody Tue Feb 10 15:28:39 2026 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; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1529005399124360.913800564554; Thu, 14 Jun 2018 12:43:19 -0700 (PDT) Received: from localhost ([::1]:42382 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTY9L-0007BZ-Aj for importer@patchew.org; Thu, 14 Jun 2018 15:43:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36975) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTXyd-00071B-1o for qemu-devel@nongnu.org; Thu, 14 Jun 2018 15:32:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fTXyb-0005pU-Tc for qemu-devel@nongnu.org; Thu, 14 Jun 2018 15:32:10 -0400 Received: from mail-pg0-x232.google.com ([2607:f8b0:400e:c05::232]:44099) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fTXyb-0005ol-NG for qemu-devel@nongnu.org; Thu, 14 Jun 2018 15:32:09 -0400 Received: by mail-pg0-x232.google.com with SMTP id p21-v6so3354716pgd.11 for ; Thu, 14 Jun 2018 12:32:09 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id x24-v6sm11532184pfj.104.2018.06.14.12.32.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 14 Jun 2018 12:32:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Wexsdf6RCRL9p3KT+WfakrG7waRhQx2Db6LZYDP544g=; b=a9np+/ixxS+/jL4/AphXpNTu7XSPCqNuE+JT0rbqg9vJvpIzPcmkMwg8ANaWTksXyt 3/6t5L1d4u4QaU+FRXwb9uKh88UqVgmGV9EABKXk+FCbp57HwrClsRhUdaAmjVcFkK4X /NVZw68ivbZsKeyJgZRbXCpc1S7zmwKEk3MGU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Wexsdf6RCRL9p3KT+WfakrG7waRhQx2Db6LZYDP544g=; b=U82Bke+fU6S5bKrc3QMk1vv2HsDa/NT48OzQS+t+RcNU2p8HKIJn7F6az0+9e4npKt 6xZDZDL9/Q0R6N6ixzob6eODIDUpCzyXoL9Hpb8bbHFVeYvLWEALgKaJNtqq7PhOwRgQ dEtO6FBKkHsclkEW97OwhYtEkXVci2fho5rnsTLKs26iDLLvDxXmlsXBfZqCv5y9B3fp R+PoNXq0l+icoewTDkQH25BIbOsEdRfe9hIW40cK6YWvhzw8Uebu4wb0gIhMJ1V9d4AP 7X72RAysONTzRwBDwmm1PaAkIHjRbLZ87pIHiNj5gsk9Bo61qfs828GN99MSh8y4lH6P cbAA== X-Gm-Message-State: APt69E0AEgMarMfnhBuhijFg+g5Ylx1e7xKKd6jjaHAViWgp/XFfKekI CuUOq0OoEZhshvH5Wq2lsSRAhvL1hpE= X-Google-Smtp-Source: ADUXVKJOogYVxfEXbhzrcAhx/gD9WKA6RMegJYjh20kP/Ps/gBuQKEhkrnZUSrxm6cfqkRv7hN3KxA== X-Received: by 2002:a62:c8a:: with SMTP id 10-v6mr10749076pfm.27.1529004728406; Thu, 14 Jun 2018 12:32:08 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 14 Jun 2018 09:31:38 -1000 Message-Id: <20180614193147.29680-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180614193147.29680-1-richard.henderson@linaro.org> References: <20180614193147.29680-1-richard.henderson@linaro.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: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::232 Subject: [Qemu-devel] [PULL 09/18] 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: peter.maydell@linaro.org, "Emilio G. Cota" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 From: "Emilio G. Cota" 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 Signed-off-by: Richard Henderson --- 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 b9c36a3e45..f32904d4a3 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -1375,10 +1375,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.17.1