From patchwork Wed Jun 28 14:55:57 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: 9814439 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 0F50860365 for ; Wed, 28 Jun 2017 14:57:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0125C2845D for ; Wed, 28 Jun 2017 14:57:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E7F6F28571; Wed, 28 Jun 2017 14:57:24 +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 7845D2845D for ; Wed, 28 Jun 2017 14:57:24 +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=YqnHxzEqXfS+S1X3SHCZnF/zjsPl8mLi0C1d8RazCqE=; b=Pwz qMqxLHKJEKtClTUjTJdr7wzlCTy9GVSONFsOJlSFvWRCawSIFcdOK5O2uKjNL5dNv0+9593AuuPm/ 4NQ7+7BENSKknn0z1RtwSboMBl2INFL+cdZ8GD8E6UBOAyN0BKkGksuoAhRRiGhaj2bLbm8UTwRkc BqLZmB972rB32UO3EfTmEeGNCgBT6wxjoVGguyEX/T6qM6PfXkwTVY8sZcowDMOp6Su5h97LGmp1E jsLwLa+PRXMofQClFmFLS0donJrW2A1Sfp02GYmmYTsX1yDFXQ2cIJds6sF/596kwtW75eIrKfDBc GfstmB8tJ02VY0yABddZ2ulB0vNJJaA==; 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 1dQEPB-00049R-F1; Wed, 28 Jun 2017 14:57:21 +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 1dQEO9-0003Ds-4l for linux-arm-kernel@lists.infradead.org; Wed, 28 Jun 2017 14:56:20 +0000 Received: by mail-wm0-x242.google.com with SMTP id j85so12017267wmj.0 for ; Wed, 28 Jun 2017 07:56:00 -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=PK45BDmRE7/y3oUyhPvttmTAdSbjumtJQqE6tIjWpI4=; b=YQqdKactnqtzOvrI+fyYhhANi4s5xw1ji9G/msxGJRZVCI4xzEaRtWL/ZAViwnzu2M r4IHLmetmXPKBOFMS+yzFztNfzzAfkV/o0Mui+yi3q0Eiea1ysKxVkMUrrLWbIW7wUjh NyMYomzUYjisswXV7MpW0JJd7IPhFF1RJCkZNE/2Uk9X+pyFN4tVJKfjiu1cLZLAsF0e +0a0hnVWIbEjji5XmTANkeCJRkcbXZ1evuAuBncw3go1eNKznAkj77dMS5pcB+pjTQ5t 4nueMo5Ml86nyErwSdXhYxD7//NFveY5mMy0auyCXWB690zvsidRecjcd8hTTpKxltQX 7Jiw== 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=PK45BDmRE7/y3oUyhPvttmTAdSbjumtJQqE6tIjWpI4=; b=gWSW21Zjy+/SylEmvzjCJwzXTYCvaPSSotVPCOlzln7dnVwVJdPQuhBCop24rrG7U1 9SXnMtjdMVIUFtdiFGgo6myJG54tQgT2PjcRrGrOKX2qcvRD5WUUBSnNkzHbecvv7oQu udGrWES+KLa4UEmj6vu4EqPnuPGWc8Wj3JpnABj8K18W2+Of1ki6zT4wxWXdZpiyXLF8 +pyFFvJoMqs5Lm+EJlDphx+lleaoCfXOpEzpiz7717IPlOugH5fyH5xmVZjJaizRVWiv y0VLoD+RJd+2Taa2cFzZ4fvc/RKVkqPSJRoEB/wrm0W98k80vLrQmkUDIEw8nTvXNygq DCfw== X-Gm-Message-State: AKS2vOyki7MTuEgyPJ5hIUj0wPkXiCgmXdyhCIoB7vL3EYvW3PEYcNDQ PVdx23SeETG7bg== X-Received: by 10.80.173.27 with SMTP id y27mr8270844edc.5.1498661759470; Wed, 28 Jun 2017 07:55:59 -0700 (PDT) Received: from localhost.localdomain ([91.177.84.115]) by smtp.gmail.com with ESMTPSA id c27sm1356234ede.32.2017.06.28.07.55.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Jun 2017 07:55:58 -0700 (PDT) From: Luc Van Oostenryck To: Will Deacon Subject: [PATCH] arm64: fix endianness annotation for __apply_alternatives()/get_alt_insn() Date: Wed, 28 Jun 2017 16:55:57 +0200 Message-Id: <20170628145557.24454-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_075617_402145_916C09D5 X-CRM114-Status: GOOD ( 12.31 ) 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 , Luc Van Oostenryck , 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 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. Signed-off-by: Luc Van Oostenryck --- arch/arm64/kernel/alternative.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/arm64/kernel/alternative.c b/arch/arm64/kernel/alternative.c index 8840c109c..56bfda8cb 100644 --- a/arch/arm64/kernel/alternative.c +++ b/arch/arm64/kernel/alternative.c @@ -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; @@ -122,9 +122,9 @@ static void __apply_alternatives(void *alt_region, bool use_linear_alias) pr_info_once("patching kernel code\n"); - origptr = ALT_ORIG_PTR(alt); - replptr = ALT_REPL_PTR(alt); - updptr = use_linear_alias ? (u32 *)lm_alias(origptr) : origptr; + origptr = (__le32 __force *) ALT_ORIG_PTR(alt); + replptr = (__le32 __force *) ALT_REPL_PTR(alt); + updptr = use_linear_alias ? (__le32 *)lm_alias(origptr) : origptr; nr_inst = alt->alt_len / sizeof(insn); for (i = 0; i < nr_inst; i++) {