From patchwork Wed Apr 16 07:39:42 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bertrand Marquis X-Patchwork-Id: 14053416 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 lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4E54EC369BA for ; Wed, 16 Apr 2025 07:40:29 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.955184.1348999 (Exim 4.92) (envelope-from ) id 1u4xNc-00068K-5i; Wed, 16 Apr 2025 07:40:20 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 955184.1348999; Wed, 16 Apr 2025 07:40:20 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1u4xNc-00068D-36; Wed, 16 Apr 2025 07:40:20 +0000 Received: by outflank-mailman (input) for mailman id 955184; Wed, 16 Apr 2025 07:40:19 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1u4xNb-00065X-2O for xen-devel@lists.xenproject.org; Wed, 16 Apr 2025 07:40:19 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-flk1.inumbo.com (Halon) with ESMTP id 0a474548-1a96-11f0-9ffb-bf95429c2676; Wed, 16 Apr 2025 09:40:17 +0200 (CEST) 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 7D823152B; Wed, 16 Apr 2025 00:40:14 -0700 (PDT) Received: from C3HXLD123V.arm.com (unknown [10.57.44.175]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id AF4DB3F66E; Wed, 16 Apr 2025 00:40:14 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 0a474548-1a96-11f0-9ffb-bf95429c2676 From: Bertrand Marquis To: xen-devel@lists.xenproject.org Cc: jens.wiklander@linaro.org, Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Stefano Stabellini , Volodymyr Babchuk Subject: [PATCH v5 1/6] xen/arm: Create tee command line parameter Date: Wed, 16 Apr 2025 09:39:42 +0200 Message-ID: X-Mailer: git-send-email 2.47.1 In-Reply-To: References: MIME-Version: 1.0 Add a new command line parameter "tee=" to be used to explicitly select what tee mediator is to be used by Xen and fail if it does not exist or the probe function for it failed. Without specifying which tee is to be used, Xen will use the first one for which the probe function succeeds which depends on the order of the mediator list which depends on the compiler. Using the command line argument, it is now possible to explicit request a specific TEE mediator and panic on boot if it is not available. Signed-off-by: Bertrand Marquis --- Changes in v5: - Typo fix and rewording in command line doc (Julien) - fix include order in tee.c (Julien) - use a local bool instead of retesting the string each time in tee_init (Julien) Changes in v4: - None Changes in v3: - Properly classify tee as arm specific (Jan) Changes in v2: - Patch introduced to add a command line selection of the TEE --- docs/misc/xen-command-line.pandoc | 14 +++++++++++++ xen/arch/arm/include/asm/tee/tee.h | 4 ++++ xen/arch/arm/tee/tee.c | 32 ++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+) diff --git a/docs/misc/xen-command-line.pandoc b/docs/misc/xen-command-line.pandoc index 89db6e83be66..472de1911363 100644 --- a/docs/misc/xen-command-line.pandoc +++ b/docs/misc/xen-command-line.pandoc @@ -2651,6 +2651,20 @@ Specify the per-cpu trace buffer size in pages. Flag to enable TSC deadline as the APIC timer mode. +### tee (arm) +> `= ` + +Specify the TEE mediator to be probed and use. + +The default behaviour is to probe all TEEs supported by Xen and use +the first one successfully probed. When this parameter is passed, Xen will +probe only the TEE mediator passed as argument and boot will fail if this +mediator is not properly probed or if the requested TEE is not supported by +Xen. + +This parameter can be set to `optee` or `ffa` if the corresponding mediators +are compiled in. + ### tevt_mask > `= ` diff --git a/xen/arch/arm/include/asm/tee/tee.h b/xen/arch/arm/include/asm/tee/tee.h index 0169fd746bcd..15d664e28dce 100644 --- a/xen/arch/arm/include/asm/tee/tee.h +++ b/xen/arch/arm/include/asm/tee/tee.h @@ -55,6 +55,9 @@ struct tee_mediator_desc { /* Printable name of the TEE. */ const char *name; + /* Command line name of the TEE (to be used with tee= cmdline option) */ + const char *cmdline_name; + /* Mediator callbacks as described above. */ const struct tee_mediator_ops *ops; @@ -77,6 +80,7 @@ void tee_free_domain_ctx(struct domain *d); static const struct tee_mediator_desc __tee_desc_##_name __used \ __section(".teemediator.info") = { \ .name = _namestr, \ + .cmdline_name = #_name, \ .ops = _ops, \ .tee_type = _type \ } diff --git a/xen/arch/arm/tee/tee.c b/xen/arch/arm/tee/tee.c index 3f65e45a7892..8501443c8e57 100644 --- a/xen/arch/arm/tee/tee.c +++ b/xen/arch/arm/tee/tee.c @@ -18,6 +18,7 @@ #include #include +#include #include #include @@ -25,6 +26,10 @@ extern const struct tee_mediator_desc _steemediator[], _eteemediator[]; static const struct tee_mediator_desc __read_mostly *cur_mediator; +/* Select the TEE mediator using a name on command line. */ +static char __initdata opt_mediator[16] = ""; +string_param("tee", opt_mediator); + /* * TODO: Add function to alter Dom0 DTB, so we can properly describe * present TEE. @@ -80,15 +85,42 @@ uint16_t tee_get_type(void) static int __init tee_init(void) { const struct tee_mediator_desc *desc; + bool select_mediator = strcmp(opt_mediator, ""); + + if ( select_mediator ) + printk(XENLOG_INFO "TEE Mediator %s selected from command line\n", + opt_mediator); + /* + * When a specific TEE is selected using the 'tee=' command line + * argument, we panic if the probe fails or if the requested TEE is not + * supported. + */ for ( desc = _steemediator; desc != _eteemediator; desc++ ) { + if ( select_mediator && + strncmp(opt_mediator, desc->cmdline_name, sizeof(opt_mediator)) ) + continue; + if ( desc->ops->probe() ) { printk(XENLOG_INFO "Using TEE mediator for %s\n", desc->name); cur_mediator = desc; return 0; } + else if ( select_mediator ) + { + panic("TEE mediator %s from command line probe failed\n", + opt_mediator); + return -EFAULT; + } + } + + if ( select_mediator ) + { + panic("TEE Mediator %s from command line not supported\n", + opt_mediator); + return -EINVAL; } return 0;