From patchwork Thu Jun 14 19:31:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138621 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2529428lji; Thu, 14 Jun 2018 12:41:42 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLv99MarU3e6nSLprqh05IVRUgiUaeBGr1g5NHB9iwh+8/ADcP05h1Hnmk5NVcTIXopxdWR X-Received: by 2002:a37:ba47:: with SMTP id k68-v6mr3431512qkf.105.1529005302833; Thu, 14 Jun 2018 12:41:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529005302; cv=none; d=google.com; s=arc-20160816; b=DxD2xGwL/rCprddBqugviEffsflDSFxyGbsM2+RDF2KrHVcEvHYd+uLkR3tR5/hRra lraCnoRNpA2mZ7ZnimYzb0M66Ijtu23yX2h2xE0qWOM9TYBuqNCifmRnB5FMCZR5wuOC 82/FiKarUlK/wHioLt8H6AVs1Hm4tssrSjPIWAQUX1u0t6TSteQF+KNXmBSgILhdm1ei Aj88tFpSCU/YJ4W16LO1k55HHVpOVA4edIhMdcP4hGCEqTl5TGgyHaqhJpBH7c2agsX3 XwG4wuZabodm/bYYQHLgsfpuqdS8j2fwwXCJB12+dMWsVNfFqvhuWUQdlr7jEIUeygjh CErA== 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=K5M457Fpk0ASJWYJ9esshut0Qeo+01CqW1AFKzaugV67TRv/Vecil9qG1RPSvRjaJi 8sjMnDTtDG9FOwpPh+Pt7ha0KYR7VSrPXGmXKxkadF7oyKXf7bhw3Pj7MGN+Mrj6fwPp fjaSBxhHhQdZV1ne32iU+U6f6pMMQT18ZIR1cdyljDRa8PZ2EbK2DI064QdXSxlyUzJH nhp3PjMaK1C41uZdghFoKxZNnGZuZfBxfPmd7v5dthL1YQLDqH7sPY9Ft6Nf6bcyHN1E R4NPkJzZ5fzeqzOjoBR1Uz1BpPM86bardr4NFwfYucFJJwSK15k0VOvZUEASZUeCI4cM OhnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="a9np+/ix"; 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 k1-v6si2369356qtk.400.2018.06.14.12.41.42 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 14 Jun 2018 12:41:42 -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="a9np+/ix"; 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]:42376 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTY7q-00062v-6J for patch@linaro.org; Thu, 14 Jun 2018 15:41:42 -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) 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-Received: by 2002:a62:c8a:: with SMTP id 10-v6mr10749076pfm.27.1529004728406; Thu, 14 Jun 2018 12:32:08 -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) 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 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+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); } }