From patchwork Mon Jun 12 14:53:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 103629 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp232963qgd; Mon, 12 Jun 2017 07:57:07 -0700 (PDT) X-Received: by 10.55.54.7 with SMTP id d7mr29386077qka.258.1497279427244; Mon, 12 Jun 2017 07:57:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497279427; cv=none; d=google.com; s=arc-20160816; b=pBJ7RE5uiBIrviNxGGkCWHmnXSytuYZmMg9fVtJMAXu2fuuL2gJ/U1LQ/4uMyzQn7X ZWkKzY1KZ62c9Pg1WkD5zPm6rUdShhOwUaW/mp94qeeeu90z/Kab/UQp7pwyZEdSeyKC sKSxAGE2RGJ5KKsND+77GUO/vISARNbXAzMrKkkyntO8cWB7ie2wiUq72hWZsUdCUOo7 OKGDHlEbcZZCN7ivuSGx8wn3+XaS9jSGRZcq75JxkvgAo9BavPAApriFAkTH5R/NmgVp enEOYrGCzll2to7oBz5AJuuR2w05RXguJY8mUKlPcSTnr/7pvvih8HtU62318S81peaD 2M6g== 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=7FYIBIuViySTPiaXi5H/eO1iU3PRJZlF4R7+dINk76Y=; b=mhnA8FyonfSxpkiGIsdv0rQlTLRDtJ7Ns9Vpii6dkOFGC5l6hcJjwyCSBTuDF40YCx LtKCuQEMPx8C0VHdHjJuE+4AErTLwNNz71GnAVlTOKTTg9Xq0ismqvPqg6hFmc7zz4Ns Zj4HX1k/GLH9W1zL5hfDqP3NDSbzwr8OCcZPchkah3RrDZv27/aQQcLykkeUu+AegGQt bQgtHS4zjyi3b4xaHej/7GBGLXdA4Wg4FigXS6UdrVQm47i+5NL+5RJ3Li+f3a6wlNyP 5KahZkMGG6V7VMAUUx+fC3QV1Z+1hLOuUPqeDqMN1RIPHdPSTPzk6Z3HdPZbSsGqAyJX 5hKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; 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 s37si8776810qte.104.2017.06.12.07.57.06 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 12 Jun 2017 07:57:07 -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; 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]:38516 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dKQm8-0000wf-Ot for patch@linaro.org; Mon, 12 Jun 2017 10:57:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58223) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dKQky-0000tz-9G for grub-devel@gnu.org; Mon, 12 Jun 2017 10:55:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dKQkw-0000uW-RS for grub-devel@gnu.org; Mon, 12 Jun 2017 10:55:52 -0400 Received: from mail-wr0-x230.google.com ([2a00:1450:400c:c0c::230]:34081) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dKQkw-0000uF-JS for grub-devel@gnu.org; Mon, 12 Jun 2017 10:55:50 -0400 Received: by mail-wr0-x230.google.com with SMTP id g76so98958289wrd.1 for ; Mon, 12 Jun 2017 07:55: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=FmPKJ6T6RMiB7ad1iiASLo3pTNH6PHIoIgPwTf6I7iI=; b=hiF6eJ6m1VxDBbCQytP88I/FIB7CJyHRQEcUYxhViQZvDkwhRtrlZiZKdko6NMQVEa TNIpU9VGFqNyXpuYMZei1aYnJ72QuWgzEnAChLxALy4QkHAF9i1oXKI/FoFYWpVTIBU+ qF6XgOKiDufrl5i8UsHUPwkrqmhb1+OeJoZHw= 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=FmPKJ6T6RMiB7ad1iiASLo3pTNH6PHIoIgPwTf6I7iI=; b=SvmvuIxKO8B8pyGxUMuELAd0kI3BrHwbqpfwv5mtW3AEJoV6LqNyzeZ2WwFJUa8B+z 89jlLsGLfYIy0+G1bOeiqdEx4DcW7cd+/xZiF7WiS9ZMicTeBW/wO8bdP3TO0sJv+WQr SS7K+gU1C/DX6JmnHGVl6wNm6Mne1KOm/a6G6opAmD6WZC8WC3PK9miL+oURZhwFgF3I dDvbRYCi6febEBjQC/+fuUHTJ6t1khNlPAggJDhw7OvFK8KuxN52JKKsPUYWBA/o4CwB 1YacG8FdTz/m56S8D0174/cC99g2mJsx5U3Qqb8bBFvogglTnE9M7LO/6am6w7Y8Wbjy bi5Q== X-Gm-Message-State: AKS2vOxcES5olbTOsYX95AMR9PjwBaBQ/ILI8d2h8cenUwbuZTarpG5l ccmabRiA4RsHMfxvX32ADw== X-Received: by 10.223.169.203 with SMTP id b69mr8521361wrd.1.1497279344453; Mon, 12 Jun 2017 07:55:44 -0700 (PDT) Received: from mohikan.hemma.eciton.net (cpc92316-cmbg19-2-0-cust118.5-4.cable.virginm.net. [82.12.0.119]) by smtp.gmail.com with ESMTPSA id s140sm7722wmd.1.2017.06.12.07.55.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Jun 2017 07:55:43 -0700 (PDT) From: Leif Lindholm To: grub-devel@gnu.org Subject: [PATCH 1/7] efi: add grub_efi_get_dram_base() function for arm* Date: Mon, 12 Jun 2017 15:53:35 +0100 Message-Id: <20170612145341.3351-2-leif.lindholm@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170612145341.3351-1-leif.lindholm@linaro.org> References: <20170612145341.3351-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::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: ard.biesheuvel@linaro.org, lersek@redhat.com, agraf@suse.de, kraxel@redhat.com 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 | 42 ++++++++++++++++++++++++++++++++++++++++++ include/grub/efi/efi.h | 1 + 2 files changed, 43 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..460a4b763 100644 --- a/grub-core/kern/efi/mm.c +++ b/grub-core/kern/efi/mm.c @@ -525,3 +525,45 @@ grub_efi_mm_init (void) grub_efi_free_pages ((grub_addr_t) memory_map, 2 * BYTES_TO_PAGES (MEMORY_MAP_SIZE)); } + +#if defined (__arm__) || defined (__aarch64__) +grub_err_t +grub_efi_get_dram_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; + + mmap_size = (1 << GRUB_EFI_PAGE_SHIFT); + while (1) + { + int ret; + + 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 > 0) + break; + + grub_free (memory_map); + if (ret == 0) + return GRUB_ERR_BUG; + + mmap_size += (1 << GRUB_EFI_PAGE_SHIFT); + } + + 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; + } + + return GRUB_ERR_NONE; +} +#endif diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h index e9c601f34..845fc2438 100644 --- a/include/grub/efi/efi.h +++ b/include/grub/efi/efi.h @@ -83,6 +83,7 @@ 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); +grub_err_t EXPORT_FUNC(grub_efi_get_dram_base)(grub_addr_t *); #endif grub_addr_t grub_efi_modules_addr (void); From patchwork Mon Jun 12 14:53:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 103631 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp233419qgd; Mon, 12 Jun 2017 07:58:17 -0700 (PDT) X-Received: by 10.200.45.35 with SMTP id n32mr37911851qta.15.1497279496956; Mon, 12 Jun 2017 07:58:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497279496; cv=none; d=google.com; s=arc-20160816; b=WsmqHUFGBYCTp271fWo15ncoQVgKwQQaTE/WvUumNYOlkuF2zaNgBkF0oZ1hCa9Dae ggdhL6F4EbTBlKXtKiYNriQvQo162nJ54KodrN0B6ApHnUb/lVPOdRAtcvEYtd4OX0RB cnQgFE5KFB3hceTh4FaHMeCuHiSeo5voYTh8FWbrdmUAwWCBTcMvQUbLU6L7tBauz945 wMDy0bLLCNE9IxWFxUS3SYoxSQni4ca/6i2cDK8qGMZiJO+s5PHG1FcOC4fuFQWiAb09 9kqDjKGYybtS80UvCMOrGOtIKGYwZxN+nD/Pxhy9J431zxmIC9nK4wkOUvQBIu5N6kxB 4W6g== 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=fhWVT6YwVd+x/zk7h3iEPf6uxviLc08VfScRegKP+sU=; b=B6bjSEVRHRfYPUgfb6jZJqmHwr7sUGZpuZDfMXrSNySLs+YFrWvTjiPaobaaWetOOB 4rp+e83wGFKIVT/tzmHiWQ6Y+EMvpbqgK1BegJFFrNLcsmuXOPi5yr0gHMN/sYmDt4NP dvCywu/y13zM2n//sPBRzUXdeZInBb2u9BmyuhSHP0cWxKahYhxcQuNE/aY6574QIfsj N4ephR1hEm9Ov0KbbRi1GySF7s9YcgSQ4Jk5aYwKidnbw9p7cTWeEFp+QJb1167/06rb FvW37u7enQECdGZSucnY/w4ybBlDgsYbAQMiqm3kuUu98vFsNf4TY+A4ftS8w6c1QCG7 V3hw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; 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 c47si1587074qta.277.2017.06.12.07.58.16 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 12 Jun 2017 07:58: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; 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]:38522 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dKQnG-0001wF-Jm for patch@linaro.org; Mon, 12 Jun 2017 10:58:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58228) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dKQky-0000uI-Ll for grub-devel@gnu.org; Mon, 12 Jun 2017 10:55:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dKQkx-0000uk-ET for grub-devel@gnu.org; Mon, 12 Jun 2017 10:55:52 -0400 Received: from mail-wr0-x230.google.com ([2a00:1450:400c:c0c::230]:32875) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dKQkx-0000uO-2S for grub-devel@gnu.org; Mon, 12 Jun 2017 10:55:51 -0400 Received: by mail-wr0-x230.google.com with SMTP id v104so99060637wrb.0 for ; Mon, 12 Jun 2017 07:55: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=YT2qqCsNAUUEhGh7ex2vZyFseNHCB1tlc2xBJM3ZK2g=; b=D3U7ertohlbfN9HQ78MHSP6d+jEmsm1w409ToXtmqTuhpqsFIbtNVgSgW/qkAMyilC rIpONoFuaFI6o6ZHfX5YJWVItpliS8wolyQN9nZ0pNPNkZ6fCsVm8LHyNGWQEwJmhCo3 O6Y9UsY3nAmltBr2z7+z+jjxgA1UfQ6V4jKGE= 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=YT2qqCsNAUUEhGh7ex2vZyFseNHCB1tlc2xBJM3ZK2g=; b=cKYaDYDPxbb5wuSdXGLLSFuRVizm1PFBMH928YU92cmQq9ESfyaIis1AxOyRlgeAMA PC1fyvuqVJnfCvtCpbVRrXiDG2FFE40Ux0dCU446GOB4hTEKR53jBOAuQykzNwj9ROoQ NYwGVAPsgAQaatQ4b2Zjmmf8XOvpUiPlidZLQqNMplLIe+gujb5Q7foA7fM0Hbo/SZCr JBN8YVrhp0O3sR7SsVXlgCl7IuVTWC1p63kKbBNckuagf9hO/wAT4W1qoqKXPBsDvwk/ 98a0xR/J0cBH771bsHY7F3oO1Zf4AxxX0ykfk5sKJG2yBXff4eEA5yFVDe2Rnjfkw+Kf srkA== X-Gm-Message-State: AODbwcC+DvzTK70kFCDKSZ533swsQWduHi1CYCS4bMRXAsDDP2O6W21O CmXcwcpUMy2ZB1MhIgXZQw== X-Received: by 10.223.154.15 with SMTP id z15mr8140131wrb.136.1497279345545; Mon, 12 Jun 2017 07:55:45 -0700 (PDT) Received: from mohikan.hemma.eciton.net (cpc92316-cmbg19-2-0-cust118.5-4.cable.virginm.net. [82.12.0.119]) by smtp.gmail.com with ESMTPSA id s140sm7722wmd.1.2017.06.12.07.55.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Jun 2017 07:55:44 -0700 (PDT) From: Leif Lindholm To: grub-devel@gnu.org Subject: [PATCH 2/7] efi: refactor grub_efi_allocate_pages Date: Mon, 12 Jun 2017 15:53:36 +0100 Message-Id: <20170612145341.3351-3-leif.lindholm@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170612145341.3351-1-leif.lindholm@linaro.org> References: <20170612145341.3351-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::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: ard.biesheuvel@linaro.org, lersek@redhat.com, agraf@suse.de, kraxel@redhat.com 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 460a4b763..7b1763bc5 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 845fc2438..904722174 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 Mon Jun 12 14:53:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 103630 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp233227qgd; Mon, 12 Jun 2017 07:57:49 -0700 (PDT) X-Received: by 10.55.152.198 with SMTP id a189mr17525996qke.63.1497279469531; Mon, 12 Jun 2017 07:57:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497279469; cv=none; d=google.com; s=arc-20160816; b=UPiOBulfnobbZ71ugcHmRHY+jF5EW2oIlYOcgTQXwYCUdtlzs3yS9OUZr561Q/yHXn HC4qVY06qbbGYpcPIQvJMTd9WEBj+bSn1oWW4e2St0aw/DcGq29dHQvrUQJ8OPyPWVf0 ueLXRNLe+ygJ44u7jLuqPesF/hRtDm2GDy6iVXt24GPtn/uknwgWKflGitqx/BRvfKEr U1sv34zP4gKQ32bTBkM6Yf4qQdhb3I9LDx1TF4iCVz4ob79UAqylhEq0bACEw7CWMSmq hBpGiOW1OlmxSiaWuttn2SUwdTWVmtsftikZuTjZOFeL4HDEaGXYf4Z0FRU6C44c5VZR jzuQ== 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=7fXQm/ciZMwTyFkNX7v+nUC99uZNbJRkCjGdBm/gyIY=; b=xt5SclYtMOUS/gJVvkgev4bX9WXlAgYQyiGVEfJRiep0FI3BRIZXZH+VB9J1wul2Fr vH/dPkag9o6N4gY/gmeb+U3L6wTXZRLno0FNLsT6rZ1JPTXep27YEq3hDL1BYqw1X6VS Oa64UAqSrcMXlBGITFlCAKJlgB7/T+NQVKOBxrRvlo1cBUq/B/zp2D2C1/GFOVN2NmM5 09Xjl8tHm3tmvOiYNJfVEg4XI+NApdkxsod/FHE+xeJTovNbgondIvcvJp+VOW6UM8c9 9dy2aixqF3H2GGNMot65dARybc395jZOtPY5NNn/FSwdPCBnspeamleq/L0wJN91sBaA Q89g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; 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 l2si8682006qki.34.2017.06.12.07.57.49 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 12 Jun 2017 07:57:49 -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; 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]:38520 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dKQmp-0001Xh-5J for patch@linaro.org; Mon, 12 Jun 2017 10:57:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58246) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dKQkz-0000v0-D4 for grub-devel@gnu.org; Mon, 12 Jun 2017 10:55:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dKQky-0000ut-9E for grub-devel@gnu.org; Mon, 12 Jun 2017 10:55:53 -0400 Received: from mail-wr0-x229.google.com ([2a00:1450:400c:c0c::229]:32883) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dKQky-0000uc-11 for grub-devel@gnu.org; Mon, 12 Jun 2017 10:55:52 -0400 Received: by mail-wr0-x229.google.com with SMTP id v104so99061064wrb.0 for ; Mon, 12 Jun 2017 07:55:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=LVR3mmhwnzyFHkPr1SCigm28f9HbDPOm/uRd+yyiCAU=; b=fy0E47Vdb7HEPGmPzbDuNlMisl9RCeyvARqLRyR9nJtnaoDRrFhG1KS/EzEwbglur3 a6hpvsI9slQEqmc1o29OUEj/A+ckb4V6INAgTheWKDjFcty1wtkPY3zj9exKl/2HSzbs xzHgcB+QuppNNIqYGeADDf32kZ+ijlytS5WCg= 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=LVR3mmhwnzyFHkPr1SCigm28f9HbDPOm/uRd+yyiCAU=; b=sllqx2Rxh7ipLG2q9VebR39xYgo3noci8Zc4x1PApshUXdlDduVTohSTBgW3L2xjsR E7behMsMaOQ9Ly3vtL0ESXfLKy4v4r6W5UIbENhRQ3pJDnV10Wtx0EzGWcPdlFDg+bXl cywiQl3ZbG0TPJmjAj/lBAkwm32doyT6PCAW/rgK1yGA7x6L+vA3GnYgqOe4iKvB4xHs vdWRKulpSAb6hzwNKsf0pg+eRubbg29T/HCQlXS3adM8CUg+uNkHTKeIS+ae0LPVnkJX yulPF/P84Yk5Rg0WocC2RRoINjR+GARV3JLeu+FkZPtuaY2TQ+3XctF3sYQBGnVV7F+k gyvw== X-Gm-Message-State: AKS2vOxE5G7qXTAHM59UqIhKU/mIYkucCPbTCNKO9L3mI+EEl+lEJvSX MUcZKxlUqWi8y8QRZJNJQg== X-Received: by 10.28.58.143 with SMTP id h137mr8242392wma.72.1497279346442; Mon, 12 Jun 2017 07:55:46 -0700 (PDT) Received: from mohikan.hemma.eciton.net (cpc92316-cmbg19-2-0-cust118.5-4.cable.virginm.net. [82.12.0.119]) by smtp.gmail.com with ESMTPSA id s140sm7722wmd.1.2017.06.12.07.55.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Jun 2017 07:55:45 -0700 (PDT) From: Leif Lindholm To: grub-devel@gnu.org Subject: [PATCH 3/7] efi: move fdt helper library Date: Mon, 12 Jun 2017 15:53:37 +0100 Message-Id: <20170612145341.3351-4-leif.lindholm@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170612145341.3351-1-leif.lindholm@linaro.org> References: <20170612145341.3351-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: ard.biesheuvel@linaro.org, lersek@redhat.com, agraf@suse.de, kraxel@redhat.com 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 move the EFI page size definitions to grub/efi/memory.h. (These definitions refer strictly to allocation operations, as opposed to translation granules.) --- grub-core/Makefile.core.def | 2 +- grub-core/loader/arm64/linux.c | 3 ++- grub-core/loader/arm64/xen_boot.c | 3 ++- grub-core/loader/{arm64 => efi}/fdt.c | 3 ++- include/grub/{arm64 => efi}/fdtload.h | 3 --- include/grub/efi/memory.h | 3 +++ 6 files changed, 10 insertions(+), 7 deletions(-) rename grub-core/loader/{arm64 => efi}/fdt.c (98%) rename include/grub/{arm64 => efi}/fdtload.h (89%) -- 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 9519d2e4d..cac94d53d 100644 --- a/grub-core/loader/arm64/linux.c +++ b/grub-core/loader/arm64/linux.c @@ -26,8 +26,9 @@ #include #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 27ede46ca..d092a53ed 100644 --- a/grub-core/loader/arm64/xen_boot.c +++ b/grub-core/loader/arm64/xen_boot.c @@ -27,9 +27,10 @@ #include #include #include -#include #include #include +#include +#include #include /* required by struct xen_hypervisor_header */ #include #include diff --git a/grub-core/loader/arm64/fdt.c b/grub-core/loader/efi/fdt.c similarity index 98% rename from grub-core/loader/arm64/fdt.c rename to grub-core/loader/efi/fdt.c index db49cf649..be369fd9d 100644 --- a/grub-core/loader/arm64/fdt.c +++ b/grub-core/loader/efi/fdt.c @@ -18,12 +18,13 @@ #include #include -#include #include #include #include #include #include +#include +#include static void *loaded_fdt; static void *fdt; diff --git a/include/grub/arm64/fdtload.h b/include/grub/efi/fdtload.h similarity index 89% rename from include/grub/arm64/fdtload.h rename to include/grub/efi/fdtload.h index 7b9ddba91..713c9424d 100644 --- a/include/grub/arm64/fdtload.h +++ b/include/grub/efi/fdtload.h @@ -29,7 +29,4 @@ grub_fdt_unload (void); grub_err_t grub_fdt_install (void); -#define GRUB_EFI_PAGE_SHIFT 12 -#define GRUB_EFI_BYTES_TO_PAGES(bytes) (((bytes) + 0xfff) >> GRUB_EFI_PAGE_SHIFT) - #endif diff --git a/include/grub/efi/memory.h b/include/grub/efi/memory.h index 20526b146..0eb0b70b6 100644 --- a/include/grub/efi/memory.h +++ b/include/grub/efi/memory.h @@ -22,6 +22,9 @@ #include #include +#define GRUB_EFI_PAGE_SHIFT 12 +#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 Mon Jun 12 14:53:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 103633 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp233780qgd; Mon, 12 Jun 2017 07:59:13 -0700 (PDT) X-Received: by 10.237.38.193 with SMTP id q59mr63459948qtd.69.1497279553404; Mon, 12 Jun 2017 07:59:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497279553; cv=none; d=google.com; s=arc-20160816; b=ixDMzP8VWku5uoqqz7h1FmkBn5ByKNwcgaJR4ZjpHgZNGjoi6d+k1ZkgHUscXWTjb4 gLfRt8d+fhe2Pw73oaEpD7j4poMAWhJacLg553QRC5ZvP+NWYAtlFBq9Z3eKhQTHeNts h1Reo8aC5bMNs2SPzeWV4conzXBsqs+BERxl+jOS6Vka89EyjZA13Zl+MW7WdCIkEebj 2LHEhJ9QIjiDP7zbdog1TC0UAL9D+CS8IXOpWblc7eCqWd7XuMwKpPlewuhD41bLXFWL T0cgVmhOPdCXWwGdIto26qyMOONHHtEMRrbuW4OH4mtaKU/IgJzWxeLjEl+GFy5oLRmn jwkA== 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=MZfAsxhunoPMts1lqUWWa+ZdJhTg38Hd1BcyuQxUJ2k=; b=CU3fxZcTRcnz/PZvnCqymrFlwuaONbOEty8RIlJiTvm0Ha2uUi5unihEOQpDdfv6jg 8V5VM50dgMrmfnHqececkV2Sm8FSuYL2D2GwfjxEiIuQl//uZ6sJFBedn2gkPAoD3LbG 6Digc43o/wiJib128ai+4eBPTmB/bRuVh3e1nBuDUsh7D16h9Q6WoLkbgAy8nzU2t3mk Lm0OMfkMOdrZ1FQMHrzqh6AOFV0SCxPDC2FWjynij7L1ls1HSGihhwz0EE29Gcp9spvV fFC5fB7oS/lCSURQeErhyGTMTrvasc8IqlofLbdZvwPD0nrx+6Gr3O30PPI7tuv/JSbq oBlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; 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 h64si8809992qtd.205.2017.06.12.07.59.12 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 12 Jun 2017 07:59:13 -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; 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]:38532 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dKQoA-0003UM-If for patch@linaro.org; Mon, 12 Jun 2017 10:59:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58303) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dKQl4-00010J-Fu for grub-devel@gnu.org; Mon, 12 Jun 2017 10:56:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dKQkz-0000vb-M5 for grub-devel@gnu.org; Mon, 12 Jun 2017 10:55:58 -0400 Received: from mail-wr0-x22f.google.com ([2a00:1450:400c:c0c::22f]:34101) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dKQkz-0000v9-CK for grub-devel@gnu.org; Mon, 12 Jun 2017 10:55:53 -0400 Received: by mail-wr0-x22f.google.com with SMTP id g76so98959730wrd.1 for ; Mon, 12 Jun 2017 07:55:53 -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=iCIpw4e86qzOQPVBLlBq0TZCFr9fqFMPEgxcEKoYylI=; b=VqIWFW9sagDpIADtTffZMgnvdUZFTNr/on2gteYO0f7Xe5dMZDEZUgUYFcBJ4P4Egf 1pSP3XWFkrgGPWQHAECnJRZUZUd92/EDTrfXUtEgMLqcI3VLNHxiMQ0CvSFYGV970psG DkhzZaUysWso4TpAAFBuPRwspUJcBi+yP42vc= 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=iCIpw4e86qzOQPVBLlBq0TZCFr9fqFMPEgxcEKoYylI=; b=TjMtuqkFcy+U4WLZ3FT/4d4BuHvkNWplKEmkceVsltjcHsJM94efCU8Kvp2+HxYaeu ig81Q7WD7uYr7fL0KI1xkTY1CjrY6+S69cFpw6KyNLV2Bn0io4v5wxEt4XdeJCws5hE/ 9aqHgrtjzraUmN5ccTar32qi3iYG8rmJvo2p7fgbEvONV6+ah5SMBbleItIoBZY7XqOE 1PhdGusjZ19oOvdFqE4TwM3wzD/0JCaMo9R7T62azZBQ6R1P7CzXkz+zDNN67MPp9YHq 64anYCxPh+ApSYY1AdwMwQ1gDwDhtKXbnwC/Qz78sImVXbULTHDneT0Y+AnKxeFg7Hof T2cg== X-Gm-Message-State: AKS2vOz1GtP+qYGTl2BpXwi5QZX75IeLFE0s7Jc7pRrc+ZRsiAe1NzrZ SfD+FZhccGfkBNoUCRF6mg== X-Received: by 10.223.150.39 with SMTP id b36mr8571999wra.149.1497279347405; Mon, 12 Jun 2017 07:55:47 -0700 (PDT) Received: from mohikan.hemma.eciton.net (cpc92316-cmbg19-2-0-cust118.5-4.cable.virginm.net. [82.12.0.119]) by smtp.gmail.com with ESMTPSA id s140sm7722wmd.1.2017.06.12.07.55.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Jun 2017 07:55:46 -0700 (PDT) From: Leif Lindholm To: grub-devel@gnu.org Subject: [PATCH 4/7] arm64: make efi linux loader more generic Date: Mon, 12 Jun 2017 15:53:38 +0100 Message-Id: <20170612145341.3351-5-leif.lindholm@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170612145341.3351-1-leif.lindholm@linaro.org> References: <20170612145341.3351-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::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: ard.biesheuvel@linaro.org, lersek@redhat.com, agraf@suse.de, kraxel@redhat.com MIME-Version: 1.0 Errors-To: grub-devel-bounces+patch=linaro.org@gnu.org Sender: "Grub-devel" In order to enable reuse of the arm64 efi linux loader for arm, change a few function names and macros. Add a global definition of GRUB_PE32_MAGIC in grub/efi/pe32.h. Make the arm64 efi loader (and fdt helpers) 32/64-bit safe. Also update the arm64 xen loader, since it depends on some of the functions in the linux loader. Signed-off-by: Leif Lindholm --- grub-core/loader/arm64/linux.c | 31 ++++++++++++++----------------- grub-core/loader/arm64/xen_boot.c | 12 ++++++------ grub-core/loader/efi/fdt.c | 8 ++++---- include/grub/arm64/linux.h | 13 ++----------- include/grub/efi/efi.h | 4 ++++ include/grub/efi/pe32.h | 2 ++ 6 files changed, 32 insertions(+), 38 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..8cd44230d 100644 --- a/grub-core/loader/arm64/linux.c +++ b/grub-core/loader/arm64/linux.c @@ -48,18 +48,16 @@ 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_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")); 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); @@ -111,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; @@ -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; @@ -175,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 @@ -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; } @@ -253,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); @@ -272,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(); @@ -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/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/grub-core/loader/efi/fdt.c b/grub-core/loader/efi/fdt.c index be369fd9d..e2899c47b 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; } diff --git a/include/grub/arm64/linux.h b/include/grub/arm64/linux.h index 1ea23696e..e53be83b1 100644 --- a/include/grub/arm64/linux.h +++ b/include/grub/arm64/linux.h @@ -19,14 +19,10 @@ #ifndef GRUB_LINUX_CPU_HEADER #define GRUB_LINUX_CPU_HEADER 1 -#include - -#define GRUB_ARM64_LINUX_MAGIC 0x644d5241 /* 'ARM\x64' */ - -#define GRUB_EFI_PE_MAGIC 0x5A4D +#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 */ @@ -40,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 904722174..395daeae3 100644 --- a/include/grub/efi/efi.h +++ b/include/grub/efi/efi.h @@ -89,6 +89,10 @@ 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); grub_err_t EXPORT_FUNC(grub_efi_get_dram_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); 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 Mon Jun 12 14:53:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 103644 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp236328qgd; Mon, 12 Jun 2017 08:03:01 -0700 (PDT) X-Received: by 10.237.46.65 with SMTP id j59mr10031793qtd.72.1497279781665; Mon, 12 Jun 2017 08:03:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497279781; cv=none; d=google.com; s=arc-20160816; b=B0DJ2IEfR3E4lLPRqZXrO5vPc1MS5wQNtTAJUnq9S44hAd1Ex0oj4mLwFyGiCNSL7W E+bdCUTiYW/va0zw+1XsmHRd3nCe3tfrNm9l/D4PlKgOvgDujKcyFu40d5ANWSkhWyhV wkhNho440PXDK3zQxWRjk9yLh0ocP6Ahp7foozPmDIAbnxABxhHzVPOhSKllAczVuM7G oSQhrPMr9JMAwe3IKjsO1xnm7TB5r5rhEFB/Evws20oREMr1Xslnq227yXKbI76O3H3r 0CGPsgJsLrG39aaGDJ3kEuqGOyI35O7SVgd+0C+0CH51UjYXJwMFPjhju2BRd3ttRMje 65hQ== 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=R9iZuaKaoE0XSgh1uTq+iyFEu594ttOFSxwKNp4gT9o=; b=Zwtsedj1KiSYFQAmtEHMVgDhpStNht3HkHaRv2THft76wLD5C68SBT9/jlEf68Sva9 IIrtsJxZp+MmU/CeMEOVdtk5ALJcr7oBMGav0XAl71Tlq3JnsNjYm+5lNxqd+G9i2hoQ d6bEcmHk+Os4vywFfCrB+hPn3ZudKbq6PFRWgd4ygN7ejMbOdY0cKzJY9vZ5AU+PMIax X8U6tO85Loh72hsKtdMsb0aikmdF40McqiHccULJekp+tGQD9rOpxPHEz1QjIriIWDCj UIYUwBovSPg9zpRQxDnDIS7SKeO1k9Jb2c1FNYsU2YszYXBjeMGzy9eFwPvC4Rt1mLqH cj5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; 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 x9si8945113qtx.134.2017.06.12.08.03.00 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 12 Jun 2017 08:03:01 -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; 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]:38565 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dKQrq-00070p-G7 for patch@linaro.org; Mon, 12 Jun 2017 11:02:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58287) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dKQl2-0000yj-TQ for grub-devel@gnu.org; Mon, 12 Jun 2017 10:55:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dKQl0-0000w3-LS for grub-devel@gnu.org; Mon, 12 Jun 2017 10:55:56 -0400 Received: from mail-wr0-x22f.google.com ([2a00:1450:400c:c0c::22f]:34108) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dKQl0-0000vX-5j for grub-devel@gnu.org; Mon, 12 Jun 2017 10:55:54 -0400 Received: by mail-wr0-x22f.google.com with SMTP id g76so98960250wrd.1 for ; Mon, 12 Jun 2017 07:55:53 -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=UAErhnnSyKp7m1+z7Ss36RfryDUf5ov04noWAvoabfA=; b=C1u+utxHXziTnDVl8qjdbk+GxFmYweE6dHUZFTXrBAJiDlAs4ZWGqt1RvpGUpupTMx DuKsnEQvITLewsEEIFyrOMi2IyGIowDxBC8nzkl/TFh5I7qiLkIKPDxQAK0hVE/8TRlW tsrTRvTRjavKOHwdhJMDt3LoX8hqZqtzqXvaI= 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=UAErhnnSyKp7m1+z7Ss36RfryDUf5ov04noWAvoabfA=; b=VNM6LTjF75eZm3IBbRfOlsZrSb/r1U4MmQU9vgH8miDLwhISugg7nONn61hqkfMxF8 wvue/qcmJ4EJRXVIuyO2wB1Ikxwcysrab7uhqumkf3JLnb0NPorP6XbzKRpiWfVAQpMt re+pl8Gt8yuNSQd6sbhJZnCJs6HFQElpkncdbZVFMeZeiq5ijOCMK2N+/XYyp76X+XZN iPXv74uZytF/lGAcK5WaKXkOjCS7UGjX+Efmi+oR4fG8ljuTCFNc15dY4sGE54eLpDUu +0TW6SgpdYJLncDhTf+c8njS/UDxNQXzaMrKEOeJALVxDhUscQk7ZcK0mx20EtkQrrWy lVug== X-Gm-Message-State: AKS2vOy3Q8ISvtuFZDSzpI6Aw8I3kOzySYVrp06ZmBxxQuaoxrv66e1s lEud58VntzmPF/7OzlhFoA== X-Received: by 10.28.88.3 with SMTP id m3mr8052362wmb.28.1497279348355; Mon, 12 Jun 2017 07:55:48 -0700 (PDT) Received: from mohikan.hemma.eciton.net (cpc92316-cmbg19-2-0-cust118.5-4.cable.virginm.net. [82.12.0.119]) by smtp.gmail.com with ESMTPSA id s140sm7722wmd.1.2017.06.12.07.55.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Jun 2017 07:55:47 -0700 (PDT) From: Leif Lindholm To: grub-devel@gnu.org Subject: [PATCH 5/7] arm: reuse arm64 linux loader on efi systems Date: Mon, 12 Jun 2017 15:53:39 +0100 Message-Id: <20170612145341.3351-6-leif.lindholm@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170612145341.3351-1-leif.lindholm@linaro.org> References: <20170612145341.3351-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::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: ard.biesheuvel@linaro.org, lersek@redhat.com, agraf@suse.de, kraxel@redhat.com MIME-Version: 1.0 Errors-To: grub-devel-bounces+patch=linaro.org@gnu.org Sender: "Grub-devel" The original 32-bit arm EFI Linux loader reused the 32-bit Linux loader for U-Boot. However, this meant it was acting in an entirely not UEFI-compliant fashion. Since EFI stub loader support for arm went into upstream Linux for 4.5, we can now reuse the same loader as is used on arm64. This results in some now-redundant code being dropped from the U-Boot linux loader, and the arm efi port in general. This also drops the ability to boot kernels without the efi stub support on 32-bit arm efi grub. Signed-off-by: Leif Lindholm --- grub-core/Makefile.am | 1 - grub-core/Makefile.core.def | 6 +- grub-core/kern/arm/efi/misc.c | 202 ------------------------------------------ grub-core/loader/arm/linux.c | 39 ++------ include/grub/arm/efi/loader.h | 26 ------ include/grub/arm/efi/memory.h | 3 + include/grub/arm/linux.h | 30 +++---- 7 files changed, 22 insertions(+), 285 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/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/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 260cbf068..8d50f77e9 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) @@ -293,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); @@ -315,17 +303,12 @@ 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); -#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); @@ -337,9 +320,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) @@ -429,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/efi/memory.h b/include/grub/arm/efi/memory.h index 2c64918e3..986f656d6 100644 --- a/include/grub/arm/efi/memory.h +++ b/include/grub/arm/efi/memory.h @@ -3,4 +3,7 @@ #define GRUB_EFI_MAX_USABLE_ADDRESS 0xffffffff +#define GRUB_EFI_PAGE_SHIFT 12 +#define GRUB_EFI_BYTES_TO_PAGES(bytes) (((bytes) + 0xfff) >> GRUB_EFI_PAGE_SHIFT) + #endif /* ! GRUB_MEMORY_CPU_HEADER */ diff --git a/include/grub/arm/linux.h b/include/grub/arm/linux.h index f217f8281..98ff4c004 100644 --- a/include/grub/arm/linux.h +++ b/include/grub/arm/linux.h @@ -20,32 +20,26 @@ #ifndef GRUB_LINUX_CPU_HEADER #define GRUB_LINUX_CPU_HEADER 1 -#define LINUX_ZIMAGE_OFFSET 0x24 -#define LINUX_ZIMAGE_MAGIC 0x016f2818 +#define GRUB_LINUX_MAGIC_SIGNATURE 0x016f2818 -#include "system.h" +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 "system.h" # include # define LINUX_ADDRESS (start_of_ram + 0x8000) # define LINUX_INITRD_ADDRESS (start_of_ram + 0x02000000) # 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 @@ -64,6 +58,4 @@ grub_arm_firmware_get_machine_type (void) } #endif -#define FDT_ADDITIONAL_ENTRIES_SIZE 0x300 - #endif /* ! GRUB_LINUX_CPU_HEADER */ From patchwork Mon Jun 12 14:53:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 103643 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp235869qgd; Mon, 12 Jun 2017 08:02:24 -0700 (PDT) X-Received: by 10.237.63.182 with SMTP id s51mr55306907qth.61.1497279744489; Mon, 12 Jun 2017 08:02:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497279744; cv=none; d=google.com; s=arc-20160816; b=Z9k3PVGt1xrwEYHtAHlnHyEnQJnx8bY0pw67VxMLX+SarRZheU/MWp0Km1+IhMkY+e Lw+iPQWxVK3+ceVR1ef6pVhgrEoXeTKcFTlqMUuH0LYdB96JiKSi6LgUA+x1NeI5BX15 YVPOsbsgx5zQ3GVsQBxFzxxcpVnsse+q9FFtnnRG1GK50D9pvHVtBxTWy+x2fYfSeKJ4 c+a+IutAJIhnzStM0HFJ3Zqhd0p0q6uEK5I11khnkiILchA5uquZYwxMdCIKlUEX3W6z mMr8Nr/x2MN4vz0FPyD5uNEwVgsyryNPU/ro3KDy76PaH/OlsyL6EhbCPwOSDCvO0Nh9 101A== 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=tX5ldvnd8pXabiGA9TANkHUpNFvwHOucXSqCtPC7vIw=; b=cmMMSLYjge/+PCF+g1jykvnxPuvew/RBRTCwqBhlbJ5aaZ/EnZO+41g3DMRnVHYL2F Bgr2WTRkefUjntHj50vD7JjR6MqYBg9Jt8VZbj9zejlD1rOOT7jj04M3WGGPhDnqTlVt EhZWIrQn2cJaUU1ZaASk1/YUSopBPUlgA8gMGFAC3xzPrfF665A2YJe+Qzcqa2QsoMyQ ljaKZaVdwc4ugV2dKJvrZjkH6KJwG6EXfs2XEAZsWN5mk/Y+CiiJ4ObfnFkVSe5dTHh8 Ojo/sl6rhQ24fhygdy1cwKOb5ePUcDckyMtRN6hC6ccQ5EOtaip4cP9CjeCnneSySaGh QT7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; 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 v69si9052612qkb.125.2017.06.12.08.02.24 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 12 Jun 2017 08:02:24 -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; 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]:38553 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dKQrG-0005nh-48 for patch@linaro.org; Mon, 12 Jun 2017 11:02:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58280) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dKQl2-0000yP-GP for grub-devel@gnu.org; Mon, 12 Jun 2017 10:55:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dKQl1-0000wK-Br for grub-devel@gnu.org; Mon, 12 Jun 2017 10:55:56 -0400 Received: from mail-wr0-x236.google.com ([2a00:1450:400c:c0c::236]:32900) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dKQl0-0000vv-Vr for grub-devel@gnu.org; Mon, 12 Jun 2017 10:55:55 -0400 Received: by mail-wr0-x236.google.com with SMTP id v104so99062529wrb.0 for ; Mon, 12 Jun 2017 07:55:54 -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=uUMXXzs9lDnMkuvXX0lJdSXJVTvkG20S6kNTA3DIhYE=; b=ShUmsDdbffXoVkK4w2XArH/GZqozgAOKapwxVgKrIPvDfBFqEw9l6DKxI1lIstBCmw UK6Jpmax3FnIY40TEBTjzbFl/e183O8JmQCNzN5jZuCVdKQi2vsLwNckTtTTRzWg8r/Y Fctbujbgj+YpI9sUMHHaT+E2Bwcme8XNmglfI= 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=uUMXXzs9lDnMkuvXX0lJdSXJVTvkG20S6kNTA3DIhYE=; b=M1K5HiIdX8rQA4YPwmc7I06kMT1Kx2lc6w5zv3XqyRoC9Nj5X82W4WAWL0NMZbxk44 e/6BfgaTPa+0ggU+QBWcfg33mn+rm73rX8oxT+VGOzIJz/4EI1XaG7pgpT1waAMGujC4 hHedQhXyl3zluBmHOuA8A8VPSlfV6kBVRf7uBBP9tctEpxy+uHE0MqivVJYI5zXYAkne 67ifm7jdrP/9V1wPz1QbqJCAXygnzQVPelzg7kPm31+pfi31zwHoCztdN4GO0nJNHXrN tJ4hQcxqMZMbSNhyAAaaJJF/+wJp+hgLqti0O2XbCCosWZuk13v5U0GM0lRWFZeH+3yx hNTw== X-Gm-Message-State: AKS2vOw26Ar77TTtcmgJfQUL5OeWyW/DybGvT+bAWu37n+emNCFdWm7y bYiDOVjhYL04INPXJzHXhw== X-Received: by 10.28.13.1 with SMTP id 1mr8401446wmn.12.1497279349268; Mon, 12 Jun 2017 07:55:49 -0700 (PDT) Received: from mohikan.hemma.eciton.net (cpc92316-cmbg19-2-0-cust118.5-4.cable.virginm.net. [82.12.0.119]) by smtp.gmail.com with ESMTPSA id s140sm7722wmd.1.2017.06.12.07.55.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Jun 2017 07:55:48 -0700 (PDT) From: Leif Lindholm To: grub-devel@gnu.org Subject: [PATCH 6/7] efi: restrict arm/arm64 linux loader initrd placement Date: Mon, 12 Jun 2017 15:53:40 +0100 Message-Id: <20170612145341.3351-7-leif.lindholm@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170612145341.3351-1-leif.lindholm@linaro.org> References: <20170612145341.3351-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: ard.biesheuvel@linaro.org, lersek@redhat.com, agraf@suse.de, kraxel@redhat.com 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..7e989c2b9 100644 --- a/grub-core/loader/arm64/linux.c +++ b/grub-core/loader/arm64/linux.c @@ -35,6 +35,23 @@ GRUB_MOD_LICENSE ("GPLv3+"); +/* + * 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 + static grub_dl_t my_mod; static int loaded; @@ -194,6 +211,25 @@ 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_dram_base (&max_addr) != GRUB_ERR_NONE) + return NULL; + + 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 Mon Jun 12 14:53:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 103642 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp235092qgd; Mon, 12 Jun 2017 08:01:24 -0700 (PDT) X-Received: by 10.55.88.194 with SMTP id m185mr68383203qkb.230.1497279684862; Mon, 12 Jun 2017 08:01:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497279684; cv=none; d=google.com; s=arc-20160816; b=w42WVGktzjJVdbPiO9wouTHwKJFANi5fBpS9Tw2Pi8VGNSFQxyfQzSW+qe0B8zqXwO pgkVsXuB5LatMijf7XuE5NBt1qYEESJU5riZveEjZGYL9hk9pSUGvvEpAHJ68IcfrwlO uuf41qgCTdu1KWIewPx0eevhcH7v6b8OR6GCfMWcR0LzG/+qjlXSSdahdp7NlujpHVbJ 5jwskG07pgwwIjMt/lumRuejehuWE7DBRj1fIph7kxKKC+M1t32G8aNb+NVFjGKbkrzO 6lfDr1fOBeHbye9AzvWYTfUbXiuJ8QH92ty5nvsa/fAblnR0wMFh+LooDtl2UiFfBrQr 8URA== 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=KsGghTS49iDVpanbD2gDDvEt7MlfdUV/DHg8AFdqbkw=; b=kxWKusORxW1V7+clxWgqgvhTLe/Sz77lsofCR0RbJZmgMvYh5KAh6/KQmevhNcOd05 njSDELedAmT6sybroCaFmPD/HKIKugQQiAmnzrULAE4ASOOmtao0s89MuX3PJ/uFSLo/ suRG1l7y8/303xKQ3Bw1rFF1QKh7Sb0JI9VjPDvQKzZyR7yJuLCWkIVH3XpllhDoCODQ pTypBCUQEDlvSrnGF0yGkVFHKItTW4TB17rPmrMOyIKTVAuImoTcNsOhhALGP4Fx5hbD lzMJLWohQKzrwyodmX3eWcv4++0MzT0PwSuqfmoly16YS3iuCHynkvEnUWsrS1O1FJeJ fukA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; 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 o32si4154533qko.165.2017.06.12.08.01.24 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 12 Jun 2017 08:01:24 -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; 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]:38546 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dKQqI-00053B-G4 for patch@linaro.org; Mon, 12 Jun 2017 11:01:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58283) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dKQl2-0000yZ-NT for grub-devel@gnu.org; Mon, 12 Jun 2017 10:55:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dKQl2-0000wU-0h for grub-devel@gnu.org; Mon, 12 Jun 2017 10:55:56 -0400 Received: from mail-wr0-x231.google.com ([2a00:1450:400c:c0c::231]:34117) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dKQl1-0000w8-Kt for grub-devel@gnu.org; Mon, 12 Jun 2017 10:55:55 -0400 Received: by mail-wr0-x231.google.com with SMTP id g76so98960973wrd.1 for ; Mon, 12 Jun 2017 07:55:55 -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=k40hvaiiAPb9KtxKtSUVxyRM1mHccocC4rK6H4oUbnw=; b=Be0pDOLWyxaDJhqikeByrZN/OiS/thFX8N8ujt4R9hOq/CERnPzk3e4wK3YPV3/aJV Hr5yOZDAbBXLdBhZZ1LO6NvNHF8MQ/ALQn8uvkgP2hJAaFgfJtghZqhFVbo0ERyNTI7n iNwlzb94dlzFXCNDD2LZhMMGFZ8beZT0knC+I= 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=k40hvaiiAPb9KtxKtSUVxyRM1mHccocC4rK6H4oUbnw=; b=b0paLnROPUbyPl2QfAiMlFCGLB6oF1A5oWmbH9lULF/MGx1GFD4myFh8lnx7O/XafX TZFUViFsJZDmKuL9DPRQ6cKkExS44OrXg4PpZLeYIseIMEQF71/eOiyZvg3p10Oa9rpM spFX9y4EnSwl216UXQWWJWWKkinoKsBBHVjFiYOBS434/sRNVH18977rHUhSuguj36wF Fc32KKOmBnrTppfwOPjazVSaEXae/WJAeWCVMTBekcaa/6o6OQsyvb2PCBWvFue8ipd0 ler0FUBjB+QuXeselrs6D/Fd11Vu8mKH+yTRswHrnkYqGOgtvi2MOQD413z2Ke7KVTNg oilQ== X-Gm-Message-State: AODbwcAhsF0gJFlrx0WeE/hdnxA9+YjJzZacK5mB6U8Py1SNooLytmMA yOhWtIoOrzetJs8GyZfIbw== X-Received: by 10.223.162.156 with SMTP id s28mr8613653wra.97.1497279350197; Mon, 12 Jun 2017 07:55:50 -0700 (PDT) Received: from mohikan.hemma.eciton.net (cpc92316-cmbg19-2-0-cust118.5-4.cable.virginm.net. [82.12.0.119]) by smtp.gmail.com with ESMTPSA id s140sm7722wmd.1.2017.06.12.07.55.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Jun 2017 07:55:49 -0700 (PDT) From: Leif Lindholm To: grub-devel@gnu.org Subject: [PATCH 7/7] efi: change heap allocation type to GRUB_EFI_LOADER_CODE Date: Mon, 12 Jun 2017 15:53:41 +0100 Message-Id: <20170612145341.3351-8-leif.lindholm@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170612145341.3351-1-leif.lindholm@linaro.org> References: <20170612145341.3351-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::231 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: ard.biesheuvel@linaro.org, lersek@redhat.com, agraf@suse.de, kraxel@redhat.com 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 7b1763bc5..f27a48e68 100644 --- a/grub-core/kern/efi/mm.c +++ b/grub-core/kern/efi/mm.c @@ -404,7 +404,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),