From patchwork Mon Sep 17 11:54:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 146852 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp3675744ljw; Mon, 17 Sep 2018 04:54:43 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZu0rg9JBzL7UT/obdXjETWnohzCFQUQ+Vkop52EGQKnzf10Eh8OSPkwxwwHJEgd45ti8mQ X-Received: by 2002:aa7:c358:: with SMTP id j24-v6mr43137077edr.100.1537185283440; Mon, 17 Sep 2018 04:54:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537185283; cv=none; d=google.com; s=arc-20160816; b=EUnWUh0jrLLW5jGMlZ61MEJU1tlbqhg6DQdxFXRsaAOGVUyQ41g1WGKF3ZRjqr61io K8Fl+afCc9WLjz/vCsL6khTxRadlEkLtzp0P7izSOqR6pCGqnOhtmtTPoX9KDUeYzDxQ EqVzAM/xdIRApQXlzWqmOMXFMRpgbOD/NIDEOZyu8cHwpB7GWvyl9Hw8HxR5hMNqXuCD L93U2OKHvZ6W8RYwbzEIbmKr9uL98HgceCoRLMmBGBgW8ExMla4Co4/FDCNVyBEY4/g/ dqepCdkVMMoFo77SikbdFF0ZAZsa/DOJ+OjuUlrFJtBCrQT+Zy9pEd2vr/CT0iBlKaim BVXQ== 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 :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:message-id:date:to:from; bh=Z2LXwmI2OI/TkAtZe1TzhnM5v8gHpSgtfB5RGV27EgU=; b=Rs0LxHwy1tcv1tpO0JQY6IjDY3S1kpZZfOhZURncCIXxIrz1OaXVWgc36k+vmYyWWK 1bNtLQhnq2c6WrSM+XW7TUdQV0QBMlHSXbfMaPRR51w5mMzh1extUJWI07F10b9f7IyH sj/TmVNhmPP9mcavI5x0hsDlhl4+0sfzOYFfkTLsUod1w0tMDjDwTTrLgLJnER+2v8Ek iKraitqHcy0NlI+XSiNXuRFAc5XdlW2uXQv4x/j7g1alKnIjbQ0v/MxpTVj3qOXYkMyh jd3DdyuARsHag9RDY00H8wMev4RzTXrVKHJt9nJiFImkajOjmtisAJuskfR8hEjIf2bv Npyg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id a5-v6si3783106edl.388.2018.09.17.04.54.43; Mon, 17 Sep 2018 04:54:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id E0712C21E2C; Mon, 17 Sep 2018 11:54:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 34E3BC21DE8; Mon, 17 Sep 2018 11:54:35 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 6D23DC21DE8; Mon, 17 Sep 2018 11:54:34 +0000 (UTC) Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id 229D7C21DCA for ; Mon, 17 Sep 2018 11:54:34 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id CDC44AF0E; Mon, 17 Sep 2018 11:54:33 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Mon, 17 Sep 2018 13:54:33 +0200 Message-Id: <20180917115433.84505-1-agraf@suse.de> X-Mailer: git-send-email 2.12.3 Cc: Heinrich Schuchardt Subject: [U-Boot] [PATCH v2] efi_loader: Align runtime section to 64kb X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" The UEFI spec mandates that runtime sections are 64kb aligned to enable support for 64kb page size OSs. This patch ensures that we extend the runtime section to 64kb to be spec compliant. Signed-off-by: Alexander Graf --- v1 -> v2: - rename kb to KiB in accordance to the spec - add reference to spec section for alignment requirement - only use 64KiB alignment on aarch64 --- lib/efi_loader/efi_memory.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c index 5bd4f4d7fc..b4cb543275 100644 --- a/lib/efi_loader/efi_memory.c +++ b/lib/efi_loader/efi_memory.c @@ -11,6 +11,7 @@ #include #include #include +#include DECLARE_GLOBAL_DATA_PTR; @@ -563,6 +564,7 @@ __weak void efi_add_known_memory(void) static void add_u_boot_and_runtime(void) { unsigned long runtime_start, runtime_end, runtime_pages; + unsigned long runtime_mask = EFI_PAGE_MASK; unsigned long uboot_start, uboot_pages; unsigned long uboot_stack_size = 16 * 1024 * 1024; @@ -571,10 +573,22 @@ static void add_u_boot_and_runtime(void) uboot_pages = (gd->ram_top - uboot_start) >> EFI_PAGE_SHIFT; efi_add_memory_map(uboot_start, uboot_pages, EFI_LOADER_DATA, false); - /* Add Runtime Services */ - runtime_start = (ulong)&__efi_runtime_start & ~EFI_PAGE_MASK; +#if defined(__aarch64__) + /* + * Runtime Services must be 64KiB aligned according to the + * "AArch64 Platforms" section in the UEFI spec (2.7+). + */ + + runtime_mask = SZ_64K - 1; +#endif + + /* + * Add Runtime Services. We mark surrounding boottime code as runtime as + * well to fulfill the runtime alignment constraints but avoid padding. + */ + runtime_start = (ulong)&__efi_runtime_start & ~runtime_mask; runtime_end = (ulong)&__efi_runtime_stop; - runtime_end = (runtime_end + EFI_PAGE_MASK) & ~EFI_PAGE_MASK; + runtime_end = (runtime_end + runtime_mask) & ~runtime_mask; runtime_pages = (runtime_end - runtime_start) >> EFI_PAGE_SHIFT; efi_add_memory_map(runtime_start, runtime_pages, EFI_RUNTIME_SERVICES_CODE, false);