linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Christophe Leroy <christophe.leroy@csgroup.eu>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Paul Mackerras <paulus@samba.org>,
	Michael Ellerman <mpe@ellerman.id.au>,
	naveen.n.rao@linux.vnet.ibm.com
Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org
Subject: [PATCH v3 23/25] powerpc/modules: Use PPC_LI macros instead of opencoding
Date: Mon,  9 May 2022 07:36:21 +0200	[thread overview]
Message-ID: <3d56d7bc3200403773d54e62659d0e01292a055d.1652074503.git.christophe.leroy@csgroup.eu> (raw)
In-Reply-To: <cover.1652074503.git.christophe.leroy@csgroup.eu>

Use PPC_LI_MASK and PPC_LI() instead of opencoding.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
v2: Utilisation de PPC_LI() et PPC_LI_MASK
---
 arch/powerpc/kernel/module_32.c | 11 ++++-------
 arch/powerpc/kernel/module_64.c |  3 +--
 2 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/arch/powerpc/kernel/module_32.c b/arch/powerpc/kernel/module_32.c
index 715a42f383d0..3d47e9853f3e 100644
--- a/arch/powerpc/kernel/module_32.c
+++ b/arch/powerpc/kernel/module_32.c
@@ -256,9 +256,8 @@ int apply_relocate_add(Elf32_Shdr *sechdrs,
 			       value, (uint32_t)location);
 			pr_debug("Location before: %08X.\n",
 			       *(uint32_t *)location);
-			value = (*(uint32_t *)location & ~0x03fffffc)
-				| ((value - (uint32_t)location)
-				   & 0x03fffffc);
+			value = (*(uint32_t *)location & ~PPC_LI_MASK) |
+				PPC_LI(value - (uint32_t)location);
 
 			if (patch_instruction(location, ppc_inst(value)))
 				return -EFAULT;
@@ -266,10 +265,8 @@ int apply_relocate_add(Elf32_Shdr *sechdrs,
 			pr_debug("Location after: %08X.\n",
 			       *(uint32_t *)location);
 			pr_debug("ie. jump to %08X+%08X = %08X\n",
-			       *(uint32_t *)location & 0x03fffffc,
-			       (uint32_t)location,
-			       (*(uint32_t *)location & 0x03fffffc)
-			       + (uint32_t)location);
+				 *(uint32_t *)PPC_LI((uint32_t)location), (uint32_t)location,
+				 (*(uint32_t *)PPC_LI((uint32_t)location)) + (uint32_t)location);
 			break;
 
 		case R_PPC_REL32:
diff --git a/arch/powerpc/kernel/module_64.c b/arch/powerpc/kernel/module_64.c
index c1d87937b962..4c844198185e 100644
--- a/arch/powerpc/kernel/module_64.c
+++ b/arch/powerpc/kernel/module_64.c
@@ -653,8 +653,7 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
 			}
 
 			/* Only replace bits 2 through 26 */
-			value = (*(uint32_t *)location & ~0x03fffffc)
-				| (value & 0x03fffffc);
+			value = (*(uint32_t *)location & ~PPC_LI_MASK) | PPC_LI(value);
 
 			if (patch_instruction((u32 *)location, ppc_inst(value)))
 				return -EFAULT;
-- 
2.35.1


  parent reply	other threads:[~2022-05-09  5:46 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-09  5:35 [PATCH v3 00/25] powerpc: ftrace optimisation and cleanup and more [v3] Christophe Leroy
2022-05-09  5:35 ` [PATCH v3 01/25] powerpc/ftrace: Refactor prepare_ftrace_return() Christophe Leroy
2022-05-09  5:36 ` [PATCH v3 02/25] powerpc/ftrace: Remove redundant create_branch() calls Christophe Leroy
2022-05-09  5:36 ` [PATCH v3 03/25] powerpc/code-patching: Inline is_offset_in_{cond}_branch_range() Christophe Leroy
2022-05-09  5:36 ` [PATCH v3 04/25] powerpc/ftrace: Use is_offset_in_branch_range() Christophe Leroy
2022-05-09  5:36 ` [PATCH v3 05/25] powerpc/code-patching: Inline create_branch() Christophe Leroy
2022-05-09  5:36 ` [PATCH v3 06/25] powerpc/ftrace: Inline ftrace_modify_code() Christophe Leroy
2022-05-09  5:36 ` [PATCH v3 07/25] powerpc/ftrace: Use patch_instruction() return directly Christophe Leroy
2022-05-09  5:36 ` [PATCH v3 08/25] powerpc: Add CONFIG_PPC64_ELF_ABI_V1 and CONFIG_PPC64_ELF_ABI_V2 Christophe Leroy
2022-05-09  5:36 ` [PATCH v3 09/25] powerpc: Replace PPC64_ELF_ABI_v{1/2} by CONFIG_PPC64_ELF_ABI_V{1/2} Christophe Leroy
2022-05-09  5:36 ` [PATCH v3 10/25] powerpc: Finalise cleanup around ABI use Christophe Leroy
2022-05-09  5:36 ` [PATCH v3 11/25] powerpc/ftrace: Make __ftrace_make_{nop/call}() common to PPC32 and PPC64 Christophe Leroy
2022-08-08 18:41   ` Nick Desaulniers
2022-08-08 18:47   ` Nick Desaulniers
2022-08-09  6:25     ` Naveen N. Rao
2022-05-09  5:36 ` [PATCH v3 12/25] powerpc/ftrace: Don't include ftrace.o for CONFIG_FTRACE_SYSCALLS Christophe Leroy
2022-05-09  5:36 ` [PATCH v3 13/25] powerpc/ftrace: Use CONFIG_FUNCTION_TRACER instead of CONFIG_DYNAMIC_FTRACE Christophe Leroy
2022-05-09  5:36 ` [PATCH v3 14/25] powerpc/ftrace: Remove ftrace_plt_tramps[] Christophe Leroy
2022-05-09  5:36 ` [PATCH v3 15/25] powerpc/ftrace: Use BRANCH_SET_LINK instead of value 1 Christophe Leroy
2022-05-09  5:36 ` [PATCH v3 16/25] powerpc/ftrace: Use PPC_RAW_xxx() macros instead of opencoding Christophe Leroy
2022-05-09  5:36 ` [PATCH v3 17/25] powerpc/ftrace: Use size macro " Christophe Leroy
2022-05-09  5:36 ` [PATCH v3 18/25] powerpc/ftrace: Simplify expected_nop_sequence() Christophe Leroy
2022-05-09  5:36 ` [PATCH v3 19/25] powerpc/ftrace: Minimise number of #ifdefs Christophe Leroy
2022-05-18  9:45   ` Naveen N. Rao
2022-05-18 10:08     ` Christophe Leroy
2022-05-18 11:19     ` Michael Ellerman
2022-05-18 12:03       ` Michael Ellerman
2022-05-18 12:12         ` Christophe Leroy
2022-05-18 17:03           ` Naveen N. Rao
2022-05-18 12:04       ` Christophe Leroy
2022-05-09  5:36 ` [PATCH v3 20/25] powerpc/inst: Add __copy_inst_from_kernel_nofault() Christophe Leroy
2022-05-09  5:36 ` [PATCH v3 21/25] powerpc/ftrace: Don't use copy_from_kernel_nofault() in module_trampoline_target() Christophe Leroy
2022-05-09  5:36 ` [PATCH v3 22/25] powerpc/inst: Remove PPC_INST_BRANCH Christophe Leroy
2022-05-09  5:36 ` Christophe Leroy [this message]
2022-05-09  5:36 ` [PATCH v3 24/25] powerpc/inst: Remove PPC_INST_BL Christophe Leroy
2022-05-09  5:36 ` [PATCH v3 25/25] powerpc/opcodes: Remove unused PPC_INST_XXX macros Christophe Leroy
2022-05-24 11:09 ` [PATCH v3 00/25] powerpc: ftrace optimisation and cleanup and more [v3] Michael Ellerman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3d56d7bc3200403773d54e62659d0e01292a055d.1652074503.git.christophe.leroy@csgroup.eu \
    --to=christophe.leroy@csgroup.eu \
    --cc=benh@kernel.crashing.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    --cc=naveen.n.rao@linux.vnet.ibm.com \
    --cc=paulus@samba.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).