2019-05-26 23:55:01 -07:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2009-09-20 15:14:15 -07:00
|
|
|
|
2005-11-11 03:15:21 -07:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2004 Benjamin Herrenschmidt, IBM Corp.
|
|
|
|
* <benh@kernel.crashing.org>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/sched.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/mm.h>
|
|
|
|
#include <linux/smp.h>
|
|
|
|
#include <linux/stddef.h>
|
|
|
|
#include <linux/unistd.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/user.h>
|
|
|
|
#include <linux/elf.h>
|
|
|
|
#include <linux/security.h>
|
2010-07-11 21:36:09 -07:00
|
|
|
#include <linux/memblock.h>
|
2020-09-27 02:16:19 -07:00
|
|
|
#include <linux/syscalls.h>
|
2021-03-31 09:48:47 -07:00
|
|
|
#include <linux/time_namespace.h>
|
2020-11-26 06:10:05 -07:00
|
|
|
#include <vdso/datapage.h>
|
2005-11-11 03:15:21 -07:00
|
|
|
|
2020-09-27 02:16:19 -07:00
|
|
|
#include <asm/syscall.h>
|
2005-11-11 03:15:21 -07:00
|
|
|
#include <asm/processor.h>
|
|
|
|
#include <asm/mmu.h>
|
|
|
|
#include <asm/mmu_context.h>
|
|
|
|
#include <asm/machdep.h>
|
|
|
|
#include <asm/cputable.h>
|
|
|
|
#include <asm/sections.h>
|
2006-03-28 05:15:54 -07:00
|
|
|
#include <asm/firmware.h>
|
2005-11-11 03:15:21 -07:00
|
|
|
#include <asm/vdso.h>
|
|
|
|
#include <asm/vdso_datapage.h>
|
2013-10-28 07:20:51 -07:00
|
|
|
#include <asm/setup.h>
|
2006-10-19 18:47:18 -07:00
|
|
|
|
2009-10-03 19:35:41 -07:00
|
|
|
/* The alignment of the vDSO */
|
|
|
|
#define VDSO_ALIGNMENT (1 << 16)
|
|
|
|
|
2015-05-11 03:01:02 -07:00
|
|
|
extern char vdso32_start, vdso32_end;
|
2005-11-11 03:15:21 -07:00
|
|
|
extern char vdso64_start, vdso64_end;
|
|
|
|
|
2022-09-20 23:56:01 -07:00
|
|
|
long sys_ni_syscall(void);
|
|
|
|
|
2005-11-11 03:15:21 -07:00
|
|
|
/*
|
|
|
|
* The vdso data page (aka. systemcfg for old ppc64 fans) is here.
|
|
|
|
* Once the early boot kernel code no longer needs to muck around
|
|
|
|
* with it, it will become dynamically allocated
|
|
|
|
*/
|
|
|
|
static union {
|
2020-11-26 06:10:05 -07:00
|
|
|
struct vdso_arch_data data;
|
2005-11-11 03:15:21 -07:00
|
|
|
u8 page[PAGE_SIZE];
|
2009-09-20 15:14:15 -07:00
|
|
|
} vdso_data_store __page_aligned_data;
|
2020-11-26 06:10:05 -07:00
|
|
|
struct vdso_arch_data *vdso_data = &vdso_data_store.data;
|
2005-11-11 03:15:21 -07:00
|
|
|
|
2021-03-31 09:48:47 -07:00
|
|
|
enum vvar_pages {
|
|
|
|
VVAR_DATA_PAGE_OFFSET,
|
|
|
|
VVAR_TIMENS_PAGE_OFFSET,
|
|
|
|
VVAR_NR_PAGES,
|
|
|
|
};
|
|
|
|
|
2020-09-27 02:16:28 -07:00
|
|
|
static int vdso_mremap(const struct vm_special_mapping *sm, struct vm_area_struct *new_vma,
|
|
|
|
unsigned long text_size)
|
|
|
|
{
|
|
|
|
unsigned long new_size = new_vma->vm_end - new_vma->vm_start;
|
|
|
|
|
2021-03-31 09:48:46 -07:00
|
|
|
if (new_size != text_size)
|
2020-09-27 02:16:28 -07:00
|
|
|
return -EINVAL;
|
|
|
|
|
2021-03-31 09:48:46 -07:00
|
|
|
current->mm->context.vdso = (void __user *)new_vma->vm_start;
|
2020-09-27 02:16:28 -07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int vdso32_mremap(const struct vm_special_mapping *sm, struct vm_area_struct *new_vma)
|
|
|
|
{
|
|
|
|
return vdso_mremap(sm, new_vma, &vdso32_end - &vdso32_start);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int vdso64_mremap(const struct vm_special_mapping *sm, struct vm_area_struct *new_vma)
|
|
|
|
{
|
|
|
|
return vdso_mremap(sm, new_vma, &vdso64_end - &vdso64_start);
|
|
|
|
}
|
2005-11-11 03:15:21 -07:00
|
|
|
|
2024-08-12 01:26:03 -07:00
|
|
|
static void vdso_close(const struct vm_special_mapping *sm, struct vm_area_struct *vma)
|
|
|
|
{
|
|
|
|
struct mm_struct *mm = vma->vm_mm;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* close() is called for munmap() but also for mremap(). In the mremap()
|
|
|
|
* case the vdso pointer has already been updated by the mremap() hook
|
|
|
|
* above, so it must not be set to NULL here.
|
|
|
|
*/
|
|
|
|
if (vma->vm_start != (unsigned long)mm->context.vdso)
|
|
|
|
return;
|
|
|
|
|
|
|
|
mm->context.vdso = NULL;
|
|
|
|
}
|
|
|
|
|
2021-03-31 09:48:47 -07:00
|
|
|
static vm_fault_t vvar_fault(const struct vm_special_mapping *sm,
|
|
|
|
struct vm_area_struct *vma, struct vm_fault *vmf);
|
|
|
|
|
2021-03-31 09:48:46 -07:00
|
|
|
static struct vm_special_mapping vvar_spec __ro_after_init = {
|
|
|
|
.name = "[vvar]",
|
2021-03-31 09:48:47 -07:00
|
|
|
.fault = vvar_fault,
|
2021-03-31 09:48:46 -07:00
|
|
|
};
|
|
|
|
|
2020-09-27 02:16:27 -07:00
|
|
|
static struct vm_special_mapping vdso32_spec __ro_after_init = {
|
|
|
|
.name = "[vdso]",
|
2020-09-27 02:16:28 -07:00
|
|
|
.mremap = vdso32_mremap,
|
2024-08-12 01:26:03 -07:00
|
|
|
.close = vdso_close,
|
2020-09-27 02:16:27 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct vm_special_mapping vdso64_spec __ro_after_init = {
|
|
|
|
.name = "[vdso]",
|
2020-09-27 02:16:28 -07:00
|
|
|
.mremap = vdso64_mremap,
|
2024-08-12 01:26:03 -07:00
|
|
|
.close = vdso_close,
|
2020-09-27 02:16:27 -07:00
|
|
|
};
|
|
|
|
|
2021-03-31 09:48:47 -07:00
|
|
|
#ifdef CONFIG_TIME_NS
|
|
|
|
struct vdso_data *arch_get_vdso_data(void *vvar_page)
|
|
|
|
{
|
|
|
|
return ((struct vdso_arch_data *)vvar_page)->data;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The vvar mapping contains data for a specific time namespace, so when a task
|
|
|
|
* changes namespace we must unmap its vvar data for the old namespace.
|
|
|
|
* Subsequent faults will map in data for the new namespace.
|
|
|
|
*
|
|
|
|
* For more details see timens_setup_vdso_data().
|
|
|
|
*/
|
|
|
|
int vdso_join_timens(struct task_struct *task, struct time_namespace *ns)
|
|
|
|
{
|
|
|
|
struct mm_struct *mm = task->mm;
|
2022-09-06 12:48:53 -07:00
|
|
|
VMA_ITERATOR(vmi, mm, 0);
|
2021-03-31 09:48:47 -07:00
|
|
|
struct vm_area_struct *vma;
|
|
|
|
|
|
|
|
mmap_read_lock(mm);
|
2022-09-06 12:48:53 -07:00
|
|
|
for_each_vma(vmi, vma) {
|
2021-03-31 09:48:47 -07:00
|
|
|
if (vma_is_special_mapping(vma, &vvar_spec))
|
2023-01-03 17:27:32 -07:00
|
|
|
zap_vma_pages(vma);
|
2021-03-31 09:48:47 -07:00
|
|
|
}
|
|
|
|
mmap_read_unlock(mm);
|
2022-09-06 12:48:53 -07:00
|
|
|
|
2021-03-31 09:48:47 -07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static vm_fault_t vvar_fault(const struct vm_special_mapping *sm,
|
|
|
|
struct vm_area_struct *vma, struct vm_fault *vmf)
|
|
|
|
{
|
|
|
|
struct page *timens_page = find_timens_vvar_page(vma);
|
|
|
|
unsigned long pfn;
|
|
|
|
|
|
|
|
switch (vmf->pgoff) {
|
|
|
|
case VVAR_DATA_PAGE_OFFSET:
|
|
|
|
if (timens_page)
|
|
|
|
pfn = page_to_pfn(timens_page);
|
|
|
|
else
|
|
|
|
pfn = virt_to_pfn(vdso_data);
|
|
|
|
break;
|
|
|
|
#ifdef CONFIG_TIME_NS
|
|
|
|
case VVAR_TIMENS_PAGE_OFFSET:
|
|
|
|
/*
|
|
|
|
* If a task belongs to a time namespace then a namespace
|
|
|
|
* specific VVAR is mapped with the VVAR_DATA_PAGE_OFFSET and
|
|
|
|
* the real VVAR page is mapped with the VVAR_TIMENS_PAGE_OFFSET
|
|
|
|
* offset.
|
|
|
|
* See also the comment near timens_setup_vdso_data().
|
|
|
|
*/
|
|
|
|
if (!timens_page)
|
|
|
|
return VM_FAULT_SIGBUS;
|
|
|
|
pfn = virt_to_pfn(vdso_data);
|
|
|
|
break;
|
|
|
|
#endif /* CONFIG_TIME_NS */
|
|
|
|
default:
|
|
|
|
return VM_FAULT_SIGBUS;
|
|
|
|
}
|
|
|
|
|
|
|
|
return vmf_insert_pfn(vma, vmf->address, pfn);
|
|
|
|
}
|
|
|
|
|
2005-11-11 03:15:21 -07:00
|
|
|
/*
|
|
|
|
* This is called from binfmt_elf, we create the special vma for the
|
|
|
|
* vDSO and insert it into the mm struct tree
|
|
|
|
*/
|
2020-09-27 02:16:26 -07:00
|
|
|
static int __arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
|
2005-11-11 03:15:21 -07:00
|
|
|
{
|
2021-03-31 09:48:46 -07:00
|
|
|
unsigned long vdso_size, vdso_base, mappings_size;
|
2020-09-27 02:16:27 -07:00
|
|
|
struct vm_special_mapping *vdso_spec;
|
2021-03-31 09:48:47 -07:00
|
|
|
unsigned long vvar_size = VVAR_NR_PAGES * PAGE_SIZE;
|
2021-03-31 09:48:46 -07:00
|
|
|
struct mm_struct *mm = current->mm;
|
2020-09-27 02:16:27 -07:00
|
|
|
struct vm_area_struct *vma;
|
2005-11-11 03:15:21 -07:00
|
|
|
|
2010-08-26 20:49:11 -07:00
|
|
|
if (is_32bit_task()) {
|
2020-09-27 02:16:27 -07:00
|
|
|
vdso_spec = &vdso32_spec;
|
2020-09-27 02:16:25 -07:00
|
|
|
vdso_size = &vdso32_end - &vdso32_start;
|
2005-11-11 03:15:21 -07:00
|
|
|
} else {
|
2020-09-27 02:16:27 -07:00
|
|
|
vdso_spec = &vdso64_spec;
|
2020-09-27 02:16:25 -07:00
|
|
|
vdso_size = &vdso64_end - &vdso64_start;
|
2005-11-11 03:15:21 -07:00
|
|
|
}
|
|
|
|
|
2021-03-31 09:48:46 -07:00
|
|
|
mappings_size = vdso_size + vvar_size;
|
|
|
|
mappings_size += (VDSO_ALIGNMENT - 1) & PAGE_MASK;
|
2005-11-11 03:15:21 -07:00
|
|
|
|
|
|
|
/*
|
2022-08-18 10:31:25 -07:00
|
|
|
* Pick a base address for the vDSO in process space.
|
2009-10-03 19:35:41 -07:00
|
|
|
* Add enough to the size so that the result can be aligned.
|
2005-11-11 03:15:21 -07:00
|
|
|
*/
|
2022-08-18 10:31:25 -07:00
|
|
|
vdso_base = get_unmapped_area(NULL, 0, mappings_size, 0, 0);
|
2020-09-27 02:16:26 -07:00
|
|
|
if (IS_ERR_VALUE(vdso_base))
|
|
|
|
return vdso_base;
|
2005-11-11 03:15:21 -07:00
|
|
|
|
2009-10-03 19:35:41 -07:00
|
|
|
/* Add required alignment. */
|
|
|
|
vdso_base = ALIGN(vdso_base, VDSO_ALIGNMENT);
|
|
|
|
|
2021-03-31 09:48:46 -07:00
|
|
|
vma = _install_special_mapping(mm, vdso_base, vvar_size,
|
|
|
|
VM_READ | VM_MAYREAD | VM_IO |
|
|
|
|
VM_DONTDUMP | VM_PFNMAP, &vvar_spec);
|
|
|
|
if (IS_ERR(vma))
|
|
|
|
return PTR_ERR(vma);
|
2009-09-21 09:57:40 -07:00
|
|
|
|
2005-11-11 03:15:21 -07:00
|
|
|
/*
|
|
|
|
* our vma flags don't have VM_WRITE so by default, the process isn't
|
|
|
|
* allowed to write those pages.
|
|
|
|
* gdb can break that with ptrace interface, and thus trigger COW on
|
|
|
|
* those pages but it's then your responsibility to never do that on
|
|
|
|
* the "data" page of the vDSO or you'll stop getting kernel updates
|
|
|
|
* and your nice userland gettimeofday will be totally dead.
|
|
|
|
* It's fine to use that for setting breakpoints in the vDSO code
|
coredump: remove VM_ALWAYSDUMP flag
The motivation for this patchset was that I was looking at a way for a
qemu-kvm process, to exclude the guest memory from its core dump, which
can be quite large. There are already a number of filter flags in
/proc/<pid>/coredump_filter, however, these allow one to specify 'types'
of kernel memory, not specific address ranges (which is needed in this
case).
Since there are no more vma flags available, the first patch eliminates
the need for the 'VM_ALWAYSDUMP' flag. The flag is used internally by
the kernel to mark vdso and vsyscall pages. However, it is simple
enough to check if a vma covers a vdso or vsyscall page without the need
for this flag.
The second patch then replaces the 'VM_ALWAYSDUMP' flag with a new
'VM_NODUMP' flag, which can be set by userspace using new madvise flags:
'MADV_DONTDUMP', and unset via 'MADV_DODUMP'. The core dump filters
continue to work the same as before unless 'MADV_DONTDUMP' is set on the
region.
The qemu code which implements this features is at:
http://people.redhat.com/~jbaron/qemu-dump/qemu-dump.patch
In my testing the qemu core dump shrunk from 383MB -> 13MB with this
patch.
I also believe that the 'MADV_DONTDUMP' flag might be useful for
security sensitive apps, which might want to select which areas are
dumped.
This patch:
The VM_ALWAYSDUMP flag is currently used by the coredump code to
indicate that a vma is part of a vsyscall or vdso section. However, we
can determine if a vma is in one these sections by checking it against
the gate_vma and checking for a non-NULL return value from
arch_vma_name(). Thus, freeing a valuable vma bit.
Signed-off-by: Jason Baron <jbaron@redhat.com>
Acked-by: Roland McGrath <roland@hack.frob.com>
Cc: Chris Metcalf <cmetcalf@tilera.com>
Cc: Avi Kivity <avi@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-03-23 15:02:51 -07:00
|
|
|
* pages though.
|
2007-01-26 01:56:51 -07:00
|
|
|
*/
|
2021-03-31 09:48:46 -07:00
|
|
|
vma = _install_special_mapping(mm, vdso_base + vvar_size, vdso_size,
|
2020-09-27 02:16:27 -07:00
|
|
|
VM_READ | VM_EXEC | VM_MAYREAD |
|
|
|
|
VM_MAYWRITE | VM_MAYEXEC, vdso_spec);
|
2024-08-12 01:26:05 -07:00
|
|
|
if (IS_ERR(vma)) {
|
2021-03-31 09:48:46 -07:00
|
|
|
do_munmap(mm, vdso_base, vvar_size, NULL);
|
2024-08-12 01:26:05 -07:00
|
|
|
return PTR_ERR(vma);
|
|
|
|
}
|
2021-03-31 09:48:46 -07:00
|
|
|
|
2024-08-12 01:26:05 -07:00
|
|
|
// Now that the mappings are in place, set the mm VDSO pointer
|
|
|
|
mm->context.vdso = (void __user *)vdso_base + vvar_size;
|
|
|
|
|
|
|
|
return 0;
|
2020-09-27 02:16:26 -07:00
|
|
|
}
|
2007-02-08 15:20:43 -07:00
|
|
|
|
2020-09-27 02:16:26 -07:00
|
|
|
int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
|
|
|
|
{
|
|
|
|
struct mm_struct *mm = current->mm;
|
|
|
|
int rc;
|
|
|
|
|
2020-09-27 02:16:29 -07:00
|
|
|
mm->context.vdso = NULL;
|
2020-09-27 02:16:26 -07:00
|
|
|
|
|
|
|
if (mmap_write_lock_killable(mm))
|
|
|
|
return -EINTR;
|
|
|
|
|
|
|
|
rc = __arch_setup_additional_pages(bprm, uses_interp);
|
2006-05-29 20:51:37 -07:00
|
|
|
|
2020-06-08 21:33:25 -07:00
|
|
|
mmap_write_unlock(mm);
|
2006-05-29 20:51:37 -07:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2020-09-27 02:16:34 -07:00
|
|
|
#define VDSO_DO_FIXUPS(type, value, bits, sec) do { \
|
|
|
|
void *__start = (void *)VDSO##bits##_SYMBOL(&vdso##bits##_start, sec##_start); \
|
|
|
|
void *__end = (void *)VDSO##bits##_SYMBOL(&vdso##bits##_start, sec##_end); \
|
|
|
|
\
|
|
|
|
do_##type##_fixups((value), __start, __end); \
|
|
|
|
} while (0)
|
2005-11-11 03:15:21 -07:00
|
|
|
|
2020-09-27 02:16:43 -07:00
|
|
|
static void __init vdso_fixup_features(void)
|
2006-10-19 18:47:18 -07:00
|
|
|
{
|
|
|
|
#ifdef CONFIG_PPC64
|
2020-09-27 02:16:34 -07:00
|
|
|
VDSO_DO_FIXUPS(feature, cur_cpu_spec->cpu_features, 64, ftr_fixup);
|
|
|
|
VDSO_DO_FIXUPS(feature, cur_cpu_spec->mmu_features, 64, mmu_ftr_fixup);
|
|
|
|
VDSO_DO_FIXUPS(feature, powerpc_firmware_features, 64, fw_ftr_fixup);
|
|
|
|
VDSO_DO_FIXUPS(lwsync, cur_cpu_spec->cpu_features, 64, lwsync_fixup);
|
2006-10-19 18:47:18 -07:00
|
|
|
#endif /* CONFIG_PPC64 */
|
|
|
|
|
2015-05-11 03:01:02 -07:00
|
|
|
#ifdef CONFIG_VDSO32
|
2020-09-27 02:16:34 -07:00
|
|
|
VDSO_DO_FIXUPS(feature, cur_cpu_spec->cpu_features, 32, ftr_fixup);
|
|
|
|
VDSO_DO_FIXUPS(feature, cur_cpu_spec->mmu_features, 32, mmu_ftr_fixup);
|
2006-10-19 18:47:18 -07:00
|
|
|
#ifdef CONFIG_PPC64
|
2020-09-27 02:16:34 -07:00
|
|
|
VDSO_DO_FIXUPS(feature, powerpc_firmware_features, 32, fw_ftr_fixup);
|
2006-10-19 18:47:18 -07:00
|
|
|
#endif /* CONFIG_PPC64 */
|
2020-09-27 02:16:34 -07:00
|
|
|
VDSO_DO_FIXUPS(lwsync, cur_cpu_spec->cpu_features, 32, lwsync_fixup);
|
2015-05-11 03:01:02 -07:00
|
|
|
#endif
|
2005-11-11 03:15:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Called from setup_arch to initialize the bitmap of available
|
|
|
|
* syscalls in the systemcfg page
|
|
|
|
*/
|
|
|
|
static void __init vdso_setup_syscall_map(void)
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
2015-11-18 23:04:53 -07:00
|
|
|
for (i = 0; i < NR_syscalls; i++) {
|
2022-09-20 23:55:58 -07:00
|
|
|
if (sys_call_table[i] != (void *)&sys_ni_syscall)
|
2020-09-27 02:16:20 -07:00
|
|
|
vdso_data->syscall_map[i >> 5] |= 0x80000000UL >> (i & 0x1f);
|
2020-03-20 03:20:16 -07:00
|
|
|
if (IS_ENABLED(CONFIG_COMPAT) &&
|
2022-09-20 23:55:58 -07:00
|
|
|
compat_sys_call_table[i] != (void *)&sys_ni_syscall)
|
2020-09-27 02:16:20 -07:00
|
|
|
vdso_data->compat_syscall_map[i >> 5] |= 0x80000000UL >> (i & 0x1f);
|
2005-11-11 03:15:21 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-04 13:37:11 -07:00
|
|
|
#ifdef CONFIG_PPC64
|
2013-06-24 12:30:09 -07:00
|
|
|
int vdso_getcpu_init(void)
|
2012-07-04 13:37:11 -07:00
|
|
|
{
|
|
|
|
unsigned long cpu, node, val;
|
|
|
|
|
|
|
|
/*
|
2014-03-10 15:29:38 -07:00
|
|
|
* SPRG_VDSO contains the CPU in the bottom 16 bits and the NUMA node
|
|
|
|
* in the next 16 bits. The VDSO uses this to implement getcpu().
|
2012-07-04 13:37:11 -07:00
|
|
|
*/
|
|
|
|
cpu = get_cpu();
|
|
|
|
WARN_ON_ONCE(cpu > 0xffff);
|
|
|
|
|
|
|
|
node = cpu_to_node(cpu);
|
|
|
|
WARN_ON_ONCE(node > 0xffff);
|
|
|
|
|
2020-07-15 16:37:04 -07:00
|
|
|
val = (cpu & 0xffff) | ((node & 0xffff) << 16);
|
2014-03-10 15:29:38 -07:00
|
|
|
mtspr(SPRN_SPRG_VDSO_WRITE, val);
|
|
|
|
get_paca()->sprg_vdso = val;
|
2012-07-04 13:37:11 -07:00
|
|
|
|
|
|
|
put_cpu();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/* We need to call this before SMP init */
|
|
|
|
early_initcall(vdso_getcpu_init);
|
|
|
|
#endif
|
2005-11-11 03:15:21 -07:00
|
|
|
|
2020-09-27 02:16:23 -07:00
|
|
|
static struct page ** __init vdso_setup_pages(void *start, void *end)
|
2005-11-11 03:15:21 -07:00
|
|
|
{
|
|
|
|
int i;
|
2020-09-27 02:16:23 -07:00
|
|
|
struct page **pagelist;
|
|
|
|
int pages = (end - start) >> PAGE_SHIFT;
|
|
|
|
|
|
|
|
pagelist = kcalloc(pages + 1, sizeof(struct page *), GFP_KERNEL);
|
|
|
|
if (!pagelist)
|
|
|
|
panic("%s: Cannot allocate page list for VDSO", __func__);
|
|
|
|
|
2020-09-27 02:16:30 -07:00
|
|
|
for (i = 0; i < pages; i++)
|
2021-03-31 09:48:46 -07:00
|
|
|
pagelist[i] = virt_to_page(start + i * PAGE_SIZE);
|
|
|
|
|
|
|
|
return pagelist;
|
|
|
|
}
|
|
|
|
|
2020-09-27 02:16:23 -07:00
|
|
|
static int __init vdso_init(void)
|
|
|
|
{
|
2005-11-11 03:15:21 -07:00
|
|
|
#ifdef CONFIG_PPC64
|
|
|
|
/*
|
2009-09-28 18:43:57 -07:00
|
|
|
* Fill up the "systemcfg" stuff for backward compatibility
|
2005-11-11 03:15:21 -07:00
|
|
|
*/
|
2007-05-16 08:12:16 -07:00
|
|
|
strcpy((char *)vdso_data->eye_catcher, "SYSTEMCFG:PPC64");
|
2005-11-11 03:15:21 -07:00
|
|
|
vdso_data->version.major = SYSTEMCFG_MAJOR;
|
|
|
|
vdso_data->version.minor = SYSTEMCFG_MINOR;
|
|
|
|
vdso_data->processor = mfspr(SPRN_PVR);
|
2006-03-28 05:15:54 -07:00
|
|
|
/*
|
2012-03-21 11:23:27 -07:00
|
|
|
* Fake the old platform number for pSeries and add
|
2006-03-28 05:15:54 -07:00
|
|
|
* in LPAR bit if necessary
|
|
|
|
*/
|
2012-03-21 11:23:27 -07:00
|
|
|
vdso_data->platform = 0x100;
|
2006-03-28 05:15:54 -07:00
|
|
|
if (firmware_has_feature(FW_FEATURE_LPAR))
|
|
|
|
vdso_data->platform |= 1;
|
2010-07-11 21:36:09 -07:00
|
|
|
vdso_data->physicalMemorySize = memblock_phys_mem_size();
|
2017-01-08 16:31:47 -07:00
|
|
|
vdso_data->dcache_size = ppc64_caches.l1d.size;
|
|
|
|
vdso_data->dcache_line_size = ppc64_caches.l1d.line_size;
|
|
|
|
vdso_data->icache_size = ppc64_caches.l1i.size;
|
|
|
|
vdso_data->icache_line_size = ppc64_caches.l1i.line_size;
|
|
|
|
vdso_data->dcache_block_size = ppc64_caches.l1d.block_size;
|
|
|
|
vdso_data->icache_block_size = ppc64_caches.l1i.block_size;
|
|
|
|
vdso_data->dcache_log_block_size = ppc64_caches.l1d.log_block_size;
|
|
|
|
vdso_data->icache_log_block_size = ppc64_caches.l1i.log_block_size;
|
2020-09-27 02:16:24 -07:00
|
|
|
#endif /* CONFIG_PPC64 */
|
2007-11-19 18:24:45 -07:00
|
|
|
|
2005-11-11 03:15:21 -07:00
|
|
|
vdso_setup_syscall_map();
|
2006-10-19 18:47:18 -07:00
|
|
|
|
2020-09-27 02:16:43 -07:00
|
|
|
vdso_fixup_features();
|
2005-11-11 03:15:21 -07:00
|
|
|
|
2020-09-27 02:16:24 -07:00
|
|
|
if (IS_ENABLED(CONFIG_VDSO32))
|
2020-09-27 02:16:27 -07:00
|
|
|
vdso32_spec.pages = vdso_setup_pages(&vdso32_start, &vdso32_end);
|
2007-02-08 15:20:43 -07:00
|
|
|
|
2020-09-27 02:16:24 -07:00
|
|
|
if (IS_ENABLED(CONFIG_PPC64))
|
2020-09-27 02:16:27 -07:00
|
|
|
vdso64_spec.pages = vdso_setup_pages(&vdso64_start, &vdso64_end);
|
2005-11-11 03:15:21 -07:00
|
|
|
|
2007-02-11 19:31:08 -07:00
|
|
|
smp_wmb();
|
|
|
|
|
|
|
|
return 0;
|
2005-11-11 03:15:21 -07:00
|
|
|
}
|
2007-02-11 19:31:08 -07:00
|
|
|
arch_initcall(vdso_init);
|