From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: agrecascino123@gmail.com, qemu-devel@nongnu.org
Cc: "Catherine A. Frederick" <chocola@animebitch.es>, rth@twiddle.net
Subject: Re: [PATCH] tcg: Sanitize shift constants on ppc64le so that shift operations with large constants don't generate invalid instructions.
Date: Wed, 3 Jun 2020 08:43:31 +0200 [thread overview]
Message-ID: <2a0fa3cb-9527-ae8b-e89b-2af08e2f54f4@amsat.org> (raw)
In-Reply-To: <20200603052308.11744-1-agrecascino123@gmail.com>
Hi Catherine,
On 6/3/20 7:23 AM, agrecascino123@gmail.com wrote:
> From: "Catherine A. Frederick" <chocola@animebitch.es>
>
> Signed-off-by: "Catherine A. Frederick" <chocola@animebitch.es>
> ---
> tcg/ppc/tcg-target.inc.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/tcg/ppc/tcg-target.inc.c b/tcg/ppc/tcg-target.inc.c
> index ee1f9227c1..a5450a5e67 100644
> --- a/tcg/ppc/tcg-target.inc.c
> +++ b/tcg/ppc/tcg-target.inc.c
> @@ -790,21 +790,25 @@ static inline void tcg_out_ext32u(TCGContext *s, TCGReg dst, TCGReg src)
>
> static inline void tcg_out_shli32(TCGContext *s, TCGReg dst, TCGReg src, int c)
> {
> + c = ((unsigned)c > 32) ? 32 : c;
> tcg_out_rlw(s, RLWINM, dst, src, c, 0, 31 - c);
> }
>
> static inline void tcg_out_shli64(TCGContext *s, TCGReg dst, TCGReg src, int c)
> {
> + c = ((unsigned)c > 64) ? 64 : c;
> tcg_out_rld(s, RLDICR, dst, src, c, 63 - c);
> }
>
> static inline void tcg_out_shri32(TCGContext *s, TCGReg dst, TCGReg src, int c)
> {
> + c = ((unsigned)c > 32) ? 32 : c;
> tcg_out_rlw(s, RLWINM, dst, src, 32 - c, c, 31);
> }
>
> static inline void tcg_out_shri64(TCGContext *s, TCGReg dst, TCGReg src, int c)
> {
> + c = ((unsigned)c > 64) ? 64 : c;
> tcg_out_rld(s, RLDICL, dst, src, 64 - c, c);
> }
I agree there is a bug, but I am not sure we should silently cap the
value this way. I'd rather see the caller provide a value in range, and
maybe the callee use 'tcg_debug_assert(c <= RANGE);' to catch future new
caller added missing the range check.
next prev parent reply other threads:[~2020-06-03 6:44 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-03 5:23 [PATCH] tcg: Sanitize shift constants on ppc64le so that shift operations with large constants don't generate invalid instructions agrecascino123
2020-06-03 6:43 ` Philippe Mathieu-Daudé [this message]
2020-06-03 16:09 ` Richard Henderson
-- strict thread matches above, loose matches on Subject: below --
2020-06-03 4:47 agrecascino123
2020-06-03 5:08 ` Catherine A. Frederick / mptcultist
2020-06-03 5:09 ` no-reply
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=2a0fa3cb-9527-ae8b-e89b-2af08e2f54f4@amsat.org \
--to=f4bug@amsat.org \
--cc=agrecascino123@gmail.com \
--cc=chocola@animebitch.es \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).