Skip to content

Commit 530dce2

Browse files
xinli-intelbp3tk0v
authored andcommitted
x86/syscall: Split IDT syscall setup code into idt_syscall_init()
Because FRED uses the ring 3 FRED entrypoint for SYSCALL and SYSENTER and ERETU is the only legit instruction to return to ring 3, there is NO need to setup SYSCALL and SYSENTER MSRs for FRED, except the IA32_STAR MSR. Split IDT syscall setup code into idt_syscall_init() to make it easy to skip syscall setup code when FRED is enabled. Suggested-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Xin Li <xin3.li@intel.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Tested-by: Shan Kang <shan.kang@intel.com> Link: https://lore.kernel.org/r/20231205105030.8698-34-xin3.li@intel.com
1 parent 70d0fe5 commit 530dce2

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

arch/x86/kernel/cpu/common.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2066,10 +2066,8 @@ static void wrmsrl_cstar(unsigned long val)
20662066
wrmsrl(MSR_CSTAR, val);
20672067
}
20682068

2069-
/* May not be marked __init: used by software suspend */
2070-
void syscall_init(void)
2069+
static inline void idt_syscall_init(void)
20712070
{
2072-
wrmsr(MSR_STAR, 0, (__USER32_CS << 16) | __KERNEL_CS);
20732071
wrmsrl(MSR_LSTAR, (unsigned long)entry_SYSCALL_64);
20742072

20752073
if (ia32_enabled()) {
@@ -2103,6 +2101,15 @@ void syscall_init(void)
21032101
X86_EFLAGS_AC|X86_EFLAGS_ID);
21042102
}
21052103

2104+
/* May not be marked __init: used by software suspend */
2105+
void syscall_init(void)
2106+
{
2107+
/* The default user and kernel segments */
2108+
wrmsr(MSR_STAR, 0, (__USER32_CS << 16) | __KERNEL_CS);
2109+
2110+
idt_syscall_init();
2111+
}
2112+
21062113
#else /* CONFIG_X86_64 */
21072114

21082115
#ifdef CONFIG_STACKPROTECTOR

0 commit comments

Comments
 (0)