From patchwork Tue Sep 5 20:41:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 111748 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp3336702qge; Tue, 5 Sep 2017 13:41:45 -0700 (PDT) X-Received: by 10.200.12.68 with SMTP id l4mr537443qti.340.1504644105208; Tue, 05 Sep 2017 13:41:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504644105; cv=none; d=google.com; s=arc-20160816; b=EVO3tr7e+G9N6YosxrjD7MSDrluLL1P4BoifBjAcmcWIFPrd6aCH9Ef/AoWUfGLPg1 qQ6JWDKTB/nvjtkNIdQROgfWnEd/lGviZb4Yia85BLGRU1jNHT9z9TUTALAqrizcQhO9 MQfd+0b3I6pD3hmvfZbkLpPHyug2GQI8nS7caClXPf+kFObxG73z9ncUOgBTulX4/Vvj Vtjprqg300ebFjc8ud0lrTpr/td4WFIu18VNQrBoT1gxTnUahx+glu4c4jE/Oqe7So+v 3ixCkgvcq0n3SerIBJx6lkZ7R+dp6m+IBT0SaA/q4nWJvoLvi4zxOgcbshyn66ldoOwm 26bg== 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=imzGPAbRCb8lhIfaZ0eYe6TQiN2c1Cefjou4m/J1wHc=; b=v3AIEqfu0Er54dc8Ug7LnL+XWQEGhKdKEENcvllBZAr5mit42MjRBDafRk4l3GYayg LXl3toxkxhdgbPo/mABpLmGXzZfUhduWHidSAKdo3zLXaakjMIZ1HNq/CTkWwBs+5fD1 e91083wxifZDd6LGyDdjUIVx7Ui6I8XblDRkpB1iCf584Q41WhQWYFRsQUr807a1MiaN lN8TuhVxbGTbZdSZlxhGTlBolkGmx4o9Kv7rvj3o1NNJi8CuUOU2255cGWY3+pVklY/0 S9eCiBTaJDsT/yEmsMXD304EwWWtDlQlMyIIBHE3v5m/uaXDQWmZCwqtymhiD9gtTtDl a9Ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=LjJ7TJiY; 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 l65si1234538qkf.163.2017.09.05.13.41.44 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 05 Sep 2017 13:41:45 -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=LjJ7TJiY; 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]:33135 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpKfH-00074p-0R for patch@linaro.org; Tue, 05 Sep 2017 16:41:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43643) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpKez-000739-Fr for grub-devel@gnu.org; Tue, 05 Sep 2017 16:41:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dpKeu-0003Ek-9c for grub-devel@gnu.org; Tue, 05 Sep 2017 16:41:25 -0400 Received: from mail-wm0-x229.google.com ([2a00:1450:400c:c09::229]:35814) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dpKeu-0003EH-04 for grub-devel@gnu.org; Tue, 05 Sep 2017 16:41:20 -0400 Received: by mail-wm0-x229.google.com with SMTP id f199so3390795wme.0 for ; Tue, 05 Sep 2017 13:41:19 -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=RB6JLrA+zBcwvK8JAbiBK4qIpXq/gJ6MGH4zst2m8i0=; b=LjJ7TJiY9TXdfhVtFCuJrLYkREmVaheyKFFiah7NPaRF3MLshLDtsG529cl6I7RVbD tWw2PXvYcwyUWS1gvYTn8/gK8lNVXLVWxaHJrHpbBFKlvvPghnW5HG1zBBryM9+T1itX CgjUxhcJFJigIPCIgqdP5i8vX0LGlRVh4s9C4= 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=RB6JLrA+zBcwvK8JAbiBK4qIpXq/gJ6MGH4zst2m8i0=; b=masK8PeGKneyfiRKldkQ1tHFB6k4WLIqo/QynJUIXloKb/h7+olyQUdGxBGvpJbHGJ z4fQSvJ+u4dLfy71YPmyaZJw0KewwE/JWBwCGKTZfivawaqFIFze6HOjrQlRqNTBcji8 AWqP9SNDIEN42ayI8fqkJgI2weSUxIcWYb3RYGcdlMaZMrI1KwX2r+rnKUld4Cuw9rQv I19kobuZem6Wc/DJC/fJ9a4w+ep07aKpgtSC5P0kNPW4ZrUnkG/BL82buWtkkNS6YDN7 vXsz2mJ6wVXD0rLadAjO2j2/Qo9U8POMohrT55SvZXHZ+Vh624ivYd6CX0Rl7LhcN9f2 Zr0A== X-Gm-Message-State: AHPjjUjO6aI/Xa/dRp+8LUtqDGGiZQEZFvYMIac/AV4TfAGQdPgtjYhf dR+22DVQBw0Eoj3D4537wQ== X-Google-Smtp-Source: ADKCNb6P/09e1I2pnShSHufyecbhlXy1l6VRoOMckvrcKAro8UDsy+ZaVMydGLYPTA2wrDl0O4IBEw== X-Received: by 10.28.150.69 with SMTP id y66mr132939wmd.8.1504644078531; Tue, 05 Sep 2017 13:41:18 -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.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Sep 2017 13:41:17 -0700 (PDT) From: Leif Lindholm To: grub-devel@gnu.org Subject: [PATCH 1/4] i386/x86_64: make linux header definitions arch-specific Date: Tue, 5 Sep 2017 21:41:11 +0100 Message-Id: <20170905204114.9462-2-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::229 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" Rename GRUB_LINUX_MAGIC_SIGNATURE -> GRUB_LINUX_I386_MAGIC_SIGNATURE and linux_kernel_header -> linux_i386_kernel_header. Also change the include guard on grub/i386/linux.h to prevent clashes when including multiple linux.h headers (like in commands/file.c). Signed-off-by: Leif Lindholm --- OK, so one question here: in order to follow existing style, I have kept to the existing linux_ format. Is that the appropriate prefix, or should this be grub_linux_ like I originally used in the ARM series? Regardless, I intend to align the ARM patches to whatever format ends up being used for this patch. grub-core/commands/file.c | 6 +++--- grub-core/loader/i386/linux.c | 4 ++-- grub-core/loader/i386/pc/linux.c | 12 ++++++------ grub-core/loader/i386/xen_file.c | 4 ++-- include/grub/i386/linux.h | 10 +++++----- 5 files changed, 18 insertions(+), 18 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/commands/file.c b/grub-core/commands/file.c index 12fba99e0..63c84499b 100644 --- a/grub-core/commands/file.c +++ b/grub-core/commands/file.c @@ -497,7 +497,7 @@ grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args) case IS_X86_LINUX32: case IS_X86_LINUX: { - struct linux_kernel_header lh; + struct linux_i386_kernel_header lh; if (grub_file_read (file, &lh, sizeof (lh)) != sizeof (lh)) break; if (lh.boot_flag != grub_cpu_to_le16_compile_time (0xaa55)) @@ -508,7 +508,7 @@ grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args) /* FIXME: some really old kernels (< 1.3.73) will fail this. */ if (lh.header != - grub_cpu_to_le32_compile_time (GRUB_LINUX_MAGIC_SIGNATURE) + grub_cpu_to_le32_compile_time (GRUB_LINUX_I386_MAGIC_SIGNATURE) || grub_le_to_cpu16 (lh.version) < 0x0200) break; @@ -521,7 +521,7 @@ grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args) /* FIXME: 2.03 is not always good enough (Linux 2.4 can be 2.03 and still not support 32-bit boot. */ if (lh.header != - grub_cpu_to_le32_compile_time (GRUB_LINUX_MAGIC_SIGNATURE) + grub_cpu_to_le32_compile_time (GRUB_LINUX_I386_MAGIC_SIGNATURE) || grub_le_to_cpu16 (lh.version) < 0x0203) break; diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c index 083f9417c..44301e126 100644 --- a/grub-core/loader/i386/linux.c +++ b/grub-core/loader/i386/linux.c @@ -678,7 +678,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), int argc, char *argv[]) { grub_file_t file = 0; - struct linux_kernel_header lh; + struct linux_i386_kernel_header lh; grub_uint8_t setup_sects; grub_size_t real_size, prot_size, prot_file_size; grub_ssize_t len; @@ -721,7 +721,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), /* FIXME: 2.03 is not always good enough (Linux 2.4 can be 2.03 and still not support 32-bit boot. */ - if (lh.header != grub_cpu_to_le32_compile_time (GRUB_LINUX_MAGIC_SIGNATURE) + if (lh.header != grub_cpu_to_le32_compile_time (GRUB_LINUX_I386_MAGIC_SIGNATURE) || grub_le_to_cpu16 (lh.version) < 0x0203) { grub_error (GRUB_ERR_BAD_OS, "version too old for 32-bit boot" diff --git a/grub-core/loader/i386/pc/linux.c b/grub-core/loader/i386/pc/linux.c index a293b17aa..b69cb7a3a 100644 --- a/grub-core/loader/i386/pc/linux.c +++ b/grub-core/loader/i386/pc/linux.c @@ -121,7 +121,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), int argc, char *argv[]) { grub_file_t file = 0; - struct linux_kernel_header lh; + struct linux_i386_kernel_header lh; grub_uint8_t setup_sects; grub_size_t real_size; grub_ssize_t len; @@ -169,7 +169,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), maximal_cmdline_size = 256; - if (lh.header == grub_cpu_to_le32_compile_time (GRUB_LINUX_MAGIC_SIGNATURE) + if (lh.header == grub_cpu_to_le32_compile_time (GRUB_LINUX_I386_MAGIC_SIGNATURE) && grub_le_to_cpu16 (lh.version) >= 0x0200) { grub_linux_is_bzimage = (lh.loadflags & GRUB_LINUX_FLAG_BIG_KERNEL); @@ -322,7 +322,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), goto fail; } - if (lh.header != grub_cpu_to_le32_compile_time (GRUB_LINUX_MAGIC_SIGNATURE) + if (lh.header != grub_cpu_to_le32_compile_time (GRUB_LINUX_I386_MAGIC_SIGNATURE) || grub_le_to_cpu16 (lh.version) < 0x0200) /* Clear the heap space. */ grub_memset (grub_linux_real_chunk @@ -387,7 +387,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), { grub_size_t size = 0; grub_addr_t addr_max, addr_min; - struct linux_kernel_header *lh; + struct linux_i386_kernel_header *lh; grub_uint8_t *initrd_chunk; grub_addr_t initrd_addr; grub_err_t err; @@ -405,9 +405,9 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), goto fail; } - lh = (struct linux_kernel_header *) grub_linux_real_chunk; + lh = (struct linux_i386_kernel_header *) grub_linux_real_chunk; - if (!(lh->header == grub_cpu_to_le32_compile_time (GRUB_LINUX_MAGIC_SIGNATURE) + if (!(lh->header == grub_cpu_to_le32_compile_time (GRUB_LINUX_I386_MAGIC_SIGNATURE) && grub_le_to_cpu16 (lh->version) >= 0x0200)) { grub_error (GRUB_ERR_BAD_OS, "the kernel is too old for initrd"); diff --git a/grub-core/loader/i386/xen_file.c b/grub-core/loader/i386/xen_file.c index 99fad4cad..77a93e7b2 100644 --- a/grub-core/loader/i386/xen_file.c +++ b/grub-core/loader/i386/xen_file.c @@ -26,7 +26,7 @@ grub_elf_t grub_xen_file (grub_file_t file) { grub_elf_t elf; - struct linux_kernel_header lh; + struct linux_i386_kernel_header lh; grub_file_t off_file; grub_uint32_t payload_offset, payload_length; grub_uint8_t magic[6]; @@ -43,7 +43,7 @@ grub_xen_file (grub_file_t file) goto fail; if (lh.boot_flag != grub_cpu_to_le16_compile_time (0xaa55) - || lh.header != grub_cpu_to_le32_compile_time (GRUB_LINUX_MAGIC_SIGNATURE) + || lh.header != grub_cpu_to_le32_compile_time (GRUB_LINUX_I386_MAGIC_SIGNATURE) || grub_le_to_cpu16 (lh.version) < 0x0208) { grub_error (GRUB_ERR_BAD_OS, "version too old for xen boot"); diff --git a/include/grub/i386/linux.h b/include/grub/i386/linux.h index da0ca3b83..854e3e687 100644 --- a/include/grub/i386/linux.h +++ b/include/grub/i386/linux.h @@ -16,10 +16,10 @@ * along with GRUB. If not, see . */ -#ifndef GRUB_LINUX_MACHINE_HEADER -#define GRUB_LINUX_MACHINE_HEADER 1 +#ifndef GRUB_LINUX_I386_HEADER +#define GRUB_LINUX_I386_HEADER 1 -#define GRUB_LINUX_MAGIC_SIGNATURE 0x53726448 /* "HdrS" */ +#define GRUB_LINUX_I386_MAGIC_SIGNATURE 0x53726448 /* "HdrS" */ #define GRUB_LINUX_DEFAULT_SETUP_SECTS 4 #define GRUB_LINUX_INITRD_MAX_ADDRESS 0x37FFFFFF #define GRUB_LINUX_MAX_SETUP_SECTS 64 @@ -85,7 +85,7 @@ enum }; /* For the Linux/i386 boot protocol version 2.10. */ -struct linux_kernel_header +struct linux_i386_kernel_header { grub_uint8_t code1[0x0020]; grub_uint16_t cl_magic; /* Magic number 0xA33F */ @@ -312,4 +312,4 @@ struct linux_kernel_params } GRUB_PACKED; #endif /* ! ASM_FILE */ -#endif /* ! GRUB_LINUX_MACHINE_HEADER */ +#endif /* ! GRUB_LINUX_I386_HEADER */ From patchwork Tue Sep 5 20:41:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 111750 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp3337774qge; Tue, 5 Sep 2017 13:42:50 -0700 (PDT) X-Received: by 10.200.44.198 with SMTP id 6mr587272qtx.68.1504644170353; Tue, 05 Sep 2017 13:42:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504644170; cv=none; d=google.com; s=arc-20160816; b=yjjgyP7xN4jBtLWi52NDa302AOaPNZ0f+VW3wkNoon8WYOq6ztv3HDY/Wo2UvWt9ji vwQgu+mcCwuTbmah3kiV30iZOu3uA1hahHHD5glgKJvSug4/tw/Iq31BViYc/mfpXbbZ 1cO4P1dUUq+0g6STwTaKdkowaUQW2MlJh2hFz04w5Y6jslkgXYHKlh841DQc8bGnWEWa t7rVOX3iULwtr7QOAb6IUQbwlL9W+SK1xAI/jDy6Yr2oZ0/wFsycacE2dgtnyXq1aQb5 hftvbd9ZdM3bHnsA6rE6i7YyLka51X67s5HZBtVO2o3ZEIP92HjuWhHiaj+36orhWHpm abyQ== 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=gxNULSmh0t/xUPbIRI8So36UBLSgWp9B4+GIz3HxFHg=; b=DGwLIBSor62JHH0x7doeF+ViKHqukV9nK8coNFsxVY54cJn6MXqmf1waq5GXE26U/B jz0amRzG+zRbdN5jSMwG17c9Wr+9rGRqPXyT4WQF7w6+ZQCEmuXdXrWDeNxZyuN+Ur/v dp/Pa1V3RRfTXScd0y6KuFmt2LNbr1jgfDJ4dsDR5haJdJPI3DeM9XB9FX1xTLkDpyxo TvUWrPlrvqbtxaEC1zIotq2s9CSLkTWo94+Zsyi3ZOT2MN+Ei/6hJC6cUSRbfUCYYHwq /jEB6zLaR7xp2wPlS/fp9uzLCXDXySW4vU/65DuhqaYoERk25CWps/z68VX73wGT4GMt TK/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=eT2sLmP5; 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 a197si1355793qkc.21.2017.09.05.13.42.50 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 05 Sep 2017 13:42:50 -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=eT2sLmP5; 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]:33139 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpKgK-00081T-B2 for patch@linaro.org; Tue, 05 Sep 2017 16:42:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43649) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpKf0-00073C-78 for grub-devel@gnu.org; Tue, 05 Sep 2017 16:41:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dpKev-0003FT-Ja for grub-devel@gnu.org; Tue, 05 Sep 2017 16:41:26 -0400 Received: from mail-wr0-x22d.google.com ([2a00:1450:400c:c0c::22d]:38599) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dpKev-0003Ew-Cn for grub-devel@gnu.org; Tue, 05 Sep 2017 16:41:21 -0400 Received: by mail-wr0-x22d.google.com with SMTP id 108so10715052wra.5 for ; Tue, 05 Sep 2017 13:41:21 -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=W3zGMxru4hKhOgiDHuzvUMgXvu50HHmV/9UmxE2lOxc=; b=eT2sLmP5Z66TsouiVDGz8rum8bMWv6HcH0cSLmC268Gtd0zOnw2/Umpib6sNHOytHo qw9eF2aXPR5j5ScAxTriCda2/lBbXURx1rhrXFIEsLe5BEIGJep0djIp9VMWiUUo4vj4 RALS4yqhVFtqDIlx2PeNSU6PJEW9OdfHlyxRE= 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=W3zGMxru4hKhOgiDHuzvUMgXvu50HHmV/9UmxE2lOxc=; b=LC5uYE6krHkeIE6WHauP9I7i11PHX1DrgiQMifH4i7km7IMCmbKJB119K1AAip8e/f 6P9yAA+7lLwAw5C9XptPaP5mwHZ6/4h3wO7fLUefmFpVV8HbIKe387qmXxzBm4JWhxH+ ttBU/ZJtZscAR9ePR0hrKMCqoj3O8wvs4VRK8IEJ+Oiqe5H3rqw1HZl2t/8KwoZvzm6t s8N6KMAA2YeaGT1Ljz3mEILoMZxz1pAHOfIdWEcesF79aBEpJfx2pZpsBqfUdWj7s1uy dTkw0G98AT6hVsta0jtoGZdXMW8jBDW/4bLEmOa9x5pEo7gwcGxsHme7l8/uyCCnu4IT nqgw== X-Gm-Message-State: AHPjjUjgE8g6ZEZOGER/sMoIoM0IynkR2Yp0MzPPZR/sITGe8W+wrzHD k1m762/hRPX0j9eZmgi6ug== X-Google-Smtp-Source: ADKCNb74YB+6e5VOeg9TzJ34BhInoIbqew5pzvlOVU5cG0laE1RQPKPlrZw5WMGyL78LA4UaW4qAKw== X-Received: by 10.223.167.4 with SMTP id c4mr173059wrd.88.1504644080049; Tue, 05 Sep 2017 13:41:20 -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.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Sep 2017 13:41:19 -0700 (PDT) From: Leif Lindholm To: grub-devel@gnu.org Subject: [PATCH 2/4] arm64/efi: move EFI_PAGE definitions to efi/memory.h Date: Tue, 5 Sep 2017 21:41:12 +0100 Message-Id: <20170905204114.9462-3-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:c0c::22d 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" The EFI page definitions and macros are generic and should not be confined to arm64 headers - so move to efi/memory.h. Also add EFI_PAGE_SIZE macro. Update loader sources to reflect new header location. Signed-off-by: Leif Lindholm --- grub-core/loader/arm64/linux.c | 1 + grub-core/loader/arm64/xen_boot.c | 1 + grub-core/loader/efi/fdt.c | 1 + include/grub/efi/fdtload.h | 3 --- include/grub/efi/memory.h | 7 +++++++ 5 files changed, 10 insertions(+), 3 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/arm64/linux.c b/grub-core/loader/arm64/linux.c index 746edd104..ca01a2349 100644 --- a/grub-core/loader/arm64/linux.c +++ b/grub-core/loader/arm64/linux.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include diff --git a/grub-core/loader/arm64/xen_boot.c b/grub-core/loader/arm64/xen_boot.c index c95d6c5a8..67ada136b 100644 --- a/grub-core/loader/arm64/xen_boot.c +++ b/grub-core/loader/arm64/xen_boot.c @@ -30,6 +30,7 @@ #include #include #include +#include #include /* required by struct xen_hypervisor_header */ #include #include diff --git a/grub-core/loader/efi/fdt.c b/grub-core/loader/efi/fdt.c index 17212c38d..c0c6800f7 100644 --- a/grub-core/loader/efi/fdt.c +++ b/grub-core/loader/efi/fdt.c @@ -24,6 +24,7 @@ #include #include #include +#include static void *loaded_fdt; static void *fdt; diff --git a/include/grub/efi/fdtload.h b/include/grub/efi/fdtload.h index 7b9ddba91..713c9424d 100644 --- a/include/grub/efi/fdtload.h +++ b/include/grub/efi/fdtload.h @@ -29,7 +29,4 @@ grub_fdt_unload (void); grub_err_t grub_fdt_install (void); -#define GRUB_EFI_PAGE_SHIFT 12 -#define GRUB_EFI_BYTES_TO_PAGES(bytes) (((bytes) + 0xfff) >> GRUB_EFI_PAGE_SHIFT) - #endif diff --git a/include/grub/efi/memory.h b/include/grub/efi/memory.h index 20526b146..08fe62277 100644 --- a/include/grub/efi/memory.h +++ b/include/grub/efi/memory.h @@ -22,6 +22,13 @@ #include #include +/* The term "page" in UEFI refers only to a 4 KiB-aligned 4 KiB size region of + memory. It is not concerned with underlying translation management concepts, + but only used as the granule for memory allocations. */ +#define GRUB_EFI_PAGE_SHIFT 12 +#define GRUB_EFI_PAGE_SIZE (1 << GRUB_EFI_PAGE_SHIFT) +#define GRUB_EFI_BYTES_TO_PAGES(bytes) (((bytes) + 0xfff) >> GRUB_EFI_PAGE_SHIFT) + #define GRUB_MMAP_REGISTER_BY_FIRMWARE 1 grub_err_t grub_machine_mmap_register (grub_uint64_t start, grub_uint64_t size, From patchwork Tue Sep 5 20:41:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 111749 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp3337669qge; Tue, 5 Sep 2017 13:42:43 -0700 (PDT) X-Received: by 10.200.35.123 with SMTP id b56mr577554qtb.62.1504644163822; Tue, 05 Sep 2017 13:42:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504644163; cv=none; d=google.com; s=arc-20160816; b=wAPwyDiy581pCLozhVb922+R/mjaknBwGwmo+aKOI58918k1KIVoL807cRV/6G6nRM v1Rsx7Ox0pk8SVoHv6lGMSyyMLrMoIiwvK0B2l4xnoEyCa2Iy8e8a2jI0fHb2PNliwQ6 th6p+IWvmLIvfBVlxXor9cD5vTE2rebaSlA5pDKt2AOnqb14PLnt1WGfuE+VhIfkBgKE ACaDKVhwotHE0LmYxj4RbFnF4zpt5ivBEd1RnoMpMUWF9U1TGRpkkdjVingvwehaAomC SjYUAvMHg0rGlLV0B1wHpgINKLv92NVBdyH27TaVNtp4PwIV+BZIuA5C+LU1uNK53IWC cc9Q== 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=ubNwHm8BiOKShaSXJRuxYTmaUT4w0V9swTGrtpkEQVI=; b=CreJv/lAF1HJ0ZseD0VJHrQHbzjbfkd6A632a3QoODZKyhudg3WvBVNq/z4cL6MSpE ji7q+GvZikUFEhsfffS7ozd2zKKzs/60EmQauQtjeibEeBPr4UoONJN4krITIWFVscpI dMvvYzTJ1WCRxvW/RvVQnBxUQkfBZ8f0Czle0SadnqajvKWDVK0w0oLfa9vd8d0BtaRM 7HC4Z7lQT+rHfa4WxCMzzXHQahQDjC119/SlxeN20ZV4ZwgHHovafa+ZvSYvJY76fIVC Z+jWJYbh3WwTp9baF4+BCxcMfKV/6quowOVoImv73kLC0lxT6+OH1pux7YuSkPXX9KK6 G9DQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=DjhjRKgK; 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 j4si1062512qtd.456.2017.09.05.13.42.43 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 05 Sep 2017 13:42:43 -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=DjhjRKgK; 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]:33136 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpKgD-00075I-P5 for patch@linaro.org; Tue, 05 Sep 2017 16:42:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43657) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpKf1-00073D-4n for grub-devel@gnu.org; Tue, 05 Sep 2017 16:41:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dpKew-0003Fo-Ci for grub-devel@gnu.org; Tue, 05 Sep 2017 16:41:27 -0400 Received: from mail-wr0-x22b.google.com ([2a00:1450:400c:c0c::22b]:34289) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dpKew-0003FM-6f for grub-devel@gnu.org; Tue, 05 Sep 2017 16:41:22 -0400 Received: by mail-wr0-x22b.google.com with SMTP id a47so9041528wra.1 for ; Tue, 05 Sep 2017 13:41:22 -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=BZ9Px02dTLL9ncj4JBS6kvzCHiLbj6l7QNDhSw7fMLg=; b=DjhjRKgKnWOMF8ha5miPIASL9KLvmfW111FVOE4mIUGO0qTI/FVz39dgFYrqVhMZTU DMwYuJEWIP2VI5MntILH96GkZqlcxoh3AbY7oT2+bzenUgYe631Fa/H9yxGuq37bcnW3 L7pIOcSbd478R/6vP7PjMP+fBNGsvoXfvtrkw= 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=BZ9Px02dTLL9ncj4JBS6kvzCHiLbj6l7QNDhSw7fMLg=; b=dRcPjNbZ1pQfAr8kN/RzdBg880PRjdGH9Bk3HBCZAPiREtUnuVPO1esY7bgdCc+kvf gq6FF+Rg8AQVnXaX/ukVuPDc8BKLz4E3X6h+mkzcML4wm1BUIKOtQKlJ2Mxl9Mlg6b+L oCbFAfSMXOj/hjv84EI47talxs5a2Y6DJZ+IuNDz9xoReJsjnVcB+2giWkiKiU45t1uO IJxvXkveGanMq0jtwGow0dTP4Yz78LppeVS7b1pN0dKOw+j/t6z5LzYsxk7XPseptnp+ coQuAYJQwAa67QG9jgmZSDJLWIGAA8EpCsB4KWegLs4UlP52v/3k10LbnipyOi83IvHU VtFA== X-Gm-Message-State: AHPjjUiBVVGj284tvQFYmGyQlca2Mro5rpuAtB884MldbZ4xHEIEelpW 8fEyRiWytwLdhgmEj9O6mw== X-Google-Smtp-Source: ADKCNb699eC03BzKPYm0pLNEA2hMdPL5hy+l31QXNva6JfMh8sq8wMX0z6kyWlY2Mh4OjcbXOC/2Dg== X-Received: by 10.223.165.137 with SMTP id g9mr171972wrc.269.1504644080885; Tue, 05 Sep 2017 13:41:20 -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:20 -0700 (PDT) From: Leif Lindholm To: grub-devel@gnu.org Subject: [PATCH 3/4] efi: add central copy of grub_efi_find_mmap_size Date: Tue, 5 Sep 2017 21:41:13 +0100 Message-Id: <20170905204114.9462-4-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:c0c::22b 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" There are several implementations of this function in the tree. Add a central version in grub-core/efi/mm.c. Taken from grub-core/loader/i386/linux.c, changing some hard-coded constants to use macros from efi/memory.h. Signed-off-by: Leif Lindholm --- grub-core/kern/efi/mm.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ include/grub/efi/efi.h | 1 + 2 files changed, 48 insertions(+) -- 2.11.0 _______________________________________________ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c index ac2a4c556..8795aa1e0 100644 --- a/grub-core/kern/efi/mm.c +++ b/grub-core/kern/efi/mm.c @@ -218,6 +218,53 @@ grub_efi_finish_boot_services (grub_efi_uintn_t *outbuf_size, void *outbuf, return GRUB_ERR_NONE; } +/* To obtain the UEFI memory map, we must pass a buffer of sufficient size + to hold the entire map. This function returns a sane start value for + buffer size. */ +grub_efi_uintn_t +grub_efi_find_mmap_size (void) +{ + static grub_efi_uintn_t mmap_size = 0; + + if (mmap_size != 0) + return mmap_size; + + mmap_size = 1 * GRUB_EFI_PAGE_SIZE; + 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 += GRUB_EFI_PAGE_SIZE; + } + + /* Increase the size a bit for safety, because GRUB allocates more on + later, and EFI itself may allocate more. */ + mmap_size += 3 * GRUB_EFI_PAGE_SIZE; + + mmap_size = ALIGN_UP (mmap_size, GRUB_EFI_PAGE_SIZE); + return mmap_size; +} + /* Get the memory map as defined in the EFI spec. Return 1 if successful, return 0 if partial, or return -1 if an error occurs. */ int diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h index 3fa082816..8f1f36c8c 100644 --- a/include/grub/efi/efi.h +++ b/include/grub/efi/efi.h @@ -49,6 +49,7 @@ void * EXPORT_FUNC(grub_efi_allocate_any_pages) (grub_efi_uintn_t pages); void EXPORT_FUNC(grub_efi_free_pages) (grub_efi_physical_address_t address, grub_efi_uintn_t pages); +grub_efi_uintn_t EXPORT_FUNC(grub_efi_find_mmap_size) (void); int EXPORT_FUNC(grub_efi_get_memory_map) (grub_efi_uintn_t *memory_map_size, grub_efi_memory_descriptor_t *memory_map, 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)