From patchwork Mon Apr 28 19:28:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 29270 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f199.google.com (mail-ie0-f199.google.com [209.85.223.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 71437202FE for ; Mon, 28 Apr 2014 19:30:13 +0000 (UTC) Received: by mail-ie0-f199.google.com with SMTP id at1sf10700908iec.6 for ; Mon, 28 Apr 2014 12:30:12 -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=dd81uf89a+TjzCzRDEQzzUO6buIX4H/sHflcCD9eHIw=; b=QSFpesS7WT0q4Yy5SnSIk+BCojkWLBaO3qfXDg9gY+zh5Bn9Y2Ygh2idn6dRah+PGY vHDUmmFOF36O+t7jfiJSg1Rf470pi+EBqqBHUVLiD7hjvQJXNJuxoVAzppnE9640RQh0 3E+hykm0qhdWvP+FucrSofzP//8mUlz+C2+gKwyJOpQ/7qZTUcMNMKgNsCd0BoGbi+YJ Lw4nu+gEDFS0qI2g2hORkuu3pPRqFoEOcJ11TIV1ZwTz1X99VfYzFLpv9I3XqNTvO/7F 122NinnfHZrqEIud0U3R6o5YsT6zJf0bOvENieesTduDKQDVQ1lnDa/yf3G4B7/j+yi0 e3MA== X-Gm-Message-State: ALoCoQkfx/a0lMh541hUvbZVXYrepcor7phjDjFdIZobC9srIkakav62jRWkRjbyiQCDdQZLqfI8 X-Received: by 10.183.1.7 with SMTP id bc7mr3743268obd.47.1398713412929; Mon, 28 Apr 2014 12:30:12 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.23.106 with SMTP id 97ls2882491qgo.34.gmail; Mon, 28 Apr 2014 12:30:12 -0700 (PDT) X-Received: by 10.220.163.3 with SMTP id y3mr25250534vcx.7.1398713412746; Mon, 28 Apr 2014 12:30:12 -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 w15si3887820vcz.181.2014.04.28.12.30.12 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 28 Apr 2014 12:30:12 -0700 (PDT) Received-SPF: none (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) client-ip=2607:f8b0:400c:c01::22f; Received: by mail-ve0-f175.google.com with SMTP id oz11so8564568veb.20 for ; Mon, 28 Apr 2014 12:30:12 -0700 (PDT) X-Received: by 10.220.105.130 with SMTP id t2mr25235464vco.18.1398713412671; Mon, 28 Apr 2014 12:30:12 -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 ib8csp141351vcb; Mon, 28 Apr 2014 12:30:12 -0700 (PDT) X-Received: by 10.140.23.7 with SMTP id 7mr34709384qgo.0.1398713411662; Mon, 28 Apr 2014 12:30:11 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id t10si8353294qci.39.2014.04.28.12.30.11 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 28 Apr 2014 12:30:11 -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]:45600 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WerFi-0006Ms-OB for patch@linaro.org; Mon, 28 Apr 2014 15:30:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60089) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WerEb-0005Ri-Dl for qemu-devel@nongnu.org; Mon, 28 Apr 2014 15:29:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WerEW-0008Mj-An for qemu-devel@nongnu.org; Mon, 28 Apr 2014 15:29:01 -0400 Received: from mail-qg0-x230.google.com ([2607:f8b0:400d:c04::230]:37716) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WerEW-0008MY-6h for qemu-devel@nongnu.org; Mon, 28 Apr 2014 15:28:56 -0400 Received: by mail-qg0-f48.google.com with SMTP id q108so7406418qgd.7 for ; Mon, 28 Apr 2014 12:28:55 -0700 (PDT) X-Received: by 10.140.40.239 with SMTP id x102mr34400851qgx.16.1398713335812; Mon, 28 Apr 2014 12:28:55 -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 v9sm34841261qav.28.2014.04.28.12.28.54 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Apr 2014 12:28:55 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 28 Apr 2014 12:28:07 -0700 Message-Id: <1398713302-29657-2-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1398713302-29657-1-git-send-email-rth@twiddle.net> References: <1398713302-29657-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::230 Cc: Peter Maydell Subject: [Qemu-devel] [PATCH v3 01/16] exec-all.h: Use stl_p to avoid undefined behaviour patching x86 jumps 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: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) 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 The code which patches x86 jump instructions assumes it can do an unaligned write of a uint32_t. This is actually safe on x86, but it's still undefined behaviour. We have infrastructure for doing efficient unaligned accesses which doesn't engage in undefined behaviour, so use it. This is technically fractionally less efficient, at least with gcc 4.6; instead of one instruction: 7b2: 89 3e mov %edi,(%rsi) we get an extra spurious store to the stack slot: 7b2: 89 7c 24 64 mov %edi,0x64(%rsp) 7b6: 89 3e mov %edi,(%rsi) Reviewed-by: Alex Bennée Signed-off-by: Peter Maydell Signed-off-by: Richard Henderson --- include/exec/exec-all.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index f9ac332..1c49a21 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -229,7 +229,7 @@ void ppc_tb_set_jmp_target(unsigned long jmp_addr, unsigned long addr); static inline void tb_set_jmp_target1(uintptr_t jmp_addr, uintptr_t addr) { /* patch the branch destination */ - *(uint32_t *)jmp_addr = addr - (jmp_addr + 4); + stl_p((void*)jmp_addr, addr - (jmp_addr + 4)); /* no need to flush icache explicitly */ } #elif defined(__aarch64__)