Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1182582rwd; Sun, 14 May 2023 14:41:02 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ58ZH+xA8/tWBOCxFMeHZ7cPvfEQ2bcFEN3rs5Idt73K1LlraaEXa2qUVf5mzTRF3Z+iO5v X-Received: by 2002:a05:6a00:240a:b0:63d:3a18:4a08 with SMTP id z10-20020a056a00240a00b0063d3a184a08mr39499482pfh.24.1684100462285; Sun, 14 May 2023 14:41:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684100462; cv=none; d=google.com; s=arc-20160816; b=SF1k64zlF3uUyvGF9cEuaa/oypvtkij0zotIEk/ZdVBoGyrowNGRMmajSiwAObdIzC I6FJRzFwLinWZ3BBXP+elbCgQhKxArgoa6LxigxkVNAg6atKA7sLe6T6TgY1JHJFYern 7E1s0q5PPNS3Oj5E5kNPsHRz9PS2KWQyqKmJLrBjKblGB5kd4/u2qBIyHdOtp5JmrT5f vyIhzpsp+flg01borwPdXTyGvVhg+Dxecorzku8PrmKvIstt3bxE+VAWb2HuqTy6CcHQ kSGZG26kY1sZAFFI3xJenj/XRLmbaWWQExW68Rk+nRX6uFXHWzUTtXRCCgHV4xaSX3Vp yjKg== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:feedback-id:dkim-signature:dkim-signature; bh=IuSPhPzoKt6SzlFItZmSGd7IFEm9JtR4K2XlTqqjDSg=; b=KGk7tjfHOJzVxgvI7hdyxM8YJbxil/nQJlZipkkK97DWOtzda4U4Ux+zROwx76/Ycd FAYEGOvNxNKF2ju5sTuPHCelMmU8qOpa1ruk6uCia4SwMzBhyG3dESB27UtU7EsTnzpB 2QE9xTpsoDljaugSPDTiJvg7+KNOcj5UgqPr3sDvgUvpon5KQjTjo7YEu4WnXNrYbpdo DLl2/CaLLSn4L1dt+Bwo7BVmLLUsqjMDGeRR1FK9O9LWN54DA/0FUjDnaXYLzu4v3WZN fAfuwRPoC7n+5mPd+OZhguUJrBcQEs1Yft+AB2XgZJRDeMPGGP7bi514Ao3hjS+yBgyY Dq4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@shutemov.name header.s=fm2 header.b=tRwc6niu; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=qAOct1LD; 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 y8-20020aa78f28000000b0064140b05b6dsi15575540pfr.228.2023.05.14.14.40.45; Sun, 14 May 2023 14:41:02 -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=tRwc6niu; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=qAOct1LD; 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 S234828AbjENVNe (ORCPT + 99 others); Sun, 14 May 2023 17:13:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229585AbjENVNd (ORCPT ); Sun, 14 May 2023 17:13:33 -0400 Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA617199; Sun, 14 May 2023 14:13:29 -0700 (PDT) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 1D14F5C00C2; Sun, 14 May 2023 17:13:29 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Sun, 14 May 2023 17:13:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov.name; h=cc:cc:content-transfer-encoding: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=1684098809; x=1684185209; bh=IuSPhPzoKt6SzlFItZmSGd7IF Em9JtR4K2XlTqqjDSg=; b=tRwc6niuBNOVuTKwEyqx9a6VsQIiR8Moy/8NsjRBc MFNzOOBwCeyBwuKH7hfQf2mu11BcHRvW1/sTy4ioyfDuFCfb831tniIUXGJWZLoQ +olt7twOWA1isCCaTiLKvMAj/ObtUl1WhE8iidAq9qKKDFSNBBs2icMa1urfhSyq jzlTGwaNZLVGaG3PN9OieoaRG0lwYWf3/jRkOXymTJ1/5i+FgiZiry1ORlENAWvP dVt+22VdL8RZQszaF5cZNpd0J0NBOlTGSBHTTJf0Ei2WBX/bB/H93NDVbMcFYE6r 4kNmCJWwvOPkvJQ5AFuUF/dT08mYqhEeUO5moMzZWR7zQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :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= 1684098809; x=1684185209; bh=IuSPhPzoKt6SzlFItZmSGd7IFEm9JtR4K2X lTqqjDSg=; b=qAOct1LDQY6g96IN0g+vR8v7cPKjM76ZHfoMUWVWkTj38CppXKb n2qLMtnZjESXKqj5IoGvh+Y2tH2QsKrUUZbixtRlm8ZpZx31hjD/VYngQ5yhM8X0 tgSZWUPOBTxLaZ/jfTPnY/TDMO0jDiP5PLOfKyQHRl8VXxPGFW4I5JNL4vJWNt+0 v/at5pANurF9eFyKG+s+INq228hVcDUSkq8LXMSucg3Ij7lQFX7hyJlXmKXNyT2e qebGr1GFlQ7bogamkkOa7WznBY6VUnfRPEVmO9g1SE1jaE2YulTGy0cyKKsoN/N7 OpmPFn+xFm63xvHzfPl3Xi9SvvJF6PUiDJw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeehhedgudehlecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvvefukfhfgggtugfgjgesthektddttddtudenucfhrhhomhepfdfm ihhrihhllhcutedrucfuhhhuthgvmhhovhdfuceokhhirhhilhhlsehshhhuthgvmhhovh drnhgrmhgvqeenucggtffrrghtthgvrhhnpeetveehleetgeegffejffejtdevgeeugeef tefghffhgfeivefghfeuvefgjeekfeenucevlhhushhtvghrufhiiigvpedtnecurfgrrh grmhepmhgrihhlfhhrohhmpehkihhrihhllhesshhhuhhtvghmohhvrdhnrghmvg X-ME-Proxy: Feedback-ID: ie3994620:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 14 May 2023 17:13:27 -0400 (EDT) Received: by box.shutemov.name (Postfix, from userid 1000) id 3DBD910C400; Mon, 15 May 2023 00:13:24 +0300 (+03) Date: Mon, 15 May 2023 00:13:24 +0300 From: "Kirill A. Shutemov" To: Mika =?utf-8?B?UGVudHRpbMOk?= , Ard Biesheuvel Cc: "Kirill A. Shutemov" , Borislav Petkov , Andy Lutomirski , Dave Hansen , Sean Christopherson , Andrew Morton , Joerg Roedel , Andi Kleen , Kuppuswamy Sathyanarayanan , David Rientjes , Vlastimil Babka , Tom Lendacky , Thomas Gleixner , Peter Zijlstra , Paolo Bonzini , Ingo Molnar , Dario Faggioli , Mike Rapoport , David Hildenbrand , Mel Gorman , marcelo.cerri@canonical.com, tim.gardner@canonical.com, khalid.elmously@canonical.com, philip.cox@canonical.com, aarcange@redhat.com, peterx@redhat.com, x86@kernel.org, linux-mm@kvack.org, linux-coco@lists.linux.dev, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCHv11 3/9] efi/libstub: Implement support for unaccepted memory Message-ID: <20230514211324.fymzoa263wx2hs2p@box.shutemov.name> References: <20230513220418.19357-1-kirill.shutemov@linux.intel.com> <20230513220418.19357-4-kirill.shutemov@linux.intel.com> <9549d984-e581-048d-95a3-7c54acd70fb8@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <9549d984-e581-048d-95a3-7c54acd70fb8@redhat.com> 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 Sun, May 14, 2023 at 08:08:07AM +0300, Mika Penttil? wrote: > > + status = efi_bs_call(allocate_pool, EFI_LOADER_DATA, > > + sizeof(*unaccepted_table) + bitmap_size, > > + (void **)&unaccepted_table); > > > Wonder if EFI_LOADER_DATA guarantees bitmap not to be freed, or should some > more persistent type be used. If EFI_LOADER_DATA is enough, maybe a comment > why it is safe could be added. Ughh.. I've lost the hunk that reserves the memory explicitly while folding in the patch we discussed with Ard. See below. But the question is solid. Ard, do we want to allocate the memory as EFI_RUNTIME_SERVICES_DATA (or something else?) that got reserved automatically without additional steps? diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index e15a2005ed93..d817e7afd266 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -765,6 +765,25 @@ int __init efi_config_parse_tables(const efi_config_table_t *config_tables, } } + if (IS_ENABLED(CONFIG_UNACCEPTED_MEMORY) && + efi.unaccepted != EFI_INVALID_TABLE_ADDR) { + struct efi_unaccepted_memory *unaccepted; + + unaccepted = early_memremap(efi.unaccepted, sizeof(*unaccepted)); + if (unaccepted) { + unsigned long size; + + if (unaccepted->version == 1) { + size = sizeof(*unaccepted) + unaccepted->size; + memblock_reserve(efi.unaccepted, size); + } else { + efi.unaccepted = EFI_INVALID_TABLE_ADDR; + } + + early_memunmap(unaccepted, sizeof(*unaccepted)); + } + } + return 0; } -- Kiryl Shutsemau / Kirill A. Shutemov