target/alpha: Fix linux-user exception for CVTTQ
cover target/alpha: Fix linux-user exception for CVTTQ
Alex's new float_convs test dies with SIGFPE for alpha-linux-user.
This is fixed in patch 6, where I mask the exception similar to how the kernel would, when passed through the software completion handler.
Patches 2 & 3 fix bugs that I noticed in the process; the rest are simple cleanup, trying to make the code better or easier.
r~
Richard Henderson (7):
target/alpha: Use array for FPCR_DYN conversion target/alpha: Fix SWCR_MAP_UMZ
target/alpha: Fix SWCR_TRAP_ENABLE_MASK target/alpha: Handle SWCR_MAP_DMZ earlier target/alpha: Write to fpcr_flush_to_zero once target/alpha: Mask IOV exception with INV for user-only target/alpha: Tidy helper_fp_exc_raise_s
target/alpha/fpu_helper.c | 15 +++------ target/alpha/helper.c | 68 +++++++++++++++++++-------------------- 2 files changed, 38 insertions(+), 45 deletions(-)
Signature · 1 line
2.17.1
PATCH 1/7 target/alpha: Use array for FPCR_DYN conversion
This is a bit more straight-forward than using a switch statement. No functional change.
--- target/alpha/helper.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-)
target/alpha/helper.c +8 -16
@@ -36,6 +36,13 @@ uint64_t cpu_alpha_load_fpcr(CPUAlphaState *env)void cpu_alpha_store_fpcr (CPUAlphaState *env,uint64_t val) { +static const uint8_t rm_map[] = { + [FPCR_DYN_NORMAL >>FPCR_DYN_SHIFT ] = float_round_nearest_even, + [FPCR_DYN_CHOPPED >>FPCR_DYN_SHIFT ] = float_round_to_zero, + [FPCR_DYN_MINUS >>FPCR_DYN_SHIFT ] = float_round_down, + [FPCR_DYN_PLUS >>FPCR_DYN_SHIFT ] = float_round_up, + }; +uint32_t fpcr = val >>32 ;uint32_t t =0 ;
@@ -48,22 +55,7 @@ void cpu_alpha_store_fpcr(CPUAlphaState *env, uint64_t val) env->fpcr = fpcr; env->fpcr_exc_enable = ~t &FPCR_STATUS_MASK ; -switch (fpcr &FPCR_DYN_MASK ) { -case FPCR_DYN_NORMAL : -default : - t = float_round_nearest_even; -break ; -case FPCR_DYN_CHOPPED : - t = float_round_to_zero; -break ; -case FPCR_DYN_MINUS : - t = float_round_down; -break ; -case FPCR_DYN_PLUS : - t = float_round_up; -break ; - } - env->fpcr_dyn_round = t; + env->fpcr_dyn_round = rm_map[(fpcr &FPCR_DYN_MASK ) >>FPCR_DYN_SHIFT ]; env->fpcr_flush_to_zero = (fpcr &FPCR_UNFD ) && (fpcr &FPCR_UNDZ ); env->fp_status.flush_inputs_to_zero = (fpcr &FPCR_DNZ ) !=0 ;
Signature · 1 line
2.17.1
Re: [PATCH 1/7] target/alpha: Use array for FPCR_DYN conversion
Quoted 4 lines · Richard Henderson
This is a bit more straight-forward than using a switch statement. No functional change.
Signed-off-by Richard Henderson <[email protected]>
Quoted 47 lines
--- target/alpha/helper.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-)target/alpha/helper.c +8
-16@@ -36,6 +36,13 @@ uint64_t cpu_alpha_load_fpcr(CPUAlphaState *env)void cpu_alpha_store_fpcr (CPUAlphaState *env,uint64_t val) { +static const uint8_t rm_map[] = { + [FPCR_DYN_NORMAL >>FPCR_DYN_SHIFT ] = float_round_nearest_even, + [FPCR_DYN_CHOPPED >>FPCR_DYN_SHIFT ] = float_round_to_zero, + [FPCR_DYN_MINUS >>FPCR_DYN_SHIFT ] = float_round_down, + [FPCR_DYN_PLUS >>FPCR_DYN_SHIFT ] = float_round_up, + }; +uint32_t fpcr = val >>32 ;uint32_t t =0 ;@@ -48,22 +55,7 @@ void cpu_alpha_store_fpcr(CPUAlphaState *env, uint64_t val) env->fpcr = fpcr; env->fpcr_exc_enable = ~t &FPCR_STATUS_MASK ; -switch (fpcr &FPCR_DYN_MASK ) { -case FPCR_DYN_NORMAL : -default : - t = float_round_nearest_even; -break ; -case FPCR_DYN_CHOPPED : - t = float_round_to_zero; -break ; -case FPCR_DYN_MINUS : - t = float_round_down; -break ; -case FPCR_DYN_PLUS : - t = float_round_up; -break ; - } - env->fpcr_dyn_round = t; + env->fpcr_dyn_round = rm_map[(fpcr &FPCR_DYN_MASK ) >>FPCR_DYN_SHIFT ]; env->fpcr_flush_to_zero = (fpcr &FPCR_UNFD ) && (fpcr &FPCR_UNDZ ); env->fp_status.flush_inputs_to_zero = (fpcr &FPCR_DNZ ) !=0 ;
Re: [PATCH 1/7] target/alpha: Use array for FPCR_DYN conversion
In reply to Richard HendersonQuoted 4 lines · Richard Henderson
This is a bit more straight-forward than using a switch statement. No functional change.
Signed-off-by Richard Henderson <[email protected]>
Quoted 36 lines
--- target/alpha/helper.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-)target/alpha/helper.c +7
-10@@ -36,6 +36,13 @@ uint64_t cpu_alpha_load_fpcr(CPUAlphaState *env)void cpu_alpha_store_fpcr (CPUAlphaState *env,uint64_t val) { +static const uint8_t rm_map[] = { + [FPCR_DYN_NORMAL >>FPCR_DYN_SHIFT ] = float_round_nearest_even, + [FPCR_DYN_CHOPPED >>FPCR_DYN_SHIFT ] = float_round_to_zero, + [FPCR_DYN_MINUS >>FPCR_DYN_SHIFT ] = float_round_down, + [FPCR_DYN_PLUS >>FPCR_DYN_SHIFT ] = float_round_up, + }; +uint32_t fpcr = val >>32 ;uint32_t t =0 ;@@ -48,22 +55,7 @@ void cpu_alpha_store_fpcr(CPUAlphaState *env, uint64_t val) env->fpcr = fpcr; env->fpcr_exc_enable = ~t &FPCR_STATUS_MASK ; -switch (fpcr &FPCR_DYN_MASK ) { -case FPCR_DYN_NORMAL : -default : - t = float_round_nearest_even; -break ; -case FPCR_DYN_CHOPPED : - t = float_round_to_zero; -break ; -case FPCR_DYN_MINUS : - t = float_round_down;
target/alpha/helper.c void cpu_alpha_store_fpcr(CPUAlphaState *env, uint64_t val) · line 61
Quoted 10 lines
target/alpha/helper.c +1
-6-break ; -case FPCR_DYN_PLUS : - t = float_round_up; -break ; - } - env->fpcr_dyn_round = t; + env->fpcr_dyn_round = rm_map[(fpcr &FPCR_DYN_MASK ) >>FPCR_DYN_SHIFT ]; env->fpcr_flush_to_zero = (fpcr &FPCR_UNFD ) && (fpcr &FPCR_UNDZ ); env->fp_status.flush_inputs_to_zero = (fpcr &FPCR_DNZ ) !=0 ;
--
Alex Bennée
PATCH 2/7 target/alpha: Fix SWCR_MAP_UMZ
In reply to Richard HendersonWe were setting the wrong bit. The fp_status.flush_to_zero setting is overwritten by either the constant 1 or the value of fpcr_flush_to_zero depending on bits within an fp insn.
--- target/alpha/helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/alpha/helper.c +1 -1
@@ -71,7 +71,7 @@ void cpu_alpha_store_fpcr(CPUAlphaState *env, uint64_t val) env->fp_status.flush_inputs_to_zero = 1; }if (env->swcr &SWCR_MAP_UMZ ) { - env->fp_status.flush_to_zero =1 ; + env->fpcr_flush_to_zero =1 ; } env->fpcr_exc_enable &= ~(alpha_ieee_swcr_to_fpcr (env->swcr) >>32 );#endif
Signature · 1 line
2.17.1
Re: [PATCH 2/7] target/alpha: Fix SWCR_MAP_UMZ
Quoted 2 lines · Richard Henderson
We were setting the wrong bit. The fp_status.flush_to_zero setting is overwritten
".. in the generated code.."?
Quoted 4 lines
by either the constant 1 or the value
offpcr_flush_to_zerodepending on bits within an fp insn.Signed-off-by Richard Henderson <[email protected]>
Quoted 9 lines
--- target/alpha/helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)target/alpha/helper.c +0
-0
target/alpha/helper.c void cpu_alpha_store_fpcr(CPUAlphaState *env, uint64_t val) · line 77
Quoted 8 lines
target/alpha/helper.c +1
-1@@ -71,7 +71,7 @@ void cpu_alpha_store_fpcr(CPUAlphaState *env, uint64_t val) env->fp_status.flush_inputs_to_zero = 1; }if (env->swcr &SWCR_MAP_UMZ ) { - env->fp_status.flush_to_zero =1 ; + env->fpcr_flush_to_zero =1 ; } env->fpcr_exc_enable &= ~(alpha_ieee_swcr_to_fpcr (env->swcr) >>32 );#endif
--
Alex Bennée
PATCH 3/7 target/alpha: Fix SWCR_TRAP_ENABLE_MASK
In reply to Richard HendersonThe CONFIG_USER_ONLY adjustment blindly mashed the swcr exception enable bits into the fpcr exception disable bits.
However, fpcr_exc_enable has already converted the exception disable bits into the exception status bits in order to make it easier to mask status bits at runtime.
Instead, merge the swcr enable bits with the fpcr before we convert to status bits.
--- target/alpha/helper.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-)
target/alpha/helper.c +18 -13
@@ -46,19 +46,8 @@ void cpu_alpha_store_fpcr(CPUAlphaState *env, uint64_t val)uint32_t fpcr = val >>32 ;uint32_t t =0 ; - t |=CONVERT_BIT (fpcr,FPCR_INED ,FPCR_INE ); - t |=CONVERT_BIT (fpcr,FPCR_UNFD ,FPCR_UNF ); - t |=CONVERT_BIT (fpcr,FPCR_OVFD ,FPCR_OVF ); - t |=CONVERT_BIT (fpcr,FPCR_DZED ,FPCR_DZE ); - t |=CONVERT_BIT (fpcr,FPCR_INVD ,FPCR_INV ); - +/* Record the raw value before adjusting for linux-user. */ env->fpcr = fpcr; - env->fpcr_exc_enable = ~t &FPCR_STATUS_MASK ; - - env->fpcr_dyn_round = rm_map[(fpcr &FPCR_DYN_MASK ) >>FPCR_DYN_SHIFT ]; - - env->fpcr_flush_to_zero = (fpcr &FPCR_UNFD ) && (fpcr &FPCR_UNDZ ); - env->fp_status.flush_inputs_to_zero = (fpcr &FPCR_DNZ ) !=0 ;#ifdef CONFIG_USER_ONLY /*
@@ -67,13 +56,29 @@ void cpu_alpha_store_fpcr(CPUAlphaState *env, uint64_t val)* which point the kernel's handler would emulate and apply * the software exception mask. */ +uint32_t soft_fpcr =alpha_ieee_swcr_to_fpcr (env->swcr) >>32 ; + fpcr |= soft_fpcr &FPCR_STATUS_MASK ; +#endif + + t |=CONVERT_BIT (fpcr,FPCR_INED ,FPCR_INE ); + t |=CONVERT_BIT (fpcr,FPCR_UNFD ,FPCR_UNF ); + t |=CONVERT_BIT (fpcr,FPCR_OVFD ,FPCR_OVF ); + t |=CONVERT_BIT (fpcr,FPCR_DZED ,FPCR_DZE ); + t |=CONVERT_BIT (fpcr,FPCR_INVD ,FPCR_INV ); + + env->fpcr_exc_enable = ~t &FPCR_STATUS_MASK ; + + env->fpcr_dyn_round = rm_map[(fpcr &FPCR_DYN_MASK ) >>FPCR_DYN_SHIFT ]; + + env->fpcr_flush_to_zero = (fpcr &FPCR_UNFD ) && (fpcr &FPCR_UNDZ ); + env->fp_status.flush_inputs_to_zero = (fpcr &FPCR_DNZ ) !=0 ; +#ifdef CONFIG_USER_ONLY if (env->swcr &SWCR_MAP_DMZ ) { env->fp_status.flush_inputs_to_zero =1 ; }if (env->swcr &SWCR_MAP_UMZ ) { env->fpcr_flush_to_zero =1 ; } - env->fpcr_exc_enable &= ~(alpha_ieee_swcr_to_fpcr (env->swcr) >>32 );#endif }
Signature · 1 line
2.17.1
PATCH 4/7 target/alpha: Handle SWCR_MAP_DMZ earlier
In reply to Richard HendersonSince we're converting the swcr to fpcr format for exceptions, it's trivial to add FPCR_DNZ to the set of fpcr bits overriden. No functional change.
--- target/alpha/helper.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
target/alpha/helper.c +1 -4
@@ -57,7 +57,7 @@ void cpu_alpha_store_fpcr(CPUAlphaState *env, uint64_t val)* the software exception mask. */ uint32_t soft_fpcr =alpha_ieee_swcr_to_fpcr (env->swcr) >>32 ; - fpcr |= soft_fpcr &FPCR_STATUS_MASK ; + fpcr |= soft_fpcr & (FPCR_STATUS_MASK |FPCR_DNZ );#endif t |=CONVERT_BIT (fpcr,FPCR_INED ,FPCR_INE );
@@ -73,9 +73,6 @@ void cpu_alpha_store_fpcr(CPUAlphaState *env, uint64_t val) env->fpcr_flush_to_zero = (fpcr &FPCR_UNFD ) && (fpcr &FPCR_UNDZ ); env->fp_status.flush_inputs_to_zero = (fpcr &FPCR_DNZ ) !=0 ;#ifdef CONFIG_USER_ONLY -if (env->swcr &SWCR_MAP_DMZ ) { - env->fp_status.flush_inputs_to_zero =1 ; - }if (env->swcr &SWCR_MAP_UMZ ) { env->fpcr_flush_to_zero =1 ; }
Signature · 1 line
2.17.1
PATCH 5/7 target/alpha: Write to fpcr_flush_to_zero once
In reply to Richard HendersonTidy the computation of the value; no functional change.
--- target/alpha/helper.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
target/alpha/helper.c +4 -5
@@ -69,14 +69,13 @@ void cpu_alpha_store_fpcr(CPUAlphaState *env, uint64_t val) env->fpcr_exc_enable = ~t &FPCR_STATUS_MASK ; env->fpcr_dyn_round = rm_map[(fpcr &FPCR_DYN_MASK ) >>FPCR_DYN_SHIFT ]; - - env->fpcr_flush_to_zero = (fpcr &FPCR_UNFD ) && (fpcr &FPCR_UNDZ ); env->fp_status.flush_inputs_to_zero = (fpcr &FPCR_DNZ ) !=0 ; + + t = (fpcr &FPCR_UNFD ) && (fpcr &FPCR_UNDZ );#ifdef CONFIG_USER_ONLY -if (env->swcr &SWCR_MAP_UMZ ) { - env->fpcr_flush_to_zero =1 ; - } + t |= (env->swcr &SWCR_MAP_UMZ ) !=0 ;#endif + env->fpcr_flush_to_zero = t; }uint64_t helper_load_fpcr (CPUAlphaState *env)
Signature · 1 line
2.17.1
Re: [PATCH 5/7] target/alpha: Write to fpcr_flush_to_zero once
Quoted 3 lines · Richard Henderson
Tidy the computation of the value; no functional change.
Signed-off-by Richard Henderson <[email protected]>
Quoted 28 lines
--- target/alpha/helper.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)target/alpha/helper.c +4
-5@@ -69,14 +69,13 @@ void cpu_alpha_store_fpcr(CPUAlphaState *env, uint64_t val) env->fpcr_exc_enable = ~t &FPCR_STATUS_MASK ; env->fpcr_dyn_round = rm_map[(fpcr &FPCR_DYN_MASK ) >>FPCR_DYN_SHIFT ]; - - env->fpcr_flush_to_zero = (fpcr &FPCR_UNFD ) && (fpcr &FPCR_UNDZ ); env->fp_status.flush_inputs_to_zero = (fpcr &FPCR_DNZ ) !=0 ; + + t = (fpcr &FPCR_UNFD ) && (fpcr &FPCR_UNDZ );#ifdef CONFIG_USER_ONLY -if (env->swcr &SWCR_MAP_UMZ ) { - env->fpcr_flush_to_zero =1 ; - } + t |= (env->swcr &SWCR_MAP_UMZ ) !=0 ;#endif + env->fpcr_flush_to_zero = t; }uint64_t helper_load_fpcr (CPUAlphaState *env)
Re: [PATCH 5/7] target/alpha: Write to fpcr_flush_to_zero once
In reply to Richard HendersonQuoted 3 lines · Richard Henderson
Tidy the computation of the value; no functional change.
Signed-off-by Richard Henderson <[email protected]>
Quoted 17 lines
--- target/alpha/helper.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)target/alpha/helper.c +2
-2@@ -69,14 +69,13 @@ void cpu_alpha_store_fpcr(CPUAlphaState *env, uint64_t val) env->fpcr_exc_enable = ~t &FPCR_STATUS_MASK ; env->fpcr_dyn_round = rm_map[(fpcr &FPCR_DYN_MASK ) >>FPCR_DYN_SHIFT ]; - - env->fpcr_flush_to_zero = (fpcr &FPCR_UNFD ) && (fpcr &FPCR_UNDZ ); env->fp_status.flush_inputs_to_zero = (fpcr &FPCR_DNZ ) !=0 ; + + t = (fpcr &FPCR_UNFD ) && (fpcr &FPCR_UNDZ );
target/alpha/helper.c void cpu_alpha_store_fpcr(CPUAlphaState *env, uint64_t val) · line 81
Quoted 10 lines
target/alpha/helper.c +2
-3#ifdef CONFIG_USER_ONLY -if (env->swcr &SWCR_MAP_UMZ ) { - env->fpcr_flush_to_zero =1 ; - } + t |= (env->swcr &SWCR_MAP_UMZ ) !=0 ;#endif + env->fpcr_flush_to_zero = t; }uint64_t helper_load_fpcr (CPUAlphaState *env)
--
Alex Bennée
PATCH 6/7 target/alpha: Mask IOV exception with INV for user-only
In reply to Richard HendersonThe kernel masks the integer overflow exception with the software invalid exception mask. Include IOV in the set of exception bits masked by fpcr_exc_enable.
Fixes the new float_convs test.
--- target/alpha/helper.c | 7 +++++++ 1 file changed, 7 insertions(+)
target/alpha/helper.c +7 -0
@@ -58,6 +58,13 @@ void cpu_alpha_store_fpcr(CPUAlphaState *env, uint64_t val)*/ uint32_t soft_fpcr =alpha_ieee_swcr_to_fpcr (env->swcr) >>32 ; fpcr |= soft_fpcr & (FPCR_STATUS_MASK |FPCR_DNZ ); + +/* +* The IOV exception is disabled by the kernel with SWCR_TRAP_ENABLE_INV, +* which got mapped by alpha_ieee_swcr_to_fpcr to FPCR_INVD. +* Add FPCR_IOV to fpcr_exc_enable so that it is handled identically. +*/ + t |=CONVERT_BIT (soft_fpcr,FPCR_INVD ,FPCR_IOV );#endif t |=CONVERT_BIT (fpcr,FPCR_INED ,FPCR_INE );
Signature · 1 line
2.17.1
Re: [PATCH 6/7] target/alpha: Mask IOV exception with INV for user-only
Quoted 7 lines · Richard Henderson
The kernel masks the integer overflow exception with the software invalid exception mask. Include IOV in the set of exception bits masked by
fpcr_exc_enable.Fixes the new
float_convstest.Signed-off-by Richard Henderson <[email protected]>
Quoted 12 lines
--- target/alpha/helper.c | 7 +++++++ 1 file changed, 7 insertions(+)target/alpha/helper.c +0
-0@@ -58,6 +58,13 @@ void cpu_alpha_store_fpcr(CPUAlphaState *env, uint64_t val)*/ uint32_t soft_fpcr =alpha_ieee_swcr_to_fpcr (env->swcr) >>32 ; fpcr |= soft_fpcr & (FPCR_STATUS_MASK |FPCR_DNZ );
target/alpha/helper.c void cpu_alpha_store_fpcr(CPUAlphaState *env, uint64_t val) · line 70
Quoted 10 lines
target/alpha/helper.c +7
-0+ +/* +* The IOV exception is disabled by the kernel with SWCR_TRAP_ENABLE_INV, +* which got mapped by alpha_ieee_swcr_to_fpcr to FPCR_INVD. +* Add FPCR_IOV to fpcr_exc_enable so that it is handled identically. +*/ + t |=CONVERT_BIT (soft_fpcr,FPCR_INVD ,FPCR_IOV );#endif t |=CONVERT_BIT (fpcr,FPCR_INED ,FPCR_INE );
--
Alex Bennée
PATCH 7/7 target/alpha: Tidy helper_fp_exc_raise_s
In reply to Richard HendersonRemove a redundant masking of ignore. Once that's gone it is obvious that the system-mode inner test is redundant with the outer test. Move the fpcr_exc_enable masking up and tidy.
No functional change.
--- target/alpha/fpu_helper.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-)
target/alpha/fpu_helper.c +4 -11
@@ -90,25 +90,18 @@ void helper_fp_exc_raise_s(CPUAlphaState *env, uint32_t ignore, uint32_t regno)uint32_t exc = env->error_code & ~ignore;if (exc) { env->fpcr |= exc; - exc &= ~ignore; -#ifdef CONFIG_USER_ONLY -/* -* In user mode, the kernel's software handler only -* delivers a signal if the exception is enabled. -*/ -if (!(exc & env->fpcr_exc_enable)) { -return ; - } -#else + exc &= env->fpcr_exc_enable;/* * In system mode, the software handler gets invoked * for any non-ignored exception. +* In user mode, the kernel's software handler only +* delivers a signal if the exception is enabled. */ +#ifdef CONFIG_USER_ONLY if (!exc) {return ; }#endif - exc &= env->fpcr_exc_enable;fp_exc_raise1 (env,GETPC (), exc, regno,EXC_M_SWC ); } }
Signature · 1 line
2.17.1
Re: [PATCH 7/7] target/alpha: Tidy helper_fp_exc_raise_s
Quoted 7 lines · Richard Henderson
Remove a redundant masking of ignore. Once that's gone it is obvious that the system-mode inner test is redundant with the outer test. Move the
fpcr_exc_enablemasking up and tidy.No functional change.
Signed-off-by Richard Henderson <[email protected]>
Quoted 39 lines
--- target/alpha/fpu_helper.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-)target/alpha/fpu_helper.c +4
-11@@ -90,25 +90,18 @@ void helper_fp_exc_raise_s(CPUAlphaState *env, uint32_t ignore, uint32_t regno)uint32_t exc = env->error_code & ~ignore;if (exc) { env->fpcr |= exc; - exc &= ~ignore; -#ifdef CONFIG_USER_ONLY -/* -* In user mode, the kernel's software handler only -* delivers a signal if the exception is enabled. -*/ -if (!(exc & env->fpcr_exc_enable)) { -return ; - } -#else + exc &= env->fpcr_exc_enable;/* * In system mode, the software handler gets invoked * for any non-ignored exception. +* In user mode, the kernel's software handler only +* delivers a signal if the exception is enabled. */ +#ifdef CONFIG_USER_ONLY if (!exc) {return ; }#endif - exc &= env->fpcr_exc_enable;fp_exc_raise1 (env,GETPC (), exc, regno,EXC_M_SWC ); } }
Re: [PATCH 7/7] target/alpha: Tidy helper_fp_exc_raise_s
In reply to Richard HendersonQuoted 7 lines · Richard Henderson
Remove a redundant masking of ignore. Once that's gone it is obvious that the system-mode inner test is redundant with the outer test. Move the
fpcr_exc_enablemasking up and tidy.No functional change.
Signed-off-by Richard Henderson <[email protected]>
Quoted 28 lines
--- target/alpha/fpu_helper.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-)target/alpha/fpu_helper.c +3
-10@@ -90,25 +90,18 @@ void helper_fp_exc_raise_s(CPUAlphaState *env, uint32_t ignore, uint32_t regno)uint32_t exc = env->error_code & ~ignore;if (exc) { env->fpcr |= exc; - exc &= ~ignore; -#ifdef CONFIG_USER_ONLY -/* -* In user mode, the kernel's software handler only -* delivers a signal if the exception is enabled. -*/ -if (!(exc & env->fpcr_exc_enable)) { -return ; - } -#else + exc &= env->fpcr_exc_enable;/* * In system mode, the software handler gets invoked * for any non-ignored exception. +* In user mode, the kernel's software handler only +* delivers a signal if the exception is enabled.
target/alpha/fpu_helper.c void helper_fp_exc_raise_s(CPUAlphaState *env, uint32_t ignore, uint32_t regno) · line 107
Quoted 10 lines
target/alpha/fpu_helper.c +1
-1*/ +#ifdef CONFIG_USER_ONLY if (!exc) {return ; }#endif - exc &= env->fpcr_exc_enable;fp_exc_raise1 (env,GETPC (), exc, regno,EXC_M_SWC ); } }
--
Alex Bennée
Quoted 7 lines · Richard Henderson
Alex's new
float_convstest dies with SIGFPE for alpha-linux-user.This is fixed in patch 6, where I mask the exception similar to how the kernel would, when passed through the software completion handler.
Patches 2 & 3 fix bugs that I noticed in the process; the rest are simple cleanup, trying to make the code better or easier.
Now Richard has eli5'd the CONVERT_BITS magic for me>
the rest of the series.
Quoted 14 lines
r~
Richard Henderson (7):
target/alpha: Use array forFPCR_DYNconversion target/alpha: FixSWCR_MAP_UMZ
target/alpha: FixSWCR_TRAP_ENABLE_MASKtarget/alpha: HandleSWCR_MAP_DMZearlier target/alpha: Write tofpcr_flush_to_zeroonce target/alpha: Mask IOV exception with INV for user-only target/alpha: Tidyhelper_fp_exc_raise_s
Quoted 3 lines
target/alpha/fpu_helper.c | 15 +++------ target/alpha/helper.c | 68 +++++++++++++++++++-------------------- 2 files changed, 38 insertions(+), 45 deletions(-)
--
Alex Bennée