x86/asm/entry/64: Fix MSR_IA32_SYSENTER_CS MSR value
Borislav Petkov
maintainerPATCH 1/1 x86/asm/entry/64: Fix MSR_IA32_SYSENTER_CS MSR value
From: Borislav Petkov <[email protected]>
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.
--- arch/x86/kernel/cpu/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/cpu/common.c +1 -1
@@ -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 );wrmsrl_safe (MSR_IA32_SYSENTER_ESP ,0ULL );wrmsrl_safe (MSR_IA32_SYSENTER_EIP ,0ULL );#endif
Signature · 1 line
2.3.3
Borislav Petkov
maintainerQuoted 35 lines · Borislav Petkov
From: Borislav Petkov <[email protected]>
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 typewrmsrl_safe(MSR_IA32_SYSENTER_CS, 0);Fix it.
Signed-off-by Borislav Petkov <[email protected]>Cc Denys Vlasenko <[email protected]>Cc Andy Lutomirski <[email protected]>Cc Alexei Starovoitov <[email protected]>Cc Frederic Weisbecker <[email protected]>Cc H. Peter Anvin <[email protected]>Cc Kees Cook <[email protected]>Cc Linus Torvalds <[email protected]>Cc Oleg Nesterov <[email protected]>Cc Steven Rostedt <[email protected]>Cc Will Drewry <[email protected]>Cc Ingo Molnar <[email protected]>--- arch/x86/kernel/cpu/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/x86/kernel/cpu/common.c +0
-0
arch/x86/kernel/cpu/common.c void syscall_init(void) · line 1226
Quoted 5 lines
arch/x86/kernel/cpu/common.c +1
-1@@ -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.
Signature · 5 lines
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.
--Quoted 44 lines · Borislav Petkov
Quoted 35 lines · Borislav Petkov
From: Borislav Petkov <[email protected]>
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 typewrmsrl_safe(MSR_IA32_SYSENTER_CS, 0);Fix it.
Signed-off-by Borislav Petkov <[email protected]>Cc Denys Vlasenko <[email protected]>Cc Andy Lutomirski <[email protected]>Cc Alexei Starovoitov <[email protected]>Cc Frederic Weisbecker <[email protected]>Cc H. Peter Anvin <[email protected]>Cc Kees Cook <[email protected]>Cc Linus Torvalds <[email protected]>Cc Oleg Nesterov <[email protected]>Cc Steven Rostedt <[email protected]>Cc Will Drewry <[email protected]>Cc Ingo Molnar <[email protected]>--- arch/x86/kernel/cpu/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/x86/kernel/cpu/common.c +0
-0arch/x86/kernel/cpu/common.c void syscall_init(void) · line 1226
Quoted 5 lines
arch/x86/kernel/cpu/common.c +1
-1@@ -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
Quoted 3 lines
#define
GDT_ENTRY_INVALID_SEGMENT0ULLand use that value instead of the naked 0.
Why? Segment selectors aren't "long long", they are in fact "short" (16-bit ints).
The "ULL" is used here in wrmsrl not because it's a segment, but because wrmsrl expects a u64 parameter.
We can probably add a cast in its definition...
Borislav Petkov
maintainerQuoted 7 lines · Denys Vlasenko
Why? Segment selectors aren't "long long", they are in fact "short" (16-bit ints).
The "ULL" is used here in wrmsrl not because it's a segment, but because wrmsrl expects a u64 parameter.
We can probably add a cast in its definition...
Yeah, I meant to not use the naked 0. Cast should be fine.
Let me do a patch.
Signature · 5 lines
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.
--Borislav Petkov
maintainerPATCH 1/1 x86/asm/entry/64: Use a define for an invalid segment
Quoted 1 line · Borislav Petkov
Let me do a patch.
---
From: Borislav Petkov <[email protected]>
Date: Fri, 3 Apr 2015 14:22:00 +0200
Subject: [PATCH] x86/asm/entry/64: Use a define for an invalid segment
selector
... instead of a naked number, for better readability.
--- arch/x86/include/asm/segment.h | 2 ++ arch/x86/kernel/cpu/common.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-)
arch/x86/include/asm/segment.h +2 -0
@@ -39,6 +39,8 @@/* ... GDT has it cleared */ #define SEGMENT_GDT 0x0 +#define GDT_ENTRY_INVALID_SEG 0 +#ifdef CONFIG_X86_32 /* * The layout of the per-CPU GDT under Linux:
arch/x86/kernel/cpu/common.c +1 -1
@@ -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 ,0ULL ); +wrmsrl_safe (MSR_IA32_SYSENTER_CS , (u64 )GDT_ENTRY_INVALID_SEG );wrmsrl_safe (MSR_IA32_SYSENTER_ESP ,0ULL );wrmsrl_safe (MSR_IA32_SYSENTER_EIP ,0ULL );#endif
Signature · 8 lines
2.3.3
--
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.
--tip-bot for Borislav Petkov
merge botx86/asm/entry/64: Fix MSR_IA32_SYSENTER_CS MSR value
Commit-ID: 7c74d5b7b7b63fc279ed446ebd78de20d81f2824 Gitweb: http://git.kernel.org/tip/7c74d5b7b7b63fc279ed446ebd78de20d81f2824 Author: Borislav Petkov <[email protected]> AuthorDate: Fri, 3 Apr 2015 11:42:10 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Fri, 3 Apr 2015 15:29:12 +0200
x86/asm/entry/64: Fix MSR_IA32_SYSENTER_CS MSR value
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.
--- arch/x86/kernel/cpu/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/cpu/common.c +1 -1
@@ -1184,7 +1184,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 );wrmsrl_safe (MSR_IA32_SYSENTER_ESP ,0ULL );wrmsrl_safe (MSR_IA32_SYSENTER_EIP ,0ULL );#endif
tip-bot for Borislav Petkov
merge bot[tip:x86/asm] x86/asm/entry/64: Use a define for an invalid segment selector
In reply to Borislav Petkovx86/asm/entry/64: Use a define for an invalid segment selector
Commit-ID: 6b51311c976593fb7311322b1647a912cd456ec4 Gitweb: http://git.kernel.org/tip/6b51311c976593fb7311322b1647a912cd456ec4 Author: Borislav Petkov <[email protected]> AuthorDate: Fri, 3 Apr 2015 14:25:28 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Fri, 3 Apr 2015 15:29:13 +0200
x86/asm/entry/64: Use a define for an invalid segment selector
... instead of a naked number, for better readability.
--- arch/x86/include/asm/segment.h | 2 ++ arch/x86/kernel/cpu/common.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-)
arch/x86/include/asm/segment.h +2 -0
@@ -39,6 +39,8 @@/* ... GDT has it cleared */ #define SEGMENT_GDT 0x0 +#define GDT_ENTRY_INVALID_SEG 0 +#ifdef CONFIG_X86_32 /* * The layout of the per-CPU GDT under Linux:
arch/x86/kernel/cpu/common.c +1 -1
@@ -1184,7 +1184,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 ,0ULL ); +wrmsrl_safe (MSR_IA32_SYSENTER_CS , (u64 )GDT_ENTRY_INVALID_SEG );wrmsrl_safe (MSR_IA32_SYSENTER_ESP ,0ULL );wrmsrl_safe (MSR_IA32_SYSENTER_EIP ,0ULL );#endif