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 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 DB523C636D4 for ; Thu, 9 Feb 2023 07:15:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=CkqWKhiZ6NkXqCZ15xaIDC5nuggcJn5vpCFtAEPlOZU=; b=n0g7YUWlySO+E2 cFoIZ1PF+4ZiwgZkVcNRhbD25TVbJqzPt+w8UbZCqB0qSQmskS7hsPKwayvtVkorrw0xwZLqq2iFV Fiv0Dqxm5H8ocixE56pNHGYMojX8Wp06ijPdWEHmHfwkeaIqLasyWFEgnAZrK0eDMxaRV/wF5UXwC hKm0HlN2RA/x/oalC1tabUk6hczN0OZDdKzUJtz5tsFG8xchqeroMuyogCWnLuN5sStQoaVbUYG8i e68mXVlCP8iWqmaWrYRxmn5ndHpAOVu6V+z7mUSSo/1JHv8fRaZj8DXnv9DDM9hL4ZGjP7p1XBYgr Wbfoow0saJWvBN7/QVew==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQ18U-000LfD-71; Thu, 09 Feb 2023 07:14:26 +0000 Received: from mail-ej1-x62d.google.com ([2a00:1450:4864:20::62d]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQ18O-000LY4-Pv for linux-arm-kernel@lists.infradead.org; Thu, 09 Feb 2023 07:14:22 +0000 Received: by mail-ej1-x62d.google.com with SMTP id lu11so3656599ejb.3 for ; Wed, 08 Feb 2023 23:14:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=peBY+HBlVZ8ZkvrSDoKKy0AQZ0Ydjnp4NTJQOD0LUtE=; b=fkaxIkSHmLjq+JftR7TsfPbiauz7Vn6O6EnheFTIp90dhq73+8q9oOJNlwHPBuMyjs /RrucsRntMGarzh2pgYuijZaMEfgOEDreTDYnKOXATsIZ4KOcSv7znXEwo/GUeArnf14 rqxKXu7rgyQ55BcgR7MJHLolbobDX8BWmkm4QVb3fgHzs6zCUth8lF11gVYEXBLp8un3 IrBl12FocE0C07WGYgqmG6gF8GeOD1nAMCZMGsEpd5+l8mFHprZEQFu9R9k4iFBY8awE utR12pNl/oUCBYwMpLrwwRNTg0gwPz/ZXQFs8BHMWWaPTuSJNp9rMmWbk+P8lgW//HXx jRDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=peBY+HBlVZ8ZkvrSDoKKy0AQZ0Ydjnp4NTJQOD0LUtE=; b=GvWW5EXmH/g0AAgDn6wnblROq+nZk6aJTVuxeZHerBp3rIMT2TEnSRWoMfnAGX8IWN x0P85RIVtjkckxnXYNfKY0Al/ig79XOm/ADC7dC87k2JkN3KHGENfneLuLD+VznxRiJJ BlpIhqdWhd9w0CHVj6q2V/gUlYkZ+r11xOtxgN3dK3r0vKH+U1aBE8tnF4xSGOu9SGLG Z+/heSlN+igGyozkc9xDmpivhEU9R0bPkI5a3JnHtSIUWolLvZ45mxvDmrM4FP4m74uL zXHq8AcjVjzqoeyM/YJP5ttcLo4A2sSGLJG/zRNAtwBTcmYcUcruSyaQ+c59FayHVRaN EPjA== X-Gm-Message-State: AO0yUKWmgZ+L8YSKmUw6guz7M/daMe8BETNGddb+xBmzVKo6xyXFjlFy SbdV64ab0Pd/OCWVY0v8DydT9A== X-Google-Smtp-Source: AK7set+gm66PMORBWMw+4wP4Y0UArCDRRxflnUcTYgIYxG7RJk6eu83PziSQxhhjh71dxmf9b47bJQ== X-Received: by 2002:a17:907:8a03:b0:7c1:458b:a946 with SMTP id sc3-20020a1709078a0300b007c1458ba946mr14926713ejc.0.1675926856553; Wed, 08 Feb 2023 23:14:16 -0800 (PST) Received: from jade (h-46-59-78-111.A175.priv.bahnhof.se. [46.59.78.111]) by smtp.gmail.com with ESMTPSA id z16-20020a5096d0000000b004aad0a9144fsm346878eda.51.2023.02.08.23.14.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Feb 2023 23:14:16 -0800 (PST) Date: Thu, 9 Feb 2023 08:14:14 +0100 From: Jens Wiklander To: Etienne Carriere Cc: Sumit Garg , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Sudeep Holla , Cristian Marussi Subject: Re: [PATCH 1/2] tee: system invocation Message-ID: References: <20230130094157.1082712-1-etienne.carriere@linaro.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230208_231420_925513_54236632 X-CRM114-Status: GOOD ( 38.13 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Etienne, On Wed, Feb 08, 2023 at 06:09:17PM +0100, Etienne Carriere wrote: > Hello Sumit, Jens, > [snip] > > > > > > > > > > > > if (rpc_arg && tee_shm_is_dynamic(shm)) { > > > > > > - param.a0 = OPTEE_SMC_CALL_WITH_REGD_ARG; > > > > > > + if (ctx->sys_service && > > > > > > + (optee->smc.sec_caps & OPTEE_SMC_SEC_CAP_SYSTEM_THREAD)) > > > > > > + param.a0 = OPTEE_SMC_CALL_SYSTEM_WITH_REGD_ARG; > > > > > > + else > > > > > > + param.a0 = OPTEE_SMC_CALL_WITH_REGD_ARG; > > > > > > > > > > This system thread flag should also be applicable to platforms without > > > > > registered arguments support. IOW, we need similar equivalents for > > > > > OPTEE_SMC_FUNCID_CALL_WITH_ARG and OPTEE_SMC_FUNCID_CALL_WITH_RPC_ARG > > > > > too. So I would rather suggest that we add following flag to all 3 > > > > > call types: > > > > > > > > > > #define OPTEE_SMC_CALL_SYSTEM_THREAD_FLAG 0x8000 > > > > > > > > The main reason platforms don't support registered arguments is that > > > > they haven't been updated since this was introduced. So if a platform > > > > needs system threads it could update to use registered arguments too. > > > > > > Are we hinting at deprecating reserved shared memory support? If yes, > > > wouldn't it be better to be explicit about it with a boot time warning > > > message about its deprecation? > > > > > > Otherwise it will be difficult to debug for the end user to find out > > > why system thread support isn't activated. > > > > > > > The Linux kernel already supports registered arguments. An advantage > > > > with the current approach is that the ABI is easier to implement > > > > since we have distinct SMC IDs for each function. > > > > > > I see your point but my initial thought was that we don't end up > > > making that list too large that it becomes cumbersome to maintain, > > > involving all the combinatorial. > > > > You have a point. Etienne, do you think we could give it a try at > > https://github.com/OP-TEE/optee_os/pull/5789 to better see how this > > would play out? > > > > Indeed I miss that... > With the patch proposed here, indeed if OP-TEE does not support > dynamic shared memory then Linux will never use the provisioned TEE > thread. This is weird as in such a case OP-TEE provisions resources > that will never be used, which is the exact opposite goal of this > feature. Verified on our qemu-arm setup. > > For simplicity, I think this system invocation should require OP-TEE > supports dyn shm. It's not obvious to me that this will easier to implement and maintain. Looking at the code in optee_os it looks like using a flag bit as proposed by Sumit would be quite easy to handle. > > If OP-TEE could know when Linux does not support TEE system > invocation, then OP-TEE could let any invocation use these provisioned > resources so that they are not wasted. > I think a good way would be Linux to expose if it supports this > capability, during capabilities exchange. > Would you agree with this approach? No, I'm not so keen on adding that side effect to OPTEE_SMC_EXCHANGE_CAPABILITIES. The way you're describing the problem it sounds like it's a normal world problem to know how many system threads are needed. How about adding a fast call where normal world can request how many system threads should be reserved? If none are requested, none will be reserved. Cheers, Jens _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel