From: Richard Henderson <rth@twiddle.net>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, aurelien@aurel32.net
Subject: [Qemu-devel] [PATCH 2/8] tcg: Avoid stores to unaligned addresses
Date: Fri, 28 Mar 2014 17:27:08 -0700 [thread overview]
Message-ID: <1396052834-26834-3-git-send-email-rth@twiddle.net> (raw)
In-Reply-To: <1396052834-26834-1-git-send-email-rth@twiddle.net>
From: Peter Maydell <peter.maydell@linaro.org>
Avoid stores to unaligned addresses in TCG code generation, by using the
usual memcpy() approach. (Using bswap.h would drag a lot of QEMU baggage
into TCG, so it's simpler just to do direct memcpy() here.)
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
---
tcg/tcg.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tcg/tcg.c b/tcg/tcg.c
index f1e0763..60f06c5 100644
--- a/tcg/tcg.c
+++ b/tcg/tcg.c
@@ -125,21 +125,21 @@ static inline void tcg_out8(TCGContext *s, uint8_t v)
static inline void tcg_out16(TCGContext *s, uint16_t v)
{
uint8_t *p = s->code_ptr;
- *(uint16_t *)p = v;
+ memcpy(p, &v, sizeof(v));
s->code_ptr = p + 2;
}
static inline void tcg_out32(TCGContext *s, uint32_t v)
{
uint8_t *p = s->code_ptr;
- *(uint32_t *)p = v;
+ memcpy(p, &v, sizeof(v));
s->code_ptr = p + 4;
}
static inline void tcg_out64(TCGContext *s, uint64_t v)
{
uint8_t *p = s->code_ptr;
- *(uint64_t *)p = v;
+ memcpy(p, &v, sizeof(v));
s->code_ptr = p + 8;
}
--
1.9.0
next prev parent reply other threads:[~2014-03-29 0:27 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-29 0:27 [Qemu-devel] [PATCH 0/8] tcg: tidy the type of code_ptr Richard Henderson
2014-03-29 0:27 ` [Qemu-devel] [PATCH 1/8] exec-all.h: Use stl_p to avoid undefined behaviour patching x86 jumps Richard Henderson
2014-04-01 12:09 ` [Qemu-devel] [PATCH 1/8] exec-all.h: Use stl_p to avoid undefinedbehaviour patching x86 jumpss Alex Bennée
2014-04-01 12:18 ` Peter Maydell
2014-03-29 0:27 ` Richard Henderson [this message]
2014-04-01 12:12 ` [Qemu-devel] [PATCH 2/8] tcg: Avoid stores to unaligned addresses Alex Bennée
2014-03-29 0:27 ` [Qemu-devel] [PATCH 3/8] tcg: Avoid undefined behaviour patching code at " Richard Henderson
2014-04-01 12:13 ` [Qemu-devel] [PATCH 3/8] tcg: Avoid undefined behaviour patchingcode at unaligned addressess Alex Bennée
2014-03-29 0:27 ` [Qemu-devel] [PATCH 4/8] tcg: Define tcg_itype for code pointers Richard Henderson
2014-03-29 0:27 ` [Qemu-devel] [PATCH 5/8] tcg-ppc64: Define TCG_TARGET_ITYPE_SIZE Richard Henderson
2014-03-29 0:27 ` [Qemu-devel] [PATCH 6/8] tcg-ppc: " Richard Henderson
2014-03-29 0:27 ` [Qemu-devel] [PATCH 7/8] tcg-aarch64: " Richard Henderson
2014-03-29 0:27 ` [Qemu-devel] [PATCH 8/8] tcg-sparc: " Richard Henderson
2014-03-29 20:26 ` [Qemu-devel] [PATCH 0/8] tcg: tidy the type of code_ptr Peter Maydell
2014-03-30 15:31 ` Richard Henderson
2014-03-31 3:19 ` Richard Henderson
2014-04-01 12:05 ` Alex Bennée
2014-04-01 12:19 ` Alex Bennée
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=1396052834-26834-3-git-send-email-rth@twiddle.net \
--to=rth@twiddle.net \
--cc=aurelien@aurel32.net \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.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 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).