Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp221897yba; Fri, 3 May 2019 00:04:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqwcqPvfvvGDWBXb4j+YAJr4LlJCvCEQJ16LqStFHok6rGjHNboBklzOux3lDeG6w50zcZVK X-Received: by 2002:a63:7504:: with SMTP id q4mr8498526pgc.443.1556867047814; Fri, 03 May 2019 00:04:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556867047; cv=none; d=google.com; s=arc-20160816; b=JVm3YNwBLdh92ClFqaDg5ZF+PdPrWZ/fpvwSuG7M+zNw4a5EKs52c5iJ5pSIk3A/68 aLgtz31RPZiI3HYdgbICjrGr06EMFJiV4j9QoKwMDkVjebd7WUHmBpXwVaVe5Ezau7V3 2ag53vHD+/vgQPjxu1+DLhWO+3IPQO8jCN3KVKVdAvxybIWxg1omORIqMydeBugql8Vg KQTGs20Jn2GW0z4E32QpwTe2Rrh5h2WYx4oJAEkU6599UHkc3Ch28pCNwck41e+2qu4s F4/rVXi2lUZn3Ta3XbmF5nLuWaGm8M6gtD44atzdINUNuGnAmJCp4ZBxIUnUnHtPq0nI T3NQ== 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=ErZY6f2nbUnrR9LqRl87fClAqCNURuX08D5DzZWi5Nw=; b=qsNvX1xh9VOKp46+hyZgyqj4ZlSuQ7EWVJSe7cTkRfIlFwpIF7eVk4czge+LVH7ALL /aoJta9zN7gVn3nl7mwb3cauEbFgXWxQS2O2yzWtcPNbK+CuoZzbDIthKjviHSKhKJjV +cxz6Eh1JpL5aVoGs32Sd7fjyFPImSw5OLdrsTuQV/uFsMozNqdZUpsmWU7nDDpQ6q96 KU4jFGszpU1akNRrd8W6s/tvqDkNvq1kKxzCHmB/Ag5sAQcQHDgDdOJiu7VAC950+t4d MIgdczgmJV3Ob+qdTbA7cu8Om2nb2eUJ9dUCYiQWjSOZ5vIrQDr00hWzfQ80z6vPKQcN Q16w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=pmW8T7OK; 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 j11si1383483plt.112.2019.05.03.00.03.52; Fri, 03 May 2019 00:04:07 -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=pmW8T7OK; 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 S1726826AbfECGkW (ORCPT + 99 others); Fri, 3 May 2019 02:40:22 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:10901 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726022AbfECGkT (ORCPT ); Fri, 3 May 2019 02:40:19 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 44wMvN2QSJz9tyt0; Fri, 3 May 2019 08:40:16 +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=pmW8T7OK; 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 wCtPh53GZE7D; Fri, 3 May 2019 08:40:16 +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 44wMvN1Csdz9tysx; Fri, 3 May 2019 08:40:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1556865616; bh=ErZY6f2nbUnrR9LqRl87fClAqCNURuX08D5DzZWi5Nw=; h=In-Reply-To:References:From:Subject:To:Cc:Date:From; b=pmW8T7OKkjWoSTTSmyNynz8pHy31B7/9nU6N548EhvrtsorMvoRyK5zllKzi8oolU UrXBX4LRvEJg45MhFRBV8L6yTuk84OywZDMh1U9s4fXOMc+i+HccHunTjIPoOXomlv WX/lkuSYwGdp5VrlhWEGNGiWrp3UjZAyv6ixDa9E= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 13B078B7F9; Fri, 3 May 2019 08:40:17 +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 RkhyRCXMLTaB; Fri, 3 May 2019 08:40:17 +0200 (CEST) Received: from po16846vm.idsi0.si.c-s.fr (po15451.idsi0.si.c-s.fr [172.25.231.6]) by messagerie.si.c-s.fr (Postfix) with ESMTP id EAD288B75A; Fri, 3 May 2019 08:40:16 +0200 (CEST) Received: by po16846vm.idsi0.si.c-s.fr (Postfix, from userid 0) id E3BA566204; Fri, 3 May 2019 06:40:16 +0000 (UTC) Message-Id: In-Reply-To: <298f344bdb21ab566271f5d18c6782ed20f072b7.1556865423.git.christophe.leroy@c-s.fr> References: <298f344bdb21ab566271f5d18c6782ed20f072b7.1556865423.git.christophe.leroy@c-s.fr> From: Christophe Leroy Subject: [PATCH v3 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: Fri, 3 May 2019 06:40:16 +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 --- v3: no change 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