From: agrecascino123@gmail.com
To: qemu-devel@nongnu.org
Cc: "Catherine A. Frederick" <chocola@animebitch.es>, rth@twiddle.net
Subject: [PATCH] tcg: Sanitize shift constants on ppc64le so that shift operations with large constants don't generate invalid instructions.
Date: Wed, 3 Jun 2020 01:23:08 -0400 [thread overview]
Message-ID: <20200603052308.11744-1-agrecascino123@gmail.com> (raw)
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);
}
--
2.26.2
next reply other threads:[~2020-06-03 5:24 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-03 5:23 agrecascino123 [this message]
2020-06-03 6:43 ` [PATCH] tcg: Sanitize shift constants on ppc64le so that shift operations with large constants don't generate invalid instructions Philippe Mathieu-Daudé
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=20200603052308.11744-1-agrecascino123@gmail.com \
--to=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).