Received: by 10.223.185.116 with SMTP id b49csp3212095wrg; Mon, 5 Mar 2018 16:39:45 -0800 (PST) X-Google-Smtp-Source: AG47ELub8/Q1gon4Y7JWMZECh8Dhh5nzWIuulr9B5025L866K1p/SZyJHztela4LQRlWJaPzJTIC X-Received: by 2002:a17:902:7082:: with SMTP id z2-v6mr11522717plk.130.1520296785172; Mon, 05 Mar 2018 16:39:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520296785; cv=none; d=google.com; s=arc-20160816; b=z2cUHxtnfLc/eZ0Tnt0vHXk+8AHT1/bw0yyrhq6OpQNgsGdA0ssNiKSkK30PBzs16o I7wn0+U+JYRNcBZWWPE/sEo7jnZLynu/DX14oly5ijFhwdRDeeIJIj/kME16diTbtGlc NyM9j1VLbSQAhSqXIdItix13pSuJZndVhpkwocPpKrO75karXcOazpmidLXJHuAe9vtt zvmbAadFW3a3CPcCy9CwQFlgPsV/FuwbCY/Pzmr91tNqwm1g5endJ1Yitgw5Tgu2eGBr q+LMcGKb7U2lSL9EYp8bWp1uQT+NARUNS1n5D1h/C4dYcdCEZ6hzykQzIT+dLyIRx5kV Pjpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:to:from:dkim-signature:arc-authentication-results; bh=FgiTRexofsgHhhW+f6GjVCgwwlAS0PXe5RJCA3neXRs=; b=WcTJdWLqiU1a9R450vmhJgRJUp4agZS+1/akvgrOtocjWhuEbXul11WvpJTz6a9+aq lWbiRYCS1jdYPnHKHwaIJ7fPfVZ9pZDmWt3DpWnlnSNhTd9zVmDVHZjoqATwzg2vNWXR VnSxJQVWeEe0W4G03CanpvF4tjGzaFfEi2s45p/5Ejg5zCcPMhd1SoPo4hfh/dOVVHIB h9vROGFyYXTfvf1nJsNTHn8HFd4McUlkaeFYkRmXOdgCP5kgZlXdpXkMaYR+oI0n2NAl eJXMbCb90ri/ZKZlvNNpl17L/5ZdCAVm5DbmKThtwUKAK20pnLSyhU8hdVSuVMSmiJ5Q eXhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=P2Q15uu9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f1-v6si10168453plb.73.2018.03.05.16.39.30; Mon, 05 Mar 2018 16:39:45 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=P2Q15uu9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933445AbeCFAh4 (ORCPT + 99 others); Mon, 5 Mar 2018 19:37:56 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:40604 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933123AbeCFA0X (ORCPT ); Mon, 5 Mar 2018 19:26:23 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w260Ln6J187407; Tue, 6 Mar 2018 00:26:19 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2017-10-26; bh=FgiTRexofsgHhhW+f6GjVCgwwlAS0PXe5RJCA3neXRs=; b=P2Q15uu9z/MInfco7mXh/CXLW3NWHKqQvlp+L6r5CiDUtAb6BXZ2qtlT0CMCLwmm7An+ Z/tGDNu64EHbJo7je3f3tCOCNcE7nervAmx5VE05HqzmYdiesRB5PFO+282jnTQBDo6U wPSKtrQpPk/qtgdpK9EtOmVSuGSwSKJCZXEqpfhUSspQZZVTd6Hk23cmmFIHgC8SkGxF A77LKvfjOo+SnYXVhUK4E95x8kWklapGqpuGNFzn61iUm4RD30RQPVtKR9EuhxJU51dH fAwQ6bUkRUYd+Vy+dJi+J84WEH2/TPD18hZguPJey3YR8eIyOLaakfVtVJNlpIZsywxd 7A== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2130.oracle.com with ESMTP id 2ghdxf8jqu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Mar 2018 00:26:19 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w260QJqk025265 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 6 Mar 2018 00:26:19 GMT Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w260QIDu022070; Tue, 6 Mar 2018 00:26:18 GMT Received: from localhost.localdomain (/98.216.35.41) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 05 Mar 2018 16:26:18 -0800 From: Pavel Tatashin To: steven.sistare@oracle.com, daniel.m.jordan@oracle.com, linux-kernel@vger.kernel.org, Alexander.Levin@microsoft.com, dan.j.williams@intel.com, sathyanarayanan.kuppuswamy@intel.com, pankaj.laxminarayan.bharadiya@intel.com, akuster@mvista.com, cminyard@mvista.com, pasha.tatashin@oracle.com, gregkh@linuxfoundation.org, stable@vger.kernel.org Subject: [PATCH 4.1 23/65] x86/entry: Stop using PER_CPU_VAR(kernel_stack) Date: Mon, 5 Mar 2018 19:24:56 -0500 Message-Id: <20180306002538.1761-24-pasha.tatashin@oracle.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180306002538.1761-1-pasha.tatashin@oracle.com> References: <20180306002538.1761-1-pasha.tatashin@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8823 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1803060003 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Denys Vlasenko PER_CPU_VAR(kernel_stack) is redundant: - On the 64-bit build, we can use PER_CPU_VAR(cpu_tss + TSS_sp0). - On the 32-bit build, we can use PER_CPU_VAR(cpu_current_top_of_stack). PER_CPU_VAR(kernel_stack) will be deleted by a separate change. Signed-off-by: Denys Vlasenko Cc: Alexei Starovoitov Cc: Andrew Morton Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Frederic Weisbecker Cc: H. Peter Anvin Cc: Kees Cook Cc: Linus Torvalds Cc: Oleg Nesterov Cc: Peter Zijlstra Cc: Steven Rostedt Cc: Thomas Gleixner Cc: Will Drewry Link: http://lkml.kernel.org/r/1429889495-27850-1-git-send-email-dvlasenk@redhat.com Signed-off-by: Ingo Molnar (cherry picked from commit 63332a8455d8310b77d38779c6c21a660a8d9feb) Signed-off-by: Pavel Tatashin --- arch/x86/ia32/ia32entry.S | 2 +- arch/x86/include/asm/thread_info.h | 8 +++++++- arch/x86/kernel/entry_64.S | 4 ++-- arch/x86/xen/xen-asm_64.S | 5 +++-- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S index 27e54946ef35..2ae22c951fa0 100644 --- a/arch/x86/ia32/ia32entry.S +++ b/arch/x86/ia32/ia32entry.S @@ -356,7 +356,7 @@ ENTRY(ia32_cstar_target) SWAPGS_UNSAFE_STACK movl %esp,%r8d CFI_REGISTER rsp,r8 - movq PER_CPU_VAR(kernel_stack),%rsp + movq PER_CPU_VAR(cpu_tss + TSS_sp0),%rsp ENABLE_INTERRUPTS(CLBR_NONE) /* Zero-extending 32-bit regs, do not remove */ diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h index b4bdec3e9523..d656a363e1eb 100644 --- a/arch/x86/include/asm/thread_info.h +++ b/arch/x86/include/asm/thread_info.h @@ -198,9 +198,15 @@ static inline unsigned long current_stack_pointer(void) #else /* !__ASSEMBLY__ */ /* Load thread_info address into "reg" */ +#ifdef CONFIG_X86_32 #define GET_THREAD_INFO(reg) \ - _ASM_MOV PER_CPU_VAR(kernel_stack),reg ; \ + _ASM_MOV PER_CPU_VAR(cpu_current_top_of_stack),reg ; \ _ASM_SUB $(THREAD_SIZE),reg ; +#else +#define GET_THREAD_INFO(reg) \ + _ASM_MOV PER_CPU_VAR(cpu_tss + TSS_sp0),reg ; \ + _ASM_SUB $(THREAD_SIZE),reg ; +#endif /* * ASM operand which evaluates to a 'thread_info' address of diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S index 6c9cb6073832..99f67a38f7f0 100644 --- a/arch/x86/kernel/entry_64.S +++ b/arch/x86/kernel/entry_64.S @@ -216,7 +216,7 @@ ENTRY(system_call) GLOBAL(system_call_after_swapgs) movq %rsp,PER_CPU_VAR(rsp_scratch) - movq PER_CPU_VAR(kernel_stack),%rsp + movq PER_CPU_VAR(cpu_tss + TSS_sp0),%rsp /* Construct struct pt_regs on stack */ pushq_cfi $__USER_DS /* pt_regs->ss */ @@ -1464,7 +1464,7 @@ ENTRY(nmi) SWAPGS_UNSAFE_STACK cld movq %rsp, %rdx - movq PER_CPU_VAR(kernel_stack), %rsp + movq PER_CPU_VAR(cpu_tss + TSS_sp0), %rsp pushq 5*8(%rdx) /* pt_regs->ss */ pushq 4*8(%rdx) /* pt_regs->rsp */ pushq 3*8(%rdx) /* pt_regs->flags */ diff --git a/arch/x86/xen/xen-asm_64.S b/arch/x86/xen/xen-asm_64.S index 985fc3ee0973..acc49e088ec5 100644 --- a/arch/x86/xen/xen-asm_64.S +++ b/arch/x86/xen/xen-asm_64.S @@ -15,6 +15,7 @@ #include #include #include +#include #include @@ -69,7 +70,7 @@ ENTRY(xen_sysret64) * still with the kernel gs, so we can easily switch back */ movq %rsp, PER_CPU_VAR(rsp_scratch) - movq PER_CPU_VAR(kernel_stack), %rsp + movq PER_CPU_VAR(cpu_tss + TSS_sp0), %rsp pushq $__USER_DS pushq PER_CPU_VAR(rsp_scratch) @@ -88,7 +89,7 @@ ENTRY(xen_sysret32) * still with the kernel gs, so we can easily switch back */ movq %rsp, PER_CPU_VAR(rsp_scratch) - movq PER_CPU_VAR(kernel_stack), %rsp + movq PER_CPU_VAR(cpu_tss + TSS_sp0), %rsp pushq $__USER32_DS pushq PER_CPU_VAR(rsp_scratch) -- 2.16.2