Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1p5n3H-0003jH-Nq for mharc-grub-devel@gnu.org; Thu, 15 Dec 2022 07:09:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p5n38-0003gx-08 for grub-devel@gnu.org; Thu, 15 Dec 2022 07:09:23 -0500 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p5n31-00063T-LP for grub-devel@gnu.org; Thu, 15 Dec 2022 07:09:13 -0500 Received: by mail-pj1-x1032.google.com with SMTP id js9so10263293pjb.2 for ; Thu, 15 Dec 2022 04:09:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=pZeDtwx5JIFz7ONWVH6mQB1TghZJvCn4FqfNQE5Sz4o=; b=KOsSobpkZzi7Dj5Pt36P81KRkmUa1LdupFUkwAafkSxbPCIc1vQBRepAJ+K2gLm4JL SVHurnWFWfE3kIZ5eDPXR5E0mydm+9wtS8MIbsHm74gMQm2gGbE3rShFwiUBNm1en2c0 +epcF3v0pDux8A08W+PiXNxnlUAxafeKM7XTyRP1lBTPGNkukxxXOp72wru0IgaJR9C8 5U3qKNZRtZzcbrayMuwSA+ArBDMH8mE/67RgEu6AyXrTG0mEJVQWgDitQlinmpNVRCRC 9T6amYc1jl5mpS70CrFuNMw6E65wc3SsPsNUN55aGp4gbkYoKmczxbvfaAt5/olA9kIs ZAIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=pZeDtwx5JIFz7ONWVH6mQB1TghZJvCn4FqfNQE5Sz4o=; b=6NLYzhsxXdZEJvYtdx49jOJAuPzMLCN84yTgR/fu8wRpzDJ7PN+C8R42JkY+Jh6stM iPKNJYq392eO1guP6uXb2wBG+jc1jgKsHAF7UinziiBb0mB2EMNoBqqgGy57Sl8S2A6O wZoqxA50xt1lGVR271yj3vs5Ov2clvsD7qjJhnegW5r/6ERPKpcyVBlTNuoBnq8qrW18 gNAX9g6oucRiICukUcpcV0GcyoFKkUhsBJKKv//4jFNZ7eN8t3txHCPBafL7Ps/DnIrv mrr/7sFQQ9sBpl/y9WlL4sA/9f8l1sWtAJygHvJOV4qNsKpvU6QimvsktZJ2fU361Et/ Heqw== X-Gm-Message-State: ANoB5pknTJWNfMsB4ZyrD8OiKuHoAzcinskVqYN8g7HW9RSucMV2lgXI 01BtgLT7VnArcWOBDM1vH1s= X-Google-Smtp-Source: AA0mqf7NTnFjZQ+76FkUVHmfsL375d2aLpg55lSa6KopkJ4clFIEneyuixxcmcuyM9M2YM7QPo2ekw== X-Received: by 2002:a17:903:330d:b0:18f:9b13:5fc2 with SMTP id jk13-20020a170903330d00b0018f9b135fc2mr17483104plb.52.1671106149728; Thu, 15 Dec 2022 04:09:09 -0800 (PST) Received: from [0.0.0.0] (ec2-13-113-80-70.ap-northeast-1.compute.amazonaws.com. [13.113.80.70]) by smtp.gmail.com with ESMTPSA id d16-20020a170902ced000b00186b8752a78sm3692542plg.80.2022.12.15.04.09.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 15 Dec 2022 04:09:09 -0800 (PST) Message-ID: <549821db-7749-4e33-7e89-53142c99317c@gmail.com> Date: Thu, 15 Dec 2022 20:09:03 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.1 Subject: Re: [PATCH v2 3/6] ieee1275: support runtime memory claiming Content-Language: en-US To: Daniel Kiper , Stefan Berger Cc: The development of GNU GRUB , development@efficientek.com, diegodo@linux.vnet.ibm.com, dja@axtens.net, sudhakar@linux.ibm.com, nasastry@in.ibm.com References: <20221201211201.2915206-1-stefanb@linux.ibm.com> <20221201211201.2915206-4-stefanb@linux.ibm.com> <20221213161403.zqxqvcm7nbwhxtkz@tomti.i.net-space.pl> <413c897b-69b1-dc01-08c0-39db2e1ac49a@linux.ibm.com> <20221214143735.gmoveycu4muoy23w@tomti.i.net-space.pl> From: Zhang Boyang In-Reply-To: <20221214143735.gmoveycu4muoy23w@tomti.i.net-space.pl> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Received-SPF: pass client-ip=2607:f8b0:4864:20::1032; envelope-from=zhangboyang.id@gmail.com; helo=mail-pj1-x1032.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, NICE_REPLY_A=-0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Dec 2022 12:09:26 -0000 Hi, On 2022/12/14 22:37, Daniel Kiper wrote: > Adding Zhang... > > On Tue, Dec 13, 2022 at 02:10:01PM -0500, Stefan Berger wrote: >> On 12/13/22 11:14, Daniel Kiper wrote: >>> On Thu, Dec 01, 2022 at 04:11:58PM -0500, Stefan Berger wrote: >>>> From: Daniel Axtens >>>> >>>> On powerpc-ieee1275, we are running out of memory trying to verify >>>> anything. This is because: >>>> >>>> - we have to load an entire file into memory to verify it. This is >>>> difficult to change with appended signatures. >>>> - We only have 32MB of heap. >>>> - Distro kernels are now often around 30MB. >>>> >> >>>> + >>>> + if (flags & GRUB_MM_ADD_REGION_CONSECUTIVE) >>>> + { >>>> + /* first try rounding up hard for the sake of speed */ >>>> + total = grub_max (ALIGN_UP(size, 1024 * 1024) + 1024 * 1024, 32 * 1024 * 1024); >>> >>> s/ALIGN_UP(/ALIGN_UP (/ >>> >>>> + total = grub_min (free_memory - RUNTIME_MIN_SPACE, total); >>>> + >>>> + grub_dprintf ("ieee1275", "looking for %x bytes of memory (%x requested)\n", total, size); >>>> + >>>> + grub_machine_mmap_iterate (region_claim, &total); >>>> + grub_dprintf ("ieee1275", "get memory from fw %s\n", total == 0 ? "succeeded" : "failed"); >>>> + >>>> + /* fallback: requested size + padding for a grub_mm_header_t and region */ >>> >>> This... >> >> With 'this' you mean the comment above or which exact part? > > Yes, exactly... > >>>> + if (total != 0) >>>> + { >>>> + total = size + 48; >>> >>> ... and this should be dropped. I think this patch set, [1], [2], solves >> >> You mean adding 48 to it can be dropped? > > Yep... Sorry for being imprecise... > >>> this kinds of problems in general. Please take a look... >> >> I looked at them and I don't know how they are related. > > If I do not miss anything your patch set does not take into account size > needed for *grub_mm_region_t and *grub_mm_header structs. They are > needed for mm mgmt. So, grub_mm_add_region_fn() can be called twice to > fulfill request or memory addition may fail. The "mm: Preallocate some > space when adding new regions" patch extends the region size further to > not call firmware too often to fulfill small allocations. Due to that > I think your series should be merged into master together with Zhang one. > I hope he will repost updated mm series soon. > I also think 48 can be removed, if 48 means sizeof(grub_mm_region)+sizeof(grub_mm_header). With my patchset, the "size" passed to grub_mm_add_region_fn() will include these overhead and there is no need to add them in arch specific code. Best Regards, Zhang Boyang >>>> + total = grub_min (free_memory - RUNTIME_MIN_SPACE, total); >>>> + >>>> + grub_dprintf ("ieee1275", "fallback for %x bytes of memory (%x requested)\n", total, size); >>>> + >>>> + grub_machine_mmap_iterate (region_claim, &total); >>>> + grub_dprintf ("ieee1275", "fallback from fw %s\n", total == 0 ? "succeeded" : "failed"); >>>> + } >>>> + } >>>> + else >>>> + { >>>> + /* provide padding for a grub_mm_header_t and region */ >>>> + total = size + 48; >>> >>> Ditto... And then probably total can be dropped too... >> >> Don't we need a parameter to grub_machine_mmap_iterate (region_claim, &total) ? > > I think you can use size variable instead of total then. > > Daniel