From patchwork Fri Jul 13 16:34:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 141938 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp1011083ljj; Fri, 13 Jul 2018 09:35:13 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcdudYVoVcJWquBrrk5eB+mXRZ1QhMFCiAeIpnbw60xjxmUhX8Rcdm2GfjCgl//dBIN5Qyu X-Received: by 2002:ae9:dd05:: with SMTP id r5-v6mr6212170qkf.214.1531499713455; Fri, 13 Jul 2018 09:35:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531499713; cv=none; d=google.com; s=arc-20160816; b=Uhnngki7z9I3yRKWfteJyEXddJnlYSHxZrJT2Zz16gem3svb9wckCnfkKhEt4q8UvZ 8IrLP3jC8uXRxZgfhfNVIFYbr6tlx5Jbqh+N0lNkQisGBQSGJU/9FiCHdsd9Lzfddvpy 5kIz9Sa6xHMq1z0kLJnzt28m2KrU/N5gXfN2SuPCE6vKD7KipEVunnXFxlRyDjhawFSR KYstEL6+XvoA7aCe9hGmeyXBRZtcsZW079pka9ctTlpyDjW69mtYfG+nj2Fkv1Eb35JC OzsgM1YGxDJDwE9IBU9SZxU6jwAwiwHhAHyHE0K/Z6qsGUdei00Ftsc2coKbCnTrusrX 1WCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:references:in-reply-to:message-id:date:subject :to:from:dkim-signature:arc-authentication-results; bh=SYtkDtO5QDaPxt/MkWIjTsk1ZRbwgodOrKEYU9oGQt4=; b=L5CV8hfVGspSC9q/b0fPJC/9jXH2Py8VyJ9f79w1SFNmsO9D0AVlYqHnVDenKPv/GG raDPE6FFRZW/BU+Xy/sTNtVwnX3W4tjIA0cQDayiwBpKAitUf4Ft7m32zm5fSF/tCzGo /aUbR/LQp4sPr4l91ZorJ9sZPB7WfGhAkXqJ/s4kidApOd5gHMoL9I/bPRlqGMLtq0To oxHwq3ZFvXp36hl0swtSqZtWiRr7UJUbtqebb4BzJj91U6yznEI8CC/rU8eIT+GTJgky ES54VdNrFTg21VpdpHymtS2QhvSemfCDKptooi56r/W5YMGDL0A/fqkPkWGv2SxM4nt7 TuWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=D5V3Izvo; spf=pass (google.com: domain of grub-devel-bounces+patch=linaro.org@gnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="grub-devel-bounces+patch=linaro.org@gnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id g1-v6si13357482qkd.118.2018.07.13.09.35.13 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 13 Jul 2018 09:35:13 -0700 (PDT) Received-SPF: pass (google.com: domain of grub-devel-bounces+patch=linaro.org@gnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=D5V3Izvo; spf=pass (google.com: domain of grub-devel-bounces+patch=linaro.org@gnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="grub-devel-bounces+patch=linaro.org@gnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:38330 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fe12G-0005fs-TE for patch@linaro.org; Fri, 13 Jul 2018 12:35:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43187) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fe11z-0005eO-9T for grub-devel@gnu.org; Fri, 13 Jul 2018 12:34:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fe11y-0000Qq-H2 for grub-devel@gnu.org; Fri, 13 Jul 2018 12:34:55 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:45635) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fe11y-0000QJ-B2 for grub-devel@gnu.org; Fri, 13 Jul 2018 12:34:54 -0400 Received: by mail-wr1-x441.google.com with SMTP id c4-v6so13042110wrs.12 for ; Fri, 13 Jul 2018 09:34:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=NuvxbkpmdRD65QdBd0+BG7mkETHITEFZpsMMudda0Ro=; b=D5V3IzvoERshY86YATfRHt0Ig0fJYO95VtJYsGGhPwzGbz+FDOIvPJNKHTDNCA80VB kyuc1Bdw8kn6RI1mBY4tlbv5qJQQPKQ/mXYT9YXEPrJYETingO3plkCsuHeBn+gSA3s6 S08CdupyFquIDcmxLtOqk61n+A0WuhsacumpY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=NuvxbkpmdRD65QdBd0+BG7mkETHITEFZpsMMudda0Ro=; b=cJzf4CSoGbgkA1kAUOpSPyBKmo/mMWQ6pFqXRtisalAB60gWNgCitLiHrjmVnrGxR6 RxyOvJCWDChWMT8uei7hrMZbWtjUaYTbzxNBJ8rFNodWujL/erreGm2Nz7HOzuAs18Eo nT7QuAPK4NdDVxNQVg7b0ajADqvo2m33VT+4D3Dq9+BkOrq0I2B/Y3xxps8gudkBFmR7 SdsPj8AXJJownXVZXqGGSTvUUUkxqd4sAP6bCqlJQfOZeTYDOqzMwHFAkRZpWjCbarQN rKDrtQU/G1RI3feNWkLy3LXq+oSTAGN1UoigvED3RkslHGnQIsrh+P0PAq6drLVhplw6 QocA== X-Gm-Message-State: AOUpUlGoO6OiL91guxsOVbAxg5wNgRzWfI37tyfZ5erR9ODFcpUW2MNw UtyqddFmSj/xHYGg2YntrEnkIUc+2bs= X-Received: by 2002:a5d:514d:: with SMTP id u13-v6mr5384106wrt.162.1531499693093; Fri, 13 Jul 2018 09:34:53 -0700 (PDT) Received: from vanye.hemma.eciton.net (cpc92302-cmbg19-2-0-cust304.5-4.cable.virginm.net. [82.1.209.49]) by smtp.gmail.com with ESMTPSA id h5-v6sm16245899wrr.19.2018.07.13.09.34.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Jul 2018 09:34:51 -0700 (PDT) From: Leif Lindholm To: grub-devel@gnu.org Subject: [PATCH 3/3] loader/multiboot_mbi2: use central copy of grub_efi_find_mmap_size Date: Fri, 13 Jul 2018 17:34:45 +0100 Message-Id: <20180713163445.29478-4-leif.lindholm@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180713163445.29478-1-leif.lindholm@linaro.org> References: <20180713163445.29478-1-leif.lindholm@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::441 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: The development of GNU GRUB Cc: Daniel Kiper MIME-Version: 1.0 Errors-To: grub-devel-bounces+patch=linaro.org@gnu.org Sender: "Grub-devel" Delete local copy of function to determine required buffer size for the UEFI memory map, use helper in kern/efi/mm.c. Signed-off-by: Leif Lindholm --- grub-core/loader/multiboot_mbi2.c | 38 +------------------------------------- 1 file changed, 1 insertion(+), 37 deletions(-) -- 2.11.0 _______________________________________________ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel diff --git a/grub-core/loader/multiboot_mbi2.c b/grub-core/loader/multiboot_mbi2.c index 4df659595..747e10850 100644 --- a/grub-core/loader/multiboot_mbi2.c +++ b/grub-core/loader/multiboot_mbi2.c @@ -407,42 +407,6 @@ acpiv2_size (void) static grub_efi_uintn_t efi_mmap_size = 0; -/* Find the optimal number of pages for the memory map. Is it better to - move this code to efi/mm.c? */ -static void -find_efi_mmap_size (void) -{ - efi_mmap_size = (1 << 12); - while (1) - { - int ret; - grub_efi_memory_descriptor_t *mmap; - grub_efi_uintn_t desc_size; - grub_efi_uintn_t cur_mmap_size = efi_mmap_size; - - mmap = grub_malloc (cur_mmap_size); - if (! mmap) - return; - - ret = grub_efi_get_memory_map (&cur_mmap_size, mmap, 0, &desc_size, 0); - grub_free (mmap); - - if (ret < 0) - return; - else if (ret > 0) - break; - - if (efi_mmap_size < cur_mmap_size) - efi_mmap_size = cur_mmap_size; - efi_mmap_size += (1 << 12); - } - - /* Increase the size a bit for safety, because GRUB allocates more on - later, and EFI itself may allocate more. */ - efi_mmap_size += (3 << 12); - - efi_mmap_size = ALIGN_UP (efi_mmap_size, 4096); -} #endif static grub_size_t @@ -463,7 +427,7 @@ grub_multiboot2_get_mbi_size (void) { #ifdef GRUB_MACHINE_EFI if (!keep_bs && !efi_mmap_size) - find_efi_mmap_size (); + efi_mmap_size = grub_efi_find_mmap_size (); #endif return 2 * sizeof (grub_uint32_t) + sizeof (struct multiboot_tag) + sizeof (struct multiboot_tag)