From patchwork Tue Apr 1 20:53:27 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 27574 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f197.google.com (mail-pd0-f197.google.com [209.85.192.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 860DD20553 for ; Tue, 1 Apr 2014 20:54:55 +0000 (UTC) Received: by mail-pd0-f197.google.com with SMTP id fp1sf26093468pdb.4 for ; Tue, 01 Apr 2014 13:54:54 -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=iJVyVhQmCtab3amx/sVg2kmLcp7w5hQD87Zdcdhae6s=; b=ITmTGmWI2XNj1XDFJXG1Lv8QLHExwhAt/9kcYgps+AopgWDCwJpxsFiWSfkDkUhoXa D8EgIBHtEuDD8urvbiic1XOJcwW0FAwAzbfKkfM65h3oyfuaR6XQIH3wucWQ1dYuVhJP fEjo/p24TQjWkWh2i6t24YQXaPd/Qw+5s2YefTEJVg5Wbzdbki5pA9NQHvrkQdmdHg5v hu8KNWmLIyrdEjTXuQfy8eqZj9h2uLLmgDY1uqHYcQUtVNfAizyY02zkODCeIXPg/y6f qUFkbsg6XYDZ2s1t4yRgsNbh7vX+Lj/0D5mSMQcocOhG9URTGf98piXb4dJPvvvpI3E3 QaHg== X-Gm-Message-State: ALoCoQlqYSL0haHSb0rO4N9jVUgr+CKwQY6vROvovrljEwvefgp3fSvI9rlygLa6qVbMXYSX1RIS X-Received: by 10.66.141.231 with SMTP id rr7mr7361466pab.47.1396385694545; Tue, 01 Apr 2014 13:54:54 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.44.72 with SMTP id f66ls125515qga.47.gmail; Tue, 01 Apr 2014 13:54:54 -0700 (PDT) X-Received: by 10.52.141.105 with SMTP id rn9mr2101431vdb.44.1396385694440; Tue, 01 Apr 2014 13:54:54 -0700 (PDT) Received: from mail-vc0-x229.google.com (mail-vc0-x229.google.com [2607:f8b0:400c:c03::229]) by mx.google.com with ESMTPS id b4si3851786vck.115.2014.04.01.13.54.54 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 01 Apr 2014 13:54:54 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c03::229 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c03::229; Received: by mail-vc0-f169.google.com with SMTP id ik5so10632422vcb.14 for ; Tue, 01 Apr 2014 13:54:54 -0700 (PDT) X-Received: by 10.52.104.33 with SMTP id gb1mr2103189vdb.45.1396385694361; Tue, 01 Apr 2014 13:54:54 -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.12.8 with SMTP id v8csp269393vcv; Tue, 1 Apr 2014 13:54:54 -0700 (PDT) X-Received: by 10.224.5.136 with SMTP id 8mr38773658qav.42.1396385693848; Tue, 01 Apr 2014 13:54:53 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id f91si8189878qga.128.2014.04.01.13.54.53 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 01 Apr 2014 13:54:53 -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]:34340 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WV5ht-0001s4-GV for patch@linaro.org; Tue, 01 Apr 2014 16:54:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46308) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WV5gt-0000pX-Sz for qemu-devel@nongnu.org; Tue, 01 Apr 2014 16:53:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WV5gn-0007VV-Vb for qemu-devel@nongnu.org; Tue, 01 Apr 2014 16:53:51 -0400 Received: from mail-qg0-x22f.google.com ([2607:f8b0:400d:c04::22f]:39056) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WV5gn-0007VQ-Qv for qemu-devel@nongnu.org; Tue, 01 Apr 2014 16:53:45 -0400 Received: by mail-qg0-f47.google.com with SMTP id 63so9563341qgz.20 for ; Tue, 01 Apr 2014 13:53:45 -0700 (PDT) X-Received: by 10.224.125.194 with SMTP id z2mr5154668qar.99.1396385625265; Tue, 01 Apr 2014 13:53:45 -0700 (PDT) Received: from pike.twiddle.home.com (50-194-63-110-static.hfc.comcastbusiness.net. [50.194.63.110]) by mx.google.com with ESMTPSA id g20sm36923963qaq.4.2014.04.01.13.53.43 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 Apr 2014 13:53:44 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 1 Apr 2014 13:53:27 -0700 Message-Id: <1396385614-19267-3-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1396385614-19267-1-git-send-email-rth@twiddle.net> References: <1396385614-19267-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:c04::22f Cc: peter.maydell@linaro.org Subject: [Qemu-devel] [PATCH v2 2/9] 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=neutral (google.com: 2607:f8b0:400c:c03::229 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) 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 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; }