From patchwork Mon Jul 9 17:33:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 141476 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp2923671ljj; Mon, 9 Jul 2018 10:34:25 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdS9fE3ITpMaR7vioZd2RDYzNKbO7GzLEN23AlN1GIx2tzolZOeolQzXadcF3PFXKHXT5ER X-Received: by 2002:a37:2711:: with SMTP id n17-v6mr10617436qkn.109.1531157665683; Mon, 09 Jul 2018 10:34:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531157665; cv=none; d=google.com; s=arc-20160816; b=LezA9COozxItU35usJq4Y+52zrXZaAcAu8KHhVjBcGfxATRzobZ5JA5JssQVDC8LX4 K/+5O4rymbUbFz736f7bkhxOHyUHDXcSuieQ2J+dWeCN0rMXSgcZEUk/+CFlMlb4efGI nnPB2tWq1VD/lIc80ab4AyFlbgDdXHUdetNr3AZyQRtWveTaOg6sHZNUABy4ExgDIRp6 V+jYnybkNRTQJGmTtm9TU95c8TqR7zP/0W42RduOEoBkCFvuhNYAtB6G9Ai2AxHDlREM AkUMwI1ZvhQQT5+J1W9lbl7WerYVp7vMfcxFP4fkmSMhcOk/0LdY0b1MmQU+1kxq3WIs Q4BA== 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=g5LxAi21zjTnek3uOSNvwIYONtnuGm3j8k0V0EgIZps=; b=syvqEZ9kPSaFcHpHVFRKflxsyJIdZk6rUeGXtcNEZK7bavnZeelBJjRjzKvQLMG4jH gEhxTNSaMfWH3Mhx4XrbBH3v6esgtlee1adaFPNUECmGx4FqfGP0UmEm4dtgb1R5J/mx 738DnBCia2PFhXZSBwd6YAnfHzQ8HyC4admd36t46M9it8dEcO0p9WsVS9/bJNBkmGcE +EIZkihjgO4ybXroZuR9tNyCOyz5YiS3AMVgACEfgnkEWGlguC1e2kEyUY5u5sxsR2Qb /encEeIeNQMizTX/csxClrCGhIkaHy2rCGzVIAMnzUOpCCCXIT1q4wdcu4cc8EpERfQ2 evDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=DLHR8k4r; 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 u26-v6si1223521qtf.173.2018.07.09.10.34.25 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 09 Jul 2018 10:34:25 -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=DLHR8k4r; 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]:43607 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fca3N-0000KH-27 for patch@linaro.org; Mon, 09 Jul 2018 13:34:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44241) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fca2D-0000H7-QX 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 1fca2A-0002fP-BD for grub-devel@gnu.org; Mon, 09 Jul 2018 13:33:13 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:34626) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fca2A-0002f3-45 for grub-devel@gnu.org; Mon, 09 Jul 2018 13:33:10 -0400 Received: by mail-wr1-x442.google.com with SMTP id c13-v6so11785853wrt.1 for ; Mon, 09 Jul 2018 10:33:10 -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=0cYpTbGsvEvA8ODG7yCjNOLULulzByq9vMajAfVdP8o=; b=DLHR8k4rAszQAm0MeFj10dDrzgPxUWTZ8JT3k82XmazQ13+RwQz1N7TDlJQT6JLodv 5ifVyMX/u02+hou7odXKvCtmuCTxB+MNuTzl53essmffb+2BnQJxG/C92vTx+9gezFRg 5Rn7PhKF5y5odNmZ1jdrzgNVvn9/mvsOhJJ/o= 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=0cYpTbGsvEvA8ODG7yCjNOLULulzByq9vMajAfVdP8o=; b=tCZIHHjxWkXs7CjxeDn5v8Ut/0Sc5DojFmizYcRAc1cuMJ/hvg4Wze7EwxS9iqJ4NF +1tLr+ujzqN77mEJFNBuPIAjKk6xnssFotpvu129iPXbbaZlFh++yzWE34p2FATUoHOf iE42AfeBvJkJyQ38FGNhZdYnrq1oto9fnYLorD1Pr08EzVmdRQViUecTM1ZSKmJsk3Bv FeQgDGGY9Jfq7ZRJRZPrekvGDkLodxYPhqRA2mJ5CBewq5NxvzhJtqFD0mErscovByJi tPT43d7B5sETd/Z9q5omE/pmDtFxfmhoAb/JEEoxfWiySLgnRw6TOVr9EBg33mTulY9I GsWA== X-Gm-Message-State: APt69E0REa/NCbkaIICBiNKcAMPdrI/sNAY9bDZPFZnUh27Kt4tiFulc 6rDe4iQdkQ/rihs/VrXN9rFuxNNqshY= X-Received: by 2002:adf:9582:: with SMTP id p2-v6mr14943782wrp.252.1531157588831; Mon, 09 Jul 2018 10:33:08 -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.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Jul 2018 10:33:07 -0700 (PDT) From: Leif Lindholm To: grub-devel@gnu.org Subject: [PATCH v4 1/6] efi: add central copy of grub_efi_find_mmap_size Date: Mon, 9 Jul 2018 18:33:00 +0100 Message-Id: <20180709173305.17588-2-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::442 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: The development of GNU GRUB Cc: Daniel Kiper MIME-Version: 1.0 Errors-To: grub-devel-bounces+patch=linaro.org@gnu.org Sender: "Grub-devel" There are several implementations of this function in the tree. Add a central version in grub-core/efi/mm.c. Signed-off-by: Leif Lindholm --- grub-core/kern/efi/mm.c | 20 ++++++++++++++++++++ include/grub/efi/efi.h | 1 + 2 files changed, 21 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 c48e9b5c7..fd39d23b4 100644 --- a/grub-core/kern/efi/mm.c +++ b/grub-core/kern/efi/mm.c @@ -286,6 +286,26 @@ grub_efi_finish_boot_services (grub_efi_uintn_t *outbuf_size, void *outbuf, return GRUB_ERR_NONE; } +/* To obtain the UEFI memory map, we must pass a buffer of sufficient size + to hold the entire map. This function returns a sane start value for + buffer size. */ +grub_efi_uintn_t +grub_efi_find_mmap_size (void) +{ + grub_efi_uintn_t mmap_size = 0; + grub_efi_uintn_t desc_size; + + if (grub_efi_get_memory_map (&mmap_size, NULL, NULL, &desc_size, 0) < 0) + { + grub_error (GRUB_ERR_IO, "cannot get EFI memory map size"); + return 0; + } + + /* Add an extra page, since UEFI can alter the memory map itself on + callbacks or explicit calls, including console output. */ + return ALIGN_UP (mmap_size + GRUB_EFI_PAGE_SIZE, GRUB_EFI_PAGE_SIZE); +} + /* Get the memory map as defined in the EFI spec. Return 1 if successful, return 0 if partial, or return -1 if an error occurs. */ int diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h index c996913e5..1021273c1 100644 --- a/include/grub/efi/efi.h +++ b/include/grub/efi/efi.h @@ -49,6 +49,7 @@ void * EXPORT_FUNC(grub_efi_allocate_any_pages) (grub_efi_uintn_t pages); void EXPORT_FUNC(grub_efi_free_pages) (grub_efi_physical_address_t address, grub_efi_uintn_t pages); +grub_efi_uintn_t EXPORT_FUNC(grub_efi_find_mmap_size) (void); int EXPORT_FUNC(grub_efi_get_memory_map) (grub_efi_uintn_t *memory_map_size, grub_efi_memory_descriptor_t *memory_map, From patchwork 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); From patchwork Mon Jul 9 17:33:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 141477 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp2923693ljj; Mon, 9 Jul 2018 10:34:26 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcuzRuWKBVgARpxtz6pWS4QkBRg46gRNdTIkhh/U+J7j0mdNvUn6bv3Dj01O6kx5iMo1osI X-Received: by 2002:a37:ab17:: with SMTP id u23-v6mr18466957qke.279.1531157666224; Mon, 09 Jul 2018 10:34:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531157666; cv=none; d=google.com; s=arc-20160816; b=KjIFruKg5D3lpW5sVSww8w6GYZNBfAaNSMzhg+DddWuAuQ3aF8SDoXdlwDjIFpfsya zlccoJCP2hyP9+KRt1Rwlh+fH6xa0loqpxlRRkLu2MOBbDzPJf7vftziLWt+odjRr7qD 6aVu5PonelV/9dpoRt2//GBGnUzRL2rEdgEC1g7S5stB2T0SPCxLWvG4Zag5Ah4a3IzV sCro2CDGacGoshI7N7La5EG8XzmTls94vFa87OhwJ/3wXTPxTGCS8s+W0Sc3v+tbrt5W DIqv6oEtpHPos6ft+XOP6wLExjzwykFeJUGB3nEnqYjeCBiwTETu38mNIeWbRnvHYJLQ FjwA== 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=MJFO/8cj5wYavyPNYn4mheI326p6n5jWs3oq04rKmmg=; b=TW2oliGOPUbwmdqlsseRSYefPmpIrpGBXBsAqRineBw0drD0vT9b7s2bhcY9+8f/ap nCUEIyxww0PqwdXrDtxZbn960iPC9D/Vj5RU239rh1GB9FcvDUjgd/eEC0up5fK13Qkg pifzEpZCeqbF0Viuu3Qmr/LB/00O39Hl2NFhsV7jqYrGq/IiUgcXpragyOemiU/jwk4F lbDCb8WhultXfSyocNiOcmvZq82fRja4zhsBJbvAd6qbZHH69tpSRtoAofSNztVyQSOO Wxuw2h1g7/JxRyK5i1xa86gIgdx4REV6sCyt4UBaLBEs4q66swqW88H5vALDAnw1c8Wd niag== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b="dA+Y/G6p"; 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 o62-v6si1925869qkc.112.2018.07.09.10.34.25 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 09 Jul 2018 10:34:26 -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="dA+Y/G6p"; 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]:43608 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fca3N-0000LJ-H3 for patch@linaro.org; Mon, 09 Jul 2018 13:34:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44270) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fca2E-0000I9-Gm for grub-devel@gnu.org; Mon, 09 Jul 2018 13:33:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fca2D-0002gO-EU for grub-devel@gnu.org; Mon, 09 Jul 2018 13:33:14 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:34950) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fca2D-0002fy-5W for grub-devel@gnu.org; Mon, 09 Jul 2018 13:33:13 -0400 Received: by mail-wr1-x444.google.com with SMTP id a3-v6so2591010wrt.2 for ; Mon, 09 Jul 2018 10:33:13 -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=0E35Ed+bLDcoVv3jWhX8CibdX5rV2j7zVhQfj075eio=; b=dA+Y/G6p5SUCzvDHYl9hoN0/8oKb1CvhLepXVPvzUoKasvSK+u6nSKEAY85/1PfuSL M0hjsSQfPDqkWI812ehZE+nQyosn5S6vWicjfn+tSa/GOEJTC4GF7CF1PPWWQfCTbxcT 1q7WKg1cc0NxmnDbq56eTnP7V0+ZTsxDmvP8A= 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=0E35Ed+bLDcoVv3jWhX8CibdX5rV2j7zVhQfj075eio=; b=sSnQd341YDCD8+hB+9QNpDrEhiMnrx3y4bnGEQUgJoc4hasfDV/nAVOeRIP4k5CZQq vs/X/bY5TxsPL4ToQtz21xKL/QhwrtnMK1xxZELdxxpdWWkM9NSJ06XbbSxezbXtpxZw mEyqJz7asU4UklDGckBiXPsZtjLfzQlzfEjaPmiLEj3eRjqNdpHpVvOO8q7fNE6t0f8X 4Nfy3kOSfb3q4n9igmKdawAWL8qZ8865LAL0jTz2upBMvmO69Su48WfYvQ1kRF0ZKAa1 /LxgxO2RJlJvLzNU8drPGQcmScTCErhSOh6BNclQQJRmAWmmiKYBjZ/K2teBzqzMvf8w v9gQ== X-Gm-Message-State: APt69E1Ke3dnJ7DZ1+/7+RJ2suo13DnSg4e8CWeu+0RYpZcoqxwj0pik 2Z2WXraJMdWhDUz+x+QKzmsrWFJrBQA= X-Received: by 2002:adf:d4c4:: with SMTP id w4-v6mr14708514wrk.185.1531157591868; Mon, 09 Jul 2018 10:33:11 -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.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Jul 2018 10:33:10 -0700 (PDT) From: Leif Lindholm To: grub-devel@gnu.org Subject: [PATCH v4 3/6] arm64 linux loader: rename functions and macros and move to common headers Date: Mon, 9 Jul 2018 18:33:02 +0100 Message-Id: <20180709173305.17588-4-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::444 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: The development of GNU GRUB Cc: Daniel Kiper MIME-Version: 1.0 Errors-To: grub-devel-bounces+patch=linaro.org@gnu.org Sender: "Grub-devel" In preparation for using the linux loader for 32-bit and 64-bit platforms, rename grub_arm64*/GRUB_ARM64* to grub_armxx*/GRUB_ARMXX*. Move prototypes for now-common functions to efi/efi.h. Signed-off-by: Leif Lindholm --- grub-core/loader/arm64/linux.c | 14 +++++++------- grub-core/loader/arm64/xen_boot.c | 10 +++++----- include/grub/arm64/linux.h | 9 ++++----- include/grub/efi/efi.h | 4 ++++ 4 files changed, 20 insertions(+), 17 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 ebe1e730d..f90c5f926 100644 --- a/grub-core/loader/arm64/linux.c +++ b/grub-core/loader/arm64/linux.c @@ -48,9 +48,9 @@ static grub_addr_t initrd_start; static grub_addr_t initrd_end; grub_err_t -grub_arm64_uefi_check_image (struct linux_arm64_kernel_header * lh) +grub_armxx_efi_linux_check_image (struct linux_armxx_kernel_header * lh) { - if (lh->magic != GRUB_LINUX_ARM64_MAGIC_SIGNATURE) + if (lh->magic != GRUB_LINUX_ARMXX_MAGIC_SIGNATURE) return grub_error(GRUB_ERR_BAD_OS, "invalid magic number"); if ((lh->code0 & 0xffff) != GRUB_PE32_MAGIC) @@ -109,7 +109,7 @@ failure: } grub_err_t -grub_arm64_uefi_boot_image (grub_addr_t addr, grub_size_t size, char *args) +grub_armxx_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; @@ -172,8 +172,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_armxx_efi_linux_boot_image((grub_addr_t)kernel_addr, + kernel_size, linux_args)); } static grub_err_t @@ -249,7 +249,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), int argc, char *argv[]) { grub_file_t file = 0; - struct linux_arm64_kernel_header lh; + struct linux_armxx_kernel_header lh; grub_dl_ref (my_mod); @@ -268,7 +268,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_armxx_efi_linux_check_image (&lh) != GRUB_ERR_NONE) goto fail; grub_loader_unset(); diff --git a/grub-core/loader/arm64/xen_boot.c b/grub-core/loader/arm64/xen_boot.c index 258264c79..1003a0b99 100644 --- a/grub-core/loader/arm64/xen_boot.c +++ b/grub-core/loader/arm64/xen_boot.c @@ -265,9 +265,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_armxx_efi_linux_boot_image (xen_hypervisor->start, + xen_hypervisor->size, + xen_hypervisor->cmdline); } static void @@ -468,8 +468,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 linux_arm64_kernel_header *) &sh) != GRUB_ERR_NONE) + if (grub_armxx_efi_linux_check_image + ((struct linux_armxx_kernel_header *) &sh) != GRUB_ERR_NONE) goto fail; grub_file_seek (file, 0); diff --git a/include/grub/arm64/linux.h b/include/grub/arm64/linux.h index b06347624..8655067e0 100644 --- a/include/grub/arm64/linux.h +++ b/include/grub/arm64/linux.h @@ -19,8 +19,6 @@ #ifndef GRUB_ARM64_LINUX_HEADER #define GRUB_ARM64_LINUX_HEADER 1 -#include - #define GRUB_LINUX_ARM64_MAGIC_SIGNATURE 0x644d5241 /* 'ARM\x64' */ /* From linux/Documentation/arm64/booting.txt */ @@ -38,8 +36,9 @@ struct linux_arm64_kernel_header grub_uint32_t hdr_offset; /* Offset of PE/COFF header */ }; -grub_err_t grub_arm64_uefi_check_image (struct linux_arm64_kernel_header *lh); -grub_err_t grub_arm64_uefi_boot_image (grub_addr_t addr, grub_size_t size, - char *args); +#if defined(__aarch64__) +# define GRUB_LINUX_ARMXX_MAGIC_SIGNATURE GRUB_LINUX_ARM64_MAGIC_SIGNATURE +# define linux_armxx_kernel_header linux_arm64_kernel_header +#endif #endif /* ! GRUB_ARM64_LINUX_HEADER */ diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h index 57db74b57..1deaa3c8f 100644 --- a/include/grub/efi/efi.h +++ b/include/grub/efi/efi.h @@ -95,6 +95,10 @@ void *EXPORT_FUNC(grub_efi_get_firmware_fdt)(void); #endif #if defined(__aarch64__) grub_err_t EXPORT_FUNC(grub_efi_get_ram_base)(grub_addr_t *); +#include +grub_err_t grub_armxx_efi_linux_check_image(struct linux_armxx_kernel_header *lh); +grub_err_t grub_armxx_efi_linux_boot_image(grub_addr_t addr, grub_size_t size, + char *args); #endif grub_addr_t grub_efi_modules_addr (void); From patchwork Mon Jul 9 17:33:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 141475 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp2922913ljj; Mon, 9 Jul 2018 10:33:33 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeRAfOXsr4MJGUyjVlI+JF3HavAfhIlFqZNobOGOU5OlIFrsBFsHKmucJwLKxTUKMFZAaIh X-Received: by 2002:ac8:2c24:: with SMTP id d33-v6mr2594196qta.118.1531157612890; Mon, 09 Jul 2018 10:33:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531157612; cv=none; d=google.com; s=arc-20160816; b=faersR/fX7+N/YgS6Yw0ROzVuCET0o9T37O6EMVOa2gearOCMBokbXnIyrvqNxCa0H A6UnVCoFB9vi415CQ+IOcPvWBlu+YSYowU4Ms2aKck1R7l35pIObNZMSqedk/Ye1f6z0 Bm1YhIjfSikojclDX7KgUfT4ikn+YbNRVaRzd0ms41B4XJ31+ahsdNcVVe3jBsORgAvr aBJRZ0nXV+2M85Amextxx48NAPst8MO6QeP0KLY7CWnABG7NNx4FhR6GAKRzsnEwGMHz k6bClE/2hhAHgx0Ye5H1HHCZDA620fh/ZWJHeD9GYflx3MqUgozvxE6nHExXq4NYHuQB OKkw== 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=9qgiUTAoCSz/euL6+6XEnTGiLKZmZqB69/63QwGp+FE=; b=IXcgMBtgQqUs83Pnrymvq4usqTA8I7O2P5WhwKgyJQopLAWblz+tTLzfAafaPjzXL9 MUeHcKTqbjb/MHeTa8bvdcKEJSQjHMFBRFRC5bT0gPDiN7BPgRWX0r/RSPHW9Wpd/1g5 bsOmTJpLXpYcsKq/4S5pyS6K7Kd6EX4POLkAD5rpg7soMPKbZmbU8JHVhyPu3jM3rTZO crCXD5kgV1xbyfHK4Vm/2u3YYls93VzjhrIq5sOMbtKb3dcMilgKfwAcZbcL5gw1/iVR RFM7PO/NGRiBRiSzgQJvXF7eKV+5YZ8HsJyTLDyRP+DeQ91dBm5GHpx9KB0vPmV09TpQ 4ATg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b="OEnv/rk1"; 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 s55-v6si109000qvc.259.2018.07.09.10.33.32 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 09 Jul 2018 10:33:32 -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="OEnv/rk1"; 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]:43609 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fca2W-0000MO-6T for patch@linaro.org; Mon, 09 Jul 2018 13:33:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44281) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fca2F-0000Js-PJ for grub-devel@gnu.org; Mon, 09 Jul 2018 13:33:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fca2E-0002hC-Ow for grub-devel@gnu.org; Mon, 09 Jul 2018 13:33:15 -0400 Received: from mail-wm0-x236.google.com ([2a00:1450:400c:c09::236]:39044) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fca2E-0002gq-Ij for grub-devel@gnu.org; Mon, 09 Jul 2018 13:33:14 -0400 Received: by mail-wm0-x236.google.com with SMTP id h20-v6so5691396wmb.4 for ; Mon, 09 Jul 2018 10:33:14 -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=xDGlRpSaOOQ50Q0B5HRZ7Qljf02tkbpV7Dbe7rz6rh4=; b=OEnv/rk1XdrVARTvbbO6QtTPjTfa4YfpKjHTEAxqW2Oy8MLC18n4398G+AA4IVY09M 0EXs8rH0y8mMrP54B18086mndRso4butn9zCQN/NYIsu40oFp1uMxW0nAqPG+utsdCBN EedwOPZ4c6jmFoSwY4+BGMRZmMfNnyathrbIQ= 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=xDGlRpSaOOQ50Q0B5HRZ7Qljf02tkbpV7Dbe7rz6rh4=; b=osLuVlMsYDdtuv48PrZffGaYl3RPnA17nmgcoaZsi8psZp3sjuqjLYIGVscwVgm74y 9AI/a/nbz2MVwncJaLrzR+GC3yLhEQ4RrotizaPqIcWOvYqyBGH+I5Cse7uomDiTED/G 6xUNkIBnaozGHtn29vEHYqzc1pIPaW77ncYWucPchPh0/ylaQdbLSDCgPhtAmIM7uMkQ mohV9WH5lMl0zv4gPJ+FHNfX4+gj2Bl3vSlUue/GMEWYuAn+sFElBGWSzHI/o8sdbXWe F4Ywzwk76upIS33WnlD+LKsAomFZFdUFm7cgUJ/PAPflQLZxAQtuXwApdJ6fCRj4Vxbm LK8A== X-Gm-Message-State: APt69E04sZG2r3OpDuH/38f/TbwxwTuKPkCsOdmOO4C4i/2vOoGyTHrD d73zzK3V2GPi9/ZdUPAVE0dnGlI3rJY= X-Received: by 2002:a1c:3282:: with SMTP id y124-v6mr12331594wmy.11.1531157593281; Mon, 09 Jul 2018 10:33:13 -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.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Jul 2018 10:33:12 -0700 (PDT) From: Leif Lindholm To: grub-devel@gnu.org Subject: [PATCH v4 4/6] arm/efi: switch to arm64 linux loader Date: Mon, 9 Jul 2018 18:33:03 +0100 Message-Id: <20180709173305.17588-5-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:400c:c09::236 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: The development of GNU GRUB Cc: Daniel Kiper MIME-Version: 1.0 Errors-To: grub-devel-bounces+patch=linaro.org@gnu.org Sender: "Grub-devel" The arm64 and arm linux kernel EFI-stub support presents pretty much identical interfaces, so the same linux loader source can be used for both architectures. Switch 32-bit ARM UEFI platforms over to the existing EFI-stub aware loader initially developed for arm64. This *WILL* stop non-efistub Linux kernels from booting on arm-efi. Signed-off-by: Leif Lindholm --- grub-core/Makefile.core.def | 7 ++++--- grub-core/kern/efi/mm.c | 2 +- include/grub/arm/linux.h | 5 +++++ include/grub/efi/efi.h | 2 -- 4 files changed, 10 insertions(+), 6 deletions(-) -- 2.11.0 _______________________________________________ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index fc4767f19..9590e87d9 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; @@ -1693,7 +1692,9 @@ 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_coreboot = loader/arm/linux.c; + arm_efi = loader/arm64/linux.c; + arm_uboot = loader/arm/linux.c; arm64 = loader/arm64/linux.c; common = loader/linux.c; common = lib/cmdline.c; @@ -1702,7 +1703,7 @@ module = { module = { name = fdt; - arm64 = loader/efi/fdt.c; + efi = loader/efi/fdt.c; common = lib/fdt.c; enable = fdt; }; diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c index b7cf144e5..f443b8955 100644 --- a/grub-core/kern/efi/mm.c +++ b/grub-core/kern/efi/mm.c @@ -630,7 +630,7 @@ grub_efi_mm_init (void) 2 * BYTES_TO_PAGES (MEMORY_MAP_SIZE)); } -#if defined (__aarch64__) +#if defined (__aarch64__) || defined (__arm__) grub_err_t grub_efi_get_ram_base(grub_addr_t *base_addr) { diff --git a/include/grub/arm/linux.h b/include/grub/arm/linux.h index cceb9c4a9..3d0d15eb4 100644 --- a/include/grub/arm/linux.h +++ b/include/grub/arm/linux.h @@ -34,6 +34,11 @@ struct linux_arm_kernel_header { grub_uint32_t hdr_offset; }; +#if defined(__arm__) +# define GRUB_LINUX_ARMXX_MAGIC_SIGNATURE GRUB_LINUX_ARM_MAGIC_SIGNATURE +# define linux_armxx_kernel_header linux_arm_kernel_header +#endif + #if defined GRUB_MACHINE_UBOOT # include # define LINUX_ADDRESS (start_of_ram + 0x8000) diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h index 1deaa3c8f..2c6648d46 100644 --- a/include/grub/efi/efi.h +++ b/include/grub/efi/efi.h @@ -92,8 +92,6 @@ extern void (*EXPORT_VAR(grub_efi_net_config)) (grub_efi_handle_t hnd, #if defined(__arm__) || defined(__aarch64__) void *EXPORT_FUNC(grub_efi_get_firmware_fdt)(void); -#endif -#if defined(__aarch64__) grub_err_t EXPORT_FUNC(grub_efi_get_ram_base)(grub_addr_t *); #include grub_err_t grub_armxx_efi_linux_check_image(struct linux_armxx_kernel_header *lh); From patchwork Mon Jul 9 17:33:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 141479 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp2924856ljj; Mon, 9 Jul 2018 10:35:42 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfWsWNgG4zzz1L+OeDaroqvTwZopGE7NvqAcoUiCoWVNQLzsMjnBtFtATHp6aR2em6VmqST X-Received: by 2002:ac8:33c5:: with SMTP id d5-v6mr20019424qtb.142.1531157742501; Mon, 09 Jul 2018 10:35:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531157742; cv=none; d=google.com; s=arc-20160816; b=Is+846R6cPB+p/X5P8Y3+qZcQTuyIgdTG6rQokntSs4ipN7H9jEd26afATrCqEbrCi 2mzkiVcJGZ96e+sVgDlb7Mes1t00SC+jKx4TWPtssf2XtQ8GDQZpxzl8X9Trvp1kAjWa zq1DAUIGppXCwc0F93avLnpGTjeaGKTJW8GgHstABTr+lS3NSZyzO80+43TnNb/+hu0q N5P2cVNgSw8sL0sUNsvsD6uV5hOHl5MiEH6caT0OBAOE9d33GNbzieifRD+DbWx2YS/P 217i6tKdCI8MPj7+arOE4+bsiepRIXi1CIiRXTD/E9HJdV0Q1kQLaZBaQ66kdlLNZ/f8 4oYQ== 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=NIfrcfKu9JrJ+HGS3ixLpzSqMfmsRmziEfeOlZjyLGw=; b=tQUT6Ec9LrB0QLcIk7T4zmd0AGb47y+lJafVrx5kc8h2VIgL/2GlpqjEjPG7nzeZjb pwwsrTLOEYGjTDkkF58bIrFdXBoZf1q6pVn8IFNJEJDxg7QTgJJO/gsRcdq8vLDfLDn2 oVilZsO6MIXzLSLdiveIcznNRqXw4RrDG/nqaJq/b3RcbF6HNkNwc/sdYL+W2M/58Mq5 HPpF/D/psqbWumh+fHCgtAoRvuGxG9MawcLvh3Qy4xnzsBeNdmk+Ys58Zc/+Cfngaax4 wkDd/IRKbj7o6ejYQUjCJQguwLWXplkWaV3cyPnwMYz1C79ABbm+RZL4MxG34VrpZDmG 8XBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b="Q/lgjide"; 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 t2-v6si2061771qva.11.2018.07.09.10.35.42 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 09 Jul 2018 10:35:42 -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="Q/lgjide"; 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]:43612 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fca4b-0001L5-OK for patch@linaro.org; Mon, 09 Jul 2018 13:35:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44304) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fca2I-0000NA-Kf for grub-devel@gnu.org; Mon, 09 Jul 2018 13:33:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fca2G-0002hg-Kc for grub-devel@gnu.org; Mon, 09 Jul 2018 13:33:18 -0400 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:33081) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fca2G-0002hQ-Al for grub-devel@gnu.org; Mon, 09 Jul 2018 13:33:16 -0400 Received: by mail-wm0-x243.google.com with SMTP id z6-v6so11525971wma.0 for ; Mon, 09 Jul 2018 10:33:16 -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=SSVu1QtDljgG4ksbANiLExrl+VY8URHjQ8OGjG+buRE=; b=Q/lgjideATb/fzFxo/QG1YVsjrJLkbaQtEVDv5qKtL1sgiiWn8g4Af+hxOqC9AuCst EBZhkjhQ4G7vBjNHa+Q6d87emyb6dlYAK8h6b/5qnLtSgrTwim9wdZynt+ng3ckbL3yM 6vMdVHCLJsGag9n5+Dywrz1lOosIMrXtMjGKk= 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=SSVu1QtDljgG4ksbANiLExrl+VY8URHjQ8OGjG+buRE=; b=kMq5mSq+CotFxhhUi7H37Y5assOZJyMDoDoC3tuL4kQAFg7KDImtxr561+sezDKtfN g71n6eokeQMcS8hZ8M49aqX+r1sABxFbIpUtPM++3wDb+whVQjiX7h0pBPZ9V/6Rcpr2 AaJwvXUswPmkD8ftAkO9wgs2eASIuaIdjnZ4PSsKDU6ph6OsmRctmrYnzagRFvX5k5YP jfIgbuDsJ4rZi3rqXXWJqZcP6hZPcEeONvvf1tIBMc5dzet6R1aPIud9NNdpTYts7A06 P3WBrIXq1cdm+tQekKPhUnQ6aGj1ioUHYcEg69irVn73mp/aY8Zno5rBOENBrrm2eO0G RK6w== X-Gm-Message-State: APt69E3aieS8l1jmZk30HoanPM0o28lr1bvYzA+YKwplBNpI25e0Yclg QrGvaI9b50MM3iWT9FS3xeytd5J4QM0= X-Received: by 2002:a1c:87ca:: with SMTP id j193-v6mr12543365wmd.76.1531157594804; Mon, 09 Jul 2018 10:33:14 -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.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Jul 2018 10:33:13 -0700 (PDT) From: Leif Lindholm To: grub-devel@gnu.org Subject: [PATCH v4 5/6] arm: delete unused efi support from loader/arm Date: Mon, 9 Jul 2018 18:33:04 +0100 Message-Id: <20180709173305.17588-6-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:400c:c09::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" The 32-bit arm efi port now shares the 64-bit linux loader, so delete the now unused bits from the 32-bit linux loader. This in turn leaves the grub-core/kern/arm/efi/misc.c unused, so delete that too. Signed-off-by: Leif Lindholm --- grub-core/Makefile.am | 1 - grub-core/kern/arm/efi/misc.c | 202 ------------------------------------------ grub-core/loader/arm/linux.c | 28 ------ include/grub/arm/efi/loader.h | 26 ------ include/grub/arm/linux.h | 16 ---- 5 files changed, 273 deletions(-) delete mode 100644 grub-core/kern/arm/efi/misc.c delete mode 100644 include/grub/arm/efi/loader.h -- 2.11.0 _______________________________________________ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am index 104513847..f4ff62b76 100644 --- a/grub-core/Makefile.am +++ b/grub-core/Makefile.am @@ -254,7 +254,6 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/fdtbus.h endif if COND_arm_efi -KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/arm/efi/loader.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/arm/system.h diff --git a/grub-core/kern/arm/efi/misc.c b/grub-core/kern/arm/efi/misc.c deleted file mode 100644 index c95e8299d..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_fixed (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_any_pages (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 9f43e41bb..b4f609d2d 100644 --- a/grub-core/loader/arm/linux.c +++ b/grub-core/loader/arm/linux.c @@ -290,15 +290,6 @@ linux_boot (void) */ linuxmain = (kernel_entry_t) linux_addr; -#ifdef GRUB_MACHINE_EFI - { - grub_err_t err; - err = grub_efi_prepare_platform(); - if (err != GRUB_ERR_NONE) - return err; - } -#endif - grub_arm_disable_caches_mmu (); linuxmain (0, machine_type, target_fdt); @@ -317,13 +308,7 @@ linux_load (const char *filename, grub_file_t file) size = grub_file_size (file); -#ifdef GRUB_MACHINE_EFI - linux_addr = (grub_addr_t) grub_efi_allocate_loader_memory (LINUX_PHYS_OFFSET, size); - if (!linux_addr) - return grub_errno; -#else linux_addr = LINUX_ADDRESS; -#endif grub_dprintf ("loader", "Loading Linux to 0x%08x\n", (grub_addr_t) linux_addr); @@ -428,20 +413,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), size = grub_get_initrd_size (&initrd_ctx); -#ifdef GRUB_MACHINE_EFI - if (initrd_start) - grub_efi_free_pages (initrd_start, - (initrd_end - initrd_start + 0xfff) >> 12); - initrd_start = (grub_addr_t) grub_efi_allocate_loader_memory (LINUX_INITRD_PHYS_OFFSET, size); - - if (!initrd_start) - { - grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory")); - goto fail; - } -#else initrd_start = LINUX_INITRD_ADDRESS; -#endif grub_dprintf ("loader", "Loading initrd to 0x%08x\n", (grub_addr_t) initrd_start); diff --git a/include/grub/arm/efi/loader.h b/include/grub/arm/efi/loader.h deleted file mode 100644 index 4bab18e83..000000000 --- a/include/grub/arm/efi/loader.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * GRUB -- GRand Unified Bootloader - * Copyright (C) 2013 Free Software Foundation, Inc. - * - * GRUB is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * GRUB is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GRUB. If not, see . - */ - -#ifndef GRUB_LOADER_MACHINE_HEADER -#define GRUB_LOADER_MACHINE_HEADER 1 - -grub_err_t EXPORT_FUNC (grub_efi_prepare_platform) (void); -void * EXPORT_FUNC (grub_efi_allocate_loader_memory) (grub_uint32_t min_offset, - grub_uint32_t size); - -#endif /* ! GRUB_LOADER_MACHINE_HEADER */ diff --git a/include/grub/arm/linux.h b/include/grub/arm/linux.h index 3d0d15eb4..712ba17b9 100644 --- a/include/grub/arm/linux.h +++ b/include/grub/arm/linux.h @@ -46,20 +46,6 @@ struct linux_arm_kernel_header { # define LINUX_FDT_ADDRESS (LINUX_INITRD_ADDRESS - 0x10000) # define grub_arm_firmware_get_boot_data grub_uboot_get_boot_data # define grub_arm_firmware_get_machine_type grub_uboot_get_machine_type -#elif defined GRUB_MACHINE_EFI -# include -# include -/* On UEFI platforms - load the images at the lowest available address not - less than *_PHYS_OFFSET from the first available memory location. */ -# define LINUX_PHYS_OFFSET (0x00008000) -# define LINUX_INITRD_PHYS_OFFSET (LINUX_PHYS_OFFSET + 0x02000000) -# define LINUX_FDT_PHYS_OFFSET (LINUX_INITRD_PHYS_OFFSET - 0x10000) -# define grub_arm_firmware_get_boot_data (grub_addr_t)grub_efi_get_firmware_fdt -static inline grub_uint32_t -grub_arm_firmware_get_machine_type (void) -{ - return GRUB_ARM_MACHINE_TYPE_FDT; -} #elif defined (GRUB_MACHINE_COREBOOT) #include #include @@ -78,6 +64,4 @@ grub_arm_firmware_get_machine_type (void) } #endif -#define FDT_ADDITIONAL_ENTRIES_SIZE 0x300 - #endif /* ! GRUB_ARM_LINUX_HEADER */ From patchwork Mon Jul 9 17:33:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 141480 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp2924863ljj; Mon, 9 Jul 2018 10:35:43 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdTzLBVNlxA+Gj0mjDqMRJAGb2xvc3crdnKIx/LvZPuraaU0tWNkbLMsc4Pzx0vrETAXGtK X-Received: by 2002:ac8:3094:: with SMTP id v20-v6mr8753682qta.313.1531157742942; Mon, 09 Jul 2018 10:35:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531157742; cv=none; d=google.com; s=arc-20160816; b=JfczcxBkv1Wi6lNzO2jPHRSSpGDQ68BP3ESp16lgNz7LpP/RbvLNr6ntO6suaBk/O+ 4TRScydRdeQKXFLn1L8E1sbE0O/YMN+6L9UABG9eQp1Gne6olVJTdJCQrzUrPIl+/rS6 qlbZBWbSgb3xeor1sAr/xGleloW14J4/0dRq54/dJQGywDsT0b5wwZ1RigfkogFE+Xw9 f+EzcRACCkG0IAdkVljKz03UG/vAJoKOR+Lqwos/72xt1cLCM1cBpkdrYo8ssT/iKEmu 8qyS18xz0A17u/J1ZH23bUxzuCSw66a64z+fMXQny5vJANDgouNSNBphY8BwCtNWi3lY hmNw== 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=6st4UNQ0DaiCPD06wGOo+dUyb26eTvpMce+A/9AUopw=; b=jmtZJRUQdH5RMwhHfV4FNiFRAl2OWj2bTb9cBeQiuFZ1Z8rtDQosbQBcznxYu1GSeZ /1icf2ZmeC2llIF3T9KAfB7XJMhGrHTcGaDGqMXavpziGo0TMrZ2QGzZrDoRHf0t2lhV AxiXTT4AjmvJqPfovhc7WM7WqQTX0rO8Av0fd5dptX4EMJvn3saghaRpIA4cffSrbO20 l75HrcHsA54HWUq3DFXrICGADtGZevuosj/xQXa5vp7j1YG0RHgddCe6CFl9X9Dvipi0 XruGRZJl0oV39WHCoyf0fbb1qWUYz9tKIZYZ9dswrga2dNvdzIspZWUnKqKUHd0+cTDY wVeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=fw49ikRh; 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 y39-v6si8467417qtc.351.2018.07.09.10.35.42 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 09 Jul 2018 10:35:42 -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=fw49ikRh; 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]:43614 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fca4c-0001N3-9p for patch@linaro.org; Mon, 09 Jul 2018 13:35:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44306) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fca2I-0000NF-MB for grub-devel@gnu.org; Mon, 09 Jul 2018 13:33:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fca2H-0002iP-Ta for grub-devel@gnu.org; Mon, 09 Jul 2018 13:33:18 -0400 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:39534) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fca2H-0002i9-Nq for grub-devel@gnu.org; Mon, 09 Jul 2018 13:33:17 -0400 Received: by mail-wm0-x241.google.com with SMTP id h20-v6so5691515wmb.4 for ; Mon, 09 Jul 2018 10:33:17 -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=s1mAK/H4O2CP9yZ1VWcq1G/Unhl4fp5+B1fp0SeCbN8=; b=fw49ikRhRkvhebudL7fU65N+f1AOqpjj0ctzUc1gb5MWO3dhV1GhYdqeSUNC8NYpSM xDGyGcBLu+MdhAMnKdJD2rYqhChETFXe2wWfMohUuA1QCCxboHPQZp2m7DzNRO/4Boar 5Zi+Td6wWCLHtAcvxyT5z4/4etexQmkF5zbDk= 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=s1mAK/H4O2CP9yZ1VWcq1G/Unhl4fp5+B1fp0SeCbN8=; b=WcsQ9LJU3EIMb3paKu8gJtFlrHFl7UlEnQkzfdboSHJXLCr6WQOJYf19x+couyrGhx gek4inRBfC84nbUrJK2DoucpD4O5/1AwMFc+5tRPB4SqaORdSpxzLHCgshKFrScFNAUT 5PRK1Dxap2WPUQXEryyUNouUp6uKvKcCsQnf2wYgEEgjGQ6zP+xGtU5hpkroQ/gGAnN6 vu185R8/0USrXDY0vZoxEvrsnpSjZUTPKOuEfUu8AbLaNXKpamFHZIKZOBt6J7spR7DN 8OsPLMpuh1QWQl4gmyO0mjgvcCTtmvwDshekRQtkRWexkjntpO0wSuNsg97Yn0TtEfj1 q1iA== X-Gm-Message-State: APt69E2oLEDKBOJTDS0eCemu+0Ejrv0iWim+HdiaZRZxydK9eri0VM1/ s/F4+4UUKOxAnZOiAFqN+lZ8sYpFiJo= X-Received: by 2002:a1c:ce0c:: with SMTP id e12-v6mr11906250wmg.86.1531157596471; Mon, 09 Jul 2018 10:33:16 -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.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Jul 2018 10:33:15 -0700 (PDT) From: Leif Lindholm To: grub-devel@gnu.org Subject: [PATCH v4 6/6] efi: restrict arm/arm64 linux loader initrd placement Date: Mon, 9 Jul 2018 18:33:05 +0100 Message-Id: <20180709173305.17588-7-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:400c:c09::241 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: The development of GNU GRUB Cc: Daniel Kiper MIME-Version: 1.0 Errors-To: grub-devel-bounces+patch=linaro.org@gnu.org Sender: "Grub-devel" The 32-bit arm Linux kernel is built as a zImage, which self-decompresses down to near start of RAM. In order for an initrd/initramfs to be accessible, it needs to be placed within the first ~768MB of RAM. The initrd loader built into the kernel EFI stub restricts this down to 512MB for simplicity - so enable the same restriction in grub. For arm64, the requirement is within a 1GB aligned 32GB window also covering the (runtime) kernel image. Since the EFI stub loader itself will attempt to relocate to near start of RAM, force initrd to be loaded completely within the first 32GB of RAM. Signed-off-by: Leif Lindholm --- grub-core/loader/arm64/linux.c | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) -- 2.11.0 _______________________________________________ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c index f90c5f926..1f86229f8 100644 --- a/grub-core/loader/arm64/linux.c +++ b/grub-core/loader/arm64/linux.c @@ -193,6 +193,42 @@ grub_linux_unload (void) return GRUB_ERR_NONE; } +/* + * 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 + +/* + * This function returns a pointer to a legally allocated initrd buffer, + * or NULL if unsuccessful + */ +static void * +allocate_initrd_mem (int initrd_pages) +{ + grub_addr_t max_addr; + + if (grub_efi_get_ram_base (&max_addr) != GRUB_ERR_NONE) + return NULL; + + 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[]) @@ -221,7 +257,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_any_pages (initrd_pages); + initrd_mem = allocate_initrd_mem (initrd_pages); + if (!initrd_mem) { grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory"));