[PATCH][for-4.21] xen/arm: Reorder SCI resource cleanup in domain destruction

Oleksii Moisieiev posted 1 patch 17 hours ago
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/164651d0662e674002ed17399300c3a25e6dcbfc.1757757602.git.oleksii._5Fmoisieiev@epam.com
xen/arch/arm/domain.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
[PATCH][for-4.21] xen/arm: Reorder SCI resource cleanup in domain destruction
Posted by Oleksii Moisieiev 17 hours ago
Move the SCI (System Control and Management Interface) resource cleanup
earlier in the domain_relinquish_resources() sequence to ensure proper
cleanup ordering during domain destruction.

The SCI cleanup is now performed before TEE (Trusted Execution Environment)
cleanup rather than after P2M mapping cleanup. This reordering ensures that
SCI resources are properly released before other subsystems that might
depend on them are torn down.

This change addresses potential resource cleanup dependencies where SCI
resources need to be released before P2M mappings are cleaned up, preventing
potential issues during domain destruction on ARM platforms with SCI support.

Signed-off-by: Oleksii Moisieiev <oleksii_moisieiev@epam.com>
---

 xen/arch/arm/domain.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
index 1a8585d02b..0ac381a5a5 100644
--- a/xen/arch/arm/domain.c
+++ b/xen/arch/arm/domain.c
@@ -1090,6 +1090,11 @@ int domain_relinquish_resources(struct domain *d)
             return ret;
 #endif
 
+    PROGRESS(sci):
+        ret = sci_relinquish_resources(d);
+        if ( ret )
+            return ret;
+
     PROGRESS(tee):
         ret = tee_relinquish_resources(d);
         if (ret )
@@ -1109,10 +1114,6 @@ int domain_relinquish_resources(struct domain *d)
         ret = relinquish_p2m_mapping(d);
         if ( ret )
             return ret;
-    PROGRESS(sci):
-        ret = sci_relinquish_resources(d);
-        if ( ret )
-            return ret;
 
     PROGRESS(p2m_root):
         /*
-- 
2.34.1
Re: [PATCH][for-4.21] xen/arm: Reorder SCI resource cleanup in domain destruction
Posted by Oleksandr Tyshchenko 13 hours ago
On Sat, Sep 13, 2025 at 1:31 PM Oleksii Moisieiev <
Oleksii_Moisieiev@epam.com> wrote:

Hello Oleksii

Move the SCI (System Control and Management Interface) resource cleanup
> earlier in the domain_relinquish_resources() sequence to ensure proper
> cleanup ordering during domain destruction.
>
> The SCI cleanup is now performed before TEE (Trusted Execution Environment)
> cleanup rather than after P2M mapping cleanup. This reordering ensures that
> SCI resources are properly released before other subsystems that might
> depend on them are torn down.
>
> This change addresses potential resource cleanup dependencies where SCI
> resources need to be released before P2M mappings are cleaned up,
> preventing
> potential issues during domain destruction on ARM platforms with SCI
> support.
>
> Signed-off-by: Oleksii Moisieiev <oleksii_moisieiev@epam.com>
> ---
>
>  xen/arch/arm/domain.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
> index 1a8585d02b..0ac381a5a5 100644
> --- a/xen/arch/arm/domain.c
> +++ b/xen/arch/arm/domain.c
> @@ -1090,6 +1090,11 @@ int domain_relinquish_resources(struct domain *d)
>              return ret;
>  #endif
>

There is an enum above (not visible in context)

enum {
     PROG_pci = 1,
     PROG_tee,
     PROG_xen,
     PROG_page,
     PROG_mapping,
     PROG_p2m_root,
     PROG_p2m,
     PROG_p2m_pool,
     PROG_sci,
     PROG_done,
};

I am sorry, but shouldn't PROG_sci location there reflect to where you now
put PROGRESS(sci)
(I mean above PROG_tee)?



> +    PROGRESS(sci):
> +        ret = sci_relinquish_resources(d);
> +        if ( ret )
> +            return ret;
> +
>      PROGRESS(tee):
>          ret = tee_relinquish_resources(d);
>          if (ret )
> @@ -1109,10 +1114,6 @@ int domain_relinquish_resources(struct domain *d)
>          ret = relinquish_p2m_mapping(d);
>          if ( ret )
>              return ret;
> -    PROGRESS(sci):
> -        ret = sci_relinquish_resources(d);
> -        if ( ret )
> -            return ret;
>
>      PROGRESS(p2m_root):
>          /*
> --
> 2.34.1
>
>

-- 
Regards,

Oleksandr Tyshchenko
Re: [PATCH][for-4.21] xen/arm: Reorder SCI resource cleanup in domain destruction
Posted by Andrew Cooper 12 hours ago
On 13/09/2025 3:07 pm, Oleksandr Tyshchenko wrote:
>
>
> On Sat, Sep 13, 2025 at 1:31 PM Oleksii Moisieiev
> <Oleksii_Moisieiev@epam.com> wrote:
>
> Hello Oleksii
>
>     Move the SCI (System Control and Management Interface) resource
>     cleanup
>     earlier in the domain_relinquish_resources() sequence to ensure proper
>     cleanup ordering during domain destruction.
>
>     The SCI cleanup is now performed before TEE (Trusted Execution
>     Environment)
>     cleanup rather than after P2M mapping cleanup. This reordering
>     ensures that
>     SCI resources are properly released before other subsystems that might
>     depend on them are torn down.
>
>     This change addresses potential resource cleanup dependencies
>     where SCI
>     resources need to be released before P2M mappings are cleaned up,
>     preventing
>     potential issues during domain destruction on ARM platforms with
>     SCI support.
>
>     Signed-off-by: Oleksii Moisieiev <oleksii_moisieiev@epam.com>
>     ---
>
>      xen/arch/arm/domain.c | 9 +++++----
>      1 file changed, 5 insertions(+), 4 deletions(-)
>
>     diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
>     index 1a8585d02b..0ac381a5a5 100644
>     --- a/xen/arch/arm/domain.c
>     +++ b/xen/arch/arm/domain.c
>     @@ -1090,6 +1090,11 @@ int domain_relinquish_resources(struct
>     domain *d)
>                  return ret;
>      #endif
>
>
> There is an enum above (not visible in context)
>
> enum {
>      PROG_pci = 1,
>      PROG_tee,
>      PROG_xen,
>      PROG_page,
>      PROG_mapping,
>      PROG_p2m_root,
>      PROG_p2m,
>      PROG_p2m_pool,
>      PROG_sci,
>      PROG_done,
> };
>
> I am sorry, but shouldn't PROG_sci location there reflect to where you
> now put PROGRESS(sci)
> (I mean above PROG_tee)?

The enumeration can be in any order.  All they're actually doing is
encoding which case label to use next time.

But, for people's sanity following the logic, they ought to be kept in
order.

~Andrew