From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58563) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5yGk-0006ZG-Az for qemu-devel@nongnu.org; Thu, 26 May 2016 12:36:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b5yGf-0003m5-Kq for qemu-devel@nongnu.org; Thu, 26 May 2016 12:36:22 -0400 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:35552) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5yGf-0003ly-E8 for qemu-devel@nongnu.org; Thu, 26 May 2016 12:36:17 -0400 Received: by mail-wm0-x244.google.com with SMTP id e3so7003931wme.2 for ; Thu, 26 May 2016 09:36:17 -0700 (PDT) From: Alvise Rigo Date: Thu, 26 May 2016 18:35:45 +0200 Message-Id: <20160526163549.3276-7-a.rigo@virtualopensystems.com> In-Reply-To: <20160526163549.3276-1-a.rigo@virtualopensystems.com> References: <20160526163549.3276-1-a.rigo@virtualopensystems.com> Subject: [Qemu-devel] [RFC 06/10] cputlb: Add tlb_tables_flush_bitmap() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: mttcg@listserver.greensocs.com, alex.bennee@linaro.org Cc: qemu-devel@nongnu.org, jani.kokkonen@huawei.com, claudio.fontana@huawei.com, tech@virtualopensystems.com, fred.konrad@greensocs.com, pbonzini@redhat.com, rth@twiddle.net, serge.fdrv@gmail.com, cota@braap.org, peter.maydell@linaro.org, Alvise Rigo Add a simple helper function to flush the TLB at the indexes specified by a bitmap. The function will be more useful in the following patches, when it will be possible to query tlb_flush_by_mmuidx() to VCPUs. Signed-off-by: Alvise Rigo --- cputlb.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/cputlb.c b/cputlb.c index 55f7447..5bbbf1b 100644 --- a/cputlb.c +++ b/cputlb.c @@ -129,15 +129,34 @@ void tlb_flush(CPUState *cpu, int flush_global) } } -static inline void v_tlb_flush_by_mmuidx(CPUState *cpu, va_list argp) +/* Flush tlb_table[] and tlb_v_table[] of @cpu at MMU indexes given by @bitmap. + * Flush also tb_jmp_cache. */ +static inline void tlb_tables_flush_bitmap(CPUState *cpu, unsigned long *bitmap) { - CPUArchState *env = cpu->env_ptr; + int mmu_idx; tlb_debug("start\n"); /* must reset current TB so that interrupts cannot modify the links while we are modifying them */ cpu->current_tb = NULL; + for (mmu_idx = 0; mmu_idx < NB_MMU_MODES; mmu_idx++) { + if (test_bit(mmu_idx, bitmap)) { + CPUArchState *env = cpu->env_ptr; + + tlb_debug("%d\n", mmu_idx); + + memset(env->tlb_table[mmu_idx], -1, sizeof(env->tlb_table[0])); + memset(env->tlb_v_table[mmu_idx], -1, sizeof(env->tlb_v_table[0])); + } + } + memset(cpu->tb_jmp_cache, 0, sizeof(cpu->tb_jmp_cache)); +} + +static inline void v_tlb_flush_by_mmuidx(CPUState *cpu, va_list argp) +{ + DECLARE_BITMAP(idxmap, NB_MMU_MODES) = { 0 }; + for (;;) { int mmu_idx = va_arg(argp, int); @@ -145,13 +164,10 @@ static inline void v_tlb_flush_by_mmuidx(CPUState *cpu, va_list argp) break; } - tlb_debug("%d\n", mmu_idx); - - memset(env->tlb_table[mmu_idx], -1, sizeof(env->tlb_table[0])); - memset(env->tlb_v_table[mmu_idx], -1, sizeof(env->tlb_v_table[0])); + set_bit(mmu_idx, idxmap); } - memset(cpu->tb_jmp_cache, 0, sizeof(cpu->tb_jmp_cache)); + tlb_tables_flush_bitmap(cpu, idxmap); } void tlb_flush_by_mmuidx(CPUState *cpu, ...) -- 2.8.3