From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4C06BC433EF for ; Fri, 3 Sep 2021 16:43:18 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 5D8B560FC4 for ; Fri, 3 Sep 2021 16:43:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5D8B560FC4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2F9B183300; Fri, 3 Sep 2021 18:43:14 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com 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; unprotected) header.d=gmail.com header.i=@gmail.com header.b="AOdazHaS"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 64B76834F9; Fri, 3 Sep 2021 18:43:11 +0200 (CEST) Received: from mail-ot1-x329.google.com (mail-ot1-x329.google.com [IPv6:2607:f8b0:4864:20::329]) (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 B0C1783300 for ; Fri, 3 Sep 2021 18:43:07 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=mr.nuke.me@gmail.com Received: by mail-ot1-x329.google.com with SMTP id c19-20020a9d6153000000b0051829acbfc7so7193100otk.9 for ; Fri, 03 Sep 2021 09:43:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=Y3hgpIddkl2rf/CToczlUpw8VfoHLJbN4JKqnoHQH3M=; b=AOdazHaSD7Wi/CWFrhrvjwXdpp9mxXlMbJeKNByz9WRFV6oXGzVVdOXRlrAXqkOQad NlEzmzVajun+HvuLM6nklHKMaT5NWJ5+Wsftz8Ulggm/EscDvjB1wEUxdkKJSYs8sDe0 RfTC/pqw0q/IwCT+Kf5D4PjilxobWCDLTxJ0/vaCN++VuZ1y2W6Um0KxU3x1Jx93O7OA vt50votxBcCJ0AFzOzB7MyhfXXwTzMt6odJmBWfsxAhK6/K4DIgDd3Cb3HDAHunTBCer Nt0ZNCTRhOuCzeaI9BFU9F36YyDdVyk7n1JmNaav1fvU4X3uQmhcQC1G5MU7JCIXYwWD N3PA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Y3hgpIddkl2rf/CToczlUpw8VfoHLJbN4JKqnoHQH3M=; b=gsUQDh51GZeD2UZKIkwYJBYBqKDUmO0cVd2kUcW3H0/3cKM3Nzlh/+rz5982eKfYSw t+E02ejzOob5rkl/TNCRZ8RMvqplldRDPq1DpBbLRVvcDsRc09emAZg2AGqJxJUzLcCS 9ScruJ9wb8ecBsRdPRN6JDIdFxzgr1aJjVFDyJCP5bKtMpo5pjeB+eXeU5M2Bd37qEf/ H98yK66kW9Z+kZOGBjlaHdAK++aLYh//9M3LgDImOKgdc6H4cnT4ROd1UPb+kcjtUq/o 5a/4pNzZ0mmbmDAhMxrz5Xv6ANYVznjwjq0DoYp14qjNSWBxpNx16horS93eAnl8CfsB s7DA== X-Gm-Message-State: AOAM530Yj7TU4nYwfkjCSn3ucudR58Arc1Dl0wWPnQfZ+w3/SECgtneN Mm3c6NPl2Un6tZaruVfyzM4= X-Google-Smtp-Source: ABdhPJzVTpV+169JAXV5sVWhUYHIxh0ctR17IAU5VARQTucvGBfqi9KtV4beZqVyCOjLuvnyHU6Jmw== X-Received: by 2002:a9d:6506:: with SMTP id i6mr3879698otl.207.1630687386213; Fri, 03 Sep 2021 09:43:06 -0700 (PDT) Received: from nuclearis3.gtech (c-98-195-139-126.hsd1.tx.comcast.net. [98.195.139.126]) by smtp.gmail.com with ESMTPSA id b3sm1098775oie.1.2021.09.03.09.43.04 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 03 Sep 2021 09:43:05 -0700 (PDT) Subject: Re: [PATCH 1/2] lib: optee: remove the duplicate CONFIG_OPTEE To: Patrick Delaunay , u-boot@lists.denx.de Cc: etienne.carriere@linaro.org, Andre Przywara , Bin Meng , Bryan O'Donoghue , Christian Gmeiner , Heinrich Schuchardt , Jens Wiklander , Kever Yang , Masahisa Kojima , Michael Walle , Michal Simek , Ovidiu Panait , =?UTF-8?Q?Pali_Roh=c3=a1r?= , Philipp Tomsich , Philippe Reynes , =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= , Samuel Holland , Sean Anderson , Simon Glass , Stefan Roese , Steffen Jaeckel , Tero Kristo , U-Boot STM32 References: <20210902115512.1.I1c6536da7609f8240549cccae2708e075dc9fcf3@changeid> From: "Alex G." Message-ID: <569089c3-8936-2a47-930e-218805064413@gmail.com> Date: Fri, 3 Sep 2021 11:43:03 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <20210902115512.1.I1c6536da7609f8240549cccae2708e075dc9fcf3@changeid> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.2 at phobos.denx.de X-Virus-Status: Clean Hi Patrick On 9/2/21 4:56 AM, Patrick Delaunay wrote: > The configuration CONFIG_OPTEE is defined 2 times: > 1- in lib/optee/Kconfig for support of OPTEE images loaded by bootm command > 2- in drivers/tee/optee/Kconfig for support of OP-TEE driver. > > It is abnormal to have the same CONFIG define for 2 purpose; > and it is difficult to managed correctly their dependencies. > > Moreover CONFIG_SPL_OPTEE is defined in common/spl/Kconfig > to manage OPTEE image load in SPL. > > This definition causes an issue with the macro CONFIG_IS_ENABLED(OPTEE) > to test the availability of the OP-TEE driver. > > This patch cleans the configuration dependency with: > - CONFIG_OPTEE_IMAGE (renamed) => support of OP-TEE image in U-Boot > - CONFIG_SPL_OPTEE_IMAGE (renamed) => support of OP-TEE image in SPL > - CONFIG_OPTEE (same) => support of OP-TEE driver in U-Boot > - CONFIG_OPTEE_LIB (new) => support of OP-TEE library > > After this patch, the macro have the correct behavior: > - CONFIG_IS_ENABLED(OPTEE_IMAGE) => Load of OP-TEE image is supported > - CONFIG_IS_ENABLED(OPTEE) => OP-TEE driver is supported It seems a little odd to have both OPTEE_LIB and OPTEE_IMAGE, since they are both used together to support booting with OP-TEE. What also seems odd is that "OP-TEE driver in U-Boot" does not depend on "OP-TEE library". Introducing OPTEE_LIB then, makes sense to me, provided that OPTEE depends on OPTEE_LIB, but I'm not sure about OPTEE_IMAGE. > diff --git a/lib/optee/optee.c b/lib/optee/optee.c > index 672690dc53..5676785cb5 100644 > --- a/lib/optee/optee.c > +++ b/lib/optee/optee.c > @@ -20,6 +20,7 @@ > "\n\theader lo=0x%08x hi=0x%08x size=0x%08lx arch=0x%08x" \ > "\n\tuimage params 0x%08lx-0x%08lx\n" > > +#if defined(CONFIG_OPTEE_IMAGE) > int optee_verify_image(struct optee_header *hdr, unsigned long tzdram_start, > unsigned long tzdram_len, unsigned long image_len) > { > @@ -70,6 +71,7 @@ error: > > return ret; > } > +#endif One the idea of having CONFIGs is to include/exclude code via obj-$(CONFIG_FOO)+=code.c. This prevents the proliferation of #ifdefs. It's fairly counterintuitive to have a CONFIG_OPTEE_IMAGE in a file controlled by CONFIG_OPTEE_LIB. Going to optee_verify_image() itself. It essentially checks against OPTEE_TZDRAM_(BASE/SIZE). But those are a derived from devicetree, not Kconfig. So it seems the motivation behing optee_verify_bootm_image() is flawed. Also the error message is not very helpful. In fact, the SPL boot path for OP-TEE doesn't use this function. That's intentional. Here's what I suggest: - Remove OPTEE_TZDRAM_BASE and _SIZE - Remove optee_verify_bootm_image() - No need for CONFIG_OPTEE_IMAGE Alex