diff options
author | Denys Vlasenko <dvlasenk@redhat.com> | 2015-03-27 06:59:16 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2015-03-27 07:23:16 -0400 |
commit | 487d1edb9a6005cf790c7fe59f25ad1e5cb5817b (patch) | |
tree | 01d6619e1121041d44ccfd51b391a37729fb3f06 /arch/x86/kernel | |
parent | aa6d9a128b861fe7e9dc37bcc37179837674b739 (diff) |
x86/asm/entry/64: Fix comment about SYSENTER MSRs
The comment is ancient, it dates to the time when only AMD's
x86_64 implementation existed. AMD wasn't (and still isn't)
supporting SYSENTER, so these writes were "just in case" back
then.
This has changed: Intel's x86_64 appeared, and Intel does
support SYSENTER in long mode. "Some future 64-bit CPU" is here
already.
The code may appear "buggy" for AMD as it stands, since
MSR_IA32_SYSENTER_EIP is only 32-bit for AMD CPUs. Writing a
kernel function's address to it would drop high bits. Subsequent
use of this MSR for branch via SYSENTER seem to allow user to
transition to CPL0 while executing his code. Scary, eh?
Explain why that is not a bug: because SYSENTER insn would not
work on AMD CPU.
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Cc: Alexei Starovoitov <ast@plumgrid.com>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Will Drewry <wad@chromium.org>
Link: http://lkml.kernel.org/r/1427453956-21931-1-git-send-email-dvlasenk@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'arch/x86/kernel')
-rw-r--r-- | arch/x86/kernel/cpu/common.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index c928a7ae1099..71e4adcb15f1 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c | |||
@@ -1173,8 +1173,10 @@ void syscall_init(void) | |||
1173 | #ifdef CONFIG_IA32_EMULATION | 1173 | #ifdef CONFIG_IA32_EMULATION |
1174 | wrmsrl(MSR_CSTAR, ia32_cstar_target); | 1174 | wrmsrl(MSR_CSTAR, ia32_cstar_target); |
1175 | /* | 1175 | /* |
1176 | * Always load these, in case some future 64-bit CPU supports | 1176 | * This only works on Intel CPUs. |
1177 | * SYSENTER from compat mode too: | 1177 | * On AMD CPUs these MSRs are 32-bit, CPU truncates MSR_IA32_SYSENTER_EIP. |
1178 | * This does not cause SYSENTER to jump to the wrong location, because | ||
1179 | * AMD doesn't allow SYSENTER in long mode (either 32- or 64-bit). | ||
1178 | */ | 1180 | */ |
1179 | wrmsrl_safe(MSR_IA32_SYSENTER_CS, (u64)__KERNEL_CS); | 1181 | wrmsrl_safe(MSR_IA32_SYSENTER_CS, (u64)__KERNEL_CS); |
1180 | wrmsrl_safe(MSR_IA32_SYSENTER_ESP, 0ULL); | 1182 | wrmsrl_safe(MSR_IA32_SYSENTER_ESP, 0ULL); |