Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 791EDC433EF for ; Sun, 27 Feb 2022 14:23:25 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7FBDE83BC0; Sun, 27 Feb 2022 15:23:23 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=csgraf.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 5EF5083BCC; Sun, 27 Feb 2022 15:23:22 +0100 (CET) Received: from zulu616.server4you.de (mail.csgraf.de [85.25.223.15]) by phobos.denx.de (Postfix) with ESMTP id 2319683A6B for ; Sun, 27 Feb 2022 15:23:19 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=csgraf.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=agraf@csgraf.de Received: from localhost.localdomain (dynamic-095-118-033-200.95.118.pool.telefonica.de [95.118.33.200]) by csgraf.de (Postfix) with ESMTPSA id 7112860805FC; Sun, 27 Feb 2022 15:23:18 +0100 (CET) From: Alexander Graf To: u-boot@lists.denx.de Cc: Tuomas Tynkkynen , Simon Glass , Mark Kettenis , Bin Meng , Asherah Connor , Heinrich Schuchardt Subject: [PATCH] qfw: Allocate ACPI memory using efi logic Date: Sun, 27 Feb 2022 15:23:17 +0100 Message-Id: <20220227142317.37235-1-agraf@csgraf.de> X-Mailer: git-send-email 2.32.0 (Apple Git-132) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean When we allocate ACPI tables dynamically as part of the qfw ACPI loading code and then later want to boot a UEFI target using them, we need to make sure that the UEFI logic is aware that these memory regions are ACPI, so that the loading kernel can mark them as reserved. Since we'll never see alignment requirements more than a page, let's just use efi_allocate_pages when we see high memory allocation requests in a UEFI enabled environment. Even if we then boot using the native zImage later, the memory allocation will still be valid. Without this patch, Linux will refuse to consume the DSDT when passed from qfw's ACPI framework. With this patch, it happily uses it. Signed-off-by: Alexander Graf --- drivers/misc/qfw.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/misc/qfw.c b/drivers/misc/qfw.c index 754bc6a603..7c6ed41f48 100644 --- a/drivers/misc/qfw.c +++ b/drivers/misc/qfw.c @@ -18,6 +18,9 @@ #if defined(CONFIG_GENERATE_ACPI_TABLE) && !defined(CONFIG_ARM) #include #endif +#ifdef CONFIG_EFI_LOADER +#include +#endif #if defined(CONFIG_GENERATE_ACPI_TABLE) && !defined(CONFIG_SANDBOX) /* @@ -35,7 +38,7 @@ static int bios_linker_allocate(struct udevice *dev, { uint32_t size, align; struct fw_file *file; - unsigned long aligned_addr; + unsigned long aligned_addr = 0; align = le32_to_cpu(entry->alloc.align); /* align must be power of 2 */ @@ -59,7 +62,19 @@ static int bios_linker_allocate(struct udevice *dev, * in which is low memory */ if (entry->alloc.zone == BIOS_LINKER_LOADER_ALLOC_ZONE_HIGH) { +#ifdef CONFIG_EFI_LOADER + efi_status_t ret; + u64 efi_addr = 1ULL << 32; + + ret = efi_allocate_pages(EFI_ALLOCATE_MAX_ADDRESS, + EFI_ACPI_RECLAIM_MEMORY, + efi_size_in_pages(size), + &efi_addr); + if (ret == EFI_SUCCESS) + aligned_addr = efi_addr; +#else aligned_addr = (unsigned long)memalign(align, size); +#endif if (!aligned_addr) { printf("error: allocating resource\n"); return -ENOMEM; -- 2.32.0