From patchwork Fri Mar 28 15:29:47 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 27308 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f71.google.com (mail-yh0-f71.google.com [209.85.213.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 19F7E2066E for ; Fri, 28 Mar 2014 15:29:52 +0000 (UTC) Received: by mail-yh0-f71.google.com with SMTP id a41sf12051030yho.10 for ; Fri, 28 Mar 2014 08:29:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=gGvpdzu5UW4kc0RPu2UREzgpK8dFuvWmrx8itklXll0=; b=Y1rWkln51AngRHCEnbr5wg/SnOd4YvPN/iJtUYGpe74tzuevVmj1YTQtPvR8MKuZ1F OMmEo7AzAFAvCFc0i0NIq5EVRZOX/GYRAgOS9xjykfGTb8PBOIdrPWkxCfDpDN6iGxHD LbmTeqJZXmbYCCOv+QTBzIYZfAhttrJyb9cvixcLb5w4oEbSKqBPtSy3pBgRzUlhd9Tm 2STmAiWcro+CK9eHlumsvFrleG0NE3Xhul71d45YydZBK74e4j2WZh/wHU53jmW9hPK9 oHsYNsYNPzm+hTuTywiZovNVynN/FX7wDjfTkvK57iEKskmp6X49pHkq5eF240FzSbW6 tyZA== X-Gm-Message-State: ALoCoQkiNpH/3qc6h9TkoatKORh6+PDZinL0Hp2x61ZpUVxelEYCDZAIq5je5kr8JtjOalLYSJWR X-Received: by 10.236.144.102 with SMTP id m66mr3142503yhj.50.1396020592788; Fri, 28 Mar 2014 08:29:52 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.50.81 with SMTP id r75ls1571901qga.71.gmail; Fri, 28 Mar 2014 08:29:52 -0700 (PDT) X-Received: by 10.58.238.35 with SMTP id vh3mr7650173vec.16.1396020592692; Fri, 28 Mar 2014 08:29:52 -0700 (PDT) Received: from mail-vc0-f177.google.com (mail-vc0-f177.google.com [209.85.220.177]) by mx.google.com with ESMTPS id rx10si1302579vdc.60.2014.03.28.08.29.52 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 28 Mar 2014 08:29:52 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.177 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.177; Received: by mail-vc0-f177.google.com with SMTP id if17so5881209vcb.22 for ; Fri, 28 Mar 2014 08:29:52 -0700 (PDT) X-Received: by 10.220.92.135 with SMTP id r7mr7724127vcm.11.1396020592624; Fri, 28 Mar 2014 08:29:52 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.12.8 with SMTP id v8csp17450vcv; Fri, 28 Mar 2014 08:29:52 -0700 (PDT) X-Received: by 10.205.64.71 with SMTP id xh7mr686707bkb.81.1396020590982; Fri, 28 Mar 2014 08:29:50 -0700 (PDT) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id tm4si677036bkb.236.2014.03.28.08.29.50 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 28 Mar 2014 08:29:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::1 as permitted sender) client-ip=2001:8b0:1d0::1; Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1WTYj6-0000Z3-S3; Fri, 28 Mar 2014 15:29:48 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Richard Henderson Subject: [RFC 2/3] tcg: Avoid stores to unaligned addresses Date: Fri, 28 Mar 2014 15:29:47 +0000 Message-Id: <1396020588-2137-3-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1396020588-2137-1-git-send-email-peter.maydell@linaro.org> References: <1396020588-2137-1-git-send-email-peter.maydell@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.177 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 Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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.) Signed-off-by: Peter Maydell Reviewed-by: Andreas Färber --- 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; }