[PATCH v3 5/5] arm/dom0less: introduce Kconfig for dom0less feature

Luca Fancellu posted 5 patches 1 year ago
There is a newer version of this series
[PATCH v3 5/5] arm/dom0less: introduce Kconfig for dom0less feature
Posted by Luca Fancellu 1 year ago
Introduce a Kconfig for the dom0less feature, enabled by default,
to be able to choose if the feature should be compiled or not.

Provide static inline stubs when the option is disabled for the
functions externally visible.

Use the new Kconfig to remove dom0less DT binding from the efi-boot.h
code when the Kconfig is not enabled, do the same for
allocate_bank_memory inside domain_build.c that currently is used
only by dom0less-build.c module, but it's kept there provisioning
its usage by dom0 code.

Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
---
Changes from v2:
 - protect allocate_bank_memory with the new Kconfig
---
 xen/arch/arm/Kconfig                      |  9 +++++++++
 xen/arch/arm/Makefile                     |  2 +-
 xen/arch/arm/domain_build.c               |  2 ++
 xen/arch/arm/efi/efi-boot.h               |  4 ++++
 xen/arch/arm/include/asm/dom0less-build.h | 12 ++++++++++++
 xen/arch/arm/include/asm/domain_build.h   |  2 ++
 6 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig
index 0045a3762d86..0399f2faf734 100644
--- a/xen/arch/arm/Kconfig
+++ b/xen/arch/arm/Kconfig
@@ -88,6 +88,15 @@ config GICV2
 	  Driver for the ARM Generic Interrupt Controller v2.
 	  If unsure, say Y
 
+config DOM0LESS_BOOT
+	bool "Dom0less boot support" if EXPERT
+	depends on ARM
+	default y
+	help
+	  Dom0less boot support enables Xen to create and start domU guests during
+	  Xen boot without the need of a control domain (Dom0), which could be
+	  present anyway.
+
 config GICV3
 	bool "GICv3 driver"
 	depends on !NEW_VGIC
diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile
index 89ef0c9075b5..5daf8f10114d 100644
--- a/xen/arch/arm/Makefile
+++ b/xen/arch/arm/Makefile
@@ -15,7 +15,7 @@ obj-y += cpufeature.o
 obj-y += decode.o
 obj-y += device.o
 obj-$(CONFIG_IOREQ_SERVER) += dm.o
-obj-y += dom0less-build.init.o
+obj-$(CONFIG_DOM0LESS_BOOT) += dom0less-build.init.o
 obj-y += domain.o
 obj-y += domain_build.init.o
 obj-$(CONFIG_ARCH_MAP_DOMAIN_PAGE) += domain_page.o
diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index c2c17f075450..87eade449006 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -415,6 +415,7 @@ static void __init allocate_memory_11(struct domain *d,
     }
 }
 
+#ifdef CONFIG_DOM0LESS_BOOT
 bool __init allocate_bank_memory(struct domain *d, struct kernel_info *kinfo,
                                  gfn_t sgfn, paddr_t tot_size)
 {
@@ -476,6 +477,7 @@ bool __init allocate_bank_memory(struct domain *d, struct kernel_info *kinfo,
 
     return true;
 }
+#endif
 
 /*
  * When PCI passthrough is available we want to keep the
diff --git a/xen/arch/arm/efi/efi-boot.h b/xen/arch/arm/efi/efi-boot.h
index 1c3640bb65fd..689dc016d081 100644
--- a/xen/arch/arm/efi/efi-boot.h
+++ b/xen/arch/arm/efi/efi-boot.h
@@ -802,6 +802,7 @@ static int __init handle_module_node(const EFI_LOADED_IMAGE *loaded_image,
     return 1;
 }
 
+#ifdef CONFIG_DOM0LESS_BOOT
 /*
  * This function checks for boot modules under the domU guest domain node
  * in the DT.
@@ -849,6 +850,7 @@ static int __init handle_dom0less_domain_node(const EFI_LOADED_IMAGE *loaded_ima
 
     return mb_modules_found;
 }
+#endif
 
 /*
  * This function checks for xen domain nodes under the /chosen node for possible
@@ -876,6 +878,7 @@ static int __init efi_check_dt_boot(const EFI_LOADED_IMAGE *loaded_image)
     {
         int ret;
 
+#ifdef CONFIG_DOM0LESS_BOOT
         if ( !fdt_node_check_compatible(fdt_efi, node, "xen,domain") )
         {
             /* Found a node with compatible xen,domain; handle this node. */
@@ -884,6 +887,7 @@ static int __init efi_check_dt_boot(const EFI_LOADED_IMAGE *loaded_image)
                 return ERROR_DT_MODULE_DOMU;
         }
         else
+#endif
         {
             ret = handle_module_node(loaded_image, &dir_handle, node, addr_len,
                                      size_len, false);
diff --git a/xen/arch/arm/include/asm/dom0less-build.h b/xen/arch/arm/include/asm/dom0less-build.h
index d95cb6234b62..859944eece16 100644
--- a/xen/arch/arm/include/asm/dom0less-build.h
+++ b/xen/arch/arm/include/asm/dom0less-build.h
@@ -8,9 +8,21 @@
 #ifndef __ARM_DOM0LESS_BUILD_H_
 #define __ARM_DOM0LESS_BUILD_H_
 
+#ifdef CONFIG_DOM0LESS_BOOT
+
 void create_domUs(void);
 bool is_dom0less_mode(void);
 
+#else  /* !CONFIG_DOM0LESS_BOOT */
+
+static inline void create_domUs(void) {}
+static inline bool is_dom0less_mode(void)
+{
+    return false;
+}
+
+#endif /* CONFIG_DOM0LESS_BOOT */
+
 #endif  /* __ARM_DOM0LESS_BUILD_H_ */
 
 /*
diff --git a/xen/arch/arm/include/asm/domain_build.h b/xen/arch/arm/include/asm/domain_build.h
index 13118b5ff956..3950f0276e55 100644
--- a/xen/arch/arm/include/asm/domain_build.h
+++ b/xen/arch/arm/include/asm/domain_build.h
@@ -6,8 +6,10 @@
 
 typedef __be32 gic_interrupt_t[3];
 
+#ifdef CONFIG_DOM0LESS_BOOT
 bool allocate_bank_memory(struct domain *d, struct kernel_info *kinfo,
                           gfn_t sgfn, paddr_t tot_size);
+#endif
 int construct_domain(struct domain *d, struct kernel_info *kinfo);
 int domain_fdt_begin_node(void *fdt, const char *name, uint64_t unit);
 int make_resv_memory_node(const struct domain *d, void *fdt, int addrcells,
-- 
2.34.1
Re: [PATCH v3 5/5] arm/dom0less: introduce Kconfig for dom0less feature
Posted by Michal Orzel 1 year ago
Hi Luca,

On 09/11/2023 10:06, Luca Fancellu wrote:
> 
> 
> Introduce a Kconfig for the dom0less feature, enabled by default,
> to be able to choose if the feature should be compiled or not.
> 
> Provide static inline stubs when the option is disabled for the
> functions externally visible.
> 
> Use the new Kconfig to remove dom0less DT binding from the efi-boot.h
> code when the Kconfig is not enabled, do the same for
> allocate_bank_memory inside domain_build.c that currently is used
> only by dom0less-build.c module, but it's kept there provisioning
> its usage by dom0 code.
> 
> Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
> ---
> Changes from v2:
>  - protect allocate_bank_memory with the new Kconfig
> ---
>  xen/arch/arm/Kconfig                      |  9 +++++++++
>  xen/arch/arm/Makefile                     |  2 +-
>  xen/arch/arm/domain_build.c               |  2 ++
>  xen/arch/arm/efi/efi-boot.h               |  4 ++++
>  xen/arch/arm/include/asm/dom0less-build.h | 12 ++++++++++++
>  xen/arch/arm/include/asm/domain_build.h   |  2 ++
>  6 files changed, 30 insertions(+), 1 deletion(-)
> 
> diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig
> index 0045a3762d86..0399f2faf734 100644
> --- a/xen/arch/arm/Kconfig
> +++ b/xen/arch/arm/Kconfig
> @@ -88,6 +88,15 @@ config GICV2
>           Driver for the ARM Generic Interrupt Controller v2.
>           If unsure, say Y
> 
> +config DOM0LESS_BOOT
> +       bool "Dom0less boot support" if EXPERT
> +       depends on ARM
You're in the Arm Kconfig, so there should be no need for this dependency (it is implicit).

Apart from that, we have 2 features: static mem and static shmem that are only meant for dom0less domUs.
Shouldn't we make them dependent on DOM0LESS_BOOT? Otherwise, what is the purpose of selecting them
with DOM0LESS_BOOT=n?

~Michal
Re: [PATCH v3 5/5] arm/dom0less: introduce Kconfig for dom0less feature
Posted by Luca Fancellu 1 year ago
Hi Michal,

>> 
>> +config DOM0LESS_BOOT
>> +       bool "Dom0less boot support" if EXPERT
>> +       depends on ARM
> You're in the Arm Kconfig, so there should be no need for this dependency (it is implicit).
> 
> Apart from that, we have 2 features: static mem and static shmem that are only meant for dom0less domUs.
> Shouldn't we make them dependent on DOM0LESS_BOOT? Otherwise, what is the purpose of selecting them
> with DOM0LESS_BOOT=n?

Sure, I’ll add the dependencies and remove the ARM one

> 
> ~Michal

Re: [PATCH v3 5/5] arm/dom0less: introduce Kconfig for dom0less feature
Posted by Luca Fancellu 1 year ago

> On 10 Nov 2023, at 09:05, Luca Fancellu <Luca.Fancellu@arm.com> wrote:
> 
> Hi Michal,
> 
>>> 
>>> +config DOM0LESS_BOOT
>>> +       bool "Dom0less boot support" if EXPERT
>>> +       depends on ARM
>> You're in the Arm Kconfig, so there should be no need for this dependency (it is implicit).
>> 
>> Apart from that, we have 2 features: static mem and static shmem that are only meant for dom0less domUs.
>> Shouldn't we make them dependent on DOM0LESS_BOOT? Otherwise, what is the purpose of selecting them
>> with DOM0LESS_BOOT=n?
> 
> Sure, I’ll add the dependencies and remove the ARM one

Just to be sure, is it what you are asking?

diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig
index 0399f2faf734..d9c5340ff3a2 100644
--- a/xen/arch/arm/Kconfig
+++ b/xen/arch/arm/Kconfig
@@ -90,7 +90,6 @@ config GICV2
 
 config DOM0LESS_BOOT
        bool "Dom0less boot support" if EXPERT
-       depends on ARM
        default y
        help
          Dom0less boot support enables Xen to create and start domU guests during
@@ -214,7 +213,7 @@ source "arch/arm/tee/Kconfig"
 
 config STATIC_SHM
        bool "Statically shared memory on a dom0less system" if UNSUPPORTED
-       depends on STATIC_MEMORY
+       depends on STATIC_MEMORY && DOM0LESS_BOOT
        help
          This option enables statically shared memory on a dom0less system.
 
diff --git a/xen/common/Kconfig b/xen/common/Kconfig
index 4d6fe051641d..e0e5f4485d1f 100644
--- a/xen/common/Kconfig
+++ b/xen/common/Kconfig
@@ -100,7 +100,7 @@ config NUMA
 
 config STATIC_MEMORY
        bool "Static Allocation Support (UNSUPPORTED)" if UNSUPPORTED
-       depends on ARM
+       depends on ARM && DOM0LESS_BOOT
        help
          Static Allocation refers to system or sub-system(domains) for
          which memory areas are pre-defined by configuration using physical


Re: [PATCH v3 5/5] arm/dom0less: introduce Kconfig for dom0less feature
Posted by Michal Orzel 1 year ago
Hi,

On 10/11/2023 10:30, Luca Fancellu wrote:
> 
> 
>> On 10 Nov 2023, at 09:05, Luca Fancellu <Luca.Fancellu@arm.com> wrote:
>>
>> Hi Michal,
>>
>>>>
>>>> +config DOM0LESS_BOOT
>>>> +       bool "Dom0less boot support" if EXPERT
>>>> +       depends on ARM
>>> You're in the Arm Kconfig, so there should be no need for this dependency (it is implicit).
>>>
>>> Apart from that, we have 2 features: static mem and static shmem that are only meant for dom0less domUs.
>>> Shouldn't we make them dependent on DOM0LESS_BOOT? Otherwise, what is the purpose of selecting them
>>> with DOM0LESS_BOOT=n?
>>
>> Sure, I’ll add the dependencies and remove the ARM one
> 
> Just to be sure, is it what you are asking?
See below

> 
> diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig
> index 0399f2faf734..d9c5340ff3a2 100644
> --- a/xen/arch/arm/Kconfig
> +++ b/xen/arch/arm/Kconfig
> @@ -90,7 +90,6 @@ config GICV2
> 
>  config DOM0LESS_BOOT
>         bool "Dom0less boot support" if EXPERT
> -       depends on ARM
>         default y
>         help
>           Dom0less boot support enables Xen to create and start domU guests during
> @@ -214,7 +213,7 @@ source "arch/arm/tee/Kconfig"
> 
>  config STATIC_SHM
>         bool "Statically shared memory on a dom0less system" if UNSUPPORTED
> -       depends on STATIC_MEMORY
> +       depends on STATIC_MEMORY && DOM0LESS_BOOT
no need for && DOM0LESS_BOOT

>         help
>           This option enables statically shared memory on a dom0less system.
> 
> diff --git a/xen/common/Kconfig b/xen/common/Kconfig
> index 4d6fe051641d..e0e5f4485d1f 100644
> --- a/xen/common/Kconfig
> +++ b/xen/common/Kconfig
> @@ -100,7 +100,7 @@ config NUMA
> 
>  config STATIC_MEMORY
>         bool "Static Allocation Support (UNSUPPORTED)" if UNSUPPORTED
> -       depends on ARM
> +       depends on ARM && DOM0LESS_BOOT
no need for ARM. DOM0LESS_BOOT already depends on ARM.

~Michal


Re: [PATCH v3 5/5] arm/dom0less: introduce Kconfig for dom0less feature
Posted by Luca Fancellu 1 year ago

> On 10 Nov 2023, at 09:38, Michal Orzel <michal.orzel@amd.com> wrote:
> 
> Hi,
> 
> On 10/11/2023 10:30, Luca Fancellu wrote:
>> 
>> 
>>> On 10 Nov 2023, at 09:05, Luca Fancellu <Luca.Fancellu@arm.com> wrote:
>>> 
>>> Hi Michal,
>>> 
>>>>> 
>>>>> +config DOM0LESS_BOOT
>>>>> +       bool "Dom0less boot support" if EXPERT
>>>>> +       depends on ARM
>>>> You're in the Arm Kconfig, so there should be no need for this dependency (it is implicit).
>>>> 
>>>> Apart from that, we have 2 features: static mem and static shmem that are only meant for dom0less domUs.
>>>> Shouldn't we make them dependent on DOM0LESS_BOOT? Otherwise, what is the purpose of selecting them
>>>> with DOM0LESS_BOOT=n?
>>> 
>>> Sure, I’ll add the dependencies and remove the ARM one
>> 
>> Just to be sure, is it what you are asking?
> See below
> 
>> 
>> diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig
>> index 0399f2faf734..d9c5340ff3a2 100644
>> --- a/xen/arch/arm/Kconfig
>> +++ b/xen/arch/arm/Kconfig
>> @@ -90,7 +90,6 @@ config GICV2
>> 
>> config DOM0LESS_BOOT
>>        bool "Dom0less boot support" if EXPERT
>> -       depends on ARM
>>        default y
>>        help
>>          Dom0less boot support enables Xen to create and start domU guests during
>> @@ -214,7 +213,7 @@ source "arch/arm/tee/Kconfig"
>> 
>> config STATIC_SHM
>>        bool "Statically shared memory on a dom0less system" if UNSUPPORTED
>> -       depends on STATIC_MEMORY
>> +       depends on STATIC_MEMORY && DOM0LESS_BOOT
> no need for && DOM0LESS_BOOT

Thanks, yes I was unsure about that indeed

> 
>>        help
>>          This option enables statically shared memory on a dom0less system.
>> 
>> diff --git a/xen/common/Kconfig b/xen/common/Kconfig
>> index 4d6fe051641d..e0e5f4485d1f 100644
>> --- a/xen/common/Kconfig
>> +++ b/xen/common/Kconfig
>> @@ -100,7 +100,7 @@ config NUMA
>> 
>> config STATIC_MEMORY
>>        bool "Static Allocation Support (UNSUPPORTED)" if UNSUPPORTED
>> -       depends on ARM
>> +       depends on ARM && DOM0LESS_BOOT
> no need for ARM. DOM0LESS_BOOT already depends on ARM.

Ok, I’ll update it

> 
> ~Michal
>