Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp6115519ybi; Sun, 7 Jul 2019 20:54:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqzr6wgrziDZkPVoWQVCd6SOAIKRIBnuLzd00M0x4dkNaOTlrS0LYqvZF8EKr/JZ927HSHAl X-Received: by 2002:a17:90a:19d:: with SMTP id 29mr22683439pjc.71.1562558072980; Sun, 07 Jul 2019 20:54:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562558072; cv=none; d=google.com; s=arc-20160816; b=vUpAYaJFP79EcwAYI+xT39P0dSwDPQFD6yz+ueHhOwu6EVUS4DITIkwAI2L6MTTL/1 sdlZPFzvS8lwUQHeQDwLKqSHEXUVunRHARne4zXe5I7nNXagyl6TvKxrQX2uXmSWy++N pAMmwYDpZZ5S56W75AgiJk3sAoDiKwoCyBpimU7Nte8nY0uB16qWF96yXKaqrYk04uwl Vg82AEzf2dlmHltJ8ehpaZQfXmU+zd4/2Is+UL4XYnHfWZo9kwDHCAmIc/ayhXYWHuaZ NzSMzjnoxIWK9PXXPipPQjX4rJrDQhq5idcUVSmvICE6ss7YWtwo7c6WQd4XjF4iZbpC cDrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from; bh=p6cmzcE2VeaszvHpJvzuLt4eFz4pnijtdPXf767Who8=; b=k8pYHwf7hBECh2/1yt7pmxPfperkEIncCh3TgdmKaEpSG1Q/p52PQeDyOGYrXKTDnE A3AQOnRA82PrAWZbyIsOx3C2YChANJ5hiZWejgOMC3pTytSHcg5d8Liblj18nFHbYz/G ZnphPrBkm3NTCYal9D7l/zX6TT00SQyGCX4qOw4lSJSIWSMxeHrN5/AuPEqlkSrgDHKW r0EUpgjzHA6qlKgZygP79qks3X9eROBM3KCfTopEvBpLnQG69nUjHimlLDXfhb7DBLwr P1u3yC5QQlvIm6eQ3XXOYUH+k/9RDLv05TmFUBsXBehIwGHzqmXONVzr+cfXorltGQhv S6jA== ARC-Authentication-Results: i=1; mx.google.com; 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 a123si18019409pfd.114.2019.07.07.20.54.03; Sun, 07 Jul 2019 20:54:32 -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; 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 S1727902AbfGHA4x (ORCPT + 99 others); Sun, 7 Jul 2019 20:56:53 -0400 Received: from bilbo.ozlabs.org ([203.11.71.1]:33645 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727163AbfGHA4x (ORCPT ); Sun, 7 Jul 2019 20:56:53 -0400 Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 45hn8f2zhzz9sN1; Mon, 8 Jul 2019 10:56:50 +1000 (AEST) From: Michael Ellerman To: Christophe Leroy , Benjamin Herrenschmidt , Paul Mackerras Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Ulirch Weigand Subject: Re: [PATCH v3 3/3] powerpc/module64: Use symbolic instructions names. In-Reply-To: <6fb61d1c9104b0324d4a9c445f431c0928c7ea25.1556865423.git.christophe.leroy@c-s.fr> References: <298f344bdb21ab566271f5d18c6782ed20f072b7.1556865423.git.christophe.leroy@c-s.fr> <6fb61d1c9104b0324d4a9c445f431c0928c7ea25.1556865423.git.christophe.leroy@c-s.fr> Date: Mon, 08 Jul 2019 10:56:50 +1000 Message-ID: <87bly5ibsd.fsf@concordia.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Christophe Leroy writes: > To increase readability/maintainability, replace hard coded > instructions values by symbolic names. > > Signed-off-by: Christophe Leroy > --- > v3: fixed warning by adding () in an 'if' around X | Y (unlike said in v2 history, this change was forgotten in v2) > v2: rearranged comments > > arch/powerpc/kernel/module_64.c | 53 +++++++++++++++++++++++++++-------------- > 1 file changed, 35 insertions(+), 18 deletions(-) > > diff --git a/arch/powerpc/kernel/module_64.c b/arch/powerpc/kernel/module_64.c > index c2e1b06253b8..b33a5d5e2d35 100644 > --- a/arch/powerpc/kernel/module_64.c > +++ b/arch/powerpc/kernel/module_64.c > @@ -704,18 +711,21 @@ int apply_relocate_add(Elf64_Shdr *sechdrs, ... > /* > * If found, replace it with: > * addis r2, r12, (.TOC.-func)@ha > * addi r2, r12, (.TOC.-func)@l > */ > - ((uint32_t *)location)[0] = 0x3c4c0000 + PPC_HA(value); > - ((uint32_t *)location)[1] = 0x38420000 + PPC_LO(value); > + ((uint32_t *)location)[0] = PPC_INST_ADDIS | __PPC_RT(R2) | > + __PPC_RA(R12) | PPC_HA(value); > + ((uint32_t *)location)[1] = PPC_INST_ADDI | __PPC_RT(R2) | > + __PPC_RA(R12) | PPC_LO(value); > break; This was crashing and it's amazing how long you can stare at a disassembly and not see the difference between `r2` and `r12` :) Fixed now. cheers