Skip to content

Commit 1c2f04c

Browse files
chenhuacaigregkh
authored andcommitted
LoongArch: Fix build errors due to backported TIMENS
Commit eb3710e ("LoongArch: Add support to clone a time namespace") backports the TIMENS support for LoongArch (corresponding upstream commit aa5e65dc0818bbf676bf06927368ec46867778fd) but causes build errors: CC arch/loongarch/kernel/vdso.o arch/loongarch/kernel/vdso.c: In function ‘vvar_fault’: arch/loongarch/kernel/vdso.c:54:36: error: implicit declaration of function ‘find_timens_vvar_page’ [-Werror=implicit-function-declaration] 54 | struct page *timens_page = find_timens_vvar_page(vma); | ^~~~~~~~~~~~~~~~~~~~~ arch/loongarch/kernel/vdso.c:54:36: warning: initialization of ‘struct page *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion] arch/loongarch/kernel/vdso.c: In function ‘vdso_join_timens’: arch/loongarch/kernel/vdso.c:143:25: error: implicit declaration of function ‘zap_vma_pages’; did you mean ‘zap_vma_ptes’? [-Werror=implicit-function-declaration] 143 | zap_vma_pages(vma); | ^~~~~~~~~~~~~ | zap_vma_ptes cc1: some warnings being treated as errors Because in 6.1.y we should define find_timens_vvar_page() by ourselves and use zap_page_range() instead of zap_vma_pages(), so fix it. Signed-off-by: Huacai Chen <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 82cae1e commit 1c2f04c

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

arch/loongarch/kernel/vdso.c

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ static struct page *vdso_pages[] = { NULL };
4040
struct vdso_data *vdso_data = generic_vdso_data.data;
4141
struct vdso_pcpu_data *vdso_pdata = loongarch_vdso_data.vdata.pdata;
4242

43+
static struct page *find_timens_vvar_page(struct vm_area_struct *vma);
44+
4345
static int vdso_mremap(const struct vm_special_mapping *sm, struct vm_area_struct *new_vma)
4446
{
4547
current->mm->context.vdso = (void *)(new_vma->vm_start);
@@ -139,13 +141,37 @@ int vdso_join_timens(struct task_struct *task, struct time_namespace *ns)
139141

140142
mmap_read_lock(mm);
141143
for_each_vma(vmi, vma) {
144+
unsigned long size = vma->vm_end - vma->vm_start;
145+
142146
if (vma_is_special_mapping(vma, &vdso_info.data_mapping))
143-
zap_vma_pages(vma);
147+
zap_page_range(vma, vma->vm_start, size);
144148
}
145149
mmap_read_unlock(mm);
146150

147151
return 0;
148152
}
153+
154+
static struct page *find_timens_vvar_page(struct vm_area_struct *vma)
155+
{
156+
if (likely(vma->vm_mm == current->mm))
157+
return current->nsproxy->time_ns->vvar_page;
158+
159+
/*
160+
* VM_PFNMAP | VM_IO protect .fault() handler from being called
161+
* through interfaces like /proc/$pid/mem or
162+
* process_vm_{readv,writev}() as long as there's no .access()
163+
* in special_mapping_vmops.
164+
* For more details check_vma_flags() and __access_remote_vm()
165+
*/
166+
WARN(1, "vvar_page accessed remotely");
167+
168+
return NULL;
169+
}
170+
#else
171+
static struct page *find_timens_vvar_page(struct vm_area_struct *vma)
172+
{
173+
return NULL;
174+
}
149175
#endif
150176

151177
static unsigned long vdso_base(void)

0 commit comments

Comments
 (0)