From patchwork Thu Jun 29 14:40:12 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: 9817207 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 9D05D602B1 for ; Thu, 29 Jun 2017 14:41:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 89B6628731 for ; Thu, 29 Jun 2017 14:41:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7D3682876E; Thu, 29 Jun 2017 14:41:15 +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 E959928731 for ; Thu, 29 Jun 2017 14:41:14 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Cat7J5PeDxinftMlHc6mNm4c2wIXGMouE0IZohD8Gxg=; b=YbtVQcEk1ccApv ow/kZnSpg9nLzMQiD2GfkdR3DsEmuYx+mMgJqSewSfY/q6n1v1M7lYllqQoX8xS9mxd7l/FPVsa3I XC0SIKzEkuHJfA5gKYrIfrglMUg4lwSIaH9VVEwwaU9q41t+IsmaHepnsexGevEbKkhE8KH/V6z+H YAiQPL1gMEmpbqyirFicZnnThxLyEwQEBfPOMWQtpn/bmFqk54Xg+b9rO/lMChkwDIIqITv2LOhXf mxFqBLT8YfNM9+qz7tFskjhjyzUS6gbgwWJOSvbBebiatE3Uu9khzRRalMhwuzXeWL3rW4ShdB2xQ 4yrMlvY++Zp8/cEYn0nw==; 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 1dQad4-0000ki-Nk; Thu, 29 Jun 2017 14:41:10 +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 1dQacW-0008D1-Bu for linux-arm-kernel@lists.infradead.org; Thu, 29 Jun 2017 14:40:43 +0000 Received: by mail-wm0-x242.google.com with SMTP id j85so2973913wmj.0 for ; Thu, 29 Jun 2017 07:40:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=a38bhPozekhGwIK4brnlTWpWs8nP/Wai/INjsF3p/qY=; b=va/iC6UVWexi621CIyGRaZ9Hiq1BvCpfUzzkybAZ4017EHiPI+TSgjViMMjxAN6Ha8 sSdD49aId6PG3p77mtpi8kpSbRH/RxplwQqoKUAB0CkCU1wi9ea3+WxzVQYjHECSmKBa jK1hoQcET8jIVc/TJ66cxLVRJss1a859291q2K+Xu1uluPgU3dr5ROGzzrM0R0Gu9ESH m1ougSdIsV8CGfS6GsaG69ry0ifp7dGCGB9PSuSgeQqCH2JRsIxcf+RoaYhcunrA+4I2 FJ2kBlaM6Cd0VtUL1fLFFEq6mHyFFiCH+Et5YmPdLHdDux/RZcwOw4jrk6/W/98N7KGm 33KQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=a38bhPozekhGwIK4brnlTWpWs8nP/Wai/INjsF3p/qY=; b=gVBD3oPub9gwRdv0dz6qKZQRV1fB32JCZViLSwPOldu5VofkIPwTLfj08pz5Iu7jRH Gf/1Kamrg3AKK6W5xoPZWjxVPbMajrDUVUJE0XtA2utIe0F7BKpn5UE3O6GJGPd60OTt M+gTG5HzTQ3uQZtaAWjjfSs7QLEnmnFk0xKXquG0WR4Si0CbNpjWqoQsgtkUYox/xWBY 2emVsWYuZDg9nqv/AY2bS4q+MMf7hyzjrwOmE6l6BVEJpu8JAnyb88eMcumwW/Q5tQEy 7Mj38XVzaes9YmUsXUbW2tkJX61pYcmXv9UxJumUj6IIjaWLW+L4EpR8+SGnXqPW3LeZ Wiyg== X-Gm-Message-State: AKS2vOz+PyN5LxKW66yyu6OK9smShlXIFyN/fPK0eX0pkS1f/j8Thb4g w68eHDWWMEloTg== X-Received: by 10.80.176.102 with SMTP id i93mr2038271edd.116.1498747214918; Thu, 29 Jun 2017 07:40:14 -0700 (PDT) Received: from ltop.local ([2a02:a03f:837:f300:1816:df24:7b15:fb23]) by smtp.gmail.com with ESMTPSA id g25sm946829eda.59.2017.06.29.07.40.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Jun 2017 07:40:14 -0700 (PDT) Date: Thu, 29 Jun 2017 16:40:12 +0200 From: Luc Van Oostenryck To: Will Deacon Subject: [PATCH v2] arm64: fix endianness annotation for __apply_alternatives()/get_alt_insn() Message-ID: <20170629144011.zdte2n3x2shfud45@ltop.local> References: <20170628145557.24454-1-luc.vanoostenryck@gmail.com> <20170629102851.GF14607@arm.com> <20170629132645.difv6xdjrkp5qvlh@ltop.local> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20170629132645.difv6xdjrkp5qvlh@ltop.local> User-Agent: NeoMutt/20170428 (1.8.2) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170629_074037_118051_2FA5B1EE X-CRM114-Status: GOOD ( 14.58 ) 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 , Ard Biesheuvel , Catalin Marinas , Suzuki K Poulose , James Morse , linux-arm-kernel@lists.infradead.org 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 get_alt_insn() is used to read and create ARM instructions, which are always stored in memory in little-endian order. These values are thus correctly converted to/from native order when processed but the pointers used to hold the address of these instructions are declared as for native order values. Fix this by declaring the pointers as __le32* instead of u32* and make the few appropriate needed changes like removing the unneeded cast '(u32*)' in front of __ALT_PTR()'s definition. Signed-off-by: Luc Van Oostenryck --- Change since v1: - remove the unneeded cast '(u32*)' in front of __ALT_PTR()'s definition. - remove the now unneeded forced cast to __le32* when using ALT_ORIG_PTR() or ALT_REPL_PTR(). - remove an unnneded cast in front of lm_alias(). arch/arm64/kernel/alternative.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/arm64/kernel/alternative.c b/arch/arm64/kernel/alternative.c index 8840c109c..6dd0a3a3e 100644 --- a/arch/arm64/kernel/alternative.c +++ b/arch/arm64/kernel/alternative.c @@ -28,7 +28,7 @@ #include #include -#define __ALT_PTR(a,f) (u32 *)((void *)&(a)->f + (a)->f) +#define __ALT_PTR(a,f) ((void *)&(a)->f + (a)->f) #define ALT_ORIG_PTR(a) __ALT_PTR(a, orig_offset) #define ALT_REPL_PTR(a) __ALT_PTR(a, alt_offset) @@ -60,7 +60,7 @@ static bool branch_insn_requires_update(struct alt_instr *alt, unsigned long pc) #define align_down(x, a) ((unsigned long)(x) & ~(((unsigned long)(a)) - 1)) -static u32 get_alt_insn(struct alt_instr *alt, u32 *insnptr, u32 *altinsnptr) +static u32 get_alt_insn(struct alt_instr *alt, __le32 *insnptr, __le32 *altinsnptr) { u32 insn; @@ -109,7 +109,7 @@ static void __apply_alternatives(void *alt_region, bool use_linear_alias) { struct alt_instr *alt; struct alt_region *region = alt_region; - u32 *origptr, *replptr, *updptr; + __le32 *origptr, *replptr, *updptr; for (alt = region->begin; alt < region->end; alt++) { u32 insn; @@ -124,7 +124,7 @@ static void __apply_alternatives(void *alt_region, bool use_linear_alias) origptr = ALT_ORIG_PTR(alt); replptr = ALT_REPL_PTR(alt); - updptr = use_linear_alias ? (u32 *)lm_alias(origptr) : origptr; + updptr = use_linear_alias ? lm_alias(origptr) : origptr; nr_inst = alt->alt_len / sizeof(insn); for (i = 0; i < nr_inst; i++) {