[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 20/34] tcg: Tidy split_cross_256mb
From: |
Richard Henderson |
Subject: |
[PULL 20/34] tcg: Tidy split_cross_256mb |
Date: |
Fri, 11 Jun 2021 16:41:30 -0700 |
Return output buffer and size via output pointer arguments,
rather than returning size via tcg_ctx->code_gen_buffer_size.
Reviewed-by: Luis Pires <luis.pires@eldorado.org.br>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
tcg/region.c | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/tcg/region.c b/tcg/region.c
index 037a01e4ed..445a278702 100644
--- a/tcg/region.c
+++ b/tcg/region.c
@@ -470,9 +470,10 @@ static inline bool cross_256mb(void *addr, size_t size)
/*
* We weren't able to allocate a buffer without crossing that boundary,
* so make do with the larger portion of the buffer that doesn't cross.
- * Returns the new base of the buffer, and adjusts code_gen_buffer_size.
+ * Returns the new base and size of the buffer in *obuf and *osize.
*/
-static inline void *split_cross_256mb(void *buf1, size_t size1)
+static inline void split_cross_256mb(void **obuf, size_t *osize,
+ void *buf1, size_t size1)
{
void *buf2 = (void *)(((uintptr_t)buf1 + size1) & ~0x0ffffffful);
size_t size2 = buf1 + size1 - buf2;
@@ -483,8 +484,8 @@ static inline void *split_cross_256mb(void *buf1, size_t
size1)
buf1 = buf2;
}
- tcg_ctx->code_gen_buffer_size = size1;
- return buf1;
+ *obuf = buf1;
+ *osize = size1;
}
#endif
@@ -514,12 +515,10 @@ static bool alloc_code_gen_buffer(size_t tb_size, int
splitwx, Error **errp)
if (size > tb_size) {
size = QEMU_ALIGN_DOWN(tb_size, qemu_real_host_page_size);
}
- tcg_ctx->code_gen_buffer_size = size;
#ifdef __mips__
if (cross_256mb(buf, size)) {
- buf = split_cross_256mb(buf, size);
- size = tcg_ctx->code_gen_buffer_size;
+ split_cross_256mb(&buf, &size, buf, size);
}
#endif
@@ -530,6 +529,7 @@ static bool alloc_code_gen_buffer(size_t tb_size, int
splitwx, Error **errp)
qemu_madvise(buf, size, QEMU_MADV_HUGEPAGE);
tcg_ctx->code_gen_buffer = buf;
+ tcg_ctx->code_gen_buffer_size = size;
return true;
}
#elif defined(_WIN32)
@@ -566,7 +566,6 @@ static bool alloc_code_gen_buffer_anon(size_t size, int
prot,
"allocate %zu bytes for jit buffer", size);
return false;
}
- tcg_ctx->code_gen_buffer_size = size;
#ifdef __mips__
if (cross_256mb(buf, size)) {
@@ -588,8 +587,7 @@ static bool alloc_code_gen_buffer_anon(size_t size, int
prot,
/* fallthru */
default:
/* Split the original buffer. Free the smaller half. */
- buf2 = split_cross_256mb(buf, size);
- size2 = tcg_ctx->code_gen_buffer_size;
+ split_cross_256mb(&buf2, &size2, buf, size);
if (buf == buf2) {
munmap(buf + size2, size - size2);
} else {
@@ -606,6 +604,7 @@ static bool alloc_code_gen_buffer_anon(size_t size, int
prot,
qemu_madvise(buf, size, QEMU_MADV_HUGEPAGE);
tcg_ctx->code_gen_buffer = buf;
+ tcg_ctx->code_gen_buffer_size = size;
return true;
}
--
2.25.1
- [PULL 19/34] tcg: Tidy tcg_n_regions, (continued)
- [PULL 19/34] tcg: Tidy tcg_n_regions, Richard Henderson, 2021/06/11
- [PULL 17/34] tcg: Replace region.end with region.total_size, Richard Henderson, 2021/06/11
- [PULL 21/34] tcg: Move in_code_gen_buffer and tests to region.c, Richard Henderson, 2021/06/11
- [PULL 23/34] tcg: Return the map protection from alloc_code_gen_buffer, Richard Henderson, 2021/06/11
- [PULL 13/34] accel/tcg: Use MiB in tcg_init_machine, Richard Henderson, 2021/06/11
- [PULL 26/34] tcg: Round the tb_size default from qemu_get_host_physmem, Richard Henderson, 2021/06/11
- [PULL 28/34] tcg: When allocating for !splitwx, begin with PROT_NONE, Richard Henderson, 2021/06/11
- [PULL 31/34] tcg: Fix documentation for tcg_constant_* vs tcg_temp_free_*, Richard Henderson, 2021/06/11
- [PULL 24/34] tcg: Sink qemu_madvise call to common code, Richard Henderson, 2021/06/11
- [PULL 22/34] tcg: Allocate code_gen_buffer into struct tcg_region_state, Richard Henderson, 2021/06/11
- [PULL 20/34] tcg: Tidy split_cross_256mb,
Richard Henderson <=
- [PULL 25/34] util/osdep: Add qemu_mprotect_rw, Richard Henderson, 2021/06/11
- [PULL 27/34] tcg: Merge buffer protection and guard page protection, Richard Henderson, 2021/06/11
- [PULL 29/34] tcg: Move tcg_init_ctx and tcg_ctx from accel/tcg/, Richard Henderson, 2021/06/11
- [PULL 32/34] tcg/arm: Fix tcg_out_op function signature, Richard Henderson, 2021/06/11
- [PULL 30/34] tcg: Introduce tcg_remove_ops_after, Richard Henderson, 2021/06/11
- [PULL 33/34] softfloat: Fix tp init in float32_exp2, Richard Henderson, 2021/06/11
- [PULL 34/34] docs/devel: Explain in more detail the TB chaining mechanisms, Richard Henderson, 2021/06/11
- Re: [PULL 00/34] tcg patch queue, Peter Maydell, 2021/06/13