From patchwork Fri Jun 15 19:43:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 10467537 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1844060348 for ; Fri, 15 Jun 2018 20:01:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 06B1428511 for ; Fri, 15 Jun 2018 20:01:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EF950285EE; Fri, 15 Jun 2018 20:01:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8401328511 for ; Fri, 15 Jun 2018 20:01:39 +0000 (UTC) Received: from localhost ([::1]:49048 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTuug-0005HG-Gs for patchwork-qemu-devel@patchwork.kernel.org; Fri, 15 Jun 2018 16:01:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51595) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTudw-0000Ql-QD for qemu-devel@nongnu.org; Fri, 15 Jun 2018 15:44:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fTudv-0002YA-Oe for qemu-devel@nongnu.org; Fri, 15 Jun 2018 15:44:20 -0400 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]:45856) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fTudv-0002Xv-I3 for qemu-devel@nongnu.org; Fri, 15 Jun 2018 15:44:19 -0400 Received: by mail-pf0-x243.google.com with SMTP id a22-v6so5321841pfo.12 for ; Fri, 15 Jun 2018 12:44:19 -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=ShUlIMM0KTqpBxnqZKpmUtzBtiivBcjvXZG919nAn2g=; b=hzSrR46mvfqF17i20lCdDa7GnPxu9G9ym7CsFtKfG2r1YK99SdkEwJroBagYNPb4YS PV0A3ucl8lZod8TbHFXLVb9oOfYXy1FLWj8EuQ1NiTy3xUCWh2XHKZd1FOXW7bdxGT2T PAs4zBl2E1n4FT0kxc25LyU4yjHvTW1+MjAu8= 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=ShUlIMM0KTqpBxnqZKpmUtzBtiivBcjvXZG919nAn2g=; b=eDJA/rmXvPhrJ+b2lk0CQcP9onfXrvDt0dRSbwiR/D2kj/UuclB/8Ydpc/zF1i6OG0 75ABLX7j1brJxn1T0D86xwkc3ZGhQFffKJrrK4WxTiB07VlM06m+2m3JyEUL7v2Xk/ay tzeGXVh5b4vvZIIvwAy7VzC9fudk8GYoJwZ47Vwjmwdrb4DwIEFZL1vyEfAlrZKU3pgf DO2fWk6lYh8OWRgyDpwSg2EusQspqUOYhk7PUaZU34wSk3jHtZr+e1dvqiLXm4R4moi4 uQ6hCnDgzUZkj1oVoDZRdEX2h+SazNKOBDGRAAxFrFH3ukIyf631LtaY6wjUUM8Flyt7 BxWQ== X-Gm-Message-State: APt69E1ymx1I87PFUtxB23dVQ9EzbPt+taGBjyc/kRe5VxLOEPxz0lzP GQC9maUs2Uqlk/uPW2rUddnsxqlNv1o= X-Google-Smtp-Source: ADUXVKJny5yxu42pHmrVt14Q61VkkGPaqnYq0ykeSA2VT/tB6MwsGLa1K/yAvcEO3W2rduHV8klIbQ== X-Received: by 2002:a62:8a83:: with SMTP id o3-v6mr3424471pfk.12.1529091858272; Fri, 15 Jun 2018 12:44:18 -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.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 Jun 2018 12:44:17 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 15 Jun 2018 09:43:45 -1000 Message-Id: <20180615194354.12489-11-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:c00::243 Subject: [Qemu-devel] [PULL v2 10/19] translate-all: move tb_invalidate_phys_page_range up in the file 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: "Emilio G. Cota" This greatly simplifies next commit's diff. 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 | 77 ++++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 38 deletions(-) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index f32904d4a3..83bb40fb20 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -1363,44 +1363,6 @@ TranslationBlock *tb_gen_code(CPUState *cpu, return tb; } -/* - * Invalidate all TBs which intersect with the target physical address range - * [start;end[. NOTE: start and end may refer to *different* physical pages. - * 'is_cpu_write_access' should be true if called from a real cpu write - * access: the virtual CPU will exit the current TB if code is modified inside - * this TB. - * - * Called with mmap_lock held for user-mode emulation, grabs tb_lock - * Called with tb_lock held for system-mode emulation - */ -static void tb_invalidate_phys_range_1(tb_page_addr_t start, tb_page_addr_t end) -{ - 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); - } -} - -#ifdef CONFIG_SOFTMMU -void tb_invalidate_phys_range(tb_page_addr_t start, tb_page_addr_t end) -{ - assert_tb_locked(); - tb_invalidate_phys_range_1(start, end); -} -#else -void tb_invalidate_phys_range(tb_page_addr_t start, tb_page_addr_t end) -{ - assert_memory_lock(); - tb_lock(); - tb_invalidate_phys_range_1(start, end); - tb_unlock(); -} -#endif /* * Invalidate all TBs which intersect with the target physical address range * [start;end[. NOTE: start and end must refer to the *same* physical page. @@ -1500,6 +1462,45 @@ void tb_invalidate_phys_page_range(tb_page_addr_t start, tb_page_addr_t end, #endif } +/* + * Invalidate all TBs which intersect with the target physical address range + * [start;end[. NOTE: start and end may refer to *different* physical pages. + * 'is_cpu_write_access' should be true if called from a real cpu write + * access: the virtual CPU will exit the current TB if code is modified inside + * this TB. + * + * Called with mmap_lock held for user-mode emulation, grabs tb_lock + * Called with tb_lock held for system-mode emulation + */ +static void tb_invalidate_phys_range_1(tb_page_addr_t start, tb_page_addr_t end) +{ + 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); + } +} + +#ifdef CONFIG_SOFTMMU +void tb_invalidate_phys_range(tb_page_addr_t start, tb_page_addr_t end) +{ + assert_tb_locked(); + tb_invalidate_phys_range_1(start, end); +} +#else +void tb_invalidate_phys_range(tb_page_addr_t start, tb_page_addr_t end) +{ + assert_memory_lock(); + tb_lock(); + tb_invalidate_phys_range_1(start, end); + tb_unlock(); +} +#endif + #ifdef CONFIG_SOFTMMU /* len must be <= 8 and start must be a multiple of len. * Called via softmmu_template.h when code areas are written to with