Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3171111pxb; Mon, 25 Jan 2021 08:43:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJxpraABEBXMvTEJgwY+q3U5rdyKVqYsy04mBed/X2IQZf+Fa4zbgltKDl5PZ6xXIDum6mUR X-Received: by 2002:a05:6402:1e5:: with SMTP id i5mr1264569edy.86.1611593022332; Mon, 25 Jan 2021 08:43:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611593022; cv=none; d=google.com; s=arc-20160816; b=NE91UNh1RSVVnk0lFlANmVWKJgKRTTfwAEdjmrlup+3GlPvHXYHUEX3SfYlaRLppgY AQRnW7rT/Nii9MLA5sjat6paNXYSxvE8MLqpGSn4FwnG3V9tBzb0xdY6i9RJvW+ROs/L D0Fytrh+c1tOJmcoXHtHm5Wr97qafJEZH4dSzxFo+CQhz3KU9oE8ZKar02DS9KtYdttc 48ejjgf/FULrY2tVgXNn0ex3g7nQkQbn+gd7gve/hhXauRRsf3ZcipnabsoZixbZ8kwN UNS5TTP2wqwzmGJiaInqLzZ052KMdpu2r0jc5gv4UFK5iJOT4YgrZRME6mTeHswIAOVi 8y2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Z41UuKh+J5aniE9+28c3DumogNmp+4Y18W99bbzbbBM=; b=qnUCyC6jmUKwGIyD1WrvMWKBXdlCfmbsDcX4uwZc5gvPefajR+Te64/xzpXC3jtSO1 NNzqkeETjQhfb1gKejuf8sWS/JW5kdXh1ToiyW7dd7pLuPIhvbM1VyQ/yS1MZAiibqRg ixe0EGCSl1JHQSIYdvWdJDPTSXiYHP/2aRD2hSPo2uu8tNd2GxrxTrE+E5TNO3EVZsaL HHhYigwe3HULKMZREARA2bwdA1gJn2qwvqtf77w6d+FJ/Ib1IQFe+4iMoDx/xtLzYB9Q BnOBiUmoXwRP6qW3icWZn06VDrhweUpDU9mKj1IvixHw+9pbx6rUBLOTd1ui8Qsqdp7o oQlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=WK19KQkZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m26si7468577edv.305.2021.01.25.08.43.17; Mon, 25 Jan 2021 08:43:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=WK19KQkZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730788AbhAYQlA (ORCPT + 99 others); Mon, 25 Jan 2021 11:41:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730781AbhAYQgj (ORCPT ); Mon, 25 Jan 2021 11:36:39 -0500 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB5A3C061786 for ; Mon, 25 Jan 2021 08:35:58 -0800 (PST) Received: by mail-pj1-x102d.google.com with SMTP id j12so8719912pjy.5 for ; Mon, 25 Jan 2021 08:35:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Z41UuKh+J5aniE9+28c3DumogNmp+4Y18W99bbzbbBM=; b=WK19KQkZCYCTyhv+cncKz2OmECR9h+SoB3yc9f+g2b6uDLU1ojYhD70oqZD0ev+dVu 5s9TJ5z/4omLDqJtYlrfGsI4keHPEQBOrj4ix6fDyb4ZgIC8KXqpJedTFikBoAIjsDeS 7+mI7GlnbzfiPfUiJFF8ejaA3oe3paAol6YaOSqYj23zV+0Z+hFHQz4y3mkKnNBGwoUI zLKeykcU2AzbF3SG8Mw5GzvWTl751r2NKnShG5BsW9co+ZMiCBivLB2FigQuFoxGzZfe ti9XmAZZjI4XjmsrGQiK2g+amtf5HBXsl85CQFGQR5aS0r7L22ZlyIy2eh8a1JFwlQf9 QkHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Z41UuKh+J5aniE9+28c3DumogNmp+4Y18W99bbzbbBM=; b=nut7ODO/46J6MeaJJJaNPuqzMFRRlLh2g/sjqmIsM2ka6RSh6jSZ6pb8mo+NY7w/6t KxqXGFw7cgVld3mOpKK0V9kWeeUAGUczMfqx9h/lUGT9cgUwP3lvaOtAW2AbvcOxYpd0 ehJBjLF8X62T/Npbi1gM9j/u2lG8aJjJWcoh3qnbS7MSOSjII6+rNzNU2BcFE63OPwEQ g/xvtu9TgXWllJgwl0jpRsLzKk7PQWNqUm3A+v0JnzUd3mNc3HjQ40Rk1uYwToELPY3H FGls3aVRFrdbkjKSSdGKZQpN5WT6B0OVlvjLqic9Lvt8j8dl/TFifvOFWjTFKoYQXRx9 F0DA== X-Gm-Message-State: AOAM530ban5Z67QIJJJqka7nYOGvOH9O3UvxTvTTN6deFIAV5j6bM3Kw /wH4R8luP0S3MrSz55YdkM7xpzVfvFUbXA== X-Received: by 2002:a17:90b:246:: with SMTP id fz6mr1001381pjb.131.1611592558269; Mon, 25 Jan 2021 08:35:58 -0800 (PST) Received: from localhost ([47.251.4.198]) by smtp.gmail.com with ESMTPSA id q141sm7200350pfc.24.2021.01.25.08.35.55 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Jan 2021 08:35:57 -0800 (PST) From: Lai Jiangshan To: linux-kernel@vger.kernel.org Cc: Lai Jiangshan , Andy Lutomirski , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" , Dave Hansen , Peter Zijlstra , Al Viro , Vincenzo Frascino , Joerg Roedel , Ricardo Neri , Reinette Chatre , Andrew Morton , Gabriel Krisman Bertazi , Kees Cook , Frederic Weisbecker , Jens Axboe , Arvind Sankar , Brian Gerst , Ard Biesheuvel , Andi Kleen , Mike Rapoport , Mike Hommey , Mark Gross , Fenghua Yu , Tony Luck , Anthony Steinhauser , Jay Lang , "Chang S. Bae" Subject: [PATCH V2 5/6] x86_32/sysenter: use percpu to get thread.sp0 when sysenter Date: Tue, 26 Jan 2021 01:34:33 +0800 Message-Id: <20210125173444.22696-6-jiangshanlai@gmail.com> X-Mailer: git-send-email 2.19.1.6.gb485710b In-Reply-To: <20210125173444.22696-1-jiangshanlai@gmail.com> References: <20210125173444.22696-1-jiangshanlai@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lai Jiangshan TSS_entry2task_stack is used to refer to tss.sp1 which is stored the value of thread.sp0. At the code where TSS_entry2task_stack is used in sysenter, the CR3 is already kernel CR3 and kernel segments is loaded. So that we can directly use percpu for it instead of offset-calculation. And we remove the unused TSS_entry2task_stack. Signed-off-by: Lai Jiangshan --- arch/x86/entry/entry_32.S | 2 +- arch/x86/kernel/asm-offsets_32.c | 10 ---------- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/arch/x86/entry/entry_32.S b/arch/x86/entry/entry_32.S index a8d2640394f9..3cb42efb3c04 100644 --- a/arch/x86/entry/entry_32.S +++ b/arch/x86/entry/entry_32.S @@ -916,7 +916,7 @@ SYM_FUNC_START(entry_SYSENTER_32) /* Switch to task stack */ movl %esp, %eax - movl (3*4+TSS_entry2task_stack)(%esp), %esp + movl PER_CPU_VAR(cpu_tss_rw + TSS_sp1), %esp .Lsysenter_past_esp: pushl $__USER_DS /* pt_regs->ss */ diff --git a/arch/x86/kernel/asm-offsets_32.c b/arch/x86/kernel/asm-offsets_32.c index 6e043f295a60..6d4143cfbf03 100644 --- a/arch/x86/kernel/asm-offsets_32.c +++ b/arch/x86/kernel/asm-offsets_32.c @@ -43,16 +43,6 @@ void foo(void) OFFSET(saved_context_gdt_desc, saved_context, gdt_desc); BLANK(); - /* - * Offset from the entry stack to task stack stored in TSS. Kernel entry - * happens on the per-cpu entry-stack, and the asm code switches to the - * task-stack pointer stored in x86_tss.sp1, which is a copy of - * task->thread.sp0 where entry code can find it. - */ - DEFINE(TSS_entry2task_stack, - offsetof(struct cpu_entry_area, tss.x86_tss.sp1) - - offsetofend(struct cpu_entry_area, entry_stack_page.stack)); - #ifdef CONFIG_STACKPROTECTOR BLANK(); OFFSET(stack_canary_offset, stack_canary, canary); -- 2.19.1.6.gb485710b