Commit 9bb234b3b170299c39c9e88cfe7da5434a92d99d
1 parent
290a0933
Fix qemu crash due to sparc division-by-zero, by Aurelien Jarno.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2510 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
10 additions
and
0 deletions
target-sparc/op.c
@@ -671,6 +671,11 @@ void OPPROTO op_udiv_T1_T0(void) | @@ -671,6 +671,11 @@ void OPPROTO op_udiv_T1_T0(void) | ||
671 | 671 | ||
672 | x0 = T0 | ((uint64_t) (env->y) << 32); | 672 | x0 = T0 | ((uint64_t) (env->y) << 32); |
673 | x1 = T1; | 673 | x1 = T1; |
674 | + | ||
675 | + if (x1 == 0) { | ||
676 | + raise_exception(TT_DIV_ZERO); | ||
677 | + } | ||
678 | + | ||
674 | x0 = x0 / x1; | 679 | x0 = x0 / x1; |
675 | if (x0 > 0xffffffff) { | 680 | if (x0 > 0xffffffff) { |
676 | T0 = 0xffffffff; | 681 | T0 = 0xffffffff; |
@@ -689,6 +694,11 @@ void OPPROTO op_sdiv_T1_T0(void) | @@ -689,6 +694,11 @@ void OPPROTO op_sdiv_T1_T0(void) | ||
689 | 694 | ||
690 | x0 = T0 | ((int64_t) (env->y) << 32); | 695 | x0 = T0 | ((int64_t) (env->y) << 32); |
691 | x1 = T1; | 696 | x1 = T1; |
697 | + | ||
698 | + if (x1 == 0) { | ||
699 | + raise_exception(TT_DIV_ZERO); | ||
700 | + } | ||
701 | + | ||
692 | x0 = x0 / x1; | 702 | x0 = x0 / x1; |
693 | if ((int32_t) x0 != x0) { | 703 | if ((int32_t) x0 != x0) { |
694 | T0 = x0 < 0? 0x80000000: 0x7fffffff; | 704 | T0 = x0 < 0? 0x80000000: 0x7fffffff; |