From 214b3564869cd93258616411962a6fceef2c5ec7 Mon Sep 17 00:00:00 2001 From: Heiko Carstens Date: Fri, 5 Feb 2021 16:09:14 +0100 Subject: [PATCH] s390/vdso: move data page before code pages For consistency with x86 and arm64 move the data page before code pages. Similar to commit 601255ae3c98 ("arm64: vdso: move data page before code pages"). Reviewed-by: Alexander Gordeev Signed-off-by: Heiko Carstens Signed-off-by: Vasily Gorbik --- arch/s390/kernel/vdso.c | 30 ++++++++++++++-------------- arch/s390/kernel/vdso64/vdso64.lds.S | 4 +--- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/arch/s390/kernel/vdso.c b/arch/s390/kernel/vdso.c index 968b263f64b4..31920b76ae6d 100644 --- a/arch/s390/kernel/vdso.c +++ b/arch/s390/kernel/vdso.c @@ -74,7 +74,8 @@ early_initcall(vdso_getcpu_init); /* Must be called before SMP init */ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp) { - unsigned long addr, vdso_text_start, vdso_text_len, vdso_mapping_len; + unsigned long vdso_text_len, vdso_mapping_len; + unsigned long vvar_start, vdso_text_start; struct mm_struct *mm = current->mm; struct vm_area_struct *vma; int rc; @@ -85,25 +86,24 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp) return -EINTR; vdso_text_len = vdso_pages << PAGE_SHIFT; vdso_mapping_len = vdso_text_len + PAGE_SIZE; - addr = get_unmapped_area(NULL, 0, vdso_mapping_len, 0, 0); - rc = addr; - if (IS_ERR_VALUE(addr)) + vvar_start = get_unmapped_area(NULL, 0, vdso_mapping_len, 0, 0); + rc = vvar_start; + if (IS_ERR_VALUE(vvar_start)) goto out; - /* VM_MAYWRITE for COW so gdb can set breakpoints */ - vdso_text_start = addr; - vma = _install_special_mapping(mm, addr, vdso_text_len, - VM_READ|VM_EXEC| - VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC, - &vdso_mapping); + vma = _install_special_mapping(mm, vvar_start, PAGE_SIZE, + VM_READ|VM_MAYREAD|VM_PFNMAP, + &vvar_mapping); rc = PTR_ERR(vma); if (IS_ERR(vma)) goto out; - addr += vdso_text_len; - vma = _install_special_mapping(mm, addr, PAGE_SIZE, - VM_READ|VM_MAYREAD|VM_PFNMAP, - &vvar_mapping); + vdso_text_start = vvar_start + PAGE_SIZE; + /* VM_MAYWRITE for COW so gdb can set breakpoints */ + vma = _install_special_mapping(mm, vdso_text_start, vdso_text_len, + VM_READ|VM_EXEC| + VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC, + &vdso_mapping); if (IS_ERR(vma)) { - do_munmap(mm, vdso_text_start, vdso_text_len, NULL); + do_munmap(mm, vvar_start, PAGE_SIZE, NULL); rc = PTR_ERR(vma); } else { current->mm->context.vdso_base = vdso_text_start; diff --git a/arch/s390/kernel/vdso64/vdso64.lds.S b/arch/s390/kernel/vdso64/vdso64.lds.S index 7bde3909290f..99063b4c6e27 100644 --- a/arch/s390/kernel/vdso64/vdso64.lds.S +++ b/arch/s390/kernel/vdso64/vdso64.lds.S @@ -13,6 +13,7 @@ ENTRY(_start) SECTIONS { + PROVIDE(_vdso_data = . - PAGE_SIZE); . = VDSO64_LBASE + SIZEOF_HEADERS; .hash : { *(.hash) } :text @@ -94,9 +95,6 @@ SECTIONS .debug_ranges 0 : { *(.debug_ranges) } .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) } - . = ALIGN(PAGE_SIZE); - PROVIDE(_vdso_data = .); - /DISCARD/ : { *(.note.GNU-stack) *(.branch_lt)