From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33077) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZTfZ8-000711-7k for qemu-devel@nongnu.org; Sun, 23 Aug 2015 20:24:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZTfZ6-0000ma-9Z for qemu-devel@nongnu.org; Sun, 23 Aug 2015 20:24:46 -0400 Received: from out4-smtp.messagingengine.com ([66.111.4.28]:38639) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZTfZ6-0000mT-3k for qemu-devel@nongnu.org; Sun, 23 Aug 2015 20:24:44 -0400 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 01386209F3 for ; Sun, 23 Aug 2015 20:24:43 -0400 (EDT) From: "Emilio G. Cota" Date: Sun, 23 Aug 2015 20:24:00 -0400 Message-Id: <1440375847-17603-32-git-send-email-cota@braap.org> In-Reply-To: <1440375847-17603-1-git-send-email-cota@braap.org> References: <1440375847-17603-1-git-send-email-cota@braap.org> Subject: [Qemu-devel] [RFC 31/38] cpu: protect l1_map with tb_lock in full-system mode List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, mttcg@listserver.greensocs.com Cc: mark.burton@greensocs.com, a.rigo@virtualopensystems.com, guillaume.delbergue@greensocs.com, pbonzini@redhat.com, alex.bennee@linaro.org, Frederic Konrad Note that user-only uses mmap_lock for this. Signed-off-by: Emilio G. Cota --- translate-all.c | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/translate-all.c b/translate-all.c index e7b4a31..8f8c402 100644 --- a/translate-all.c +++ b/translate-all.c @@ -1203,8 +1203,9 @@ void tb_invalidate_phys_range(tb_page_addr_t start, tb_page_addr_t end) * Called with mmap_lock held for user-mode emulation * If called from generated code, iothread mutex must not be held. */ -void tb_invalidate_phys_page_range(tb_page_addr_t start, tb_page_addr_t end, - int is_cpu_write_access) +static void +tb_invalidate_phys_page_range_locked(tb_page_addr_t start, tb_page_addr_t end, + int is_cpu_write_access) { TranslationBlock *tb, *tb_next, *saved_tb; CPUState *cpu = current_cpu; @@ -1236,7 +1237,6 @@ void tb_invalidate_phys_page_range(tb_page_addr_t start, tb_page_addr_t end, /* we remove all the TBs in the range [start, end[ */ /* XXX: see if in some cases it could be faster to invalidate all the code */ - tb_lock(); tb = p->first_tb; while (tb != NULL) { n = (uintptr_t)tb & 3; @@ -1310,14 +1310,19 @@ void tb_invalidate_phys_page_range(tb_page_addr_t start, tb_page_addr_t end, cpu_resume_from_signal(cpu, NULL); } #endif +} + +void tb_invalidate_phys_page_range(tb_page_addr_t start, tb_page_addr_t end, + int is_cpu_write_access) +{ + tb_lock(); + tb_invalidate_phys_page_range_locked(start, end, is_cpu_write_access); tb_unlock(); } #ifdef CONFIG_SOFTMMU -/* len must be <= 8 and start must be a multiple of len. - * Called via softmmu_template.h, with iothread mutex not held. - */ -void tb_invalidate_phys_page_fast(tb_page_addr_t start, int len) + +static void tb_invalidate_phys_page_fast_locked(tb_page_addr_t start, int len) { PageDesc *p; @@ -1352,9 +1357,19 @@ void tb_invalidate_phys_page_fast(tb_page_addr_t start, int len) } } else { do_invalidate: - tb_invalidate_phys_page_range(start, start + len, 1); + tb_invalidate_phys_page_range_locked(start, start + len, 1); } } + +/* len must be <= 8 and start must be a multiple of len. + * Called via softmmu_template.h, with iothread mutex not held. + */ +void tb_invalidate_phys_page_fast(tb_page_addr_t start, int len) +{ + tb_lock(); + tb_invalidate_phys_page_fast_locked(start, len); + tb_unlock(); +} #else /* Called with mmap_lock held. */ static void tb_invalidate_phys_page(tb_page_addr_t addr, -- 1.9.1