Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2098316rwd; Mon, 15 May 2023 07:15:52 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6Nu2/iWijDBdSr3sjBWjrsgvJbEpAnAbldFqD92MXBSkfWU2sCJzmRZL45iB2aZSkMsENb X-Received: by 2002:a05:6a00:1492:b0:643:53b6:d841 with SMTP id v18-20020a056a00149200b0064353b6d841mr48276244pfu.2.1684160152146; Mon, 15 May 2023 07:15:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684160152; cv=none; d=google.com; s=arc-20160816; b=iP+AmT8rZzQ6UbwLpWV7TtGAGNOH6EoPh/U+Kco0Pkr3e2103X/6nifVjXQPm/3qge aTQ64UhDlwDqQtHBOc6vwMbUsMj1Z+fexjRlbC690unsHPFXI+t7Nlh++CoqK6q+8jj0 hIvMs2OM5YVzgkiqrKpvtPag3bQjx85uYLk1ejo6GCqaJ/AwYY2TPQl79uC4LUWKyUHJ 4rLihQeYJf+VbQvxuWWDZjrRl0K0dqD87L//NvN/VlYTepHb+Im+1Z8wUbUFH/GQdcR9 S2209fJRPjVkpv/u2ACe5wjn6UlNu8K1U3Y5hHlnMVu8H7rRZoy6H9zsUM1ZDvaVFAR+ j9zw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:feedback-id :dkim-signature:dkim-signature; bh=CTwZDV1W0gau6t111FgqYOUN7M1N250LK2GljieQw/4=; b=Mvm61O1yXL/rEcr4h/8zBoxQapQYKfoNPpkvbw+5ohFk5hEX0k9kgll2u3/WqqMahU 3UKVi3CjLTQKD3qbkYbZSDLTGaBduk0l2Jl0OTrTsLAhk2KDOVQllpKnF0IpM86abshD Pyyo7MxzBOc3McoFFCVUT6xCtf1LBpWsRN9faBcc6UGjmuKgba/Z44eytMrRCr+mtIu6 VQ0jgxAxCo+uWVffNf/6o46WmcpIk8AQeYmluQ4z/N2qV6IGBZNEZEQxlFO5Ui6ETIeE SIIAjuTf81WnTWA1zbDIvwTbnGgdfOBqJ7+FxUhUXyAk3mG1z3cZIfoy7LCEBf5bfXPF 4tsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@shutemov.name header.s=fm2 header.b=sw42rnJu; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=Lk6XUCbj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z1-20020aa79481000000b0063d329e9a08si17289347pfk.301.2023.05.15.07.15.24; Mon, 15 May 2023 07:15:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@shutemov.name header.s=fm2 header.b=sw42rnJu; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=Lk6XUCbj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239569AbjEOOEV (ORCPT + 99 others); Mon, 15 May 2023 10:04:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238764AbjEOOET (ORCPT ); Mon, 15 May 2023 10:04:19 -0400 Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83DEA213E; Mon, 15 May 2023 07:03:42 -0700 (PDT) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 8E1685C01B1; Mon, 15 May 2023 10:03:05 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Mon, 15 May 2023 10:03:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov.name; h=cc:cc:content-type:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm2; t=1684159385; x= 1684245785; bh=CTwZDV1W0gau6t111FgqYOUN7M1N250LK2GljieQw/4=; b=s w42rnJulm/LjZtkKWWEwPzcFE7SjjwrGVI2fz6IonFax57d9zbQehczGvVJA01Ci DgPeH08At8IxbdziSMWwAWDbtBkOElanxADJgjs02aBJ6xmR73QV56CXZQIV0vl/ YHbaAbZRtj3VE0uDU85ivgCjVuf09tdAP7kwLQOrJ6ohCoTi+EbSLMMkHvaAg1sH Imt9dOKNB8dtdIdvVEDWIvYHu00q1lS6YGkzx694/9HVxLWFpZ9Yxlxb7OTNCkxh SmhEXI+3fCGJX4fIISEEHUDwJhYhYJvY/P6+ZnL6V+BekCyRWev4FjgQQaLxveGX pdFR2O34ku9uFE1so5RTw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; t=1684159385; x=1684245785; bh=CTwZDV1W0gau6 t111FgqYOUN7M1N250LK2GljieQw/4=; b=Lk6XUCbj+tlorOWcvmImstYvtxt+W XX4NxVIZdNoto19dqCIpV8bS4suk3A4Tnm3nZUGHBF7/IBafuTOUcPIWr1Ej+h0t zEbLMmSOJL/d5NFUU/WicxAfGJfCh4v6NbylwWdVL9qolJlg5ABwt0LtE+NyuG58 WQbUVKWB4QH8oP54zG4USpf3FN+P0D/EBmBtb3dtkehiefrAQ9+Ua6yas4+p3EA+ QKS5Bhg/8DpwB0F/RKX5axnB9cTq5kd4pV7W/E2s4aKgYqXjeR+a84zL3bRHSiXj q0rLLK/CihqwBAYrJlJ38xG8eJB8T/L4y1yacsjcfP41GUhzd6+V9hWUA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeehjedgjedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggujgesthdttddttddtvdenucfhrhhomhepfdfmihhr ihhllhcutedrucfuhhhuthgvmhhovhdfuceokhhirhhilhhlsehshhhuthgvmhhovhdrnh grmhgvqeenucggtffrrghtthgvrhhnpefhieeghfdtfeehtdeftdehgfehuddtvdeuheet tddtheejueekjeegueeivdektdenucevlhhushhtvghrufhiiigvpedunecurfgrrhgrmh epmhgrihhlfhhrohhmpehkihhrihhllhesshhhuhhtvghmohhvrdhnrghmvg X-ME-Proxy: Feedback-ID: ie3994620:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 15 May 2023 10:03:04 -0400 (EDT) Received: by box.shutemov.name (Postfix, from userid 1000) id 0E71310D1DE; Mon, 15 May 2023 17:03:03 +0300 (+03) Date: Mon, 15 May 2023 17:03:03 +0300 From: "Kirill A. Shutemov" To: Ard Biesheuvel Cc: linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, Evgeniy Baskov , Borislav Petkov , Andy Lutomirski , Dave Hansen , Ingo Molnar , Peter Zijlstra , Thomas Gleixner , Alexey Khoroshilov , Peter Jones , Gerd Hoffmann , Dave Young , Mario Limonciello , Kees Cook , Tom Lendacky , "Kirill A . Shutemov" , Linus Torvalds Subject: Re: [PATCH v2 05/20] x86: decompressor: Avoid the need for a stack in the 32-bit trampoline Message-ID: <20230515140303.34lba7rl4onrltdu@box.shutemov.name> References: <20230508070330.582131-1-ardb@kernel.org> <20230508070330.582131-6-ardb@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230508070330.582131-6-ardb@kernel.org> X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 08, 2023 at 09:03:15AM +0200, Ard Biesheuvel wrote: > The 32-bit trampoline no longer uses the stack for anything except > performing a long return back to long mode. Currently, this stack is > allocated in the same page that carries the trampoline code, which means > this page must be mapped writable and executable, and the stack is > therefore executable as well. > > So let's do a long jump instead: that way, we can pre-calculate the > return address and poke it into the code before we call it. In a later > patch, we will take advantage of this by removing writable permissions > (and adding executable ones) explicitly when booting via the EFI stub. > > Not playing with the stack pointer also makes it more straight-forward > to call the trampoline code as an ordinary 64-bit function from C code. > > Signed-off-by: Ard Biesheuvel Acked-by: Kirill A. Shutemov -- Kiryl Shutsemau / Kirill A. Shutemov