Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1176301rwr; Wed, 3 May 2023 11:06:54 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4UU1eofLBYez0RW/xPS8ODTWw+lJeV3oXMfCq7kLAGmx5nIcrQwtaXQTq95jgyKpy3TNVs X-Received: by 2002:a17:902:d4ce:b0:1a6:d763:3736 with SMTP id o14-20020a170902d4ce00b001a6d7633736mr844025plg.58.1683137213733; Wed, 03 May 2023 11:06:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683137213; cv=none; d=google.com; s=arc-20160816; b=nHYyCfavwRwK7y/EkrzOcmfGgufQgFaE03XCDm4AnUMB20Z+Pus7maoajzkKd91PRm sG9KPeTSVtuvrgNuJO/7V04vb5luuyCyg4k9j8yHfZkValu5v9jeg8QptlR155bBF3Gn lZJTEMG66fs7axnZd2hORoL2QIVcuH9ngjzOvpIPG1sXdNKtprgEjf7VHt0ZlOCy2HCj apLzSvqZTkGMQqn9Lz/fxl1E1JeS4PknH3l18G84lFmvwCghCHb9+17PwTRYiC3SUohD 3LUcywdeQ+0kVdU4L85CymJK+GtFzHDMjHW273p+leyA3YmmA3pWYm/jYsLkNBB1/6Zh n4CQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:subject:cc:to:from :date:references:in-reply-to:message-id:mime-version:user-agent :feedback-id:dkim-signature; bh=Y4YxYQXYH0oSVQriIDmU8VCfnypjhNE1GjKHSfa80f4=; b=yvpM3xfrGZTpls84Mm3vHHFbQyvSz5ag5aMXdLJO69pKEWvPTRw7zZdtAOtQOW1bf0 WWZFXzbRUOA/95r9bWyc5yxycNTWPB0uIsBU0COJR89a7JSAycvUFYftSxKpdeucN322 OLqMu9DF86ZOjyKvdmR0fsw2c2UKhq+bOgXF177QksUInKsBqGAlvLXerbACyq/jGN+C KHM/60Rz3h0369FZ4/pc9t0YiLIof+OnwzuMMtLUGetP3cMloevajfAg6xTt1YGRenu6 gyMBqvsbp+8ZSJKk65HGGbJMyoEPwtGY1fncjAZKC47QS72QfrYAA4IMGHor43RhcSkw wqTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YeX3d3ZR; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j3-20020a170903028300b001aae0c3fa03si10991321plr.473.2023.05.03.11.06.39; Wed, 03 May 2023 11:06:53 -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=@kernel.org header.s=k20201202 header.b=YeX3d3ZR; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229967AbjECRzs (ORCPT + 99 others); Wed, 3 May 2023 13:55:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229455AbjECRzr (ORCPT ); Wed, 3 May 2023 13:55:47 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99BC75271 for ; Wed, 3 May 2023 10:55:43 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0542862F22 for ; Wed, 3 May 2023 17:55:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C599AC4339B; Wed, 3 May 2023 17:55:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1683136542; bh=pr6VXchOekW4kaZuQqcL3QQRks0YchslFlKuv1MLJSY=; h=In-Reply-To:References:Date:From:To:Cc:Subject:From; b=YeX3d3ZRDN6tkgOoTIHOLpRhgIFe0uKWJ4SnN3qTzWNHVUg+kjpokKDUNhIDhlOIH xajJryWPn4Kp7favZeZmdV1fBZpO6/f6kjttxV4jcFVYoVI6BcwfKjRQW/kvBI4ztc aiu4pQDvmWznMFjBPcS4OzTRDYSYMVnJZIBT8L/1at2pXXwWv+jUy5SBZjNGBQYsw3 ikmRJvVD2a8sn2GqatKWc1Q+cNUbKJJ4rOezdVAZqcI0MlcX2VVDX5uGGqQHXPjuQ7 TDlvsMuFTF839FWhw32JFz96kORWJMjUBOAuQlcwvaSq3AfqsHv7ZWfUCFndDcDK6o GP/F0uTwkFBGQ== Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailauth.nyi.internal (Postfix) with ESMTP id A905127C0054; Wed, 3 May 2023 13:55:40 -0400 (EDT) Received: from imap48 ([10.202.2.98]) by compute3.internal (MEProxy); Wed, 03 May 2023 13:55:40 -0400 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfedvkedgudduhecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefofgggkfgjfhffhffvvefutgfgsehtqhertderreejnecuhfhrohhmpedf tehnugihucfnuhhtohhmihhrshhkihdfuceolhhuthhosehkvghrnhgvlhdrohhrgheqne cuggftrfgrthhtvghrnhepudevffdvgedvfefhgeejjeelgfdtffeukedugfekuddvtedv udeileeugfejgefgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomheprghnugihodhmvghsmhhtphgruhhthhhpvghrshhonhgrlhhithihqdduudei udekheeifedvqddvieefudeiiedtkedqlhhuthhopeepkhgvrhhnvghlrdhorhhgsehlih hnuhigrdhluhhtohdruhhs X-ME-Proxy: Feedback-ID: ieff94742:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 99CAB31A0063; Wed, 3 May 2023 13:55:39 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.9.0-alpha0-386-g2404815117-fm-20230425.001-g24048151 Mime-Version: 1.0 Message-Id: <44b21bb3-a65d-4560-9fe5-c7ddc260ddc0@app.fastmail.com> In-Reply-To: References: <20230416120729.2470762-1-ardb@kernel.org> <5694ea5d-da9a-413e-9499-02a54588a953@app.fastmail.com> Date: Wed, 03 May 2023 10:55:19 -0700 From: "Andy Lutomirski" To: "Ard Biesheuvel" Cc: linux-efi@vger.kernel.org, "Linux Kernel Mailing List" , "Evgeniy Baskov" , "Borislav Petkov" , "Dave Hansen" , "Ingo Molnar" , "Peter Zijlstra (Intel)" , "Thomas Gleixner" , "Alexey Khoroshilov" , "Peter Jones" , "Gerd Hoffmann" , "Dave Young" , "Mario Limonciello" , "Kees Cook" , "Tom Lendacky" , "Kirill A. Shutemov" , "Linus Torvalds" Subject: Re: [RFC PATCH 0/3] efi: Implement generic zboot support Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,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 Fri, Apr 21, 2023, at 6:41 AM, Ard Biesheuvel wrote: > On Fri, 21 Apr 2023 at 15:30, Andy Lutomirski wrote: >> >> >> >> On Sun, Apr 16, 2023, at 5:07 AM, Ard Biesheuvel wrote: >> > This series is a proof-of-concept that implements support for the E= FI >> > zboot decompressor for x86. It replaces the ordinary decompressor, = and >> > instead, performs the decompression, KASLR randomization and the 4/5 >> > level paging switch while running in the execution context of EFI. >> >> I like the concept. A couple high-level questions, since I haven=E2=80= =99t dug into the code: >> >> Could zboot and bzImage be built into the same kernel image? That wo= uld get this into distros, and eventually someone could modify the legac= y path to switch to long mode and invoke zboot (because zboot surely doe= sn=E2=80=99t need actual UEFI =E2=80=94 just a sensible environment like= what UEFI provides.) >> > > That's an interesting question, and to some extent, that is actually > what Evgeny's patch does: execute more of what the decompressor does > from inside the EFI runtime context. > > The main win with zboot imho is that we get rid of all the funky > heuristics that look for usable memory for trampolines and > decompression buffers in funky ways, and instead, just use the EFI > APIs for allocating pages and remapping them executable as needed > (which is the important piece here) I'd have to think about whether > there is any middle ground between this approach and Evgeny's - I'll > have to get back to you on that. > Hmm. I dug the tiniest bit into the history. The x86/boot/compressed s= tuff has an allocator! It's this: free_mem_ptr =3D heap; /* Heap */ free_mem_end_ptr =3D heap + BOOT_HEAP_SIZE; plus a trivial and horrible malloc() implementation in include/linux/dec= ompress/mm.h. There's one caller in x86/boot/compressed. And, once upon a time, the idea of allocating enough memory to store the= kernel from the decompressor would have been a problem. I'm willing to= claim that we should not even try to support x86 systems that have that= little memory (at least not once they've gotten long mode or at least f= lat 32-bit protected mode working). We should not try to allocate below= 1MB (my laptop will cry), but there's no need for that. So maybe the middle ground is to build a modern, simple malloc(), and ba= ck it by EFI when EFI is there and by just finding some free memory when= EFI is not there? This would be risky -- someone might have a horrible machine that has tr= ouble with a simple allocator.