[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 08/17] translate-all: work page-by-page in tb_inv
From: |
Emilio G. Cota |
Subject: |
[Qemu-devel] [PATCH v2 08/17] translate-all: work page-by-page in tb_invalidate_phys_range_1 |
Date: |
Thu, 5 Apr 2018 22:12:59 -0400 |
So that we pass a same-page range to tb_invalidate_phys_page_range,
instead of always passing an end address that could be on a different
page.
As discussed with Peter Maydell on the list [1], tb_invalidate_phys_page_range
doesn't actually do much with 'end', which explains why we have never
hit a bug despite going against what the comment on top of
tb_invalidate_phys_page_range requires:
> * Invalidate all TBs which intersect with the target physical address range
> * [start;end[. NOTE: start and end must refer to the *same* physical page.
The appended honours the comment, which avoids confusion.
While at it, rework the loop into a for loop, which is less error prone
(e.g. "continue" won't result in an infinite loop).
[1] https://lists.gnu.org/archive/html/qemu-devel/2017-07/msg09165.html
Reviewed-by: Richard Henderson <address@hidden>
Reviewed-by: Alex Bennée <address@hidden>
Signed-off-by: Emilio G. Cota <address@hidden>
---
accel/tcg/translate-all.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c
index 7c72354..b27aacc 100644
--- a/accel/tcg/translate-all.c
+++ b/accel/tcg/translate-all.c
@@ -1378,10 +1378,14 @@ TranslationBlock *tb_gen_code(CPUState *cpu,
*/
static void tb_invalidate_phys_range_1(tb_page_addr_t start, tb_page_addr_t
end)
{
- while (start < end) {
- tb_invalidate_phys_page_range(start, end, 0);
- start &= TARGET_PAGE_MASK;
- start += TARGET_PAGE_SIZE;
+ 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);
}
}
--
2.7.4
- [Qemu-devel] [PATCH v2 00/17] tcg: tb_lock_removal redux v2, Emilio G. Cota, 2018/04/05
- [Qemu-devel] [PATCH v2 06/17] translate-all: make l1_map lockless, Emilio G. Cota, 2018/04/05
- [Qemu-devel] [PATCH v2 11/17] translate-all: add page_locked assertions, Emilio G. Cota, 2018/04/05
- [Qemu-devel] [PATCH v2 02/17] qht: return existing entry when qht_insert fails, Emilio G. Cota, 2018/04/05
- [Qemu-devel] [PATCH v2 08/17] translate-all: work page-by-page in tb_invalidate_phys_range_1,
Emilio G. Cota <=
- [Qemu-devel] [PATCH v2 16/17] translate-all: remove tb_lock mention from cpu_restore_state_from_tb, Emilio G. Cota, 2018/04/05
- [Qemu-devel] [PATCH v2 13/17] translate-all: discard TB when tb_link_page returns an existing matching TB, Emilio G. Cota, 2018/04/05
- [Qemu-devel] [PATCH v2 01/17] qht: require a default comparison function, Emilio G. Cota, 2018/04/05
- [Qemu-devel] [PATCH v2 07/17] translate-all: remove hole in PageDesc, Emilio G. Cota, 2018/04/05
- [Qemu-devel] [PATCH v2 09/17] translate-all: move tb_invalidate_phys_page_range up in the file, Emilio G. Cota, 2018/04/05
- [Qemu-devel] [PATCH v2 04/17] tcg: move tb_ctx.tb_phys_invalidate_count to tcg_ctx, Emilio G. Cota, 2018/04/05
- [Qemu-devel] [PATCH v2 15/17] cputlb: remove tb_lock from tlb_flush functions, Emilio G. Cota, 2018/04/05