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 53509C5B543 for ; Sat, 7 Jun 2025 10:38:53 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A3F97807B1; Sat, 7 Jun 2025 12:38:51 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; secure) header.d=gmx.de header.i=xypron.glpk@gmx.de header.b="jzJte0d7"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CAF66828F8; Sat, 7 Jun 2025 12:38:50 +0200 (CEST) Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id B0B848003E for ; Sat, 7 Jun 2025 12:38:48 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=xypron.glpk@gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1749292727; x=1749897527; i=xypron.glpk@gmx.de; bh=sv1a4sevFB6tPOFH47/K2fHYXZXGZlzi2c2PxxieVbo=; h=X-UI-Sender-Class:Message-ID:Date:MIME-Version:Subject:To:Cc: References:From:In-Reply-To:Content-Type: Content-Transfer-Encoding:cc:content-transfer-encoding: content-type:date:from:message-id:mime-version:reply-to:subject: to; b=jzJte0d7JCoAkhz7xdyjPzlmTv1bOBgmdvw22jqLrhNL3/ipd+ae31ziIxEnh5D7 ikmY+JnJd+fo1bhrFb2se/xrhPGpKsIUzeo0nxrHQRe5bvwz3/tSCVlV8ALwLWU/J RNMW2yHd+QpaCPJbE+/guFkCcEHfdbLrTm2H3JoCPmvLN/SCOjwX5wcYhGFrzaLEx J+cOvQRZBjXalxQu++vnXXzas5u9baNx9YlfDaTyyb2/JRDZT74H4JDZwDUF/gNnB QLUX6LWTgIazrURdywgpt07UTjf4hFjbMAX3mjTAmzoqu4xZXXvGZOAnJigPGWct3 CtqGehii3XrsE3jBEA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [192.168.143.105] ([46.114.175.200]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1Msq6C-1uhrm3123E-00zesD; Sat, 07 Jun 2025 12:38:47 +0200 Message-ID: Date: Sat, 7 Jun 2025 12:38:45 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 1/4] efi: add EFI_SYSTEM_TABLE_POINTER for debug To: "Ying-Chun Liu (PaulLiu)" Cc: "Ying-Chun Liu (PaulLiu)" , Ilias Apalodimas , Peter Robinson , Simon Glass , u-boot@lists.denx.de References: <20250529040520.3799600-1-paulliu@debian.org> <20250529040520.3799600-2-paulliu@debian.org> Content-Language: en-US From: Heinrich Schuchardt In-Reply-To: <20250529040520.3799600-2-paulliu@debian.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:nKytahqQ+aOwu4s2Z57yIBZ2vtx1sR/FdNd/7AiEk98FpxGbcdr jar53lup14SUldrBH73rJDIfQRCj7XNONrOl4Bvzgi6QZsO/adBLJHWeGYVrTbe4wH9B7N4 pGiT26chuGHT+i1OcejKgLQFgx/A8BTeLYazPJpQg8XM3BeiGFU4TfkgrKb9ftBBREefE7Z /GAs51H/egcIosbKc2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vq4huJh4xKDn8lqd/eWhFfqstfnt+N/d1ihK30IEndhq2pgTOPn5xZAYAt4a6WkE+ tKgZkQiQcFfF3FyxVZT59KkpOxnNWf6cABH874xj4qYaWIAF9xySlTK7t2ezpoaTusCkO2tMX enwsF7LWW/0aHq8gyDMDOzOIO2vprTm8/6pDEaCAxC1mc8NSitjEWStdR6Hoz8hjRjQUkEG2B zBfeVq0 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 On 5/29/25 06:05, Ying-Chun Liu (PaulLiu) wrote: > From: "Ying-Chun Liu (PaulLiu)" >=20 > Add EFI_SYSTEM_TABLE_POINTER structure for remote debugger to locate > the address of EFI_SYSTEM_TABLE. >=20 > This feature is described in UEFI SPEC version 2.10. Section 18.4.2. > The implementation ensures support for hardware-assisted debugging and > provides a standardized mechanism for debuggers to discover the EFI > system table. >=20 > Signed-off-by: Ying-Chun Liu (PaulLiu) > Cc: Heinrich Schuchardt > Cc: Ilias Apalodimas > Cc: Peter Robinson > Cc: Simon Glass > --- > V2: add Kconfig options to turn on/off this feature. > V3: make efi_initialize_system_table_pointer() do the job as described. > V4: use efi_alloc_aligned_pages() for system_table_pointer. > --- > include/efi_api.h | 16 +++++++++++++++ > include/efi_loader.h | 2 ++ > lib/efi_loader/Kconfig | 7 +++++++ > lib/efi_loader/efi_boottime.c | 37 +++++++++++++++++++++++++++++++++++ > lib/efi_loader/efi_setup.c | 8 ++++++++ > 5 files changed, 70 insertions(+) >=20 > diff --git a/include/efi_api.h b/include/efi_api.h > index eb61eafa028..6c4c1a0cc7b 100644 > --- a/include/efi_api.h > +++ b/include/efi_api.h > @@ -259,6 +259,22 @@ struct efi_capsule_result_variable_header { > efi_status_t capsule_status; > } __packed; > =20 > +/** > + * struct efi_system_table_pointer - struct to store the pointer of sys= tem > + * table. > + * @signature: The signature of this struct. > + * @efi_system_table_base: The physical address of System Table. > + * @crc32: CRC32 checksum > + * > + * This struct is design for hardware debugger to search through memory= to > + * get the address of EFI System Table. > + */ > +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 8f9f2bcf1cb..8f065244d8e 100644 > --- a/include/efi_loader.h > +++ b/include/efi_loader.h > @@ -646,6 +646,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/Kconfig b/lib/efi_loader/Kconfig > index 7f02a83e2a2..d878fc9021d 100644 > --- a/lib/efi_loader/Kconfig > +++ b/lib/efi_loader/Kconfig > @@ -71,6 +71,13 @@ config EFI_SECURE_BOOT > config EFI_SIGNATURE_SUPPORT > bool > =20 > +config EFI_DEBUG_SUPPORT_TABLE > + bool "EFI Debug Support Table" > + help > + Select this option if you want to setup the EFI Debug Support > + Table which is used by the debug agent or an external debugger to > + determine loaded image information in a quiescent manner. Please, mention that this also provides the EFI_SYSTEM_TABLE_POINTER. The symbol should be called CONFIG_EFI_DEBUG_SUPPORT as it selects more= =20 than the EFI Debug Support Table. > + > menu "UEFI services" > =20 > config EFI_GET_TIME > diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime= .c > index dbebb37dc04..16e921781e9 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 = =3D { > .tables =3D NULL, > }; > =20 > +struct efi_system_table_pointer __efi_runtime_data * systab_pointer =3D= NULL; > + > /** > * efi_initialize_system_table() - Initialize system table > * > @@ -4035,3 +4037,38 @@ efi_status_t efi_initialize_system_table(void) > =20 > return ret; > } > + > +/** > + * efi_initialize_system_table() - Initialize system table pointer > + * > + * Return: status code > + */ > +efi_status_t efi_initialize_system_table_pointer(void) > +{ > + const int size_4MB =3D 0x00400000; > + u64 addr; > + u32 crc32_value; > + > + /* Allocate configuration table array */ > + addr =3D (u64)efi_alloc_aligned_pages(sizeof(struct efi_system_table_p= ointer), > + EFI_RUNTIME_SERVICES_DATA, > + size_4MB); > + > + if (!addr) { > + log_err("Installing EFI system table pointer failed\n"); > + return EFI_OUT_OF_RESOURCES; > + } > + > + systab_pointer =3D (struct efi_system_table_pointer *)addr; > + memset(systab_pointer, 0, sizeof(struct efi_system_table_pointer)); > + > + systab_pointer->signature =3D EFI_SYSTEM_TABLE_SIGNATURE; > + systab_pointer->efi_system_table_base =3D (efi_physical_addr_t)&systab= ; > + > + crc32_value =3D crc32(0, > + (const unsigned char *)systab_pointer, > + sizeof(struct efi_system_table_pointer)); > + systab_pointer->crc32 =3D crc32_value; > + > + return EFI_SUCCESS; > +} > diff --git a/lib/efi_loader/efi_setup.c b/lib/efi_loader/efi_setup.c > index 48f91da5df7..a6b37d994f6 100644 > --- a/lib/efi_loader/efi_setup.c > +++ b/lib/efi_loader/efi_setup.c > @@ -278,6 +278,14 @@ efi_status_t efi_init_obj_list(void) > if (ret !=3D EFI_SUCCESS) > goto out; > =20 > + /* Initialize system table pointer */ > + if (IS_ENABLED(CONFIG_EFI_DEBUG_SUPPORT_TABLE)) { Please, put all code that is enabled by CONFIG_EFI_DEBUG_SUPPORT_TABLE=20 into a separate code module as it is not related to EFI boot services. Best regards Heinrich > + ret =3D efi_initialize_system_table_pointer(); > + if (ret !=3D EFI_SUCCESS) { > + goto out; > + } > + } > + > if (IS_ENABLED(CONFIG_EFI_ECPT)) { > ret =3D efi_ecpt_register(); > if (ret !=3D EFI_SUCCESS)