From patchwork Fri Jul 13 16:34:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 141939 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp1011832ljj; Fri, 13 Jul 2018 09:35:54 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe2Vc6pDwp2spzpv3X/ZBHzzUi0ZU1To1HD1tUKJqPVTUmLND4sS2IjFd014KW8ndXyxUAm X-Received: by 2002:a0c:bf4e:: with SMTP id b14-v6mr7928911qvj.65.1531499754261; Fri, 13 Jul 2018 09:35:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531499754; cv=none; d=google.com; s=arc-20160816; b=XcBoBAUGnhiNNWU4kxyf8pXjlzPZfvZf9Ia+gdw7JkNDV1dayjWyu9Tesd2AEiXkzb t7udvmHXGqKwcXpW5SrxwegVfvyFA1hl2Uz3DI4iTNZPtyE/O+TzmKyU0aVR4cbo/M73 pHgQ5EDF++QmlKOaNxcDUM4p32lNXNbD8I5WAVHFqAVMYYRS4NhFmjwnruWR+U9Txc04 ZOnbA7BsSfRPCnAnM28+NfFSn4RRZ/fsIZyjjNf37OYkNGBgtV8M/LK9EgVJYigEo8pi 9lhZy5mMI2wPOCHQLU3eM6cWGbtvSe6th+vRojv/eXkLTcaTW2xCD8VO/WfI+Jj06aG4 4gSg== 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=+Fc5eEiZhv4TzDqokTb01QjsQ4sLkBBfeb2aPpGfY18=; b=auiDHPFv8odhoBHTollFZsuDZ03vUXXCQcW3zemS7xvTFC+7pgMvLfD2avLJa/zzqc 4tp/p0+ROL1mW8pux78dv4VYHrloWeAZF89z77Kr6bAg2QSwG0wWIB2+H4cnwqXnfxFQ qKK6dDksekmdwezibQJiEvv2pcObUEyYkGHwDQnTUkpXH5Ex1v58QvuLdxko0CvcNVuJ gt6ntT9LPnUARmvV50Dh73lnHuo2rXDiN44w49CvuXJyWsYpO8eVezSjlME6IzxRISpU 3Promk6Ixaesd2iRlVGBrD1TBt/fU4nJ0B68kS67cho4/Eijmrg9892L53+hO2aXriEd EDIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=GIrNmrSI; 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 m22-v6si1826261qkh.235.2018.07.13.09.35.54 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 13 Jul 2018 09:35:54 -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=GIrNmrSI; 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]:38329 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fe12v-0005f8-NX for patch@linaro.org; Fri, 13 Jul 2018 12:35:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43163) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fe11y-0005eC-4q 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 1fe11v-0000Op-Et for grub-devel@gnu.org; Fri, 13 Jul 2018 12:34:54 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:37049) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fe11v-0000O4-7E for grub-devel@gnu.org; Fri, 13 Jul 2018 12:34:51 -0400 Received: by mail-wr1-x442.google.com with SMTP id q10-v6so25707034wrd.4 for ; Fri, 13 Jul 2018 09:34:51 -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=BaP+66zvfMDasI/XThe+OpQ3UY9l3TwY5qeU6smOYp4=; b=GIrNmrSImIsXoDjV0Ycut7yQxvs0eqic1i4qoa4glxfw4AJ1hM2Dcf8sCFkjv/tAdW dwAM0zLO2iEwBEg78mdQbHHQIh5v/QCOx91W6DlF5tyNEU6jYjQIBkpKej6Rl2PJZot+ qIb7UZNBGqq/t6sOdZEMiT8wSx85DXdbKrOcg= 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=BaP+66zvfMDasI/XThe+OpQ3UY9l3TwY5qeU6smOYp4=; b=IlqsBHp6WK4p4iKPsAnKS8qVgfmNdLG65LP+47NQUyFuhSJ77HyXXH+hAfVXzcd8va f2ykvEEHUOCRJHmAURW4L+SLTLaWJVOeRAXeCagbMmiP0iY+BsL2b5phR5bYPaaE3wSi bprcTMxsymMyXpdOdLyHjwnQmx0HN89bB5vOAAaJ3wYPvYN28RMczOvEbWqvx+H1h7mu OKr+VJxS1IBZHsFFxZnkEDG4SWOEY2igfORqpUk6mxS0HhYqmqIgl/nDw2QA8ozdPb1w TlnJ5LhYKek4SAWFE8bHTRWbsl4YpXbeqgTmCmZdUBL+5W7mxOg69kL5bdHppg4CbstV SxlQ== X-Gm-Message-State: AOUpUlG93Q1mQhDAzcLHnl7gxw75EuEs1Vf6miRDldKA8K2xkP3QsjBV dkW4QtSrVbfHS1RJrVl+6/Mu2OIBUGU= X-Received: by 2002:adf:9bc9:: with SMTP id e9-v6mr5807326wrc.240.1531499689976; Fri, 13 Jul 2018 09:34:49 -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.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Jul 2018 09:34:48 -0700 (PDT) From: Leif Lindholm To: grub-devel@gnu.org Subject: [PATCH 1/3] loader/i386/linux: use central copy of grub_efi_find_mmap_size Date: Fri, 13 Jul 2018 17:34:43 +0100 Message-Id: <20180713163445.29478-2-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::442 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/i386/linux.c | 51 +------------------------------------------ 1 file changed, 1 insertion(+), 50 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 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); 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)