[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <a301c94f63888165960e21e92a0584364beb09fb.1648131740.git.christophe.leroy@csgroup.eu>
Date: Thu, 24 Mar 2022 15:30:10 +0100
From: Christophe Leroy <christophe.leroy@...roup.eu>
To: "Naveen N . Rao" <naveen.n.rao@...ux.vnet.ibm.com>,
Steven Rostedt <rostedt@...dmis.org>,
Ingo Molnar <mingo@...hat.com>,
Benjamin Herrenschmidt <benh@...nel.crashing.org>,
Paul Mackerras <paulus@...ba.org>,
Michael Ellerman <mpe@...erman.id.au>
Cc: Christophe Leroy <christophe.leroy@...roup.eu>,
linux-kernel@...r.kernel.org, linuxppc-dev@...ts.ozlabs.org
Subject: [PATCH v1 20/22] powerpc/modules: Use PPC_INST_BRANCH_MASK instead of opencoding
Use PPC_INST_BRANCH_MASK instead of opencoding.
Signed-off-by: Christophe Leroy <christophe.leroy@...roup.eu>
---
arch/powerpc/kernel/module_32.c | 13 ++++++-------
arch/powerpc/kernel/module_64.c | 4 ++--
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/arch/powerpc/kernel/module_32.c b/arch/powerpc/kernel/module_32.c
index 1282cfd672f2..344941855e9e 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_INST_OFFSET24_MASK) |
+ ((value - (uint32_t)location) & PPC_INST_OFFSET24_MASK);
if (patch_instruction(location, ppc_inst(value)))
return -EFAULT;
@@ -266,10 +265,10 @@ 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 *)location & PPC_INST_OFFSET24_MASK,
+ (uint32_t)location,
+ (*(uint32_t *)location & PPC_INST_OFFSET24_MASK) +
+ (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 b13a72665eee..8f70a04aac6c 100644
--- a/arch/powerpc/kernel/module_64.c
+++ b/arch/powerpc/kernel/module_64.c
@@ -653,8 +653,8 @@ 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_INST_OFFSET24_MASK) |
+ (value & PPC_INST_OFFSET24_MASK);
if (patch_instruction((u32 *)location, ppc_inst(value)))
return -EFAULT;
--
2.35.1
Powered by blists - more mailing lists