powerpc: module_[32|64].c: replace swap function with built-in one
authorAndrey Abramov <st5pub@yandex.ru>
Tue, 2 Apr 2019 20:47:22 +0000 (23:47 +0300)
committerMichael Ellerman <mpe@ellerman.id.au>
Mon, 11 May 2020 13:15:14 +0000 (23:15 +1000)
Replace relaswap with built-in one, because relaswap
does a simple byte to byte swap.

Since Spectre mitigations have made indirect function calls more
expensive, and the default simple byte copies swap is implemented
without them, an "optimized" custom swap function is now
a waste of time as well as code.

Signed-off-by: Andrey Abramov <st5pub@yandex.ru>
Reviewed-by: George Spelvin <lkml@sdf.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/994931554238042@iva8-b333b7f98ab0.qloud-c.yandex.net
arch/powerpc/kernel/module_32.c
arch/powerpc/kernel/module_64.c

index d7134c614c16b1a99f5ce8c2c977840019d0c961..c27b8687b82aeb07557a11fa50643f50f7d1473a 100644 (file)
@@ -67,21 +67,6 @@ static int relacmp(const void *_x, const void *_y)
                return 0;
 }
 
-static void relaswap(void *_x, void *_y, int size)
-{
-       uint32_t *x, *y, tmp;
-       int i;
-
-       y = (uint32_t *)_x;
-       x = (uint32_t *)_y;
-
-       for (i = 0; i < sizeof(Elf32_Rela) / sizeof(uint32_t); i++) {
-               tmp = x[i];
-               x[i] = y[i];
-               y[i] = tmp;
-       }
-}
-
 /* Get the potential trampolines size required of the init and
    non-init sections */
 static unsigned long get_plt_size(const Elf32_Ehdr *hdr,
@@ -118,7 +103,7 @@ static unsigned long get_plt_size(const Elf32_Ehdr *hdr,
                         */
                        sort((void *)hdr + sechdrs[i].sh_offset,
                             sechdrs[i].sh_size / sizeof(Elf32_Rela),
-                            sizeof(Elf32_Rela), relacmp, relaswap);
+                            sizeof(Elf32_Rela), relacmp, NULL);
 
                        ret += count_relocs((void *)hdr
                                             + sechdrs[i].sh_offset,
index 007606a48fd980d0e7de5ffdb9b484053851c568..f808159f3dfd2ee8aec06018dadab52ff4271460 100644 (file)
@@ -226,21 +226,6 @@ static int relacmp(const void *_x, const void *_y)
                return 0;
 }
 
-static void relaswap(void *_x, void *_y, int size)
-{
-       uint64_t *x, *y, tmp;
-       int i;
-
-       y = (uint64_t *)_x;
-       x = (uint64_t *)_y;
-
-       for (i = 0; i < sizeof(Elf64_Rela) / sizeof(uint64_t); i++) {
-               tmp = x[i];
-               x[i] = y[i];
-               y[i] = tmp;
-       }
-}
-
 /* Get size of potential trampolines required. */
 static unsigned long get_stubs_size(const Elf64_Ehdr *hdr,
                                    const Elf64_Shdr *sechdrs)
@@ -264,7 +249,7 @@ static unsigned long get_stubs_size(const Elf64_Ehdr *hdr,
                         */
                        sort((void *)sechdrs[i].sh_addr,
                             sechdrs[i].sh_size / sizeof(Elf64_Rela),
-                            sizeof(Elf64_Rela), relacmp, relaswap);
+                            sizeof(Elf64_Rela), relacmp, NULL);
 
                        relocs += count_relocs((void *)sechdrs[i].sh_addr,
                                               sechdrs[i].sh_size