Re: [PATCH] x86/asm/entry/64: Fix MSR_IA32_SYSENTER_CS MSR value

Borislav Petkov
2015-04-03T11:22:33Z

On Fri, Apr 03, 2015 at 11:42:10AM +0200, Borislav Petkov wrote:
> From: Borislav Petkov <bp@suse.de>
>
> Commit
>
> d56fe4bf5f3c ("x86/asm/entry/64: Always set up SYSENTER MSRs")
>
> missed to add "ULL" to the 0 and wrmsrl_safe() complains:
>
> arch/x86/kernel/cpu/common.c: In function ‘syscall_init’:
> arch/x86/kernel/cpu/common.c:1226:2: warning: right shift count >= width of type
> wrmsrl_safe(MSR_IA32_SYSENTER_CS, 0);
>
> Fix it.
>
> Signed-off-by: Borislav Petkov <bp@suse.de>
> Cc: Denys Vlasenko <dvlasenk@redhat.com>
> Cc: Andy Lutomirski <luto@amacapital.net>
> Cc: Alexei Starovoitov <ast@plumgrid.com>
> 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>
> Cc: Ingo Molnar <mingo@kernel.org>
> ---
> arch/x86/kernel/cpu/common.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
> index bb6633a87a19..2c249b57e4b5 100644
> --- a/arch/x86/kernel/cpu/common.c
> +++ b/arch/x86/kernel/cpu/common.c
> @@ -1223,7 +1223,7 @@ void syscall_init(void)
> wrmsrl_safe(MSR_IA32_SYSENTER_EIP, (u64)ia32_sysenter_target);
> #else
> wrmsrl(MSR_CSTAR, ignore_sysret);
> - wrmsrl_safe(MSR_IA32_SYSENTER_CS, 0);
> + wrmsrl_safe(MSR_IA32_SYSENTER_CS, 0ULL);

Btw, we probably should define an invalid segment

#define GDT_ENTRY_INVALID_SEGMENT 0ULL

and use that value instead of the naked 0.

--
Regards/Gruss,
Boris.

ECO tip #101: Trim your mails when you reply.
--