Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp588390rwr; Wed, 26 Apr 2023 03:46:42 -0700 (PDT) X-Google-Smtp-Source: AKy350bbJzTNhW1oXpZ+i8+y2G1trDJGCGGQlgZ31CuP+gSd9pvYGMJeC2QT6sosk48MBu/lVeUa X-Received: by 2002:a17:903:244f:b0:1a8:16d2:a867 with SMTP id l15-20020a170903244f00b001a816d2a867mr26773115pls.62.1682506002310; Wed, 26 Apr 2023 03:46:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682506002; cv=none; d=google.com; s=arc-20160816; b=tcT+0cGfo0IK7vRo2wUmFWB5Z+22eR0ss7V4q7cu5kwNgFLO0nn3JreHMO/XkOC5Jy Ir5sQIte61Tglhx3sLyiAM6sOfxGv9ihhaGBR/588G0b76Y12CMjNvKLZKw7jmpkZf5c yKPqd8GDUqdR9GEJRbKFUN3wGxr3DIJG6unyOrYkdMjyjPNWSH4Ay6b3aJgt+LfA7WI7 GEx/iU10B6RLkytoaKrwxFdTq6+xcOBZBNTS5FuHAuwaZJwsCrf2bkMnmFQCRN9o+eKt t83217JyPPNMjGRmN39MBkWCyg2GFA16jww8DyEXtJPBYnw7Xx+jFCrg2QycIeFVq/D1 9ljA== 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:dkim-signature; bh=LOweLt8zA60kTE20aBn8JYsK7TZCTVOVBuf8DAjDPv0=; b=0Ji3futMis0bO+p5oScXcHpdPxlSsBh+6eDXvrVikKP8BUbAd/hZG4vGLzrNGKEKsy MS6OXrY6EGDzcL+jlzQXA3Gee2E7jtdFeV3esliMy83FMwLEf6V0Sx9RgzHp6wWm6I4M NE8MkHAz9cXKubt6WN7YuaabUwl3Bvt4tRuF74Zz7F3O7/PHOHtHZ8DLADHNEmY6CFU0 lp5NpjhbpvXZ08hgDLFzJz2r4uCr3zJuxnvYoZCZ+ktupF7KL20eIXjguSXFEX7+pq/a vdXlMF3iRlXmmVMwiaU0mbHwY39Av0r0cMdZm6IbbcHkxWNz3qPc8By0XzaleSQfg72B jMqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=dNv7BFAz; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lc7-20020a170902fa8700b001a9813e7039si5366272plb.174.2023.04.26.03.46.28; Wed, 26 Apr 2023 03:46:42 -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=@intel.com header.s=Intel header.b=dNv7BFAz; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240463AbjDZKmK (ORCPT + 99 others); Wed, 26 Apr 2023 06:42:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229937AbjDZKmI (ORCPT ); Wed, 26 Apr 2023 06:42:08 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16BFF4C33; Wed, 26 Apr 2023 03:42:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1682505728; x=1714041728; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=kLwcUviicm5zFgsdk4z3rBcMK/+14kP8fClgG+/9Z2M=; b=dNv7BFAzIKdxgWxVlUhVCM4SfdWM593xamuABXu7lCPUtbzP8FeKiiBP 54rcNdPOEJYNTZfNFISXflQoi0reIuo7gwE5X+HnW3e6bv+uQGKJll13p rlmjGV1gHg+i8srQfhdYzQD6VBbCT5k3Ty4pMAPKAkEywvIUe52snJQlb DC1vUGGGSgNfv7OX9Pahv/cs3YI5jEjaHON8lksGn0zUWXo7yw3x0rJZg guY7jGW+HX+HvBvZ+pbNYYmgTV4D9A4MgXvjWKlGdJr5rp6QUXsJ+G/n0 W8XDNFBQHScqQeBoPpv7gQttAr35bXTSX8gyLKMdrrfldlyTEqRSE+ixH w==; X-IronPort-AV: E=McAfee;i="6600,9927,10691"; a="349873704" X-IronPort-AV: E=Sophos;i="5.99,227,1677571200"; d="scan'208";a="349873704" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Apr 2023 03:42:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10691"; a="758563453" X-IronPort-AV: E=Sophos;i="5.99,227,1677571200"; d="scan'208";a="758563453" Received: from schoenfm-mobl1.ger.corp.intel.com (HELO box.shutemov.name) ([10.252.34.172]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Apr 2023 03:42:02 -0700 Received: by box.shutemov.name (Postfix, from userid 1000) id 665AC10CDFB; Wed, 26 Apr 2023 13:42:00 +0300 (+03) Date: Wed, 26 Apr 2023 13:42:00 +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 , Linus Torvalds Subject: Re: [PATCH 4/6] x86: efistub: Perform 4/5 level paging switch from the stub Message-ID: <20230426104200.drmuewhwmhh3xljh@box.shutemov.name> References: <20230424165726.2245548-1-ardb@kernel.org> <20230424165726.2245548-5-ardb@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230424165726.2245548-5-ardb@kernel.org> X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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, Apr 24, 2023 at 06:57:24PM +0200, Ard Biesheuvel wrote: > In preparation for updating the EFI stub boot flow to avoid the bare > metal decompressor code altogether, implement the support code for > switching between 4 and 5 levels of paging before jumping to the kernel > proper. I must admit it is neat. I like it a lot. Any chance we can share the code with the traditional decompressor? There's not much that EFI specific here. It should be possible to isolate it from the rest, no? > @@ -792,6 +925,14 @@ asmlinkage unsigned long efi_main(efi_handle_t handle, > (get_efi_config_table(ACPI_20_TABLE_GUID) ?: > get_efi_config_table(ACPI_TABLE_GUID)); > > +#ifdef CONFIG_X86_64 > + status = efi_setup_5level_paging(); > + if (status != EFI_SUCCESS) { > + efi_err("efi_setup_5level_paging() failed!\n"); > + goto fail; > + } > +#endif > + > /* > * If the kernel isn't already loaded at a suitable address, > * relocate it. > @@ -910,6 +1051,10 @@ asmlinkage unsigned long efi_main(efi_handle_t handle, > goto fail; > } > > +#ifdef CONFIG_X86_64 > + efi_5level_switch(); > +#endif > + > return bzimage_addr; > fail: > efi_err("efi_main() failed!\n"); Maybe use IS_ENABLED() + dummy efi_setup_5level_paging()/efi_5level_switch() instead of #ifdefs? -- Kiryl Shutsemau / Kirill A. Shutemov