From patchwork Tue Apr 17 21:32:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Henry Wertz X-Patchwork-Id: 10346927 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EFB0560542 for ; Tue, 17 Apr 2018 21:35:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DEC9C262F2 for ; Tue, 17 Apr 2018 21:35:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D1BCC26E5D; Tue, 17 Apr 2018 21:35:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6478B262F2 for ; Tue, 17 Apr 2018 21:35:25 +0000 (UTC) Received: from localhost ([::1]:36286 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f8YG4-0003WK-3c for patchwork-qemu-devel@patchwork.kernel.org; Tue, 17 Apr 2018 17:35:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53710) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f8YDS-0001Ym-BP for qemu-devel@nongnu.org; Tue, 17 Apr 2018 17:32:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f8YDQ-0006h5-28 for qemu-devel@nongnu.org; Tue, 17 Apr 2018 17:32:42 -0400 Received: from mail-wr0-x22a.google.com ([2a00:1450:400c:c0c::22a]:34759) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f8YDE-0005N7-M7; Tue, 17 Apr 2018 17:32:28 -0400 Received: by mail-wr0-x22a.google.com with SMTP id d19so39364014wre.1; Tue, 17 Apr 2018 14:32:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=wgSCCdXHJn46bNJNeP0G/CNBG38WxjsYiRq6mRz5whI=; b=a/iKrX2nCfJkne/xEB4T2VR1eN82xqfc52uBS/WsTka0DFvLJiESPQiRe4/7tzKvTW Mp2JPxWTM/5k2bBlPrLqrNhaPAOqwk/195DS38lJtdezc+EIaHqWMTEv7n1yyVI4NnUC 0atOQvGrgExGtNtaROEgBcVvxp7zmKEL90dHbc5B9iuIaAFjlFHpycSk5DaUPOohkiBH 3Y9UMwmqLkfPs5Ww+lhzRq7KztGZiMpn6bkJ7QS2powE7OFO3xw/4jw2K07+AWQpkdUs oBr7ufEm92E8TSK0Ctu3J2FerbAEI9Kk51ewhV2UHds5FFzsg66pFAyoiSMaCvnUseHM FYtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=wgSCCdXHJn46bNJNeP0G/CNBG38WxjsYiRq6mRz5whI=; b=Yh8zf34y0tNvf8dZNWsLWloL5TqKZPydwUYs5p8k6aNk1tHK2trCg5gb6oW55zBbHg 2OW7cNcpeMOxxP29ONWSFn13lVrANWCtD8ua6jzGN3/b55FxbfkRb/O8gE0wiPZYCeBH wnmSD5YEd5mp/GX6nYmqPBlPrllitR/5KLWxp345sqYX7iKTDexEce0Zvq2ays4Jzz9+ KYrcF/C0wUw1u54tocXEIb6li84pEZ6yECCoy4jF659cMihP0vNzNY81eE+u4uXioy4B U7mqZZyRjh9Po2xOu095N83WA9uQVjun9ci6GXgJ29QLOaqqySD3pkzBsKHnrW0PrkkG BUeQ== X-Gm-Message-State: ALQs6tAsCLnEFQ+lSyMNRs53wzXAlm6bvBWbS5GAgpxYGl0nlNF31jmU /udC/XFckP+sXJJr4hkO8R9/VRrrs0WV5VcAGKtZBmHaP8I= X-Google-Smtp-Source: AIpwx4+rekoV5zbvhaXE5mB6eA2xRox60NMQmY4HVM+Q+gaDk4cWiKuQ/E6J3G0sf0vEt9vqE8huZaHJNjBvJc8qkAY= X-Received: by 10.223.178.87 with SMTP id y23mr2736935wra.95.1524000747308; Tue, 17 Apr 2018 14:32:27 -0700 (PDT) MIME-Version: 1.0 Received: by 10.223.129.104 with HTTP; Tue, 17 Apr 2018 14:32:26 -0700 (PDT) From: Henry Wertz Date: Tue, 17 Apr 2018 16:32:26 -0500 Message-ID: To: qemu-arm , QEMU Developers X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::22a X-Content-Filtered-By: Mailman/MimeDel 2.1.21 Subject: [Qemu-devel] ARM memory barrier patch X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Please find submitted a patch for ARM memory barriers. This patch is against qemu-2.12-rc2 but I do believe it should apply for anything from 2.11.x to current. (the code being patched was added in for 2.11 series.) I found with qemu 2.11.x or newer that I would get an illegal instruction error running some Intel binaries on my ARM chromebook. On investigation, I found it was quitting on memory barriers. qemu instruction: mb $0x31 was translating as: 0x604050cc: 5bf07ff5 blpl #0x600250a8 After patch it gives: 0x604050cc: f57ff05b dmb ish In short, I found INSN_DMB_ISH (memory barrier for ARMv7) appeared to be correct based on online docs, but due to some endian-related shenanigans it had to be byte-swapped to suit qemu; it appears INSN_DMB_MCR (memory barrier for ARMv6) also should be byte swapped (and this patch does so). I have not checked for correctness of aarch64's barrier instruction. Signed-off-by: Henry Wertz Reviewed-by: Peter Maydell *** tcg/arm/tcg-target.inc.c.orig 2018-04-04 15:28:50.000000000 -0500 --- tcg/arm/tcg-target.inc.c 2018-04-16 12:55:04.917518898 -0500 *************** *** 158,167 **** INSN_LDRD_REG = 0x000000d0, INSN_STRD_IMM = 0x004000f0, INSN_STRD_REG = 0x000000f0, ! INSN_DMB_ISH = 0x5bf07ff5, ! INSN_DMB_MCR = 0xba0f07ee, /* Architected nop introduced in v6k. */ /* ??? This is an MSR (imm) 0,0,0 insn. Anyone know if this also Just So Happened to do nothing on pre-v6k so that we --- 158,167 ---- INSN_LDRD_REG = 0x000000d0, INSN_STRD_IMM = 0x004000f0, INSN_STRD_REG = 0x000000f0, ! INSN_DMB_ISH = 0xf57ff05b, ! INSN_DMB_MCR = 0xee070fba, /* Architected nop introduced in v6k. */ /* ??? This is an MSR (imm) 0,0,0 insn. Anyone know if this also Just So Happened to do nothing on pre-v6k so that we