[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v1 5/9] cputlb: ensure we re-fill the TLB if it has reset
From: |
Alex Bennée |
Subject: |
[PATCH v1 5/9] cputlb: ensure we re-fill the TLB if it has reset |
Date: |
Tue, 2 Jun 2020 16:46:20 +0100 |
Any write to a device might cause a re-arrangement of memory
triggering a TLB flush and potential re-size of the TLB invalidating
previous entries. This would cause users of qemu_plugin_get_hwaddr()
to see the warning:
invalid use of qemu_plugin_get_hwaddr
because of the failed tlb_lookup which should always succeed. We catch
this case by checking to see if the list of entries has been cleared
and if so triggering a re-fill.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
accel/tcg/cputlb.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c
index eb2cf9de5e6..b7d329f7155 100644
--- a/accel/tcg/cputlb.c
+++ b/accel/tcg/cputlb.c
@@ -1091,6 +1091,20 @@ static void io_writex(CPUArchState *env, CPUIOTLBEntry
*iotlbentry,
MMU_DATA_STORE, mmu_idx, iotlbentry->attrs, r,
retaddr);
}
+
+ /*
+ * The memory_region_dispatch may have triggered a flush/resize
+ * so for plugins we need to ensure we have reset the tlb_entry
+ * so any later lookup is correct.
+ */
+#ifdef CONFIG_PLUGIN
+ if (env_tlb(env)->d[mmu_idx].n_used_entries == 0) {
+ int size = op & MO_SIZE;
+ tlb_fill(env_cpu(env), addr, size, MMU_DATA_STORE,
+ mmu_idx, retaddr);
+ }
+#endif
+
if (locked) {
qemu_mutex_unlock_iothread();
}
--
2.20.1
- [PATCH v1 0/9] plugins/next (bug fixes, hwprofile, lockstep), Alex Bennée, 2020/06/02
- [PATCH v1 2/9] qemu-plugin.h: add missing include <stddef.h> to define size_t, Alex Bennée, 2020/06/02
- [PATCH v1 3/9] scripts/clean-includes: Mark 'qemu/qemu-plugin.h' as special header, Alex Bennée, 2020/06/02
- [PATCH v1 1/9] plugins: new lockstep plugin for debugging TCG changes, Alex Bennée, 2020/06/02
- [PATCH v1 4/9] tests/plugin: correctly honour io_count, Alex Bennée, 2020/06/02
- [PATCH v1 5/9] cputlb: ensure we re-fill the TLB if it has reset,
Alex Bennée <=
- [PATCH v1 6/9] hw/virtio/pci: include vdev name in registered PCI sections, Alex Bennée, 2020/06/02
- [PATCH v1 7/9] plugins: add API to return a name for a IO device, Alex Bennée, 2020/06/02