From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751215AbdKUHin (ORCPT ); Tue, 21 Nov 2017 02:38:43 -0500 Received: from mail-wr0-f194.google.com ([209.85.128.194]:37324 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751100AbdKUHil (ORCPT ); Tue, 21 Nov 2017 02:38:41 -0500 X-Google-Smtp-Source: AGs4zMalsb85TpIXN9//+IhKaJogD7NDx936Iq8ulT08B/jBjLFNw4FYUqyCDPi0tEUrLgNj9oGhgA== Date: Tue, 21 Nov 2017 08:38:38 +0100 From: Ingo Molnar To: Andy Lutomirski Cc: X86 ML , Borislav Petkov , "linux-kernel@vger.kernel.org" , Brian Gerst , Dave Hansen , Linus Torvalds , Josh Poimboeuf Subject: Re: [PATCH 16/16] x86/entry/64: Move the IST stacks into cpu_entry_area Message-ID: <20171121073838.xdqtkqyajshcls6f@gmail.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Andy Lutomirski wrote: > /* May not be marked __init: used by software suspend */ > void syscall_init(void) > { > @@ -1627,7 +1637,7 @@ void cpu_init(void) > * set up and load the per-CPU TSS > */ > if (!oist->ist[0]) { > - char *estacks = per_cpu(exception_stacks, cpu); > + char *estacks = get_cpu_entry_area(cpu)->exception_stacks; > > for (v = 0; v < N_EXCEPTION_STACKS; v++) { > estacks += exception_stack_sizes[v]; This generates a new build warning: /home/mingo/tip/arch/x86/kernel/cpu/common.c: In function ‘syscall_init’: /home/mingo/tip/arch/x86/kernel/cpu/common.c:1443:6: warning: unused variable ‘cpu’ [-Wunused-variable] int cpu = smp_processor_id(); because 'cpu' is now unused in the !CONFIG_IA32_EMULATION part. The naive fix is something like the patch below, untested. Thanks, Ingo arch/x86/kernel/cpu/common.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index c7f3a0a19dce..557bad9f4179 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -1440,24 +1440,26 @@ void syscall_init(void) extern char _entry_trampoline[]; extern char entry_SYSCALL_64_trampoline[]; - int cpu = smp_processor_id(); - wrmsr(MSR_STAR, 0, (__USER32_CS << 16) | __KERNEL_CS); wrmsrl(MSR_LSTAR, (unsigned long)get_cpu_entry_area(smp_processor_id())->entry_trampoline + (entry_SYSCALL_64_trampoline - _entry_trampoline)); #ifdef CONFIG_IA32_EMULATION - wrmsrl(MSR_CSTAR, (unsigned long)entry_SYSCALL_compat); - /* - * This only works on Intel CPUs. - * On AMD CPUs these MSRs are 32-bit, CPU truncates MSR_IA32_SYSENTER_EIP. - * This does not cause SYSENTER to jump to the wrong location, because - * AMD doesn't allow SYSENTER in long mode (either 32- or 64-bit). - */ - wrmsrl_safe(MSR_IA32_SYSENTER_CS, (u64)__KERNEL_CS); - wrmsrl_safe(MSR_IA32_SYSENTER_ESP, - (unsigned long)&get_cpu_entry_area(cpu)->tss + - offsetofend(struct tss_struct, SYSENTER_stack)); - wrmsrl_safe(MSR_IA32_SYSENTER_EIP, (u64)entry_SYSENTER_compat); + { + int cpu = smp_processor_id(); + + wrmsrl(MSR_CSTAR, (unsigned long)entry_SYSCALL_compat); + /* + * This only works on Intel CPUs. + * On AMD CPUs these MSRs are 32-bit, CPU truncates MSR_IA32_SYSENTER_EIP. + * This does not cause SYSENTER to jump to the wrong location, because + * AMD doesn't allow SYSENTER in long mode (either 32- or 64-bit). + */ + wrmsrl_safe(MSR_IA32_SYSENTER_CS, (u64)__KERNEL_CS); + wrmsrl_safe(MSR_IA32_SYSENTER_ESP, + (unsigned long)&get_cpu_entry_area(cpu)->tss + + offsetofend(struct tss_struct, SYSENTER_stack)); + wrmsrl_safe(MSR_IA32_SYSENTER_EIP, (u64)entry_SYSENTER_compat); + } #else wrmsrl(MSR_CSTAR, (unsigned long)ignore_sysret); wrmsrl_safe(MSR_IA32_SYSENTER_CS, (u64)GDT_ENTRY_INVALID_SEG);