[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 02/16] tcg: Avoid stores to unaligned addresses
From: |
Richard Henderson |
Subject: |
[Qemu-devel] [PATCH v3 02/16] tcg: Avoid stores to unaligned addresses |
Date: |
Mon, 28 Apr 2014 12:28:08 -0700 |
From: Peter Maydell <address@hidden>
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.)
Reviewed-by: Alex Bennée <address@hidden>
Signed-off-by: Peter Maydell <address@hidden>
Signed-off-by: Richard Henderson <address@hidden>
---
tcg/tcg.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tcg/tcg.c b/tcg/tcg.c
index e71f7a0..293f00b 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
- [Qemu-devel] [PATCH v3 00/16] tcg: tidy the type of code_ptr, Richard Henderson, 2014/04/28
- [Qemu-devel] [PATCH v3 01/16] exec-all.h: Use stl_p to avoid undefined behaviour patching x86 jumps, Richard Henderson, 2014/04/28
- [Qemu-devel] [PATCH v3 02/16] tcg: Avoid stores to unaligned addresses,
Richard Henderson <=
- [Qemu-devel] [PATCH v3 04/16] tcg: Introduce byte pointer arithmetic helpers, Richard Henderson, 2014/04/28
- [Qemu-devel] [PATCH v3 05/16] tcg: Define tcg_insn_unit for code pointers, Richard Henderson, 2014/04/28
- [Qemu-devel] [PATCH v3 03/16] tcg: Avoid undefined behaviour patching code at unaligned addresses, Richard Henderson, 2014/04/28
- [Qemu-devel] [PATCH v3 06/16] tcg-i386: Define TCG_TARGET_INSN_UNIT_SIZE, Richard Henderson, 2014/04/28