Received: by 10.223.185.116 with SMTP id b49csp2446025wrg; Mon, 5 Mar 2018 03:04:39 -0800 (PST) X-Google-Smtp-Source: AG47ELthylI3glrXIgDL/10STJSNWJA94/K0Uog1r2sPEB1BkiMjlh+3Ze7tBKRQdN1wUW9bPS+g X-Received: by 2002:a17:902:8a8d:: with SMTP id p13-v6mr13000188plo.144.1520247878947; Mon, 05 Mar 2018 03:04:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520247878; cv=none; d=google.com; s=arc-20160816; b=moHONQ0jgglxuLe0AJtgQjFdhySufanmiYgYsLIi/1RaFhgWiddDhqu5QJQJjL8Wpg 0mTvrAQ0ZCdAyck1JFhP8TJ4X3/BKMBBHw+jhs3wLrctMNL+lgHWWGd2+7aqZwwTaZwY gbgTKmattUc2hlJLlhSI1Qsx3rjrExhyoYL3jbUauYDzIMWsnMKaF5OxHQ3TICgqgfDy Oom80ct4Kuy0dmrOcdkh3v+WUbQVNugLIFzMxL4p2zs/l5myAdZAPsdQPtYUObTbKpTF 2iYNSBedkF/eed0fZIpFhtqDHRgly+gtOq2Qg35OZVzgHdfjcT8bgTVG7jrax5+CPQbM yYCA== 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=fgwgMKd/zRPj6KG3ITqDC9fk0juoqk3DrU0KvizF3QKq/WfGIBNfMP4PRL69pqyK+A KVbxye49f+eVbELeI3DKSlh99XDgqfsxILzUwJGgddlFFFU4HrrnsCaTKfJvt45nIU3n aKeJ1kgD2qo9i9lNj3k4r3WimeUpgCfviAsAkThVF+8NIiTR1p8yEifKstL8EF9tLvUz mcoamDebzamiexsdRNTGsU0hpcuYczd++GMvLnYFVJm+qeB0iQSmZ+nx4QiXxS18Shqf 9QoKKAPQiz+K4ykiQy1tPzr48fqf8HhtNSKjJXBpawzScAphfD1o78ZMzPsrcjPTT3xd NUiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@8bytes.org header.s=mail-1 header.b=mWC+RCI+; 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 y19si2165914pfm.63.2018.03.05.03.04.24; Mon, 05 Mar 2018 03:04:38 -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=mWC+RCI+; 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 S933776AbeCEK0R (ORCPT + 99 others); Mon, 5 Mar 2018 05:26:17 -0500 Received: from 8bytes.org ([81.169.241.247]:54288 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933264AbeCEK0L (ORCPT ); Mon, 5 Mar 2018 05:26:11 -0500 Received: by theia.8bytes.org (Postfix, from userid 1000) id C840C84D; Mon, 5 Mar 2018 11:26:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=8bytes.org; s=mail-1; t=1520245565; bh=5ScQcrMXloE9ZLzy5ALCtcyHsu0J9Np6uKApz5m/BbY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mWC+RCI+RcFl7jW6hEYuaWEuy5NhCwuavDIG+IuXsCqpsjnBvLpruHP8nzTJN0U2Q D4Mb/iF4gFBoABjm5vaTTwv17tfIDXToKKO+7+FWkg+axPk4b6Ig6c5e7Ser4LfLKT yqNWrlQ0igR21VmPtcUfuJR367M0PJQoc99z4krV3iRBVmqY1MpUDuBzl3fjPRhMCX WljqfBiY//NuB55XEEXJ5Zs5H4XSi/wNU40P1w2Jaeq34EFovx7JE0br+49zjhaLJO ahFzjBSINGbJevBvbK7/Z9e81FT/UAB6TVREMX1GCDIeopXbuOWGTNEpCidcp5WKD2 nYLMioAQzcqIA== 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/34] x86/entry/32: Load task stack from x86_tss.sp1 in SYSENTER handler Date: Mon, 5 Mar 2018 11:25:32 +0100 Message-Id: <1520245563-8444-4-git-send-email-joro@8bytes.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1520245563-8444-1-git-send-email-joro@8bytes.org> References: <1520245563-8444-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