vdso32-setup.c 2.7 KB
Newer Older
L
Linus Torvalds 已提交
1 2
/*
 * (C) Copyright 2002 Linus Torvalds
3 4
 * Portions based on the vdso-randomization code from exec-shield:
 * Copyright(C) 2005-2006, Red Hat, Inc., Ingo Molnar
L
Linus Torvalds 已提交
5 6 7 8 9 10
 *
 * This file contains the needed initializations to support sysenter.
 */

#include <linux/init.h>
#include <linux/smp.h>
11 12
#include <linux/kernel.h>
#include <linux/mm_types.h>
L
Linus Torvalds 已提交
13 14

#include <asm/cpufeature.h>
15
#include <asm/processor.h>
R
Roland McGrath 已提交
16
#include <asm/vdso.h>
17 18

#ifdef CONFIG_COMPAT_VDSO
19
#define VDSO_DEFAULT	0
20
#else
21
#define VDSO_DEFAULT	1
22
#endif
L
Linus Torvalds 已提交
23

24 25 26 27
/*
 * Should the kernel map a VDSO page into processes and pass its
 * address down to glibc upon exec()?
 */
28
unsigned int __read_mostly vdso32_enabled = VDSO_DEFAULT;
29

30
static int __init vdso32_setup(char *s)
31
{
32
	vdso32_enabled = simple_strtoul(s, NULL, 0);
33

34
	if (vdso32_enabled > 1)
35 36
		pr_warn("vdso32 values other than 0 and 1 are no longer allowed; vdso disabled\n");

37 38 39
	return 1;
}

R
Roland McGrath 已提交
40 41 42 43 44
/*
 * For consistency, the argument vdso32=[012] affects the 32-bit vDSO
 * behavior on both 64-bit and 32-bit kernels.
 * On 32-bit kernels, vdso=[012] means the same thing.
 */
45
__setup("vdso32=", vdso32_setup);
46

R
Roland McGrath 已提交
47
#ifdef CONFIG_X86_32
48
__setup_param("vdso=", vdso_setup, vdso32_setup, 0);
R
Roland McGrath 已提交
49
#endif
L
Linus Torvalds 已提交
50

R
Roland McGrath 已提交
51 52
#ifdef CONFIG_X86_64

53
#define	vdso32_sysenter()	(boot_cpu_has(X86_FEATURE_SYSENTER32))
54
#define	vdso32_syscall()	(boot_cpu_has(X86_FEATURE_SYSCALL32))
R
Roland McGrath 已提交
55 56 57 58

#else  /* CONFIG_X86_32 */

#define vdso32_sysenter()	(boot_cpu_has(X86_FEATURE_SEP))
59
#define vdso32_syscall()	(0)
R
Roland McGrath 已提交
60 61 62

#endif	/* CONFIG_X86_64 */

63 64 65 66
#if defined(CONFIG_X86_32) || defined(CONFIG_COMPAT)
const struct vdso_image *selected_vdso32;
#endif

67
int __init sysenter_setup(void)
L
Linus Torvalds 已提交
68
{
69
#ifdef CONFIG_COMPAT
70 71 72
	if (vdso32_syscall())
		selected_vdso32 = &vdso_image_32_syscall;
	else
73
#endif
74 75 76 77
	if (vdso32_sysenter())
		selected_vdso32 = &vdso_image_32_sysenter;
	else
		selected_vdso32 = &vdso_image_32_int80;
78

79
	init_vdso_image(selected_vdso32);
L
Linus Torvalds 已提交
80 81 82

	return 0;
}
83

R
Roland McGrath 已提交
84 85
#ifdef CONFIG_X86_64

86
subsys_initcall(sysenter_setup);
R
Roland McGrath 已提交
87

R
Roland McGrath 已提交
88 89 90 91
#ifdef CONFIG_SYSCTL
/* Register vsyscall32 into the ABI table */
#include <linux/sysctl.h>

92
static struct ctl_table abi_table2[] = {
R
Roland McGrath 已提交
93 94
	{
		.procname	= "vsyscall32",
95
		.data		= &vdso32_enabled,
R
Roland McGrath 已提交
96 97 98 99 100 101 102
		.maxlen		= sizeof(int),
		.mode		= 0644,
		.proc_handler	= proc_dointvec
	},
	{}
};

103
static struct ctl_table abi_root_table2[] = {
R
Roland McGrath 已提交
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
	{
		.procname = "abi",
		.mode = 0555,
		.child = abi_table2
	},
	{}
};

static __init int ia32_binfmt_init(void)
{
	register_sysctl_table(abi_root_table2);
	return 0;
}
__initcall(ia32_binfmt_init);
#endif

R
Roland McGrath 已提交
120 121
#else  /* CONFIG_X86_32 */

122
struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
123 124 125 126
{
	return NULL;
}

127
int in_gate_area(struct mm_struct *mm, unsigned long addr)
128
{
129
	return 0;
130 131
}

132
int in_gate_area_no_mm(unsigned long addr)
133 134 135
{
	return 0;
}
R
Roland McGrath 已提交
136 137

#endif	/* CONFIG_X86_64 */