1818#include <linux/sched.h>
1919#include <linux/signal.h>
2020#include <linux/slab.h>
21- #include <linux/time_namespace .h>
21+ #include <linux/vdso_datastore .h>
2222#include <linux/vmalloc.h>
2323#include <vdso/datapage.h>
2424#include <vdso/helpers.h>
@@ -57,12 +57,6 @@ static struct vdso_abi_info vdso_info[] __ro_after_init = {
5757#endif /* CONFIG_COMPAT_VDSO */
5858};
5959
60- /*
61- * The vDSO data page.
62- */
63- static union vdso_data_store vdso_data_store __page_aligned_data ;
64- struct vdso_data * vdso_data = vdso_data_store .data ;
65-
6660static int vdso_mremap (const struct vm_special_mapping * sm ,
6761 struct vm_area_struct * new_vma )
6862{
@@ -104,78 +98,6 @@ static int __init __vdso_init(enum vdso_abi abi)
10498 return 0 ;
10599}
106100
107- #ifdef CONFIG_TIME_NS
108- struct vdso_data * arch_get_vdso_data (void * vvar_page )
109- {
110- return (struct vdso_data * )(vvar_page );
111- }
112-
113- static const struct vm_special_mapping vvar_map ;
114-
115- /*
116- * The vvar mapping contains data for a specific time namespace, so when a task
117- * changes namespace we must unmap its vvar data for the old namespace.
118- * Subsequent faults will map in data for the new namespace.
119- *
120- * For more details see timens_setup_vdso_data().
121- */
122- int vdso_join_timens (struct task_struct * task , struct time_namespace * ns )
123- {
124- struct mm_struct * mm = task -> mm ;
125- struct vm_area_struct * vma ;
126- VMA_ITERATOR (vmi , mm , 0 );
127-
128- mmap_read_lock (mm );
129-
130- for_each_vma (vmi , vma ) {
131- if (vma_is_special_mapping (vma , & vvar_map ))
132- zap_vma_pages (vma );
133- }
134-
135- mmap_read_unlock (mm );
136- return 0 ;
137- }
138- #endif
139-
140- static vm_fault_t vvar_fault (const struct vm_special_mapping * sm ,
141- struct vm_area_struct * vma , struct vm_fault * vmf )
142- {
143- struct page * timens_page = find_timens_vvar_page (vma );
144- unsigned long pfn ;
145-
146- switch (vmf -> pgoff ) {
147- case VVAR_DATA_PAGE_OFFSET :
148- if (timens_page )
149- pfn = page_to_pfn (timens_page );
150- else
151- pfn = sym_to_pfn (vdso_data );
152- break ;
153- #ifdef CONFIG_TIME_NS
154- case VVAR_TIMENS_PAGE_OFFSET :
155- /*
156- * If a task belongs to a time namespace then a namespace
157- * specific VVAR is mapped with the VVAR_DATA_PAGE_OFFSET and
158- * the real VVAR page is mapped with the VVAR_TIMENS_PAGE_OFFSET
159- * offset.
160- * See also the comment near timens_setup_vdso_data().
161- */
162- if (!timens_page )
163- return VM_FAULT_SIGBUS ;
164- pfn = sym_to_pfn (vdso_data );
165- break ;
166- #endif /* CONFIG_TIME_NS */
167- default :
168- return VM_FAULT_SIGBUS ;
169- }
170-
171- return vmf_insert_pfn (vma , vmf -> address , pfn );
172- }
173-
174- static const struct vm_special_mapping vvar_map = {
175- .name = "[vvar]" ,
176- .fault = vvar_fault ,
177- };
178-
179101static int __setup_additional_pages (enum vdso_abi abi ,
180102 struct mm_struct * mm ,
181103 struct linux_binprm * bprm ,
@@ -185,28 +107,26 @@ static int __setup_additional_pages(enum vdso_abi abi,
185107 unsigned long gp_flags = 0 ;
186108 void * ret ;
187109
188- BUILD_BUG_ON (VVAR_NR_PAGES != __VVAR_PAGES );
110+ BUILD_BUG_ON (VDSO_NR_PAGES != __VDSO_PAGES );
189111
190112 vdso_text_len = vdso_info [abi ].vdso_pages << PAGE_SHIFT ;
191113 /* Be sure to map the data page */
192- vdso_mapping_len = vdso_text_len + VVAR_NR_PAGES * PAGE_SIZE ;
114+ vdso_mapping_len = vdso_text_len + VDSO_NR_PAGES * PAGE_SIZE ;
193115
194116 vdso_base = get_unmapped_area (NULL , 0 , vdso_mapping_len , 0 , 0 );
195117 if (IS_ERR_VALUE (vdso_base )) {
196118 ret = ERR_PTR (vdso_base );
197119 goto up_fail ;
198120 }
199121
200- ret = _install_special_mapping (mm , vdso_base , VVAR_NR_PAGES * PAGE_SIZE ,
201- VM_READ |VM_MAYREAD |VM_PFNMAP ,
202- & vvar_map );
122+ ret = vdso_install_vvar_mapping (mm , vdso_base );
203123 if (IS_ERR (ret ))
204124 goto up_fail ;
205125
206126 if (system_supports_bti_kernel ())
207127 gp_flags = VM_ARM64_BTI ;
208128
209- vdso_base += VVAR_NR_PAGES * PAGE_SIZE ;
129+ vdso_base += VDSO_NR_PAGES * PAGE_SIZE ;
210130 mm -> context .vdso = (void * )vdso_base ;
211131 ret = _install_special_mapping (mm , vdso_base , vdso_text_len ,
212132 VM_READ |VM_EXEC |gp_flags |
0 commit comments