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