[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC 06/10] cputlb: Add tlb_tables_flush_bitmap()
From: |
Alvise Rigo |
Subject: |
[Qemu-devel] [RFC 06/10] cputlb: Add tlb_tables_flush_bitmap() |
Date: |
Thu, 26 May 2016 18:35:45 +0200 |
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 <address@hidden>
---
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
- [Qemu-devel] [RFC 00/10] MTTCG: Slow-path for atomic insns, Alvise Rigo, 2016/05/26
- [Qemu-devel] [RFC 01/10] exec: Introduce tcg_exclusive_{lock, unlock}(), Alvise Rigo, 2016/05/26
- [Qemu-devel] [RFC 04/10] cputlb: Introduce tlb_flush_other(), Alvise Rigo, 2016/05/26
- [Qemu-devel] [RFC 03/10] cpus: Introduce async_wait_run_on_cpu(), Alvise Rigo, 2016/05/26
- [Qemu-devel] [RFC 02/10] softmmu_llsc_template.h: Move to multi-threading, Alvise Rigo, 2016/05/26
- [Qemu-devel] [RFC 05/10] target-arm: End TB after ldrex instruction, Alvise Rigo, 2016/05/26
- [Qemu-devel] [RFC 06/10] cputlb: Add tlb_tables_flush_bitmap(),
Alvise Rigo <=
- [Qemu-devel] [RFC 09/10] cputlb: Query tlb_flush_page_all, Alvise Rigo, 2016/05/26
- [Qemu-devel] [RFC 07/10] cputlb: Query tlb_flush_by_mmuidx, Alvise Rigo, 2016/05/26
- [Qemu-devel] [RFC 08/10] cputlb: Query tlb_flush_page_by_mmuidx, Alvise Rigo, 2016/05/26
- [Qemu-devel] [RFC 10/10] cpus: Do not sleep if some work item is pending, Alvise Rigo, 2016/05/26