summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Henderson2017-08-02 23:50:04 +0200
committerRichard Henderson2017-08-03 20:00:30 +0200
commit13aaef678ed377b12b76dc7fb9e615b2f2f9047b (patch)
tree09e909211ba5944c2ad0697c5b56561146723b93
parenttarget/s390x: Fix CSST for 16-byte store (diff)
downloadqemu-13aaef678ed377b12b76dc7fb9e615b2f2f9047b.tar.gz
qemu-13aaef678ed377b12b76dc7fb9e615b2f2f9047b.tar.xz
qemu-13aaef678ed377b12b76dc7fb9e615b2f2f9047b.zip
tcg: Increase minimum alignment from tcg_malloc to 8
For a 64-bit ILP32 host, aligning to sizeof(long) is not enough. Guess the minimum for any host is 8, as that covers uint64_t. Qemu doesn't use a host long double or host vectors, except in extremely limited circumstances. Fixes a bus error for a sparc v8plus host. Signed-off-by: Richard Henderson <rth@twiddle.net>
-rw-r--r--tcg/tcg.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/tcg/tcg.h b/tcg/tcg.h
index da78721a0d..17b7750ee6 100644
--- a/tcg/tcg.h
+++ b/tcg/tcg.h
@@ -762,7 +762,10 @@ static inline void *tcg_malloc(int size)
{
TCGContext *s = &tcg_ctx;
uint8_t *ptr, *ptr_end;
- size = (size + sizeof(long) - 1) & ~(sizeof(long) - 1);
+
+ /* ??? This is a weak placeholder for minimum malloc alignment. */
+ size = QEMU_ALIGN_UP(size, 8);
+
ptr = s->pool_cur;
ptr_end = ptr + size;
if (unlikely(ptr_end > s->pool_end)) {