Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1p5Afg-0001QB-7X for mharc-grub-devel@gnu.org; Tue, 13 Dec 2022 14:10:36 -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 1p5AfL-00015i-5c for grub-devel@gnu.org; Tue, 13 Dec 2022 14:10:11 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p5AfI-00070a-Cu for grub-devel@gnu.org; Tue, 13 Dec 2022 14:10:10 -0500 Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2BDIlSEF033834; Tue, 13 Dec 2022 19:10:05 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding : mime-version; s=pp1; bh=nzx2V60pkbyJsGv9Wuu+1zwr3DYiTfZj+l/TgdlZD8E=; b=dJBFVAD5G/LwPKq9K5rHajuwGBxq25npJReB7foopkN8Z7tLNir+rYD9j1fEzqrQ1Ao0 CvkgjBAKPUqEA1M06+8u2SRIiY1ipnsF5cZr4vnduhWvqHzmXdTcV9HZxiak+jevqmbo wcNJG65lVZihEvAX0RBUEkKG3wON0wJnY8giRXbftStxGnH19sbg89PhXb4bRfCSd2A+ I3qZbJWrWc4qOK2m8t0HQh54S1PjX9Qk+eNT373Ajd8DqgOfdKh/lD6RCCZSCWd8CTDS xUs9mZqU1LC5+827gVc5ANNxz0hn+7et7XW+QJg/vrw5lLBkLxOkDOM6Son7wa4DJUbw eA== Received: from ppma01dal.us.ibm.com (83.d6.3fa9.ip4.static.sl-reverse.com [169.63.214.131]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3mexyvresn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 13 Dec 2022 19:10:05 +0000 Received: from pps.filterd (ppma01dal.us.ibm.com [127.0.0.1]) by ppma01dal.us.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 2BDHp84Q018814; Tue, 13 Dec 2022 19:10:04 GMT Received: from smtprelay05.dal12v.mail.ibm.com ([9.208.130.101]) by ppma01dal.us.ibm.com (PPS) with ESMTPS id 3md7ecbvy4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 13 Dec 2022 19:10:04 +0000 Received: from smtpav02.wdc07v.mail.ibm.com (smtpav02.wdc07v.mail.ibm.com [10.39.53.229]) by smtprelay05.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2BDJA2bl7406186 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 13 Dec 2022 19:10:03 GMT Received: from smtpav02.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BF39458061; Tue, 13 Dec 2022 19:10:02 +0000 (GMT) Received: from smtpav02.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 03CD25805C; Tue, 13 Dec 2022 19:10:02 +0000 (GMT) Received: from [9.47.158.152] (unknown [9.47.158.152]) by smtpav02.wdc07v.mail.ibm.com (Postfix) with ESMTP; Tue, 13 Dec 2022 19:10:01 +0000 (GMT) Message-ID: <413c897b-69b1-dc01-08c0-39db2e1ac49a@linux.ibm.com> Date: Tue, 13 Dec 2022 14:10:01 -0500 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: The development of GNU GRUB , Daniel Kiper Cc: 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> From: Stefan Berger In-Reply-To: <20221213161403.zqxqvcm7nbwhxtkz@tomti.i.net-space.pl> Content-Type: text/plain; charset=UTF-8; format=flowed X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: jPtXsK9d9Vc2xpnUUt4PJb39404_Csqu X-Proofpoint-GUID: jPtXsK9d9Vc2xpnUUt4PJb39404_Csqu Content-Transfer-Encoding: 7bit X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-13_03,2022-12-13_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 lowpriorityscore=0 phishscore=0 bulkscore=0 mlxlogscore=999 impostorscore=0 clxscore=1015 spamscore=0 adultscore=0 mlxscore=0 priorityscore=1501 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2212130167 Received-SPF: pass client-ip=148.163.158.5; envelope-from=stefanb@linux.ibm.com; helo=mx0b-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, NICE_REPLY_A=-0.001, RCVD_IN_MSPIKE_H2=-0.001, 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: Tue, 13 Dec 2022 19:10:13 -0000 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? > >> + 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? > this kinds of problems in general. Please take a look... I looked at them and I don't know how they are related. > >> + 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) ? Stefan > >> + total = grub_min (free_memory - RUNTIME_MIN_SPACE, total); >> + grub_machine_mmap_iterate (heap_init, &total); >> + grub_dprintf ("ieee1275", "get noncontig memory from fw %s\n", total == 0 ? "succeeded" : "failed"); >> + } >> + >> + if (total == 0) >> + return GRUB_ERR_NONE; >> + else >> + return GRUB_ERR_OUT_OF_MEMORY; >> +} > > Daniel > > [1] https://lists.gnu.org/archive/html/grub-devel/2022-11/msg00147.html > [2] https://lists.gnu.org/archive/html/grub-devel/2022-12/msg00115.html > > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > https://lists.gnu.org/mailman/listinfo/grub-devel