From patchwork Thu Jul 4 07:35:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 809953 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp1044197wru; Thu, 4 Jul 2024 00:44:37 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWnfGDYnJn0QRAXHfh0ugYGLfbP1KFXslIAgoxaGykHZJg/YxW74uZ3a320JO83fN1tZpCrjIaf8AlXnE0ssOfX X-Google-Smtp-Source: AGHT+IHokrH2uhpzFhsZ/hZKQRpBh5FdrYz+eusMDjr+AucnYZvPxznnIvX4wc4/2dxt/cA6Xp95 X-Received: by 2002:a17:906:16d0:b0:a77:ba2a:3c67 with SMTP id a640c23a62f3a-a77bdd94c28mr44001666b.38.1720079077266; Thu, 04 Jul 2024 00:44:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720079077; cv=none; d=google.com; s=arc-20160816; b=y0V7lk4F5eYH3ouP49l7QWU/cSQfPDSipI7dnVjF0bKGwKNw6X948EEp5hWzcaiWUm rECFaGyR0pfiMNfGhahTpvojQ8BsRWCujx7JcJHIutJe9Xps+RWU+a2dRz3CLdY8afFp GMrOmpBWbjeKpH8tmVcHaREp2a+0Ji/T5sYCekQauqySHrd22KCsJEpbfxAlsLkMHNt7 mbgBBJACXTg6ewjWsaaOr60CsiE7j5SwviPuVbk9MY/Zb8jAF4fEPockHmsMFfkOeQ8g sdAa1uiCedI0jw7V+iIaM20SUGGN6WMgtjjnR5Uohr76kqWPvWsCa1ihfGXtZ7av42WC EGuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=EAPm2TyxcLSf2cNZ5EAbf0+YOo11ELrKelSSYsL+yt8=; fh=ez1zzjhC0XWyqTp7tWutqrA/nFdALDnQKrnQnXYhk5Q=; b=bxFgs+kb2fOrLx2m6wNbxEHJNLyHarpT5j/xic1FWcHhADazyYAnsW1VrtQTEjGlRx 6gQIjWBmAEPRr4Vgqj0xznpXvXC/eGhQcavAM5kDS6Qj7PfaixJkQQOThMAvVuQDvz1w G4vuo7Bm+qsQjjfs5pgNfXjgUSDzv+/uM5StZigPxlUoVbxSmpBB2FEgQ/baE3efEobV HP+wGyqUhFmtWxivqwW27PUiIQX+xcud81MGnTTibfNxwCPLIYtrO0zmCEczZNGfcpQb JYbwyZKvcU9gT5yiXVonH/hu4U7RvDJtGY0urR3XqyGkih4RyptYXC9OBULA9SXbpg3E A7cA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id a640c23a62f3a-a72ab0bb552si637407366b.948.2024.07.04.00.44.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jul 2024 00:44:37 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2407A8897B; Thu, 4 Jul 2024 09:38:57 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org 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 AD9FE888E7; Thu, 4 Jul 2024 09:38:56 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.2 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id A9DF38897B for ; Thu, 4 Jul 2024 09:38:54 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sughosh.ganu@linaro.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3773FDA7; Thu, 4 Jul 2024 00:39:19 -0700 (PDT) Received: from a079122.blr.arm.com (a079122.arm.com [10.162.17.48]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id F0E483F762; Thu, 4 Jul 2024 00:38:50 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Tom Rini , Ilias Apalodimas , Heinrich Schuchardt , Simon Glass , Marek Vasut , Mark Kettenis , Fabio Estevam , Michal Simek , Sughosh Ganu Subject: [RFC PATCH v2 46/48] lmb: mark the EFI runtime memory regions as reserved Date: Thu, 4 Jul 2024 13:05:42 +0530 Message-Id: <20240704073544.670249-47-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240704073544.670249-1-sughosh.ganu@linaro.org> References: <20240704073544.670249-1-sughosh.ganu@linaro.org> MIME-Version: 1.0 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.8 at phobos.denx.de X-Virus-Status: Clean Mark the EFI runtime memory region as reserved memory during board init so that it does not get allocated by the LMB module on subsequent memory requests. Signed-off-by: Sughosh Ganu --- Changes since V1: New patch lib/lmb.c | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/lib/lmb.c b/lib/lmb.c index 387ec2ac65..6018f1de31 100644 --- a/lib/lmb.c +++ b/lib/lmb.c @@ -19,6 +19,7 @@ #include #include #include +#include DECLARE_GLOBAL_DATA_PTR; @@ -212,33 +213,31 @@ void arch_lmb_reserve_generic(ulong sp, ulong end, ulong align) /** * efi_lmb_reserve() - add reservations for EFI memory * - * Add reservations for all EFI memory areas that are not - * EFI_CONVENTIONAL_MEMORY. + * Add reservations for EFI runtime services memory * - * Return: 0 on success, 1 on failure + * Return: None */ -static __maybe_unused int efi_lmb_reserve(void) +static __maybe_unused void efi_lmb_reserve(void) { - struct efi_mem_desc *memmap = NULL, *map; - efi_uintn_t i, map_size = 0; - efi_status_t ret; + phys_addr_t runtime_start, runtime_end; + unsigned long runtime_mask = EFI_PAGE_MASK; - ret = efi_get_memory_map_alloc(&map_size, &memmap); - if (ret != EFI_SUCCESS) - return 1; +#if defined(__aarch64__) + /* + * Runtime Services must be 64KiB aligned according to the + * "AArch64 Platforms" section in the UEFI spec (2.7+). + */ - for (i = 0, map = memmap; i < map_size / sizeof(*map); ++map, ++i) { - if (map->type != EFI_CONVENTIONAL_MEMORY) { - lmb_reserve_flags(map_to_sysmem((void *)(uintptr_t) - map->physical_start), - map->num_pages * EFI_PAGE_SIZE, - map->type == EFI_RESERVED_MEMORY_TYPE - ? LMB_NOMAP : LMB_NONE); - } - } - efi_free_pool(memmap); + runtime_mask = SZ_64K - 1; +#endif - return 0; + /* Reserve the EFI runtime services memory */ + runtime_start = (uintptr_t)__efi_runtime_start & ~runtime_mask; + runtime_end = (uintptr_t)__efi_runtime_stop; + runtime_end = (runtime_end + runtime_mask) & ~runtime_mask; + + lmb_reserve_flags(runtime_start, runtime_end - runtime_start, + LMB_NOOVERWRITE | LMB_NONOTIFY); } static void lmb_reserve_common(void *fdt_blob)