Skip to content

Commit e10863f

Browse files
hcahcazx2c4
authored andcommitted
s390/vdso: Allow alternatives in vdso code
Implement the infrastructure required to allow alternatives in vdso code. Signed-off-by: Heiko Carstens <[email protected]> Signed-off-by: Jason A. Donenfeld <[email protected]>
1 parent a919390 commit e10863f

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

arch/s390/kernel/vdso.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@
1212
#include <linux/errno.h>
1313
#include <linux/init.h>
1414
#include <linux/kernel.h>
15+
#include <linux/module.h>
1516
#include <linux/mm.h>
1617
#include <linux/slab.h>
1718
#include <linux/smp.h>
1819
#include <linux/time_namespace.h>
1920
#include <linux/random.h>
2021
#include <vdso/datapage.h>
22+
#include <asm/alternative.h>
2123
#include <asm/vdso.h>
2224

2325
extern char vdso64_start[], vdso64_end[];
@@ -250,8 +252,25 @@ static struct page ** __init vdso_setup_pages(void *start, void *end)
250252
return pagelist;
251253
}
252254

255+
static void vdso_apply_alternatives(void)
256+
{
257+
const struct elf64_shdr *alt, *shdr;
258+
struct alt_instr *start, *end;
259+
const struct elf64_hdr *hdr;
260+
261+
hdr = (struct elf64_hdr *)vdso64_start;
262+
shdr = (void *)hdr + hdr->e_shoff;
263+
alt = find_section(hdr, shdr, ".altinstructions");
264+
if (!alt)
265+
return;
266+
start = (void *)hdr + alt->sh_offset;
267+
end = (void *)hdr + alt->sh_offset + alt->sh_size;
268+
apply_alternatives(start, end);
269+
}
270+
253271
static int __init vdso_init(void)
254272
{
273+
vdso_apply_alternatives();
255274
vdso64_mapping.pages = vdso_setup_pages(vdso64_start, vdso64_end);
256275
if (IS_ENABLED(CONFIG_COMPAT))
257276
vdso32_mapping.pages = vdso_setup_pages(vdso32_start, vdso32_end);

arch/s390/kernel/vdso64/vdso64.lds.S

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ SECTIONS
4242
.rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
4343
.rodata1 : { *(.rodata1) }
4444

45+
. = ALIGN(8);
46+
.altinstructions : { *(.altinstructions) }
47+
.altinstr_replacement : { *(.altinstr_replacement) }
48+
4549
.dynamic : { *(.dynamic) } :text :dynamic
4650

4751
.eh_frame_hdr : { *(.eh_frame_hdr) } :text :eh_frame_hdr

0 commit comments

Comments
 (0)