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

Re: [PATCH 2/6] xen/arm: ffa: Track hypervisor notifications in a bitmap


  • To: Jens Wiklander <jens.wiklander@xxxxxxxxxx>
  • From: Bertrand Marquis <Bertrand.Marquis@xxxxxxx>
  • Date: Thu, 23 Apr 2026 10:26:59 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 4.158.2.129) smtp.rcpttodomain=linaro.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=ym//CaW/erLXxXdxEf2Fr+w18mQtRJ5/hELSNT4mQlQ=; b=CuFvbFDwrItR/Znb7qskw3iSKjzfgcCAhQU/w0pOFJ35FeoUKF9iXU5+e4Jg7xX/YpfGQNTCuetmvsr08t9w7cqlKFuK57/f+ZadZ2so15Cib1jACJys6mpk+B58imorjtKNYSuvvf6jwqhMUKFp7PRb24A2VuksqpOmM/XcJJVg5NyfnwmyooB3HVAKLPtoP3YtEtoORMbZ/GO+L9OtseMxYeOGuNHtXpfQA7WfEgMHp4LtBxV8R8mJMiXlg36ZjQ5bqyW6CrvKpNMULn0z3u4TFlHpUFCYNsk2IB4+a2z3A04xTaCvBkMNAOOGjrtgVQO2ElNGE89hs3eFdlaEOQ==
  • 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=ym//CaW/erLXxXdxEf2Fr+w18mQtRJ5/hELSNT4mQlQ=; b=JGMIu/Yf+iHDQSTebQxPJTo2NqefHd/MHgqcRS1pMG9+EfBhryDJjY4f7sLlwwURDdHa/+5JdzE2NP8uPePwAIjLv05sq7H1nJ+M8fHMkns96BjnD/MMrKhUZ46iXRW1YyZe4IWn19fN71RH6CL0XjgPWQBkcmQYlW/SB3FWQNx3gMeJUnu82Dsg3MB55RQXsgnLKUdGeGWkP7oUO2OsfFaMs1fdEoeFljGwKlaDhUTDJ3hpzm71ug5rPXEnZoA18etSLd926EC+1c02omVCDq13m0X5iyCZHkABMfmCypZeLidV45lMbb+ilIzsVi4g9+Go+r+lon1jzsPe7jrRfg==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=sk3D0NgDEgGsW2OLKA0vhrSiFVvA3Bgs1z3zRuyeeWadpBwuTUO3/509jMPd4+Ic3DQKatJJoXM7Y5W1w1NZIonrtT+arrSmcPVCASL1Eu6gkRWfbWz/hgA7D6Lg42uz43pNo1KYlxM5fhSvnMFipFg4W6+1wFJlyPTdVyfd01WQ/CSmbgYwb/oK9Kl4ecQzYQaegKQaGa5sXsoykmQLK0i8f9WFpwC50I/SqPh0qTwFXoQqvEtmvIcmTcFZtzacXD2Vk3K4t8r8MqgxLL2X4J2gB8u1ssovMeUq19ZHuseFog09MJ6egdr1OwL9RjhcoaQs1QPVrnFv3km3gUXdgQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=MeED73EHX9bXepXp5TRLrMDHMXQFHu2eRrWMwHjKlY32cYKONRnKCdkFMqr7FwsYSCLI1NUt6p3ws2RqXmbj6ZFRmfucx2SFJgWIlEDabh8lI4LN6nWCOs6MdTCHGJJu1hVKG9Swjy0Zei4/MzZkrTWr9T7bLuLEqPdvb/FB0OaKzD5KWGHSdNRVnYpoOnxP3lSeteAx/wtnWtrq5azK2mlVm4EHK0fb3pTtdW1R0LNKUEb1w4RVeP4ghfs358NEXunSn87FCx2zSQ/+W0t5VkP4E1SYFc3P3I5EqxPcEGM8lSzdOSG+GWFMno/NCTH4+mbJBaOKpbb3s6Hkjls5NQ==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=arm.com header.i="@arm.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"; dkim=pass header.s=selector1 header.d=arm.com header.i="@arm.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Volodymyr Babchuk <volodymyr_babchuk@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>
  • Delivery-date: Thu, 23 Apr 2026 10:28:19 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Thread-index: AQHcznAWfT9UE3mepUCzg5x2vENfULXq2YyAgAFvNoCAACc9gIAACoOA
  • Thread-topic: [PATCH 2/6] xen/arm: ffa: Track hypervisor notifications in a bitmap

Hi Jens,

> On 23 Apr 2026, at 11:49, Jens Wiklander <jens.wiklander@xxxxxxxxxx> wrote:
> 
> Hi Bertrand,
> 
> On Thu, Apr 23, 2026 at 9:30 AM Bertrand Marquis
> <Bertrand.Marquis@xxxxxxx> wrote:
>> 
>> Hi Jens,
>> 
>> Thanks a lot for the review.
>> 
>>> On 22 Apr 2026, at 11:34, Jens Wiklander <jens.wiklander@xxxxxxxxxx> wrote:
>>> 
>>> Hi Bertrand,
>>> 
>>> On Fri, Apr 17, 2026 at 3:41 PM Bertrand Marquis
>>> <bertrand.marquis@xxxxxxx> wrote:
>>>> 
>>>> Hypervisor notifications are currently tracked with a dedicated
>>>> buff_full_pending boolean. That state only represents a single HYP
>>>> notification bit and keeps HYP bitmap handling tied to single-purpose
>>>> bookkeeping.
>>>> 
>>>> Replace the boolean with a hypervisor notification bitmap protected by
>>>> notif_lock. INFO_GET reports pending when the bitmap is non-zero, GET
>>>> returns and clears the HYP bitmap under the lock, and RX-buffer-full
>>>> sets FFA_NOTIF_RX_BUFFER_FULL in the bitmap instead of updating
>>>> separate state.
>>>> 
>>>> Initialize and clear the bitmap during domain lifecycle handling, and
>>>> use ctx->ffa_id for bitmap create and destroy so the notification state
>>>> stays tied to the cached FF-A endpoint ID.
>>>> 
>>>> No functional changes.
>>>> 
>>>> Signed-off-by: Bertrand Marquis <bertrand.marquis@xxxxxxx>
>>>> ---
>>>> xen/arch/arm/tee/ffa_notif.c   | 46 ++++++++++++++++++++++++++--------
>>>> xen/arch/arm/tee/ffa_private.h |  9 +++++--
>>>> 2 files changed, 43 insertions(+), 12 deletions(-)
>>>> 
>>>> diff --git a/xen/arch/arm/tee/ffa_notif.c b/xen/arch/arm/tee/ffa_notif.c
>>>> index 07bc5cb3a430..d15119409a25 100644
>>>> --- a/xen/arch/arm/tee/ffa_notif.c
>>>> +++ b/xen/arch/arm/tee/ffa_notif.c
>>>> @@ -94,8 +94,15 @@ void ffa_handle_notification_info_get(struct 
>>>> cpu_user_regs *regs)
>>>> 
>>>>    notif_pending = test_and_clear_bool(ctx->notif.secure_pending);
>>>>    if ( IS_ENABLED(CONFIG_FFA_VM_TO_VM) )
>>>> +    {
>>>>        notif_pending |= test_and_clear_bool(ctx->notif.vm_pending);
>>>> 
>>>> +        spin_lock(&ctx->notif.notif_lock);
>>>> +        if ( ctx->notif.hyp_pending )
>>>> +            notif_pending = true;
>>>> +        spin_unlock(&ctx->notif.notif_lock);
>>> 
>>> Isn't this a functional change? Before this patch, we didn't consider
>>> ctx->notif.buff_full_pending here. Am I missing something?
>> 
>> We did consider it implicitly through vm_pending.
>> 
>> This patch makes that cleaner by using hyp_pending for the Hypervisor
>> framework notification itself. Previously, RX-buffer-full was made visible
>> indirectly via vm_pending, and FFA_NOTIFICATION_INFO_GET
>> cleared that summary state.
>> 
>> As a result, the guest-visible pending indication could be lost before
>> the Hypervisor notification was actually retrieved with
>> FFA_NOTIFICATION_GET.
>> 
>> With this change, the pending state is tracked in hyp_pending and is only
>> cleared when the Hypervisor notifications are retrieved through
>> FFA_NOTIFICATION_GET.
>> 
>> I will reword the commit message to make that clearer.
> 
> Thanks
> 
>> 
>>> 
>>>> +    }
>>>> +
>>>>    if ( notif_pending )
>>>>    {
>>>>        /* A pending global notification for the guest */
>>>> @@ -174,12 +181,17 @@ void ffa_handle_notification_get(struct 
>>>> cpu_user_regs *regs)
>>>>            w6 = resp.a6;
>>>>    }
>>>> 
>>>> -    if ( IS_ENABLED(CONFIG_FFA_VM_TO_VM) &&
>>>> -          flags & FFA_NOTIF_FLAG_BITMAP_HYP &&
>>>> -          test_and_clear_bool(ctx->notif.buff_full_pending) )
>>>> +    if ( IS_ENABLED(CONFIG_FFA_VM_TO_VM) )
>>>>    {
>>>> -        ACCESS_ONCE(ctx->notif.vm_pending) = false;
>>>> -        w7 = FFA_NOTIF_RX_BUFFER_FULL;
>>>> +        spin_lock(&ctx->notif.notif_lock);
>>>> +
>>>> +        if ( (flags & FFA_NOTIF_FLAG_BITMAP_HYP) && 
>>>> ctx->notif.hyp_pending )
>>>> +        {
>>>> +            w7 = ctx->notif.hyp_pending;
>>>> +            ctx->notif.hyp_pending = 0;
>>>> +        }
>>>> +
>>>> +        spin_unlock(&ctx->notif.notif_lock);
>>>>    }
>>>> 
>>>>    ffa_set_regs(regs, FFA_SUCCESS_32, 0, w2, w3, w4, w5, w6, w7);
>>>> @@ -207,12 +219,17 @@ int32_t ffa_handle_notification_set(struct 
>>>> cpu_user_regs *regs)
>>>> void ffa_raise_rx_buffer_full(struct domain *d)
>>>> {
>>>>    struct ffa_ctx *ctx = d->arch.tee;
>>>> +    uint32_t prev_bitmap;
>>>> 
>>>>    if ( !ctx )
>>>>        return;
>>>> 
>>>> -    ACCESS_ONCE(ctx->notif.buff_full_pending) = true;
>>>> -    if ( !test_and_set_bool(ctx->notif.vm_pending) )
>>>> +    spin_lock(&ctx->notif.notif_lock);
>>>> +    prev_bitmap = ctx->notif.hyp_pending;
>>>> +    ctx->notif.hyp_pending |= FFA_NOTIF_RX_BUFFER_FULL;
>>>> +    spin_unlock(&ctx->notif.notif_lock);
>>>> +
>>>> +    if ( !(prev_bitmap & FFA_NOTIF_RX_BUFFER_FULL) )
>>> 
>>> Do we need to check for FFA_NOTIF_RX_BUFFER_FULL? Isn't !prev_bitmap
>>> more accurate, if any other bit would ever be used in the bitmap?
>> 
>>  I would keep the bit-specific check here, if that is OK with you.
>> 
>> This function is about raising the RX buffer full notification,
>> so I think it is clearer to check whether that bit was newly
>> pended rather than whether the whole Hypervisor bitmap
>> was previously empty.
>> 
>> Using !prev_bitmap would also make the condition depend on
>> unrelated Hypervisor notifications being pending.
>> 
>> Tell me if you are ok with that.
> 
> I see your point, it's fine.

In fact while working on this i ended up in something a bit more generic
due to your patch 6 findings and at the end i do not raise depending on
prev_bitmap anymore but just on if a notification was raised already or
not since something was changed which does not depend on hyp_pending
anymore.

I am working on v2, might be more clear then :-)

Cheers
Bertrand

> 
> Cheers,
> Jens
> 
>> 
>> Cheers
>> Bertrand



 


Rackspace

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