From patchwork Wed Jun 28 14:58:03 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: 9814733 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 99BB360365 for ; Wed, 28 Jun 2017 15:39:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8A48C1FFAE for ; Wed, 28 Jun 2017 15:39:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7D551251F4; Wed, 28 Jun 2017 15:39:43 +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 5E7C01FFAE for ; Wed, 28 Jun 2017 15:39:42 +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=HYIcDpxdVaohCQEUT/+5LbdAGWCOr0K3tzrJS/OigSI=; b=qMJ fuVGcfQIPcXO0tjaIaUiDTgcNisraFhOlEuc4Wiu0uSiPwkdCl0pYfbC737hwlbbS1tMSimAMll4h IFsHvYMNlgaFX4A0zRlsfvVWNlNUT7eaGSoD6NZ0uHeRM+5OvkHK/GXUg5j/ftcQoVMsibccKsg43 fq6ElO7wB3+BzDOHcY2jWN4bTwEMaW9FqHW5nkjfYUIM2wsYs4kFHjLvEPUt7kYvheGUfEMFjAh1e pqcgjtZ6SwJ+wHB8JRQdcpYqnCkWShht9+cgctXt8kEnj08uZe4COGH7pS0et3tbnc4F6vYcWIniW 3GTmrPEt7Xob68wL+p4zOX0ukgQDYGg==; 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 1dQF4A-00050T-25; Wed, 28 Jun 2017 15:39:42 +0000 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dQEQE-0004sb-A2 for linux-arm-kernel@lists.infradead.org; Wed, 28 Jun 2017 14:58:28 +0000 Received: by mail-wm0-x242.google.com with SMTP id j85so12027740wmj.0 for ; Wed, 28 Jun 2017 07:58:06 -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=EePf1xRPv668s3Sum0FD/1SdEdj4yfrcKWS+7FALWZQ=; b=KiQjS7wThhq4PYyjA7h10y53orM9+u6YBis8lqhnqQQFJwNVluSOKh7UaH/vPRsVv8 e6fQLHp2+PjtSP9DFPerj/5PegblsFnQSWDc4lDpElCJ+BWkwo3rlqnmEkmqHQ73LklL n7Cj2OdNEZWPvdhQYlEeHtWUvMo8sIP8EiRlJ/hbfQMuGJoBLw5T6iIZd0ff78Ugy3l0 zRgLEEq+Ivh8QN7vqImKKKsEj3x798lCgNKUfkBaszJzb3xD8ENC2CIhDBIJ/4ghNErb exgkZy+Nx1W4xkInuOzz+gReuj2qWlHvF8aOdWpc+aY51gWYtnidKa4Fv2ZKfK633rqF VH5g== 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=EePf1xRPv668s3Sum0FD/1SdEdj4yfrcKWS+7FALWZQ=; b=eIKEGI9Z5t7128uuLIpwgTZ7jzbXhbyGNJqExn9iqMjsGSIPQp+3VyIe20iP2xc1EA y9pZ9n+9UvuOeS5oVRVSQ1ar/o7v0yWvoWG8xFJQh/nlPNXt1uDgW4Sn6p+s8TVsMmCm W9Eo3PnYFij3R/oWjAQ4dk1aoRgVkir2Ef69KCWBBa3VqPOdZxYScFprCeJU7UwhvVsE sqXgRjlFn8wet5mKoRax8DrbmlQc1WSiyvUXuWOLuXKE9HFCb0Xq1xZVbQhKJ+5F1XMJ Xqry5AHXqAzx7Ndl84mCdu1z06E6itxB1dYnmjF/BVCClxFoVlz7LOVuiMyKFAagfmJB snqQ== X-Gm-Message-State: AKS2vOy24010eZZQ3hRSGtJV9gw3iL2VOfnIxozbKeQUrgxseXiW9XDB evx/Ely3o/c0UQ== X-Received: by 10.80.181.80 with SMTP id z16mr7975297edd.6.1498661884912; Wed, 28 Jun 2017 07:58:04 -0700 (PDT) Received: from localhost.localdomain ([91.177.84.115]) by smtp.gmail.com with ESMTPSA id m41sm2513179edd.37.2017.06.28.07.58.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Jun 2017 07:58:04 -0700 (PDT) From: Luc Van Oostenryck To: Will Deacon Subject: [PATCH] arm64: fix endianness annotation for 'struct jit_ctx' and friends Date: Wed, 28 Jun 2017 16:58:03 +0200 Message-Id: <20170628145803.24543-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_075826_602817_60C68207 X-CRM114-Status: GOOD ( 12.69 ) 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: Daniel Borkmann , Catalin Marinas , Alexei Starovoitov , Luc Van Oostenryck , Laura Abbott , "David S. Miller" , 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 struct jit_ctx::image is used the store a pointer to the jitted intructions, which are always little-endian. These instructions are thus correctly converted from native order to little-endian before being stored but the pointer 'image' is declared as for native order values. Fix this by declaring the field as __le32* instead of u32*. Same for the pointer used in jit_fill_hole() to initialize the image. Signed-off-by: Luc Van Oostenryck --- arch/arm64/net/bpf_jit_comp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c index c870d6f01..8860bb9c3 100644 --- a/arch/arm64/net/bpf_jit_comp.c +++ b/arch/arm64/net/bpf_jit_comp.c @@ -70,7 +70,7 @@ struct jit_ctx { int idx; int epilogue_offset; int *offset; - u32 *image; + __le32 *image; }; static inline void emit(const u32 insn, struct jit_ctx *ctx) @@ -130,7 +130,7 @@ static inline int bpf2a64_offset(int bpf_to, int bpf_from, static void jit_fill_hole(void *area, unsigned int size) { - u32 *ptr; + __le32 *ptr; /* We are guaranteed to have aligned memory. */ for (ptr = area; size >= sizeof(u32); size -= sizeof(u32)) *ptr++ = cpu_to_le32(AARCH64_BREAK_FAULT); @@ -874,7 +874,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog) /* 2. Now, the actual pass. */ - ctx.image = (u32 *)image_ptr; + ctx.image = (__le32 *)image_ptr; ctx.idx = 0; build_prologue(&ctx);