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 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 0A96FC4332F for ; Tue, 15 Nov 2022 09:04:01 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8D6EC84CBD; Tue, 15 Nov 2022 10:03:59 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org 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=linaro.org header.i=@linaro.org header.b="H/1yn8Ob"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0EC1784FF0; Tue, 15 Nov 2022 10:03:58 +0100 (CET) Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) (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 ADE8D83619 for ; Tue, 15 Nov 2022 10:03:55 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ilias.apalodimas@linaro.org Received: by mail-ed1-x52e.google.com with SMTP id s5so4714374edc.12 for ; Tue, 15 Nov 2022 01:03:55 -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=LwL11fKFbTrFtnrWwjW9yty+J0A0b0wRBsdirKj70w8=; b=H/1yn8ObB6yWmCVqz7GG3NHOtUrbAPP77hiN+/A1eOI3+M0OmCUzY6KZEexSen68/N H0v8bsgb2yhmiaBtBNJvqlUHPrAbLKPgcsYPvG9Is9tx/ADAnlIH9JeVLMBO+BwClLds P68wKcUVLoOBYAuOijt6knJEBZdkBpFujY5FHua3uF9VB1MZUjWV62Bo13LPK+QwxCQu o9yX4HLmelOVOTIqKVhHX+AEYu7e4L4BikKu+B7yz9cLuLrep0xPOCwKAjSn4iO58Tkl 1xPW8jDXb+9maPyp/KsMLUczvxxBdRA+lLh9aZpRU7jz6ze1lNf2CUZF1pedF6+UqUot m6zQ== 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=LwL11fKFbTrFtnrWwjW9yty+J0A0b0wRBsdirKj70w8=; b=GauXsl7nIRqW68KVryOb7ITD9vyVRVtvs2+cyXt5q3Ko2baID92eDKSiVr8bHXHteu FVHFbIbcFzitClf1MGfKVDgPj/2qm7SAQk4wP0Pxu+B03027PnuAnNOXCKcZJm3LRM9r pkTa9V/Rvz3j54lNC4Y1bBKNAZ82Aafi7wvxkdNbSuS7D7vj2m4NctyCMQhioKmSJQty NGatARKSVeSt9rgp3yCM/JJNa5l5Q88jAPalTXV8d+t1ZkZN9pApKjnjCbOuc0d0/5Zs Ja8e0j/gTp8wGkfUhXcnlAqThOzeQSNSg6qzJXsBs9dFu7x1Be6y+zjugkP05lDMvk45 cDaw== X-Gm-Message-State: ANoB5pkZGoWeMY5O/sClzdA9LP6FwdfoZ9baAnpFDjVv3Hz0lVDwogu2 BPckvKFGm4Mz0m3B7aU8NDEYww== X-Google-Smtp-Source: AA0mqf5iOvJL7hXX9pWWcggvRpUMHBpXkhA7GvpCwwF0nTwjArRb82llr8dkMMw1IltWjWJQLLH/dQ== X-Received: by 2002:a05:6402:4018:b0:461:dd11:c1bd with SMTP id d24-20020a056402401800b00461dd11c1bdmr13667847eda.406.1668503035234; Tue, 15 Nov 2022 01:03:55 -0800 (PST) Received: from hera ([46.198.253.211]) by smtp.gmail.com with ESMTPSA id v24-20020a170906565800b007806c1474e1sm5164931ejr.127.2022.11.15.01.03.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Nov 2022 01:03:54 -0800 (PST) Date: Tue, 15 Nov 2022 11:03:51 +0200 From: Ilias Apalodimas To: Abdellatif El Khlifi Cc: Drew.Reed@arm.com, achin.gupta@arm.com, jens.wiklander@linaro.org, nd@arm.com, sjg@chromium.org, trini@konsulko.com, u-boot@lists.denx.de, vishnu.banavath@arm.com, xueliang.zhong@arm.com, Gowtham Suresh Kumar Subject: Re: [PATCH v7 09/10] arm_ffa: efi: introduce FF-A MM communication Message-ID: References: <20221013103857.614-1-abdellatif.elkhlifi@arm.com> <20221107192055.21669-1-abdellatif.elkhlifi@arm.com> <20221107192055.21669-10-abdellatif.elkhlifi@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221107192055.21669-10-abdellatif.elkhlifi@arm.com> 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.6 at phobos.denx.de X-Virus-Status: Clean Hi Abdellatif On Mon, Nov 07, 2022 at 07:20:54PM +0000, Abdellatif El Khlifi wrote: > Add MM communication support using FF-A transport > > This feature allows accessing MM partitions services through > EFI MM communication protocol. MM partitions such as StandAlonneMM > or smm-gateway secure partitions which reside in secure world. > > An MM shared buffer and a door bell event are used to exchange > the data. > > The data is used by EFI services such as GetVariable()/SetVariable() > and copied from the communication buffer to the MM shared buffer. > > config EFI_MM_COMM_TEE > - bool "UEFI variables storage service via OP-TEE" > - depends on OPTEE > + bool "UEFI variables storage service via the trusted world" > + depends on OPTEE && ARM_FFA_TRANSPORT This shouldn't rely on both. It's either OP-TEE or FF-A > > +#if (IS_ENABLED(CONFIG_OPTEE)) This separation is a bit problematic. A user can configure bot OP-TEE and FF-A. Those are not mutually exclusive, but for the EFI variables case they are. We need a better way to isolate the compilation choices. Why don't we make ffa_bus_discover() return -1 if FF-A isn't compiled in? > /** > * get_connection() - Retrieve OP-TEE session for a specific UUID. > * > @@ -143,13 +176,229 @@ static efi_status_t optee_mm_communicate(void *comm_buf, ulong dsize) > > return ret; > } > +#endif > + > +#if (IS_ENABLED(CONFIG_ARM_FFA_TRANSPORT)) > + > +/** > + * ffa_notify_mm_sp() - Announce there is data in the shared buffer > + * > + * Notifies the MM partition in the trusted world that > + * data is available in the shared buffer. > + * This is a blocking call during which trusted world has exclusive access > + * to the MM shared buffer. > + * > + * Return: > + * > + * 0 on success > + */ > +static int ffa_notify_mm_sp(void) > +{ > + struct ffa_send_direct_data msg = {0}; > + int ret; > + int sp_event_ret = -1; > + > + if (!ffa_bus_ops_get()) > + return -EINVAL; > + > + msg.data0 = FFA_SHARED_MM_BUFFER_OFFSET; /* x3 */ > + > + ret = ffa_bus_ops_get()->sync_send_receive(mm_sp_id, &msg, 1); > + if (ret != 0) > + return ret; > + > + sp_event_ret = msg.data0; /* x3 */ > + > + if (sp_event_ret == MM_SUCCESS) > + return 0; > + > + /* > + * Failure to notify the MM SP > + */ > + > + return -EACCES; > +} > + > +/** > + * ffa_discover_mm_sp_id() - Query the MM partition ID > + * > + * Use the FF-A driver to get the MM partition ID. > + * If multiple partitions are found, use the first one. > + * This is a boot time function. > + * > + * Return: > + * > + * 0 on success > + */ > +static int ffa_discover_mm_sp_id(void) > +{ > + u32 count = 0, size = 0; > + int ret; > + struct ffa_partition_info *parts_info; > + > + if (!ffa_bus_ops_get()) > + return -EINVAL; > + > + /* > + * get from the driver the count of the SPs matching the UUID > + */ > + ret = ffa_bus_ops_get()->partition_info_get(mm_sp_svc_uuid, &count, NULL); > + if (ret != 0) { > + log_err("EFI: Failure in querying partitions count (error code: %d)\n", ret); > + return ret; > + } > + > + if (!count) { > + log_info("EFI: No MM partition found\n"); > + return ret; > + } > + > + /* > + * pre-allocate a buffer to be filled by the driver > + * with ffa_partition_info structs > + */ > + > + log_info("EFI: Pre-allocating %d partition(s) info structures\n", count); > + > + parts_info = calloc(count, sizeof(struct ffa_partition_info)); I prefer sizeof(*parts_info). Same goes for all sizeof() calls. > + if (!parts_info) > + return -ENOMEM; > + > + size = count * sizeof(struct ffa_partition_info); > + > + /* > + * ask the driver to fill the > + * buffer with the SPs info > + */ > + ret = ffa_bus_ops_get()->partition_info_get(mm_sp_svc_uuid, &size, parts_info); > + if (ret != 0) { if (!ret) [...] Thanks /Ilias