[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 02/22] host-utils: fix missing zero-extension in divs128
From: |
Luis Pires |
Subject: |
[PATCH v3 02/22] host-utils: fix missing zero-extension in divs128 |
Date: |
Fri, 10 Sep 2021 08:26:04 -0300 |
*plow (lower 64 bits of the dividend) is passed into divs128() as
a signed 64-bit integer. When building an __int128_t from it, it
must be zero-extended, instead of sign-extended.
Suggested-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Luis Pires <luis.pires@eldorado.org.br>
---
include/qemu/host-utils.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/qemu/host-utils.h b/include/qemu/host-utils.h
index 711b221704..753b9fb89f 100644
--- a/include/qemu/host-utils.h
+++ b/include/qemu/host-utils.h
@@ -70,7 +70,7 @@ static inline int divs128(int64_t *plow, int64_t *phigh,
int64_t divisor)
if (divisor == 0) {
return 1;
} else {
- __int128_t dividend = ((__int128_t)*phigh << 64) | *plow;
+ __int128_t dividend = ((__int128_t)*phigh << 64) | (uint64_t)*plow;
__int128_t result = dividend / divisor;
*plow = result;
*phigh = dividend % divisor;
--
2.25.1
- [PATCH v3 00/22] target/ppc: DFP instructions using decodetree, Luis Pires, 2021/09/10
- [PATCH v3 02/22] host-utils: fix missing zero-extension in divs128,
Luis Pires <=
- [PATCH v3 01/22] host-utils: Fix overflow detection in divu128(), 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