target-mips queue
Hi,
This pull request contains remaining change for 2.3 which was originally submitted before soft-freeze.
Thanks,
Leon
The following changes since commit 48412371415a260d00fc7fdcdb400da55f268828:
Merge remote-tracking branch 'remotes/ehabkost/tags/x86-pull-request' into staging (2015-03-11 11:12:35 +0000)
are available in the git repository at:
git://github.com/lalrae/qemu.git tags/mips-20150311
for you to fetch changes up to 644511117e7ca9f26d633a59c202a297113a796c:
target-mips: add missing MSACSR and restore fp_status and hflags (2015-03-11 14:13:57 +0000)
----------------------------------------------------------------
MIPS patches 2015-03-11
Changes:
* use VMStateDescription for MIPS CPU
----------------------------------------------------------------
Leon Alrae (2):
target-mips: replace cpu_save/cpu_load with VMStateDescription
target-mips: add missing MSACSR and restore fp_status and hflags
target-mips/cpu-qom.h | 4 + target-mips/cpu.c | 1 + target-mips/cpu.h | 19 +- target-mips/machine.c | 571 ++++++++++++++++++++----------------------- target-mips/msa_helper.c | 12 +- target-mips/translate_init.c | 10 +- 6 files changed, 288 insertions(+), 329 deletions(-)
[Qemu-devel] [PULL 2/2] target-mips: add missing MSACSR and restore fp_status and hflags
Save MSACSR state. Also remove fp_status, msa_fp_status, hflags and restore them in post_load() from the architectural registers.
Float exception flags are not present in vmstate. Information they carry is used only by softfloat caller who translates them into MIPS FCSR.Cause, FCSR.Flags and then they are cleared. Therefore there is no need for saving them in vmstate.
--- target-mips/cpu.h | 17 +++++++++++++++++ target-mips/machine.c | 34 ++++++++++++++++++++++++++-------- target-mips/msa_helper.c | 12 +----------- target-mips/translate_init.c | 10 ++-------- 4 files changed, 46 insertions(+), 27 deletions(-)
target-mips/cpu.h +17 -0
@@ -786,6 +786,23 @@ static inline void restore_flush_mode(CPUMIPSState *env) &env->active_fpu.fp_status); } +static inline void restore_fp_status (CPUMIPSState *env) +{ +restore_rounding_mode (env); +restore_flush_mode (env); +} + +static inline void restore_msa_fp_status (CPUMIPSState *env) +{ +float_status *status = &env->active_tc.msa_fp_status; +int rounding_mode = (env->active_tc.msacsr &MSACSR_RM_MASK ) >>MSACSR_RM ; +bool flush_to_zero = (env->active_tc.msacsr &MSACSR_FS_MASK ) !=0 ; + +set_float_rounding_mode (ieee_rm[rounding_mode], status); +set_flush_to_zero (flush_to_zero, status); +set_flush_inputs_to_zero (flush_to_zero, status); +} +static inline void cpu_get_tb_cpu_state (CPUMIPSState *env,target_ulong *pc,target_ulong *cs_base,int *flags) {
target-mips/machine.c +26 -8
@@ -2,19 +2,39 @@#include "cpu.h" +static int cpu_post_load (void *opaque,int version_id) +{ +MIPSCPU *cpu = opaque; +CPUMIPSState *env = &cpu->env; + +restore_fp_status (env); +restore_msa_fp_status (env); +compute_hflags (env); + +return 0 ; +} +/* FPU state */ static int get_fpr (QEMUFile *f,void *pv,size_t size) { +int i;fpr_t *v = pv; -qemu_get_be64s (f, &v->d); +/* Restore entire MSA vector register */ +for (i =0 ; i <MSA_WRLEN /64 ; i++) { +qemu_get_sbe64s (f, &v->wr.d[i]); + }return 0 ; }static void put_fpr (QEMUFile *f,void *pv,size_t size) { +int i;fpr_t *v = pv; -qemu_put_be64s (f, &v->d); +/* Save entire MSA vector register */ +for (i =0 ; i <MSA_WRLEN /64 ; i++) { +qemu_put_sbe64s (f, &v->wr.d[i]); + } }const VMStateInfo vmstate_info_fpr = {
@@ -31,9 +51,6 @@ const VMStateInfo vmstate_info_fpr = {static VMStateField vmstate_fpu_fields[] = {VMSTATE_FPR_ARRAY (fpr, CPUMIPSFPUContext,32 ), -VMSTATE_INT8 (fp_status.float_detect_tininess, CPUMIPSFPUContext), -VMSTATE_INT8 (fp_status.float_rounding_mode, CPUMIPSFPUContext), -VMSTATE_INT8 (fp_status.float_exception_flags, CPUMIPSFPUContext),VMSTATE_UINT32 (fcr0, CPUMIPSFPUContext),VMSTATE_UINT32 (fcr31, CPUMIPSFPUContext),VMSTATE_END_OF_LIST ()
@@ -70,6 +87,7 @@ static VMStateField vmstate_tc_fields[] = {VMSTATE_UINTTL (CP0_TCScheFBack, TCState),VMSTATE_INT32 (CP0_Debug_tcstatus, TCState),VMSTATE_UINTTL (CP0_UserLocal, TCState), +VMSTATE_INT32 (msacsr, TCState), VMSTATE_END_OF_LIST() };
@@ -183,8 +201,9 @@ const VMStateDescription vmstate_tlb = {const VMStateDescription vmstate_mips_cpu = { .name ="cpu" , - .version_id =5 , - .minimum_version_id =5 , + .version_id =6 , + .minimum_version_id =6 , + .post_load = cpu_post_load, .fields = (VMStateField []) {/* Active TC */ VMSTATE_STRUCT (env.active_tc,MIPSCPU ,1 , vmstate_tc, TCState),
@@ -205,7 +224,6 @@ const VMStateDescription vmstate_mips_cpu = {VMSTATE_UINT32 (env.current_tc,MIPSCPU ),VMSTATE_UINT32 (env.current_fpu,MIPSCPU ),VMSTATE_INT32 (env.error_code,MIPSCPU ), -VMSTATE_UINT32 (env.hflags,MIPSCPU ),VMSTATE_UINTTL (env.btarget,MIPSCPU ), VMSTATE_UINTTL(env.bcond, MIPSCPU),
target-mips/msa_helper.c +1 -11
@@ -1348,17 +1348,7 @@ void helper_msa_ctcmsa(CPUMIPSState *env, target_ulong elm, uint32_t cd)break ;case 1 : env->active_tc.msacsr = (int32_t )elm &MSACSR_MASK ; -/* set float_status rounding mode */ -set_float_rounding_mode ( - ieee_rm[(env->active_tc.msacsr &MSACSR_RM_MASK ) >>MSACSR_RM ], - &env->active_tc.msa_fp_status); -/* set float_status flush modes */ -set_flush_to_zero ( - (env->active_tc.msacsr &MSACSR_FS_MASK ) !=0 ?1 :0 , - &env->active_tc.msa_fp_status); -set_flush_inputs_to_zero ( - (env->active_tc.msacsr &MSACSR_FS_MASK ) !=0 ?1 :0 , - &env->active_tc.msa_fp_status); +restore_msa_fp_status (env);/* check exception */ if ((GET_FP_ENABLE (env->active_tc.msacsr) |FP_UNIMPLEMENTED ) &GET_FP_CAUSE (env->active_tc.msacsr)) {
target-mips/translate_init.c +2 -8
@@ -835,6 +835,8 @@ static void msa_reset(CPUMIPSState *env)- round to nearest / ties to even (RM bits are 0) */ env->active_tc.msacsr =0 ; +restore_msa_fp_status (env); +/* tininess detected after rounding.*/ set_float_detect_tininess (float_tininess_after_rounding, &env->active_tc.msa_fp_status);
@@ -842,14 +844,6 @@ static void msa_reset(CPUMIPSState *env)/* clear float_status exception flags */ set_float_exception_flags (0 , &env->active_tc.msa_fp_status); -/* set float_status rounding mode */ -set_float_rounding_mode (float_round_nearest_even, - &env->active_tc.msa_fp_status); - -/* set float_status flush modes */ -set_flush_to_zero (0 , &env->active_tc.msa_fp_status); -set_flush_inputs_to_zero (0 , &env->active_tc.msa_fp_status); -/* clear float_status nan mode */ set_default_nan_mode (0 , &env->active_tc.msa_fp_status); }
Signature · 1 line
2.1.0
[Qemu-devel] [PULL 1/2] target-mips: replace cpu_save/cpu_load with VMStateDescription
In reply to Leon AlraeCreate VMStateDescription for MIPS CPU. The new structure contains exactly the same fields as before, therefore leaving existing version_id.
--- target-mips/cpu-qom.h | 4 + target-mips/cpu.c | 1 + target-mips/cpu.h | 2 - target-mips/machine.c | 567 ++++++++++++++++++++++---------------------------- 4 files changed, 257 insertions(+), 317 deletions(-)
target-mips/cpu-qom.h +4 -0
@@ -74,6 +74,10 @@ static inline MIPSCPU *mips_env_get_cpu(CPUMIPSState *env)#define ENV_OFFSET offsetof(MIPSCPU, env) +#ifndef CONFIG_USER_ONLY +extern const struct VMStateDescription vmstate_mips_cpu; +#endif +void mips_cpu_do_interrupt (CPUState *cpu);bool mips_cpu_exec_interrupt (CPUState *cpu,int int_req); void mips_cpu_dump_state(CPUState *cpu, FILE *f, fprintf_function cpu_fprintf,
target-mips/cpu.c +1 -0
@@ -148,6 +148,7 @@ static void mips_cpu_class_init(ObjectClass *c, void *data) cc->do_unassigned_access = mips_cpu_unassigned_access; cc->do_unaligned_access = mips_cpu_do_unaligned_access; cc->get_phys_page_debug = mips_cpu_get_phys_page_debug; + cc->vmsd = &vmstate_mips_cpu;#endif cc->gdb_num_core_regs =73 ;
target-mips/cpu.h +0 -2
@@ -614,8 +614,6 @@ void mips_cpu_list (FILE *f, fprintf_function cpu_fprintf);extern void cpu_wrdsp (uint32_t rs,uint32_t mask_num,CPUMIPSState *env);extern uint32_t cpu_rddsp (uint32_t mask_num,CPUMIPSState *env); -#define CPU_SAVE_VERSION 5 -/* MMU modes definitions. We carefully match the indices with our hflags layout. */ #define MMU_MODE0_SUFFIX _kernel
target-mips/machine.c +252 -315
593 lines not on this page · raw message
Signature · 1 line
2.1.0
Re: [Qemu-devel] [PULL 1/2] target-mips: replace cpu_save/cpu_load with VMStateDescription
Quoted 4 lines · Leon Alrae
Create VMStateDescription for MIPS CPU. The new structure contains exactly the same fields as before, therefore leaving existing
version_id.Signed-off-by Leon Alrae <[email protected]>
Hi. I've just noticed that this commit has a bug, which provokes a warning on FreeBSD:
target-mips/machine.c:171:20: warning: incompatible pointer types passing 'uint_fast8_t *' (aka 'unsigned int *') to parameter of type 'const uint8_t *' (ake 'const unsigned char *') [-Wincompatible-pointer-types]
qemu_put_8s(f, &v->ASID);
^~~~~~~~This is because in the old code:
Quoted 12 lines
target-mips/machine.c +0
-12-/* Save TLB */ -qemu_put_be32s (f, &env->tlb->nb_tlb); -qemu_put_be32s (f, &env->tlb->tlb_in_use); -for (i =0 ; i <MIPS_TLB_MAX ; i++) { - uint16_t flags = ((env->tlb->mmu.r4k.tlb[i].EHINV << 15) | - (env->tlb->mmu.r4k.tlb[i].RI1 << 14) | - (env->tlb->mmu.r4k.tlb[i].RI0 << 13) | - (env->tlb->mmu.r4k.tlb[i].XI1 << 12) | - (env->tlb->mmu.r4k.tlb[i].XI0 << 11) | - (env->tlb->mmu.r4k.tlb[i].G << 10) | - (env->tlb->mmu.r4k.tlb[i].C0 << 7) | - (env->tlb->mmu.r4k.tlb[i].C1 << 4) |
target-mips/machine.c line 81
Quoted 10 lines
target-mips/machine.c +0
-10- (env->tlb->mmu.r4k.tlb[i].V0 <<3 ) | - (env->tlb->mmu.r4k.tlb[i].V1 <<2 ) | - (env->tlb->mmu.r4k.tlb[i].D0 <<1 ) | - (env->tlb->mmu.r4k.tlb[i].D1 << 0)); -uint8_t asid; - -qemu_put_betls (f, &env->tlb->mmu.r4k.tlb[i].VPN); -qemu_put_be32s (f, &env->tlb->mmu.r4k.tlb[i].PageMask); - asid = env->tlb->mmu.r4k.tlb[i].ASID; -qemu_put_8s (f, &asid);
we copied the asid to a local variable of the right size to pass the address to qemu_put_8s()...
Quoted 6 lines
target-mips/machine.c +6
-0+ uint16_t flags = ((v->EHINV << 15) | + (v->RI1 << 14) | + (v->RI0 << 13) | + (v->XI1 << 12) | + (v->XI0 << 11) | + (v->G << 10) |
target-mips/machine.c line 152
Quoted 10 lines
target-mips/machine.c +10
-0+ (v->C0 <<7 ) | + (v->C1 <<4 ) | + (v->V0 <<3 ) | + (v->V1 <<2 ) | + (v->D0 <<1 ) | + (v->D1 << 0)); + +qemu_put_betls (f, &v->VPN); +qemu_put_be32s (f, &v->PageMask); +qemu_put_8s (f, &v->ASID);
...but in the new code we just directly use the address in the struct, which won't work because it has a (potentially) incompatible type.
thanks
-- PMM
Re: [Qemu-devel] [PULL 1/2] target-mips: replace cpu_save/cpu_load with VMStateDescription
Quoted 62 lines · Peter Maydell
Quoted 4 lines · Leon Alrae
Create VMStateDescription for MIPS CPU. The new structure contains exactly the same fields as before, therefore leaving existing
version_id.Signed-off-by Leon Alrae <[email protected]>Hi. I've just noticed that this commit has a bug, which provokes a warning on FreeBSD:
target-mips/machine.c:171:20: warning: incompatible pointer types passing 'uint_fast8_t*' (aka 'unsigned int *') to parameter of type 'constuint8_t*' (ake 'const unsigned char *') [-Wincompatible-pointer-types]qemu_put_8s(f, &v->ASID); ^~~~~~~~This is because in the old code:
Quoted 12 lines
target-mips/machine.c +0
-12-/* Save TLB */ -qemu_put_be32s (f, &env->tlb->nb_tlb); -qemu_put_be32s (f, &env->tlb->tlb_in_use); -for (i =0 ; i <MIPS_TLB_MAX ; i++) { - uint16_t flags = ((env->tlb->mmu.r4k.tlb[i].EHINV << 15) | - (env->tlb->mmu.r4k.tlb[i].RI1 << 14) | - (env->tlb->mmu.r4k.tlb[i].RI0 << 13) | - (env->tlb->mmu.r4k.tlb[i].XI1 << 12) | - (env->tlb->mmu.r4k.tlb[i].XI0 << 11) | - (env->tlb->mmu.r4k.tlb[i].G << 10) | - (env->tlb->mmu.r4k.tlb[i].C0 << 7) | - (env->tlb->mmu.r4k.tlb[i].C1 << 4) |target-mips/machine.c line 81
Quoted 10 lines
target-mips/machine.c +0
-10- (env->tlb->mmu.r4k.tlb[i].V0 <<3 ) | - (env->tlb->mmu.r4k.tlb[i].V1 <<2 ) | - (env->tlb->mmu.r4k.tlb[i].D0 <<1 ) | - (env->tlb->mmu.r4k.tlb[i].D1 << 0)); -uint8_t asid; - -qemu_put_betls (f, &env->tlb->mmu.r4k.tlb[i].VPN); -qemu_put_be32s (f, &env->tlb->mmu.r4k.tlb[i].PageMask); - asid = env->tlb->mmu.r4k.tlb[i].ASID; -qemu_put_8s (f, &asid);we copied the asid to a local variable of the right size to pass the address to
qemu_put_8s()...Quoted 6 lines
target-mips/machine.c +6
-0+ uint16_t flags = ((v->EHINV << 15) | + (v->RI1 << 14) | + (v->RI0 << 13) | + (v->XI1 << 12) | + (v->XI0 << 11) | + (v->G << 10) |target-mips/machine.c line 152
Quoted 10 lines
target-mips/machine.c +10
-0+ (v->C0 <<7 ) | + (v->C1 <<4 ) | + (v->V0 <<3 ) | + (v->V1 <<2 ) | + (v->D0 <<1 ) | + (v->D1 << 0)); + +qemu_put_betls (f, &v->VPN); +qemu_put_be32s (f, &v->PageMask); +qemu_put_8s (f, &v->ASID);
Quoted 3 lines
...but in the new code we just directly use the address in the struct, which won't work because it has a (potentially) incompatible type.
I've just posted the patch correcting this.
Thanks,
Leon
Peter Maydell
AppliedQuoted 23 lines · Leon Alrae
Hi,
This pull request contains remaining change for 2.3 which was originally submitted before soft-freeze.
Thanks,
LeonCc Peter Maydell <[email protected]>Cc Aurelien Jarno <[email protected]>The following changes since commit
48412371415a260d00fc7fdcdb400da55f268828:Merge remote-tracking branch 'remotes/ehabkost/tags/x86-pull-request' into staging (2015-03-11 11:12:35 +0000)
are available in the git repository at:
git://github.com/lalrae/qemu.gittags/mips-20150311for you to fetch changes up to
644511117e7ca9f26d633a59c202a297113a796c:target-mips: add missing MSACSR and restore
fp_statusand hflags (2015-03-11 14:13:57 +0000)
Quoted 7 lines
----------------------------------------------------------------
MIPS patches 2015-03-11Changes:
* use VMStateDescription for MIPS CPU----------------------------------------------------------------
Applied, thanks.
-- PMM