From patchwork Thu Aug 3 10:04:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 109304 Delivered-To: patch@linaro.org Received: by 10.140.101.6 with SMTP id t6csp571026qge; Thu, 3 Aug 2017 03:08:05 -0700 (PDT) X-Received: by 10.55.157.135 with SMTP id g129mr1682282qke.241.1501754885094; Thu, 03 Aug 2017 03:08:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501754885; cv=none; d=google.com; s=arc-20160816; b=RCbE9u03a1B3fLUT6xXK/VM2oAO8ZjxJGMhRWiVcMfB0F+uIQJGB6N9W13Ig9inCwP 0BbbxzDCxdslOlyQ9jL3vd6tgtuy2no7n9cdB+taN8MTWS+bLvkHddUtDDH87OuPF7Rs +D4a2bz9SNLKdnnAeu+aCHzVm9AOyPjpmq7VjsXrCHBdBS8vlmgxInDL0ioMsgsi0CVw 4gVFSRLXZPuWngrXoT7BtiU/vz+T6i84LDd9rA66y2d5a0erwPsStxUxvlud2sPCG2Uo oGshawMP27PWUVdaKYtdova2s2GGTGMROwpO6LT4SrwclrzHAkX+aGFvwiMQsFLFbBQ6 47kQ== 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=wzWvQnk0/rV8TICHUbXRHFlu3F9yffbc9zOSa5Oa0kQ=; b=e86lUBfxwbwdMbeD0Td3YGYiBgpEyQtoTc+tR2FzfFidd82FXWb6LEV8ZZm9KIYin5 M2QbvF9F4SazOMWTBA9++NH8E0EABYHGTZdVuPjH6I25wwqQHWOdXbZ+wdcYETl+ngdn Udym4HhFl08F+MRIMTXs85pLf1EmobQqyLYPl/FlmyUS2UaC+F3MpgPWCJ/lgG2OCouQ qjuTeoNkjdhmu5BNAHhgeuRe1dpD3C6w3T+VJ/5zVhXgn2swFAwhIJD3rbC7fPQ3SgMU tJglR1q3mBQ/mVBWPRswazqqg9dz1IZr9U6lrDlYwFxC67gw+MrmTqSaVf4IPQaIgFQ1 JG6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=RqhxHf8E; 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 n8si31115463qtb.203.2017.08.03.03.08.04 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 03 Aug 2017 03:08:05 -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.b=RqhxHf8E; 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]:53198 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ddD2w-0000Fu-Lr for patch@linaro.org; Thu, 03 Aug 2017 06:08:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45614) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ddD1c-0000F3-Ba for grub-devel@gnu.org; Thu, 03 Aug 2017 06:06:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ddD1a-00046a-OL for grub-devel@gnu.org; Thu, 03 Aug 2017 06:06:40 -0400 Received: from mail-wr0-x229.google.com ([2a00:1450:400c:c0c::229]:33917) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ddD1a-00044l-I6 for grub-devel@gnu.org; Thu, 03 Aug 2017 06:06:38 -0400 Received: by mail-wr0-x229.google.com with SMTP id 12so3742233wrb.1 for ; Thu, 03 Aug 2017 03:06:37 -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=ayh31/HdZRUibUy00pqK+nc+jUnmarVfhC0eUeoW7n0=; b=RqhxHf8EhR4iahN46FrUv5oyInabxyJCzk3EmwDTxMswo4X9ZsZA+UNNSoyU6zylrE FXDkQnnX6NzQpzVDZoepTx5gEhWUDyGKB8HxRJMGDQL1xdAxlIK5OLoF//u2PpumclGN DfJnAj6rA9P3tBfQ7s14Wnsj1WyzU+pgk3fA8= 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=ayh31/HdZRUibUy00pqK+nc+jUnmarVfhC0eUeoW7n0=; b=jLwjGsLtO4yKi/f+7APN9BZhUWbb1xXmoIg0jf3+YzSvu6KDnP1g7C91q4j1JqTbWa mysx4XlrDaC84y1rdhuatqn8xZKKdoWRt/NOxoXwT7Q+fsQotLwK+khfIf8Hn/+bivY3 BUEzFxS8ohRn9SPqCcl4/lsw7cRCJmq5v/wPtKPvoIGMY0PRkBAnkzO+ZkFeqrtGrfXo luegbSmT3BuUlbnD8IkF7JQxtrLNbNMtIWpLFrWDlkA2+v+GD2+eI+kD2+0ycZ2Qb00m qZ0Qzol+MS2GJ1U4AwdcvxCJjKflttGj2tt25AU/9L6vQF/r+pZj1mmMwuBOEG1rLE0p 8EbQ== X-Gm-Message-State: AHYfb5izFQ7t+3p27WxcQc5e8v+y9iJpk6B3W80HegBNPF5OZt0kL4xx mufQZZ7A6Es4dE3hAbZVpg== X-Received: by 10.223.148.162 with SMTP id 31mr913689wrr.28.1501754795775; Thu, 03 Aug 2017 03:06:35 -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 e5sm2274543wre.24.2017.08.03.03.06.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 Aug 2017 03:06:34 -0700 (PDT) From: Leif Lindholm To: grub-devel@gnu.org Subject: [PATCH v2 01/14] arm64/efi: move EFI_PAGE definitions to efi/memory.h Date: Thu, 3 Aug 2017 11:04:19 +0100 Message-Id: <20170803100432.29913-2-leif.lindholm@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170803100432.29913-1-leif.lindholm@linaro.org> References: <20170803100432.29913-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::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: 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 atm64 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/fdt.c | 1 + grub-core/loader/arm64/linux.c | 1 + grub-core/loader/arm64/xen_boot.c | 1 + include/grub/arm64/fdtload.h | 3 --- include/grub/efi/memory.h | 4 ++++ 5 files changed, 7 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/fdt.c b/grub-core/loader/arm64/fdt.c index db49cf649..bdc3a0c1f 100644 --- a/grub-core/loader/arm64/fdt.c +++ b/grub-core/loader/arm64/fdt.c @@ -24,6 +24,7 @@ #include #include #include +#include static void *loaded_fdt; static void *fdt; diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c index 9519d2e4d..1960d18b5 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 27ede46ca..b7a5b17c9 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/include/grub/arm64/fdtload.h b/include/grub/arm64/fdtload.h index 7b9ddba91..713c9424d 100644 --- a/include/grub/arm64/fdtload.h +++ b/include/grub/arm64/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..a113348ca 100644 --- a/include/grub/efi/memory.h +++ b/include/grub/efi/memory.h @@ -22,6 +22,10 @@ #include #include +#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 Thu Aug 3 10:04:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 109301 Delivered-To: patch@linaro.org Received: by 10.140.101.6 with SMTP id t6csp569761qge; Thu, 3 Aug 2017 03:06:54 -0700 (PDT) X-Received: by 10.200.33.188 with SMTP id 57mr1301647qty.101.1501754814268; Thu, 03 Aug 2017 03:06:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501754814; cv=none; d=google.com; s=arc-20160816; b=sGNuVMt78OHfzwdF3oh4/x/6wiRLOz3RM7medCLSHkek8B0zK2yGaFi1Nxm9MJH2EB LGA39AUd22+rvCzlT40t4S6X4u0+1gmp1h7IHTMSVZIWZR9M8pad7/88GShfY7gXNozn RWap+Yrpsv50elw+uF2z7w7AlQ04WVPcEQd0JDYWQiUVaASOEkMv6NugN5KYYk+8WMrD cpKgfbT/Mz+9n6RCNiTXFLWACTNM2ZORvLzacsF+GTTBHSdtYLcxbebNPwV2ti28JD4j EysS5HI86Cf627vufA/+IzUrdoM0f1v61P/TG6F0GZy/qb6KjBkP+eJXV2cSx7jPXXeg 9D7Q== 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=/mLdyWsS5JBscLXD4HB0z8srgUDPG6aWL3QqFmRjUc4=; b=HTWaSW3oYSlf+l0s5D1deFGsdNqU9Rd/fwx5dT7EDt3hTtXjA59Vl/wBMO05E2DF2x mzEraoNxH+yZ/bhcr8mKMGVtRV6e8pw1jJ899U6SBmujjfhghy+ABwail4aAZy9eTOzO ibL241AGR2se4EUafTB0birVG3VaTWT9X1l3W0ioQDixZ4uW5mOPYoPLIVKO54j6yJUB sLM8Uf/UdxuVD+UNB8BM309BQREt2BYwe4Y3hjXQd7Iw1WBmMqErX/BK52rjQQbUg1LQ XbzjcRCaKCP0qsM2pc+RATY+tVrPogJ5WUmaOnucEYUgbHMJ1mDT7Ah36ayQBZhcw9sA Mxzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=ku91cuMJ; 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 h7si30164307qkf.508.2017.08.03.03.06.53 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 03 Aug 2017 03:06: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.b=ku91cuMJ; 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]:53196 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ddD1n-0000Fl-Qq for patch@linaro.org; Thu, 03 Aug 2017 06:06:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45613) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ddD1c-0000F2-Bu for grub-devel@gnu.org; Thu, 03 Aug 2017 06:06:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ddD1a-00045x-5J for grub-devel@gnu.org; Thu, 03 Aug 2017 06:06:40 -0400 Received: from mail-wm0-x22f.google.com ([2a00:1450:400c:c09::22f]:33499) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ddD1Z-000459-W4 for grub-devel@gnu.org; Thu, 03 Aug 2017 06:06:38 -0400 Received: by mail-wm0-x22f.google.com with SMTP id k20so3354636wmg.0 for ; Thu, 03 Aug 2017 03:06:37 -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=32S8GFOcbnzTlkBrAHmsW7W0VBoxuYyyyJoVcJReO+I=; b=ku91cuMJv7xOyux13LBvGNTyAIp3WA4yUEYbt/ntalcw/m5j7hexbz2Dq7HcHa7+rY ptBi6ZiYPtncfSYXJwwXYkN7MI8tL5ocGBLQ2a3Ygp/sK8L7RA9GVAp4Q4JzWdNJCcSQ ZWUzOtIZomBoDhLCkmUsZWIW5r1i0ofzKBOLU= 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=32S8GFOcbnzTlkBrAHmsW7W0VBoxuYyyyJoVcJReO+I=; b=Vr3u3GldLCnue8Np+hsIyFktjEbeQ6wAOi43sXJr41A1c1mbKgK8TRhi4gKAusSKzF DnPyWVhjV+DHXOvLL8LB56mfVBUEqy4sIrUY7FNRYv1hTHFYL7FDRnchwp3m+oMOCKv8 GiDW3rlEocxGuWZdm8t1ulLjV54SD1VUjcIPSfPE6FnLZkW7VI58QNc1Jn2TO6dYjQ36 mwfjUKmDBV3nJZTZieXM65BKgX9Uf39bR61GcLEftgqMaXDErytpQ1yfSmINYwfSn29q Aqpp3jpWZhTcGQJLrwMqi5EXC30U4Zz2bAfVA6pnBQjwgqFz2fpy7NdTkWUCJf+qCm8P 9YHg== X-Gm-Message-State: AIVw113XzDZLv0mrzmw3rE+4IFjp/kl/iQmZhPz2xqaANUEUsO8kCUrq aZrYKTuo8XGhfUIYhHvCuQ== X-Received: by 10.28.31.197 with SMTP id f188mr761287wmf.62.1501754796659; Thu, 03 Aug 2017 03:06:36 -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 e5sm2274543wre.24.2017.08.03.03.06.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 Aug 2017 03:06:36 -0700 (PDT) From: Leif Lindholm To: grub-devel@gnu.org Subject: [PATCH v2 02/14] efi: add central copy of grub_efi_find_mmap_size Date: Thu, 3 Aug 2017 11:04:20 +0100 Message-Id: <20170803100432.29913-3-leif.lindholm@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170803100432.29913-1-leif.lindholm@linaro.org> References: <20170803100432.29913-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::22f 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" 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 | 44 ++++++++++++++++++++++++++++++++++++++++++++ include/grub/efi/efi.h | 1 + 2 files changed, 45 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 20a47aaf5..31ca703ec 100644 --- a/grub-core/kern/efi/mm.c +++ b/grub-core/kern/efi/mm.c @@ -217,6 +217,50 @@ grub_efi_finish_boot_services (grub_efi_uintn_t *outbuf_size, void *outbuf, return GRUB_ERR_NONE; } +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 e9c601f34..3984de083 100644 --- a/include/grub/efi/efi.h +++ b/include/grub/efi/efi.h @@ -42,6 +42,7 @@ EXPORT_FUNC(grub_efi_allocate_pages) (grub_efi_physical_address_t address, 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 Thu Aug 3 10:04:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 109302 Delivered-To: patch@linaro.org Received: by 10.140.101.6 with SMTP id t6csp569889qge; Thu, 3 Aug 2017 03:07:00 -0700 (PDT) X-Received: by 10.237.42.88 with SMTP id k24mr1446095qtf.58.1501754820425; Thu, 03 Aug 2017 03:07:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501754820; cv=none; d=google.com; s=arc-20160816; b=W1YCOQBVEwYTujw5QETJGD1KgVlQ7VIedZ3PrEZJcMtM3JlmH/Y27QYUsnH00uSNFj qc+zfXR0xUPNqiS/olvCg6UwVFDFrHYCZ/aM+JPrgxW/oGM0kqtuCWg7x1S/LJPsyX9X bpBIusp49ijhcAuKSJa6lz/CL7uHXVa/+2Ouy6xku3471DzOh9NDKRUefWXiaFae7Gxn wNXNMDPBvUChfrZ7WrMQ3J86J7wJSDVIL20QSkEKeq0Bosss+lTlY+WNOjquqbtEw4tO w2lhw08KfzYLNiO9xQWVZxpFs5V/eYGsc9O/H9ZRjaMDE7FbzDcUE8fq/qo+0zVr7e9H TUdA== 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=RwaclreH+kiB/5CwvAbJJHUj95WOJrSobGAiyOSyqMo=; b=EZ80w/TKVFKBrZJi6XV22G3lz2HNPLblmEW4wE88ACXwBqg19JCk5o3cQHIoRWQmJR 5bl9HP/iaiXs3l8dsPFyWDXRGGG3vAyLGDM6H61rln61ikhIC+Hy43KxeqyFOYU8TOc4 9o71v7en0rbTn5KbiEoX6jf4OeAuNpM8y7TWIMgIAuXZXTK1t8bvsYKrKLkizPPkJkNG 9Ry+G+4qr9+gWzz1ugxpPlyHN13DNF0fNy/pa3Viw4Jf+/MzPbGT/PUYtMV+7rG8WN2d kf1nMLC66KCXjR9oeBhjD0MZqy29wROvVSV0m99PRVnSpESaoQsOuHMPw2FlvC7BrXjk KBEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=NlJ350Dg; 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 k14si22939983qtg.204.2017.08.03.03.06.59 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 03 Aug 2017 03:07:00 -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.b=NlJ350Dg; 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]:53199 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ddD1t-0000IJ-QG for patch@linaro.org; Thu, 03 Aug 2017 06:06:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45612) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ddD1c-0000F1-Ar for grub-devel@gnu.org; Thu, 03 Aug 2017 06:06:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ddD1b-00046n-1Z for grub-devel@gnu.org; Thu, 03 Aug 2017 06:06:40 -0400 Received: from mail-wr0-x234.google.com ([2a00:1450:400c:c0c::234]:35145) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ddD1a-000461-S8 for grub-devel@gnu.org; Thu, 03 Aug 2017 06:06:38 -0400 Received: by mail-wr0-x234.google.com with SMTP id k71so3722354wrc.2 for ; Thu, 03 Aug 2017 03:06:38 -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=UHJLEQi9MiLVbvMz5x0a8Mu2VAAb8gH08kT+/sjXfcY=; b=NlJ350DgLuKqzgiMoeaci+fd/i/PfE+7VKUIuk1EfIzppIiT9RmgLgSsAU8cipI2l4 IXQxV4ir1eafPYAqDFuFoYJ9XrVs4BrKK3a3TTud6oxRmk3PEk+tM4wf333mhfnWvkTd pBnzWwu2GnZaut2Jm174kq0HKHW46tRO5cUC0= 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=UHJLEQi9MiLVbvMz5x0a8Mu2VAAb8gH08kT+/sjXfcY=; b=TxPL7f0gHn1sMV3gU8aoBJwwm4eN1R1T/zuUMCZV4o0/tdCc8UT01Zb04I66xgJ9Fi YiiKHH8OOaHwWXtpOHQPMM5+YQFqjKbCVwKeO2LUZFWU8rXF2Xe4qeCb3Odq0UANJCVO 5jn9Arj/B6e0mi0w3NLkowmXub7uTIn3cXQfbLT51O4+hmEhXUHeEQC1B/06BYWmqRRp 0lAiCeFo+Zvf9xfW4kpcunPG/BEvrVc+fEpBetHdrWspgOfIEt6Fk4olkDZBUif54THO Z2nGz9Yt972WOJndXvY/+jJk06vKJrfO5EiWSI1a7+L0YrC6irbghD2F1z1n/XewNeib lbZA== X-Gm-Message-State: AIVw113jh4/E+Ghfde9dHyv1gA+l/gnaoAXJh86iKAa8yCSO+oWr0xG1 QlE9/2mKpBFYoLiYnb/mOg== X-Received: by 10.223.130.202 with SMTP id 68mr910478wrc.46.1501754797563; Thu, 03 Aug 2017 03:06:37 -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 e5sm2274543wre.24.2017.08.03.03.06.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 Aug 2017 03:06:36 -0700 (PDT) From: Leif Lindholm To: grub-devel@gnu.org Subject: [PATCH v2 03/14] loader: drop local implementations of find_efi_mmap_size Date: Thu, 3 Aug 2017 11:04:21 +0100 Message-Id: <20170803100432.29913-4-leif.lindholm@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170803100432.29913-1-leif.lindholm@linaro.org> References: <20170803100432.29913-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::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: 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 083f9417c..dfd50472f 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) From patchwork Thu Aug 3 10:04:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 109306 Delivered-To: patch@linaro.org Received: by 10.140.101.6 with SMTP id t6csp571198qge; Thu, 3 Aug 2017 03:08:16 -0700 (PDT) X-Received: by 10.200.1.204 with SMTP id b12mr1290155qtg.2.1501754896066; Thu, 03 Aug 2017 03:08:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501754896; cv=none; d=google.com; s=arc-20160816; b=sxmEHgYhmN0LMe18Uax4l4GxWUMxfT5Pf4BHqlROna17qrf5edcO0LHQze+p3yjxB7 baAj2Owh226LEV1gs1W7vBGWjFDbtN80kflah4H6Boh6Bee4ZdPHGq4qbfnz0sIyghRX RlgOqCSlXcpT7mm2xkdPGaYOCH0wmal/8PckWxfLYoau5tqIsXy1vWKevIj3T7ZCVUDX Vppf6iJmcYBa/VXOK/U4JBzu3oCMASOFj1gTbxwQSdLyqkUyurrvvvw6GafU/rwoxtQ0 ADLpSXK0c1Dm85jrKIpGEmKBA06CYlxO9bfsZLnQBsVS1X/2OHkE9e5s5gfQoDOIHL4r +7rA== 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=7aGB6YKBTk+KUGi0/gZBenNVn5/HApydUkfOauulcCI=; b=nCOPBYdWg7VMwMVMK0ENBpWhQzRwjDm+NENDmGYmlBSwNWHcbxJ+/LQYOCgDa/jwtV oEx7HJ2dyY40tHhmv2T20hUvlmeroBQNngMCSrlbLrJeLJLcF1xxS54QhO952i/ozUoE gIvSiHkC9rIuspjRUhIB9tCUWbvvGx/ZGsFuEX5emaeklGu8Abz/mZe59gmIu0T/J4ws DAqvUvqofgFm/ILUOhAkIqkJOktEYGLd+Y2f/yIKmsrUVpoZwhDtnGSg05kT5FnV8WHO cxjD7Md0xsUYNQ+Wz0uQZhl8j1eyn7d9UXcCl5uWqjBkySCb1UxLRday98TKTpZEfg5G po1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=ZozJPsYB; 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 n93si24518899qtd.151.2017.08.03.03.08.15 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 03 Aug 2017 03:08:16 -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.b=ZozJPsYB; 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]:53202 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ddD37-0001KR-9m for patch@linaro.org; Thu, 03 Aug 2017 06:08:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45639) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ddD1d-0000FF-2i for grub-devel@gnu.org; Thu, 03 Aug 2017 06:06:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ddD1b-00047S-QC for grub-devel@gnu.org; Thu, 03 Aug 2017 06:06:40 -0400 Received: from mail-wr0-x233.google.com ([2a00:1450:400c:c0c::233]:33438) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ddD1b-00046j-KG for grub-devel@gnu.org; Thu, 03 Aug 2017 06:06:39 -0400 Received: by mail-wr0-x233.google.com with SMTP id v105so3748750wrb.0 for ; Thu, 03 Aug 2017 03:06:39 -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=gHrAVhoJcXWnrRg4XXG++v9gSFD3iK9RZ/niy8QpZDA=; b=ZozJPsYB1NpYalgtzIuJJXMrEnlZGTPG4nli5iPNGaNoMABQaLL8/clGZzc+Qhk0k6 xajifSmPkfKJMGwBs9hIcCNBj4Gkfj9hgRNEPEQ7hvoQIz380wS+CqO6u/AEYc1ZAITH e136j4qHk/bRHQLkN5zBiNuF2rVidjCt33Qqs= 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=gHrAVhoJcXWnrRg4XXG++v9gSFD3iK9RZ/niy8QpZDA=; b=mKNAUmKvSsC1fy+JD6Hg2OkaJWWos6HQd+KDsNm1ghaSTR9yeZLcFkpASvgIShprfX wP99p+u7MUpauw3wFzdWhq3IPBsotZXiVGMTgHSduT+8P7JUwvbuyihqjCxH44Rf+yOa A2n3rFv+XrL8CUqjZdIdFNQjLEJTyhBsQpgaMpLZJttOnreyPHaG+L4fmUhXMTuYcFia D0GGYN21QAnM4tMR8X/NzocG9sOu6D7IZpsNYEQ/aBp2m8cqPZYrxAUAI7I8ITgNS9BX Ct84w4X0b9u/f30kR+vN5tVJolT/UUNDktgZVlwYZfcGkfz04GjRK18tHSR65n9cF6oE RlwQ== X-Gm-Message-State: AIVw1131bqrD1EP2rLOwI3XGy+8shfwoKr43os634yHPptKN59AO8kM5 0RMHVhDtasN5K8ZMemgS0A== X-Received: by 10.223.153.179 with SMTP id y48mr906591wrb.168.1501754798489; Thu, 03 Aug 2017 03:06:38 -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 e5sm2274543wre.24.2017.08.03.03.06.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 Aug 2017 03:06:37 -0700 (PDT) From: Leif Lindholm To: grub-devel@gnu.org Subject: [PATCH v2 04/14] efi: add grub_efi_get_ram_base() function for arm* Date: Thu, 3 Aug 2017 11:04:22 +0100 Message-Id: <20170803100432.29913-5-leif.lindholm@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170803100432.29913-1-leif.lindholm@linaro.org> References: <20170803100432.29913-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::233 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" Since ARM platforms do not have a common memory map, add a helper function that finds the lowest address region with the EFI_MEMORY_WB attribute set in the UEFI memory map. Required for the arm/arm64 linux loader to restrict the initrd location to where it will be accessible by the kernel at runtime. Signed-off-by: Leif Lindholm --- grub-core/kern/efi/mm.c | 36 ++++++++++++++++++++++++++++++++++++ include/grub/efi/efi.h | 3 +++ 2 files changed, 39 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 31ca703ec..8413c19e5 100644 --- a/grub-core/kern/efi/mm.c +++ b/grub-core/kern/efi/mm.c @@ -569,3 +569,39 @@ grub_efi_mm_init (void) grub_efi_free_pages ((grub_addr_t) memory_map, 2 * BYTES_TO_PAGES (MEMORY_MAP_SIZE)); } + +#if defined (__aarch64__) +grub_err_t +grub_efi_get_ram_base(grub_addr_t *base_addr) +{ + grub_efi_memory_descriptor_t *memory_map; + grub_efi_memory_descriptor_t *desc; + grub_efi_uintn_t mmap_size; + grub_efi_uintn_t desc_size; + int ret; + + mmap_size = grub_efi_find_mmap_size(); + + memory_map = grub_malloc (mmap_size); + if (! memory_map) + return GRUB_ERR_OUT_OF_MEMORY; + ret = grub_efi_get_memory_map (&mmap_size, memory_map, NULL, + &desc_size, NULL); + + if (ret < 1) + return GRUB_ERR_BUG; + + for (desc = memory_map, *base_addr = GRUB_UINT_MAX; + (grub_addr_t) desc < ((grub_addr_t) memory_map + mmap_size); + desc = NEXT_MEMORY_DESCRIPTOR (desc, desc_size)) + { + if (desc->attribute & GRUB_EFI_MEMORY_WB) + if (desc->physical_start < *base_addr) + *base_addr = desc->physical_start; + } + + grub_free(memory_map); + + return GRUB_ERR_NONE; +} +#endif diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h index 3984de083..80ab56795 100644 --- a/include/grub/efi/efi.h +++ b/include/grub/efi/efi.h @@ -85,6 +85,9 @@ extern void (*EXPORT_VAR(grub_efi_net_config)) (grub_efi_handle_t hnd, #if defined(__arm__) || defined(__aarch64__) void *EXPORT_FUNC(grub_efi_get_firmware_fdt)(void); #endif +#if defined(__aarch64__) +grub_err_t EXPORT_FUNC(grub_efi_get_ram_base)(grub_addr_t *); +#endif grub_addr_t grub_efi_modules_addr (void); From patchwork Thu Aug 3 10:04:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 109305 Delivered-To: patch@linaro.org Received: by 10.140.101.6 with SMTP id t6csp571188qge; Thu, 3 Aug 2017 03:08:15 -0700 (PDT) X-Received: by 10.200.52.56 with SMTP id u53mr1374106qtb.217.1501754895448; Thu, 03 Aug 2017 03:08:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501754895; cv=none; d=google.com; s=arc-20160816; b=yJRYqKERpmmVdsvn3gOm6dz6Y4wMXJkDHz9owrsfCDzW+TgC1Tbl6ewl9Gw93gqil1 GcH03lwVp1HxvvZY9s3ad0RG38oKNjY8XbgVfasd1Noat1/vdHnVR/jcs0NItkBtnNPJ mg5gzsKv9cdYj+tTVfe1PgvA/daHFk1GzGvO/cL9K4xHGp9RbkaodHAlXnREk34VgOLS D65myfTbNPsvimbwvaUjgidOAZpv4Q4vH4yN+Pz7f3JBSp5+E+KvlcH2qP0C4SN1NcHW JpkDoy+CnLpf2h7KpkbyrcZGocolmIVuw4NUbEV0UoIKVIiUK4Vc7QMtAa9ppUYi2OEo quDQ== 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=gqh7wbYWIMgap8yIEspKk+waNf0/oB8xlQsIhV5dB2s=; b=vCu0Tqs0vj2KmXsLmbA6zJ3b158i4R8WMlMw+6K9EmK+B6sNArlb9i5ayhoHWGLWeL 6I0ZEC/TRoMlPULATxogiqH8N+BiAzjKLH3hvqvl9VkN3xPbDkzfh07BTHiscybF9Ixy vYMo3gZNSazw8xJRhbgKs5itRQFci7EOKohf0bC4WcDyjynA/sya4dRP5KSHgfd0Rz4m 1PU8CkqGz3rNxc4KuzfNYuiEWeBfqHhHZEUhBlShCosfamDbo0XTMn27K7G1Jg/AWEcx jSK+tdeq67LNm0/3wa/MvI/D79rte2OtPjdCPTa1jtUSfKWC0yR1Ys3kmHA0uKXgOIc/ 7rjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=Dqkt0Ifi; 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 u13si16414058qki.491.2017.08.03.03.08.14 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 03 Aug 2017 03:08: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.b=Dqkt0Ifi; 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]:53201 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ddD36-0001Jt-MT for patch@linaro.org; Thu, 03 Aug 2017 06:08:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45706) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ddD1e-0000Fb-RF for grub-devel@gnu.org; Thu, 03 Aug 2017 06:06:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ddD1d-00049O-0C for grub-devel@gnu.org; Thu, 03 Aug 2017 06:06:42 -0400 Received: from mail-wr0-x233.google.com ([2a00:1450:400c:c0c::233]:38099) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ddD1c-00047g-HR for grub-devel@gnu.org; Thu, 03 Aug 2017 06:06:40 -0400 Received: by mail-wr0-x233.google.com with SMTP id f21so3672193wrf.5 for ; Thu, 03 Aug 2017 03:06:40 -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=wn+A0nQJ8FBf7rAkB9bwDeKM6oqavvFm8rPFncyeqMU=; b=Dqkt0Ifi6qwg4wj0q8Nj+4w3WRAe5DXZXok1QX/GSW2cYR2ek87mGX+AyfELcdy4IE Ncg3hxAq3F5zx5HOl/3+YWOgxdmUiLxc+pRvf7qGiTzuLWXUJIFKSvNxXOm1GGz2vl/B FxQNp71gZ0yXtvtR7cVd7nRbEenNZmjguTmls= 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=wn+A0nQJ8FBf7rAkB9bwDeKM6oqavvFm8rPFncyeqMU=; b=NmZuh5IY19Dz5m/tj1qdXR4hYKb2/IcUWsjbhNGSAtaR+UU4MZ47X2bhszKvCvKTLE WCao6dwIAatfgBV0FuhJl405h5fVMVpWWQf2MKNFlBgfmBuGgMAxiL4otKGQdw4KDs/Z +OXHPof88L7MzdtlKDRuHzX49O9aQ7UrZJws0Ar7tTCVS+PRuqc2JKObV86NKYUBlUeO 77uptqYy+xTJvKY9KuFk7a9HuFkbK4dBwrnIQKiZ9qjxF3wfJ2SVNO41LvcYocya7Wfg WFWrsFTDL/Gw0x0pE5FnFXCfLOCxQU9aetzXvHgMB/XgzRzh2Xaj6yUvjNAKMrNK4PAs 8iIw== X-Gm-Message-State: AIVw111KLOd4fWH5H5GoxIOeXNd3OOAwmRqLY8QyfSohV2qe4t57TT3j Qvctrsj+m0yXbrCKObDGoA== X-Received: by 10.223.154.203 with SMTP id a69mr894883wrc.139.1501754799341; Thu, 03 Aug 2017 03:06:39 -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 e5sm2274543wre.24.2017.08.03.03.06.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 Aug 2017 03:06:38 -0700 (PDT) From: Leif Lindholm To: grub-devel@gnu.org Subject: [PATCH v2 05/14] efi: refactor grub_efi_allocate_pages Date: Thu, 3 Aug 2017 11:04:23 +0100 Message-Id: <20170803100432.29913-6-leif.lindholm@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170803100432.29913-1-leif.lindholm@linaro.org> References: <20170803100432.29913-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::233 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" Expose a new function, grub_efi_allocate_pages_real(), making it possible to specify allocation type and memory type as supported by the UEFI AllocatePages boot service. Make grub_efi_allocate_pages() a consumer of the new function, maintaining its old functionality. Also delete some left-around #if 1/#else blocks in the affected functions. Signed-off-by: Leif Lindholm --- grub-core/kern/efi/mm.c | 46 ++++++++++++++++++++++++---------------------- include/grub/efi/efi.h | 5 +++++ 2 files changed, 29 insertions(+), 22 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/kern/efi/mm.c b/grub-core/kern/efi/mm.c index 8413c19e5..1e62eff8f 100644 --- a/grub-core/kern/efi/mm.c +++ b/grub-core/kern/efi/mm.c @@ -51,36 +51,20 @@ int grub_efi_is_finished = 0; /* Allocate pages. Return the pointer to the first of allocated pages. */ void * -grub_efi_allocate_pages (grub_efi_physical_address_t address, - grub_efi_uintn_t pages) +grub_efi_allocate_pages_real (grub_efi_physical_address_t address, + grub_efi_uintn_t pages, + grub_efi_allocate_type_t alloctype, + grub_efi_memory_type_t memtype) { - grub_efi_allocate_type_t type; grub_efi_status_t status; grub_efi_boot_services_t *b; -#if 1 /* Limit the memory access to less than 4GB for 32-bit platforms. */ if (address > GRUB_EFI_MAX_USABLE_ADDRESS) return 0; -#endif - -#if 1 - if (address == 0) - { - type = GRUB_EFI_ALLOCATE_MAX_ADDRESS; - address = GRUB_EFI_MAX_USABLE_ADDRESS; - } - else - type = GRUB_EFI_ALLOCATE_ADDRESS; -#else - if (address == 0) - type = GRUB_EFI_ALLOCATE_ANY_PAGES; - else - type = GRUB_EFI_ALLOCATE_ADDRESS; -#endif b = grub_efi_system_table->boot_services; - status = efi_call_4 (b->allocate_pages, type, GRUB_EFI_LOADER_DATA, pages, &address); + status = efi_call_4 (b->allocate_pages, alloctype, memtype, pages, &address); if (status != GRUB_EFI_SUCCESS) return 0; @@ -89,7 +73,7 @@ grub_efi_allocate_pages (grub_efi_physical_address_t address, /* Uggh, the address 0 was allocated... This is too annoying, so reallocate another one. */ address = GRUB_EFI_MAX_USABLE_ADDRESS; - status = efi_call_4 (b->allocate_pages, type, GRUB_EFI_LOADER_DATA, pages, &address); + status = efi_call_4 (b->allocate_pages, alloctype, memtype, pages, &address); grub_efi_free_pages (0, pages); if (status != GRUB_EFI_SUCCESS) return 0; @@ -98,6 +82,24 @@ grub_efi_allocate_pages (grub_efi_physical_address_t address, return (void *) ((grub_addr_t) address); } +void * +grub_efi_allocate_pages (grub_efi_physical_address_t address, + grub_efi_uintn_t pages) +{ + grub_efi_allocate_type_t alloctype; + + if (address == 0) + { + alloctype = GRUB_EFI_ALLOCATE_MAX_ADDRESS; + address = GRUB_EFI_MAX_USABLE_ADDRESS; + } + else + alloctype = GRUB_EFI_ALLOCATE_ADDRESS; + + return grub_efi_allocate_pages_real (address, pages, alloctype, + GRUB_EFI_LOADER_DATA); +} + /* Free pages starting from ADDRESS. */ void grub_efi_free_pages (grub_efi_physical_address_t address, diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h index 80ab56795..a58774efc 100644 --- a/include/grub/efi/efi.h +++ b/include/grub/efi/efi.h @@ -38,6 +38,11 @@ void *EXPORT_FUNC(grub_efi_open_protocol) (grub_efi_handle_t handle, int EXPORT_FUNC(grub_efi_set_text_mode) (int on); void EXPORT_FUNC(grub_efi_stall) (grub_efi_uintn_t microseconds); void * +EXPORT_FUNC(grub_efi_allocate_pages_real) (grub_efi_physical_address_t address, + grub_efi_uintn_t pages, + grub_efi_allocate_type_t alloctype, + grub_efi_memory_type_t memtype); +void * EXPORT_FUNC(grub_efi_allocate_pages) (grub_efi_physical_address_t address, grub_efi_uintn_t pages); void EXPORT_FUNC(grub_efi_free_pages) (grub_efi_physical_address_t address, From patchwork Thu Aug 3 10:04:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 109308 Delivered-To: patch@linaro.org Received: by 10.140.101.6 with SMTP id t6csp572485qge; Thu, 3 Aug 2017 03:09:33 -0700 (PDT) X-Received: by 10.237.53.83 with SMTP id b19mr1275786qte.312.1501754973040; Thu, 03 Aug 2017 03:09:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501754973; cv=none; d=google.com; s=arc-20160816; b=RBwtHwhwH4tML46q2JmuGvWUWHX82uamjrpbHDBeIDf9LMvQSQUfvEpL0JmrrwpI9A KODnYA8U1URsQNAKmS45a/QJ/FPaVjBBOUbPToik7Qg7OK3QCLjDVM1VBGHoyPLKqwZp u11ABgW8Q2ZArLwY3Eat/j10i4ao6eWommOo5Ux0ZRQ9PzEhJzI6E5b581N/BN1eOveg i0og533BjYTeL2oXyLXV2Hf8LCadeCQzXmX5SXYJgfWE/uarZlQvvMOgu/NqIv3xcdJP NdBELgw7itbhzmY1OhTO68prA+z6KWEb7u01naORBN6BzejaDrrKXuBnQejR3QW3AoFK CwSA== 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=jTam3tkLGxCMlCsFQXIsfRxcVj27SX/eKBCjceId+ow=; b=VNu1fk5r13BFMm0Wecj8KNMLOUd6sPoXaPvTC/DyhbW5qLMnHRpyvYlZ7uGrkt8v+l BAYV2C15OPh3SzRgojsUpUb+V3UQeq83tPaXf6SwB7puqgfWdPdi5zb1f+gCDk5lm90z f7ZyDDdMOgQpRxDtpv2NrQNXN4VSvDkd6OJRMUv6hGbdWKH731/c0ZrAywkJMJRE7lcC m8iH1Rsl2fZmX+/yWuZzZwK1PAO4QfCbgnLYXUiDUc+EcTIYkgKQoP5Ick2aXFIMaXRW o7Tr1htuOUkji4RiFx7XmeCp9kvqcL6WB1hVcyT5TQ3g5begrRQiQrZfDlNoxvlGMDvD hSxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=LijFimWn; 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 s63si12323415qkc.312.2017.08.03.03.09.32 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 03 Aug 2017 03:09:33 -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.b=LijFimWn; 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]:53219 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ddD4M-0002e4-9b for patch@linaro.org; Thu, 03 Aug 2017 06:09:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45724) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ddD1f-0000Fi-AQ for grub-devel@gnu.org; Thu, 03 Aug 2017 06:06:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ddD1d-0004A3-Q0 for grub-devel@gnu.org; Thu, 03 Aug 2017 06:06:43 -0400 Received: from mail-wr0-x22e.google.com ([2a00:1450:400c:c0c::22e]:33932) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ddD1d-000494-JE for grub-devel@gnu.org; Thu, 03 Aug 2017 06:06:41 -0400 Received: by mail-wr0-x22e.google.com with SMTP id 12so3743068wrb.1 for ; Thu, 03 Aug 2017 03:06:41 -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=zE8XQXD9Tg876JfUbF5mv2XKGvY2cG2l2k7hIDqe+94=; b=LijFimWnWRK/KxVTHpZwHI2q98wrx9LsB8LEWqYGuW0KdFvNtQ2MQAop/VJ1NSVz2J r18DkZbD9vHdef9GTpL7NaKn+GRtxObP3x68T8zG3Rl4Dg7qyzRv67Pw/BCMzPRphgDV q4v9y7qatmRqQhEftJWHpOPz0tbLYyzJFVGSc= 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=zE8XQXD9Tg876JfUbF5mv2XKGvY2cG2l2k7hIDqe+94=; b=VHW6IxTxNuSJJpVhE+70/eo50TseSiuFkF65L3xMTkJBG7HFjxgEc0LxCSFDf8CfFX LCAR6IoirLynpR1O7whqBpU/B6kCcL0R0olEzcL1eAnE1nsELEIQZrOLH5rY1XddFMGG /XFvEHYQ4s7saZbdcnZe/tBSrZiXQgGbzhY0Pnj97m6QCDALuR4PVJHnBxAslb2s+sPh ZHpw3e/8Ybb6rNgHjKAWe0DErEebjGCI7+CRicT/Nte6N3JXcoDMRrtoqBpG/Goi0SvM aFY5l6eX4heoHfWyD12Bc8rqCvCiOLRXJBIg1NwHbVHHNU20kWH3wm6zrL5LABctSGIE qDow== X-Gm-Message-State: AIVw112W2SLLqE4V0HuX81xMnXOhK4TpYfV4ixRMxA4IlAj5hx3SEBL0 NYaHWYLl7FciJwd5OOOhrg== X-Received: by 10.223.157.7 with SMTP id k7mr851258wre.43.1501754800301; Thu, 03 Aug 2017 03:06:40 -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 e5sm2274543wre.24.2017.08.03.03.06.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 Aug 2017 03:06:39 -0700 (PDT) From: Leif Lindholm To: grub-devel@gnu.org Subject: [PATCH v2 06/14] efi: move fdt helper library Date: Thu, 3 Aug 2017 11:04:24 +0100 Message-Id: <20170803100432.29913-7-leif.lindholm@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170803100432.29913-1-leif.lindholm@linaro.org> References: <20170803100432.29913-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::22e 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" There is nothing ARM64 (or even ARM) specific about the efi fdt helper library, which is used for locating or overriding a firmware-provided devicetree in a UEFI system - so move it to loader/efi for reuse. Move the fdtload.h include file to grub/efi and update path to efi/fdtload.h in source code referring to it. Signed-off-by: Leif Lindholm --- grub-core/Makefile.core.def | 2 +- grub-core/loader/arm64/linux.c | 2 +- grub-core/loader/arm64/xen_boot.c | 2 +- grub-core/loader/{arm64 => efi}/fdt.c | 2 +- include/grub/{arm64 => efi}/fdtload.h | 0 5 files changed, 4 insertions(+), 4 deletions(-) rename grub-core/loader/{arm64 => efi}/fdt.c (99%) rename include/grub/{arm64 => efi}/fdtload.h (100%) -- 2.11.0 _______________________________________________ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 1d86bd22e..a65c27f7f 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -1707,7 +1707,7 @@ module = { module = { name = fdt; - arm64 = loader/arm64/fdt.c; + arm64 = loader/efi/fdt.c; common = lib/fdt.c; enable = fdt; }; diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c index 1960d18b5..cac94d53d 100644 --- a/grub-core/loader/arm64/linux.c +++ b/grub-core/loader/arm64/linux.c @@ -26,8 +26,8 @@ #include #include #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 b7a5b17c9..d092a53ed 100644 --- a/grub-core/loader/arm64/xen_boot.c +++ b/grub-core/loader/arm64/xen_boot.c @@ -27,9 +27,9 @@ #include #include #include -#include #include #include +#include #include #include /* required by struct xen_hypervisor_header */ #include diff --git a/grub-core/loader/arm64/fdt.c b/grub-core/loader/efi/fdt.c similarity index 99% rename from grub-core/loader/arm64/fdt.c rename to grub-core/loader/efi/fdt.c index bdc3a0c1f..9715afee0 100644 --- a/grub-core/loader/arm64/fdt.c +++ b/grub-core/loader/efi/fdt.c @@ -18,12 +18,12 @@ #include #include -#include #include #include #include #include #include +#include #include static void *loaded_fdt; diff --git a/include/grub/arm64/fdtload.h b/include/grub/efi/fdtload.h similarity index 100% rename from include/grub/arm64/fdtload.h rename to include/grub/efi/fdtload.h From patchwork Thu Aug 3 10:04:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 109309 Delivered-To: patch@linaro.org Received: by 10.140.101.6 with SMTP id t6csp572557qge; Thu, 3 Aug 2017 03:09:37 -0700 (PDT) X-Received: by 10.200.8.188 with SMTP id v57mr1271468qth.213.1501754977342; Thu, 03 Aug 2017 03:09:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501754977; cv=none; d=google.com; s=arc-20160816; b=oeKOlfD567x8PxSBFBQzRJBQ3OoTiN8K2gsgKZbozvxlZqE0QRHv/nkjkAyYi8eTwD NtglmxqboBzRNAe1s8MXpyLmcnVaTWn5tHbXcpJsv1Iw2DXlxfeuv53am/O6czTruIeP fvTLafvIH7nLHiBRANrDXhB1QUl7Kf5dQvnyO1J6fDkESA8vQW8VBrG2YQztucfpwvhj yxYGir01DkjXYSKlsOZl5ACpHVf732SxKXYtU8kk5HeKpgI+7Op1+VTAxRdp2T1LhaLy yf7k75G15bWYaVdqGHKEik0R5OjYt7yczeplJD2iw4MPIq5IBkK4uhweKi30E7S17nxi Ukhw== 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=TSt13fs6OVUVa45QAkNsZwwV5wjMVndpuDC9uz5aQDs=; b=nrbUg02736ekgOUx3EJkXzjiyYToM4oeKyylg025k6I+WSHgc1WI5C8nbzw8Ki5z1i IoZei9YhELEnK+5tD6M0nY121cKUfIba4qA1JrclonE+r4ejGXyq8ufzfVhBPE1rv4dX 3d5GSJpz4GD3C5hkyyg8UQXs5g62ZjTIN4oPYi/VyKZmtHr1ZUrLS1BUAIdo2KhpACNY Hl9QReMWyh9PKxeOQQVLUfmpUDWlEi4pv9hJARbBiGWvljA/H1RRmJUptVFu9FFbn4fP L8DZKyBpvgk2z1iBGyf5CcedeolEnUmrmIWolcMALa1x9AJYMxDFeDi9L4/TKVYc/TdI 0Feg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=cLLpde98; 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 o52si31299864qto.230.2017.08.03.03.09.36 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 03 Aug 2017 03:09:37 -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.b=cLLpde98; 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]:53215 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ddD4Q-0001a5-O5 for patch@linaro.org; Thu, 03 Aug 2017 06:09:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45733) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ddD1f-0000Fw-NT for grub-devel@gnu.org; Thu, 03 Aug 2017 06:06:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ddD1e-0004B3-Go for grub-devel@gnu.org; Thu, 03 Aug 2017 06:06:43 -0400 Received: from mail-wr0-x234.google.com ([2a00:1450:400c:c0c::234]:38104) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ddD1e-00049u-6n for grub-devel@gnu.org; Thu, 03 Aug 2017 06:06:42 -0400 Received: by mail-wr0-x234.google.com with SMTP id f21so3672497wrf.5 for ; Thu, 03 Aug 2017 03:06:42 -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=CR11G9RTvme4c2Zf6y1HZTKvjrS3Hybar674t0v+DX0=; b=cLLpde98Mv70onaA9rCCuEhSDHq6a/Hi7sUY8W4b85eIUfqqAWwohJHUwjW3wrWLst BOeviCU3IkF81bONl2HbnfkaJ20LfBjXDQ/Y9P7Cv5ieQmwzf9tWeR1c0DsbSQYeyRCw 5AzAbMxaM517UpbYR8ZI+5Np8eVu884svxMow= 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=CR11G9RTvme4c2Zf6y1HZTKvjrS3Hybar674t0v+DX0=; b=mFd23Fv/blSyU9zDvNYSuXI5V2bM0SnlBUTRzfhd/xHIYRw/ITHm/OY0J0u9gQ/D/U tU4kKZXykzaY7o2b+mtHstnulkskxVMEI14Y7211G6tjqZiQ7juiOTca4kkaSLV+cMR6 +iQVs8IeqyqQ3nmWqwqE12HGx2uuD99ZUtwnPftjVsFJ77m34ubm2aL3rjCCI56nK5bB ZdgVh6YJMS1T6yPaIf4gCNy95LIBd2y6tmQkgM4QTPAr1JOG6VwUTPFZIKtuF96oy7xX xgkdrjTWOPHUlGEeZz5kWm98VBUMJtJEtk6PBn+7MJkgYKbDHum5ym9dFFcN1b6uxBZo TC3g== X-Gm-Message-State: AIVw110za7bQnVFQLOfPbD+HxiPnW1ukYiqtcWsg+LW1EMPEm4EF1liX Wn9X7fqFFrSpeydqIUe9uA== X-Received: by 10.223.176.247 with SMTP id j52mr859509wra.192.1501754801037; Thu, 03 Aug 2017 03:06:41 -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 e5sm2274543wre.24.2017.08.03.03.06.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 Aug 2017 03:06:40 -0700 (PDT) From: Leif Lindholm To: grub-devel@gnu.org Subject: [PATCH v2 07/14] efi: Add GRUB_PE32_MAGIC definition Date: Thu, 3 Aug 2017 11:04:25 +0100 Message-Id: <20170803100432.29913-8-leif.lindholm@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170803100432.29913-1-leif.lindholm@linaro.org> References: <20170803100432.29913-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::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: Daniel Kiper MIME-Version: 1.0 Errors-To: grub-devel-bounces+patch=linaro.org@gnu.org Sender: "Grub-devel" Add a generic GRUB_PE32_MAGIC definition for the PE 'MZ' tag and delete the existing one in arm64/linux.h. Update arm64 Linux loader to use this new definition. Signed-off-by: Leif Lindholm --- grub-core/loader/arm64/linux.c | 2 +- include/grub/arm64/linux.h | 2 -- include/grub/efi/pe32.h | 2 ++ 3 files changed, 3 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 cac94d53d..57ee43fac 100644 --- a/grub-core/loader/arm64/linux.c +++ b/grub-core/loader/arm64/linux.c @@ -53,7 +53,7 @@ grub_arm64_uefi_check_image (struct grub_arm64_linux_kernel_header * lh) if (lh->magic != GRUB_ARM64_LINUX_MAGIC) return grub_error(GRUB_ERR_BAD_OS, "invalid magic number"); - if ((lh->code0 & 0xffff) != GRUB_EFI_PE_MAGIC) + if ((lh->code0 & 0xffff) != GRUB_PE32_MAGIC) return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, N_("plain image kernel not supported - rebuild with CONFIG_(U)EFI_STUB enabled")); diff --git a/include/grub/arm64/linux.h b/include/grub/arm64/linux.h index 1ea23696e..a981df5d1 100644 --- a/include/grub/arm64/linux.h +++ b/include/grub/arm64/linux.h @@ -23,8 +23,6 @@ #define GRUB_ARM64_LINUX_MAGIC 0x644d5241 /* 'ARM\x64' */ -#define GRUB_EFI_PE_MAGIC 0x5A4D - /* From linux/Documentation/arm64/booting.txt */ struct grub_arm64_linux_kernel_header { diff --git a/include/grub/efi/pe32.h b/include/grub/efi/pe32.h index f79c36c02..7d44732d2 100644 --- a/include/grub/efi/pe32.h +++ b/include/grub/efi/pe32.h @@ -45,6 +45,8 @@ #define GRUB_PE32_MSDOS_STUB_SIZE 0x80 +#define GRUB_PE32_MAGIC 0x5a4d + /* According to the spec, the minimal alignment is 512 bytes... But some examples (such as EFI drivers in the Intel Sample Implementation) use 32 bytes (0x20) instead, and it seems From patchwork Thu Aug 3 10:04:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 109310 Delivered-To: patch@linaro.org Received: by 10.140.101.6 with SMTP id t6csp573366qge; Thu, 3 Aug 2017 03:10:28 -0700 (PDT) X-Received: by 10.237.34.180 with SMTP id p49mr1315436qtc.163.1501755027962; Thu, 03 Aug 2017 03:10:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501755027; cv=none; d=google.com; s=arc-20160816; b=LFvzLCs5pa8bXx56MWfvgPeVx29ciFxrYRLq516KCrptyJhHLS2s5YycNoAJWFMQln 5+U5jeWdn2wXW0cnsfj0reDofKCZdKZjb8QoXQ1fqRNtd4pmluksoBucABZHas60yFAN GkEHqoB8J5583c2749xAR9pPwdLe4qhKrZZzB3gWkMw9PaT+oyuKA2/l2C/C2Xg8vga3 L6cuBCujkPAasxOEx6Y2ea0J6ftExljrMQExFd4exEp1+/hsJvmWY34j/mmAPxnQct/B /PtSdwYjKSuen+HZm3gP0iDzalOuwCSx4bIJT80kiJ53aqdgKFTGwYY1Lg+siITNMaNs INxQ== 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=2EbIRiJqK14hzPpToOanEeBgwHByGWgLVuRMLgsZ8xM=; b=q/VkrmaEZIym/+YDxN+qjqiJZoMIqX6rfNxXVpqXtVpQp7wu4NMj0G/Orpxk2jMXyD jxmk1hT1RhB5Ri1hmeWnkjhgtTU4rlmV7Ug2OI8uvjhIWghU0qY3i567t63QDv4Q8UKz sABLMv4R8DKouY7wlhjdUWQqcDPcag5w8MIlvZUXvY0etrhc8T0kAY1vujyGUArZbj/+ n5jnXgCmB/2DhTV6Ry9dWSGwk7hOr9/Q/Wm98hrX1K51Xs4zMhAIxLAChTWqqEpdwyxB xZ2BmC8Qbyd+Yh7U/r487CrZYWUEeo1SEQTfNJy/XmGP5rZoPGoKW9fk78QiTGh38FRh GCjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=driwqUnS; 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 j4si32920919qkh.52.2017.08.03.03.10.26 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 03 Aug 2017 03:10:27 -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.b=driwqUnS; 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]:53216 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ddD5E-0002cv-4G for patch@linaro.org; Thu, 03 Aug 2017 06:10:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45761) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ddD1g-0000Hr-Qb for grub-devel@gnu.org; Thu, 03 Aug 2017 06:06:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ddD1f-0004By-CI for grub-devel@gnu.org; Thu, 03 Aug 2017 06:06:44 -0400 Received: from mail-wr0-x236.google.com ([2a00:1450:400c:c0c::236]:37236) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ddD1f-0004Az-4j for grub-devel@gnu.org; Thu, 03 Aug 2017 06:06:43 -0400 Received: by mail-wr0-x236.google.com with SMTP id 33so3716645wrz.4 for ; Thu, 03 Aug 2017 03:06:43 -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=SIHJipF/O4IOnL2Qn2/rXLcwLZRoT04WyhYqUH1AGU4=; b=driwqUnSGGpvy8Wi4yWz6FiuAWKsbqHhA7BidM2Ffkv2X5ZJ0K7dSYOP0sK6ojiKGJ HLN5zGstcXGYO4IypBnGMy6ecneqlXmW+gXSmsQ8nq45xmWXUEbZCbS7czTYO5gEjsAA 1pM0emPdorD4gnaMxwWYYMVCiVK5IMv6VnIlM= 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=SIHJipF/O4IOnL2Qn2/rXLcwLZRoT04WyhYqUH1AGU4=; b=P8rQ5KU23xWnVhkmaZPGewvbwVlSETMs9AjGA7T7A/c8Lnhj29+182nXgLVjAAuyXO AEdP327Dumvv0bs91qGR8kH3Hu4KF76LFgj5jH7TJVWnJGP4a2dRnfZ45rwqYI/e9GGY zSnE45aeBa0LHX4YvxI77AuN2d7WJuFtwWXBPKM+ce2GVHQl1ZPD2ncxcCk+OhdF61aK ur6VN/TTCEhze9d7JVPMzJzx5Lq5Dj2MXDwPLL+9LFQ1fN3LFvbocVDswQFOCEca8i3L jEf4W//tuBuDqAqooY3u47Kbd7VfbV1D/S92OAflMwTjTyJU9HiG4DNJRQSmU5c+q/RP eD3w== X-Gm-Message-State: AIVw112vV2YCIiTRa7Slro3VJR+gUFgHWe3znj2G0lwTwI5uYydIXsWX LXxouqgiPWd6Jh1tqjRX+g== X-Received: by 10.223.163.135 with SMTP id l7mr1033777wrb.89.1501754801858; Thu, 03 Aug 2017 03:06:41 -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 e5sm2274543wre.24.2017.08.03.03.06.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 Aug 2017 03:06:41 -0700 (PDT) From: Leif Lindholm To: grub-devel@gnu.org Subject: [PATCH v2 08/14] arm64 linux loader: improve type portability Date: Thu, 3 Aug 2017 11:04:26 +0100 Message-Id: <20170803100432.29913-9-leif.lindholm@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170803100432.29913-1-leif.lindholm@linaro.org> References: <20170803100432.29913-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::236 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" In preparation for turning this into a common loader for 32-bit and 64-bit platforms, ensure the code will compile cleanly for either. Signed-off-by: Leif Lindholm --- grub-core/loader/arm64/linux.c | 15 ++++++--------- grub-core/loader/efi/fdt.c | 8 ++++---- 2 files changed, 10 insertions(+), 13 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 57ee43fac..c60469e53 100644 --- a/grub-core/loader/arm64/linux.c +++ b/grub-core/loader/arm64/linux.c @@ -58,8 +58,6 @@ grub_arm64_uefi_check_image (struct grub_arm64_linux_kernel_header * lh) N_("plain image kernel not supported - rebuild with CONFIG_(U)EFI_STUB enabled")); grub_dprintf ("linux", "UEFI stub kernel:\n"); - grub_dprintf ("linux", "text_offset = 0x%012llx\n", - (long long unsigned) lh->text_offset); grub_dprintf ("linux", "PE/COFF header @ %08x\n", lh->hdr_offset); return GRUB_ERR_NONE; @@ -87,8 +85,8 @@ finalize_params_linux (void) /* Set initrd info */ if (initrd_start && initrd_end > initrd_start) { - grub_dprintf ("linux", "Initrd @ 0x%012lx-0x%012lx\n", - initrd_start, initrd_end); + grub_dprintf ("linux", "Initrd @ %p-%p\n", + (void *) initrd_start, (void *) initrd_end); retval = grub_fdt_set_prop64 (fdt, node, "linux,initrd-start", initrd_start); @@ -163,7 +161,7 @@ grub_arm64_uefi_boot_image (grub_addr_t addr, grub_size_t size, char *args) /* When successful, not reached */ b->unload_image (image_handle); - grub_efi_free_pages ((grub_efi_physical_address_t) loaded_image->load_options, + grub_efi_free_pages ((grub_addr_t) loaded_image->load_options, GRUB_EFI_BYTES_TO_PAGES (loaded_image->load_options_size)); return grub_errno; @@ -190,7 +188,7 @@ grub_linux_unload (void) initrd_start = initrd_end = 0; grub_free (linux_args); if (kernel_addr) - grub_efi_free_pages ((grub_efi_physical_address_t) kernel_addr, + grub_efi_free_pages ((grub_addr_t) kernel_addr, GRUB_EFI_BYTES_TO_PAGES (kernel_size)); grub_fdt_unload (); return GRUB_ERR_NONE; @@ -242,8 +240,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), fail: grub_initrd_close (&initrd_ctx); if (initrd_mem && !initrd_start) - grub_efi_free_pages ((grub_efi_physical_address_t) initrd_mem, - initrd_pages); + grub_efi_free_pages ((grub_addr_t) initrd_mem, initrd_pages); return grub_errno; } @@ -330,7 +327,7 @@ fail: grub_free (linux_args); if (kernel_addr && !loaded) - grub_efi_free_pages ((grub_efi_physical_address_t) kernel_addr, + grub_efi_free_pages ((grub_addr_t) kernel_addr, GRUB_EFI_BYTES_TO_PAGES (kernel_size)); return grub_errno; diff --git a/grub-core/loader/efi/fdt.c b/grub-core/loader/efi/fdt.c index 9715afee0..08bdb3d51 100644 --- a/grub-core/loader/efi/fdt.c +++ b/grub-core/loader/efi/fdt.c @@ -33,12 +33,12 @@ void * grub_fdt_load (grub_size_t additional_size) { void *raw_fdt; - grub_size_t size; + unsigned int size; if (fdt) { size = GRUB_EFI_BYTES_TO_PAGES (grub_fdt_get_totalsize (fdt)); - grub_efi_free_pages ((grub_efi_physical_address_t) fdt, size); + grub_efi_free_pages ((grub_addr_t) fdt, size); } if (loaded_fdt) @@ -50,7 +50,7 @@ grub_fdt_load (grub_size_t additional_size) raw_fdt ? grub_fdt_get_totalsize (raw_fdt) : GRUB_FDT_EMPTY_TREE_SZ; size += additional_size; - grub_dprintf ("linux", "allocating %ld bytes for fdt\n", size); + grub_dprintf ("linux", "allocating %d bytes for fdt\n", size); fdt = grub_efi_allocate_pages (0, GRUB_EFI_BYTES_TO_PAGES (size)); if (!fdt) return NULL; @@ -89,7 +89,7 @@ grub_fdt_unload (void) { if (!fdt) { return; } - grub_efi_free_pages ((grub_efi_physical_address_t) fdt, + grub_efi_free_pages ((grub_addr_t) fdt, GRUB_EFI_BYTES_TO_PAGES (grub_fdt_get_totalsize (fdt))); fdt = NULL; } From patchwork Thu Aug 3 10:04:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 109313 Delivered-To: patch@linaro.org Received: by 10.182.45.195 with SMTP id p3csp681951obm; Thu, 3 Aug 2017 03:14:40 -0700 (PDT) X-Received: by 10.200.34.100 with SMTP id p33mr1451639qtp.87.1501755280340; Thu, 03 Aug 2017 03:14:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501755280; cv=none; d=google.com; s=arc-20160816; b=tQVGWsHoyMwowds8QsTUVaDMwwvlkZqYRffvnOnhvZkxg4MxkAJ7Gw5U1ixrRXQt0l TQxNjravcsqct8jwuODTdXf0nNPa/zdtexweAuvjSiJawwsLuMSse3Z8nP/rYhJfSQsm jKkbvz0MwoMfZQo/ovQp2QCb0kmZMelfm3ANOfrtVx92j0+1xXzUqOK4Lsz4RcYNiIth T4ECh1PBLCwSc2VRw56sOOcV5gI+Ejhbqdl2yNpRFKlwwixy9cDM4Vl6jh38RrguJT64 WbNtvrBjj2C4saUAVVcElK9I6dLypox4MN7FLXGYxcLgG/45m79OnT9+TlYGATHDx1M4 UaTw== 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=TwFpKIfLCA24XyuU1RWHY0ZdRxJPvIxPmMQSlSZDCi4=; b=ftFmmBSz5/SGpG/HvfuKgX9Aw1K0Wq3GkfEjfjhO/+5bs9ETPK0+Dnz9Bx+Qbt34GD +j1Xm4LyJEfYk5PglZb4zU2WL63v68JFan5Ku527ESCnTodmXwIQSJuYC9l9WLXQmW1d dfMu3Fg0LfgGRp77eBoieOmPfdCQMYH8n4qtxAaOne+43+IrOqJb3Y4g9Pxl4QMOMuQb 40Omnxg7RdlJP+83qhp6GIl9NbnZE+zEuC0eKmGMFjw7ddy18EMUc798qC9vkFr6xIXk dbq6wMKz6gw/KH8hz54zoWwdrTPp3yAQR6eE2ltfm/hrb+eHGH/esB8aacs0eFdArIsO qDYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=jiEX8RuP; 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 a58si15582004qte.299.2017.08.03.03.14.39 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 03 Aug 2017 03:14:40 -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.b=jiEX8RuP; 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]:53649 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ddD9J-00068U-Nq for patch@linaro.org; Thu, 03 Aug 2017 06:14:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45793) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ddD1h-0000Io-NF for grub-devel@gnu.org; Thu, 03 Aug 2017 06:06:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ddD1g-0004Cw-Ax for grub-devel@gnu.org; Thu, 03 Aug 2017 06:06:45 -0400 Received: from mail-wm0-x233.google.com ([2a00:1450:400c:c09::233]:37148) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ddD1g-0004Bw-1J for grub-devel@gnu.org; Thu, 03 Aug 2017 06:06:44 -0400 Received: by mail-wm0-x233.google.com with SMTP id t201so10938146wmt.0 for ; Thu, 03 Aug 2017 03:06:43 -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=wrfXdUy48J8ogmQZW+8/snGy1D8l1O7lkTgB+WS0ryw=; b=jiEX8RuPz0srAToLUkcBJ2JutK5mZEW8ufhrm6GQLS7sZMDNslbaIRtYLe1gHvqUwA 1snRXiEO6wdYRJQmNBRdmp+d3po9li5CE+c8XW45bVXBrenycjP2Fwa6qgXqOHojWlBO qmnMw4UeZwqTiWKOgCQI2avaXwoH3K0OgI31s= 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=wrfXdUy48J8ogmQZW+8/snGy1D8l1O7lkTgB+WS0ryw=; b=jUdmUF5oS1kPanFCd2kluZBGM7PKLglH0XTkGUflF7D8ZLBDVLF+RlKWJdVe7S56+s B0+Wh8Tltd+3ulUFC/3kgwbb17MNabkskW/lXfEf8tcIAnvTcxJV0e1GKpKAMmWPMiyG uISekcf9/oUGW1G9cuz6iDzlgwgl/AjbZO5DV5hsx4xJPaNNe+FS+eGztguCk8QIwKHJ yplqKO206croEJHVgwpTMcXEs8yCrKg0K/yXWoLOUNC+LXseTrG+jyx2S0FGFdiiqc5Y +Zzg6g7Dp8e6axYYpx9q/zNLyDyQ/U2BqHuYcK6+f48+hJ4iOGDmAvNrS9bWfh1nJv/T AxSA== X-Gm-Message-State: AIVw113I+Dspd70m6ZBU0FSa9KDWnUUMVnDRoK0aCDElLlM08lWm+QpM 1/rV47qpeCaxPBsu1bK16g== X-Received: by 10.28.60.11 with SMTP id j11mr812720wma.47.1501754802703; Thu, 03 Aug 2017 03:06:42 -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 e5sm2274543wre.24.2017.08.03.03.06.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 Aug 2017 03:06:42 -0700 (PDT) From: Leif Lindholm To: grub-devel@gnu.org Subject: [PATCH v2 09/14] arm64 linux loader: rename functions and macros and move to common headers Date: Thu, 3 Aug 2017 11:04:27 +0100 Message-Id: <20170803100432.29913-10-leif.lindholm@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170803100432.29913-1-leif.lindholm@linaro.org> References: <20170803100432.29913-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::233 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" In preparation for using the linux loader for 32-bit and 64-bit platforms, rename grub_arm64*/GRUB_ARM64* to grub_efi*/GRUB_EFI*. Move prototypes for now-common functions to efi/efi.h. Signed-off-by: Leif Lindholm --- grub-core/loader/arm64/linux.c | 14 +++++++------- grub-core/loader/arm64/xen_boot.c | 12 ++++++------ include/grub/arm64/linux.h | 11 ++--------- include/grub/efi/efi.h | 4 ++++ 4 files changed, 19 insertions(+), 22 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 c60469e53..8cd44230d 100644 --- a/grub-core/loader/arm64/linux.c +++ b/grub-core/loader/arm64/linux.c @@ -48,9 +48,9 @@ static grub_addr_t initrd_start; static grub_addr_t initrd_end; grub_err_t -grub_arm64_uefi_check_image (struct grub_arm64_linux_kernel_header * lh) +grub_efi_linux_check_image (struct grub_linux_kernel_header * lh) { - if (lh->magic != GRUB_ARM64_LINUX_MAGIC) + if (lh->magic != GRUB_LINUX_MAGIC_SIGNATURE) return grub_error(GRUB_ERR_BAD_OS, "invalid magic number"); if ((lh->code0 & 0xffff) != GRUB_PE32_MAGIC) @@ -109,7 +109,7 @@ failure: } grub_err_t -grub_arm64_uefi_boot_image (grub_addr_t addr, grub_size_t size, char *args) +grub_efi_linux_boot_image (grub_addr_t addr, grub_size_t size, char *args) { grub_efi_memory_mapped_device_path_t *mempath; grub_efi_handle_t image_handle; @@ -173,8 +173,8 @@ grub_linux_boot (void) if (finalize_params_linux () != GRUB_ERR_NONE) return grub_errno; - return (grub_arm64_uefi_boot_image((grub_addr_t)kernel_addr, - kernel_size, linux_args)); + return (grub_efi_linux_boot_image((grub_addr_t)kernel_addr, + kernel_size, linux_args)); } static grub_err_t @@ -250,7 +250,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), int argc, char *argv[]) { grub_file_t file = 0; - struct grub_arm64_linux_kernel_header lh; + struct grub_linux_kernel_header lh; grub_dl_ref (my_mod); @@ -269,7 +269,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), if (grub_file_read (file, &lh, sizeof (lh)) < (long) sizeof (lh)) return grub_errno; - if (grub_arm64_uefi_check_image (&lh) != GRUB_ERR_NONE) + if (grub_efi_linux_check_image (&lh) != GRUB_ERR_NONE) goto fail; grub_loader_unset(); diff --git a/grub-core/loader/arm64/xen_boot.c b/grub-core/loader/arm64/xen_boot.c index d092a53ed..e8720584b 100644 --- a/grub-core/loader/arm64/xen_boot.c +++ b/grub-core/loader/arm64/xen_boot.c @@ -67,7 +67,7 @@ typedef enum module_type module_type_t; struct xen_hypervisor_header { - struct grub_arm64_linux_kernel_header efi_head; + struct grub_linux_kernel_header efi_head; /* This is always PE\0\0. */ grub_uint8_t signature[GRUB_PE32_SIGNATURE_SIZE]; @@ -254,9 +254,9 @@ xen_boot (void) if (err) return err; - return grub_arm64_uefi_boot_image (xen_hypervisor->start, - xen_hypervisor->size, - xen_hypervisor->cmdline); + return grub_efi_linux_boot_image (xen_hypervisor->start, + xen_hypervisor->size, + xen_hypervisor->cmdline); } static void @@ -458,8 +458,8 @@ grub_cmd_xen_hypervisor (grub_command_t cmd __attribute__ ((unused)), if (grub_file_read (file, &sh, sizeof (sh)) != (long) sizeof (sh)) goto fail; - if (grub_arm64_uefi_check_image - ((struct grub_arm64_linux_kernel_header *) &sh) != GRUB_ERR_NONE) + if (grub_efi_linux_check_image + ((struct grub_linux_kernel_header *) &sh) != GRUB_ERR_NONE) goto fail; grub_file_seek (file, 0); diff --git a/include/grub/arm64/linux.h b/include/grub/arm64/linux.h index a981df5d1..e53be83b1 100644 --- a/include/grub/arm64/linux.h +++ b/include/grub/arm64/linux.h @@ -19,12 +19,10 @@ #ifndef GRUB_LINUX_CPU_HEADER #define GRUB_LINUX_CPU_HEADER 1 -#include - -#define GRUB_ARM64_LINUX_MAGIC 0x644d5241 /* 'ARM\x64' */ +#define GRUB_LINUX_MAGIC_SIGNATURE 0x644d5241 /* 'ARM\x64' */ /* From linux/Documentation/arm64/booting.txt */ -struct grub_arm64_linux_kernel_header +struct grub_linux_kernel_header { grub_uint32_t code0; /* Executable code */ grub_uint32_t code1; /* Executable code */ @@ -38,9 +36,4 @@ struct grub_arm64_linux_kernel_header grub_uint32_t hdr_offset; /* Offset of PE/COFF header */ }; -grub_err_t grub_arm64_uefi_check_image (struct grub_arm64_linux_kernel_header - *lh); -grub_err_t grub_arm64_uefi_boot_image (grub_addr_t addr, grub_size_t size, - char *args); - #endif /* ! GRUB_LINUX_CPU_HEADER */ diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h index a58774efc..149969941 100644 --- a/include/grub/efi/efi.h +++ b/include/grub/efi/efi.h @@ -92,6 +92,10 @@ void *EXPORT_FUNC(grub_efi_get_firmware_fdt)(void); #endif #if defined(__aarch64__) grub_err_t EXPORT_FUNC(grub_efi_get_ram_base)(grub_addr_t *); +#include +grub_err_t grub_efi_linux_check_image(struct grub_linux_kernel_header *lh); +grub_err_t grub_efi_linux_boot_image(grub_addr_t addr, grub_size_t size, + char *args); #endif grub_addr_t grub_efi_modules_addr (void); From patchwork Thu Aug 3 10:04:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 109314 Delivered-To: patch@linaro.org Received: by 10.182.45.195 with SMTP id p3csp682073obm; Thu, 3 Aug 2017 03:14:47 -0700 (PDT) X-Received: by 10.55.46.5 with SMTP id u5mr1522341qkh.217.1501755287755; Thu, 03 Aug 2017 03:14:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501755287; cv=none; d=google.com; s=arc-20160816; b=lkXvhBDkoacg6KLWmnOFJ8TMfPGLNCx7xDwtqR7d89mEXoyyLjYVFpU1T4pXp6ER2c oF6PR7MPLsBqZBuNAFc8MvvLK6iaXtY+lDnMLX0zvrpEOmzBJ1gvOzKVYSJFqdiTOXcW ADL7i85D9X9trHvfk+OJydemIrcHPmrRPzufOnmiPA/P3yUmQACF4RRvNS8xyUBU6Hxj MkF7X6stsvBBo/kDBHVzz+4yiKiZ3dJ2UujMj2qN7DDEJ65hVXzhqgzd1lxMXSH+EHVu AbkC7RiQqCBEaebl8LcjVrjjP6KZ0Q3Mr9Q/aVSbyRv1QJ9bwzE5B5ZrgakNObizkIUT J7BQ== 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=a8njvOoipjMcVTrzOjIENBsQ4PoLHeuGMMxGLH5xW3k=; b=ojHNkR3xJmDsuvtDz1oJMuh9erfUNlB29MNHUwfpja/vZNMkOe3WGbX7YlrfK1uPds D3vH4nBP9bjv2d1Wi6L5GjesWuJN2ufBpbTp58c8rZUxEZBPXjvlDm1ZPDsOeNRyJMW4 5Q6sH19isph5Feqq+PsCLZWc41YPoj0IQHa3u/pK8Dk0EtCxB9FuK0SMUXGAZQNqhumZ iHGCjucYvQ+3yBbtc4KncyUtR+bDTopqVwA2doM9F1kIQeUeVCn8CDvi/9pDB8RYrDAa DicnNDtkwWjad3CIeYiCmaHeq8rs3taJlPYnFAvkPJgzls/O1X3gARz9nmE1IqB9YVG1 XWsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=UWM0/k5Q; 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 v66si33524532qkg.412.2017.08.03.03.14.47 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 03 Aug 2017 03:14:47 -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.b=UWM0/k5Q; 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]:53690 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ddD9R-0006ik-4D for patch@linaro.org; Thu, 03 Aug 2017 06:14:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45798) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ddD1i-0000JE-2N for grub-devel@gnu.org; Thu, 03 Aug 2017 06:06:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ddD1g-0004Df-UL for grub-devel@gnu.org; Thu, 03 Aug 2017 06:06:46 -0400 Received: from mail-wr0-x22d.google.com ([2a00:1450:400c:c0c::22d]:33452) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ddD1g-0004Cj-P3 for grub-devel@gnu.org; Thu, 03 Aug 2017 06:06:44 -0400 Received: by mail-wr0-x22d.google.com with SMTP id v105so3749582wrb.0 for ; Thu, 03 Aug 2017 03:06:44 -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=fXpxaReeT5087QhzCzQlNSj+V2+B1ARzUqTjd/rxd6o=; b=UWM0/k5QF0Zq46FaVKpXRttsEkCvHBc82uHiwoM8XIrgLDarlOVDOtzNLCXZCLCphD 9ewxdXzkl+NAyhEKNmWZdf7FbzAMXvE1DwISdmTgYo3hiEZS3uBgHKWtWi7TVD3EM43Q 1mtSaCeo2P8b3zD+PFBL7C9Ui88QxMRFfgrz0= 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=fXpxaReeT5087QhzCzQlNSj+V2+B1ARzUqTjd/rxd6o=; b=NDB5Tteb0AZS0koL5rekQs3XK+Fw9lpVpcbGUGGZoD1RB9O9ChmAC6JWF9b/MIim4q pQWvbyAcSbXeyxkOJQrWoUGkFmEN9G5nTOWDpuxJUPXP+Cuih2byAUIzOdu45zlETe2X V9hz5tuLP0rdtEEeO83n+cEqw9eSlFtzeL3Bc6MfdJdiWZlGHRGHnDqwivFMJJxLFL0a E2gYi0yf6pPRNKhp2zzWv2mqr0NdVIGRWHt8R0hgI3gSVDM1x7H7RwyLSsWvMBiCyMpu Ma8wG1gaiW5KstgNYYHN7zdJynwIBD9nZnsnCiC0IQtZLETIXe/9t7JdKMDp+EsUNPc6 1lRQ== X-Gm-Message-State: AHYfb5g0+QNs6YHhYbovrZ4gg9ymZrXbCneBQNBB0bbWkQby9sZVlzDO GuD1YOZDg/8VE1VlZYCWSw== X-Received: by 10.223.148.162 with SMTP id 31mr914018wrr.28.1501754803495; Thu, 03 Aug 2017 03:06:43 -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 e5sm2274543wre.24.2017.08.03.03.06.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 Aug 2017 03:06:42 -0700 (PDT) From: Leif Lindholm To: grub-devel@gnu.org Subject: [PATCH v2 10/14] loader: switch arm/linux to grub_linux_kernel_header struct Date: Thu, 3 Aug 2017 11:04:28 +0100 Message-Id: <20170803100432.29913-11-leif.lindholm@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170803100432.29913-1-leif.lindholm@linaro.org> References: <20170803100432.29913-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: Daniel Kiper MIME-Version: 1.0 Errors-To: grub-devel-bounces+patch=linaro.org@gnu.org Sender: "Grub-devel" Use kernel header struct and generic magic definition to align with arm64/linux loader. Signed-off-by: Leif Lindholm --- grub-core/loader/arm/linux.c | 11 +++++------ include/grub/arm/linux.h | 15 ++++++++++++--- 2 files changed, 17 insertions(+), 9 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/arm/linux.c b/grub-core/loader/arm/linux.c index e64c79a95..067f69894 100644 --- a/grub-core/loader/arm/linux.c +++ b/grub-core/loader/arm/linux.c @@ -46,9 +46,6 @@ static const void *current_fdt; typedef void (*kernel_entry_t) (int, unsigned long, void *); -#define LINUX_ZIMAGE_OFFSET 0x24 -#define LINUX_ZIMAGE_MAGIC 0x016f2818 - #define LINUX_PHYS_OFFSET (0x00008000) #define LINUX_INITRD_PHYS_OFFSET (LINUX_PHYS_OFFSET + 0x02000000) #define LINUX_FDT_PHYS_OFFSET (LINUX_INITRD_PHYS_OFFSET - 0x10000) @@ -315,6 +312,7 @@ linux_boot (void) static grub_err_t linux_load (const char *filename, grub_file_t file) { + struct grub_linux_kernel_header *lh; int size; size = grub_file_size (file); @@ -337,9 +335,10 @@ linux_load (const char *filename, grub_file_t file) return grub_errno; } - if (size > LINUX_ZIMAGE_OFFSET + 4 - && *(grub_uint32_t *) (linux_addr + LINUX_ZIMAGE_OFFSET) - == LINUX_ZIMAGE_MAGIC) + lh = (void *) linux_addr; + + if ((grub_size_t) size > sizeof (*lh) && + lh->magic == GRUB_LINUX_MAGIC_SIGNATURE) ; else if (size > 0x8000 && *(grub_uint32_t *) (linux_addr) == 0xea000006 && machine_type == GRUB_ARM_MACHINE_TYPE_RASPBERRY_PI) diff --git a/include/grub/arm/linux.h b/include/grub/arm/linux.h index f217f8281..802090239 100644 --- a/include/grub/arm/linux.h +++ b/include/grub/arm/linux.h @@ -20,11 +20,20 @@ #ifndef GRUB_LINUX_CPU_HEADER #define GRUB_LINUX_CPU_HEADER 1 -#define LINUX_ZIMAGE_OFFSET 0x24 -#define LINUX_ZIMAGE_MAGIC 0x016f2818 - #include "system.h" +#define GRUB_LINUX_MAGIC_SIGNATURE 0x016f2818 + +struct grub_linux_kernel_header { + grub_uint32_t code0; + grub_uint32_t reserved1[8]; + grub_uint32_t magic; + grub_uint32_t start; /* _start */ + grub_uint32_t end; /* _edata */ + grub_uint32_t reserved2[4]; + grub_uint32_t hdr_offset; +}; + #if defined GRUB_MACHINE_UBOOT # include # define LINUX_ADDRESS (start_of_ram + 0x8000) From patchwork Thu Aug 3 10:04:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 109311 Delivered-To: patch@linaro.org Received: by 10.140.101.6 with SMTP id t6csp573572qge; Thu, 3 Aug 2017 03:10:39 -0700 (PDT) X-Received: by 10.55.110.133 with SMTP id j127mr1704049qkc.92.1501755039086; Thu, 03 Aug 2017 03:10:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501755039; cv=none; d=google.com; s=arc-20160816; b=mSSDrcXyxDCJkFK+2QsgHkYLhoD+uvzf4ckyv9F9jO3KX4DP1k9ZUlRGFmWuyqmk65 bgrDba0J4KY16eet53hdKjmWpeGkqg+w51E8pIsbGLFAQsDVYXO4W1EEh3D0tMeYElZW u/pxL/fvQvEmMRD8gGBNQuT/8JFx422sOKhKGSurwOU7Jp1/FRoIcagxNVSieiGvpQ1P bmQu29gYRlIxEobr4giSXKXJoqVjlTSRAo4gIVLy3v+kAkZz1i8MkBJW3fZRhAxh4NkF 1nH0pPN/Nm+3THaRdbiAJBTF0EaoNYlGtpb51a4aPNnZq8KQfDeIiDD1daUF/wXMEoVf d8yg== 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=1fUujW+SBWy/EwH25MFgc9gvD//NPEUZk7zdwX0mJgw=; b=JvN7kbfTT5SVpRQtBFrztz+bqFO8dkD8FQGCSQEnasYxZcqyoP9tf5yXZxo813UEv6 QD8SPo9qHw56CFaJTHQKk3sRnbAIkBpfu0GNe3L7YYfiY426YsnVzuBEEObR6ZaGT4QN wBXGX/u3SHQCz8jV0H8WwHo/h/e9x4CdfAk62lH+RifDTlUmHBIrSXloXfVqXSw8/YZn dRfAurCs477D/LJcQB+Iz7Fm9LFtLq+OenJ8+muAKgqcgDwDgbyX5quz/9VhJJnwizSs xqNyVN7/88nJ26np626K+nD/OIrQhWpzlJGILyUPD0QzF4VCL//y0Z7B2hNtz2Yqeehi nFsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=YJvpXVHQ; 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 k36si12516482qtd.514.2017.08.03.03.10.38 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 03 Aug 2017 03:10:39 -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.b=YJvpXVHQ; 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]:53276 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ddD5Q-0002rp-1V for patch@linaro.org; Thu, 03 Aug 2017 06:10:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45818) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ddD1i-0000Ju-Hh for grub-devel@gnu.org; Thu, 03 Aug 2017 06:06:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ddD1h-0004EI-NH for grub-devel@gnu.org; Thu, 03 Aug 2017 06:06:46 -0400 Received: from mail-wr0-x236.google.com ([2a00:1450:400c:c0c::236]:36535) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ddD1h-0004Dh-H6 for grub-devel@gnu.org; Thu, 03 Aug 2017 06:06:45 -0400 Received: by mail-wr0-x236.google.com with SMTP id y43so3723886wrd.3 for ; Thu, 03 Aug 2017 03:06:45 -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=58mA3uyGQCjrRPlUVOJJLQnKBmkW0EW+R9L8ckGfQ/M=; b=YJvpXVHQLj9h/QggcO4FCU5irTLBZI33vBjSlctH3/WDXcEOysJbcZcpZz7hH5AAJv qW5eo4jsC35nw+Lb/HH0EF3qfl4dIoETude++aE1YoDPaV3b8KFXNb0Khq8xNDmUDzD4 sPxOzp7RI64MKE4SRuwfUJFV24VCfcqwcCEKU= 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=58mA3uyGQCjrRPlUVOJJLQnKBmkW0EW+R9L8ckGfQ/M=; b=Keq7Ni6YdBSIrcOmO8SlzNqhYQksJE7YvcQB1xPidKP+gL4kRqjoO3QOoVl25mKv2f GdJESxQwsxd3oVhfcHAfuL5RtQwH1IUMCGIHb5yxrjQhHY9S7lNowcVXL2auO0V7L8er Kflmg0Gh1sg7V/28GZsykn1+pEQUvZfR+3ULQPjaj1ZzeOKL6wKxHXO/lIG8fa1c3mIg w2dLPQXirqkMPQN5UazTh/WkEk34TMn2F1cBZws0+hJGkN22SC5dJ5e10/LjUMM0iTw7 VOc5B5rpdg2M9tS5firnuclqf/VttTRidwboewy9rMk8fnNUxE+CGxfipp3aXRGnxaKm FMDA== X-Gm-Message-State: AHYfb5inmFdQleRmv8B82hS4aM2L4IvgQWQXTFtFe4i3PGZyVIvioaol YtrroBC+AcLQy6JViCCoFg== X-Received: by 10.223.147.164 with SMTP id 33mr980976wrp.107.1501754804375; Thu, 03 Aug 2017 03:06:44 -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 e5sm2274543wre.24.2017.08.03.03.06.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 Aug 2017 03:06:43 -0700 (PDT) From: Leif Lindholm To: grub-devel@gnu.org Subject: [PATCH v2 11/14] arm/efi: switch to arm64 linux loader Date: Thu, 3 Aug 2017 11:04:29 +0100 Message-Id: <20170803100432.29913-12-leif.lindholm@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170803100432.29913-1-leif.lindholm@linaro.org> References: <20170803100432.29913-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::236 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" Switch over to the EFI-stub aware arm64 loader for 32-bit ARM platforms. Signed-off-by: Leif Lindholm --- grub-core/Makefile.core.def | 6 +++--- grub-core/kern/efi/mm.c | 2 +- include/grub/efi/efi.h | 2 -- 3 files changed, 4 insertions(+), 6 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/Makefile.core.def b/grub-core/Makefile.core.def index a65c27f7f..87f80d316 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -229,7 +229,6 @@ kernel = { ia64_efi = kern/ia64/cache.c; arm_efi = kern/arm/efi/init.c; - arm_efi = kern/arm/efi/misc.c; arm_efi = kern/efi/fdt.c; arm64_efi = kern/arm64/efi/init.c; @@ -1698,7 +1697,8 @@ module = { powerpc_ieee1275 = loader/powerpc/ieee1275/linux.c; sparc64_ieee1275 = loader/sparc64/ieee1275/linux.c; ia64_efi = loader/ia64/efi/linux.c; - arm = loader/arm/linux.c; + arm_uboot = loader/arm/linux.c; + arm_efi = loader/arm64/linux.c; arm64 = loader/arm64/linux.c; common = loader/linux.c; common = lib/cmdline.c; @@ -1707,7 +1707,7 @@ module = { module = { name = fdt; - arm64 = loader/efi/fdt.c; + efi = loader/efi/fdt.c; common = lib/fdt.c; enable = fdt; }; diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c index 1e62eff8f..c8fffe902 100644 --- a/grub-core/kern/efi/mm.c +++ b/grub-core/kern/efi/mm.c @@ -572,7 +572,7 @@ grub_efi_mm_init (void) 2 * BYTES_TO_PAGES (MEMORY_MAP_SIZE)); } -#if defined (__aarch64__) +#if defined (__aarch64__) || defined (__arm__) grub_err_t grub_efi_get_ram_base(grub_addr_t *base_addr) { diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h index 149969941..ec691bd44 100644 --- a/include/grub/efi/efi.h +++ b/include/grub/efi/efi.h @@ -89,8 +89,6 @@ extern void (*EXPORT_VAR(grub_efi_net_config)) (grub_efi_handle_t hnd, #if defined(__arm__) || defined(__aarch64__) void *EXPORT_FUNC(grub_efi_get_firmware_fdt)(void); -#endif -#if defined(__aarch64__) grub_err_t EXPORT_FUNC(grub_efi_get_ram_base)(grub_addr_t *); #include grub_err_t grub_efi_linux_check_image(struct grub_linux_kernel_header *lh); From patchwork Thu Aug 3 10:04:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 109312 Delivered-To: patch@linaro.org Received: by 10.140.101.6 with SMTP id t6csp574526qge; Thu, 3 Aug 2017 03:11:36 -0700 (PDT) X-Received: by 10.55.94.197 with SMTP id s188mr1672703qkb.167.1501755096260; Thu, 03 Aug 2017 03:11:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501755096; cv=none; d=google.com; s=arc-20160816; b=DZ2ML1ly1rXBUq+ZywR2XVXzwcoVkpDShdJXdDK4rxPyWpYKrfSpchM4uMEFlr4Jyw 5TiMHwO/5qjDMPq/tOr4biq+cCNWtQW/Mo25vs28cghuRuQqZdiimTWV8mRVNANqo84x GU+Ex+RUM/lpTfrc0kEBzaD4y1JohbRCaQNJqYAn39n91YvGtIcvmXdY6qLlhlurGjlI oDaVVJQQldxIV30Q8shW/JFswGXI5L+JBpXXiF9OlFwo8K8KhbPJ3aMyhNk9yBf1ergZ Bc1av+Z89889+gRsqua/UBsgQ0TwswLpEcxols6DniPxmKmcHmKkgPXQpBCj4EyqYgL6 g5nw== 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=oqqyuoy7Kl2daxixyQeh06wZk2193dRDgyhp2UYIQqo=; b=Y7pbhDQJNNi80DAWUSjglG7AwywaRr2h3rIxi9omoQ2gAgI8pQ0XcyDDdTYO2uQExv BswdcwXbM4kZIlFoHmPukcYTIh0ehHWCwSr+5DlFnAjTSQSb+KQmKvcXR16D4XiSBQkR jdaRHLaCEP6BZKhajUAocapm7WxU0s7yHt29+qX0TCqKBKZ34y6kh0YOQN8ALK6BdxzV +a4Zd8Oj68tOf5U50eCkElYUzs8VproaX1sMIWcS0K0RwOuGIPHy/v3kNN8w1zBzSAlK SyigKd6pl9cuxsm5J/Sz5/DL75qSHLSgIwJdmDq+M7DD3CiI1uk3MeVqqW3TLzkrZ0MH mhow== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=NbEPa45N; 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 d24si8991623qtd.51.2017.08.03.03.11.35 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 03 Aug 2017 03:11:36 -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.b=NbEPa45N; 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]:53313 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ddD6L-0003iI-Au for patch@linaro.org; Thu, 03 Aug 2017 06:11:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45911) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ddD1l-0000N9-Bz for grub-devel@gnu.org; Thu, 03 Aug 2017 06:06:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ddD1j-0004Fq-DK for grub-devel@gnu.org; Thu, 03 Aug 2017 06:06:49 -0400 Received: from mail-wr0-x22d.google.com ([2a00:1450:400c:c0c::22d]:33459) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ddD1j-0004F3-3C for grub-devel@gnu.org; Thu, 03 Aug 2017 06:06:47 -0400 Received: by mail-wr0-x22d.google.com with SMTP id v105so3750014wrb.0 for ; Thu, 03 Aug 2017 03:06:47 -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=dajpxk42CclQx+OQWb8P41rzcAzZ+awGXbodNHYN+zo=; b=NbEPa45NlqvTMvNikHcPytP+Lbmyd5kVfQfuwcJW/fqqGp7eZ7rrD+XJY4F6h+TCoc 1/dUq1AdfyThOQTCMTEidOAqczN02Pc2MA8yqnmhN633qOB67XeeY5GPp6zwQPsdY353 lo1yzKF6ukRplbAWEX4RTOjD7HFio/Ja6XAik= 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=dajpxk42CclQx+OQWb8P41rzcAzZ+awGXbodNHYN+zo=; b=TzoUd96nkPiN2F+IUpnRzVOAqBnOHvCdWZvFwmejhFcF3qErFI4uLuh3LH92rEujhn erWboKs/YL2uotQNxiO3jmBBTqMRMg+ZIQ24L5hzC9QOBr5k47UWEPq6bWybNr4XOugy vKD1wlyJwNJVy4QuH7JQfIrebpPlnGryYo85bSfUzVo1snPHElEJ55FQo+g90J7dq44P +FN2QWXYu2o/9bE4/cDuryZdUzG+DE4ThnFMb2QE2NZm+mIqHphmIYUVIveNwpVZdU+R tR0dAxyKlNLQve4KRX6bQBiGeNYBhg5Hotj7oCXJW/vCrNT0q6qR4+0vEwgMdVzyZ9Jj XOgg== X-Gm-Message-State: AIVw110kKZk7CQmTo3GMK+gRaV371juxn6ZdIGgu/to1Ev19z61urTqJ Nbbr9wC80pBq72BmvEQ+ZQ== X-Received: by 10.223.144.131 with SMTP id i3mr894713wri.40.1501754805841; Thu, 03 Aug 2017 03:06:45 -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 e5sm2274543wre.24.2017.08.03.03.06.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 Aug 2017 03:06:44 -0700 (PDT) From: Leif Lindholm To: grub-devel@gnu.org Subject: [PATCH v2 12/14] arm: delete unused efi support from loader/arm Date: Thu, 3 Aug 2017 11:04:30 +0100 Message-Id: <20170803100432.29913-13-leif.lindholm@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170803100432.29913-1-leif.lindholm@linaro.org> References: <20170803100432.29913-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: Daniel Kiper MIME-Version: 1.0 Errors-To: grub-devel-bounces+patch=linaro.org@gnu.org Sender: "Grub-devel" The 32-bit arm efi port now shares the 64-bit linux loader, so delete the now unused bits from the 32-bit linux loader. This in turn leaves the grub-core/kern/arm/efi/misc.c unused, so delete that too. Signed-off-by: Leif Lindholm --- grub-core/Makefile.am | 1 - grub-core/kern/arm/efi/misc.c | 202 ------------------------------------------ grub-core/loader/arm/linux.c | 28 ------ include/grub/arm/efi/loader.h | 26 ------ include/grub/arm/linux.h | 16 ---- 5 files changed, 273 deletions(-) delete mode 100644 grub-core/kern/arm/efi/misc.c delete mode 100644 include/grub/arm/efi/loader.h -- 2.11.0 _______________________________________________ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am index 622f946f5..cd3424c07 100644 --- a/grub-core/Makefile.am +++ b/grub-core/Makefile.am @@ -256,7 +256,6 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/fdtbus.h endif if COND_arm_efi -KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/arm/efi/loader.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/arm/system.h diff --git a/grub-core/kern/arm/efi/misc.c b/grub-core/kern/arm/efi/misc.c deleted file mode 100644 index 7cd41842a..000000000 --- a/grub-core/kern/arm/efi/misc.c +++ /dev/null @@ -1,202 +0,0 @@ -/* misc.c - various system functions for an arm-based EFI system */ -/* - * GRUB -- GRand Unified Bootloader - * Copyright (C) 2013 Free Software Foundation, Inc. - * - * GRUB is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * GRUB is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GRUB. If not, see . - */ - -#include -#include -#include -#include -#include -#include - -static inline grub_size_t -page_align (grub_size_t size) -{ - return (size + (1 << 12) - 1) & (~((1 << 12) - 1)); -} - -/* 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); -} - -#define NEXT_MEMORY_DESCRIPTOR(desc, size) \ - ((grub_efi_memory_descriptor_t *) ((char *) (desc) + (size))) -#define PAGE_SHIFT 12 - -void * -grub_efi_allocate_loader_memory (grub_uint32_t min_offset, grub_uint32_t size) -{ - grub_efi_uintn_t desc_size; - grub_efi_memory_descriptor_t *mmap, *mmap_end; - grub_efi_uintn_t mmap_size, tmp_mmap_size; - grub_efi_memory_descriptor_t *desc; - void *mem = NULL; - grub_addr_t min_start = 0; - - mmap_size = find_mmap_size(); - if (!mmap_size) - return NULL; - - mmap = grub_malloc(mmap_size); - if (!mmap) - return NULL; - - tmp_mmap_size = mmap_size; - if (grub_efi_get_memory_map (&tmp_mmap_size, mmap, 0, &desc_size, 0) <= 0) - { - grub_error (GRUB_ERR_IO, "cannot get memory map"); - goto fail; - } - - mmap_end = NEXT_MEMORY_DESCRIPTOR (mmap, tmp_mmap_size); - /* Find lowest accessible RAM location */ - { - int found = 0; - for (desc = mmap ; !found && (desc < mmap_end) ; - desc = NEXT_MEMORY_DESCRIPTOR(desc, desc_size)) - { - switch (desc->type) - { - case GRUB_EFI_CONVENTIONAL_MEMORY: - case GRUB_EFI_LOADER_CODE: - case GRUB_EFI_LOADER_DATA: - min_start = desc->physical_start + min_offset; - found = 1; - break; - default: - break; - } - } - } - - /* First, find free pages for the real mode code - and the memory map buffer. */ - for (desc = mmap ; desc < mmap_end ; - desc = NEXT_MEMORY_DESCRIPTOR(desc, desc_size)) - { - grub_uint64_t start, end; - - grub_dprintf("mm", "%s: 0x%08x bytes @ 0x%08x\n", - __FUNCTION__, - (grub_uint32_t) (desc->num_pages << PAGE_SHIFT), - (grub_uint32_t) (desc->physical_start)); - - if (desc->type != GRUB_EFI_CONVENTIONAL_MEMORY) - continue; - - start = desc->physical_start; - end = start + (desc->num_pages << PAGE_SHIFT); - grub_dprintf("mm", "%s: start=0x%016llx, end=0x%016llx\n", - __FUNCTION__, start, end); - start = start < min_start ? min_start : start; - if (start + size > end) - continue; - grub_dprintf("mm", "%s: let's allocate some (0x%x) pages @ 0x%08x...\n", - __FUNCTION__, (size >> PAGE_SHIFT), (grub_addr_t) start); - mem = grub_efi_allocate_pages (start, (size >> PAGE_SHIFT) + 1); - grub_dprintf("mm", "%s: retval=0x%08x\n", - __FUNCTION__, (grub_addr_t) mem); - if (! mem) - { - grub_error (GRUB_ERR_OUT_OF_MEMORY, "cannot allocate memory"); - goto fail; - } - break; - } - - if (! mem) - { - grub_error (GRUB_ERR_OUT_OF_MEMORY, "cannot allocate memory"); - goto fail; - } - - grub_free (mmap); - return mem; - - fail: - grub_free (mmap); - return NULL; -} - -grub_err_t -grub_efi_prepare_platform (void) -{ - grub_efi_uintn_t mmap_size; - grub_efi_uintn_t map_key; - grub_efi_uintn_t desc_size; - grub_efi_uint32_t desc_version; - grub_efi_memory_descriptor_t *mmap_buf; - grub_err_t err; - - /* - * Cloned from IA64 - * Must be done after grub_machine_fini because map_key is used by - *exit_boot_services. - */ - mmap_size = find_mmap_size (); - if (! mmap_size) - return GRUB_ERR_OUT_OF_MEMORY; - mmap_buf = grub_efi_allocate_pages (0, page_align (mmap_size) >> 12); - if (! mmap_buf) - return GRUB_ERR_OUT_OF_MEMORY; - - err = grub_efi_finish_boot_services (&mmap_size, mmap_buf, &map_key, - &desc_size, &desc_version); - if (err != GRUB_ERR_NONE) - return err; - - return GRUB_ERR_NONE; -} diff --git a/grub-core/loader/arm/linux.c b/grub-core/loader/arm/linux.c index 067f69894..e563eca95 100644 --- a/grub-core/loader/arm/linux.c +++ b/grub-core/loader/arm/linux.c @@ -290,15 +290,6 @@ linux_boot (void) */ linuxmain = (kernel_entry_t) linux_addr; -#ifdef GRUB_MACHINE_EFI - { - grub_err_t err; - err = grub_efi_prepare_platform(); - if (err != GRUB_ERR_NONE) - return err; - } -#endif - grub_arm_disable_caches_mmu (); linuxmain (0, machine_type, target_fdt); @@ -317,13 +308,7 @@ linux_load (const char *filename, grub_file_t file) size = grub_file_size (file); -#ifdef GRUB_MACHINE_EFI - linux_addr = (grub_addr_t) grub_efi_allocate_loader_memory (LINUX_PHYS_OFFSET, size); - if (!linux_addr) - return grub_errno; -#else linux_addr = LINUX_ADDRESS; -#endif grub_dprintf ("loader", "Loading Linux to 0x%08x\n", (grub_addr_t) linux_addr); @@ -428,20 +413,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), size = grub_get_initrd_size (&initrd_ctx); -#ifdef GRUB_MACHINE_EFI - if (initrd_start) - grub_efi_free_pages (initrd_start, - (initrd_end - initrd_start + 0xfff) >> 12); - initrd_start = (grub_addr_t) grub_efi_allocate_loader_memory (LINUX_INITRD_PHYS_OFFSET, size); - - if (!initrd_start) - { - grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory")); - goto fail; - } -#else initrd_start = LINUX_INITRD_ADDRESS; -#endif grub_dprintf ("loader", "Loading initrd to 0x%08x\n", (grub_addr_t) initrd_start); diff --git a/include/grub/arm/efi/loader.h b/include/grub/arm/efi/loader.h deleted file mode 100644 index 4bab18e83..000000000 --- a/include/grub/arm/efi/loader.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * GRUB -- GRand Unified Bootloader - * Copyright (C) 2013 Free Software Foundation, Inc. - * - * GRUB is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * GRUB is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GRUB. If not, see . - */ - -#ifndef GRUB_LOADER_MACHINE_HEADER -#define GRUB_LOADER_MACHINE_HEADER 1 - -grub_err_t EXPORT_FUNC (grub_efi_prepare_platform) (void); -void * EXPORT_FUNC (grub_efi_allocate_loader_memory) (grub_uint32_t min_offset, - grub_uint32_t size); - -#endif /* ! GRUB_LOADER_MACHINE_HEADER */ diff --git a/include/grub/arm/linux.h b/include/grub/arm/linux.h index 802090239..758e97d72 100644 --- a/include/grub/arm/linux.h +++ b/include/grub/arm/linux.h @@ -41,20 +41,6 @@ struct grub_linux_kernel_header { # define LINUX_FDT_ADDRESS (LINUX_INITRD_ADDRESS - 0x10000) # define grub_arm_firmware_get_boot_data grub_uboot_get_boot_data # define grub_arm_firmware_get_machine_type grub_uboot_get_machine_type -#elif defined GRUB_MACHINE_EFI -# include -# include -/* On UEFI platforms - load the images at the lowest available address not - less than *_PHYS_OFFSET from the first available memory location. */ -# define LINUX_PHYS_OFFSET (0x00008000) -# define LINUX_INITRD_PHYS_OFFSET (LINUX_PHYS_OFFSET + 0x02000000) -# define LINUX_FDT_PHYS_OFFSET (LINUX_INITRD_PHYS_OFFSET - 0x10000) -# define grub_arm_firmware_get_boot_data (grub_addr_t)grub_efi_get_firmware_fdt -static inline grub_uint32_t -grub_arm_firmware_get_machine_type (void) -{ - return GRUB_ARM_MACHINE_TYPE_FDT; -} #elif defined (GRUB_MACHINE_COREBOOT) #include #include @@ -73,6 +59,4 @@ grub_arm_firmware_get_machine_type (void) } #endif -#define FDT_ADDITIONAL_ENTRIES_SIZE 0x300 - #endif /* ! GRUB_LINUX_CPU_HEADER */ From patchwork Thu Aug 3 10:04:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 109315 Delivered-To: patch@linaro.org Received: by 10.182.45.195 with SMTP id p3csp682593obm; Thu, 3 Aug 2017 03:15:21 -0700 (PDT) X-Received: by 10.200.50.151 with SMTP id z23mr1355687qta.140.1501755321542; Thu, 03 Aug 2017 03:15:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501755321; cv=none; d=google.com; s=arc-20160816; b=rGaQUh2EfuwwtvTdPE8gkAYcgRYCCCeSH5hOUQ1fghCyt7cyNjrlP/n/AokcUU6pHI OjYgKpNvRuWCmd+WYG0KPfS6QIVBLPl3Q/cmztKXnRa6MV+qKEB+cxt+c9k/2nmWQ5LJ tJyJVyfHVg1coDto3Lyz1PbFRcbqPwRy7Eqg8yf4sLrov/NglhhTs0uv5r/8NUDMUejY 1g38dogZgmDb/2aST/PjJU2alyPhfN92E9vvqXQA44bDC0sK7czy6Q6nDwVoC4ja3uT3 oD8vs+i72OadE9JvOwWfNrfo1F18QzB5r1Ipk7J39JB15EAYCoT5DViK9KoJX7Z7IpRe DgqA== 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=vUz2rC5EA7bYOPoAxPN/54AwqHxs3DXlHp9EiAlWkuk=; b=QIUouiEK9EjNZEpCA4o8CGdhEHdT2Vy5I3ImFICSfoGKNjeZtwMxLRQn5SwgGXYcH2 kHOtF3iASH8wlo9wTTWsTUff3D5gzSUx9PhY1GHwpuH4MFuGwxObOn/FwPiFte8J9dsd Z3E9X2cGPo9OeNKhZjMdJrWtDdAzJx7LT1r0mGykLCn05oZAGeBlAiUjv+cMZmljbWA2 gBJiQx2w7stJ0bFwkXE/o3ASH48UzrYg+XncJKJGIPNOluMtXRQrM9XEUoQrtJ2fjUHa v2DzqWP2eXrrzklER4PjLqtLEyckmoIlsyZ4vBDeiYwH1s0NnvofSVlwrLblDd1RLEkA 6I2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=BNULt0Gy; 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 j62si22075080qkd.539.2017.08.03.03.15.21 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 03 Aug 2017 03:15:21 -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.b=BNULt0Gy; 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]:53793 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ddD9y-0007NE-VB for patch@linaro.org; Thu, 03 Aug 2017 06:15:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45946) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ddD1m-0000OX-P5 for grub-devel@gnu.org; Thu, 03 Aug 2017 06:06:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ddD1l-0004IZ-OX for grub-devel@gnu.org; Thu, 03 Aug 2017 06:06:50 -0400 Received: from mail-wm0-x22e.google.com ([2a00:1450:400c:c09::22e]:33516) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ddD1l-0004Hh-Hw for grub-devel@gnu.org; Thu, 03 Aug 2017 06:06:49 -0400 Received: by mail-wm0-x22e.google.com with SMTP id k20so3355858wmg.0 for ; Thu, 03 Aug 2017 03:06:49 -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=ckTreSR6iDYDUDIVWewLS0lTVTiop8S3dutqHJfhtCo=; b=BNULt0GymvU3SLL5KqBpkoo1So7edmLU7grvCLaKVswp7UrzJDlj7VdQ5XfzAqx64b ciVdy8J6jjF6ciyt3uwa3xXRe+vwIg2B60QKKONkKctsBrsOE/svnM3bPiUHniQe/aiH YXsRV8wDMHMiHFLEcm5niT0eVvhDbwxdR3AJ8= 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=ckTreSR6iDYDUDIVWewLS0lTVTiop8S3dutqHJfhtCo=; b=LDo/Cbr/Fmckpp2wztDZEffIoogjfF65kNc5+9h2YZg6ll71uIhDfQAJvcdhj+elEm jPw9tn2LtGMMLDmdtr2+Vz41mRU8cH3HR67rWtQqR2T0zT5nv64MPwkkUsrGI/gE35aN 4OCaVy4vn8GaI9SRBeJsVbFFYNHXIVaupI3w7YnDlmUUfgHp0ecQJQtyndDJth+jcn5b k5CB2XDUxufalvxN912fGP0YcLfTJ+T2RiwVAilGlI76nJGv0uRaV2itBp8Q2Lkq54Ed 0SfILLDUKvf0qgqghfnvh66Cs/bK+9ZEvdLxy9Avip853lbzMAuNB8ktC6FEvTxu91Ei WJQw== X-Gm-Message-State: AIVw11029Dey5UOpNqutvmuo5BtbIEniIVwGPr9rE7eDtQ/JM+ADOV8J LqvyiKqLg+eDD8AABxM1cA== X-Received: by 10.28.199.207 with SMTP id x198mr761456wmf.156.1501754808302; Thu, 03 Aug 2017 03:06:48 -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 e5sm2274543wre.24.2017.08.03.03.06.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 Aug 2017 03:06:46 -0700 (PDT) From: Leif Lindholm To: grub-devel@gnu.org Subject: [PATCH v2 13/14] efi: restrict arm/arm64 linux loader initrd placement Date: Thu, 3 Aug 2017 11:04:31 +0100 Message-Id: <20170803100432.29913-14-leif.lindholm@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170803100432.29913-1-leif.lindholm@linaro.org> References: <20170803100432.29913-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::22e 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" The 32-bit arm Linux kernel is built as a zImage, which self-decompresses down to near start of RAM. In order for an initrd/initramfs to be accessible, it needs to be placed within the first ~768MB of RAM. The initrd loader built into the kernel EFI stub restricts this down to 512MB for simplicity - so enable the same restriction in grub. For arm64, the requirement is within a 1GB aligned 32GB window also covering the (runtime) kernel image. Since the EFI stub loader itself will attempt to relocate to near start of RAM, force initrd to be loaded completely within the first 32GB of RAM. Signed-off-by: Leif Lindholm --- grub-core/loader/arm64/linux.c | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) -- 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 8cd44230d..a96019a3b 100644 --- a/grub-core/loader/arm64/linux.c +++ b/grub-core/loader/arm64/linux.c @@ -194,6 +194,42 @@ grub_linux_unload (void) return GRUB_ERR_NONE; } +/* + * This function returns a pointer to a legally allocated initrd buffer, + * or NULL if unsuccessful + */ +static void * +allocate_initrd_mem (int initrd_pages) +{ + grub_addr_t max_addr; + + if (grub_efi_get_ram_base (&max_addr) != GRUB_ERR_NONE) + return NULL; + + /* + * As per linux/Documentation/arm/Booting + * ARM initrd needs to be covered by kernel linear mapping, + * so place it in the first 512MB of DRAM. + * + * As per linux/Documentation/arm64/booting.txt + * ARM64 initrd needs to be contained entirely within a 1GB aligned window + * of up to 32GB of size that covers the kernel image as well. + * Since the EFI stub loader will attempt to load the kernel near start of + * RAM, place the buffer in the first 32GB of RAM. + */ +#ifdef __arm__ +#define INITRD_MAX_ADDRESS_OFFSET (512U * 1024 * 1024) +#else /* __aarch64__ */ +#define INITRD_MAX_ADDRESS_OFFSET (32ULL * 1024 * 1024 * 1024) +#endif + + max_addr += INITRD_MAX_ADDRESS_OFFSET - 1; + + return grub_efi_allocate_pages_real (max_addr, initrd_pages, + GRUB_EFI_ALLOCATE_MAX_ADDRESS, + GRUB_EFI_LOADER_DATA); +} + static grub_err_t grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), int argc, char *argv[]) @@ -222,7 +258,8 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), grub_dprintf ("linux", "Loading initrd\n"); initrd_pages = (GRUB_EFI_BYTES_TO_PAGES (initrd_size)); - initrd_mem = grub_efi_allocate_pages (0, initrd_pages); + initrd_mem = allocate_initrd_mem (initrd_pages); + if (!initrd_mem) { grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory")); From patchwork Thu Aug 3 10:04:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 109307 Delivered-To: patch@linaro.org Received: by 10.140.101.6 with SMTP id t6csp572419qge; Thu, 3 Aug 2017 03:09:27 -0700 (PDT) X-Received: by 10.200.9.27 with SMTP id t27mr1287360qth.107.1501754967866; Thu, 03 Aug 2017 03:09:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501754967; cv=none; d=google.com; s=arc-20160816; b=cyNX3627SMgTRZNq7be9uODCIWpT/9VQlEG8bfT/I7MwZIHhm+zcFTG98caRMTTGY/ PhRRH/+f/jTg5P68jCUU4KzACyg5ohhF2VXq8Ti/utyvKYUprhI4UcvM1xJU8OGQ6mUQ gIxVEbEixkojAVgebQMQ0P5pNpHf5ggVla6zv19D8wgNtHaxfgH3ucDY1OdYhp2F8yHm plF9So8MONOQnNJZDpVAAP1sOYnuNumRhekjtiEkPbOVM1cHLVShXeDUaUx4pO8aFEkN wWasWuwMuueMzDojGhod4x10E+Wo4vh6yht0kYDEUnniOXyJICYqESF1FJtDRWWxU5u+ yFbg== 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=V6eVkXAEaslp2jfw18/fl0PL6SoQ664tL9pT++tN0iU=; b=dxQGjYoeKnZ78Cao6zpj3VI2UGksuyj21P9tOPGQVDSCaazZN4EEykcJxFKXlwAXrW CMJtXX5BkEzaQ2YaJn3xg5bXxH2SvLNN0QOHujZY35zQKmAOu76xjGcckOeKu7H8mcoO FMnZ+leTVLCSKX9oGlVgWHt5HoS3bCpBXzq3b+gGcfUqHjjPH8dtkhuBjNLCYaacu/cw VVa9PuVOjEnFNE5z2EuvoeIyx/Cl2BCt07YqEZzj12A5LkKJjBQ1A0Nu1BcVhajVpdMC kO7B4i7ggwUKf6qtczPzP6sGfo87sFTJFEMfhNLJv7WUpb5CWvlwHd8Ks3ZK3YXpRLsC rLtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=K/omtFhy; 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 h61si32018274qtd.426.2017.08.03.03.09.27 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 03 Aug 2017 03:09:27 -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.b=K/omtFhy; 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]:53213 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ddD4H-0001Rl-9K for patch@linaro.org; Thu, 03 Aug 2017 06:09:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45965) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ddD1n-0000PA-C6 for grub-devel@gnu.org; Thu, 03 Aug 2017 06:06:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ddD1m-0004JK-H0 for grub-devel@gnu.org; Thu, 03 Aug 2017 06:06:51 -0400 Received: from mail-wm0-x230.google.com ([2a00:1450:400c:c09::230]:36189) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ddD1m-0004IH-Bs for grub-devel@gnu.org; Thu, 03 Aug 2017 06:06:50 -0400 Received: by mail-wm0-x230.google.com with SMTP id t201so10871732wmt.1 for ; Thu, 03 Aug 2017 03:06:50 -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=I5tj2kQAvU41T9Ncnsrrj6Z+w7qjyOkZ/cOVaRrBs5o=; b=K/omtFhyHcZGMLFAmBT6dmomt5vgcY8MIcWZez5AqYSZ3DkiRc9gkKjq+lrf2FLBZN Fe78IdhzqN8L0cBwPsZ6d5eyPHWtghVtd2UhwJEkdH1IoQzlawxElb4ALVlSEFqT2nQ3 YjLLg4a+tQ6ShX3zUZFLhDx8Rv7c0H0li0Z7Q= 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=I5tj2kQAvU41T9Ncnsrrj6Z+w7qjyOkZ/cOVaRrBs5o=; b=e2Y7kUydsi4NunsjoM7uBULMAbN2EHHd4/GyOdI8+P14czAT97a4c8IO/SBgowtiq9 rnijzCzH/DSNlCI5zTYCfgDSoUdtOOj86cue/uV9/bMb6vSSbD+8/hOw+NBoadsuFqRp oUQOQ+YkeMdr7snWBbrRoO5m1sDNCDFoFFqRAxMTXJfFaf4UuzSRaPBc/fQZH5vZH+Cy 7vWzz5+GU69TFTrFc/7KFKs00eSVqAJofpp5Uz844Wl7+p6JB/QiKjSTAeAMnKZMqfXt 9FZoQED4jc2hE6z1urp3Y3gIeAK58tN3BPI5+d48IA5gGeSXY2KjvKwO5KFX4bPLzdx8 ZdTA== X-Gm-Message-State: AIVw110XXsSeNc2kpglvymqQM+QepMN58sS2uuOy0WU5A2DKauvZHByN qGULnrF/vbdUaXWG1YmVtw== X-Received: by 10.28.138.194 with SMTP id m185mr761945wmd.116.1501754809134; Thu, 03 Aug 2017 03:06:49 -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 e5sm2274543wre.24.2017.08.03.03.06.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 Aug 2017 03:06:48 -0700 (PDT) From: Leif Lindholm To: grub-devel@gnu.org Subject: [PATCH v2 14/14] efi: change heap allocation type to GRUB_EFI_LOADER_CODE Date: Thu, 3 Aug 2017 11:04:32 +0100 Message-Id: <20170803100432.29913-15-leif.lindholm@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170803100432.29913-1-leif.lindholm@linaro.org> References: <20170803100432.29913-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::230 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" With upcoming changes to EDK2, allocations of type EFI_LOADER_DATA may not return regions with execute ability. Since modules are loaded onto the heap, change the heap allocation type to GRUB_EFI_LOADER_CODE in order to permit execution on systems with this feature enabled. Closes: 50420 Signed-off-by: Leif Lindholm --- grub-core/kern/efi/mm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) -- 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 c8fffe902..f1424f2e4 100644 --- a/grub-core/kern/efi/mm.c +++ b/grub-core/kern/efi/mm.c @@ -448,7 +448,9 @@ add_memory_regions (grub_efi_memory_descriptor_t *memory_map, pages = required_pages; } - addr = grub_efi_allocate_pages (start, pages); + addr = grub_efi_allocate_pages_real (start, pages, + GRUB_EFI_ALLOCATE_ADDRESS, + GRUB_EFI_LOADER_CODE); if (! addr) grub_fatal ("cannot allocate conventional memory %p with %u pages", (void *) ((grub_addr_t) start),