From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35183) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ddKbn-0006OS-0D for qemu-devel@nongnu.org; Thu, 03 Aug 2017 14:12:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ddKbm-0003Dl-73 for qemu-devel@nongnu.org; Thu, 03 Aug 2017 14:12:31 -0400 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]:37812) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ddKbm-0003D8-1S for qemu-devel@nongnu.org; Thu, 03 Aug 2017 14:12:30 -0400 Received: by mail-pf0-x243.google.com with SMTP id p13so2180241pfd.4 for ; Thu, 03 Aug 2017 11:12:30 -0700 (PDT) Sender: Richard Henderson From: Richard Henderson Date: Thu, 3 Aug 2017 11:12:24 -0700 Message-Id: <20170803181224.21748-4-rth@twiddle.net> In-Reply-To: <20170803181224.21748-1-rth@twiddle.net> References: <20170803181224.21748-1-rth@twiddle.net> Subject: [Qemu-devel] [PULL for-2.10 3/3] tcg: Increase minimum alignment from tcg_malloc to 8 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org 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 --- tcg/tcg.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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)) { -- 2.13.3