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