From patchwork Wed Jun 27 17:17:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 140371 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp1152251ljj; Wed, 27 Jun 2018 10:19:05 -0700 (PDT) X-Google-Smtp-Source: AAOMgpciJAIlgPsCW1HWk/leF3eag1AHyWr26MzCpvKS1YB9VYPljCU5jtUYKzedMawcaocGfRT9 X-Received: by 2002:aed:3fa3:: with SMTP id s32-v6mr6295749qth.229.1530119945337; Wed, 27 Jun 2018 10:19:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530119945; cv=none; d=google.com; s=arc-20160816; b=yTSvmJ7aPo8CuwEhqrfQHAal3EgPO4KQ3tgDWQ96UFJrLiYcIYYyTHLuQFbdomR/a6 8kA+gCKoTD89pmWnHTDrfxL6pDU69BIaze63TIFhD6vOFd0NwkmsBpd5HlRuRotgY0Q/ Ftjo55fU9ZrTVbAFLWCID60nsdG0EIbAM4hSCtcFSpAYCdY6MP1sve5BdyusgdF7o7aL 3gWpWKr1szki915doF3U1ojtJPImr3AEOds7UKKwBFikJ/ifTBPoidKFcGb5SjPUTIbY ySSSBNcpgmYLEXnnRm6edaJ8QzyU4X9yX/UEK66nQjrPVsPD7rGfW3J1MmfTGT9igl27 ZSBA== 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=u+8QKdzz8kMP8i7y3xZGNnIQj4jUn6kOAF8cUXzEziMS0K3RGVfC0MeeGl0gKmloNZ Vh/uOMsgToMmHP95AyuOhQ40Vpdte9eiUEKqEZUEFP5j7cTnra7sAqeP+IJut0kndPQz CPFMO3VSr5sZyGpg29SbP/td8BickrBrhWYaPS15wnF6uk+SANz6DaQRmbSdvu97dEob Bzq6/gsScBKOPyZqy2bT/5BgguDVFZR4CD6R11FfnjVAK5kC3asYaqioPtczUK36SHUQ /XMxl7z2/e9d0ws3V3RhXSbcyIngfG2nCMDJgdNcZMzOGh7U09nog3PZW4DrEv2P9kjf Qgag== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=ktmqbJ8i; 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 a126-v6si3615102qkf.46.2018.06.27.10.19.05 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 27 Jun 2018 10:19:05 -0700 (PDT) Received-SPF: pass (google.com: domain of grub-devel-bounces+patch=linaro.org@gnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=ktmqbJ8i; 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]:60573 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYE5w-0005XT-Ho for patch@linaro.org; Wed, 27 Jun 2018 13:19:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57570) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYE4P-0004aT-8d for grub-devel@gnu.org; Wed, 27 Jun 2018 13:17:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYE4M-0006KC-J3 for grub-devel@gnu.org; Wed, 27 Jun 2018 13:17:29 -0400 Received: from mail-wr0-x244.google.com ([2a00:1450:400c:c0c::244]:34528) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYE4M-0006JB-Bl for grub-devel@gnu.org; Wed, 27 Jun 2018 13:17:26 -0400 Received: by mail-wr0-x244.google.com with SMTP id a12-v6so2823327wro.1 for ; Wed, 27 Jun 2018 10:17:26 -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=ktmqbJ8i4lTaiRhkFA/N+5Rr6IPrLSLjvsqaRXCKCPoQHGf5U2e/kVLMvx+wKAU1rQ yauueL3RpY2bH0fHMNS+GKfDLGk390Ry0i5vNy0IbDIyW+oVjMQu8M8T3VhStPSYzpFS sOQPEvvjliABr6L4neRQTX0AsF3lBDuGtpi1U= 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=AmsTl3cCUV7/fBwO3fvCQFJAVDW5VejAxojHWG+bxoBDAqxbIZvDwXgzQfsvvrazh0 FTEwzaD+4RxPd3Pw7lCC8Rq4+/KfTm0KpCoCiIRaUkyuX2ondWu88oeoP11Nn2Q0ey1E kvv40+eXMY2JaChZjFdOQ/iNEYl88La00VJ+3lsWcDsPzK+WXOUaDnPMiRkDg+35fezX MvzUcBzYLM0nYdnYVN0SnTnPhh5hNkxQZB8IPEmagDqtwVuBPoeS9ogmHPZdkWAE+sNW MGujtfbrv0528rQ1d6jv8bQwvkj7ToSNNvTp/s7cfQE8ATOVnP9lSN/ioaIYwOP7TAib qluw== X-Gm-Message-State: APt69E0inRPSGEjT21fnLjGLcpSz21nUI+zU6ldc9q2Rewpg+z/+OFLP akiYlLJXEjLXw+puGj2mYsrtLbXMOpY= X-Received: by 2002:adf:8e49:: with SMTP id n67-v6mr5785907wrb.131.1530119843860; Wed, 27 Jun 2018 10:17:23 -0700 (PDT) Received: from vanye.hemma.eciton.net (cpc92302-cmbg19-2-0-cust304.5-4.cable.virginm.net. [82.1.209.49]) by smtp.gmail.com with ESMTPSA id a2-v6sm3406572wmb.6.2018.06.27.10.17.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Jun 2018 10:17:22 -0700 (PDT) From: Leif Lindholm To: grub-devel@gnu.org Subject: [PATCH v3 1/6] efi: add central copy of grub_efi_find_mmap_size Date: Wed, 27 Jun 2018 18:17:15 +0100 Message-Id: <20180627171720.27028-2-leif.lindholm@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180627171720.27028-1-leif.lindholm@linaro.org> References: <20180627171720.27028-1-leif.lindholm@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::244 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 Wed Jun 27 17:17:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 140369 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp1152011ljj; Wed, 27 Jun 2018 10:18:54 -0700 (PDT) X-Google-Smtp-Source: AAOMgpd7qZm1q2zuTBZLU6GRI/M7qt6UrQ3tPNBHvHUaaZh7SkelZCSwxotTe+PjP8ckObcv1TdV X-Received: by 2002:a37:6446:: with SMTP id y67-v6mr5901709qkb.309.1530119933996; Wed, 27 Jun 2018 10:18:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530119933; cv=none; d=google.com; s=arc-20160816; b=Pe31vLuv5Fl2eKL20Tu9gcXoy52pO4d5fSzmM9jCnQFcFSGOZBW7Axikk1bdnHafDR 6yf5h1uSLZR4zaUVUsarnlNTs3YyXuw5ABGuvC3izwd/9NLBVEIQBzsAxlZ6fvrqu7kV g6XrJ7J4WRz4HZVomutbaQz1gyHc8cRRa/flY0NpNJrV3UMETridIqc9TRdPnSM8cWHh mt4A3giMdzUzdvbVz+INv9kwlD7o6V9gZTTPmoz5qj28kpU2tjKS9ni16ghiCTuSMsgp SEH5ZUwc19J0pLUSvh9FRr3i5eXrXFEoOxtlQapaWgRbhBM8KYBJhsSsyAEHMu/BHgDj IzBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:references:in-reply-to:message-id:date:subject :to:from:dkim-signature:arc-authentication-results; bh=gULe/BX8Esu5w1uzW7rPfBxeo8+R9f68DYgemclFatA=; b=DDvOUqm4w+W8bjgGE3jUeeY14JP7KaGELT3Q+pYEu8aIu8Tub1Rvf7kB7Kv90oBAzp RlLWMhV8mjPIJfFVJhVA3FFY766YvZ3vluM/ZwZXbpynXcigl8QgA81mTRytpaoPX2hZ WmR9Ojt5vHo3ILpWlD9BNU13Buy871fPiUe44uT2raVmahkUZjuVOsNiTRRzbM/0FrBw HSQpcvHKPtRnDX6pRiQWQIhD1HSF/IZGJI8XcZ20atoL2KKFjX2IJIL9oBmeG0dGZG80 cVer2N/SkBcEKGMgTLA1WWjV1iy8VrhovToJgJNOW/ep9il6ZEwvo6FH5aYo1hN1zInd sV9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b="YyMO+PZ/"; spf=pass (google.com: domain of grub-devel-bounces+patch=linaro.org@gnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="grub-devel-bounces+patch=linaro.org@gnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id f19-v6si1914212qka.95.2018.06.27.10.18.53 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 27 Jun 2018 10:18:53 -0700 (PDT) Received-SPF: pass (google.com: domain of grub-devel-bounces+patch=linaro.org@gnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b="YyMO+PZ/"; spf=pass (google.com: domain of grub-devel-bounces+patch=linaro.org@gnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="grub-devel-bounces+patch=linaro.org@gnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:60567 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYE5l-0004al-7F for patch@linaro.org; Wed, 27 Jun 2018 13:18:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57571) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYE4P-0004aU-94 for grub-devel@gnu.org; Wed, 27 Jun 2018 13:17:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYE4O-0006Ly-5b for grub-devel@gnu.org; Wed, 27 Jun 2018 13:17:29 -0400 Received: from mail-wr0-x243.google.com ([2a00:1450:400c:c0c::243]:41734) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYE4N-0006Ks-Tv for grub-devel@gnu.org; Wed, 27 Jun 2018 13:17:28 -0400 Received: by mail-wr0-x243.google.com with SMTP id h10-v6so2805815wrq.8 for ; Wed, 27 Jun 2018 10:17:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=DMF1bDXi1lSNL5Bp6P3Uv32MFLh6O2KrgGtDlZ78xWI=; b=YyMO+PZ/dPFxl596t1eI02ni2EL/SG70S03bpKFyJvUtfiCstBTRlyEbrzNEJiH6y8 4P084XHnYNMrTO4Rg12gF5rmtRwAmxpDvT2T41FSftFXzZfFZhWV7tGGlo02XUdi12R1 2nyBmkjHaWricF0bTACxFNxMHqXOh007A88Ag= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=DMF1bDXi1lSNL5Bp6P3Uv32MFLh6O2KrgGtDlZ78xWI=; b=D1B3XI7r9CNL+1F2SquBPYbGnmTpwf+57QtTSksrxRFgvuTKRpYAhEUK7zM7hkgVjr oohB/DnPc/PAeletjiDfTCujq4ddGeRCQapfW8HLKQ9TnjWyYUtOL4txQVyuMrqfTClb Il7OdT4ZTnemn8yXFHfwKLhdJx78L4fEp/dVMFG8AfpM4vAMO5sqeLuKw1fOOWsLZP4g r3JOGrCx4TGElaqZt5IBWBB+EjYkgLZjCYwwhyBjR+Zd8W+CLfIBfR/AzGrZhDG26pKQ UOJNabPnpyEsIay78j3ryUDKhEBOEk5vfBjvyxJFJkzNgJXiI4vls2jlHrscG1CO1gKN K4NQ== X-Gm-Message-State: APt69E1QfUoWjrtIH7tfYeFq+9awwUTfCvkPAnqugBePgA1aer/u35El OY3S2dgae9SBvRrdA9pDRD2F+VsOgxo= X-Received: by 2002:adf:9603:: with SMTP id b3-v6mr6008692wra.253.1530119846577; Wed, 27 Jun 2018 10:17:26 -0700 (PDT) Received: from vanye.hemma.eciton.net (cpc92302-cmbg19-2-0-cust304.5-4.cable.virginm.net. [82.1.209.49]) by smtp.gmail.com with ESMTPSA id a2-v6sm3406572wmb.6.2018.06.27.10.17.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Jun 2018 10:17:24 -0700 (PDT) From: Leif Lindholm To: grub-devel@gnu.org Subject: [PATCH v3 2/6] efi: add grub_efi_get_ram_base() function for arm64 Date: Wed, 27 Jun 2018 18:17:16 +0100 Message-Id: <20180627171720.27028-3-leif.lindholm@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180627171720.27028-1-leif.lindholm@linaro.org> References: <20180627171720.27028-1-leif.lindholm@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::243 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: The development of GNU GRUB Cc: Daniel Kiper MIME-Version: 1.0 Errors-To: grub-devel-bounces+patch=linaro.org@gnu.org Sender: "Grub-devel" Since ARM platforms do not have a common memory map, add a helper function that finds the lowest address region with the EFI_MEMORY_WB attribute set in the UEFI memory map. Required for the arm64 efi linux loader to restrict the initrd location to where it will be accessible by the kernel at runtime. Signed-off-by: Leif Lindholm --- grub-core/kern/efi/mm.c | 36 ++++++++++++++++++++++++++++++++++++ include/grub/efi/efi.h | 3 +++ 2 files changed, 39 insertions(+) -- 2.11.0 _______________________________________________ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c index fd39d23b4..10ffa2c9b 100644 --- a/grub-core/kern/efi/mm.c +++ b/grub-core/kern/efi/mm.c @@ -629,3 +629,39 @@ grub_efi_mm_init (void) grub_efi_free_pages ((grub_addr_t) memory_map, 2 * BYTES_TO_PAGES (MEMORY_MAP_SIZE)); } + +#if defined (__aarch64__) +grub_err_t +grub_efi_get_ram_base(grub_addr_t *base_addr) +{ + grub_efi_memory_descriptor_t *memory_map; + grub_efi_memory_descriptor_t *desc; + grub_efi_uintn_t mmap_size; + grub_efi_uintn_t desc_size; + int ret; + + mmap_size = grub_efi_find_mmap_size(); + + memory_map = grub_malloc (mmap_size); + if (! memory_map) + return GRUB_ERR_OUT_OF_MEMORY; + ret = grub_efi_get_memory_map (&mmap_size, memory_map, NULL, + &desc_size, NULL); + + if (ret < 1) + return GRUB_ERR_BUG; + + for (desc = memory_map, *base_addr = GRUB_UINT_MAX; + (grub_addr_t) desc < ((grub_addr_t) memory_map + mmap_size); + desc = NEXT_MEMORY_DESCRIPTOR (desc, desc_size)) + { + if (desc->attribute & GRUB_EFI_MEMORY_WB) + if (desc->physical_start < *base_addr) + *base_addr = desc->physical_start; + } + + grub_free(memory_map); + + return GRUB_ERR_NONE; +} +#endif diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h index 1021273c1..57db74b57 100644 --- a/include/grub/efi/efi.h +++ b/include/grub/efi/efi.h @@ -93,6 +93,9 @@ extern void (*EXPORT_VAR(grub_efi_net_config)) (grub_efi_handle_t hnd, #if defined(__arm__) || defined(__aarch64__) void *EXPORT_FUNC(grub_efi_get_firmware_fdt)(void); #endif +#if defined(__aarch64__) +grub_err_t EXPORT_FUNC(grub_efi_get_ram_base)(grub_addr_t *); +#endif grub_addr_t grub_efi_modules_addr (void); From patchwork Wed Jun 27 17:17:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 140373 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp1153467ljj; Wed, 27 Jun 2018 10:20:10 -0700 (PDT) X-Google-Smtp-Source: AAOMgpegEtmbrM2UiomtiEAiVUY1/VHue7KIhFN9jpOckrDV4X2RSrVrIzp+NWdGRlf+mVO5rB2k X-Received: by 2002:a37:6d41:: with SMTP id i62-v6mr5791196qkc.142.1530120010108; Wed, 27 Jun 2018 10:20:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530120010; cv=none; d=google.com; s=arc-20160816; b=vkwqRN5gLvU46rcc2FIviGWwqTOcywIkk4LoVK9sormad2qj9nJsI/7Fw5JqAvL/Zn Fcp7OLMpw/Xtscz1aRpW6XjphVJsEtmnMieezMyt1TVBszyokn507KoaVrVmN2RFy19g 2igKUHuFDUperFyyceX/DvC3U6GeHNAHm82hOsLhr4z1Vtuihh2aSx8ElbqCDUWYIjJs EKu3k5qgP4NEehTbma07YtsB2IzzagUUpsZbuQ67oNDZlv6tCw1UZGrgZuzHkv0x/upF dHrG+UZuCU0G+oHoOutbkswDd/7PgCIR7F5VZZCnb4aStxXvidugNeH+5fum9Vb2DlYX QfBg== 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=czmDIQ/0AgExlIfMlWX+6TOF3ljKUO3K7x84J6R2PgI=; b=yMv9945HHOZ7tVrRfI12a/911s6O/nfdocbeK1Wca3QO3PtpW3CD+x1lWylIbyMvjW IHijdIGE/Xa1zPBc2sHenKTjc9RnlMh/r1v/Fjk3SlamSanl+qzsHJWEvNK5FU7cwnER 1hCLujxm8VvLnEysKfRjsDo+f3A443u8AGYiY3evh3PTxTlViXnAa4T2QXau0eHb2Uzu YRck0WSwlqWCG8cJF2E9FyV+zY8IVwGZ3HLZ+Nr/oMSypZvQjSjd3SN7nEoOZ6/xyy9+ To8ckZIxHcEMrxz/qlvsElQpZXSZjzJ7K9a4x+ti5JneyWtONP2D0yHorL+nBtkmhEJY /eGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=aaOEqQXv; 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 u20-v6si4448093qth.247.2018.06.27.10.20.09 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 27 Jun 2018 10:20:10 -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=aaOEqQXv; 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]:60588 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYE6z-0006M0-BB for patch@linaro.org; Wed, 27 Jun 2018 13:20:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57625) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYE4R-0004ak-7B for grub-devel@gnu.org; Wed, 27 Jun 2018 13:17:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYE4P-0006OF-TU for grub-devel@gnu.org; Wed, 27 Jun 2018 13:17:31 -0400 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:40842) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYE4P-0006Mk-J9 for grub-devel@gnu.org; Wed, 27 Jun 2018 13:17:29 -0400 Received: by mail-wm0-x242.google.com with SMTP id z13-v6so6315532wma.5 for ; Wed, 27 Jun 2018 10:17:29 -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=Jgsb13aLReiJiSJqzP2uFly8H0EdYG3oDsWIFtU6Vms=; b=aaOEqQXv8AlcQOgeFZW9D4KDejmxM43TpIGIX1Nd2/v8I5dOSD62Nxm1cOx6u9ZKIS 5rjiRt2TXX4ehQlkO++DAnDi8XyztNQ60rbExZ+D8pNR51ccKt2dGavqiG2CnWDE1vLv xwYFQaySL3f/0oVZDLP7kD/MNwDl+0N8VUG8Y= 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=Jgsb13aLReiJiSJqzP2uFly8H0EdYG3oDsWIFtU6Vms=; b=XztAs78uLFThLfq3G27tlDZZQ5Epw84vVO+eiQcv69B8boBWx6TqF02hxEYegZ2ngj B+D/4yUskUrPHEPg4GVTxLyXzIB5OqkMNFRvVmBUR7ljAabknEvHbp0/Y4Bdbb4m5sUg rdvujoiH+VP4S2aBHpOkFyqOyVmycNvijPCS3aFWKy0i3FEfDD0vkCp4xg/mnKhrot8/ ehwvUFnrBmzA0p0EJI0hf8OC3oR2uuZzWmWC/0PoK5OBG9NcxTmRZ9I+FVRBrQpdysHd 92VJk3hEySlgaaaR7DQc4uX2ZqiYR31ebmc9KvQNQJcg6g9W0x8j8UM/yEqxeYdXuSVn 3Wcg== X-Gm-Message-State: APt69E3Y7f5VqYJ7FaGeQ6LeiYCm0Uqhz9AZxUTeaqXPbQeMMK1P26PT jFYCTnJdmrQ2M6KtpFFCz9ik4Hs0a2M= X-Received: by 2002:a1c:c006:: with SMTP id q6-v6mr5550535wmf.107.1530119848205; Wed, 27 Jun 2018 10:17:28 -0700 (PDT) Received: from vanye.hemma.eciton.net (cpc92302-cmbg19-2-0-cust304.5-4.cable.virginm.net. [82.1.209.49]) by smtp.gmail.com with ESMTPSA id a2-v6sm3406572wmb.6.2018.06.27.10.17.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Jun 2018 10:17:26 -0700 (PDT) From: Leif Lindholm To: grub-devel@gnu.org Subject: [PATCH v3 3/6] arm64 linux loader: rename functions and macros and move to common headers Date: Wed, 27 Jun 2018 18:17:17 +0100 Message-Id: <20180627171720.27028-4-leif.lindholm@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180627171720.27028-1-leif.lindholm@linaro.org> References: <20180627171720.27028-1-leif.lindholm@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::242 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: The development of GNU GRUB Cc: Daniel Kiper MIME-Version: 1.0 Errors-To: grub-devel-bounces+patch=linaro.org@gnu.org Sender: "Grub-devel" In preparation for using the linux loader for 32-bit and 64-bit platforms, rename grub_arm64*/GRUB_ARM64* to grub_efi*/GRUB_EFI*. Move prototypes for now-common functions to efi/efi.h. Signed-off-by: Leif Lindholm --- grub-core/loader/arm64/linux.c | 14 +++++++------- grub-core/loader/arm64/xen_boot.c | 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..577fbda54 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_efi_linux_check_image (struct linux_armxx_kernel_header * lh) { - if (lh->magic != GRUB_LINUX_ARM64_MAGIC_SIGNATURE) + if (lh->magic != 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_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_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_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..b86704757 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_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_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..4c0d8d239 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 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..5888bf6ac 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_efi_linux_check_image(struct linux_armxx_kernel_header *lh); +grub_err_t grub_efi_linux_boot_image(grub_addr_t addr, grub_size_t size, + char *args); #endif grub_addr_t grub_efi_modules_addr (void); From patchwork Wed Jun 27 17:17:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 140370 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp1152049ljj; Wed, 27 Jun 2018 10:18:56 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfmGZvnKZ2T+Nind78LzyFYzXkDP2GZMOYrKpEZcAWTO8w0oZPUcAsTLBPbqeRFPUggKVrt X-Received: by 2002:a37:32cb:: with SMTP id y194-v6mr5852516qky.11.1530119936485; Wed, 27 Jun 2018 10:18:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530119936; cv=none; d=google.com; s=arc-20160816; b=ltJiUmhwo+OLN9DBUWRbyOaAqGeXtq/88nAKGAb4mN44Yj65iYrlSQ8Tr0CP42GRkv mXleaBrOdGCrOvypxjCTaR8gSWZ+WxIMIPnDeFo2fiUjIH9iZ2M6s5qNw09Cftu8Q1eK RkaHBjwLPM9kNp7RSoOf+xeYoyYQF/FLLa70CKH9w/Nuhovjd24MxPU+fhfjuUQ30lWu LgmTgOnUDplNvGxt0CO1y3E9vJxqSsrDXGiGeFTl6invyOuiY8HB8VuVF/xV1OMAtJIx WHf7l82afSce8YBauS3CvSZ7BpMWDi4GBRWuPEdFQNWuPcXEYWs78TXvbROqm6pcp8+e yKrw== 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=MbGFomyabspKcMeWSwUa9T9ETbkqecrDZTuSZLkj3Zs=; b=rgIlddEV4IK88I6uE+SZE0IXyeKTX55Qwv8/gJgol/rRzdwuHurR00xLmv/QdASiq3 yvk0mwR3paDwdv0jMHkPtxq3ZPiqppQqg/fwu6LjQ7GQEIR5NeNAXagf8N/iwVqkuy0q lkstWQc031+UER6wl0Zsam5gIU06myM5w71eW5xbqdp2O9skTMct7+X4+DV21eSe5YKs THPVTKAzEnoqtIEGaG0DzM+U6z8T+Afar5tOk2BlBxFUpmRbWcenBkHR8Qwxv8W417Ye f7Lf56DavucBFMrgr1wbZSAXJSxWxb7ojGXKbVPbyllxELOHo34fWLGu3Z7156auAJqd KVww== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=MwWL3AS9; 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 j23-v6si2120794qtj.7.2018.06.27.10.18.56 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 27 Jun 2018 10:18:56 -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=MwWL3AS9; 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]:60569 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYE5n-0004dG-LW for patch@linaro.org; Wed, 27 Jun 2018 13:18:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57653) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYE4S-0004b1-8i for grub-devel@gnu.org; Wed, 27 Jun 2018 13:17:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYE4R-0006Qk-8x for grub-devel@gnu.org; Wed, 27 Jun 2018 13:17:32 -0400 Received: from mail-wm0-x22d.google.com ([2a00:1450:400c:c09::22d]:50590) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYE4R-0006P8-14 for grub-devel@gnu.org; Wed, 27 Jun 2018 13:17:31 -0400 Received: by mail-wm0-x22d.google.com with SMTP id e16-v6so6667116wmd.0 for ; Wed, 27 Jun 2018 10:17:30 -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=z0Nq9Ij3m9J3jbNyWxzW3B8f4DwIMamSf8WOvEdMQsg=; b=MwWL3AS9hzr9oBNFhzVOw2U4mrJNKhUYvObS3jQdQHbnuZMchIu9p9NKakleNEtmn0 CMDO9jSHzJQI/ZBESTdLeTBg/D7kQLd5UDikNtlNKWJQxW9c9iz3pfstguuL2uc3mAVf X37PdGnvFvEhfGf8ln1cB4qoXpqDeFPS72B38= 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=z0Nq9Ij3m9J3jbNyWxzW3B8f4DwIMamSf8WOvEdMQsg=; b=s1FAHXnC44Cy65fpfN9e9eM6Ha49hC7MHMl6fMb4QRwXB084fxrGvk04IRBeo5BLCD I5hgUGgcwA8JAeY+dPSEk0+zYOie/QKiX99ReTmM7ZnpBfkUaOdwhzCoWFm5+VIq1xZb 0BWwetRUvSDVlzOyxniTldrzJe1ERRaUeYVPcggohSAkUWtQIoMryO9lV/6hL+0OPI+d xjMae7mtIJkB7wgPX4nQnV9lxSp7QIuXkDsCaYz0xn7snjtHAE5Uhm+qLqOCBNtMMgRZ rkHXMF9bg+IxSGYdNSFMeY9/mwYpuIhiYP/P1WRfkYKjM96h0VxMzIWNJEcErya3gQxK d4tQ== X-Gm-Message-State: APt69E1qXlezThmCQJQFkBTqR0983zpwpLkrO/ixIO0gmOxqH1RV/PcG Zi2cmVKCIlMostzhIgF1Om+rmG/3Ch8= X-Received: by 2002:a1c:ad4:: with SMTP id 203-v6mr5419221wmk.98.1530119849709; Wed, 27 Jun 2018 10:17:29 -0700 (PDT) Received: from vanye.hemma.eciton.net (cpc92302-cmbg19-2-0-cust304.5-4.cable.virginm.net. [82.1.209.49]) by smtp.gmail.com with ESMTPSA id a2-v6sm3406572wmb.6.2018.06.27.10.17.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Jun 2018 10:17:28 -0700 (PDT) From: Leif Lindholm To: grub-devel@gnu.org Subject: [PATCH v3 4/6] arm/efi: switch to arm64 linux loader Date: Wed, 27 Jun 2018 18:17:18 +0100 Message-Id: <20180627171720.27028-5-leif.lindholm@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180627171720.27028-1-leif.lindholm@linaro.org> References: <20180627171720.27028-1-leif.lindholm@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::22d X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: The development of GNU GRUB Cc: Daniel Kiper MIME-Version: 1.0 Errors-To: grub-devel-bounces+patch=linaro.org@gnu.org Sender: "Grub-devel" Switch over to the EFI-stub aware arm64 loader for 32-bit ARM platforms. 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 10ffa2c9b..b6a3f40f7 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..54658af1b 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 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 5888bf6ac..e75c730c0 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_efi_linux_check_image(struct linux_armxx_kernel_header *lh); From patchwork Wed Jun 27 17:17:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 140368 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp1150883ljj; Wed, 27 Jun 2018 10:17:53 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcSEFJxveLdC9881n4RotFYZacvXr3hW1NVbR1uUWt2UYEiAAwdOMqKBuQL0wsD8B3QlL0d X-Received: by 2002:aed:23e7:: with SMTP id k36-v6mr6472537qtc.20.1530119873771; Wed, 27 Jun 2018 10:17:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530119873; cv=none; d=google.com; s=arc-20160816; b=du/QLVPYSeyGv1Zj2jyC8vG1BLnbne/FDoUlGXJysZfcwvE+6iF5esF8TZIL8NqUtk WglXg5NimilafLPgFD2qhMXjbxZxAugCg5KbTHLvVww/SgRfthMMwNhepAjHhgtvHojH 905zEiEbnppq4W085Sa5WWmG1atSFdQPEK0tcPOPdwHqyKQVIcp+fMZ/FfihzjFI6hOm S+LlslRu65RwQMIU10jcfXYzCNYfab6x6PieWoTcfx6picO9ruUqY/MpyMOrZnXUJBQt GswQfhHHe6+7uMeY1+sQ+X1NnKjIDkb9Dpa5SfkGp/DITyAuxEkBnkGBk1KJzPwjL3m4 ROfg== 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=llzs+yW/Y+5KOHGlUMU7kfOBK2316Ush5gM/q1N9nOU=; b=aA1+rG5K10t52w+9ofXD95koloAoBqFbWVGKAeaiCw/VfXx+rPQm+V3xY9IHy5uXOt BsuyL4Yman0Cs7yJLbwJONOucMUaHmklhffl3W5UV1n6fvnFEg0k5CeEl4dmQPTSnymc R1+fwmxoTq3RN2XZAv6BYwOSJYSafWyQ9oljuDEzUxuOujTYe1Pua9hFlm6mX6+rzoTb +viswRSxJXqB3i85sXlRUnwnI63kvN4dK6yUz7H/w4iOKqRsNq7aMgaPunp9BtZvyy+L l6BezplX9d+Y7gNDNcYLZ4mQplQHSGD9rF6oE/BfMASCApmX8KSVd731NrLf80AAL+cQ 5luw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=UAAiOJZ8; 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 a1-v6si1501417qvh.212.2018.06.27.10.17.53 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 27 Jun 2018 10:17:53 -0700 (PDT) Received-SPF: pass (google.com: domain of grub-devel-bounces+patch=linaro.org@gnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=UAAiOJZ8; 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]:60570 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYE4m-0004hR-SE for patch@linaro.org; Wed, 27 Jun 2018 13:17:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57701) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYE4W-0004dJ-8z for grub-devel@gnu.org; Wed, 27 Jun 2018 13:17:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYE4U-0006Uf-7V for grub-devel@gnu.org; Wed, 27 Jun 2018 13:17:36 -0400 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:54328) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYE4T-0006U6-U0 for grub-devel@gnu.org; Wed, 27 Jun 2018 13:17:34 -0400 Received: by mail-wm0-x243.google.com with SMTP id i139-v6so6648787wmf.4 for ; Wed, 27 Jun 2018 10:17:33 -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=edkitR1+Rpz9K+92lbQeNkR9GvrAFaPjGhY735waU98=; b=UAAiOJZ8dmRfSltg8FtWmtaSpa6+VoT7Prqjc+HQhfEnMyB1Dyg6p61WMAp6soh1ga fVYx+IPDf7XILdE2CXnLLAUJVssF3h8G5IAysKA4MoLLF6jrJfiRmP13Bcm5CxJgXbtm vbH6XGmFHlCdegDuJ/eBxMd2TOXx7HOWeDZYg= 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=edkitR1+Rpz9K+92lbQeNkR9GvrAFaPjGhY735waU98=; b=D/Uu2wXeOTEKKbcL3KSWaQgaG3SXkV83lb2WnsQ3VDxaHNUfxckz13Y4TXttyvijGS 2EM/IYSHT2G3JeMqNSiDhKI9zHQsEW5Erln49XAg2YOjg5DSnGOYe1vYsGcowioDXPx0 kKAnCnXM1WjCMxPqcDhTJiyupnCjv25z8XhSgFZk2eFAHHh+O8xJHjj/2LO+4UWu+e08 rkiaCmLYSLriUhKfNNZK+dRZZbMqapYLVkFkJPPGZlL3mFogodTyG3bRCgElvMUM+tJl oPYgzfemFsZyVGFqz+FobLjD6JAFj3ln1bg3hXqY+5ZdiFo80fU6TKMDZkDfa8fap1Au iwkw== X-Gm-Message-State: APt69E3lZzLoURDIR9qqDuozdmSAWA4R58kbR32RwvDVA2suT+Udh+La mySsM7r5EehetxLNnd5I6nwSvoijgQs= X-Received: by 2002:a1c:1414:: with SMTP id 20-v6mr5417981wmu.119.1530119852503; Wed, 27 Jun 2018 10:17:32 -0700 (PDT) Received: from vanye.hemma.eciton.net (cpc92302-cmbg19-2-0-cust304.5-4.cable.virginm.net. [82.1.209.49]) by smtp.gmail.com with ESMTPSA id a2-v6sm3406572wmb.6.2018.06.27.10.17.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Jun 2018 10:17:30 -0700 (PDT) From: Leif Lindholm To: grub-devel@gnu.org Subject: [PATCH v3 5/6] arm: delete unused efi support from loader/arm Date: Wed, 27 Jun 2018 18:17:19 +0100 Message-Id: <20180627171720.27028-6-leif.lindholm@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180627171720.27028-1-leif.lindholm@linaro.org> References: <20180627171720.27028-1-leif.lindholm@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c: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 54658af1b..9a4a5fb7e 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 Wed Jun 27 17:17:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 140372 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp1152257ljj; Wed, 27 Jun 2018 10:19:05 -0700 (PDT) X-Google-Smtp-Source: AAOMgpc8fsyrk9c3WDbXQhtE5g9qUzZWuGhpw3bY9QtzhP9n16cmRY2FeGSowULJHK6aMZh5U2nU X-Received: by 2002:aed:2317:: with SMTP id h23-v6mr5712831qtc.85.1530119945667; Wed, 27 Jun 2018 10:19:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530119945; cv=none; d=google.com; s=arc-20160816; b=PD+SQ9aw2CcKyyYvFQgM3ET8IxDAItnnOLg3JbUmq9HN1oFBr7QuMkwrdFfC4SzoNR rNOVnunZbzpkMoPAzPLV6RaqoU6rodeHlu5hikXa9DZqRnM3Si1CljhkkHZuy5YkcFI/ lA4PajYbnlreuMDT4vK7lTASxP2z6lDTUTCaHTmjnTDCQU2pxifZ7hLeeL8Ag/iSEI0V A/O6LMatMYhrtbrng0fWn8pyJ07OwXWiC55F0h8SvnjQEAHrUDQoK95MwQKNxNoIexTq WAU1ahiZLBv/z2jtV5Dg4Wi0i1wszGbymCJRj/D1V1Gp2+BZNxh39AisUPxG/itADUm9 yqIw== 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=Z4fa3yjbEmziHOCxKTQLig5a7J51yJiPU10ubc/s018=; b=o7xRXazI/WX8yY2nE/KS6/NwenL3m4VulounUvcampjRjNsqUGqH3upTUF9j9Ewfo5 aVXQLcnO1/6b7BOseyvEpxufcKBZQ7tP0BbGDgp7rR27v+CEUIJTQjDjl7SY/HvsLWR5 Rd8kf4LzmqXWZnENufbiYOmSnwD39S8WA5Do96YbrLAjm6ZvAYsSRaniB6z8XRFCdGl8 nzdubK4QHWhwUcItVmIcFdnhEgp/GNjkUbcVFVSPTg2EZzVD20c55lrN4qomtYJPiJdS gwYJy7CdtpTIe1HKyhEuzr9MuDhawaJ9PGDxjKraZSSiZdwv7Bn8pRLC1LmUW6ZHDZ5f TSzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=B9+LE0sX; 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 s8-v6si4560805qvc.77.2018.06.27.10.19.05 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 27 Jun 2018 10:19:05 -0700 (PDT) Received-SPF: pass (google.com: domain of grub-devel-bounces+patch=linaro.org@gnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=B9+LE0sX; 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]:60574 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYE5w-0005Xd-So for patch@linaro.org; Wed, 27 Jun 2018 13:19:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57765) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYE4b-0004gV-8r for grub-devel@gnu.org; Wed, 27 Jun 2018 13:17:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYE4W-0006Wu-1D for grub-devel@gnu.org; Wed, 27 Jun 2018 13:17:40 -0400 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]:38663) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYE4V-0006Vw-Pa for grub-devel@gnu.org; Wed, 27 Jun 2018 13:17:35 -0400 Received: by mail-wr0-x242.google.com with SMTP id e18-v6so2812593wrs.5 for ; Wed, 27 Jun 2018 10:17:35 -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=Qy4I2sp/I/OB+4EB/ycGuC7SztEI3vJjew2QqPp3/A0=; b=B9+LE0sXIrbCrIh/0kUqE5tcoZebx5PhpVPPQ5PLI/WVbow9rXxTLHfRajWdk7vmrC 3LgLfPK74ldnGV+pg1TJStYVwAA51u4YLuENXwfQ5dyiv8a8UqIasm1GdLluc03T54uQ fUEi8pzl11JjUU/Lr45435piQoGar5A2cGbio= 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=Qy4I2sp/I/OB+4EB/ycGuC7SztEI3vJjew2QqPp3/A0=; b=WjCiN4YACGJbU56HALaRVHmGU+6qMEIVtjvHe6xxXF5dhcmzyH4dlUYp/Ss0F8KzaS keD0xZS76YMcRhi1lSBdjqoGMdZD6w6A2dU6AwK6cboCSt9G8JcYz9xoSZh3gcb4caZr S/CzaVeAJ0A0BvxTI57OHGi8D6wHAXUQNe6TYy+PTitMZO8/lQKUotLroi2YxGsQMEz5 t9ykDwV8mT4WguUKI4TWTumFlnG1OoTTcJromntZYY9mEGj4umpqd+XACA+/x0rZVuP+ tZuiN2A/Xs0Siq+gZ+RPQPGKHos4ukm3l3FTxavDG6MW3sq6CFW3S3ARMO6ZWUk+mv6E utsQ== X-Gm-Message-State: APt69E2RFC7dv+ut6bq0jFq4S/7oE+2g+iuNceqU++J0MBLFmNVe0GpT OITFjuU2i6HCgQjLHVJZuNhogMljZoY= X-Received: by 2002:adf:ec4d:: with SMTP id w13-v6mr5765084wrn.222.1530119854476; Wed, 27 Jun 2018 10:17:34 -0700 (PDT) Received: from vanye.hemma.eciton.net (cpc92302-cmbg19-2-0-cust304.5-4.cable.virginm.net. [82.1.209.49]) by smtp.gmail.com with ESMTPSA id a2-v6sm3406572wmb.6.2018.06.27.10.17.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Jun 2018 10:17:32 -0700 (PDT) From: Leif Lindholm To: grub-devel@gnu.org Subject: [PATCH v3 6/6] efi: restrict arm/arm64 linux loader initrd placement Date: Wed, 27 Jun 2018 18:17:20 +0100 Message-Id: <20180627171720.27028-7-leif.lindholm@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180627171720.27028-1-leif.lindholm@linaro.org> References: <20180627171720.27028-1-leif.lindholm@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::242 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 577fbda54..0d550182f 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; } +/* + * This function returns a pointer to a legally allocated initrd buffer, + * or NULL if unsuccessful + */ +static void * +allocate_initrd_mem (int initrd_pages) +{ + grub_addr_t max_addr; + + if (grub_efi_get_ram_base (&max_addr) != GRUB_ERR_NONE) + return NULL; + + /* + * As per linux/Documentation/arm/Booting + * ARM initrd needs to be covered by kernel linear mapping, + * so place it in the first 512MB of DRAM. + * + * As per linux/Documentation/arm64/booting.txt + * ARM64 initrd needs to be contained entirely within a 1GB aligned window + * of up to 32GB of size that covers the kernel image as well. + * Since the EFI stub loader will attempt to load the kernel near start of + * RAM, place the buffer in the first 32GB of RAM. + */ +#ifdef __arm__ +#define INITRD_MAX_ADDRESS_OFFSET (512U * 1024 * 1024) +#else /* __aarch64__ */ +#define INITRD_MAX_ADDRESS_OFFSET (32ULL * 1024 * 1024 * 1024) +#endif + + max_addr += INITRD_MAX_ADDRESS_OFFSET - 1; + + return grub_efi_allocate_pages_real (max_addr, initrd_pages, + GRUB_EFI_ALLOCATE_MAX_ADDRESS, + GRUB_EFI_LOADER_DATA); +} + static grub_err_t grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), int argc, char *argv[]) @@ -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"));