[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 01/22] host-utils: Fix overflow detection in divu128()
From: |
Luis Pires |
Subject: |
[PATCH v3 01/22] host-utils: Fix overflow detection in divu128() |
Date: |
Fri, 10 Sep 2021 08:26:03 -0300 |
The previous code didn't detect overflows if the high 64-bit
of the dividend were equal to the 64-bit divisor. In that case,
64 bits wouldn't be enough to hold the quotient.
Signed-off-by: Luis Pires <luis.pires@eldorado.org.br>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
util/host-utils.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/util/host-utils.c b/util/host-utils.c
index 7b9322071d..a789a11b46 100644
--- a/util/host-utils.c
+++ b/util/host-utils.c
@@ -102,7 +102,7 @@ int divu128(uint64_t *plow, uint64_t *phigh, uint64_t
divisor)
*plow = dlo / divisor;
*phigh = dlo % divisor;
return 0;
- } else if (dhi > divisor) {
+ } else if (dhi >= divisor) {
return 1;
} else {
--
2.25.1
- [PATCH v3 00/22] target/ppc: DFP instructions using decodetree, Luis Pires, 2021/09/10
- [PATCH v3 01/22] host-utils: Fix overflow detection in divu128(),
Luis Pires <=
- [PATCH v3 02/22] host-utils: fix missing zero-extension in divs128, Luis Pires, 2021/09/10
- [PATCH v3 03/22] host-utils: introduce uabs64(), Luis Pires, 2021/09/10
- [PATCH v3 04/22] i386/kvm: Replace abs64() with uabs64() from host-utils, Luis Pires, 2021/09/10
- [PATCH v3 05/22] host-utils: move checks out of divu128/divs128, Luis Pires, 2021/09/10
- [PATCH v3 06/22] host-utils: move udiv_qrnnd() to host-utils, Luis Pires, 2021/09/10
- [PATCH v3 07/22] host-utils: add 128-bit quotient support to divu128/divs128, Luis Pires, 2021/09/10
- [PATCH v3 08/22] host-utils: add unit tests for divu128/divs128, Luis Pires, 2021/09/10
- [PATCH v3 09/22] libdecnumber: introduce decNumberFrom[U]Int128, Luis Pires, 2021/09/10
- [PATCH v3 10/22] target/ppc: Move REQUIRE_ALTIVEC/VECTOR to translate.c, Luis Pires, 2021/09/10
- [PATCH v3 11/22] target/ppc: Introduce REQUIRE_FPU, Luis Pires, 2021/09/10