From patchwork Wed Jun 27 17:17:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 140369 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp1152011ljj; Wed, 27 Jun 2018 10:18:54 -0700 (PDT) X-Google-Smtp-Source: AAOMgpd7qZm1q2zuTBZLU6GRI/M7qt6UrQ3tPNBHvHUaaZh7SkelZCSwxotTe+PjP8ckObcv1TdV X-Received: by 2002:a37:6446:: with SMTP id y67-v6mr5901709qkb.309.1530119933996; Wed, 27 Jun 2018 10:18:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530119933; cv=none; d=google.com; s=arc-20160816; b=Pe31vLuv5Fl2eKL20Tu9gcXoy52pO4d5fSzmM9jCnQFcFSGOZBW7Axikk1bdnHafDR 6yf5h1uSLZR4zaUVUsarnlNTs3YyXuw5ABGuvC3izwd/9NLBVEIQBzsAxlZ6fvrqu7kV g6XrJ7J4WRz4HZVomutbaQz1gyHc8cRRa/flY0NpNJrV3UMETridIqc9TRdPnSM8cWHh mt4A3giMdzUzdvbVz+INv9kwlD7o6V9gZTTPmoz5qj28kpU2tjKS9ni16ghiCTuSMsgp SEH5ZUwc19J0pLUSvh9FRr3i5eXrXFEoOxtlQapaWgRbhBM8KYBJhsSsyAEHMu/BHgDj IzBg== 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=gULe/BX8Esu5w1uzW7rPfBxeo8+R9f68DYgemclFatA=; b=DDvOUqm4w+W8bjgGE3jUeeY14JP7KaGELT3Q+pYEu8aIu8Tub1Rvf7kB7Kv90oBAzp RlLWMhV8mjPIJfFVJhVA3FFY766YvZ3vluM/ZwZXbpynXcigl8QgA81mTRytpaoPX2hZ WmR9Ojt5vHo3ILpWlD9BNU13Buy871fPiUe44uT2raVmahkUZjuVOsNiTRRzbM/0FrBw HSQpcvHKPtRnDX6pRiQWQIhD1HSF/IZGJI8XcZ20atoL2KKFjX2IJIL9oBmeG0dGZG80 cVer2N/SkBcEKGMgTLA1WWjV1iy8VrhovToJgJNOW/ep9il6ZEwvo6FH5aYo1hN1zInd sV9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b="YyMO+PZ/"; 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 f19-v6si1914212qka.95.2018.06.27.10.18.53 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 27 Jun 2018 10:18:53 -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="YyMO+PZ/"; 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]:60567 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYE5l-0004al-7F for patch@linaro.org; Wed, 27 Jun 2018 13:18:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57571) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYE4P-0004aU-94 for grub-devel@gnu.org; Wed, 27 Jun 2018 13:17:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYE4O-0006Ly-5b for grub-devel@gnu.org; Wed, 27 Jun 2018 13:17:29 -0400 Received: from mail-wr0-x243.google.com ([2a00:1450:400c:c0c::243]:41734) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYE4N-0006Ks-Tv for grub-devel@gnu.org; Wed, 27 Jun 2018 13:17:28 -0400 Received: by mail-wr0-x243.google.com with SMTP id h10-v6so2805815wrq.8 for ; Wed, 27 Jun 2018 10:17:27 -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=DMF1bDXi1lSNL5Bp6P3Uv32MFLh6O2KrgGtDlZ78xWI=; b=YyMO+PZ/dPFxl596t1eI02ni2EL/SG70S03bpKFyJvUtfiCstBTRlyEbrzNEJiH6y8 4P084XHnYNMrTO4Rg12gF5rmtRwAmxpDvT2T41FSftFXzZfFZhWV7tGGlo02XUdi12R1 2nyBmkjHaWricF0bTACxFNxMHqXOh007A88Ag= 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=DMF1bDXi1lSNL5Bp6P3Uv32MFLh6O2KrgGtDlZ78xWI=; b=D1B3XI7r9CNL+1F2SquBPYbGnmTpwf+57QtTSksrxRFgvuTKRpYAhEUK7zM7hkgVjr oohB/DnPc/PAeletjiDfTCujq4ddGeRCQapfW8HLKQ9TnjWyYUtOL4txQVyuMrqfTClb Il7OdT4ZTnemn8yXFHfwKLhdJx78L4fEp/dVMFG8AfpM4vAMO5sqeLuKw1fOOWsLZP4g r3JOGrCx4TGElaqZt5IBWBB+EjYkgLZjCYwwhyBjR+Zd8W+CLfIBfR/AzGrZhDG26pKQ UOJNabPnpyEsIay78j3ryUDKhEBOEk5vfBjvyxJFJkzNgJXiI4vls2jlHrscG1CO1gKN K4NQ== X-Gm-Message-State: APt69E1QfUoWjrtIH7tfYeFq+9awwUTfCvkPAnqugBePgA1aer/u35El OY3S2dgae9SBvRrdA9pDRD2F+VsOgxo= X-Received: by 2002:adf:9603:: with SMTP id b3-v6mr6008692wra.253.1530119846577; Wed, 27 Jun 2018 10:17:26 -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 a2-v6sm3406572wmb.6.2018.06.27.10.17.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Jun 2018 10:17:24 -0700 (PDT) From: Leif Lindholm To: grub-devel@gnu.org Subject: [PATCH v3 2/6] efi: add grub_efi_get_ram_base() function for arm64 Date: Wed, 27 Jun 2018 18:17:16 +0100 Message-Id: <20180627171720.27028-3-leif.lindholm@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180627171720.27028-1-leif.lindholm@linaro.org> References: <20180627171720.27028-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::243 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 | 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 fd39d23b4..10ffa2c9b 100644 --- a/grub-core/kern/efi/mm.c +++ b/grub-core/kern/efi/mm.c @@ -629,3 +629,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 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);