All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: Richard Henderson <richard.henderson@linaro.org>
Cc: Keith Packard <keithp@keithp.com>, qemu-devel@nongnu.org
Subject: Re: [PATCH] tcg: Remove dh_alias indirection for dh_typecode
Date: Thu, 17 Feb 2022 12:41:06 +0000	[thread overview]
Message-ID: <878ru9br7i.fsf@linaro.org> (raw)
In-Reply-To: <20220217034725.272552-1-richard.henderson@linaro.org>


Richard Henderson <richard.henderson@linaro.org> writes:

> 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
>

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/876

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>

-- 
Alex Bennée


  reply	other threads:[~2022-02-17 13:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-17  3:47 [PATCH] tcg: Remove dh_alias indirection for dh_typecode Richard Henderson
2022-02-17 12:41 ` Alex Bennée [this message]
2022-02-17 13:00 ` Christian Ehrhardt
2022-02-17 17:11 ` Keith Packard via

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=878ru9br7i.fsf@linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=keithp@keithp.com \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.