]> git.ipfire.org Git - thirdparty/kernel/linux.git/blobdiff - arch/x86/entry/vdso/vma.c
x86: convert vdso to use vm_fault_t
[thirdparty/kernel/linux.git] / arch / x86 / entry / vdso / vma.c
index 5b8b556dbb12aa91664aac85fad9e0d5af0259cd..7eb878561910f168b82a84bb4c52efdd5a901595 100644 (file)
@@ -39,7 +39,7 @@ void __init init_vdso_image(const struct vdso_image *image)
 
 struct linux_binprm;
 
-static int vdso_fault(const struct vm_special_mapping *sm,
+static vm_fault_t vdso_fault(const struct vm_special_mapping *sm,
                      struct vm_area_struct *vma, struct vm_fault *vmf)
 {
        const struct vdso_image *image = vma->vm_mm->context.vdso_image;
@@ -84,12 +84,11 @@ static int vdso_mremap(const struct vm_special_mapping *sm,
        return 0;
 }
 
-static int vvar_fault(const struct vm_special_mapping *sm,
+static vm_fault_t vvar_fault(const struct vm_special_mapping *sm,
                      struct vm_area_struct *vma, struct vm_fault *vmf)
 {
        const struct vdso_image *image = vma->vm_mm->context.vdso_image;
        long sym_offset;
-       int ret = -EFAULT;
 
        if (!image)
                return VM_FAULT_SIGBUS;
@@ -108,29 +107,24 @@ static int vvar_fault(const struct vm_special_mapping *sm,
                return VM_FAULT_SIGBUS;
 
        if (sym_offset == image->sym_vvar_page) {
-               ret = vm_insert_pfn(vma, vmf->address,
-                                   __pa_symbol(&__vvar_page) >> PAGE_SHIFT);
+               return vmf_insert_pfn(vma, vmf->address,
+                               __pa_symbol(&__vvar_page) >> PAGE_SHIFT);
        } else if (sym_offset == image->sym_pvclock_page) {
                struct pvclock_vsyscall_time_info *pvti =
                        pvclock_get_pvti_cpu0_va();
                if (pvti && vclock_was_used(VCLOCK_PVCLOCK)) {
-                       ret = vm_insert_pfn_prot(
-                               vma,
-                               vmf->address,
-                               __pa(pvti) >> PAGE_SHIFT,
-                               pgprot_decrypted(vma->vm_page_prot));
+                       return vmf_insert_pfn_prot(vma, vmf->address,
+                                       __pa(pvti) >> PAGE_SHIFT,
+                                       pgprot_decrypted(vma->vm_page_prot));
                }
        } else if (sym_offset == image->sym_hvclock_page) {
                struct ms_hyperv_tsc_page *tsc_pg = hv_get_tsc_page();
 
                if (tsc_pg && vclock_was_used(VCLOCK_HVCLOCK))
-                       ret = vm_insert_pfn(vma, vmf->address,
-                                           vmalloc_to_pfn(tsc_pg));
+                       return vmf_insert_pfn(vma, vmf->address,
+                                       vmalloc_to_pfn(tsc_pg));
        }
 
-       if (ret == 0 || ret == -EBUSY)
-               return VM_FAULT_NOPAGE;
-
        return VM_FAULT_SIGBUS;
 }
 
@@ -332,40 +326,6 @@ static __init int vdso_setup(char *s)
        return 0;
 }
 __setup("vdso=", vdso_setup);
-#endif
-
-#ifdef CONFIG_X86_64
-static void vgetcpu_cpu_init(void *arg)
-{
-       int cpu = smp_processor_id();
-       struct desc_struct d = { };
-       unsigned long node = 0;
-#ifdef CONFIG_NUMA
-       node = cpu_to_node(cpu);
-#endif
-       if (static_cpu_has(X86_FEATURE_RDTSCP))
-               write_rdtscp_aux((node << 12) | cpu);
-
-       /*
-        * Store cpu number in limit so that it can be loaded
-        * quickly in user space in vgetcpu. (12 bits for the CPU
-        * and 8 bits for the node)
-        */
-       d.limit0 = cpu | ((node & 0xf) << 12);
-       d.limit1 = node >> 4;
-       d.type = 5;             /* RO data, expand down, accessed */
-       d.dpl = 3;              /* Visible to user code */
-       d.s = 1;                /* Not a system segment */
-       d.p = 1;                /* Present */
-       d.d = 1;                /* 32-bit */
-
-       write_gdt_entry(get_cpu_gdt_rw(cpu), GDT_ENTRY_PER_CPU, &d, DESCTYPE_S);
-}
-
-static int vgetcpu_online(unsigned int cpu)
-{
-       return smp_call_function_single(cpu, vgetcpu_cpu_init, NULL, 1);
-}
 
 static int __init init_vdso(void)
 {
@@ -375,9 +335,7 @@ static int __init init_vdso(void)
        init_vdso_image(&vdso_image_x32);
 #endif
 
-       /* notifier priority > KVM */
-       return cpuhp_setup_state(CPUHP_AP_X86_VDSO_VMA_ONLINE,
-                                "x86/vdso/vma:online", vgetcpu_online, NULL);
+       return 0;
 }
 subsys_initcall(init_vdso);
 #endif /* CONFIG_X86_64 */