accel/tcg/cputlb.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
To ease code review, factor range_within_page() out.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
accel/tcg/cputlb.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c
index b6713efdb81..91d185021a4 100644
--- a/accel/tcg/cputlb.c
+++ b/accel/tcg/cputlb.c
@@ -657,6 +657,11 @@ void tlb_flush_page_all_cpus_synced(CPUState *src, vaddr addr)
tlb_flush_page_by_mmuidx_all_cpus_synced(src, addr, ALL_MMUIDX_BITS);
}
+static bool range_within_page(const CPUState *cpu, unsigned bits, vaddr len)
+{
+ return bits >= TARGET_LONG_BITS && len <= TARGET_PAGE_SIZE;
+}
+
static void tlb_flush_range_locked(CPUState *cpu, int midx,
vaddr addr, vaddr len,
unsigned bits)
@@ -772,7 +777,7 @@ void tlb_flush_range_by_mmuidx(CPUState *cpu, vaddr addr,
* If all bits are significant, and len is small,
* this devolves to tlb_flush_page.
*/
- if (bits >= TARGET_LONG_BITS && len <= TARGET_PAGE_SIZE) {
+ if (range_within_page(cpu, bits, len)) {
tlb_flush_page_by_mmuidx(cpu, addr, idxmap);
return;
}
@@ -810,7 +815,7 @@ void tlb_flush_range_by_mmuidx_all_cpus_synced(CPUState *src_cpu,
* If all bits are significant, and len is small,
* this devolves to tlb_flush_page.
*/
- if (bits >= TARGET_LONG_BITS && len <= TARGET_PAGE_SIZE) {
+ if (range_within_page(src_cpu, bits, len)) {
tlb_flush_page_by_mmuidx_all_cpus_synced(src_cpu, addr, idxmap);
return;
}
--
2.47.1
On 3/23/25 15:53, Philippe Mathieu-Daudé wrote: > @@ -772,7 +777,7 @@ void tlb_flush_range_by_mmuidx(CPUState *cpu, vaddr addr, > * If all bits are significant, and len is small, > * this devolves to tlb_flush_page. > */ > - if (bits >= TARGET_LONG_BITS && len <= TARGET_PAGE_SIZE) { > + if (range_within_page(cpu, bits, len)) { > tlb_flush_page_by_mmuidx(cpu, addr, idxmap); > return; > } > @@ -810,7 +815,7 @@ void tlb_flush_range_by_mmuidx_all_cpus_synced(CPUState *src_cpu, > * If all bits are significant, and len is small, > * this devolves to tlb_flush_page. > */ > - if (bits >= TARGET_LONG_BITS && len <= TARGET_PAGE_SIZE) { > + if (range_within_page(src_cpu, bits, len)) { > tlb_flush_page_by_mmuidx_all_cpus_synced(src_cpu, addr, idxmap); > return; > } Better would be to swap the two if's in these functions: if (bits < TARGET_LONG_BITS) { } if (len <= TARGET_PAGE_SIZE) { } at which point you don't need a helper to simplify. r~
© 2016 - 2025 Red Hat, Inc.