From patchwork Wed Jul 11 11:29:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 10519427 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AD4276032A for ; Wed, 11 Jul 2018 11:30:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B217628C90 for ; Wed, 11 Jul 2018 11:30:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B016028D2C; Wed, 11 Jul 2018 11:30:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8F2F228C90 for ; Wed, 11 Jul 2018 11:30:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 319776B0271; Wed, 11 Jul 2018 07:30:09 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 2A2B56B0272; Wed, 11 Jul 2018 07:30:09 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1B80C6B0273; Wed, 11 Jul 2018 07:30:09 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by kanga.kvack.org (Postfix) with ESMTP id B0D6E6B0271 for ; Wed, 11 Jul 2018 07:30:08 -0400 (EDT) Received: by mail-ed1-f70.google.com with SMTP id b9-v6so682508edn.18 for ; Wed, 11 Jul 2018 04:30:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=DUQ7KzuPNsaOxN/NxhTDSDMnWYxjA4gkQNEHIpMfKIQ=; b=oTVPGuG+8nX2EN/OpW6hBPeurgeqF9vTU0FkXqYmgr848tO4GrozsC8dSvfd1xwByh ESa2HXWjzrQFC5oPIq2tI9sadJ6EmYh7LTgwYzS5IuYkBEPPcG6w3xsZla2tUj2njwT3 1RgrdWmYvC2goHLTypm/3XGM/Myeo7n0k2f9bvXEnLi7EPEo1djQHzv+tX21ZUnkkYoI h8gnKW/ZHrjJHBkjIQBldAMoyghK0HVm5XgXS/c/pW1JoSENnXmo1g0J7wVgJE8XJ63b RQuYBvZ4BhDdgx2oimQlvrvN13c29+Ohyj41GoIsfEBXfXvlph3zpbm9ya2ooAdnwwdS k3aQ== X-Gm-Message-State: APt69E1TPjZXBEd4o9LGSU87J6nnwRd01MJsffpcY9mNKw1pW3KDQNzL OP5wfOabiKZvv/P1xDmpZGyfxL8WT769gSqpXGRO3cMaKWjNbjmdB43vkC9FMpKIK/iT6o1TDaR qojOp1nbjdzeRd0A673rqtdlgHK55iSvMxq77Lvin45AxEUf0Ze/U2UE6TumUXYAjmA== X-Received: by 2002:a50:b5a5:: with SMTP id a34-v6mr29930278ede.88.1531308608290; Wed, 11 Jul 2018 04:30:08 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfRrDLoyYxc3Cdw5tVG40OooCQ3KNf9PBg5Dq4vQIWMMSfD3E4V+LMtDY9PMEK+JN6HmJqK X-Received: by 2002:a50:b5a5:: with SMTP id a34-v6mr29930242ede.88.1531308607694; Wed, 11 Jul 2018 04:30:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531308607; cv=none; d=google.com; s=arc-20160816; b=Oe7SBLt7nwqRxBX3PC7pStSHrVbeDl6w4FASrM6e13qAOTe4KAMppCJHyRygnMyTFs dSUIwsrED0CLJUnx4dU5YZm1ewHaWzsHE6VGcYXH2BVWzw4Yeopf6gKhT6bU2lYeitRo e3odboB2tsDIHnAUlJhmgs5QdELwtOJkQnYq3yPvRPPbCbbikKejA33JKMdUyOjt6E8J FFu2jukUHrWOf1AZvIk0MAO7Fr+P5QQmqwCO5CzRMIq79KF4RMYGAaQo0MVhE0l7IJRe jMF8xICZfwsJ1RYd8Y58dKDl+1isUb2gBTIFaDD59FyWeFhJrhPoIAlBjOxY9mRuK1Nn aC0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=DUQ7KzuPNsaOxN/NxhTDSDMnWYxjA4gkQNEHIpMfKIQ=; b=eFDPV/qSI+QLrdmpSsScDftBlQrz5fs3Ezo87ISsz7ZsUiWS2WOK2ZdfKTmrNg4bGh kAP2K8ZmX2m33dMhQafrFXzTpPu2jwVvOyPlWrgzkBMna1fZN7I5pGTtlNbWtBO/s78V MwzZ/L/ZCSfujY1WfSjr8tuNaAVDznJoI+8IkZ74S66a9QHfSZnUC2iOUosuY4gvmdo4 yuX8ez+bWV0czsXiAs9PnftKI8ehadsfoHgMcUXfITwmRJNrQgleCXKAmRZe+vseYstm MBoQD1+HF9sq0kwTMXKWIK4nCOmR7uYSrLj7Gp2umlOE1L6puAPjL0WIWD2TKy9pNEEr /a3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@8bytes.org header.s=mail-1 header.b=cmOnzPKa; spf=pass (google.com: domain of joro@8bytes.org designates 2a01:238:4383:600:38bc:a715:4b6d:a889 as permitted sender) smtp.mailfrom=joro@8bytes.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: from theia.8bytes.org (8bytes.org. [2a01:238:4383:600:38bc:a715:4b6d:a889]) by mx.google.com with ESMTPS id t27-v6si2340065edd.157.2018.07.11.04.30.07 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Jul 2018 04:30:07 -0700 (PDT) Received-SPF: pass (google.com: domain of joro@8bytes.org designates 2a01:238:4383:600:38bc:a715:4b6d:a889 as permitted sender) client-ip=2a01:238:4383:600:38bc:a715:4b6d:a889; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@8bytes.org header.s=mail-1 header.b=cmOnzPKa; spf=pass (google.com: domain of joro@8bytes.org designates 2a01:238:4383:600:38bc:a715:4b6d:a889 as permitted sender) smtp.mailfrom=joro@8bytes.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: by theia.8bytes.org (Postfix, from userid 1000) id 90E74715; Wed, 11 Jul 2018 13:29:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=8bytes.org; s=mail-1; t=1531308600; bh=Hav1IUA8t2cPKpgp4yckMuXOqky9jmo+BHWZdTZpH90=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cmOnzPKaoCsujY+x1U8rnAAIVssULkVOEk+V4dKoqDBri/5EAx+2wWLAVuAX/04iM fhGLCcxgUuVdbmbvXmGOhpQDPGcQ1gM07Jnkwip5TKy7+aNj0bGb0uikZGuHNtefAn IogzQWZDJNZgWQ2JswLVrfGSYVD0uc+HNV2GRVDTOi/Tahax5jWOgmDCU+NxBl6nLR 3H0Ery0DnHrvW2N9zWWaEOJ1fvPcsTJE0jpOsF08mOQ7D4MfhIRspJeR91BIUWuoXw dx00iwk5oQn8rOoglJePkDrTbtNVpMQtK8N0n6mLwawSAcEquuRhABQacPNzqD4udW W5pTLgwoJ4NJg== 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 , "David H . Gutteridge" , jroedel@suse.de, joro@8bytes.org Subject: [PATCH 03/39] x86/entry/32: Load task stack from x86_tss.sp1 in SYSENTER handler Date: Wed, 11 Jul 2018 13:29:10 +0200 Message-Id: <1531308586-29340-4-git-send-email-joro@8bytes.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1531308586-29340-1-git-send-email-joro@8bytes.org> References: <1531308586-29340-1-git-send-email-joro@8bytes.org> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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 ab2d949..36d77d3 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_STACKPROTECTOR diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c index 0ae659d..ec62cc7 100644 --- a/arch/x86/kernel/process_32.c +++ b/arch/x86/kernel/process_32.c @@ -290,6 +290,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)