[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 46/52] tcg: Fix PAGE/PROT confusion
|
From: |
Richard Henderson |
|
Subject: |
[PATCH v2 46/52] tcg: Fix PAGE/PROT confusion |
|
Date: |
Tue, 23 May 2023 06:53:16 -0700 |
The bug was hidden because they happen to have the same values.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
tcg/region.c | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/tcg/region.c b/tcg/region.c
index 34ac124081..184e684b04 100644
--- a/tcg/region.c
+++ b/tcg/region.c
@@ -507,6 +507,14 @@ static int alloc_code_gen_buffer(size_t tb_size, int
splitwx, Error **errp)
return PROT_READ | PROT_WRITE;
}
#elif defined(_WIN32)
+/*
+ * Local source-level compatibility with Unix.
+ * Used by tcg_region_init below.
+ */
+#define PROT_READ 1
+#define PROT_WRITE 2
+#define PROT_EXEC 4
+
static int alloc_code_gen_buffer(size_t size, int splitwx, Error **errp)
{
void *buf;
@@ -527,7 +535,7 @@ static int alloc_code_gen_buffer(size_t size, int splitwx,
Error **errp)
region.start_aligned = buf;
region.total_size = size;
- return PAGE_READ | PAGE_WRITE | PAGE_EXEC;
+ return PROT_READ | PROT_WRITE | PROT_EXEC;
}
#else
static int alloc_code_gen_buffer_anon(size_t size, int prot,
@@ -796,10 +804,10 @@ void tcg_region_init(size_t tb_size, int splitwx,
unsigned max_cpus)
* buffer -- let that one use hugepages throughout.
* Work with the page protections set up with the initial mapping.
*/
- need_prot = PAGE_READ | PAGE_WRITE;
+ need_prot = PROT_READ | PROT_WRITE;
#ifndef CONFIG_TCG_INTERPRETER
if (tcg_splitwx_diff == 0) {
- need_prot |= PAGE_EXEC;
+ need_prot |= PROT_EXEC;
}
#endif
for (size_t i = 0, n = region.n; i < n; i++) {
@@ -809,9 +817,9 @@ void tcg_region_init(size_t tb_size, int splitwx, unsigned
max_cpus)
if (have_prot != need_prot) {
int rc;
- if (need_prot == (PAGE_READ | PAGE_WRITE | PAGE_EXEC)) {
+ if (need_prot == (PROT_READ | PROT_WRITE | PROT_EXEC)) {
rc = qemu_mprotect_rwx(start, end - start);
- } else if (need_prot == (PAGE_READ | PAGE_WRITE)) {
+ } else if (need_prot == (PROT_READ | PROT_WRITE)) {
rc = qemu_mprotect_rw(start, end - start);
} else {
g_assert_not_reached();
--
2.34.1
- [PATCH v2 38/52] accel/tcg: Introduce translator_io_start, (continued)
- [PATCH v2 38/52] accel/tcg: Introduce translator_io_start, Richard Henderson, 2023/05/23
- [PATCH v2 34/52] tcg: Remove USE_TCG_OPTIMIZATIONS, Richard Henderson, 2023/05/23
- [PATCH v2 41/52] target/mips: Tidy helpers for translation, Richard Henderson, 2023/05/23
- [PATCH v2 42/52] *: Add missing includes of exec/translation-block.h, Richard Henderson, 2023/05/23
- [PATCH v2 40/52] target/arm: Tidy helpers for translation, Richard Henderson, 2023/05/23
- [PATCH v2 45/52] tcg: Define IN_TCG, Richard Henderson, 2023/05/23
- [PATCH v2 46/52] tcg: Fix PAGE/PROT confusion,
Richard Henderson <=
- [PATCH v2 48/52] tcg: Remove target-specific headers from tcg.[ch], Richard Henderson, 2023/05/23
- [PATCH v2 52/52] tcg: Build once for system and once for user-only, Richard Henderson, 2023/05/23
- [PATCH v2 43/52] *: Add missing includes of exec/exec-all.h, Richard Henderson, 2023/05/23
- [PATCH v2 49/52] plugins: Move plugin_insn_append to translator.c, Richard Henderson, 2023/05/23
- [PATCH v2 50/52] plugins: Drop unused headers from exec/plugin-gen.h, Richard Henderson, 2023/05/23
- [PATCH v2 47/52] tcg: Move env defines out of NEED_CPU_H in helper-head.h, Richard Henderson, 2023/05/23
- [PATCH v2 51/52] exec/poison: Do not poison CONFIG_SOFTMMU, Richard Henderson, 2023/05/23
- [PATCH v2 44/52] accel/tcg: Tidy includes for translator.[ch], Richard Henderson, 2023/05/23