aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Lutomirski <luto@amacapital.net>2014-05-05 15:19:33 -0400
committerH. Peter Anvin <hpa@linux.intel.com>2014-05-05 16:18:47 -0400
commitcfda7bb9ecbf9d96264bb5bade33a842966d1062 (patch)
tree847dca2ec3bfccc701a9e9dd4cb74a48c9afc3b6
parent3d7ee969bffcc984c8aeaffc6ac6816fd929ace1 (diff)
x86, vdso: Move syscall and sysenter setup into kernel/cpu/common.c
This code is used during CPU setup, and it isn't strictly speaking related to the 32-bit vdso. It's easier to understand how this works when the code is closer to its callers. This also lets syscall32_cpu_init be static, which might save some trivial amount of kernel text. Signed-off-by: Andy Lutomirski <luto@amacapital.net> Link: http://lkml.kernel.org/r/4e466987204e232d7b55a53ff6b9739f12237461.1399317206.git.luto@amacapital.net Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
-rw-r--r--arch/x86/include/asm/proto.h2
-rw-r--r--arch/x86/kernel/cpu/common.c32
-rw-r--r--arch/x86/vdso/vdso32-setup.c30
3 files changed, 32 insertions, 32 deletions
diff --git a/arch/x86/include/asm/proto.h b/arch/x86/include/asm/proto.h
index 6fd3fd769796..a90f8972dad5 100644
--- a/arch/x86/include/asm/proto.h
+++ b/arch/x86/include/asm/proto.h
@@ -12,8 +12,6 @@ void ia32_syscall(void);
12void ia32_cstar_target(void); 12void ia32_cstar_target(void);
13void ia32_sysenter_target(void); 13void ia32_sysenter_target(void);
14 14
15void syscall32_cpu_init(void);
16
17void x86_configure_nx(void); 15void x86_configure_nx(void);
18void x86_report_nx(void); 16void x86_report_nx(void);
19 17
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index a135239badb7..7c65b4666c24 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -953,6 +953,38 @@ static void vgetcpu_set_mode(void)
953 else 953 else
954 vgetcpu_mode = VGETCPU_LSL; 954 vgetcpu_mode = VGETCPU_LSL;
955} 955}
956
957/* May not be __init: called during resume */
958static void syscall32_cpu_init(void)
959{
960 /* Load these always in case some future AMD CPU supports
961 SYSENTER from compat mode too. */
962 wrmsrl_safe(MSR_IA32_SYSENTER_CS, (u64)__KERNEL_CS);
963 wrmsrl_safe(MSR_IA32_SYSENTER_ESP, 0ULL);
964 wrmsrl_safe(MSR_IA32_SYSENTER_EIP, (u64)ia32_sysenter_target);
965
966 wrmsrl(MSR_CSTAR, ia32_cstar_target);
967}
968#endif
969
970#ifdef CONFIG_X86_32
971void enable_sep_cpu(void)
972{
973 int cpu = get_cpu();
974 struct tss_struct *tss = &per_cpu(init_tss, cpu);
975
976 if (!boot_cpu_has(X86_FEATURE_SEP)) {
977 put_cpu();
978 return;
979 }
980
981 tss->x86_tss.ss1 = __KERNEL_CS;
982 tss->x86_tss.sp1 = sizeof(struct tss_struct) + (unsigned long) tss;
983 wrmsr(MSR_IA32_SYSENTER_CS, __KERNEL_CS, 0);
984 wrmsr(MSR_IA32_SYSENTER_ESP, tss->x86_tss.sp1, 0);
985 wrmsr(MSR_IA32_SYSENTER_EIP, (unsigned long) ia32_sysenter_target, 0);
986 put_cpu();
987}
956#endif 988#endif
957 989
958void __init identify_boot_cpu(void) 990void __init identify_boot_cpu(void)
diff --git a/arch/x86/vdso/vdso32-setup.c b/arch/x86/vdso/vdso32-setup.c
index 5a657d93c6e0..9c78d5b24874 100644
--- a/arch/x86/vdso/vdso32-setup.c
+++ b/arch/x86/vdso/vdso32-setup.c
@@ -75,41 +75,11 @@ static unsigned vdso32_size;
75#define vdso32_sysenter() (boot_cpu_has(X86_FEATURE_SYSENTER32)) 75#define vdso32_sysenter() (boot_cpu_has(X86_FEATURE_SYSENTER32))
76#define vdso32_syscall() (boot_cpu_has(X86_FEATURE_SYSCALL32)) 76#define vdso32_syscall() (boot_cpu_has(X86_FEATURE_SYSCALL32))
77 77
78/* May not be __init: called during resume */
79void syscall32_cpu_init(void)
80{
81 /* Load these always in case some future AMD CPU supports
82 SYSENTER from compat mode too. */
83 wrmsrl_safe(MSR_IA32_SYSENTER_CS, (u64)__KERNEL_CS);
84 wrmsrl_safe(MSR_IA32_SYSENTER_ESP, 0ULL);
85 wrmsrl_safe(MSR_IA32_SYSENTER_EIP, (u64)ia32_sysenter_target);
86
87 wrmsrl(MSR_CSTAR, ia32_cstar_target);
88}
89
90#else /* CONFIG_X86_32 */ 78#else /* CONFIG_X86_32 */
91 79
92#define vdso32_sysenter() (boot_cpu_has(X86_FEATURE_SEP)) 80#define vdso32_sysenter() (boot_cpu_has(X86_FEATURE_SEP))
93#define vdso32_syscall() (0) 81#define vdso32_syscall() (0)
94 82
95void enable_sep_cpu(void)
96{
97 int cpu = get_cpu();
98 struct tss_struct *tss = &per_cpu(init_tss, cpu);
99
100 if (!boot_cpu_has(X86_FEATURE_SEP)) {
101 put_cpu();
102 return;
103 }
104
105 tss->x86_tss.ss1 = __KERNEL_CS;
106 tss->x86_tss.sp1 = sizeof(struct tss_struct) + (unsigned long) tss;
107 wrmsr(MSR_IA32_SYSENTER_CS, __KERNEL_CS, 0);
108 wrmsr(MSR_IA32_SYSENTER_ESP, tss->x86_tss.sp1, 0);
109 wrmsr(MSR_IA32_SYSENTER_EIP, (unsigned long) ia32_sysenter_target, 0);
110 put_cpu();
111}
112
113#endif /* CONFIG_X86_64 */ 83#endif /* CONFIG_X86_64 */
114 84
115int __init sysenter_setup(void) 85int __init sysenter_setup(void)