hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/arch/riscv/kernel/vdso.c
....@@ -1,28 +1,22 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (C) 2004 Benjamin Herrenschmidt, IBM Corp.
34 * <benh@kernel.crashing.org>
45 * Copyright (C) 2012 ARM Limited
56 * Copyright (C) 2015 Regents of the University of California
6
- *
7
- * This program is free software; you can redistribute it and/or modify
8
- * it under the terms of the GNU General Public License version 2 as
9
- * published by the Free Software Foundation.
10
- *
11
- * This program is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- * GNU General Public License for more details.
15
- *
16
- * You should have received a copy of the GNU General Public License
17
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
187 */
198
9
+#include <linux/elf.h>
2010 #include <linux/mm.h>
2111 #include <linux/slab.h>
2212 #include <linux/binfmts.h>
2313 #include <linux/err.h>
24
-
14
+#include <asm/page.h>
15
+#ifdef CONFIG_GENERIC_TIME_VSYSCALL
16
+#include <vdso/datapage.h>
17
+#else
2518 #include <asm/vdso.h>
19
+#endif
2620
2721 extern char vdso_start[], vdso_end[];
2822
....@@ -54,7 +48,6 @@
5448 struct page *pg;
5549
5650 pg = virt_to_page(vdso_start + (i << PAGE_SHIFT));
57
- ClearPageReserved(pg);
5851 vdso_pagelist[i] = pg;
5952 }
6053 vdso_pagelist[i] = virt_to_page(vdso_data);
....@@ -72,7 +65,9 @@
7265
7366 vdso_len = (vdso_pages + 1) << PAGE_SHIFT;
7467
75
- down_write(&mm->mmap_sem);
68
+ if (mmap_write_lock_killable(mm))
69
+ return -EINTR;
70
+
7671 vdso_base = get_unmapped_area(NULL, 0, vdso_len, 0, 0);
7772 if (IS_ERR_VALUE(vdso_base)) {
7873 ret = vdso_base;
....@@ -86,15 +81,24 @@
8681 */
8782 mm->context.vdso = (void *)vdso_base;
8883
89
- ret = install_special_mapping(mm, vdso_base, vdso_len,
84
+ ret =
85
+ install_special_mapping(mm, vdso_base, vdso_pages << PAGE_SHIFT,
9086 (VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC),
9187 vdso_pagelist);
9288
89
+ if (unlikely(ret)) {
90
+ mm->context.vdso = NULL;
91
+ goto end;
92
+ }
93
+
94
+ vdso_base += (vdso_pages << PAGE_SHIFT);
95
+ ret = install_special_mapping(mm, vdso_base, PAGE_SIZE,
96
+ (VM_READ | VM_MAYREAD), &vdso_pagelist[vdso_pages]);
97
+
9398 if (unlikely(ret))
9499 mm->context.vdso = NULL;
95
-
96100 end:
97
- up_write(&mm->mmap_sem);
101
+ mmap_write_unlock(mm);
98102 return ret;
99103 }
100104
....@@ -102,24 +106,8 @@
102106 {
103107 if (vma->vm_mm && (vma->vm_start == (long)vma->vm_mm->context.vdso))
104108 return "[vdso]";
105
- return NULL;
106
-}
107
-
108
-/*
109
- * Function stubs to prevent linker errors when AT_SYSINFO_EHDR is defined
110
- */
111
-
112
-int in_gate_area_no_mm(unsigned long addr)
113
-{
114
- return 0;
115
-}
116
-
117
-int in_gate_area(struct mm_struct *mm, unsigned long addr)
118
-{
119
- return 0;
120
-}
121
-
122
-struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
123
-{
109
+ if (vma->vm_mm && (vma->vm_start ==
110
+ (long)vma->vm_mm->context.vdso + PAGE_SIZE))
111
+ return "[vdso_data]";
124112 return NULL;
125113 }