Received: by 10.223.176.5 with SMTP id f5csp453246wra; Fri, 9 Feb 2018 01:41:33 -0800 (PST) X-Google-Smtp-Source: AH8x227nDOUsT278ZGmNUejNxlgdKvAGMgITW6+nd3FMMNkLKDsQtCxbZnoNRxXsMNu6iRearBMd X-Received: by 10.99.111.71 with SMTP id k68mr1829505pgc.360.1518169293774; Fri, 09 Feb 2018 01:41:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518169293; cv=none; d=google.com; s=arc-20160816; b=Ew2nY4HQ/ty/qIxtzJksdOm8JG4NGl4rrW3Df18ZNM9TIiu9/XCkx0yGcysoYuDc38 KQ12cuDzkGcHfIFUd8NdBPW6VVddRCWpXzz87QnjtxhI4ucDbkLV6u59Zb0l0YkzVX/a R0SwjtPP4vspZCz0nISaXLnNxkDhF//MIjMCk3kg//eH1h/lQA7gxoKzfZuVEVY/e12q Ysj2JDm+y1OkAPkau2uX6Fx/DZRhk4MTxzuFXcCTRjPxgqpgBOWWdp7J/M+ZmcjwdGbw 5xei60V49Yj5u6ugUt/hEQInV4uvKB/Vbk7z7IG33sLlweJ5kXljJhjha82oS7DJ0evP 0kgQ== 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:cc:to:from:dkim-signature:arc-authentication-results; bh=NTVb4LONHnLz6w99SoQtjWWuv+4gRfgau5jr8PemZlw=; b=TtROE5c7SuQxKFCLohb3Bdks3J8ScE0Wx9+nQNU7NOWRXa7mCssz2lL7+dfnWmuYWP N97Tywvst0mr8ESVEFgEErAMMAG0eVhfglJZ1cONlHZr2MHecjNzyrmeSC3//9cMMeVW fWG4wRoMMEw5PrQe9/nwovu64bhSsiOteUGma+o1NkF6LFJYzOKpS3XPk+2R5/YtFoby gHN+y2IUPbY5SUVraWmBhyeCVJJKo/gZqlKK2GiLnkcYNbtf8iAOJTXlJM+nltG3MUtQ MgCYqka+R0ocaq8TlZSsJGoJirIKMWvAUuFBSV5ugMtWhGPOPHtlXJi85HpdTfHngIJx +QrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@8bytes.org header.s=mail-1 header.b=Js8FkR9l; 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=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c8si1444146pfi.93.2018.02.09.01.41.16; Fri, 09 Feb 2018 01:41:33 -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=fail (test mode) header.i=@8bytes.org header.s=mail-1 header.b=Js8FkR9l; 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=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750895AbeBIJjH (ORCPT + 99 others); Fri, 9 Feb 2018 04:39:07 -0500 Received: from 8bytes.org ([81.169.241.247]:42996 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751941AbeBIJZ4 (ORCPT ); Fri, 9 Feb 2018 04:25:56 -0500 Received: by theia.8bytes.org (Postfix, from userid 1000) id 39B2A377; Fri, 9 Feb 2018 10:25:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=8bytes.org; s=mail-1; t=1518168351; bh=5ScQcrMXloE9ZLzy5ALCtcyHsu0J9Np6uKApz5m/BbY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Js8FkR9logD+8FEThYUPHkokGXgBGazLjfwk8n7a3Elm7cBPpKJ/mdELAVaauTOOn IVBJh2HZuU0k9W5UKQyRBQCH0Kh2Z2Woa8Z4wD+ElUnPWlqh9mmLc9DLknYOFazduL jYNZyy7QuPSFgOTX2mPwSBmzoEb5CDKAZ4f1myKrdUhv23NpqUIFP96LauvuX9ns0n XoUh+1U0xZiTB5wjiWb2NzuMJDcQ1xxVH4TphhyFMga6eUr3IU0fg+pxGKFnjkvz7J 2tGGn/nJCLf18WDswFKwvKAmd2VFkH95mzuwaqV02eQgxUYvQYDk3VgBY+jw5U10GB 5Ms5LgRkvnTZw== From: Joerg Roedel To: Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" Cc: x86@kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Linus Torvalds , Andy Lutomirski , Dave Hansen , Josh Poimboeuf , Juergen Gross , Peter Zijlstra , Borislav Petkov , Jiri Kosina , Boris Ostrovsky , Brian Gerst , David Laight , Denys Vlasenko , Eduardo Valentin , Greg KH , Will Deacon , aliguori@amazon.com, daniel.gruss@iaik.tugraz.at, hughd@google.com, keescook@google.com, Andrea Arcangeli , Waiman Long , Pavel Machek , jroedel@suse.de, joro@8bytes.org Subject: [PATCH 03/31] x86/entry/32: Load task stack from x86_tss.sp1 in SYSENTER handler Date: Fri, 9 Feb 2018 10:25:12 +0100 Message-Id: <1518168340-9392-4-git-send-email-joro@8bytes.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518168340-9392-1-git-send-email-joro@8bytes.org> References: <1518168340-9392-1-git-send-email-joro@8bytes.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Joerg Roedel We want x86_tss.sp0 point to the entry stack later to use it as a trampoline stack for other kernel entry points besides SYSENTER. So store the task stack pointer in x86_tss.sp1, which is otherwise unused by the hardware, as Linux doesn't make use of Ring 1. Signed-off-by: Joerg Roedel --- arch/x86/kernel/asm-offsets_32.c | 2 +- arch/x86/kernel/process_32.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/asm-offsets_32.c b/arch/x86/kernel/asm-offsets_32.c index f452bfd..b97e48c 100644 --- a/arch/x86/kernel/asm-offsets_32.c +++ b/arch/x86/kernel/asm-offsets_32.c @@ -47,7 +47,7 @@ void foo(void) BLANK(); /* Offset from the sysenter stack to tss.sp0 */ - DEFINE(TSS_entry_stack, offsetof(struct cpu_entry_area, tss.x86_tss.sp0) - + DEFINE(TSS_entry_stack, offsetof(struct cpu_entry_area, tss.x86_tss.sp1) - offsetofend(struct cpu_entry_area, entry_stack_page.stack)); #ifdef CONFIG_CC_STACKPROTECTOR diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c index 5224c60..097d36a 100644 --- a/arch/x86/kernel/process_32.c +++ b/arch/x86/kernel/process_32.c @@ -292,6 +292,8 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p) this_cpu_write(cpu_current_top_of_stack, (unsigned long)task_stack_page(next_p) + THREAD_SIZE); + /* SYSENTER reads the task-stack from tss.sp1 */ + this_cpu_write(cpu_tss_rw.x86_tss.sp1, next_p->thread.sp0); /* * Restore %gs if needed (which is common) -- 2.7.4