From patchwork Sat Mar 29 00:27:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 27384 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ig0-f198.google.com (mail-ig0-f198.google.com [209.85.213.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D883020062 for ; Sat, 29 Mar 2014 00:28:35 +0000 (UTC) Received: by mail-ig0-f198.google.com with SMTP id ur14sf3782890igb.9 for ; Fri, 28 Mar 2014 17:28:35 -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:date :message-id:in-reply-to:references: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; bh=Hg3eeanaYmXEdCKsnVcJrdYTZlDBXUEcKrOTyT5FXWc=; b=NGDckxzOTxnODS0ufMKUxlUOIX6vnEqh0dJwCZUdKp+dQEQ52iQ1fM6uAXAeE51niD eaVVN6KheO3ZMLxlvCa93FCUUUapUlU4SWgcOpH79H/sgLYveX3qWkCX01L+F2YIX4MF xNUwSAHVijSZi7p5fnc8NNbC9M7qXXov3SHlL5NOHhLClVluuz0GG8orVu9tW4uit64v xTQT4CIN/T89xFJwKzG1n8NhpocX9TsXFiAi+QIdw3bUmZH/+hXnQsenO+IDQDnqyH3f VGK8q7k7qouFadNNflgnMLQbyi77vBbb+PAk9AmyOr1JHzuWW1f0KM0HemSFL/xN1S5U iJXQ== X-Gm-Message-State: ALoCoQl7kc5xHyRwecNTYSyocWKUEhitXPiTNtSquGGEm6T5jMt1cotWrsCXvMGhI7o611w5QaOs X-Received: by 10.182.11.70 with SMTP id o6mr4414111obb.19.1396052915310; Fri, 28 Mar 2014 17:28:35 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.86.170 with SMTP id p39ls190046qgd.49.gmail; Fri, 28 Mar 2014 17:28:35 -0700 (PDT) X-Received: by 10.52.69.146 with SMTP id e18mr8175847vdu.15.1396052915210; Fri, 28 Mar 2014 17:28:35 -0700 (PDT) Received: from mail-ve0-x22f.google.com (mail-ve0-x22f.google.com [2607:f8b0:400c:c01::22f]) by mx.google.com with ESMTPS id uq6si1596219vcb.0.2014.03.28.17.28.35 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 28 Mar 2014 17:28:35 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c01::22f 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:c01::22f; Received: by mail-ve0-f175.google.com with SMTP id oz11so6394627veb.34 for ; Fri, 28 Mar 2014 17:28:35 -0700 (PDT) X-Received: by 10.58.185.145 with SMTP id fc17mr10084110vec.14.1396052915124; Fri, 28 Mar 2014 17:28:35 -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 v8csp48429vcv; Fri, 28 Mar 2014 17:28:34 -0700 (PDT) X-Received: by 10.224.137.5 with SMTP id u5mr12968846qat.12.1396052914782; Fri, 28 Mar 2014 17:28:34 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id b42si3276732qge.199.2014.03.28.17.28.34 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 28 Mar 2014 17:28:34 -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]:36561 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WTh8U-0007hx-BO for patch@linaro.org; Fri, 28 Mar 2014 20:28:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51502) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WTh7T-0006dv-GQ for qemu-devel@nongnu.org; Fri, 28 Mar 2014 20:27:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WTh7N-0006hw-O4 for qemu-devel@nongnu.org; Fri, 28 Mar 2014 20:27:31 -0400 Received: from mail-qg0-x233.google.com ([2607:f8b0:400d:c04::233]:35266) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WTh7N-0006hs-J9 for qemu-devel@nongnu.org; Fri, 28 Mar 2014 20:27:25 -0400 Received: by mail-qg0-f51.google.com with SMTP id q108so1681482qgd.10 for ; Fri, 28 Mar 2014 17:27:25 -0700 (PDT) X-Received: by 10.224.151.130 with SMTP id c2mr7970303qaw.67.1396052845221; Fri, 28 Mar 2014 17:27:25 -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 x5sm13105906qaj.9.2014.03.28.17.27.23 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Mar 2014 17:27:24 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 28 Mar 2014 17:27:08 -0700 Message-Id: <1396052834-26834-3-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1396052834-26834-1-git-send-email-rth@twiddle.net> References: <1396052834-26834-1-git-send-email-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400d:c04::233 Cc: peter.maydell@linaro.org, aurelien@aurel32.net Subject: [Qemu-devel] [PATCH 2/8] 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:c01::22f 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.) Signed-off-by: Peter Maydell Signed-off-by: Richard Henderson Reviewed-by: Alex Bennée --- 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; }