[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 02/10] xen/arm: ffa: Rework feature discovery


  • To: Julien Grall <julien@xxxxxxx>
  • From: Bertrand Marquis <Bertrand.Marquis@xxxxxxx>
  • Date: Tue, 24 Sep 2024 08:16:35 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=arm.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com])
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
  • Arc-message-signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=4J6lX5DLM4A6nZIX741miPr2fyFj0PUPrw27ajvBAKE=; b=Tj+9SZlz4ku9Ss4Ov91zRb9R/avg8qn7SieiirIOvoycAQy9gAi/R/baKh6Ri6QCVGdFMqsQZ6YYolcphKo8jriVzKTeN/JUWHjhDyrPkkuWmSVMzILxsLPVqMvu2r0jpd54bOFR6v1KEZPQXe9oq0GgyS8uPhIovufmVFs82tFgXBBETKsNoTaJrwGB7egTmCtNO62OQXGsnR9N4xUlON/C3YUCbIBA2z16+PI1TB2n3s964k+RZLBn2uR3hVvZ1bLDBEiHy2AxIiudC3Pq85i9So7Vkot7418VvLrhAe5Zj6nkmQAXTn0MFhA7j4vrJtT1lDIeDFVROk4F+ffxoQ==
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=4J6lX5DLM4A6nZIX741miPr2fyFj0PUPrw27ajvBAKE=; b=HEr6+/HgejoSTuGXNVEdkmgbdyvZ0zsneUrqWJxgE7mgrEmvIV5lMvGqdBrB0/7vcj6wkMFU6Daf30RDgNUm9iz/UWg7boGhVUJgObqUXgryUH3GC3Cxq7ULRpP4TOVzzL+6pbM6tJCVPNjv4rxTQYj5+Z7CSJlyZPbq2S586xNpOpB0umrQVxclKABvA7VoL6YnLAM4zuUXdX41lEo7DfK8L1rFNgE1K8hFynlgF7YB3RdpYsKT4HCrOUdupHkOjlqn5b4D0ZQ/wIIQ2zpH4NSk7qT0C6dHQ9WUbYVC6MfafQw2/brGdOKnrCywpppR44V3TYnFIgGbgD1MkYbaCg==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=NC5Ov1L3ks8TnmrM0G9toqek3Rwhs9OsEQuH0g8g27gNeG+BWdp6mA2zEbwmKKvxhaLaNbSmm+elOaQlz6+iPxYrCGG1+s36qoJwulZ9m/WPNEDSam/8Fy8V72VH6WkBCv7pD1fvT6TTJDBVRDJAT7edV+faCxgl1sGnNEYnQk/RCjzRrsxQqc62zEMEQwkFCuIPsFaC+p9gQ8S7kB6h/xEOe9PDACZJCl4N4BOx6kaosXxLlCbVwJJFEgZO4tZE87tJhn2Kdo6CHyaIkGYGOXSAib804C+azPks8HxnQCkzUFWKIJhrfQ6ob9M1gJ4EvG8FCxQA1hG9O/N4v0krGw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=sre+PlIMsIy8Yc138Fk4fJdjHl+asG1nEbf2smFMfhld4ZBFGWOMS5Ri5AMr4bQeDYeCvDzyA4aWqbYfR2oyg04yiw4VRWUMwjUG7ncHZqJzy6UQw+DgqzhTUhAF3tdc3X2ive7PhVPjKqNSrYSuKxzvP8U02FitWsfB90ds3jpT2mJOV4aQIgQ7u6epW652WqzeAq8ADw67tpFF+adrxcu2u3l+ZIvvcvsB0+xITEXac8641AgF0RE4DyD8XNA/9JSF+u9cHCR43yqDXr5K85EkY3NvSoOmUeO4d09RJqsm0dkeH9NaKO0dcIwCUMDgFkqmef98rBb6wxvwpZsWwg==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Volodymyr Babchuk <volodymyr_babchuk@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>
  • Delivery-date: Tue, 24 Sep 2024 08:17:06 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Thread-index: AQHbCo5ExIbA7l69J0+4YFeayWExYrJjiLEAgAMWSoA=
  • Thread-topic: [PATCH 02/10] xen/arm: ffa: Rework feature discovery

Hi Julien,

Thanks a lot for the review.

> On 22 Sep 2024, at 11:07, Julien Grall <julien@xxxxxxx> wrote:
> 
> Hi,
> 
> On 19/09/2024 14:19, Bertrand Marquis wrote:
>> Store the list of ABI we need in a list and go through the list instead
>> of having a list of conditions inside the code.
>> No functional change.
>> Signed-off-by: Bertrand Marquis <bertrand.marquis@xxxxxxx>
>> ---
>>  xen/arch/arm/tee/ffa.c | 61 +++++++++++++++++++++---------------------
>>  1 file changed, 30 insertions(+), 31 deletions(-)
>> diff --git a/xen/arch/arm/tee/ffa.c b/xen/arch/arm/tee/ffa.c
>> index 7c84aa6aa43d..7ff2529b2055 100644
>> --- a/xen/arch/arm/tee/ffa.c
>> +++ b/xen/arch/arm/tee/ffa.c
>> @@ -74,6 +74,24 @@
>>  /* Negotiated FF-A version to use with the SPMC, 0 if not there or 
>> supported */
>>  static uint32_t __ro_after_init ffa_fw_version;
>>  +/* List of ABI we use from the firmware */
>> +static const uint32_t ffa_fw_feat_needed[] = {
>> +    FFA_VERSION,
>> +    FFA_FEATURES,
>> +    FFA_NOTIFICATION_BITMAP_CREATE,
>> +    FFA_NOTIFICATION_BITMAP_DESTROY,
>> +    FFA_PARTITION_INFO_GET,
>> +    FFA_NOTIFICATION_INFO_GET_64,
>> +    FFA_NOTIFICATION_GET,
>> +    FFA_RX_RELEASE,
>> +    FFA_RXTX_MAP_64,
>> +    FFA_RXTX_UNMAP,
>> +    FFA_MEM_SHARE_32,
>> +    FFA_MEM_SHARE_64,
>> +    FFA_MEM_RECLAIM,
>> +    FFA_MSG_SEND_DIRECT_REQ_32,
>> +    FFA_MSG_SEND_DIRECT_REQ_64,
>> +};
> 
> NIT: As we are creating an array, could be take the opportunity to provide a 
> name for each feature (we could use macro for that)? This would make easier 
> for the user to know which feature is missing.

In fact those are not "features" per say but ABI we need to use with the 
firmware so maybe i should first rename the variable to say abi instead of feat.

Now we could create some features out of those as in practice several ABIs are 
needed to be able to use one feature (for example notifications support require 
the INFO_GET and the GET).

In your mind you wanted to have something like:
"Version", FFA_VERSION
"Direct Messages", FFA_MSG_SEND_DIRECT_REQ_32,
"Direct Messages", FFA_MSG_SEND_DIRECT_REQ_64 

So that we could print a more meaningfull name or would you be ok with just 
printing "FFA_MSG_SEND_DIRECT_REQ_32" ?

> 
>>    /*
>>   * Our rx/tx buffers shared with the SPMC. FFA_RXTX_PAGE_COUNT is the
>> @@ -112,20 +130,9 @@ static bool ffa_get_version(uint32_t *vers)
>>      return true;
>>  }
>>  -static int32_t ffa_features(uint32_t id)
>> +static bool ffa_feature_supported(uint32_t id)
>>  {
>> -    return ffa_simple_call(FFA_FEATURES, id, 0, 0, 0);
>> -}
>> -
>> -static bool check_mandatory_feature(uint32_t id)
>> -{
>> -    int32_t ret = ffa_features(id);
>> -
>> -    if ( ret )
>> -        printk(XENLOG_ERR "ffa: mandatory feature id %#x missing: error 
>> %d\n",
>> -               id, ret);
>> -
>> -    return !ret;
>> +    return !ffa_simple_call(FFA_FEATURES, id, 0, 0, 0);
>>  }
>>    static void handle_version(struct cpu_user_regs *regs)
>> @@ -529,24 +536,6 @@ static bool ffa_probe(void)
>>          goto err_no_fw;
>>      }
>>  -    /*
>> -     * At the moment domains must support the same features used by Xen.
>> -     * TODO: Rework the code to allow domain to use a subset of the
>> -     * features supported.
>> -     */
> 
> You removed this TODO but I don't think it was addressed. Can you clarify?

Right this should only be removed with the next patch when we add fine
granular call support. I will readd it here and remove it in the fine granular 
patch.

> 
>> -    if ( !check_mandatory_feature(FFA_PARTITION_INFO_GET) ||
>> -         !check_mandatory_feature(FFA_RX_RELEASE) ||
>> -         !check_mandatory_feature(FFA_RXTX_MAP_64) ||
>> -         !check_mandatory_feature(FFA_MEM_SHARE_64) ||
>> -         !check_mandatory_feature(FFA_RXTX_UNMAP) ||
>> -         !check_mandatory_feature(FFA_MEM_SHARE_32) ||
>> -         !check_mandatory_feature(FFA_MEM_RECLAIM) ||
>> -         !check_mandatory_feature(FFA_MSG_SEND_DIRECT_REQ_32) )
>> -    {
>> -        printk(XENLOG_ERR "ffa: Mandatory feature not supported by fw\n");
>> -        goto err_no_fw;
>> -    }
>> -
>>      major_vers = (vers >> FFA_VERSION_MAJOR_SHIFT)
>>                   & FFA_VERSION_MAJOR_MASK;
>>      minor_vers = vers & FFA_VERSION_MINOR_MASK;
>> @@ -555,6 +544,16 @@ static bool ffa_probe(void)
>>        ffa_fw_version = vers;
>>  +    for ( int i = 0; i < ARRAY_SIZE(ffa_fw_feat_needed); i++ )
> 
> This is an index, so please use unsigned int (even though it should 
> technically be size_t).

Ack

> 
>> +    {
>> +        if ( !ffa_feature_supported(ffa_fw_feat_needed[i]) )
>> +        {
>> +            printk(XENLOG_INFO "ARM FF-A Firmware does not support 
>> 0x%08x\n",
>> +                   ffa_fw_feat_needed[i]);
>> +            goto err_no_fw;
>> +        }
>> +    }
>> +
>>      if ( !ffa_rxtx_init() )
>>      {
>>          printk(XENLOG_ERR "ffa: Error during RXTX buffer init\n");
> 
> Cheers,

Cheers
Bertrand

> 
> -- 
> Julien Grall





 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.