|
23 | 23 | #include "exec/exec-all.h"
|
24 | 24 | #include "exec/cpu_ldst.h"
|
25 | 25 | #include "exec/plugin-gen.h"
|
| 26 | +#include "exec/translate-all.h" |
26 | 27 | #include "tcg/tcg.h"
|
27 | 28 |
|
28 | 29 |
|
@@ -74,6 +75,17 @@ typedef struct DisasContextBase {
|
74 | 75 | int num_insns;
|
75 | 76 | int max_insns;
|
76 | 77 | bool singlestep_enabled;
|
| 78 | +#ifdef CONFIG_USER_ONLY |
| 79 | + /* |
| 80 | + * Guest address of the last byte of the last protected page. |
| 81 | + * |
| 82 | + * Pages containing the translated instructions are made non-writable in |
| 83 | + * order to achieve consistency in case another thread is modifying the |
| 84 | + * code while translate_insn() fetches the instruction bytes piecemeal. |
| 85 | + * Such writer threads are blocked on mmap_lock() in page_unprotect(). |
| 86 | + */ |
| 87 | + target_ulong page_protect_end; |
| 88 | +#endif |
77 | 89 | } DisasContextBase;
|
78 | 90 |
|
79 | 91 | /**
|
@@ -156,27 +168,23 @@ bool translator_use_goto_tb(DisasContextBase *db, target_ulong dest);
|
156 | 168 | */
|
157 | 169 |
|
158 | 170 | #define GEN_TRANSLATOR_LD(fullname, type, load_fn, swap_fn) \
|
159 |
| - static inline type \ |
160 |
| - fullname ## _swap(CPUArchState *env, abi_ptr pc, bool do_swap) \ |
| 171 | + type fullname ## _swap(CPUArchState *env, DisasContextBase *dcbase, \ |
| 172 | + abi_ptr pc, bool do_swap); \ |
| 173 | + static inline type fullname(CPUArchState *env, \ |
| 174 | + DisasContextBase *dcbase, abi_ptr pc) \ |
161 | 175 | { \
|
162 |
| - type ret = load_fn(env, pc); \ |
163 |
| - if (do_swap) { \ |
164 |
| - ret = swap_fn(ret); \ |
165 |
| - } \ |
166 |
| - plugin_insn_append(&ret, sizeof(ret)); \ |
167 |
| - return ret; \ |
168 |
| - } \ |
169 |
| - \ |
170 |
| - static inline type fullname(CPUArchState *env, abi_ptr pc) \ |
171 |
| - { \ |
172 |
| - return fullname ## _swap(env, pc, false); \ |
| 176 | + return fullname ## _swap(env, dcbase, pc, false); \ |
173 | 177 | }
|
174 | 178 |
|
175 |
| -GEN_TRANSLATOR_LD(translator_ldub, uint8_t, cpu_ldub_code, /* no swap */) |
176 |
| -GEN_TRANSLATOR_LD(translator_ldsw, int16_t, cpu_ldsw_code, bswap16) |
177 |
| -GEN_TRANSLATOR_LD(translator_lduw, uint16_t, cpu_lduw_code, bswap16) |
178 |
| -GEN_TRANSLATOR_LD(translator_ldl, uint32_t, cpu_ldl_code, bswap32) |
179 |
| -GEN_TRANSLATOR_LD(translator_ldq, uint64_t, cpu_ldq_code, bswap64) |
| 179 | +#define FOR_EACH_TRANSLATOR_LD(F) \ |
| 180 | + F(translator_ldub, uint8_t, cpu_ldub_code, /* no swap */) \ |
| 181 | + F(translator_ldsw, int16_t, cpu_ldsw_code, bswap16) \ |
| 182 | + F(translator_lduw, uint16_t, cpu_lduw_code, bswap16) \ |
| 183 | + F(translator_ldl, uint32_t, cpu_ldl_code, bswap32) \ |
| 184 | + F(translator_ldq, uint64_t, cpu_ldq_code, bswap64) |
| 185 | + |
| 186 | +FOR_EACH_TRANSLATOR_LD(GEN_TRANSLATOR_LD) |
| 187 | + |
180 | 188 | #undef GEN_TRANSLATOR_LD
|
181 | 189 |
|
182 | 190 | #endif /* EXEC__TRANSLATOR_H */
|
0 commit comments