vdso.c (4b4193256c8d3bc3a5397b5cd9494c2ad386317d) vdso.c (871402e05b24cb56bc69df47cff960d0e0d24267)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * vdso setup for s390
4 *
5 * Copyright IBM Corp. 2008
6 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
7 */
8

--- 6 unchanged lines hidden (view full) ---

15#include <linux/stddef.h>
16#include <linux/unistd.h>
17#include <linux/slab.h>
18#include <linux/user.h>
19#include <linux/elf.h>
20#include <linux/security.h>
21#include <linux/memblock.h>
22#include <linux/compat.h>
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * vdso setup for s390
4 *
5 * Copyright IBM Corp. 2008
6 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
7 */
8

--- 6 unchanged lines hidden (view full) ---

15#include <linux/stddef.h>
16#include <linux/unistd.h>
17#include <linux/slab.h>
18#include <linux/user.h>
19#include <linux/elf.h>
20#include <linux/security.h>
21#include <linux/memblock.h>
22#include <linux/compat.h>
23#include <linux/binfmts.h>
24#include <vdso/datapage.h>
23#include <asm/asm-offsets.h>
24#include <asm/processor.h>
25#include <asm/mmu.h>
26#include <asm/mmu_context.h>
27#include <asm/sections.h>
28#include <asm/vdso.h>
29#include <asm/facility.h>
30

--- 23 unchanged lines hidden (view full) ---

54 vmf->page = vdso_pagelist[vmf->pgoff];
55 get_page(vmf->page);
56 return 0;
57}
58
59static int vdso_mremap(const struct vm_special_mapping *sm,
60 struct vm_area_struct *vma)
61{
25#include <asm/asm-offsets.h>
26#include <asm/processor.h>
27#include <asm/mmu.h>
28#include <asm/mmu_context.h>
29#include <asm/sections.h>
30#include <asm/vdso.h>
31#include <asm/facility.h>
32

--- 23 unchanged lines hidden (view full) ---

56 vmf->page = vdso_pagelist[vmf->pgoff];
57 get_page(vmf->page);
58 return 0;
59}
60
61static int vdso_mremap(const struct vm_special_mapping *sm,
62 struct vm_area_struct *vma)
63{
62 unsigned long vdso_pages;
63
64 vdso_pages = vdso64_pages;
65
66 if ((vdso_pages << PAGE_SHIFT) != vma->vm_end - vma->vm_start)
67 return -EINVAL;
68
69 if (WARN_ON_ONCE(current->mm != vma->vm_mm))
70 return -EFAULT;
71
72 current->mm->context.vdso_base = vma->vm_start;
64 current->mm->context.vdso_base = vma->vm_start;
65
73 return 0;
74}
75
76static const struct vm_special_mapping vdso_mapping = {
77 .name = "[vdso]",
78 .fault = vdso_fault,
79 .mremap = vdso_mremap,
80};

--- 10 unchanged lines hidden (view full) ---

91
92/*
93 * The vdso data page
94 */
95static union {
96 struct vdso_data data;
97 u8 page[PAGE_SIZE];
98} vdso_data_store __page_aligned_data;
66 return 0;
67}
68
69static const struct vm_special_mapping vdso_mapping = {
70 .name = "[vdso]",
71 .fault = vdso_fault,
72 .mremap = vdso_mremap,
73};

--- 10 unchanged lines hidden (view full) ---

84
85/*
86 * The vdso data page
87 */
88static union {
89 struct vdso_data data;
90 u8 page[PAGE_SIZE];
91} vdso_data_store __page_aligned_data;
99struct vdso_data *vdso_data = &vdso_data_store.data;
100
92struct vdso_data *vdso_data = (struct vdso_data *)&vdso_data_store.data;
101/*
93/*
102 * Setup vdso data page.
103 */
104static void __init vdso_init_data(struct vdso_data *vd)
105{
106 vd->ectg_available = test_facility(31);
107}
108
109/*
110 * Allocate/free per cpu vdso data.
111 */
112#define SEGMENT_ORDER 2
113
94 * Allocate/free per cpu vdso data.
95 */
96#define SEGMENT_ORDER 2
97
114/*
115 * The initial vdso_data structure for the boot CPU. Eventually
116 * it is replaced with a properly allocated structure in vdso_init.
117 * This is necessary because a valid S390_lowcore.vdso_per_cpu_data
118 * pointer is required to be able to return from an interrupt or
119 * program check. See the exit paths in entry.S.
120 */
121struct vdso_data boot_vdso_data __initdata;
122
123void __init vdso_alloc_boot_cpu(struct lowcore *lowcore)
124{
125 lowcore->vdso_per_cpu_data = (unsigned long) &boot_vdso_data;
126}
127
128int vdso_alloc_per_cpu(struct lowcore *lowcore)
129{
130 unsigned long segment_table, page_table, page_frame;
131 struct vdso_per_cpu_data *vd;
132
133 segment_table = __get_free_pages(GFP_KERNEL, SEGMENT_ORDER);
134 page_table = get_zeroed_page(GFP_KERNEL);
135 page_frame = get_zeroed_page(GFP_KERNEL);

--- 105 unchanged lines hidden (view full) ---

241 mmap_write_unlock(mm);
242 return rc;
243}
244
245static int __init vdso_init(void)
246{
247 int i;
248
98int vdso_alloc_per_cpu(struct lowcore *lowcore)
99{
100 unsigned long segment_table, page_table, page_frame;
101 struct vdso_per_cpu_data *vd;
102
103 segment_table = __get_free_pages(GFP_KERNEL, SEGMENT_ORDER);
104 page_table = get_zeroed_page(GFP_KERNEL);
105 page_frame = get_zeroed_page(GFP_KERNEL);

--- 105 unchanged lines hidden (view full) ---

211 mmap_write_unlock(mm);
212 return rc;
213}
214
215static int __init vdso_init(void)
216{
217 int i;
218
249 vdso_init_data(vdso_data);
250
251 /* Calculate the size of the 64 bit vDSO */
252 vdso64_pages = ((&vdso64_end - &vdso64_start
253 + PAGE_SIZE - 1) >> PAGE_SHIFT) + 1;
254
255 /* Make sure pages are in the correct state */
256 vdso64_pagelist = kcalloc(vdso64_pages + 1, sizeof(struct page *),
257 GFP_KERNEL);
258 BUG_ON(vdso64_pagelist == NULL);

--- 15 unchanged lines hidden ---
219 /* Calculate the size of the 64 bit vDSO */
220 vdso64_pages = ((&vdso64_end - &vdso64_start
221 + PAGE_SIZE - 1) >> PAGE_SHIFT) + 1;
222
223 /* Make sure pages are in the correct state */
224 vdso64_pagelist = kcalloc(vdso64_pages + 1, sizeof(struct page *),
225 GFP_KERNEL);
226 BUG_ON(vdso64_pagelist == NULL);

--- 15 unchanged lines hidden ---