diff mbox series

[v8,6/9] xen/arm: introduce CDF_staticmem

Message ID 20220707092244.485936-7-Penny.Zheng@arm.com (mailing list archive)
State Superseded
Headers show
Series populate/unpopulate memory when domain on static allocation | expand

Commit Message

Penny Zheng July 7, 2022, 9:22 a.m. UTC
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>
---
v8 changes:
- #ifdef-ary around is_domain_using_staticmem() is not needed anymore
---
v7 changes:
- IS_ENABLED(CONFIG_STATIC_MEMORY) would not be needed anymore
---
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(-)

Comments

Jan Beulich July 7, 2022, 11:05 a.m. UTC | #1
On 07.07.2022 11:22, Penny Zheng wrote:
> 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>

Acked-by: Jan Beulich <jbeulich@suse.com>
Julien Grall July 15, 2022, 6:51 p.m. UTC | #2
Hi Penny,

On 07/07/2022 10:22, Penny Zheng wrote:
> 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>
> ---
> v8 changes:
> - #ifdef-ary around is_domain_using_staticmem() is not needed anymore
> ---
> v7 changes:
> - IS_ENABLED(CONFIG_STATIC_MEMORY) would not be needed anymore
> ---
> 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(-)
> 
> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
> index 3fd1186b53..b76a84e8f5 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) )

It is not clear to me why dropping IS_ENABLED(...) here is fine. What 
would happen if a user specify "xen,static-mem" in the device-tree but 
forgot CONFIG_STATIC_MEMORY in Xen?

Cheers,
Julien Grall July 15, 2022, 6:55 p.m. UTC | #3
On 15/07/2022 19:51, Julien Grall wrote:
> Hi Penny,
> 
> On 07/07/2022 10:22, Penny Zheng wrote:
>> 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>
>> ---
>> v8 changes:
>> - #ifdef-ary around is_domain_using_staticmem() is not needed anymore
>> ---
>> v7 changes:
>> - IS_ENABLED(CONFIG_STATIC_MEMORY) would not be needed anymore
>> ---
>> 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(-)
>>
>> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
>> index 3fd1186b53..b76a84e8f5 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) )
> 
> It is not clear to me why dropping IS_ENABLED(...) here is fine. What 
> would happen if a user specify "xen,static-mem" in the device-tree but 
> forgot CONFIG_STATIC_MEMORY in Xen?

Nvm... flags & CDF_staticmem would be 0 so it would cover that case. 
Sorry for the noise.

Acked-by: Julien Grall <jgrall@amazon.com>


Cheers,
diff mbox series

Patch

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 3fd1186b53..b76a84e8f5 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 ( !(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 628b14b086..2c8116afba 100644
--- a/xen/include/xen/domain.h
+++ b/xen/include/xen/domain.h
@@ -35,6 +35,14 @@  void arch_get_domain_info(const struct domain *d,
 /* Should domain memory be directly mapped? */
 #define CDF_directmap            (1U << 1)
 #endif
+/* Is domain memory on static allocation? */
+#ifdef CONFIG_STATIC_MEMORY
+#define CDF_staticmem            (1U << 2)
+#else
+#define CDF_staticmem            0
+#endif
+
+#define is_domain_using_staticmem(d) ((d)->cdf & CDF_staticmem)
 
 /*
  * Arch-specifics.