From patchwork Fri Jul 13 16:34:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 141940 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp1012205ljj; Fri, 13 Jul 2018 09:36:15 -0700 (PDT) X-Google-Smtp-Source: AAOMgpd0gEqe3+4kyLwSuPYUEumMBNg7Ww9StLGtwavHz92KyNjVerPDWVwwJTUrCegIHF5EdB6L X-Received: by 2002:ac8:33c2:: with SMTP id d2-v6mr6359899qtb.323.1531499775341; Fri, 13 Jul 2018 09:36:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531499775; cv=none; d=google.com; s=arc-20160816; b=01Zl15Enj0D56gXl8Aas3FuHafGNTvV0tGekSuI25UYJDgpRVxgx06ugRt2THLPP2J qPaIPvr5mM29f9N+suo7wR5xyXiDG949xIsvkjo1CpYeEybsPpFRypOV+qpgmj0bMKru FxwnsQ2qXT9wc8tsc2C2Yn3nT1/FPjnIfh3jSZknuFw76eJ+/c5IfsCt5HofuORfU6hU vGA4TopNYd2t15Og+rn9yVN58WKIpUO5j6s6QDWy+FX/x4CkHhZ2p1mCCIVZ6hMOvojn LJLHswplwCG0jav7P/O/uMLYA6y7qRhd0YYVZb+YpheYDrE1ytyQYIPBbUJo67g6ROOG Y7tQ== 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=h6OGpB4ucbn3YiOE603saGkrZaSX0aoLV/KkUPfLa64=; b=T7HzRlQKtMPuAHlvzjAiiLeR8q2BAWN2FJMZe/RXfE0raXLGxIlrQCbvYsK9dGxIVv 2xylonAQ3mUNOI7PN2sXJbc+9BuRYprHUz7PoOihtxQHsWdIpTrw7MEkgajTZ3RIFP3o Zo3T+ljmgI9j9QL2HysHYEnTg5QZzaGc+6KA/6CXjmE3lvshEwl/+UYi8o/oESU0a7nZ 7vf6jlqp1b4PKwl3DpxGc2sfXaP0l9KPqSkq8kcycQNZsJuej/viMZfymGqf59W5eTgc EtFNqv1Bw0+M2umi7ryaQK/cZloG9fkGudUSFwU5fhcQ2CO303Cwy3QWa7H5RHtsk27R mtOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=G1SX10Bj; 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 v6-v6si5767637qvv.284.2018.07.13.09.36.15 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 13 Jul 2018 09:36:15 -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=G1SX10Bj; 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]:38341 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fe13G-0006Yc-Rt for patch@linaro.org; Fri, 13 Jul 2018 12:36:14 -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-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 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: , 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/ia64/efi/linux.c | 46 ++------------------------------------- 1 file changed, 2 insertions(+), 44 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/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);