From patchwork Mon Jul 9 17:33:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 141478 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp2924774ljj; Mon, 9 Jul 2018 10:35:37 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdrv98dnSd1G0R1XAW7WZZ/ZwoeqJXaIwgScGSWfdMnG6FAxF22qPd3zfJapHNvYcR5VU+M X-Received: by 2002:ac8:2c24:: with SMTP id d33-v6mr2601756qta.118.1531157737872; Mon, 09 Jul 2018 10:35:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531157737; cv=none; d=google.com; s=arc-20160816; b=M+mx8kZHBqa3FNcafmbg60vMsO9JLosTx8GoU3slzUx1027gK2FoDCOK3pMJ4Y0YSY oqOHG+JEZwtzA5ZHitxH/7l7XTQ4MNkjxODpU7cPVir9nZMVe41w4o1fQjg/0jJ5ZW6U /kAFaYcT65/7RdO6Hr8F+ybqrXAuLKVKqhjmwI/TAa8pTkNbrsX4i3Vd4WSkkt/YaOkU mrpUa0zo4nh0ithlqo+cywfnaVFlxACuOOxInZgzvLnc/pNhvhsIhPnprjvu09iio6aQ 188jHrJhisCizYdl1nxdXgu3Q6g/ydk560RiBoEnmO14X3tx3a557fD9ZulcDzLlAd7X 4VPA== 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=jmFrtsu0ZFZxEJijCXvFjXZ18rwz5RYHzZEBKW0Qxgs=; b=mCIwtyzI62oBACvYu8VSchD3AZfagUy+QR3nW+MxhsiK9qh9vB9yoCjgBEvMFc/YWn KDcfkKNFkvTYAOZ4l3ZZmOgq77RRMV5Vp4iuguFzKkGciRv3ayPekr6uIE8H9leBSXXu IxZARBNrtw9lv3rCKCWNX6x3riW3fl8ye4uDM/NizJ1sm7/84oys3gyBcrWGz/zKIwaU kP8pcRmzdVxiQlF5qz6Ykp94q8vERU2DKEXSyKneQ24gd1R3E+rGVZFJSfthOwfCtfW3 1vAWEX5c8rmwKJR5qxc2Cn8F6GAzCuS4KLL7Dl9W2DIRMmQDJsPLmofBPTK5cD8kv/48 LwUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b="hh0pKU/u"; 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 q3-v6si6896461qtl.309.2018.07.09.10.35.37 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 09 Jul 2018 10:35: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.s=google header.b="hh0pKU/u"; 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]:43611 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fca4X-0001HS-68 for patch@linaro.org; Mon, 09 Jul 2018 13:35:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44240) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fca2D-0000H6-QW for grub-devel@gnu.org; Mon, 09 Jul 2018 13:33:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fca2B-0002fl-Pu for grub-devel@gnu.org; Mon, 09 Jul 2018 13:33:13 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:45227) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fca2B-0002fW-JW for grub-devel@gnu.org; Mon, 09 Jul 2018 13:33:11 -0400 Received: by mail-wr1-x441.google.com with SMTP id u7-v6so11824195wrn.12 for ; Mon, 09 Jul 2018 10:33:11 -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=KVajlpE5s632frBnorjrIL41ZuT3aGtJVGETvBOrfBk=; b=hh0pKU/uWK9V/F5npy24IMIBIOpxk1ya/DWMuUjYZ9fMoh952yIVwZwlPm3sJbttG4 +dH029R+RGUHnsUJ3lHbpQ8+wYvU9kg7B9sTOEJiO626kJ1altNQTQ9LyTFHtvi0WHCH 0Z0jnJ1b3ki7CPYcvWlpObKHqCnKv2m/mM2Jk= 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=KVajlpE5s632frBnorjrIL41ZuT3aGtJVGETvBOrfBk=; b=GPfmqqCcpdz3quTORdB4UgmLVhngiirfH+FiNljVgcTBjmmAXLwoa/S4OksCqM9+Tp tlW5sCKVynVB9Ap1rj88TrbkUfC1DXtw4VLIyXnHZXAT2+NoB62dtPnH59FwegqXPz0q nRe9VwkiOiJ7R8cTRLJYWIeLUirzfvfdjeL1znhI1fLoKppwafj4ikkPpPOMBt52F/vl xkobBri4Wy/2yuVf0wMcwqm9CiFoCWuucYwzJayf+rCkD+mqXOfI6jiZYSAutF2PBEeY rXFqxX6Hbj3RvRhnBX54lOupVj/YpT4iDDZbeqp4cZ0XhJIrhNLm6ClpOxUGh601iKzO CUGw== X-Gm-Message-State: APt69E1HFbgrv8Mc3z4bYhrKtbgu6r4BtgLE11qYeHupQ0CnjVFOnuv/ +Yxc8OLJx5G50rOqU8SEpSKSdxLf2j4= X-Received: by 2002:a5d:4e49:: with SMTP id r9-v6mr14272545wrt.27.1531157590323; Mon, 09 Jul 2018 10:33:10 -0700 (PDT) Received: from vanye.hemma.eciton.net (cpc92302-cmbg19-2-0-cust304.5-4.cable.virginm.net. [82.1.209.49]) by smtp.gmail.com with ESMTPSA id p3-v6sm27742988wrg.47.2018.07.09.10.33.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Jul 2018 10:33:09 -0700 (PDT) From: Leif Lindholm To: grub-devel@gnu.org Subject: [PATCH v4 2/6] efi: add grub_efi_get_ram_base() function for arm64 Date: Mon, 9 Jul 2018 18:33:01 +0100 Message-Id: <20180709173305.17588-3-leif.lindholm@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180709173305.17588-1-leif.lindholm@linaro.org> References: <20180709173305.17588-1-leif.lindholm@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::441 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: The development of GNU GRUB Cc: Daniel Kiper MIME-Version: 1.0 Errors-To: grub-devel-bounces+patch=linaro.org@gnu.org Sender: "Grub-devel" 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 arm64 efi 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 | 31 +++++++++++++++++++++++++++++++ include/grub/efi/efi.h | 3 +++ 2 files changed, 34 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 fd39d23b4..b7cf144e5 100644 --- a/grub-core/kern/efi/mm.c +++ b/grub-core/kern/efi/mm.c @@ -629,3 +629,34 @@ 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, *desc; + grub_efi_uintn_t memory_map_size, desc_size; + int ret; + + memory_map_size = grub_efi_find_mmap_size(); + + memory_map = grub_malloc (memory_map_size); + if (! memory_map) + return GRUB_ERR_OUT_OF_MEMORY; + ret = grub_efi_get_memory_map (&memory_map_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 + memory_map_size); + desc = NEXT_MEMORY_DESCRIPTOR (desc, desc_size)) + if (desc->attribute & GRUB_EFI_MEMORY_WB) + *base_addr = grub_min (*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 1021273c1..57db74b57 100644 --- a/include/grub/efi/efi.h +++ b/include/grub/efi/efi.h @@ -93,6 +93,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);