Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp7420013yba; Thu, 2 May 2019 09:30:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqzEVJ73cfRv5gNj3oHfDWtOhc9pr8J+P1ANwlaTLgPa7kIBi7dGVLvXot//PG9DiqQTnsM5 X-Received: by 2002:a63:4c26:: with SMTP id z38mr5002443pga.425.1556814641976; Thu, 02 May 2019 09:30:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556814641; cv=none; d=google.com; s=arc-20160816; b=GQn4kDA/eCoxaiTejQ2Wgn+KjsIoOqLr+VAF+2Ed3iRmC5sf9wVSdTErAkoe2U/ylJ Q+GdFwYvo52Jx24gDGeKu4z+/TueZpqnoCNhkG60S04P2oaJONMFsVh9Z6x/LnRGHADN V8KFDgCx7lB2B/4iOLv7hHAeeKHOt/cpb5Pp1FMqI2NYYOOcLiY5HXi+qvpZFGqSncbT /oD6dRHDEvCypACPwxyxvfF+Tt0EsGVO2kYVOBqQdQXNsb9z33d2yjih5Kah/HbU70rC uQD9eEzIhyUYQ0OnqYBipcZw87gwpOVOgnK1KruVwoEnt3MNBM1ihTEJEqlr6LJBHKxk 5v7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:cc:to:subject:from:references :in-reply-to:message-id:dkim-signature; bh=2XvB/geiUYMUvPBRKdnnwkEaTU6dGWad8XFW+OQ9YYU=; b=iaQyvF3MyOmwnZZ02TL5eh7sLMdoWNIW3nD+JBMSnYYYYySs4JzoJm17ZPyWtevblk 9ZdZlE3b7CwrOsguQ7JDpjW69vAh6R2KF+qNSI3wDwhbRJ5nenroXO+MByOkcSZzwwOD NuTobZdKRYh8XgHu/20s1J4DVLv8rQEmS0icAVK+jtXbmOjip/ahVebWmGB3QBLHWVew k1OLj+4jMH+xSWiO5tjpjIYhBa8NlHVqmAtH/r0NN7Vel+ojZQKNvhPIxs/Kg1gfB+m/ KJMSfCbEnFgFrZ5TqYMPVPZvXrsGLFo1W0cfCjoBZs7FbUzcvjZKsAZXbic098eIn2GB ip2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=fVxTzPSI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n25si13910664pgv.454.2019.05.02.09.30.25; Thu, 02 May 2019 09:30:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=fVxTzPSI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726350AbfEBQ1f (ORCPT + 99 others); Thu, 2 May 2019 12:27:35 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:59473 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726321AbfEBQ1d (ORCPT ); Thu, 2 May 2019 12:27:33 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 44w0zP4mPdz9tycm; Thu, 2 May 2019 18:27:29 +0200 (CEST) Authentication-Results: localhost; dkim=pass reason="1024-bit key; insecure key" header.d=c-s.fr header.i=@c-s.fr header.b=fVxTzPSI; dkim-adsp=pass; dkim-atps=neutral X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id 8Emtp1vUq3LX; Thu, 2 May 2019 18:27:29 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 44w0zP3fdjz9tyck; Thu, 2 May 2019 18:27:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1556814449; bh=2XvB/geiUYMUvPBRKdnnwkEaTU6dGWad8XFW+OQ9YYU=; h=In-Reply-To:References:From:Subject:To:Cc:Date:From; b=fVxTzPSIsBnP4pyL5v4uakzhbwcldG54jQM+YnQwY3IgDneyzvk+zSpkHJ90ThtIx G9w+seliyQJgBaxL8vLY6MNcHTCoQhIz6F6azrhUH6M0ybbuRrwTw0Jd1klvjmjq30 Yd6pgL9hTD6J5lVWeavhhN0bjesIuTuXv+liOOwo= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 2EEB28B8FE; Thu, 2 May 2019 18:27:31 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id kOM5NWQInaLu; Thu, 2 May 2019 18:27:31 +0200 (CEST) Received: from po16846vm.idsi0.si.c-s.fr (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 0838E8B899; Thu, 2 May 2019 18:27:31 +0200 (CEST) Received: by po16846vm.idsi0.si.c-s.fr (Postfix, from userid 0) id D0904672AF; Thu, 2 May 2019 16:27:30 +0000 (UTC) Message-Id: In-Reply-To: <298f344bdb21ab566271f5d18c6782ed20f072b7.1556814003.git.christophe.leroy@c-s.fr> References: <298f344bdb21ab566271f5d18c6782ed20f072b7.1556814003.git.christophe.leroy@c-s.fr> From: Christophe Leroy Subject: [PATCH v2 2/3] powerpc/module32: Use symbolic instructions names. To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Date: Thu, 2 May 2019 16:27:30 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org To increase readability/maintainability, replace hard coded instructions values by symbolic names. Signed-off-by: Christophe Leroy --- v2: Remove the ENTRY_JMP0 and ENTRY_JMP1 macros ; left real instructions as a comment. arch/powerpc/kernel/module_32.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/arch/powerpc/kernel/module_32.c b/arch/powerpc/kernel/module_32.c index 88d83771f462..9cf201111d6c 100644 --- a/arch/powerpc/kernel/module_32.c +++ b/arch/powerpc/kernel/module_32.c @@ -172,10 +172,12 @@ int module_frob_arch_sections(Elf32_Ehdr *hdr, static inline int entry_matches(struct ppc_plt_entry *entry, Elf32_Addr val) { - if (entry->jump[0] == 0x3d800000 + ((val + 0x8000) >> 16) - && entry->jump[1] == 0x398c0000 + (val & 0xffff)) - return 1; - return 0; + if (entry->jump[0] != (PPC_INST_ADDIS | __PPC_RT(R12) | PPC_HA(val))) + return 0; + if (entry->jump[1] != (PPC_INST_ADDI | __PPC_RT(R12) | __PPC_RA(R12) | + PPC_LO(val))) + return 0; + return 1; } /* Set up a trampoline in the PLT to bounce us to the distant function */ @@ -200,10 +202,16 @@ static uint32_t do_plt_call(void *location, entry++; } - entry->jump[0] = 0x3d800000+((val+0x8000)>>16); /* lis r12,sym@ha */ - entry->jump[1] = 0x398c0000 + (val&0xffff); /* addi r12,r12,sym@l*/ - entry->jump[2] = 0x7d8903a6; /* mtctr r12 */ - entry->jump[3] = 0x4e800420; /* bctr */ + /* + * lis r12, sym@ha + * addi r12, r12, sym@l + * mtctr r12 + * bctr + */ + entry->jump[0] = PPC_INST_ADDIS | __PPC_RT(R12) | PPC_HA(val); + entry->jump[1] = PPC_INST_ADDI | __PPC_RT(R12) | __PPC_RA(R12) | PPC_LO(val); + entry->jump[2] = PPC_INST_MTCTR | __PPC_RS(R12); + entry->jump[3] = PPC_INST_BCTR; pr_debug("Initialized plt for 0x%x at %p\n", val, entry); return (uint32_t)entry; -- 2.13.3