From patchwork Tue Sep 5 20:41:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 111751 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp3337868qge; Tue, 5 Sep 2017 13:42:56 -0700 (PDT) X-Received: by 10.55.49.73 with SMTP id x70mr522220qkx.238.1504644176014; Tue, 05 Sep 2017 13:42:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504644176; cv=none; d=google.com; s=arc-20160816; b=jgbCPc8s29mPTtaJkMtuqjfI69iW4EXffieE0mHs6zkLfwn2focIEdjQ87UXGOVbRu LhPkWvnXXNeZRH8z+0u9Sx82ifuSZzE2n5R9OUrb1n0H5bsOKZsaw1DaMY7iCWRznSD+ 3f8M2bQuH0RMQttteIFFfqB5X0GDOBd8bIOH9Ia1BLQw+5wdQL4eEWKwnKzR2WIkTXNr 5/LrtABUfD4gow9Wr89IJgD2+F4JmfVE8N1tRoVw+7Xt3Aie7C+XgNWAQczLrGxFJKtr eGF6vIDal+ipjcpT6ipKwiSjch6ztrdG4uGLX/AMpgZm1vb2NekyA2/G3IIzJ+BMbxUW sRmA== 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=MfxZSwhJnBkaW1fnDEZRGp4FjHDiGVAGeuud9yWSHdA=; b=zJvCLVC/oE5tsLE7+oInkIagE9ZTFC0zN3qSZP+V1i3Jbepfb+eVLg4gCQOmRo8v+b brnIuu2n2Qx+AuJydsV594oDN21Ohw8GM0Z3QNA3AXqtvk7lk+E+L1hzDNq7Wro2yl7C 9AA+2HqB98X1unk5kMDge+514hM9iKKk878u14VaZrYfuSuXDgM0KhqK4a0gnGZ+qGZ3 hA8g/94OXiL35wBvVJZzrpaUbdUxREvfUB3HHzeicoa1Pj7LWVa/9E8XyGrSlsSdscpv 0wIaztwNtG6kdLjwa0uAcUAWYbRmb5VQJX78UWQP5B+ytKM35ZCZi7fkCxWzrnB4PkUc Uqkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=cMDfLIS3; 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 u188si1284475qkb.333.2017.09.05.13.42.55 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 05 Sep 2017 13:42:56 -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=cMDfLIS3; 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]:33138 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpKgP-0007Ko-RW for patch@linaro.org; Tue, 05 Sep 2017 16:42:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43677) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpKf2-00073J-UY for grub-devel@gnu.org; Tue, 05 Sep 2017 16:41:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dpKex-0003Gf-R5 for grub-devel@gnu.org; Tue, 05 Sep 2017 16:41:28 -0400 Received: from mail-wm0-x234.google.com ([2a00:1450:400c:c09::234]:32777) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dpKex-0003GL-Jz for grub-devel@gnu.org; Tue, 05 Sep 2017 16:41:23 -0400 Received: by mail-wm0-x234.google.com with SMTP id f145so13226969wme.0 for ; Tue, 05 Sep 2017 13:41:23 -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=coIcfRNf2R3ZjZIyS1vdbO6GMCOCMFkkwy4kmuqDMU8=; b=cMDfLIS3KhsBOmJXkcb+fUrNw3kgoik76OqI5dBneDO034urcWfKnZt8ujW0y+CCFi h8VsjP72HvqqkROlDpUehwa15AEIQJPYpRFtwxsSVu4M84R5w1IridgsSEX4Sv7gysVT TFJtJU2UkIYzhxiEviB9VmYLRYjvkz6OU0c60= 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=coIcfRNf2R3ZjZIyS1vdbO6GMCOCMFkkwy4kmuqDMU8=; b=TAx+XLnTGt8WD2ir6ryKJN1WTBZfmhEgxW3UdB28tvTEWy/bW3sczVtKS40xhgWg3u eIYx3E2sQVnC63fLoPdEORsr45V5rzGXjptvaTe8YUCk7MQnrlnQ98zOX3wtDY4dngzJ b0iqaLMjXXbl8+1wyHxyylryuKI3TSNnqRIoKMq4uexE7xMssJm+U6ytDISwWWYlD+7l bmbnaHDKr2JOhZdoycxL927/uzyX8kMsc8ZP9Ox5qnFidUQooGjuQ/byBqutbE6sNwnr 1KVc5GtxqNC2xxUh71RSWiYmOw3JSoKTCn4fVCZejbYEe7EAyGZIIZNxkyeP2KOfM9sE GfXg== X-Gm-Message-State: AHPjjUi6q8/mDNTR/v6R44eEjtDXwGtjHBDY+A4y7DXkh8eyBdahQRmw ngzwQDW6+vx0J8ODKHZ7YQ== X-Google-Smtp-Source: ADKCNb6k8OmHwrGB9BZ9M6HivvlG/sss9NOg+jmiyoGVAzZHJeEqKMbOO6Y/7TjkJw4P34WHo+HDgw== X-Received: by 10.28.46.145 with SMTP id u139mr142640wmu.178.1504644082226; Tue, 05 Sep 2017 13:41:22 -0700 (PDT) Received: from vanye.hemma.eciton.net (cpc92316-cmbg19-2-0-cust118.5-4.cable.virginm.net. [82.12.0.119]) by smtp.gmail.com with ESMTPSA id k52sm2291077wrf.62.2017.09.05.13.41.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Sep 2017 13:41:21 -0700 (PDT) From: Leif Lindholm To: grub-devel@gnu.org Subject: [PATCH 4/4] loader: drop local implementations of find_efi_mmap_size Date: Tue, 5 Sep 2017 21:41:14 +0100 Message-Id: <20170905204114.9462-5-leif.lindholm@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170905204114.9462-1-leif.lindholm@linaro.org> References: <20170905204114.9462-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::234 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: Vladimir 'phcoder' Serbinenko , Daniel Kiper MIME-Version: 1.0 Errors-To: grub-devel-bounces+patch=linaro.org@gnu.org Sender: "Grub-devel" Now we have a grub_efi_find_mmap_size, replace near-identical implementations in i386/linux and mbi2 loaders with calls to that one. Signed-off-by: Leif Lindholm --- grub-core/loader/i386/linux.c | 51 +-------------------------------------- grub-core/loader/multiboot_mbi2.c | 38 +---------------------------- 2 files changed, 2 insertions(+), 87 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/i386/linux.c b/grub-core/loader/i386/linux.c index 44301e126..ab02add53 100644 --- a/grub-core/loader/i386/linux.c +++ b/grub-core/loader/i386/linux.c @@ -101,55 +101,6 @@ page_align (grub_size_t size) return (size + (1 << 12) - 1) & (~((1 << 12) - 1)); } -#ifdef GRUB_MACHINE_EFI -/* 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_efi_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; - grub_efi_uintn_t cur_mmap_size = mmap_size; - - mmap = grub_malloc (cur_mmap_size); - if (! mmap) - return 0; - - ret = grub_efi_get_memory_map (&cur_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; - - if (mmap_size < cur_mmap_size) - mmap_size = cur_mmap_size; - 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 += (3 << 12); - - mmap_size = page_align (mmap_size); - return mmap_size; -} - -#endif - /* Helper for find_mmap_size. */ static int count_hook (grub_uint64_t addr __attribute__ ((unused)), @@ -560,7 +511,7 @@ grub_linux_boot (void) ctx.real_size = ALIGN_UP (cl_offset + maximal_cmdline_size, 4096); #ifdef GRUB_MACHINE_EFI - efi_mmap_size = find_efi_mmap_size (); + efi_mmap_size = grub_efi_find_mmap_size (); if (efi_mmap_size == 0) return grub_errno; #endif diff --git a/grub-core/loader/multiboot_mbi2.c b/grub-core/loader/multiboot_mbi2.c index b0679a9f6..b5f961494 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_multiboot_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)