From patchwork Wed Jun 28 14:58:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 9814557 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 CF5E6603F2 for ; Wed, 28 Jun 2017 15:10:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C0CBB2855E for ; Wed, 28 Jun 2017 15:10:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B5066285D4; Wed, 28 Jun 2017 15:10:51 +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=-1.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 597202855E for ; Wed, 28 Jun 2017 15:10:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=uM0jgIhgE5Jz0x0DVHifiwNlr2gQ3ptXuZWkgy0Qujs=; b=nH9 j1I5UB6ZGJ5lnM2DJ+J4y0ZXPvlSgpTcnyIH4XRcMdxiaFnzgvh44qmm6BhtyS0I69436d6VPbUDo N22e63t6BMwBJFJy0OyyUuzQuT+WznnNV57msrE8TP74kmVSKQgDyxESF8RZ0qMZjuG5hk89elCC7 Yl2CnKFpm2jkSsdYKO2XpTG9ZOPiA/85zoC5NHyCZg53Iw29tar1JcCc0Ql8UJceJETmG4R4OVIXa WRqyUEb3CGXOVAGqa56zJJFvs3w1QRiEkeNylZ4adT0Fsj7I3SciCufgkWtd7WxoT3Wg8dyHEJHEF /63bhk/8zlQT6CWSB3Trr3/POvHa7BQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dQEcE-0000T1-8t; Wed, 28 Jun 2017 15:10:50 +0000 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dQEQM-0004tA-3O for linux-arm-kernel@lists.infradead.org; Wed, 28 Jun 2017 14:58:38 +0000 Received: by mail-wm0-x241.google.com with SMTP id 131so11997551wmq.2 for ; Wed, 28 Jun 2017 07:58:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=mv8G4CknsLx1z22SQ+D2K7+yPDmuWDfoCqviWTOdtGw=; b=RKnYDV4jCmy/A4dUVCyoJso915xHKBgqHQzlQcJt21tCcKXITeFO+FZBzRRc9v0cIz NfDkhpKT5MZyL387QXa+MY8AhzKAjK8DReQ0NDP1TLVrzUMCjcLFiGrnB4x0501qxWrA SKVsTAo9+TTnWw+HSTBhLaT2HLWRYf93a27Y2A4noTyq+wvLdFj9xeC+2GfcaXEmsere MHvbESqXHraypYhD3V2uJ2/pnm7Ea+5ZZ1yOKymxPmVnwhw9YjROH1SAUhbr3CIwuLtg 6S7WYApMA4BeYls5FY3LHOhRKmyIi+zUlqVKiv4iYtxwNyjwHPR2/I067Zl5NeTb0Ktw Z7TQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=mv8G4CknsLx1z22SQ+D2K7+yPDmuWDfoCqviWTOdtGw=; b=dqDrMejPWy1VHV3mrdXS5F2S6ikeIF/o5F+Om8un4zVvRhRTdlt4zm/s0GpqMCY12I VZ0dCLPEV7oq6cxsuh9aMi1v3Ao/Yomb/MqUAz8DYq6d9mtj3QZI4+OaPs2gg4Xb4k+U fb3fNl0H8YGWcpvzGT9A68Zw83rkSlmn8vwGEqy5YIfhFbAdS+NzuHrmpWEKcWF7o0au mctIJ1AUSGRKqFcmz8+NL5jRHrMeXiWtsya743AZ0usFe9RMXmNp+W5Jte+lc7shfcIJ DM9n7TXKHlI7NfikHCuR5rD5cx72DMRt4vDKw24tfKnGmfnmeYxQDTJZw1UpGd1zRV7N bGpQ== X-Gm-Message-State: AKS2vOyxPSO20DbMHEwUF3YuFlZgmI/XNYA+XDA+61niagnvbJ9bELeB caHyQLcP9i+/ww== X-Received: by 10.80.151.219 with SMTP id f27mr7875280edb.126.1498661893906; Wed, 28 Jun 2017 07:58:13 -0700 (PDT) Received: from localhost.localdomain ([2a02:a03f:837:f300:dc41:f6b3:4608:d7c8]) by smtp.gmail.com with ESMTPSA id j43sm1184346ede.18.2017.06.28.07.58.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Jun 2017 07:58:13 -0700 (PDT) From: Luc Van Oostenryck To: Will Deacon Subject: [PATCH] arm64: fix endianness annotation for aarch64_insn_write() Date: Wed, 28 Jun 2017 16:58:11 +0200 Message-Id: <20170628145811.24719-1-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.13.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170628_075834_840419_08881060 X-CRM114-Status: GOOD ( 11.88 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Daniel Borkmann , Suzuki K Poulose , Marc Zyngier , Catalin Marinas , Masami Hiramatsu , Luc Van Oostenryck , Laura Abbott , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP aarch64_insn_write() is used to write an instruction. As on ARM64 in-memory instructions are always stored in little-endian order, this function, taking the instruction opcode in native order, correctly convert it to little-endian before sending it to an helper function __aarch64_insn_write() which will do the effective write. This is all good, but the variable and argument holding the converted value are not annotated for a little-endian value but left for native values. Fix this by adjusting the prototype of the helper and directly using the result of cpu_to_le32() without passing by an intermediate variable (which was not a distinct one but the same as the one holding the native value). Signed-off-by: Luc Van Oostenryck --- arch/arm64/kernel/insn.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/arch/arm64/kernel/insn.c b/arch/arm64/kernel/insn.c index d4d80b32c..60a2f03d7 100644 --- a/arch/arm64/kernel/insn.c +++ b/arch/arm64/kernel/insn.c @@ -126,7 +126,7 @@ int __kprobes aarch64_insn_read(void *addr, u32 *insnp) return ret; } -static int __kprobes __aarch64_insn_write(void *addr, u32 insn) +static int __kprobes __aarch64_insn_write(void *addr, __le32 insn) { void *waddr = addr; unsigned long flags = 0; @@ -145,8 +145,7 @@ static int __kprobes __aarch64_insn_write(void *addr, u32 insn) int __kprobes aarch64_insn_write(void *addr, u32 insn) { - insn = cpu_to_le32(insn); - return __aarch64_insn_write(addr, insn); + return __aarch64_insn_write(addr, cpu_to_le32(insn)); } static bool __kprobes __aarch64_insn_hotpatch_safe(u32 insn)