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

target/xtensa: only rotate window in the retw helper

Move return address calculation and WINDOW_START adjustment out of the
retw helper to simplify logic a bit and avoid using registers directly.
Pass a0 as a parameter to the helper.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>

+10 -9
+1 -1
target/xtensa/helper.h
··· 7 7 DEF_HELPER_4(entry, void, env, i32, i32, i32) 8 8 DEF_HELPER_2(test_ill_retw, void, env, i32) 9 9 DEF_HELPER_2(test_underflow_retw, void, env, i32) 10 - DEF_HELPER_2(retw, i32, env, i32) 10 + DEF_HELPER_2(retw, void, env, i32) 11 11 DEF_HELPER_3(window_check, noreturn, env, i32, i32) 12 12 DEF_HELPER_1(restore_owb, void, env) 13 13 DEF_HELPER_2(movsp, void, env, i32)
+7 -2
target/xtensa/translate.c
··· 2227 2227 static void translate_retw(DisasContext *dc, const uint32_t arg[], 2228 2228 const uint32_t par[]) 2229 2229 { 2230 - TCGv_i32 tmp = tcg_const_i32(dc->pc); 2231 - gen_helper_retw(tmp, cpu_env, tmp); 2230 + TCGv_i32 tmp = tcg_const_i32(1); 2231 + tcg_gen_shl_i32(tmp, tmp, cpu_SR[WINDOW_BASE]); 2232 + tcg_gen_andc_i32(cpu_SR[WINDOW_START], 2233 + cpu_SR[WINDOW_START], tmp); 2234 + tcg_gen_movi_i32(tmp, dc->pc); 2235 + tcg_gen_deposit_i32(tmp, tmp, cpu_R[0], 0, 30); 2236 + gen_helper_retw(cpu_env, cpu_R[0]); 2232 2237 gen_jump(dc, tmp); 2233 2238 tcg_temp_free(tmp); 2234 2239 }
+2 -6
target/xtensa/win_helper.c
··· 184 184 } 185 185 } 186 186 187 - uint32_t HELPER(retw)(CPUXtensaState *env, uint32_t pc) 187 + void HELPER(retw)(CPUXtensaState *env, uint32_t a0) 188 188 { 189 - int n = (env->regs[0] >> 30) & 0x3; 190 - uint32_t windowbase = windowbase_bound(env->sregs[WINDOW_BASE], env); 191 - uint32_t ret_pc = (pc & 0xc0000000) | (env->regs[0] & 0x3fffffff); 189 + int n = (a0 >> 30) & 0x3; 192 190 193 191 xtensa_rotate_window(env, -n); 194 - env->sregs[WINDOW_START] &= ~windowstart_bit(windowbase, env); 195 - return ret_pc; 196 192 } 197 193 198 194 void xtensa_restore_owb(CPUXtensaState *env)