From patchwork Mon May 12 23:30:50 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 29999 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f71.google.com (mail-pa0-f71.google.com [209.85.220.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id BA967203F3 for ; Mon, 12 May 2014 23:37:00 +0000 (UTC) Received: by mail-pa0-f71.google.com with SMTP id kq14sf29688893pab.10 for ; Mon, 12 May 2014 16:37:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:mime-version:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list:content-type :content-transfer-encoding; bh=JvB5cO2ZWTj13YEZaRWeeaUeCzBjek2s1vnJYaUmpoQ=; b=AVGQrGNjzm64JwvnKwFcrofvGTmP02DU/FqUMXeFLCbZymtzqDeKEwkLRx0XWMZLjG k3Lfl5SUkO508uiB9VHewlUoAYj5k0y0slePDqTQ45qzIHJKOfYYfSkULlM1p5djRuEr /DCvwZDU6yvMhKvLo7zloyPMHcrVv2jHIZNg43ysw5jSU5mCgaDMwoH6x7DBFCsE0RDJ pPVareZ3MiyTlkSPa0U3xxk1CN+nGtnm5+5295b1TEZNS5ajxIH8qhHqWCteiEDkdO4d N9s0sUzgB0Z4i8TcCRu3Didd369p9fSvzSYvAKk5yafHjgzGNJZK7VQ6U64q47zwryyz xYsA== X-Gm-Message-State: ALoCoQlh5qfy1CtFlpSwAqb92uIGyKHWVGs8I2i0woW6Zp6g2G6uLG8pywRj8pxFhJewR1pyieoC X-Received: by 10.66.137.105 with SMTP id qh9mr13777486pab.30.1399937820014; Mon, 12 May 2014 16:37:00 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.33.164 with SMTP id j33ls1678425qgj.73.gmail; Mon, 12 May 2014 16:36:59 -0700 (PDT) X-Received: by 10.52.72.138 with SMTP id d10mr21502974vdv.15.1399937819911; Mon, 12 May 2014 16:36:59 -0700 (PDT) Received: from mail-ve0-x229.google.com (mail-ve0-x229.google.com [2607:f8b0:400c:c01::229]) by mx.google.com with ESMTPS id tj4si2322925vdc.159.2014.05.12.16.36.59 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 12 May 2014 16:36:59 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2607:f8b0:400c:c01::229 as permitted sender) client-ip=2607:f8b0:400c:c01::229; Received: by mail-ve0-f169.google.com with SMTP id jx11so9963311veb.0 for ; Mon, 12 May 2014 16:36:59 -0700 (PDT) X-Received: by 10.220.69.72 with SMTP id y8mr25674481vci.21.1399937819798; Mon, 12 May 2014 16:36:59 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp106588vcb; Mon, 12 May 2014 16:36:59 -0700 (PDT) X-Received: by 10.224.163.17 with SMTP id y17mr42478078qax.44.1399937818677; Mon, 12 May 2014 16:36:58 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id u105si6908386qgu.45.2014.05.12.16.36.58 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 12 May 2014 16:36:58 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:40613 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WjzmE-0001Ay-8j for patch@linaro.org; Mon, 12 May 2014 19:36:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59132) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WjzhL-0004cL-4b for qemu-devel@nongnu.org; Mon, 12 May 2014 19:32:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WjzhG-0005lp-Cr for qemu-devel@nongnu.org; Mon, 12 May 2014 19:31:55 -0400 Received: from mail-qc0-x22d.google.com ([2607:f8b0:400d:c01::22d]:39232) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WjzhG-0005lf-9M for qemu-devel@nongnu.org; Mon, 12 May 2014 19:31:50 -0400 Received: by mail-qc0-f173.google.com with SMTP id i8so8760659qcq.32 for ; Mon, 12 May 2014 16:31:49 -0700 (PDT) X-Received: by 10.229.96.199 with SMTP id i7mr42945071qcn.20.1399937509916; Mon, 12 May 2014 16:31:49 -0700 (PDT) Received: from anchor.com (50-194-63-110-static.hfc.comcastbusiness.net. [50.194.63.110]) by mx.google.com with ESMTPSA id m7sm23815931qae.35.2014.05.12.16.31.47 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 May 2014 16:31:48 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 12 May 2014 16:30:50 -0700 Message-Id: <1399937474-6530-3-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1399937474-6530-1-git-send-email-rth@twiddle.net> References: <1399937474-6530-1-git-send-email-rth@twiddle.net> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400d:c01::22d Cc: peter.maydell@linaro.org Subject: [Qemu-devel] [PULL 02/26] tcg: Avoid stores to unaligned addresses X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Original-Sender: rth@twiddle.net X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2607:f8b0:400c:c01::229 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=fail header.i=@gmail.com Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 From: Peter Maydell 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 Signed-off-by: Peter Maydell Signed-off-by: Richard Henderson --- 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; }