qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

translator: Use cpu_ld*_code instead of open-coding

The DO_LOAD macros replicate the distinction already performed
by the cpu_ldst.h functions. Use them.

Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

+13 -46
-11
include/exec/cpu_ldst.h
··· 129 129 #include "exec/cpu_ldst_useronly_template.h" 130 130 #undef MEMSUFFIX 131 131 132 - /* 133 - * Code access is deprecated in favour of translator_ld* functions 134 - * (see translator.h). However there are still users that need to 135 - * converted so for now these stay. 136 - */ 137 132 #define MEMSUFFIX _code 138 133 #define CODE_ACCESS 139 134 #define DATA_SIZE 1 ··· 454 449 #include "exec/cpu_ldst_template.h" 455 450 #undef CPU_MMU_INDEX 456 451 #undef MEMSUFFIX 457 - 458 - /* 459 - * Code access is deprecated in favour of translator_ld* functions 460 - * (see translator.h). However there are still users that need to 461 - * converted so for now these stay. 462 - */ 463 452 464 453 #define CPU_MMU_INDEX (cpu_mmu_index(env, true)) 465 454 #define MEMSUFFIX _code
+13 -35
include/exec/translator.h
··· 148 148 /* 149 149 * Translator Load Functions 150 150 * 151 - * These are intended to replace the old cpu_ld*_code functions and 152 - * are mandatory for front-ends that have been migrated to the common 153 - * translator_loop. These functions are only intended to be called 154 - * from the translation stage and should not be called from helper 155 - * functions. Those functions should be converted to encode the 156 - * relevant information at translation time. 151 + * These are intended to replace the direct usage of the cpu_ld*_code 152 + * functions and are mandatory for front-ends that have been migrated 153 + * to the common translator_loop. These functions are only intended 154 + * to be called from the translation stage and should not be called 155 + * from helper functions. Those functions should be converted to encode 156 + * the relevant information at translation time. 157 157 */ 158 158 159 - #ifdef CONFIG_USER_ONLY 160 - 161 - #define DO_LOAD(type, name, shift) \ 162 - do { \ 163 - set_helper_retaddr(1); \ 164 - ret = name ## _p(g2h(pc)); \ 165 - clear_helper_retaddr(); \ 166 - } while (0) 167 - 168 - #else 169 - 170 - #define DO_LOAD(type, name, shift) \ 171 - do { \ 172 - int mmu_idx = cpu_mmu_index(env, true); \ 173 - TCGMemOpIdx oi = make_memop_idx(shift, mmu_idx); \ 174 - ret = helper_ret_ ## name ## _cmmu(env, pc, oi, 0); \ 175 - } while (0) 176 - 177 - #endif 178 - 179 - #define GEN_TRANSLATOR_LD(fullname, name, type, shift, swap_fn) \ 159 + #define GEN_TRANSLATOR_LD(fullname, type, load_fn, swap_fn) \ 180 160 static inline type \ 181 161 fullname ## _swap(CPUArchState *env, abi_ptr pc, bool do_swap) \ 182 162 { \ 183 - type ret; \ 184 - DO_LOAD(type, name, shift); \ 185 - \ 163 + type ret = load_fn(env, pc); \ 186 164 if (do_swap) { \ 187 165 ret = swap_fn(ret); \ 188 166 } \ ··· 195 173 return fullname ## _swap(env, pc, false); \ 196 174 } 197 175 198 - GEN_TRANSLATOR_LD(translator_ldub, ldub, uint8_t, 0, /* no swap */ ) 199 - GEN_TRANSLATOR_LD(translator_ldsw, ldsw, int16_t, 1, bswap16) 200 - GEN_TRANSLATOR_LD(translator_lduw, lduw, uint16_t, 1, bswap16) 201 - GEN_TRANSLATOR_LD(translator_ldl, ldl, uint32_t, 2, bswap32) 202 - GEN_TRANSLATOR_LD(translator_ldq, ldq, uint64_t, 3, bswap64) 176 + GEN_TRANSLATOR_LD(translator_ldub, uint8_t, cpu_ldub_code, /* no swap */) 177 + GEN_TRANSLATOR_LD(translator_ldsw, int16_t, cpu_ldsw_code, bswap16) 178 + GEN_TRANSLATOR_LD(translator_lduw, uint16_t, cpu_lduw_code, bswap16) 179 + GEN_TRANSLATOR_LD(translator_ldl, uint32_t, cpu_ldl_code, bswap32) 180 + GEN_TRANSLATOR_LD(translator_ldq, uint64_t, cpu_ldq_code, bswap64) 203 181 #undef GEN_TRANSLATOR_LD 204 182 205 183 #endif /* EXEC__TRANSLATOR_H */