Received: from list by lists.gnu.org with archive (Exim 4.71) id 1fe124-0005fx-Ty for mharc-grub-devel@gnu.org; Fri, 13 Jul 2018 12:35:00 -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-Google-Smtp-Source: AAOMgpftfNtNajj1LP49oImwpnXRILFb+2kO2AMK4qio7ZHYALOwUdbsAj+DDp152IsAwYEYmbLTvQ== 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 Cc: Daniel Kiper 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: , X-List-Received-Date: Fri, 13 Jul 2018 16:34:56 -0000 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(-) 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) -- 2.11.0