Received: from list by lists.gnu.org with archive (Exim 4.71) id 1fe120-0005ei-LB for mharc-grub-devel@gnu.org; Fri, 13 Jul 2018 12:34:56 -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-Google-Smtp-Source: AAOMgpdnYNEkral3NQYOjssRzqdp0S2oLuMo/t3ahCVKbucX4BXgo5886MkbKBXmopXXMdpVDLbT2Q== 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 Cc: Daniel Kiper 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: , 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/i386/linux.c | 51 +------------------------------------------ 1 file changed, 1 insertion(+), 50 deletions(-) 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 -- 2.11.0