~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/csky/kernel/vdso.c

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0
  2 // Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
  3 
  4 #include <linux/binfmts.h>
  5 #include <linux/elf.h>
  6 #include <linux/err.h>
  7 #include <linux/mm.h>
  8 #include <linux/slab.h>
  9 
 10 #include <asm/page.h>
 11 #include <vdso/datapage.h>
 12 
 13 extern char vdso_start[], vdso_end[];
 14 
 15 static unsigned int vdso_pages;
 16 static struct page **vdso_pagelist;
 17 
 18 static union vdso_data_store vdso_data_store __page_aligned_data;
 19 struct vdso_data *vdso_data = vdso_data_store.data;
 20 
 21 static int __init vdso_init(void)
 22 {
 23         unsigned int i;
 24 
 25         vdso_pages = (vdso_end - vdso_start) >> PAGE_SHIFT;
 26         vdso_pagelist =
 27                 kcalloc(vdso_pages + 1, sizeof(struct page *), GFP_KERNEL);
 28         if (unlikely(vdso_pagelist == NULL)) {
 29                 pr_err("vdso: pagelist allocation failed\n");
 30                 return -ENOMEM;
 31         }
 32 
 33         for (i = 0; i < vdso_pages; i++) {
 34                 struct page *pg;
 35 
 36                 pg = virt_to_page(vdso_start + (i << PAGE_SHIFT));
 37                 vdso_pagelist[i] = pg;
 38         }
 39         vdso_pagelist[i] = virt_to_page(vdso_data);
 40 
 41         return 0;
 42 }
 43 arch_initcall(vdso_init);
 44 
 45 int arch_setup_additional_pages(struct linux_binprm *bprm,
 46         int uses_interp)
 47 {
 48         struct mm_struct *mm = current->mm;
 49         unsigned long vdso_base, vdso_len;
 50         int ret;
 51 
 52         vdso_len = (vdso_pages + 1) << PAGE_SHIFT;
 53 
 54         mmap_write_lock(mm);
 55         vdso_base = get_unmapped_area(NULL, 0, vdso_len, 0, 0);
 56         if (IS_ERR_VALUE(vdso_base)) {
 57                 ret = vdso_base;
 58                 goto end;
 59         }
 60 
 61         /*
 62          * Put vDSO base into mm struct. We need to do this before calling
 63          * install_special_mapping or the perf counter mmap tracking code
 64          * will fail to recognise it as a vDSO (since arch_vma_name fails).
 65          */
 66         mm->context.vdso = (void *)vdso_base;
 67 
 68         ret =
 69            install_special_mapping(mm, vdso_base, vdso_pages << PAGE_SHIFT,
 70                 (VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC),
 71                 vdso_pagelist);
 72 
 73         if (unlikely(ret)) {
 74                 mm->context.vdso = NULL;
 75                 goto end;
 76         }
 77 
 78         vdso_base += (vdso_pages << PAGE_SHIFT);
 79         ret = install_special_mapping(mm, vdso_base, PAGE_SIZE,
 80                 (VM_READ | VM_MAYREAD), &vdso_pagelist[vdso_pages]);
 81 
 82         if (unlikely(ret))
 83                 mm->context.vdso = NULL;
 84 end:
 85         mmap_write_unlock(mm);
 86         return ret;
 87 }
 88 
 89 const char *arch_vma_name(struct vm_area_struct *vma)
 90 {
 91         if (vma->vm_mm && (vma->vm_start == (long)vma->vm_mm->context.vdso))
 92                 return "[vdso]";
 93         if (vma->vm_mm && (vma->vm_start ==
 94                            (long)vma->vm_mm->context.vdso + PAGE_SIZE))
 95                 return "[vdso_data]";
 96         return NULL;
 97 }
 98 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php