Message ID | 20240529072559.2486986-7-jens.wiklander@linaro.org (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | FF-A notifications | expand |
Hi Jens, > On 29 May 2024, at 09:25, Jens Wiklander <jens.wiklander@linaro.org> wrote: > > Add tee_free_domain_ctx() to the TEE mediator framework. > tee_free_domain_ctx() is called from arch_domain_destroy() to allow late > freeing of the d->arch.tee context. This will simplify access to > d->arch.tee for domains retrieved with rcu_lock_domain_by_id(). > > Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com> Cheers Bertrand > --- > xen/arch/arm/domain.c | 1 + > xen/arch/arm/include/asm/tee/tee.h | 6 ++++++ > xen/arch/arm/tee/tee.c | 6 ++++++ > 3 files changed, 13 insertions(+) > > diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c > index 34cbfe699a68..61e46a157ccc 100644 > --- a/xen/arch/arm/domain.c > +++ b/xen/arch/arm/domain.c > @@ -837,6 +837,7 @@ int arch_domain_teardown(struct domain *d) > > void arch_domain_destroy(struct domain *d) > { > + tee_free_domain_ctx(d); > /* IOMMU page table is shared with P2M, always call > * iommu_domain_destroy() before p2m_final_teardown(). > */ > diff --git a/xen/arch/arm/include/asm/tee/tee.h b/xen/arch/arm/include/asm/tee/tee.h > index eda8a8aa38f2..2e99a38184be 100644 > --- a/xen/arch/arm/include/asm/tee/tee.h > +++ b/xen/arch/arm/include/asm/tee/tee.h > @@ -38,6 +38,7 @@ struct tee_mediator_ops { > */ > int (*domain_init)(struct domain *d); > int (*domain_teardown)(struct domain *d); > + void (*free_domain_ctx)(struct domain *d); > > /* > * Called during domain destruction to relinquish resources used > @@ -70,6 +71,7 @@ int tee_domain_teardown(struct domain *d); > int tee_relinquish_resources(struct domain *d); > uint16_t tee_get_type(void); > void init_tee_interrupt(void); > +void tee_free_domain_ctx(struct domain *d); > > #define REGISTER_TEE_MEDIATOR(_name, _namestr, _type, _ops) \ > static const struct tee_mediator_desc __tee_desc_##_name __used \ > @@ -113,6 +115,10 @@ static inline void init_tee_interrupt(void) > { > } > > +static inline void tee_free_domain_ctx(struct domain *d) > +{ > +} > + > #endif /* CONFIG_TEE */ > > #endif /* __ARCH_ARM_TEE_TEE_H__ */ > diff --git a/xen/arch/arm/tee/tee.c b/xen/arch/arm/tee/tee.c > index 8117fd55123e..cb65f187f51f 100644 > --- a/xen/arch/arm/tee/tee.c > +++ b/xen/arch/arm/tee/tee.c > @@ -102,6 +102,12 @@ void __init init_tee_interrupt(void) > cur_mediator->ops->init_interrupt(); > } > > +void tee_free_domain_ctx(struct domain *d) > +{ > + if ( cur_mediator && cur_mediator->ops->free_domain_ctx) > + cur_mediator->ops->free_domain_ctx(d); > +} > + > /* > * Local variables: > * mode: C > -- > 2.34.1 >
diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index 34cbfe699a68..61e46a157ccc 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -837,6 +837,7 @@ int arch_domain_teardown(struct domain *d) void arch_domain_destroy(struct domain *d) { + tee_free_domain_ctx(d); /* IOMMU page table is shared with P2M, always call * iommu_domain_destroy() before p2m_final_teardown(). */ diff --git a/xen/arch/arm/include/asm/tee/tee.h b/xen/arch/arm/include/asm/tee/tee.h index eda8a8aa38f2..2e99a38184be 100644 --- a/xen/arch/arm/include/asm/tee/tee.h +++ b/xen/arch/arm/include/asm/tee/tee.h @@ -38,6 +38,7 @@ struct tee_mediator_ops { */ int (*domain_init)(struct domain *d); int (*domain_teardown)(struct domain *d); + void (*free_domain_ctx)(struct domain *d); /* * Called during domain destruction to relinquish resources used @@ -70,6 +71,7 @@ int tee_domain_teardown(struct domain *d); int tee_relinquish_resources(struct domain *d); uint16_t tee_get_type(void); void init_tee_interrupt(void); +void tee_free_domain_ctx(struct domain *d); #define REGISTER_TEE_MEDIATOR(_name, _namestr, _type, _ops) \ static const struct tee_mediator_desc __tee_desc_##_name __used \ @@ -113,6 +115,10 @@ static inline void init_tee_interrupt(void) { } +static inline void tee_free_domain_ctx(struct domain *d) +{ +} + #endif /* CONFIG_TEE */ #endif /* __ARCH_ARM_TEE_TEE_H__ */ diff --git a/xen/arch/arm/tee/tee.c b/xen/arch/arm/tee/tee.c index 8117fd55123e..cb65f187f51f 100644 --- a/xen/arch/arm/tee/tee.c +++ b/xen/arch/arm/tee/tee.c @@ -102,6 +102,12 @@ void __init init_tee_interrupt(void) cur_mediator->ops->init_interrupt(); } +void tee_free_domain_ctx(struct domain *d) +{ + if ( cur_mediator && cur_mediator->ops->free_domain_ctx) + cur_mediator->ops->free_domain_ctx(d); +} + /* * Local variables: * mode: C
Add tee_free_domain_ctx() to the TEE mediator framework. tee_free_domain_ctx() is called from arch_domain_destroy() to allow late freeing of the d->arch.tee context. This will simplify access to d->arch.tee for domains retrieved with rcu_lock_domain_by_id(). Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> --- xen/arch/arm/domain.c | 1 + xen/arch/arm/include/asm/tee/tee.h | 6 ++++++ xen/arch/arm/tee/tee.c | 6 ++++++ 3 files changed, 13 insertions(+)