]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
s390/vdso: Allow alternatives in vdso code
authorHeiko Carstens <hca@linux.ibm.com>
Fri, 13 Sep 2024 13:05:41 +0000 (15:05 +0200)
committerJason A. Donenfeld <Jason@zx2c4.com>
Fri, 13 Sep 2024 15:28:36 +0000 (17:28 +0200)
Implement the infrastructure required to allow alternatives in vdso code.

Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
arch/s390/kernel/vdso.c
arch/s390/kernel/vdso64/vdso64.lds.S

index 2f967ac2b8e3e4491e96d0427a8b21d4413ae367..8e4e6b3163379f4c6292d2328ceef49c85fd7075 100644 (file)
 #include <linux/errno.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
+#include <linux/module.h>
 #include <linux/mm.h>
 #include <linux/slab.h>
 #include <linux/smp.h>
 #include <linux/time_namespace.h>
 #include <linux/random.h>
 #include <vdso/datapage.h>
+#include <asm/alternative.h>
 #include <asm/vdso.h>
 
 extern char vdso64_start[], vdso64_end[];
@@ -250,8 +252,25 @@ static struct page ** __init vdso_setup_pages(void *start, void *end)
        return pagelist;
 }
 
+static void vdso_apply_alternatives(void)
+{
+       const struct elf64_shdr *alt, *shdr;
+       struct alt_instr *start, *end;
+       const struct elf64_hdr *hdr;
+
+       hdr = (struct elf64_hdr *)vdso64_start;
+       shdr = (void *)hdr + hdr->e_shoff;
+       alt = find_section(hdr, shdr, ".altinstructions");
+       if (!alt)
+               return;
+       start = (void *)hdr + alt->sh_offset;
+       end = (void *)hdr + alt->sh_offset + alt->sh_size;
+       apply_alternatives(start, end);
+}
+
 static int __init vdso_init(void)
 {
+       vdso_apply_alternatives();
        vdso64_mapping.pages = vdso_setup_pages(vdso64_start, vdso64_end);
        if (IS_ENABLED(CONFIG_COMPAT))
                vdso32_mapping.pages = vdso_setup_pages(vdso32_start, vdso32_end);
index 37e2a505e81dbde8a8954a6883e6a60f8fa81b0f..fa02c6ae3cacaf475ab6c0dc64795533206c194b 100644 (file)
@@ -42,6 +42,10 @@ SECTIONS
        .rodata         : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
        .rodata1        : { *(.rodata1) }
 
+       . = ALIGN(8);
+       .altinstructions        : { *(.altinstructions) }
+       .altinstr_replacement   : { *(.altinstr_replacement) }
+
        .dynamic        : { *(.dynamic) }               :text   :dynamic
 
        .eh_frame_hdr   : { *(.eh_frame_hdr) }          :text   :eh_frame_hdr