diff options
author | Richard Henderson <richard.henderson@linaro.org> | 2022-02-16 20:06:22 -0500 |
---|---|---|
committer | Richard Henderson <richard.henderson@linaro.org> | 2022-02-28 08:04:06 -1000 |
commit | 8929906e212cbe606e361cbd32917dcbe5bb6dd0 (patch) | |
tree | 4acc52416554ce423d8cb93f7cc303affa7303a8 /target/i386 | |
parent | 00483d386901173e84c7965f9f0d678791a75e01 (diff) | |
download | qemu-8929906e212cbe606e361cbd32917dcbe5bb6dd0.zip qemu-8929906e212cbe606e361cbd32917dcbe5bb6dd0.tar.gz qemu-8929906e212cbe606e361cbd32917dcbe5bb6dd0.tar.bz2 |
tcg: Remove dh_alias indirection for dh_typecode
The dh_alias redirect is intended to handle TCG types as distinguished
from C types. TCG does not distinguish signed int from unsigned int,
because they are the same size. However, we need to retain this
distinction for dh_typecode, lest we fail to extend abi types properly
for the host call parameters.
This bug was detected when running the 'arm' emulator on an s390
system. The s390 uses TCG_TARGET_EXTEND_ARGS which triggers code
in tcg_gen_callN to extend 32 bit values to 64 bits; the incorrect
sign data in the typemask for each argument caused the values to be
extended as unsigned values.
This simple program exhibits the problem:
static volatile int num = -9;
static volatile int den = -5;
int main(void)
{
int quo = num / den;
printf("num %d den %d quo %d\n", num, den, quo);
exit(0);
}
When run on the broken qemu, this results in:
num -9 den -5 quo 0
The correct result is:
num -9 den -5 quo 1
Fixes: 7319d83a735 ("tcg: Combine dh_is_64bit and dh_is_signed to dh_typecode")
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/876
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reported-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Tested-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Tested-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Diffstat (limited to 'target/i386')
-rw-r--r-- | target/i386/ops_sse_header.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/target/i386/ops_sse_header.h b/target/i386/ops_sse_header.h index e68af5c..cef28f2 100644 --- a/target/i386/ops_sse_header.h +++ b/target/i386/ops_sse_header.h @@ -30,6 +30,9 @@ #define dh_ctype_Reg Reg * #define dh_ctype_ZMMReg ZMMReg * #define dh_ctype_MMXReg MMXReg * +#define dh_typecode_Reg dh_typecode_ptr +#define dh_typecode_ZMMReg dh_typecode_ptr +#define dh_typecode_MMXReg dh_typecode_ptr DEF_HELPER_3(glue(psrlw, SUFFIX), void, env, Reg, Reg) DEF_HELPER_3(glue(psraw, SUFFIX), void, env, Reg, Reg) |