From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1fe120-0005et-P0 for mharc-grub-devel@gnu.org; Fri, 13 Jul 2018 12:34:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43168) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fe11y-0005eE-8r for grub-devel@gnu.org; Fri, 13 Jul 2018 12:34:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fe11x-0000Q9-Gb for grub-devel@gnu.org; Fri, 13 Jul 2018 12:34:54 -0400 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:39941) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fe11x-0000Pd-Ah for grub-devel@gnu.org; Fri, 13 Jul 2018 12:34:53 -0400 Received: by mail-wm0-x243.google.com with SMTP id z13-v6so9977162wma.5 for ; Fri, 13 Jul 2018 09:34:52 -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=2YDuEVriczYjMdyyUD5sjSydG0NjVPk92aKOcIr8Huo=; b=G1SX10BjQYne4NpNg2T4YY4EvHzumqL4DT70rIKfDksqCybkF5sZckLTAkSm/X4x7w VptoZK6f+ajtHLe2JUABabcctFGM0E4dMgZK7rE3iBjC1PaX7D7u2jOYowGQEa+cFNWE QjnE6ds+ShCAlqiPXZbGwt2YrLXYsciuBCrxs= 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=2YDuEVriczYjMdyyUD5sjSydG0NjVPk92aKOcIr8Huo=; b=Sup0FENGxFZ3RdF4adgECzDI5rn4X4h5UDwSKJP1rPsDDt7bQWgsFwsyFitvo6Uxjd y8T9WNw7uJ85OrlwUfG0OgRiklTov3OUKysE+Ax0cLlvdcEmgj0lt7c/Z2tjjtOMbGWa Wos/pun2N+pHLefSkreKZ31j4OewV4GAG4hfm4kLfGZHfGSaR3tV8jOZEGF0zwlWp0hr v+DjNdU4dKZ1OWNRkc0RpgCflw4GRomBdXEm6NxpY5OJEPWctkIq2PISQH/l3vChbv+a +MFm7uvZ3waAgzki3n/a9bTchlTHcORtzxzpT8LIm7MnaHBE5foCEOoH3q3yWcVZL/fG jILA== X-Gm-Message-State: AOUpUlFtNCiNsWfh9p1gJp3sG5DJwUQhYmYoklh+zf9mOAZWWKuRzAJQ 9Kyn2sQl08VGuagNhHI2OIoRbQhZDnU= X-Google-Smtp-Source: AAOMgpcXH8RRY/J2Jzvt5WGioX1QwpITYnKPzuF2pN+WDnt30IdsvC6xiD2Gy33m5U9WFoJLf+tgwg== X-Received: by 2002:a1c:e043:: with SMTP id x64-v6mr4458461wmg.58.1531499691579; Fri, 13 Jul 2018 09:34:51 -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.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Jul 2018 09:34:50 -0700 (PDT) From: Leif Lindholm To: grub-devel@gnu.org Cc: Daniel Kiper Subject: [PATCH 2/3] loader/ia64/linux: use central copy of grub_efi_find_mmap_size Date: Fri, 13 Jul 2018 17:34:44 +0100 Message-Id: <20180713163445.29478-3-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:400c:c09::243 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:55 -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/ia64/efi/linux.c | 46 ++------------------------------------- 1 file changed, 2 insertions(+), 44 deletions(-) diff --git a/grub-core/loader/ia64/efi/linux.c b/grub-core/loader/ia64/efi/linux.c index 750330d45..96fce713a 100644 --- a/grub-core/loader/ia64/efi/linux.c +++ b/grub-core/loader/ia64/efi/linux.c @@ -133,48 +133,6 @@ query_fpswa (void) } } -/* Find the optimal number of pages for the memory map. Is it better to - move this code to efi/mm.c? */ -static grub_efi_uintn_t -find_mmap_size (void) -{ - static grub_efi_uintn_t mmap_size = 0; - - if (mmap_size != 0) - return mmap_size; - - mmap_size = (1 << 12); - while (1) - { - int ret; - grub_efi_memory_descriptor_t *mmap; - grub_efi_uintn_t desc_size; - - mmap = grub_malloc (mmap_size); - if (! mmap) - return 0; - - ret = grub_efi_get_memory_map (&mmap_size, mmap, 0, &desc_size, 0); - grub_free (mmap); - - if (ret < 0) - { - grub_error (GRUB_ERR_IO, "cannot get memory map"); - return 0; - } - else if (ret > 0) - break; - - mmap_size += (1 << 12); - } - - /* Increase the size a bit for safety, because GRUB allocates more on - later, and EFI itself may allocate more. */ - mmap_size += (1 << 12); - - return page_align (mmap_size); -} - static void free_pages (void) { @@ -212,7 +170,7 @@ allocate_pages (grub_uint64_t align, grub_uint64_t size_pages, size = size_pages << 12; - mmap_size = find_mmap_size (); + mmap_size = grub_efi_find_mmap_size (); if (!mmap_size) return 0; @@ -323,7 +281,7 @@ grub_linux_boot (void) /* MDT. Must be done after grub_machine_fini because map_key is used by exit_boot_services. */ - mmap_size = find_mmap_size (); + mmap_size = grub_efi_find_mmap_size (); if (! mmap_size) return grub_errno; mmap_buf = grub_efi_allocate_any_pages (page_align (mmap_size) >> 12); -- 2.11.0