Re: [PATCH] target: i386: Check float overflow about register stack

2020-02-24 Thread Chen Gang
On 2020/2/24 下午8:43, Paolo Bonzini wrote: > On 22/02/20 13:25, Chen Gang wrote: >> On 2020/2/22 下午3:37, Paolo Bonzini wrote: >>> On 22/02/20 03:10, Chen Gang wrote: Set C1 to 1 if stack overflow occurred; set to 0 otherwise". In helper_fxam_ST0, I guess, we need "env->fpus |= 0x200"

Re: [PATCH] target: i386: Check float overflow about register stack

2020-02-24 Thread Paolo Bonzini
On 22/02/20 13:25, Chen Gang wrote: > On 2020/2/22 下午3:37, Paolo Bonzini wrote: >> On 22/02/20 03:10, Chen Gang wrote: >>> Set C1 to 1 if stack overflow occurred; set to 0 otherwise". >>> >>> In helper_fxam_ST0, I guess, we need "env->fpus |= 0x200" (but I don't >>> know wheter it will be conflict

Re: [PATCH] target: i386: Check float overflow about register stack

2020-02-22 Thread Chen Gang
On 2020/2/22 下午3:37, Paolo Bonzini wrote: > On 22/02/20 03:10, Chen Gang wrote: >> Set C1 to 1 if stack overflow occurred; set to 0 otherwise". >> >> In helper_fxam_ST0, I guess, we need "env->fpus |= 0x200" (but I don't >> know wheter it will be conflict with SIGND(temp)). And we have to still >>

Re: [PATCH] target: i386: Check float overflow about register stack

2020-02-21 Thread Paolo Bonzini
On 22/02/20 03:10, Chen Gang wrote: > Set C1 to 1 if stack overflow occurred; set to 0 otherwise". > > In helper_fxam_ST0, I guess, we need "env->fpus |= 0x200" (but I don't > know wheter it will be conflict with SIGND(temp)). And we have to still > need foverflow, because all env->fptags being 0

Re: [PATCH] target: i386: Check float overflow about register stack

2020-02-21 Thread Chen Gang
On 2020/2/22 上午10:10, Chen Gang wrote: > On 2020/2/22 上午12:18, Paolo Bonzini wrote: >> On 21/02/20 15:09, Chen Gang wrote: -/* XXX: test fptags too */ +if (env->fptags[env->fpstt]) { +env->fpus |= 0x4100; /* Empty */ +return; +} + >>> For fp

Re: [PATCH] target: i386: Check float overflow about register stack

2020-02-21 Thread Chen Gang
On 2020/2/22 上午12:18, Paolo Bonzini wrote: > On 21/02/20 15:09, Chen Gang wrote: >>> -/* XXX: test fptags too */ >>> +if (env->fptags[env->fpstt]) { >>> +env->fpus |= 0x4100; /* Empty */ >>> +return; >>> +} >>> + >> For fpop overflow, this fix is enough, but for me, we s

Re: [PATCH] target: i386: Check float overflow about register stack

2020-02-21 Thread Paolo Bonzini
On 21/02/20 15:09, Chen Gang wrote: >> -/* XXX: test fptags too */ >> +if (env->fptags[env->fpstt]) { >> +env->fpus |= 0x4100; /* Empty */ >> +return; >> +} >> + > For fpop overflow, this fix is enough, but for me, we still need > foverflow to check fpush/fld*_ST0 overfl

Re: [PATCH] target: i386: Check float overflow about register stack

2020-02-21 Thread Chen Gang
On 2020/2/21 下午4:58, Paolo Bonzini wrote: > On 21/02/20 04:45, cheng...@emindsoft.com.cn wrote: >> static inline void fpush(CPUX86State *env) >> { >> -env->fpstt = (env->fpstt - 1) & 7; >> -env->fptags[env->fpstt] = 0; /* validate stack entry */ >> +set_fpstt(env, env->fpstt - 1, fals

Re: [PATCH] target: i386: Check float overflow about register stack

2020-02-21 Thread Paolo Bonzini
On 21/02/20 04:45, cheng...@emindsoft.com.cn wrote: > static inline void fpush(CPUX86State *env) > { > -env->fpstt = (env->fpstt - 1) & 7; > -env->fptags[env->fpstt] = 0; /* validate stack entry */ > +set_fpstt(env, env->fpstt - 1, false, true); On overflow fpstt is ~0, so this does:

[PATCH] target: i386: Check float overflow about register stack

2020-02-20 Thread chengang
From: Chen Gang The fxam instruction also checks the register stack overflow, which can be get by the following fstsw instruction. The related code is below, it works well under real x86_64 hardware, but can not work under qemu-i386. 0006b63c <_CIsqrt>: 6b63c: 55 pu