From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E3DB4C433E0 for ; Mon, 25 Jan 2021 16:42:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B595C225AB for ; Mon, 25 Jan 2021 16:42:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730864AbhAYQmJ (ORCPT ); Mon, 25 Jan 2021 11:42:09 -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-Google-Smtp-Source: ABdhPJxJ+YMIRL9lCPsWVlo9wOx7JfperulYU/Z+kULUdNSuazEVNS6xO0P5fxyrGdR4dxsdTpBH5Q== 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