Andi Kleen | 2aae950 | 2007-07-21 17:10:01 +0200 | [diff] [blame] | 1 | /* |
Andi Kleen | 2aae950 | 2007-07-21 17:10:01 +0200 | [diff] [blame] | 2 | * Copyright 2007 Andi Kleen, SUSE Labs. |
| 3 | * Subject to the GPL, v.2 |
Andy Lutomirski | 1c0c1b9 | 2014-09-23 10:50:57 -0700 | [diff] [blame] | 4 | * |
| 5 | * This contains most of the x86 vDSO kernel-side code. |
Andi Kleen | 2aae950 | 2007-07-21 17:10:01 +0200 | [diff] [blame] | 6 | */ |
| 7 | #include <linux/mm.h> |
Alexey Dobriyan | 4e950f6 | 2007-07-30 02:36:13 +0400 | [diff] [blame] | 8 | #include <linux/err.h> |
Andi Kleen | 2aae950 | 2007-07-21 17:10:01 +0200 | [diff] [blame] | 9 | #include <linux/sched.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 10 | #include <linux/slab.h> |
Andi Kleen | 2aae950 | 2007-07-21 17:10:01 +0200 | [diff] [blame] | 11 | #include <linux/init.h> |
| 12 | #include <linux/random.h> |
Jaswinder Singh Rajput | 3fa89ca | 2009-04-12 20:37:25 +0530 | [diff] [blame] | 13 | #include <linux/elf.h> |
Andy Lutomirski | d4f829d | 2014-09-23 10:50:52 -0700 | [diff] [blame] | 14 | #include <linux/cpu.h> |
Andi Kleen | 2aae950 | 2007-07-21 17:10:01 +0200 | [diff] [blame] | 15 | #include <asm/vgtod.h> |
| 16 | #include <asm/proto.h> |
Roland McGrath | 7f3646a | 2008-01-30 13:30:41 +0100 | [diff] [blame] | 17 | #include <asm/vdso.h> |
Andy Lutomirski | 1c0c1b9 | 2014-09-23 10:50:57 -0700 | [diff] [blame] | 18 | #include <asm/vvar.h> |
Andy Lutomirski | aafade2 | 2011-07-21 15:47:10 -0400 | [diff] [blame] | 19 | #include <asm/page.h> |
Andy Lutomirski | 18d0a6f | 2014-05-05 12:19:35 -0700 | [diff] [blame] | 20 | #include <asm/hpet.h> |
Andy Lutomirski | d4f829d | 2014-09-23 10:50:52 -0700 | [diff] [blame] | 21 | #include <asm/desc.h> |
Roland McGrath | 7f3646a | 2008-01-30 13:30:41 +0100 | [diff] [blame] | 22 | |
Andy Lutomirski | b4b541a | 2014-03-17 23:22:08 +0100 | [diff] [blame] | 23 | #if defined(CONFIG_X86_64) |
Andy Lutomirski | 3d7ee96 | 2014-05-05 12:19:32 -0700 | [diff] [blame] | 24 | unsigned int __read_mostly vdso64_enabled = 1; |
Andy Lutomirski | b4b541a | 2014-03-17 23:22:08 +0100 | [diff] [blame] | 25 | #endif |
H. J. Lu | 1a21d4e | 2012-02-19 11:38:06 -0800 | [diff] [blame] | 26 | |
Andy Lutomirski | 6f121e5 | 2014-05-05 12:19:34 -0700 | [diff] [blame] | 27 | void __init init_vdso_image(const struct vdso_image *image) |
H. J. Lu | 1a21d4e | 2012-02-19 11:38:06 -0800 | [diff] [blame] | 28 | { |
H. J. Lu | 1a21d4e | 2012-02-19 11:38:06 -0800 | [diff] [blame] | 29 | int i; |
Andy Lutomirski | 6f121e5 | 2014-05-05 12:19:34 -0700 | [diff] [blame] | 30 | int npages = (image->size) / PAGE_SIZE; |
H. J. Lu | 1a21d4e | 2012-02-19 11:38:06 -0800 | [diff] [blame] | 31 | |
Andy Lutomirski | 6f121e5 | 2014-05-05 12:19:34 -0700 | [diff] [blame] | 32 | BUG_ON(image->size % PAGE_SIZE != 0); |
| 33 | for (i = 0; i < npages; i++) |
Andy Lutomirski | a62c34b | 2014-05-19 15:58:33 -0700 | [diff] [blame] | 34 | image->text_mapping.pages[i] = |
| 35 | virt_to_page(image->data + i*PAGE_SIZE); |
H. J. Lu | 1a21d4e | 2012-02-19 11:38:06 -0800 | [diff] [blame] | 36 | |
Andy Lutomirski | 6f121e5 | 2014-05-05 12:19:34 -0700 | [diff] [blame] | 37 | apply_alternatives((struct alt_instr *)(image->data + image->alt), |
| 38 | (struct alt_instr *)(image->data + image->alt + |
| 39 | image->alt_len)); |
H. J. Lu | 1a21d4e | 2012-02-19 11:38:06 -0800 | [diff] [blame] | 40 | } |
Andy Lutomirski | 6f121e5 | 2014-05-05 12:19:34 -0700 | [diff] [blame] | 41 | |
Andi Kleen | 2aae950 | 2007-07-21 17:10:01 +0200 | [diff] [blame] | 42 | struct linux_binprm; |
| 43 | |
Andy Lutomirski | 394f56f | 2014-12-19 16:04:11 -0800 | [diff] [blame] | 44 | /* |
| 45 | * Put the vdso above the (randomized) stack with another randomized |
| 46 | * offset. This way there is no hole in the middle of address space. |
| 47 | * To save memory make sure it is still in the same PTE as the stack |
| 48 | * top. This doesn't give that many random bits. |
| 49 | * |
| 50 | * Note that this algorithm is imperfect: the distribution of the vdso |
| 51 | * start address within a PMD is biased toward the end. |
| 52 | * |
| 53 | * Only used for the 64-bit and x32 vdsos. |
| 54 | */ |
Andi Kleen | 2aae950 | 2007-07-21 17:10:01 +0200 | [diff] [blame] | 55 | static unsigned long vdso_addr(unsigned long start, unsigned len) |
| 56 | { |
Jan Beulich | d093601 | 2014-07-03 15:35:07 +0100 | [diff] [blame] | 57 | #ifdef CONFIG_X86_32 |
| 58 | return 0; |
| 59 | #else |
Andi Kleen | 2aae950 | 2007-07-21 17:10:01 +0200 | [diff] [blame] | 60 | unsigned long addr, end; |
| 61 | unsigned offset; |
Andy Lutomirski | 394f56f | 2014-12-19 16:04:11 -0800 | [diff] [blame] | 62 | |
| 63 | /* |
| 64 | * Round up the start address. It can start out unaligned as a result |
| 65 | * of stack start randomization. |
| 66 | */ |
| 67 | start = PAGE_ALIGN(start); |
| 68 | |
| 69 | /* Round the lowest possible end address up to a PMD boundary. */ |
| 70 | end = (start + len + PMD_SIZE - 1) & PMD_MASK; |
Ingo Molnar | d951734 | 2009-02-20 23:32:28 +0100 | [diff] [blame] | 71 | if (end >= TASK_SIZE_MAX) |
| 72 | end = TASK_SIZE_MAX; |
Andi Kleen | 2aae950 | 2007-07-21 17:10:01 +0200 | [diff] [blame] | 73 | end -= len; |
Andy Lutomirski | 394f56f | 2014-12-19 16:04:11 -0800 | [diff] [blame] | 74 | |
| 75 | if (end > start) { |
| 76 | offset = get_random_int() % (((end - start) >> PAGE_SHIFT) + 1); |
| 77 | addr = start + (offset << PAGE_SHIFT); |
| 78 | } else { |
| 79 | addr = start; |
| 80 | } |
Borislav Petkov | dfb09f9 | 2011-08-05 15:15:08 +0200 | [diff] [blame] | 81 | |
| 82 | /* |
Andy Lutomirski | 394f56f | 2014-12-19 16:04:11 -0800 | [diff] [blame] | 83 | * Forcibly align the final address in case we have a hardware |
| 84 | * issue that requires alignment for performance reasons. |
Borislav Petkov | dfb09f9 | 2011-08-05 15:15:08 +0200 | [diff] [blame] | 85 | */ |
Michel Lespinasse | f9902472 | 2012-12-11 16:01:52 -0800 | [diff] [blame] | 86 | addr = align_vdso_addr(addr); |
Borislav Petkov | dfb09f9 | 2011-08-05 15:15:08 +0200 | [diff] [blame] | 87 | |
Andi Kleen | 2aae950 | 2007-07-21 17:10:01 +0200 | [diff] [blame] | 88 | return addr; |
Jan Beulich | d093601 | 2014-07-03 15:35:07 +0100 | [diff] [blame] | 89 | #endif |
Andi Kleen | 2aae950 | 2007-07-21 17:10:01 +0200 | [diff] [blame] | 90 | } |
| 91 | |
Andy Lutomirski | 18d0a6f | 2014-05-05 12:19:35 -0700 | [diff] [blame] | 92 | static int map_vdso(const struct vdso_image *image, bool calculate_addr) |
Andi Kleen | 2aae950 | 2007-07-21 17:10:01 +0200 | [diff] [blame] | 93 | { |
| 94 | struct mm_struct *mm = current->mm; |
Andy Lutomirski | 18d0a6f | 2014-05-05 12:19:35 -0700 | [diff] [blame] | 95 | struct vm_area_struct *vma; |
Andy Lutomirski | e6577a7 | 2014-07-10 18:13:15 -0700 | [diff] [blame] | 96 | unsigned long addr, text_start; |
Andy Lutomirski | 18d0a6f | 2014-05-05 12:19:35 -0700 | [diff] [blame] | 97 | int ret = 0; |
Andy Lutomirski | 1e844fb | 2014-05-19 15:58:31 -0700 | [diff] [blame] | 98 | static struct page *no_pages[] = {NULL}; |
Andy Lutomirski | a62c34b | 2014-05-19 15:58:33 -0700 | [diff] [blame] | 99 | static struct vm_special_mapping vvar_mapping = { |
| 100 | .name = "[vvar]", |
| 101 | .pages = no_pages, |
| 102 | }; |
Andy Lutomirski | dac16fb | 2015-12-10 19:20:20 -0800 | [diff] [blame^] | 103 | struct pvclock_vsyscall_time_info *pvti; |
Andi Kleen | 2aae950 | 2007-07-21 17:10:01 +0200 | [diff] [blame] | 104 | |
Andy Lutomirski | 18d0a6f | 2014-05-05 12:19:35 -0700 | [diff] [blame] | 105 | if (calculate_addr) { |
| 106 | addr = vdso_addr(current->mm->start_stack, |
Andy Lutomirski | e6577a7 | 2014-07-10 18:13:15 -0700 | [diff] [blame] | 107 | image->size - image->sym_vvar_start); |
Andy Lutomirski | 18d0a6f | 2014-05-05 12:19:35 -0700 | [diff] [blame] | 108 | } else { |
| 109 | addr = 0; |
| 110 | } |
Andi Kleen | 2aae950 | 2007-07-21 17:10:01 +0200 | [diff] [blame] | 111 | |
| 112 | down_write(&mm->mmap_sem); |
Andy Lutomirski | 18d0a6f | 2014-05-05 12:19:35 -0700 | [diff] [blame] | 113 | |
Andy Lutomirski | e6577a7 | 2014-07-10 18:13:15 -0700 | [diff] [blame] | 114 | addr = get_unmapped_area(NULL, addr, |
| 115 | image->size - image->sym_vvar_start, 0, 0); |
Andi Kleen | 2aae950 | 2007-07-21 17:10:01 +0200 | [diff] [blame] | 116 | if (IS_ERR_VALUE(addr)) { |
| 117 | ret = addr; |
| 118 | goto up_fail; |
| 119 | } |
| 120 | |
Andy Lutomirski | e6577a7 | 2014-07-10 18:13:15 -0700 | [diff] [blame] | 121 | text_start = addr - image->sym_vvar_start; |
| 122 | current->mm->context.vdso = (void __user *)text_start; |
Peter Zijlstra | f7b6eb3 | 2009-06-05 14:04:51 +0200 | [diff] [blame] | 123 | |
Andy Lutomirski | 18d0a6f | 2014-05-05 12:19:35 -0700 | [diff] [blame] | 124 | /* |
| 125 | * MAYWRITE to allow gdb to COW and set breakpoints |
| 126 | */ |
Andy Lutomirski | a62c34b | 2014-05-19 15:58:33 -0700 | [diff] [blame] | 127 | vma = _install_special_mapping(mm, |
Andy Lutomirski | e6577a7 | 2014-07-10 18:13:15 -0700 | [diff] [blame] | 128 | text_start, |
Andy Lutomirski | a62c34b | 2014-05-19 15:58:33 -0700 | [diff] [blame] | 129 | image->size, |
| 130 | VM_READ|VM_EXEC| |
| 131 | VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC, |
| 132 | &image->text_mapping); |
Andy Lutomirski | 18d0a6f | 2014-05-05 12:19:35 -0700 | [diff] [blame] | 133 | |
Andy Lutomirski | a62c34b | 2014-05-19 15:58:33 -0700 | [diff] [blame] | 134 | if (IS_ERR(vma)) { |
| 135 | ret = PTR_ERR(vma); |
Andy Lutomirski | 18d0a6f | 2014-05-05 12:19:35 -0700 | [diff] [blame] | 136 | goto up_fail; |
Andy Lutomirski | a62c34b | 2014-05-19 15:58:33 -0700 | [diff] [blame] | 137 | } |
Andy Lutomirski | 18d0a6f | 2014-05-05 12:19:35 -0700 | [diff] [blame] | 138 | |
| 139 | vma = _install_special_mapping(mm, |
Andy Lutomirski | e6577a7 | 2014-07-10 18:13:15 -0700 | [diff] [blame] | 140 | addr, |
| 141 | -image->sym_vvar_start, |
Andy Lutomirski | ac37983 | 2014-07-25 16:27:01 -0700 | [diff] [blame] | 142 | VM_READ|VM_MAYREAD, |
Andy Lutomirski | a62c34b | 2014-05-19 15:58:33 -0700 | [diff] [blame] | 143 | &vvar_mapping); |
Andy Lutomirski | 18d0a6f | 2014-05-05 12:19:35 -0700 | [diff] [blame] | 144 | |
| 145 | if (IS_ERR(vma)) { |
| 146 | ret = PTR_ERR(vma); |
Andi Kleen | 2aae950 | 2007-07-21 17:10:01 +0200 | [diff] [blame] | 147 | goto up_fail; |
Peter Zijlstra | f7b6eb3 | 2009-06-05 14:04:51 +0200 | [diff] [blame] | 148 | } |
Andi Kleen | 2aae950 | 2007-07-21 17:10:01 +0200 | [diff] [blame] | 149 | |
Andy Lutomirski | 18d0a6f | 2014-05-05 12:19:35 -0700 | [diff] [blame] | 150 | if (image->sym_vvar_page) |
| 151 | ret = remap_pfn_range(vma, |
Andy Lutomirski | e6577a7 | 2014-07-10 18:13:15 -0700 | [diff] [blame] | 152 | text_start + image->sym_vvar_page, |
Andy Lutomirski | 18d0a6f | 2014-05-05 12:19:35 -0700 | [diff] [blame] | 153 | __pa_symbol(&__vvar_page) >> PAGE_SHIFT, |
| 154 | PAGE_SIZE, |
| 155 | PAGE_READONLY); |
| 156 | |
| 157 | if (ret) |
| 158 | goto up_fail; |
| 159 | |
| 160 | #ifdef CONFIG_HPET_TIMER |
| 161 | if (hpet_address && image->sym_hpet_page) { |
| 162 | ret = io_remap_pfn_range(vma, |
Andy Lutomirski | e6577a7 | 2014-07-10 18:13:15 -0700 | [diff] [blame] | 163 | text_start + image->sym_hpet_page, |
Andy Lutomirski | 18d0a6f | 2014-05-05 12:19:35 -0700 | [diff] [blame] | 164 | hpet_address >> PAGE_SHIFT, |
| 165 | PAGE_SIZE, |
| 166 | pgprot_noncached(PAGE_READONLY)); |
| 167 | |
| 168 | if (ret) |
| 169 | goto up_fail; |
| 170 | } |
| 171 | #endif |
| 172 | |
Andy Lutomirski | dac16fb | 2015-12-10 19:20:20 -0800 | [diff] [blame^] | 173 | pvti = pvclock_pvti_cpu0_va(); |
| 174 | if (pvti && image->sym_pvclock_page) { |
| 175 | ret = remap_pfn_range(vma, |
| 176 | text_start + image->sym_pvclock_page, |
| 177 | __pa(pvti) >> PAGE_SHIFT, |
| 178 | PAGE_SIZE, |
| 179 | PAGE_READONLY); |
| 180 | |
| 181 | if (ret) |
| 182 | goto up_fail; |
| 183 | } |
| 184 | |
Andi Kleen | 2aae950 | 2007-07-21 17:10:01 +0200 | [diff] [blame] | 185 | up_fail: |
Andy Lutomirski | 18d0a6f | 2014-05-05 12:19:35 -0700 | [diff] [blame] | 186 | if (ret) |
| 187 | current->mm->context.vdso = NULL; |
| 188 | |
Andi Kleen | 2aae950 | 2007-07-21 17:10:01 +0200 | [diff] [blame] | 189 | up_write(&mm->mmap_sem); |
| 190 | return ret; |
| 191 | } |
| 192 | |
Brian Gerst | ab8b82ee6 | 2015-06-22 07:55:15 -0400 | [diff] [blame] | 193 | #if defined(CONFIG_X86_32) || defined(CONFIG_IA32_EMULATION) |
Andy Lutomirski | 18d0a6f | 2014-05-05 12:19:35 -0700 | [diff] [blame] | 194 | static int load_vdso32(void) |
H. J. Lu | 1a21d4e | 2012-02-19 11:38:06 -0800 | [diff] [blame] | 195 | { |
Andy Lutomirski | 18d0a6f | 2014-05-05 12:19:35 -0700 | [diff] [blame] | 196 | if (vdso32_enabled != 1) /* Other values all mean "disabled" */ |
| 197 | return 0; |
| 198 | |
Andy Lutomirski | 0a6d1fa | 2015-10-05 17:47:56 -0700 | [diff] [blame] | 199 | return map_vdso(&vdso_image_32, false); |
H. J. Lu | 1a21d4e | 2012-02-19 11:38:06 -0800 | [diff] [blame] | 200 | } |
| 201 | #endif |
| 202 | |
Andy Lutomirski | 18d0a6f | 2014-05-05 12:19:35 -0700 | [diff] [blame] | 203 | #ifdef CONFIG_X86_64 |
| 204 | int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp) |
| 205 | { |
| 206 | if (!vdso64_enabled) |
| 207 | return 0; |
| 208 | |
| 209 | return map_vdso(&vdso_image_64, true); |
| 210 | } |
| 211 | |
| 212 | #ifdef CONFIG_COMPAT |
| 213 | int compat_arch_setup_additional_pages(struct linux_binprm *bprm, |
| 214 | int uses_interp) |
| 215 | { |
| 216 | #ifdef CONFIG_X86_X32_ABI |
| 217 | if (test_thread_flag(TIF_X32)) { |
| 218 | if (!vdso64_enabled) |
| 219 | return 0; |
| 220 | |
| 221 | return map_vdso(&vdso_image_x32, true); |
| 222 | } |
| 223 | #endif |
Brian Gerst | ab8b82ee6 | 2015-06-22 07:55:15 -0400 | [diff] [blame] | 224 | #ifdef CONFIG_IA32_EMULATION |
Andy Lutomirski | 18d0a6f | 2014-05-05 12:19:35 -0700 | [diff] [blame] | 225 | return load_vdso32(); |
Brian Gerst | ab8b82ee6 | 2015-06-22 07:55:15 -0400 | [diff] [blame] | 226 | #else |
| 227 | return 0; |
| 228 | #endif |
Andy Lutomirski | 18d0a6f | 2014-05-05 12:19:35 -0700 | [diff] [blame] | 229 | } |
| 230 | #endif |
| 231 | #else |
| 232 | int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp) |
| 233 | { |
| 234 | return load_vdso32(); |
| 235 | } |
| 236 | #endif |
| 237 | |
| 238 | #ifdef CONFIG_X86_64 |
Andi Kleen | 2aae950 | 2007-07-21 17:10:01 +0200 | [diff] [blame] | 239 | static __init int vdso_setup(char *s) |
| 240 | { |
Andy Lutomirski | 3d7ee96 | 2014-05-05 12:19:32 -0700 | [diff] [blame] | 241 | vdso64_enabled = simple_strtoul(s, NULL, 0); |
Andi Kleen | 2aae950 | 2007-07-21 17:10:01 +0200 | [diff] [blame] | 242 | return 0; |
| 243 | } |
| 244 | __setup("vdso=", vdso_setup); |
Andy Lutomirski | b4b541a | 2014-03-17 23:22:08 +0100 | [diff] [blame] | 245 | #endif |
Andy Lutomirski | d4f829d | 2014-09-23 10:50:52 -0700 | [diff] [blame] | 246 | |
| 247 | #ifdef CONFIG_X86_64 |
Andy Lutomirski | 1c0c1b9 | 2014-09-23 10:50:57 -0700 | [diff] [blame] | 248 | static void vgetcpu_cpu_init(void *arg) |
Andy Lutomirski | d4f829d | 2014-09-23 10:50:52 -0700 | [diff] [blame] | 249 | { |
Andy Lutomirski | 1c0c1b9 | 2014-09-23 10:50:57 -0700 | [diff] [blame] | 250 | int cpu = smp_processor_id(); |
Andrew Morton | a92f101 | 2014-11-01 21:18:26 +0100 | [diff] [blame] | 251 | struct desc_struct d = { }; |
Andy Lutomirski | d4f829d | 2014-09-23 10:50:52 -0700 | [diff] [blame] | 252 | unsigned long node = 0; |
| 253 | #ifdef CONFIG_NUMA |
| 254 | node = cpu_to_node(cpu); |
| 255 | #endif |
| 256 | if (cpu_has(&cpu_data(cpu), X86_FEATURE_RDTSCP)) |
| 257 | write_rdtscp_aux((node << 12) | cpu); |
| 258 | |
| 259 | /* |
Andy Lutomirski | 2588015 | 2014-09-23 10:50:53 -0700 | [diff] [blame] | 260 | * Store cpu number in limit so that it can be loaded |
| 261 | * quickly in user space in vgetcpu. (12 bits for the CPU |
| 262 | * and 8 bits for the node) |
Andy Lutomirski | d4f829d | 2014-09-23 10:50:52 -0700 | [diff] [blame] | 263 | */ |
Andrew Morton | a92f101 | 2014-11-01 21:18:26 +0100 | [diff] [blame] | 264 | d.limit0 = cpu | ((node & 0xf) << 12); |
| 265 | d.limit = node >> 4; |
| 266 | d.type = 5; /* RO data, expand down, accessed */ |
| 267 | d.dpl = 3; /* Visible to user code */ |
| 268 | d.s = 1; /* Not a system segment */ |
| 269 | d.p = 1; /* Present */ |
| 270 | d.d = 1; /* 32-bit */ |
Andy Lutomirski | d4f829d | 2014-09-23 10:50:52 -0700 | [diff] [blame] | 271 | |
| 272 | write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_PER_CPU, &d, DESCTYPE_S); |
| 273 | } |
| 274 | |
Andy Lutomirski | d4f829d | 2014-09-23 10:50:52 -0700 | [diff] [blame] | 275 | static int |
Andy Lutomirski | 1c0c1b9 | 2014-09-23 10:50:57 -0700 | [diff] [blame] | 276 | vgetcpu_cpu_notifier(struct notifier_block *n, unsigned long action, void *arg) |
Andy Lutomirski | d4f829d | 2014-09-23 10:50:52 -0700 | [diff] [blame] | 277 | { |
| 278 | long cpu = (long)arg; |
| 279 | |
| 280 | if (action == CPU_ONLINE || action == CPU_ONLINE_FROZEN) |
Andy Lutomirski | 1c0c1b9 | 2014-09-23 10:50:57 -0700 | [diff] [blame] | 281 | smp_call_function_single(cpu, vgetcpu_cpu_init, NULL, 1); |
Andy Lutomirski | d4f829d | 2014-09-23 10:50:52 -0700 | [diff] [blame] | 282 | |
| 283 | return NOTIFY_DONE; |
| 284 | } |
| 285 | |
Andy Lutomirski | 1c0c1b9 | 2014-09-23 10:50:57 -0700 | [diff] [blame] | 286 | static int __init init_vdso(void) |
Andy Lutomirski | d4f829d | 2014-09-23 10:50:52 -0700 | [diff] [blame] | 287 | { |
Andy Lutomirski | 1c0c1b9 | 2014-09-23 10:50:57 -0700 | [diff] [blame] | 288 | init_vdso_image(&vdso_image_64); |
| 289 | |
| 290 | #ifdef CONFIG_X86_X32_ABI |
| 291 | init_vdso_image(&vdso_image_x32); |
| 292 | #endif |
| 293 | |
Andy Lutomirski | d4f829d | 2014-09-23 10:50:52 -0700 | [diff] [blame] | 294 | cpu_notifier_register_begin(); |
| 295 | |
Andy Lutomirski | 1c0c1b9 | 2014-09-23 10:50:57 -0700 | [diff] [blame] | 296 | on_each_cpu(vgetcpu_cpu_init, NULL, 1); |
Andy Lutomirski | d4f829d | 2014-09-23 10:50:52 -0700 | [diff] [blame] | 297 | /* notifier priority > KVM */ |
Andy Lutomirski | 1c0c1b9 | 2014-09-23 10:50:57 -0700 | [diff] [blame] | 298 | __hotcpu_notifier(vgetcpu_cpu_notifier, 30); |
Andy Lutomirski | d4f829d | 2014-09-23 10:50:52 -0700 | [diff] [blame] | 299 | |
| 300 | cpu_notifier_register_done(); |
| 301 | |
| 302 | return 0; |
| 303 | } |
Andy Lutomirski | 1c0c1b9 | 2014-09-23 10:50:57 -0700 | [diff] [blame] | 304 | subsys_initcall(init_vdso); |
| 305 | #endif /* CONFIG_X86_64 */ |