Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3172397pxb; Mon, 25 Jan 2021 08:45:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJxYV0IqizyDUp6jb6EJulUOY3+DTGapaUe3DBtb3JTsTynjqoD0ja3jWNZkQdKZuvmTA4HZ X-Received: by 2002:a17:906:dbe7:: with SMTP id yd7mr929048ejb.71.1611593139537; Mon, 25 Jan 2021 08:45:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611593139; cv=none; d=google.com; s=arc-20160816; b=Iq2xeZHlFK/0ksBILLDf4merzGdtgAFhynxVMoeeMqMoqDPQuC6maVLsyWqCtk0dCr QNrs2uNF+dj5xG8XDNrnOD5WZwKaVVGwr41cOQduReUAkB8l1texp2e+6IsRhOVrVZ7E 6/D+u1WLjiZ2biNLO5IdrM8H2escwPAkx3elI7GlKgDRjVGmqV5abbZ+RqDeARooPhjS tyFTDwSDGnN9omWBNTCg29jqvUnlxkvCMyxYczDqxrl+1aDCMlZV9C03bu6MiBcMMCp3 WUJZy5wxUBiS+w9/I/qFKcoaqRIXZgyUpGeVe8lf/Eyzlr/II3SodHWWH+Evd6aQA9M9 cXpg== 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=boDIhTNveL/8HHbCdQWZkom//s1uIHiPUA052kJfxyw=; b=I8Ke1GOfKGmNymLp1bh/1uZvspGd7zXbfBsnqGtf/sABcaKhYak4mBVmD4ODuvZECO Xg38Q/qoyjYn6/QNLK8Slr68NwdkqonNoted5qoGxQ0AmD28V3NbpbUCn/3lk4pDNZEu mKkNvzBkDlXsM6MWk6roC77hNYqEGIEIOl3IxB564Rc3PZR5OunZBu+Rg9kl+V/HwFUi DDjSZb+pQiMRPrKmsVdbrn6pVig+I7/MvZQC56aumYW0DDXvQwFf/H5FfBEjad8js3r9 yCdzKgpzt1/eerBt9xvY8rhZ7ygOXrx2s9SNO3EOuLY+EnxtOrnE9htbAyx8ZGCh/xSD TxiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="M7Dlr/sT"; 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 y25si7232854edv.428.2021.01.25.08.45.14; Mon, 25 Jan 2021 08:45:39 -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="M7Dlr/sT"; 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 S1730844AbhAYQll (ORCPT + 99 others); Mon, 25 Jan 2021 11:41:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728927AbhAYQfx (ORCPT ); Mon, 25 Jan 2021 11:35:53 -0500 Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18174C0613D6 for ; Mon, 25 Jan 2021 08:35:03 -0800 (PST) Received: by mail-pg1-x530.google.com with SMTP id q7so9258707pgm.5 for ; Mon, 25 Jan 2021 08:35:03 -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=boDIhTNveL/8HHbCdQWZkom//s1uIHiPUA052kJfxyw=; b=M7Dlr/sTMUd7pIVTpkNSZ0QPlSH+HUO7eSm66TTopBn1QyoMIzpD9dprUK1YTNciJa AjZHqXtpZrNr89W2I4tXKNFHfAVWtEjRj5KrKXMViCxncoKGeoiVS3yYVJ55LIMYbOe4 35Pd6v7Y90PfjOLFsIIcPjCcurt1EyNr7pogv3CzLW1Z5s3/tLIR19atVWqgAlcR337q vHKgVmGlym4Mn/WC2u3SUzJqUDm7psYpPn7F7wlX0mHLKTWcrUOsE6CiSubagP8bk2Bd 9LUqFHMtlXCe+3n9ha/HjpXyGhXJHKRFiatHd4x1YkGWgk6SJ9Y/LeslZc3nTFd55GrX DojQ== 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=boDIhTNveL/8HHbCdQWZkom//s1uIHiPUA052kJfxyw=; b=t5wl91ElQ3VFnDFBOltf8CxZVwMnhlsepMZr5opRR5RTDPNhInSTIUbzS0pLNfGC92 gOLCoX0LHFMskvNlgktafqLWKe5zBkWPb8cl1H8p4rhKBiSXgOGNveoJyoWTtp2HyZVK nWfQt25sQMks9k/5fKS3C3CW7B9tE0IzKokTDy2Ju6WV5XOtoMDljfY5F7y5DK1C8MQ/ kZ7pDPZtygFTT+X+12MkbFNdSUoN0qB2Z5nAjLfOPhRAFN/OvdqeR4ScC/XbZRk/Z4OM ak7nmwEcXGvdw0KYWUykyf4nxbIPjxzLICwQhfIO/e8F/SWVoWV3Oeu++3hi7VODK7i9 W3ug== X-Gm-Message-State: AOAM533QFH22dCdmEKyCjSUQAKTF8aDV3+lvSTEItuh++PdhueAtojW0 9H/JzAZUAnHMm5XOTXoWW5GuMs3Rkof/mA== X-Received: by 2002:a62:e516:0:b029:156:3b35:9423 with SMTP id n22-20020a62e5160000b02901563b359423mr1292417pff.19.1611592502344; Mon, 25 Jan 2021 08:35:02 -0800 (PST) Received: from localhost ([47.251.4.198]) by smtp.gmail.com with ESMTPSA id r7sm3459001pfc.26.2021.01.25.08.35.01 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Jan 2021 08:35:01 -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 3/6] x86_32/sysenter: switch to the task stack without emptying the entry stack Date: Tue, 26 Jan 2021 01:34:31 +0800 Message-Id: <20210125173444.22696-4-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 Like the way x86_64 uses the "old" stack, we can save the entry stack pointer to a register and switch to the task stack. So that we have space on the "old" stack to save more things or scratch registers. Signed-off-by: Lai Jiangshan --- arch/x86/entry/entry_32.S | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/arch/x86/entry/entry_32.S b/arch/x86/entry/entry_32.S index 3b4d1a63d1f0..4513702ba45d 100644 --- a/arch/x86/entry/entry_32.S +++ b/arch/x86/entry/entry_32.S @@ -905,19 +905,18 @@ SYM_FUNC_START(entry_SYSENTER_32) pushl %eax BUG_IF_WRONG_CR3 no_user_check=1 SWITCH_TO_KERNEL_CR3 scratch_reg=%eax - popl %eax - popfl - /* Stack empty again, switch to task stack */ - movl TSS_entry2task_stack(%esp), %esp + /* Switch to task stack */ + movl %esp, %eax + movl (2*4+TSS_entry2task_stack)(%esp), %esp .Lsysenter_past_esp: pushl $__USER_DS /* pt_regs->ss */ pushl $0 /* pt_regs->sp (placeholder) */ - pushfl /* pt_regs->flags (except IF = 0) */ + pushl 4(%eax) /* pt_regs->flags (except IF = 0) */ pushl $__USER_CS /* pt_regs->cs */ pushl $0 /* pt_regs->ip = 0 (placeholder) */ - pushl %eax /* pt_regs->orig_ax */ + pushl (%eax) /* pt_regs->orig_ax */ SAVE_ALL pt_regs_ax=$-ENOSYS /* save rest, stack already switched */ /* -- 2.19.1.6.gb485710b