From patchwork Wed Apr 23 21:31:42 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ying-Chun Liu \(PaulLiu\)" X-Patchwork-Id: 883603 Delivered-To: patch@linaro.org Received: by 2002:a5d:474d:0:b0:38f:210b:807b with SMTP id o13csp3133994wrs; Wed, 23 Apr 2025 14:32:21 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWbuXwP4vrT8b63s7PRRmfwn5YjnolUe+uFej3ROEcDKanI805m1IzBgV7qeWX/RTJzZQutvA==@linaro.org X-Google-Smtp-Source: AGHT+IE6XTxCsQ+6W0MW5/oH/dlrDzwlH0lMybU/nfW9ot8xwhZIaNSRYzkPAx0I/1TvchsRg+cu X-Received: by 2002:a05:6000:2482:b0:39c:1f04:a646 with SMTP id ffacd0b85a97d-3a06cf53254mr54630f8f.13.1745443940978; Wed, 23 Apr 2025 14:32:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1745443940; cv=none; d=google.com; s=arc-20240605; b=b1fiudtPYOgyBIUO0sRJ8F6kmAbXJlgRMZpSxYjQIEMnTXMY8IHtZ/7wx0gO1XjPil UOSQEOBzS3at2GvOQ3H724a7B8EJrpSLkmvN5doDns/GHq32xitTSQHEyXGzXThaFoSB Q/qD3d56Ef0zgKH7lwOTaTags3LU1TKNpdX4CFm/QHP3B4pfhQ8+pxeKnGTZ6TnD9vop +T8+dJfU11489JDFy9gootXWNiAh22uR2XImZJ/9W/W7mh5R2qQb9FvNh5McbBrZM9v/ pr8I4/Z5sjbAsHjd4cbFUdwZNvCTAY8ISxyDyn8d97h9fZZCi8zDsuTd135fsY7oVYDv fkqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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:dkim-signature; bh=naahOQfCQ9QFZUhdV0xqfJzvf7fY56aK2l8A56ypjVc=; fh=yXVQQdlQRM26TTYMoA2yrv//F921MlR4o2VBZ4jl39k=; b=eOzq5XKOQ2ZgipGZjbc5SKzEdwR0Bp/EU7pNDNouyJphPZy6L4grjKIGwm2IEy2mEH XslcxNxWlQsxnyuLkVY59jCTJZPTC3fqnhPVM478fZt928GV0CU/ycjeQRGz0r6IrztK 1T096kUnlr3NvXnFhoubg95MFWScCjv/eufbdCK0QJPhRVcq7WUlMFGCL9VrLIYdON6N 20RKO/6c9LQf5BaCP73ng9P1XNqqY8/RFjW2kVg3ejR0HeTnx+XeX8Y/AP9e+SIEek+C OzBH9JJiK30oNnLVNd5j9fU/A3co5MthxN19vwcmgyy8kZTSk+9BaEmFtA4GGO2/0CZP /gdg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20230601 header.b=KXT6l8+V; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dara=fail header.i=@linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id 5b1f17b1804b1-4409b95e41dsi1411615e9.57.2025.04.23.14.32.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Apr 2025 14:32:20 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20230601 header.b=KXT6l8+V; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dara=fail header.i=@linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CF6DE81B4B; Wed, 23 Apr 2025 23:32:14 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="KXT6l8+V"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BBECD8059D; Wed, 23 Apr 2025 23:32:13 +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=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 5EC568059A for ; Wed, 23 Apr 2025 23:32:11 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=grandpaul@gmail.com Received: by mail-pj1-x102e.google.com with SMTP id 98e67ed59e1d1-301302a328bso422474a91.2 for ; Wed, 23 Apr 2025 14:32:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1745443929; x=1746048729; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=naahOQfCQ9QFZUhdV0xqfJzvf7fY56aK2l8A56ypjVc=; b=KXT6l8+V1PCmuM+ALwD/01tWZhYHjEzEJIapvi5FPwdVGQ2B9CqMtIDZzRwNtgpUPL roYCCgNtd9c0KOAHEUfs4VBospM6U7BYboBOkt++I/PeA8y5Apqe3VfSnzF8pSpMNJA1 SwrnwsRxmaHDfI8CNvLYwNf3dZEyVyhCsZQvOi4KO2kmch0HvTDdR8OFH025F19DuqBM yrSaxAFwevPHUJigTG0IY+WbbNH7EuPhpAA7sk7sLkQMeyv4fjLHorQdISmiz3UwKFc6 yfhGfgkAviEpJeyckeRSCMWXwM+iwZvjkXLVzyVTcYcNiruEDnAbaEYLTNtXIBWkm/M9 8foQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745443929; x=1746048729; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=naahOQfCQ9QFZUhdV0xqfJzvf7fY56aK2l8A56ypjVc=; b=dJH7eU8JIqbJWyZ3iPIrppcae9APAO+Q7d6npWgr6A4qV9xGZmwHNHe1K3xjpeatI0 dHufDHWYJWDWZrXjqx1Sb20oKrTVGtBLNuBOi4m/i7aWchtHviN9doyr/hPyDp8r+PkD cKclpWUFFR+zK/uptbij+IgMFPkcnvDCiQvEyKf6QNmR3zzUmYq6palYqKvKlDczMz4t NW59//ecEUNQnia+O6rCxyx/xOmgTwBXunU+ZuKpAb13T1e5MOQJfY5eAWb9YCLHpgVf FxJHnga4XsfOpM8kHHHvEpVl2IHUZAi1BPbHxDka3NqrULRrTGh+0dk5wwLoOxDrtwgL i2+Q== X-Gm-Message-State: AOJu0YwNeZoDnLXAYmWvuMzPtuluXYhSPySHFeIqq12xg5DAexnVQWDh +YXKTtKNcfwR+nd4OwOY73tEBXPDFoBfkVh4s2k7ZCXWzEm38hCOlJeUGA== X-Gm-Gg: ASbGncvfn9K8mSeJBvGn0YxZes5EMCze5Fe+ZEnCoudk3NqocKQgkoZCNa7k5y3JQM0 ykYdgth+q2iGhdBTZrCl8ennIVoEM7UdqunCGMR/7Atn6RzEs+DVbivEKLgGmABlh5Lu9PGk0ax MdYTaGjdP0vMUj1nTddqL8HY95FBfdkNy54NcOXgaev/y3OrH81/wxRnNonm5lAPAEsvCc8QGAv Rtgjd/NPcTrQMijM+5jGFkqTZ4G5JhkTKPK1SlfdarsC27tiMpZU9cnfoIs7O4S0s9GucVLzRGN gkEvFCSrPRumovi1yoDgO4ro869wdLVsRAwL X-Received: by 2002:a17:90b:45:b0:2ff:5016:7fd2 with SMTP id 98e67ed59e1d1-309ed35b230mr441030a91.24.1745443929218; Wed, 23 Apr 2025 14:32:09 -0700 (PDT) Received: from localhost ([61.71.79.124]) by smtp.gmail.com with UTF8SMTPSA id 98e67ed59e1d1-309df922267sm2182182a91.0.2025.04.23.14.32.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Apr 2025 14:32:08 -0700 (PDT) From: "Ying-Chun Liu (PaulLiu)" To: u-boot@lists.denx.de Cc: "Ying-Chun Liu (PaulLiu)" , Heinrich Schuchardt , Ilias Apalodimas Subject: [PATCH 1/3] efi: add EFI_SYSTEM_TABLE_POINTER for debug Date: Thu, 24 Apr 2025 05:31:42 +0800 Message-ID: <20250423213145.1959046-2-paulliu@debian.org> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250423213145.1959046-1-paulliu@debian.org> References: <20250423213145.1959046-1-paulliu@debian.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 From: "Ying-Chun Liu (PaulLiu)" Add EFI_SYSTEM_TABLE_POINTER structure for debugger to locate the address of EFI_SYSTEM_TABLE. This feature is described in UEFI SPEC version 2.10. Section 18.4.2. Signed-off-by: Ying-Chun Liu (PaulLiu) Cc: Heinrich Schuchardt Cc: Ilias Apalodimas --- include/efi_api.h | 6 +++++ include/efi_loader.h | 2 ++ lib/efi_loader/efi_boottime.c | 44 +++++++++++++++++++++++++++++++++++ lib/efi_loader/efi_setup.c | 7 ++++++ 4 files changed, 59 insertions(+) diff --git a/include/efi_api.h b/include/efi_api.h index eb61eafa028..5017d9037cd 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -259,6 +259,12 @@ struct efi_capsule_result_variable_header { efi_status_t capsule_status; } __packed; +struct efi_system_table_pointer { + u64 signature; + efi_physical_addr_t efi_system_table_base; + u32 crc32; +}; + struct efi_memory_range { efi_physical_addr_t address; u64 length; diff --git a/include/efi_loader.h b/include/efi_loader.h index 1d75d97ebbc..370bc042f70 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -615,6 +615,8 @@ efi_status_t efi_tcg2_measure_dtb(void *dtb); efi_status_t efi_root_node_register(void); /* Called by bootefi to initialize runtime */ efi_status_t efi_initialize_system_table(void); +/* Called by bootefi to initialize debug */ +efi_status_t efi_initialize_system_table_pointer(void); /* efi_runtime_detach() - detach unimplemented runtime functions */ void efi_runtime_detach(void); /* efi_convert_pointer() - convert pointer to virtual address */ diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index 5164cb15986..366bc0d2b1d 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -4001,6 +4001,8 @@ struct efi_system_table __efi_runtime_data systab = { .tables = NULL, }; +struct efi_system_table_pointer __efi_runtime_data * systab_pointer = NULL; + /** * efi_initialize_system_table() - Initialize system table * @@ -4035,3 +4037,45 @@ efi_status_t efi_initialize_system_table(void) return ret; } + +/** + * efi_initialize_system_table() - Initialize system table + * + * Return: status code + */ +efi_status_t efi_initialize_system_table_pointer(void) +{ + efi_status_t ret; + const int size_4MB = 0x00400000; + int pages = efi_size_in_pages(sizeof(struct efi_system_table_pointer)); + int alignment_mask = size_4MB - 1; + int real_pages = pages + efi_size_in_pages(size_4MB); + u64 addr; + u64 aligned_addr; + u32 crc32_value; + + /* Allocate configuration table array */ + ret = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES, + EFI_RUNTIME_SERVICES_DATA, + real_pages, + &addr); + + /* alignment to 4MB boundary */ + aligned_addr = (addr + alignment_mask) & ~alignment_mask; + + systab_pointer = (struct efi_system_table_pointer *)aligned_addr; + memset(systab_pointer, 0, sizeof(struct efi_system_table_pointer)); + + /* + * These entries will be set to NULL in ExitBootServices(). To avoid + * relocation in SetVirtualAddressMap(), set them dynamically. + */ + systab_pointer->signature = EFI_SYSTEM_TABLE_SIGNATURE; + systab_pointer->efi_system_table_base = (efi_physical_addr_t)&systab; + systab_pointer->crc32 = 0; + crc32_value = crc32(0, + (const unsigned char *)systab_pointer, + sizeof(struct efi_system_table_pointer)); + systab_pointer->crc32 = crc32_value; + return ret; +} diff --git a/lib/efi_loader/efi_setup.c b/lib/efi_loader/efi_setup.c index aa59bc7779d..073a08b1127 100644 --- a/lib/efi_loader/efi_setup.c +++ b/lib/efi_loader/efi_setup.c @@ -259,6 +259,13 @@ efi_status_t efi_init_obj_list(void) if (ret != EFI_SUCCESS) goto out; + /* Initialize system table */ + ret = efi_initialize_system_table_pointer(); + if (ret != EFI_SUCCESS) { + printf("EFI init system table pointer fail\n"); + goto out; + } + if (IS_ENABLED(CONFIG_EFI_ECPT)) { ret = efi_ecpt_register(); if (ret != EFI_SUCCESS)