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

target/openrisc: Implement move to/from FPCSR

Reviewed-by: Stafford Horne <shorne@gmail.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

+38 -5
+1
target/openrisc/cpu.c
··· 55 55 cpu->env.sr = SR_FO | SR_SM; 56 56 cpu->env.lock_addr = -1; 57 57 s->exception_index = -1; 58 + cpu_set_fpcsr(&cpu->env, 0); 58 59 59 60 #ifndef CONFIG_USER_ONLY 60 61 cpu->env.picmr = 0x00000000;
+2
target/openrisc/cpu.h
··· 413 413 env->sr = (val & ~(SR_F | SR_CY | SR_OV)) | SR_FO; 414 414 } 415 415 416 + void cpu_set_fpcsr(CPUOpenRISCState *env, uint32_t val); 417 + 416 418 #define CPU_INTERRUPT_TIMER CPU_INTERRUPT_TGT_INT_0 417 419 418 420 #endif /* OPENRISC_CPU_H */
+13
target/openrisc/fpu_helper.c
··· 61 61 } 62 62 } 63 63 64 + void cpu_set_fpcsr(CPUOpenRISCState *env, uint32_t val) 65 + { 66 + static const int rm_to_sf[] = { 67 + float_round_nearest_even, 68 + float_round_to_zero, 69 + float_round_up, 70 + float_round_down 71 + }; 72 + 73 + env->fpcsr = val & 0x7ff; 74 + set_float_rounding_mode(rm_to_sf[extract32(val, 1, 2)], &env->fp_status); 75 + } 76 + 64 77 uint64_t HELPER(itofd)(CPUOpenRISCState *env, uint64_t val) 65 78 { 66 79 return int64_to_float64(val, &env->fp_status);
+11
target/openrisc/machine.c
··· 121 121 } 122 122 }; 123 123 124 + static int cpu_post_load(void *opaque, int version_id) 125 + { 126 + OpenRISCCPU *cpu = opaque; 127 + CPUOpenRISCState *env = &cpu->env; 128 + 129 + /* Update env->fp_status to match env->fpcsr. */ 130 + cpu_set_fpcsr(env, env->fpcsr); 131 + return 0; 132 + } 133 + 124 134 const VMStateDescription vmstate_openrisc_cpu = { 125 135 .name = "cpu", 126 136 .version_id = 1, 127 137 .minimum_version_id = 1, 138 + .post_load = cpu_post_load, 128 139 .fields = (VMStateField[]) { 129 140 VMSTATE_CPU(), 130 141 VMSTATE_STRUCT(env, OpenRISCCPU, 1, vmstate_env, CPUOpenRISCState),
+11 -5
target/openrisc/sys_helper.c
··· 37 37 CPUState *cs = env_cpu(env); 38 38 target_ulong mr; 39 39 int idx; 40 + #endif 40 41 41 42 switch (spr) { 43 + #ifndef CONFIG_USER_ONLY 42 44 case TO_SPR(0, 11): /* EVBAR */ 43 45 env->evbar = rb; 44 46 break; ··· 179 181 } 180 182 cpu_openrisc_timer_update(cpu); 181 183 break; 182 - default: 184 + #endif 185 + 186 + case TO_SPR(0, 20): /* FPCSR */ 187 + cpu_set_fpcsr(env, rb); 183 188 break; 184 189 } 185 - #endif 186 190 } 187 191 188 192 target_ulong HELPER(mfspr)(CPUOpenRISCState *env, target_ulong rd, ··· 193 197 OpenRISCCPU *cpu = env_archcpu(env); 194 198 CPUState *cs = env_cpu(env); 195 199 int idx; 200 + #endif 196 201 197 202 switch (spr) { 203 + #ifndef CONFIG_USER_ONLY 198 204 case TO_SPR(0, 0): /* VR */ 199 205 return env->vr; 200 206 ··· 303 309 case TO_SPR(10, 1): /* TTCR */ 304 310 cpu_openrisc_count_update(cpu); 305 311 return cpu_openrisc_count_get(cpu); 312 + #endif 306 313 307 - default: 308 - break; 314 + case TO_SPR(0, 20): /* FPCSR */ 315 + return env->fpcsr; 309 316 } 310 - #endif 311 317 312 318 /* for rd is passed in, if rd unchanged, just keep it back. */ 313 319 return rd;