From patchwork Fri Jun 15 19:43:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138767 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp1255120lji; Fri, 15 Jun 2018 12:56:52 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIuLYl9Wj4CApwCj+e0BWZuYSSJv3MYY7zJdCLdwhX0IYwHyrfYm88Hq5MT6/Tvi4bqYq3q X-Received: by 2002:a37:b603:: with SMTP id g3-v6mr2693713qkf.208.1529092612754; Fri, 15 Jun 2018 12:56:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529092612; cv=none; d=google.com; s=arc-20160816; b=fy5K0Bc5T1P0GsXcXza2oL7dc9erC4o+rDQ4rvgxW9ev41rLbpgKcP/9zq4Ly1vZf+ oXKS301aIS3fgJ+aTGzLkPwcFuDbyRPAMWPuokaqccO0ZMIENbtyVMNd6RXef4KLl6pG eJn+FDSSJUK2tOMqBov8tau8pkSoVvgWH87iT6UQG+wAjZZphuiEsepno7ardZzX4tIq Gw127NS4EoUm97QfwgCXnQjdVFs87QAOU1ryxK9601LhTiJiIX6m20omWjh88kSTmC3A zHwH+mKV1GIIM2502cQrAyrIMHGEg5r9dJsaxif5fE5F94qkhKkMxR722enkqv85dmu0 Ohpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=Wexsdf6RCRL9p3KT+WfakrG7waRhQx2Db6LZYDP544g=; b=F8Tw0a3FIj7HvSbvuVktH2RoDrBXgt0zyRxvrRU7ec7D5Qv1iqcekZ6mxbvFc7hAxE 7Efzmr2/FXhusNU8uWBtImq+Z+OuclKZzoxubENEEY5p3hVmKWOBZyAljCmffxuOH8Kh BMLpxSqIpjEir8EedE8p77IzeDb6U5HdBvpevTMJgmCN3VGLD3mx6/99gSwfOQeeX0PG AFBMRHXwEtgpulQejtH4d35CJGoUgxDt2X7EfOqR5qpYUl5uHDJvWzmZfzN96xH/PtEN p8IhwEaWSG1HxYoayyqCfx+K6bfjjEOWFIYtIv1vKaBDKeQxM3dkEnIfV/V8YWw702fk a7UA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Iuk9ZE3E; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id i58-v6si1581983qti.134.2018.06.15.12.56.52 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 15 Jun 2018 12:56:52 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Iuk9ZE3E; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:49019 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTuq4-0001ft-8u for patch@linaro.org; Fri, 15 Jun 2018 15:56:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51579) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTudv-0000Ow-0a for qemu-devel@nongnu.org; Fri, 15 Jun 2018 15:44:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fTudt-0002Wz-UK for qemu-devel@nongnu.org; Fri, 15 Jun 2018 15:44:19 -0400 Received: from mail-pl0-x22a.google.com ([2607:f8b0:400e:c01::22a]:33307) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fTudt-0002WS-Oa for qemu-devel@nongnu.org; Fri, 15 Jun 2018 15:44:17 -0400 Received: by mail-pl0-x22a.google.com with SMTP id 6-v6so5312755plb.0 for ; Fri, 15 Jun 2018 12:44:17 -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=Iuk9ZE3EDSVu2etBCW3lyy9zANN38sQmYghkrev9scXgob7smDg3yvrRe6S+OOh4Hf XPOkQKt/mcbiCdhrUAguqxTwzGydKq7zYZg/8bve/squdE4TCvwwHMz6b1fY0GhWirZq 7bbFnMjJn57lQM5wpGT96OfiFTl8DHucrbFbw= 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=nvHCmxidHhSGrpXDKrnxADxDwJzWdKU8t3QrzZot9/RsRjLLoIPLb9rgsW5q28LylU xImkCSR6OzFsq2/77kzkd+Dx+UPPL0ErU1auE9pcwI/8jBkJ7a9b/UzQZoeMwcq289Fk rU2GflFFLXeAM9pj78crAbiAJF+uwl+2nEo0YjqWAdxwHThWz/WWma07Bg8mtB6d24Ao Ddc3ZF0NL+owztB9R4N5CdGSUFJwbesXQ1I22VRq2oX978PJBqTw+5lFSLHkU6o8YBhF 6By2fzhYAtm8SzQdsRflmk+A/eruiADrd8UajfdqZp1yM/N/1CpC4ZzfMlwMy69LKTox O46A== X-Gm-Message-State: APt69E3pKLLkRQhTnliGID6QgaWzMCZO2zBBROio2Fv4VX87BgMGW48M 556yp0kSE4PLLbOrb8W/eL7er6YWGgM= X-Received: by 2002:a17:902:748b:: with SMTP id h11-v6mr3553130pll.12.1529091856448; Fri, 15 Jun 2018 12:44:16 -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 29-v6sm14038360pfj.14.2018.06.15.12.44.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 Jun 2018 12:44:15 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 15 Jun 2018 09:43:44 -1000 Message-Id: <20180615194354.12489-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180615194354.12489-1-richard.henderson@linaro.org> References: <20180615194354.12489-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::22a Subject: [Qemu-devel] [PULL v2 09/19] 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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_range 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 range > * [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ée Signed-off-by: Emilio G. Cota Signed-off-by: Richard Henderson --- accel/tcg/translate-all.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) -- 2.17.1 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 &= TARGET_PAGE_MASK; - start += TARGET_PAGE_SIZE; + tb_page_addr_t next; + + for (next = (start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE; + start < end; + start = next, next += TARGET_PAGE_SIZE) { + tb_page_addr_t bound = MIN(next, end); + + tb_invalidate_phys_page_range(start, bound, 0); } }