Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp329616rdb; Thu, 15 Feb 2024 01:04:48 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXHRO9kjJDUz0da0DGpvba5qz+jbGRtCRAIPKmWB+BFMH/LqsIGyAZdgLbDr22f2z8JixJIo8YM5/YIKgwhcq0B/RiflzkgOiybXeEMsQ== X-Google-Smtp-Source: AGHT+IE7mKIbVAjXkEre7hWSQrO4m0mA0xFW/9FUokYtONnxXdztlkM69wnoExAARuEVi1o6Jlyr X-Received: by 2002:a17:906:8404:b0:a3c:f7c9:5ba with SMTP id n4-20020a170906840400b00a3cf7c905bamr686528ejx.10.1707987888303; Thu, 15 Feb 2024 01:04:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707987888; cv=pass; d=google.com; s=arc-20160816; b=bTZJCYxJpQGEOWvkJhbRWS5LRiPyj/Kw979uBj9DNTV8StpAxqtESN83ao+MUL+/vK YQFsJa7v4BrFPhxV0evSjeLWiVXc7FPpcOszIRMGOre44jDmfPehCus9KmqqfrCzqVt+ PoWyOUXGMS1Rl9mTOLBKjF+6T3KEMC42Q95UUkmmJTSH8wnLE7VvRsK4pc4BxJvOwvip CwPp2/u3AvOOQdKyVVsPoTYdsTZmpBeFXzB25GVgsGD/cdRxgFtrUHNTNE6lZweiyvQE P4U0XadKHXlVBVUYJXXvIqLs3Lj5Om39rvH6rfCb5uznQoSwWmPILmMDOLF1oydMzbgr q+Aw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature; bh=CRfLYsNATkUKnxVcX7WsUtnMmGEl9wEiuB0kaMAyJBM=; fh=FzuNmUBnyxlMG2UApN+OI5rQu4K95M9t/kRkOLHpbMk=; b=l77PVaD2PN2oO1ys2xBkKHZjBLCCzo2sBzBr0acatf+tLxh3LZGcE3atEe2alcwR6v dVTlyB0Vd9RRXEez63K4tQqrknaqrwibebHw0RpVSvX00BkCT/WdukOyJFQ/YDRcZo35 xlT2sCYrxSrrliBKXeZDAA6v17JandGJuJz0wawmdtFK2FymMlVI1OYhwIlzEc7yl2R2 Sk21AG7jiFJNIhHN8Y6IURVvodGGiNmO1OgzUUEEtv7DCDSLKyTntwT3yBzZOY3sy1Xl 5KWNgp+eZHu7PsXDpG4aEhsuNAa+BF/khSpHRVg5XgN7BA67yM5vlzXA2xPzQ9cfNFe2 pf9w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jlUKT8CN; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-66480-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66480-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id ji12-20020a170907980c00b00a3d53e344b6si449858ejc.306.2024.02.15.01.04.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 01:04:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-66480-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jlUKT8CN; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-66480-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66480-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 9A6BF1F21461 for ; Thu, 15 Feb 2024 09:04:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 385C417591; Thu, 15 Feb 2024 08:59:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="jlUKT8CN" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 35F8213FE0; Thu, 15 Feb 2024 08:59:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707987596; cv=none; b=ZQx+BaG45zhJ4opiVlpYazcLbDbTsPwcpvONnFR99S0SjG0+0JQ0emoWL/YUOz4Crc9/OTcvwP51i+90zpZ0nzVZyfoMq0CBGta7//40yIhvj+r6ta2fysX2R7+xXcfuMKSe4GGkjYLxMUMmg47aH/VcZ89NsIBn4TMGMO/vyqQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707987596; c=relaxed/simple; bh=G9qyRbqkA8rWsZ26DMdDBi4+x1C3kmyUp9YqerlCj0U=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=IAfIr39DBb4PfM5J/d57cY8Jx+CW9h0Eu8yP9t2aWmU0LhD5H2w5yhSAXa8lXQ185PcU1tHXYM1gVBlR9G+xWFnWR3uBBADUoYzN0h/p1HfIjz2PILmKbAkTlX8mWxkHZImG8HZpPswrze0g6B54AaDq/sEca3BmG93Fo65BfBo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jlUKT8CN; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5FDAEC433F1; Thu, 15 Feb 2024 08:59:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707987595; bh=G9qyRbqkA8rWsZ26DMdDBi4+x1C3kmyUp9YqerlCj0U=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=jlUKT8CNq1f0gonoEAR5qIVXuHM56JANNrmeW5KovGqqvtwGSiNlMoO0cTCLl7GR8 +oL+TMt5lEhCJbnIX9dptE+EErldu1hg4pOquky6nVwIntF57AlCy38Y4DMDxmu8qs xMslk0934/V+eewWNDhyyfz9k1Q2Aiw02xkfkRKefXolhyq5DUedXlz8EAf+UpSUrF 9qzaVrhvWgIgiTMIqiDXtJtk3iwPdFM677GVa14N2JxnoDHZjukijuDOxjjpo8URDc mOwXLKsT18bxhcuKaXxw4AByUVRoEW9Fb73KmIFySk4tosGJBQ80uKZEDjs7cD3lfp umznrBnUA/Sew== Message-ID: Date: Thu, 15 Feb 2024 09:59:50 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/3] tee: tstee: Add Trusted Services TEE driver Content-Language: en-US To: Balint Dobszay , op-tee@lists.trustedfirmware.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: jens.wiklander@linaro.org, sumit.garg@linaro.org, corbet@lwn.net, sudeep.holla@arm.com, gyorgy.szing@arm.com References: <20240213145239.379875-1-balint.dobszay@arm.com> <20240213145239.379875-3-balint.dobszay@arm.com> From: Krzysztof Kozlowski Autocrypt: addr=krzk@kernel.org; keydata= xsFNBFVDQq4BEAC6KeLOfFsAvFMBsrCrJ2bCalhPv5+KQF2PS2+iwZI8BpRZoV+Bd5kWvN79 cFgcqTTuNHjAvxtUG8pQgGTHAObYs6xeYJtjUH0ZX6ndJ33FJYf5V3yXqqjcZ30FgHzJCFUu JMp7PSyMPzpUXfU12yfcRYVEMQrmplNZssmYhiTeVicuOOypWugZKVLGNm0IweVCaZ/DJDIH gNbpvVwjcKYrx85m9cBVEBUGaQP6AT7qlVCkrf50v8bofSIyVa2xmubbAwwFA1oxoOusjPIE J3iadrwpFvsZjF5uHAKS+7wHLoW9hVzOnLbX6ajk5Hf8Pb1m+VH/E8bPBNNYKkfTtypTDUCj NYcd27tjnXfG+SDs/EXNUAIRefCyvaRG7oRYF3Ec+2RgQDRnmmjCjoQNbFrJvJkFHlPeHaeS BosGY+XWKydnmsfY7SSnjAzLUGAFhLd/XDVpb1Een2XucPpKvt9ORF+48gy12FA5GduRLhQU vK4tU7ojoem/G23PcowM1CwPurC8sAVsQb9KmwTGh7rVz3ks3w/zfGBy3+WmLg++C2Wct6nM Pd8/6CBVjEWqD06/RjI2AnjIq5fSEH/BIfXXfC68nMp9BZoy3So4ZsbOlBmtAPvMYX6U8VwD TNeBxJu5Ex0Izf1NV9CzC3nNaFUYOY8KfN01X5SExAoVTr09ewARAQABzSVLcnp5c3p0b2Yg S296bG93c2tpIDxrcnprQGtlcm5lbC5vcmc+wsGVBBMBCgA/AhsDBgsJCAcDAgYVCAIJCgsE FgIDAQIeAQIXgBYhBJvQfg4MUfjVlne3VBuTQ307QWKbBQJgPO8PBQkUX63hAAoJEBuTQ307 QWKbBn8P+QFxwl7pDsAKR1InemMAmuykCHl+XgC0LDqrsWhAH5TYeTVXGSyDsuZjHvj+FRP+ gZaEIYSw2Yf0e91U9HXo3RYhEwSmxUQ4Fjhc9qAwGKVPQf6YuQ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ckM+3zJHGmVPqJP/h2Iwv6nw8U+7Yyl6gU BLHFTg2hYnLFJI4Xjg+AX1hHFVKmvl3VBHIsBv0oDcsQWXqY+NaFahT0lRPjYtrTa1v3tem/ JoFzZ4B0p27K+qQCF2R96hVvuEyjzBmdq2esyE6zIqftdo4MOJho8uctOiWbwNNq2U9pPWmu 4vXVFBYIGmpyNPYzRm0QPwARAQABwsF8BBgBCgAmAhsMFiEEm9B+DgxR+NWWd7dUG5NDfTtB YpsFAmA872oFCRRflLYACgkQG5NDfTtBYpvScw/9GrqBrVLuJoJ52qBBKUBDo4E+5fU1bjt0 Gv0nh/hNJuecuRY6aemU6HOPNc2t8QHMSvwbSF+Vp9ZkOvrM36yUOufctoqON+wXrliEY0J4 ksR89ZILRRAold9Mh0YDqEJc1HmuxYLJ7lnbLYH1oui8bLbMBM8S2Uo9RKqV2GROLi44enVt vdrDvo+CxKj2K+d4cleCNiz5qbTxPUW/cgkwG0lJc4I4sso7l4XMDKn95c7JtNsuzqKvhEVS oic5by3fbUnuI0cemeizF4QdtX2uQxrP7RwHFBd+YUia7zCcz0//rv6FZmAxWZGy5arNl6Vm lQqNo7/Poh8WWfRS+xegBxc6hBXahpyUKphAKYkah+m+I0QToCfnGKnPqyYIMDEHCS/RfqA5 t8F+O56+oyLBAeWX7XcmyM6TGeVfb+OZVMJnZzK0s2VYAuI0Rl87FBFYgULdgqKV7R7WHzwD uZwJCLykjad45hsWcOGk3OcaAGQS6NDlfhM6O9aYNwGL6tGt/6BkRikNOs7VDEa4/HlbaSJo 7FgndGw1kWmkeL6oQh7wBvYll2buKod4qYntmNKEicoHGU+x91Gcan8mCoqhJkbqrL7+nXG2 5Q/GS5M9RFWS+nYyJh+c3OcfKqVcZQNANItt7+ULzdNJuhvTRRdC3g9hmCEuNSr+CLMdnRBY fv0= In-Reply-To: <20240213145239.379875-3-balint.dobszay@arm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 13/02/2024 15:52, Balint Dobszay wrote: > The Trusted Services project provides a framework for developing and > deploying device Root of Trust services in FF-A Secure Partitions. The > FF-A SPs are accessible through the FF-A driver, but this doesn't > provide a user space interface. The goal of this TEE driver is to make > Trusted Services SPs accessible for user space clients. > > All TS SPs have the same FF-A UUID, it identifies the RPC protocol used > by TS. A TS SP can host one or more services, a service is identified by > its service UUID. The same type of service cannot be present twice in > the same SP. During SP boot each service in an SP is assigned an > interface ID, this is just a short ID to simplify message addressing. > There is 1:1 mapping between TS SPs and TEE devices, i.e. a separate TEE > device is registered for each TS SP. This is required since contrary to > the generic TEE design where memory is shared with the whole TEE > implementation, in case of FF-A, memory is shared with a specific SP. A > user space client has to be able to separately share memory with each SP > based on its endpoint ID. > > Signed-off-by: Balint Dobszay > --- > +static int tstee_probe(struct ffa_device *ffa_dev) > +{ > + struct tstee *tstee; > + int rc; > + > + ffa_dev->ops->msg_ops->mode_32bit_set(ffa_dev); > + > + if (!tstee_check_rpc_compatible(ffa_dev)) > + return -EINVAL; > + > + tstee = kzalloc(sizeof(*tstee), GFP_KERNEL); > + if (!tstee) > + return -ENOMEM; > + > + tstee->ffa_dev = ffa_dev; > + > + tstee->pool = tstee_create_shm_pool(); > + if (IS_ERR(tstee->pool)) { > + rc = PTR_ERR(tstee->pool); > + tstee->pool = NULL; > + goto err; Is it logically correct to call here tee_device_unregister()? > + } > + > + tstee->teedev = tee_device_alloc(&tstee_desc, NULL, tstee->pool, tstee); > + if (IS_ERR(tstee->teedev)) { > + rc = PTR_ERR(tstee->teedev); > + tstee->teedev = NULL; > + goto err; > + } > + > + rc = tee_device_register(tstee->teedev); > + if (rc) > + goto err; > + > + ffa_dev_set_drvdata(ffa_dev, tstee); > + > + pr_info("driver initialized for endpoint 0x%x\n", ffa_dev->vm_id); Don't print simple probe success messages. Anyway all prints in device context should be dev_*. > + > + return 0; > + > +err: > + tstee_deinit_common(tstee); > + return rc; > +} > + > +static void tstee_remove(struct ffa_device *ffa_dev) > +{ > + tstee_deinit_common(ffa_dev->dev.driver_data); > +} > + > +static const struct ffa_device_id tstee_device_ids[] = { > + /* TS RPC protocol UUID: bdcd76d7-825e-4751-963b-86d4f84943ac */ > + { TS_RPC_UUID }, > + {} > +}; > + > +static struct ffa_driver tstee_driver = { > + .name = "arm_tstee", > + .probe = tstee_probe, > + .remove = tstee_remove, > + .id_table = tstee_device_ids, > +}; > + > +static int __init mod_init(void) > +{ > + return ffa_register(&tstee_driver); > +} > +module_init(mod_init) > + > +static void __exit mod_exit(void) > +{ > + ffa_unregister(&tstee_driver); > +} > +module_exit(mod_exit) > + > +MODULE_ALIAS("arm-tstee"); Why do you need this alias? I don't see MODULE_DEVICE_TABLE, so how this bus handles module loading? Best regards, Krzysztof