Message ID | 20220607073031.722174-7-Penny.Zheng@arm.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | populate/unpopulate memory when domain on static allocation | expand |
On 07.06.2022 09:30, Penny Zheng wrote: > --- a/xen/arch/arm/domain_build.c > +++ b/xen/arch/arm/domain_build.c > @@ -3287,9 +3287,12 @@ void __init create_domUs(void) > if ( !dt_device_is_compatible(node, "xen,domain") ) > continue; > > + if ( dt_find_property(node, "xen,static-mem", NULL) ) > + flags |= CDF_staticmem; > + > if ( dt_property_read_bool(node, "direct-map") ) > { > - if ( !IS_ENABLED(CONFIG_STATIC_MEMORY) || !dt_find_property(node, "xen,static-mem", NULL) ) > + if ( !IS_ENABLED(CONFIG_STATIC_MEMORY) || !(flags & CDF_staticmem) ) > panic("direct-map is not valid for domain %s without static allocation.\n", > dt_node_name(node)); I think there's either a change needed elsewhere (which you may have in a later patch, but which would look to belong here) or you may want to deal right here with CDF_staticmem being invalid without STATIC_MEMORY: if ( IS_ENABLED(CONFIG_STATIC_MEMORY) && dt_find_property(node, "xen,static-mem", NULL) ) flags |= CDF_staticmem; if ( dt_property_read_bool(node, "direct-map") ) { if ( !(flags & CDF_staticmem) ) panic("direct-map is not valid for domain %s without static allocation.\n", dt_node_name(node)); Another option would seem to be /* Is domain memory on static allocation? */ #ifdef CONFIG_STATIC_MEMORY # define CDF_staticmem (1U << 2) #else # define CDF_staticmem 0 #endif in xen/domain.h (at which point no IS_ENABLED() would be needed anymore afaict). Jan
diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 7ddd16c26d..f6e2e44c1e 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -3287,9 +3287,12 @@ void __init create_domUs(void) if ( !dt_device_is_compatible(node, "xen,domain") ) continue; + if ( dt_find_property(node, "xen,static-mem", NULL) ) + flags |= CDF_staticmem; + if ( dt_property_read_bool(node, "direct-map") ) { - if ( !IS_ENABLED(CONFIG_STATIC_MEMORY) || !dt_find_property(node, "xen,static-mem", NULL) ) + if ( !IS_ENABLED(CONFIG_STATIC_MEMORY) || !(flags & CDF_staticmem) ) panic("direct-map is not valid for domain %s without static allocation.\n", dt_node_name(node)); diff --git a/xen/include/xen/domain.h b/xen/include/xen/domain.h index 1c3c88a14d..c847452414 100644 --- a/xen/include/xen/domain.h +++ b/xen/include/xen/domain.h @@ -34,6 +34,14 @@ void arch_get_domain_info(const struct domain *d, #ifdef CONFIG_ARM /* Should domain memory be directly mapped? */ #define CDF_directmap (1U << 1) +/* Is domain memory on static allocation? */ +#define CDF_staticmem (1U << 2) +#endif + +#ifdef CONFIG_STATIC_MEMORY +#define is_domain_using_staticmem(d) ((d)->cdf & CDF_staticmem) +#else +#define is_domain_using_staticmem(d) ((void)(d), false) #endif /*
In order to have an easy and quick way to find out whether this domain memory is statically configured, this commit introduces a new flag CDF_staticmem and a new helper is_domain_using_staticmem() to tell. Signed-off-by: Penny Zheng <penny.zheng@arm.com> --- v6 changes: - move non-zero is_domain_using_staticmem() from ARM header to common header --- v5 changes: - guard "is_domain_using_staticmem" under CONFIG_STATIC_MEMORY - #define is_domain_using_staticmem zero if undefined --- v4 changes: - no changes --- v3 changes: - change name from "is_domain_static()" to "is_domain_using_staticmem" --- v2 changes: - change name from "is_domain_on_static_allocation" to "is_domain_static()" --- xen/arch/arm/domain_build.c | 5 ++++- xen/include/xen/domain.h | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-)