Skip to contentSkip to conversation

Fine granular configuration

PATCH Superseded Luca Fancellu 2 participants 9 messages Nov 13, 2023

v4 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v4 cover Fine granular configuration

This serie aims to add more modularity to some feature that can be excluded without issues from the build.

The first patch is already reviewed.

v2 update: So I've tried to see how to put the dom0less code in the common code, but the amount of modifications are not trivial, even putting only the common part and protecting them with ARM, leaving the ARM specific stuff under arch/ like gic etc... will leave a status that is not very nice, so I've decided for now to keep everything on the arm architecture so that who is going to work on unifying the code in common can just take from there and do the proper rework.

This serie is not targeting 4.18.

Luca Fancellu (5):
arm/gicv2: make GICv2 driver and vGICv2 optional xen/arm: Add asm/domain.h include to kernel.h arm/dom0less: put dom0less feature code in a separate module xen/arm: Move static memory build code in separate modules arm/dom0less: introduce Kconfig for dom0less feature

 xen/arch/arm/Kconfig                      |   27 +
 xen/arch/arm/Makefile                     |    7 +-
 xen/arch/arm/bootfdt.c                    |  161 +-
 xen/arch/arm/dom0less-build.c             | 1018 ++++++
 xen/arch/arm/domain_build.c               | 3591 ++++++---------------
 xen/arch/arm/efi/efi-boot.h               |    4 +
 xen/arch/arm/gic-v3.c                     |    4 +
 xen/arch/arm/include/asm/dom0less-build.h |   30 +
 xen/arch/arm/include/asm/domain_build.h   |   36 +
 xen/arch/arm/include/asm/kernel.h         |    1 +
 xen/arch/arm/include/asm/setup.h          |    1 -
 xen/arch/arm/include/asm/static-memory.h  |   50 +
 xen/arch/arm/include/asm/static-shmem.h   |   71 +
 xen/arch/arm/setup.c                      |   58 +-
 xen/arch/arm/static-memory.c              |  294 ++
 xen/arch/arm/static-shmem.c               |  554 ++++
 xen/arch/arm/vgic.c                       |    2 +
 xen/arch/arm/vgic/Makefile                |    4 +-
 xen/common/Kconfig                        |    2 +-
 19 files changed, 3083 insertions(+), 2832 deletions(-)
 create mode 100644 xen/arch/arm/dom0less-build.c
 create mode 100644 xen/arch/arm/include/asm/dom0less-build.h
 create mode 100644 xen/arch/arm/include/asm/static-memory.h
 create mode 100644 xen/arch/arm/include/asm/static-shmem.h
 create mode 100644 xen/arch/arm/static-memory.c
 create mode 100644 xen/arch/arm/static-shmem.c
Signature · 1 line
2.34.1
#1 lore raw

PATCH v4 1/5 arm/gicv2: make GICv2 driver and vGICv2 optional

Introduce Kconfig GICV2 to be able to compile the GICv2 driver only when needed, the option is active by default.

Introduce Kconfig VGICV2 that compiles the Generic Interrupt Controller v2 emulation for domains, it is required only when using GICv2 driver, otherwise using the GICv3 driver it is optional and can be deselected if the user doesn't want to offer the v2 emulation to domains or maybe its GICv3 hardware can't offer the GICv2 compatible mode.

---
Changes from v3:
- No changes
Changes from v2:
- No changes

---
 xen/arch/arm/Kconfig        | 19 +++++++++++++++++++
 xen/arch/arm/Makefile       |  4 ++--
 xen/arch/arm/domain_build.c |  4 ++++
 xen/arch/arm/gic-v3.c       |  4 ++++
 xen/arch/arm/vgic.c         |  2 ++
 xen/arch/arm/vgic/Makefile  |  4 ++--
 6 files changed, 33 insertions(+), 4 deletions(-)
xen/arch/arm/Kconfig +19 -0
index 2939db429b78..0045a3762d86 100644
@@ -80,6 +80,14 @@ config ARM_EFI
 	  UEFI firmware. A UEFI stub is provided to allow Xen to
 	  be booted as an EFI application.
 
+config GICV2
+	bool "GICv2 driver"
+	default y
+	select VGICV2
+	help
+	  Driver for the ARM Generic Interrupt Controller v2.
+	  If unsure, say Y
+
 config GICV3
 	bool "GICv3 driver"
 	depends on !NEW_VGIC
@@ -99,11 +107,22 @@ config OVERLAY_DTB
 	help
 	  Dynamic addition/removal of Xen device tree nodes using a dtbo.
 
+config VGICV2
+	bool "vGICv2 interface for domains"
+	default y
+	help
+	  Allow Xen to expose a Generic Interrupt Controller version 2 like to Xen
+	  domains. This can be configured at the domain creation.
+	  This option is mandatory when using GICv2.
+	  For GICv3, this allows domain to use GICv2 when the hardware supports it.
+	  If unsure say Y.
+
 config HVM
         def_bool y
 
 config NEW_VGIC
 	bool "Use new VGIC implementation"
+	select GICV2
 	---help---
 
 	This is an alternative implementation of the ARM GIC interrupt
xen/arch/arm/Makefile +2 -2
index 7bf07e992046..81c31c36fc3d 100644
@@ -22,7 +22,7 @@ obj-y += domctl.o
 obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
 obj-y += efi/
 obj-y += gic.o
-obj-y += gic-v2.o
+obj-$(CONFIG_GICV2) += gic-v2.o
 obj-$(CONFIG_GICV3) += gic-v3.o
 obj-$(CONFIG_HAS_ITS) += gic-v3-its.o
 obj-$(CONFIG_HAS_ITS) += gic-v3-lpi.o
@@ -57,7 +57,7 @@ obj-$(CONFIG_NEW_VGIC) += vgic/
 ifneq ($(CONFIG_NEW_VGIC),y)
 obj-y += gic-vgic.o
 obj-y += vgic.o
-obj-y += vgic-v2.o
+obj-$(CONFIG_VGICV2) += vgic-v2.o
 obj-$(CONFIG_GICV3) += vgic-v3.o
 obj-$(CONFIG_HAS_ITS) += vgic-v3-its.o
 endif
xen/arch/arm/domain_build.c +4 -0
index 49792dd590ee..3d3a117bde7a 100644
@@ -2490,6 +2490,7 @@ static int __init handle_node(struct domain *d, struct kernel_info *kinfo,
     return res;
 }
 
+#ifdef CONFIG_VGICV2
 static int __init make_gicv2_domU_node(struct kernel_info *kinfo)
 {
     void *fdt = kinfo->fdt;
@@ -2541,6 +2542,7 @@ static int __init make_gicv2_domU_node(struct kernel_info *kinfo)
 
     return res;
 }
+#endif
 
 #ifdef CONFIG_GICV3
 static int __init make_gicv3_domU_node(struct kernel_info *kinfo)
@@ -2616,8 +2618,10 @@ static int __init make_gic_domU_node(struct kernel_info *kinfo)
     case GIC_V3:
         return make_gicv3_domU_node(kinfo);
 #endif
+#ifdef CONFIG_VGICV2
     case GIC_V2:
         return make_gicv2_domU_node(kinfo);
+#endif
     default:
         panic("Unsupported GIC version\n");
     }
xen/arch/arm/gic-v3.c +4 -0
index 172ff8c005ff..292abefd8731 100644
@@ -1334,6 +1334,7 @@ static paddr_t __initdata dbase = INVALID_PADDR;
 static paddr_t __initdata vbase = INVALID_PADDR, vsize = 0;
 static paddr_t __initdata cbase = INVALID_PADDR, csize = 0;
 
+#ifdef CONFIG_VGICV2
 /* If the GICv3 supports GICv2, initialize it */
 static void __init gicv3_init_v2(void)
 {
@@ -1359,6 +1360,9 @@ static void __init gicv3_init_v2(void)
 
     vgic_v2_setup_hw(dbase, cbase, csize, vbase, 0);
 }
+#else
+static inline void gicv3_init_v2(void) { }
+#endif
 
 static void __init gicv3_ioremap_distributor(paddr_t dist_paddr)
 {
xen/arch/arm/vgic.c +2 -0
index f6b49766f97a..c04fc4f83f96 100644
@@ -96,10 +96,12 @@ int domain_vgic_register(struct domain *d, unsigned int *mmio_count)
            return -ENODEV;
         break;
 #endif
+#ifdef CONFIG_VGICV2
     case GIC_V2:
         if ( vgic_v2_init(d, mmio_count) )
             return -ENODEV;
         break;
+#endif
     default:
         printk(XENLOG_G_ERR "d%d: Unknown vGIC version %u\n",
                d->domain_id, d->arch.vgic.version);
xen/arch/arm/vgic/Makefile +2 -2
index 806826948e20..60cbf7f2f94a 100644
@@ -1,5 +1,5 @@
 obj-y += vgic.o
-obj-y += vgic-v2.o
+obj-$(CONFIG_VGICV2) += vgic-v2.o
 obj-y += vgic-mmio.o
-obj-y += vgic-mmio-v2.o
+obj-$(CONFIG_VGICV2) += vgic-mmio-v2.o
 obj-y += vgic-init.o
Signature · 1 line
2.34.1
#2 lore raw

PATCH v4 2/5 xen/arm: Add asm/domain.h include to kernel.h

In reply to Luca Fancellu

The 'enum domain_type' is defined by 'asm/domain.h' which is not included (directly or indirectly) by 'asm/kernel.h'.

This currently doesn't break the compilation because asm/domain.h will included by the user of 'kernel.h'. But it would be better to avoid relying on it. So add the include in 'asm/domain.h'.

---
Changes from v3:
- No changes
Changes from v2:
- add Ack-by Julien
Changes from v1:
- Rephrased commit message (Julien)

---
 xen/arch/arm/include/asm/kernel.h | 1 +
 1 file changed, 1 insertion(+)
xen/arch/arm/include/asm/kernel.h +1 -0
index 4617cdc83bac..0a23e86c2d37 100644
@@ -7,6 +7,7 @@
 #define __ARCH_ARM_KERNEL_H__
 
 #include <xen/device_tree.h>
+#include <asm/domain.h>
 #include <asm/setup.h>
 
 /*
Signature · 1 line
2.34.1
#3 lore raw

PATCH v4 3/5 arm/dom0less: put dom0less feature code in a separate module

In reply to Luca Fancellu

Currently the dom0less feature code is mostly inside domain_build.c and setup.c, it is a feature that may not be useful to everyone so put the code in a different compilation module in order to make it easier to disable the feature in the future.

Move gic_interrupt_t in domain_build.h to use it with the function declaration, move its comment above the declaration.

The following functions are now visible externally from domain_build because they are used also from the dom0less-build module:
- get_allocation_size
- set_interrupt
- domain_fdt_begin_node
- make_memory_node
- make_resv_memory_node
- make_hypervisor_node
- make_psci_node
- make_cpus_node
- make_timer_node
- handle_device_interrupts
- construct_domain
- process_shm
- allocate_bank_memory

The functions allocate_static_memory and assign_static_memory_11 are now externally visible, so put their declarations into domain_build.h and move the #else and stub definition in the header as well.

Move is_dom0less_mode from setup.c to dom0less-build.c and make it externally visible.

The function allocate_bank_memory is used only by dom0less code at the moment, but it's been decided to leave it in domain_build.c in case that in the future the dom0 code can use it.

Where spotted, fix code style issues.

No functional change is intended.

---
Changes from v3:
- remove header in dom0less-build.h (Michal)
Changes from v2:
- move allocate_bank_memory back in domain_build.c, remove header from dom0less-build.c.

---
 xen/arch/arm/Makefile                     |    1 +
 xen/arch/arm/dom0less-build.c             | 1018 +++++++++++++++++
 xen/arch/arm/domain_build.c               | 1265 +++------------------
 xen/arch/arm/include/asm/dom0less-build.h |   20 +
 xen/arch/arm/include/asm/domain_build.h   |   60 +
 xen/arch/arm/include/asm/setup.h          |    1 -
 xen/arch/arm/setup.c                      |   33 +-
 7 files changed, 1240 insertions(+), 1158 deletions(-)
 create mode 100644 xen/arch/arm/dom0less-build.c
 create mode 100644 xen/arch/arm/include/asm/dom0less-build.h
xen/arch/arm/Makefile +1 -0
index 81c31c36fc3d..70dd7201ef30 100644
@@ -15,6 +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-y += domain.o
 obj-y += domain_build.init.o
 obj-$(CONFIG_ARCH_MAP_DOMAIN_PAGE) += domain_page.o
xen/arch/arm/dom0less-build.c new file +1018 -0

1,018 lines not on this page · raw message

xen/arch/arm/domain_build.c +140 -1125

1,424 lines not on this page · raw message

xen/arch/arm/include/asm/dom0less-build.h new file +20 -0
new file mode 100644
index 000000000000..022ae61ead7c
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef __ARM_DOM0LESS_BUILD_H_
+#define __ARM_DOM0LESS_BUILD_H_
+
+#include <asm/kernel.h>
+
+void create_domUs(void);
+bool is_dom0less_mode(void);
+
+#endif  /* __ARM_DOM0LESS_BUILD_H_ */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:b
+ */
xen/arch/arm/include/asm/domain_build.h +60 -0

75 lines not on this page · raw message

xen/arch/arm/include/asm/setup.h +0 -1
index 98af6f55f5a0..39359f64b678 100644
@@ -135,7 +135,6 @@ void acpi_create_efi_mmap_table(struct domain *d,
 
 int acpi_make_efi_nodes(void *fdt, struct membank tbl_add[]);
 
-void create_domUs(void);
 void create_dom0(void);
 void alloc_static_evtchn(void);
 
xen/arch/arm/setup.c +1 -32
index 3f3a45719ccb..60b544b67b4e 100644
@@ -34,6 +34,7 @@
 #include <xen/warning.h>
 #include <xen/hypercall.h>
 #include <asm/alternative.h>
+#include <asm/dom0less-build.h>
 #include <asm/page.h>
 #include <asm/current.h>
 #include <asm/setup.h>
@@ -1042,38 +1043,6 @@ static void __init setup_mm(void)
 }
 #endif
 
-static bool __init is_dom0less_mode(void)
-{
-    struct bootmodules *mods = &bootinfo.modules;
-    struct bootmodule *mod;
-    unsigned int i;
-    bool dom0found = false;
-    bool domUfound = false;
-
-    /* Look into the bootmodules */
-    for ( i = 0 ; i < mods->nr_mods ; i++ )
-    {
-        mod = &mods->module[i];
-        /* Find if dom0 and domU kernels are present */
-        if ( mod->kind == BOOTMOD_KERNEL )
-        {
-            if ( mod->domU == false )
-            {
-                dom0found = true;
-                break;
-            }
-            else
-                domUfound = true;
-        }
-    }
-
-    /*
-     * If there is no dom0 kernel but at least one domU, then we are in
-     * dom0less mode
-     */
-    return ( !dom0found && domUfound );
-}
-
 size_t __read_mostly dcache_line_bytes;
 
 /* C entry point for boot CPU */
Signature · 1 line
2.34.1
#4 lore raw

Re: [PATCH v4 3/5] arm/dom0less: put dom0less feature code in a separate module

Hi Luca,

Apart from pending question on static event channels code movement, a few NITs.

Quoted 61 lines · Luca Fancellu

Currently the dom0less feature code is mostly inside domain_build.c and setup.c, it is a feature that may not be useful to everyone so put the code in a different compilation module in order to make it easier to disable the feature in the future.

Move gic_interrupt_t in domain_build.h to use it with the function declaration, move its comment above the declaration.

The following functions are now visible externally from domain_build because they are used also from the dom0less-build module:
- get_allocation_size
- set_interrupt
- domain_fdt_begin_node
- make_memory_node
- make_resv_memory_node
- make_hypervisor_node
- make_psci_node
- make_cpus_node
- make_timer_node
- handle_device_interrupts
- construct_domain
- process_shm
- allocate_bank_memory

The functions allocate_static_memory and assign_static_memory_11 are now externally visible, so put their declarations into domain_build.h and move the #else and stub definition in the header as well.

Move is_dom0less_mode from setup.c to dom0less-build.c and make it externally visible.

The function allocate_bank_memory is used only by dom0less code at the moment, but it's been decided to leave it in domain_build.c in case that in the future the dom0 code can use it.

Where spotted, fix code style issues.

No functional change is intended.

---
Changes from v3:
- remove header in dom0less-build.h (Michal)
Changes from v2:
- move allocate_bank_memory back in domain_build.c, remove header from dom0less-build.c.

---
 xen/arch/arm/Makefile                     |    1 +
 xen/arch/arm/dom0less-build.c             | 1018 +++++++++++++++++
 xen/arch/arm/domain_build.c               | 1265 +++------------------
 xen/arch/arm/include/asm/dom0less-build.h |   20 +
 xen/arch/arm/include/asm/domain_build.h   |   60 +
 xen/arch/arm/include/asm/setup.h          |    1 -
 xen/arch/arm/setup.c                      |   33 +-
 7 files changed, 1240 insertions(+), 1158 deletions(-)
 create mode 100644 xen/arch/arm/dom0less-build.c
 create mode 100644 xen/arch/arm/include/asm/dom0less-build.h

[...]

xen/arch/arm/include/asm/dom0less-build.h line 3

Quoted 9 lines
xen/arch/arm/include/asm/dom0less-build.h new file +3 -0
new file mode 100644
index 000000000000..022ae61ead7c
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef __ARM_DOM0LESS_BUILD_H_

The majority of header files have a guard starting with __ASM so I would stick to the scheme.

xen/arch/arm/include/asm/dom0less-build.h line 11

Quoted 8 lines
xen/arch/arm/include/asm/dom0less-build.h new file +8 -0
+#define __ARM_DOM0LESS_BUILD_H_
+
+#include <asm/kernel.h>
+
+void create_domUs(void);
+bool is_dom0less_mode(void);
+
+#endif  /* __ARM_DOM0LESS_BUILD_H_ */

1 space between #endif and comment

xen/arch/arm/include/asm/dom0less-build.h line 19

Quoted 8 lines
xen/arch/arm/include/asm/dom0less-build.h new file +8 -0
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:b

What does 'b' means here? Only 2 files have that.

The comments apply to other files as well.

Apart from that, the movement LGTM.

~Michal

#5 lore raw

Re: [PATCH v4 3/5] arm/dom0less: put dom0less feature code in a separate module

Quoted 7 lines · Michal Orzel

Hi Luca,

Apart from pending question on static event channels code movement, a few NITs.

Related to that, it seems to me that this part can be handled by a separate patch/serie from this one, moving code from domain_build.c to a new module, so I’m wondering, is this point a blocker for this serie?

Quoted 66 lines · Luca Fancellu
Quoted 61 lines

Currently the dom0less feature code is mostly inside domain_build.c and setup.c, it is a feature that may not be useful to everyone so put the code in a different compilation module in order to make it easier to disable the feature in the future.

Move gic_interrupt_t in domain_build.h to use it with the function declaration, move its comment above the declaration.

The following functions are now visible externally from domain_build because they are used also from the dom0less-build module:
- get_allocation_size
- set_interrupt
- domain_fdt_begin_node
- make_memory_node
- make_resv_memory_node
- make_hypervisor_node
- make_psci_node
- make_cpus_node
- make_timer_node
- handle_device_interrupts
- construct_domain
- process_shm
- allocate_bank_memory

The functions allocate_static_memory and assign_static_memory_11 are now externally visible, so put their declarations into domain_build.h and move the #else and stub definition in the header as well.

Move is_dom0less_mode from setup.c to dom0less-build.c and make it externally visible.

The function allocate_bank_memory is used only by dom0less code at the moment, but it's been decided to leave it in domain_build.c in case that in the future the dom0 code can use it.

Where spotted, fix code style issues.

No functional change is intended.

---
Changes from v3:
- remove header in dom0less-build.h (Michal)
Changes from v2:
- move allocate_bank_memory back in domain_build.c, remove header from dom0less-build.c.
---

xen/arch/arm/Makefile                     |    1 +
xen/arch/arm/dom0less-build.c             | 1018 +++++++++++++++++
xen/arch/arm/domain_build.c               | 1265 +++------------------
xen/arch/arm/include/asm/dom0less-build.h |   20 +
xen/arch/arm/include/asm/domain_build.h   |   60 +
xen/arch/arm/include/asm/setup.h          |    1 -
xen/arch/arm/setup.c                      |   33 +-
7 files changed, 1240 insertions(+), 1158 deletions(-)

create mode 100644 xen/arch/arm/dom0less-build.c create mode 100644 xen/arch/arm/include/asm/dom0less-build.h

[...]

Quoted 10 lines

xen/arch/arm/include/asm/dom0less-build.h line 3

Quoted 9 lines
xen/arch/arm/include/asm/dom0less-build.h new file +3 -0
new file mode 100644
index 000000000000..022ae61ead7c
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef __ARM_DOM0LESS_BUILD_H_

The majority of header files have a guard starting with __ASM so I would stick to the scheme.

Sure, makes sense

Quoted 10 lines

xen/arch/arm/include/asm/dom0less-build.h line 11

Quoted 9 lines
xen/arch/arm/include/asm/dom0less-build.h new file +8 -0
+#define __ARM_DOM0LESS_BUILD_H_
+
+#include <asm/kernel.h>
+
+void create_domUs(void);
+bool is_dom0less_mode(void);
+
+#endif  /* __ARM_DOM0LESS_BUILD_H_ */

1 space between #endif and comment

I’ll fix

Quoted 10 lines

xen/arch/arm/include/asm/dom0less-build.h line 19

Quoted 9 lines
xen/arch/arm/include/asm/dom0less-build.h new file +8 -0
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:b

What does 'b' means here? Only 2 files have that.

Mmm... I think I’ve copied this part from smccc.h and I didn’t realised there is a typo (or at least I think it is) because looking into CODING_STYLE, there is no ‘b’ in ‘End:’, I’ll fix it.

Quoted 7 lines

The comments apply to other files as well.

Apart from that, the movement LGTM.

~Michal

#6 lore raw

Re: [PATCH v4 3/5] arm/dom0less: put dom0less feature code in a separate module

Hi Luca,

Quoted 11 lines · Luca Fancellu
Quoted 7 lines · Michal Orzel

Hi Luca,

Apart from pending question on static event channels code movement, a few NITs.

Related to that, it seems to me that this part can be handled by a separate patch/serie from this one, moving code from domain_build.c to a new module, so I’m wondering, is this point a blocker for this serie?

My recommendation was to move it to dom0less-build for now if we all agree that it should be guarded by dom0less. That said, it is not a blocker from my POV. I can handle it later on after your series.

~Michal

#7 lore raw

PATCH v4 4/5 xen/arm: Move static memory build code in separate modules

In reply to Luca Fancellu

Move static memory and static shared memory code in separate modules so that they are included only when the corresponding feature is enabled, doing that we modularise the features and we remove some ifdefs from the code to improve readability.

Move process_shm_node function from bootfdt module and make it externally visible.

A static inline helper called process_shm_chosen is introduced, it will call the process_shm function for the '/chosen' node, and will be used by the function construct_dom0 instead of using directly process_shm, allowing some #ifdef to be removed.

No functional changes are intended.

---
Changes from v3:
- Moved make_resv_memory_node from domain_build to static-shmem (Michal), make make_shm_memory_node static.
Changes from v2:
- no changes

---
 xen/arch/arm/Makefile                     |   2 +
 xen/arch/arm/bootfdt.c                    | 161 +-----
 xen/arch/arm/dom0less-build.c             |   4 +-
 xen/arch/arm/domain_build.c               | 654 +---------------------
 xen/arch/arm/include/asm/dom0less-build.h |   2 -
 xen/arch/arm/include/asm/domain_build.h   |  26 -
 xen/arch/arm/include/asm/static-memory.h  |  50 ++
 xen/arch/arm/include/asm/static-shmem.h   |  71 +++
 xen/arch/arm/setup.c                      |  25 +-
 xen/arch/arm/static-memory.c              | 294 ++++++++++
 xen/arch/arm/static-shmem.c               | 554 ++++++++++++++++++
 11 files changed, 977 insertions(+), 866 deletions(-)
 create mode 100644 xen/arch/arm/include/asm/static-memory.h
 create mode 100644 xen/arch/arm/include/asm/static-shmem.h
 create mode 100644 xen/arch/arm/static-memory.c
 create mode 100644 xen/arch/arm/static-shmem.c
xen/arch/arm/Makefile +2 -0
index 70dd7201ef30..89ef0c9075b5 100644
@@ -50,6 +50,8 @@ obj-y += setup.o
 obj-y += shutdown.o
 obj-y += smp.o
 obj-y += smpboot.o
+obj-$(CONFIG_STATIC_MEMORY) += static-memory.init.o
+obj-$(CONFIG_STATIC_SHM) += static-shmem.init.o
 obj-y += sysctl.o
 obj-y += time.o
 obj-y += traps.o
xen/arch/arm/bootfdt.c +1 -160

173 lines not on this page · raw message

xen/arch/arm/dom0less-build.c +2 -2
index 1ca9d39043d6..d39cbd969aca 100644
@@ -13,6 +13,8 @@
 #include <asm/arm64/sve.h>
 #include <asm/dom0less-build.h>
 #include <asm/domain_build.h>
+#include <asm/static-memory.h>
+#include <asm/static-shmem.h>
 
 bool __init is_dom0less_mode(void)
 {
@@ -806,11 +808,9 @@ static int __init construct_domU(struct domain *d,
     else
         assign_static_memory_11(d, &kinfo, node);
 
-#ifdef CONFIG_STATIC_SHM
     rc = process_shm(d, &kinfo, node);
     if ( rc < 0 )
         return rc;
-#endif
 
     /*
      * Base address and irq number are needed when creating vpl011 device
xen/arch/arm/domain_build.c +2 -652

686 lines not on this page · raw message

xen/arch/arm/include/asm/dom0less-build.h +0 -2
index 022ae61ead7c..75502b562548 100644
@@ -3,8 +3,6 @@
 #ifndef __ARM_DOM0LESS_BUILD_H_
 #define __ARM_DOM0LESS_BUILD_H_
 
-#include <asm/kernel.h>
-
 void create_domUs(void);
 bool is_dom0less_mode(void);
 
xen/arch/arm/include/asm/domain_build.h +0 -26
index b9ae0d170c5c..da9e6025f37c 100644
@@ -10,8 +10,6 @@ bool allocate_bank_memory(struct domain *d, struct kernel_info *kinfo,
                           gfn_t sgfn, paddr_t tot_size);
 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,
-                          int sizecells, const struct meminfo *mem);
 int make_chosen_node(const struct kernel_info *kinfo);
 int make_cpus_node(const struct domain *d, void *fdt);
 int make_hypervisor_node(struct domain *d, const struct kernel_info *kinfo,
@@ -42,9 +40,6 @@ int handle_device_interrupts(struct domain *d, struct dt_device_node *dev,
 void set_interrupt(gic_interrupt_t interrupt, unsigned int irq,
                    unsigned int cpumask, unsigned int level);
 
-int process_shm(struct domain *d, struct kernel_info *kinfo,
-                const struct dt_device_node *node);
-
 #ifndef CONFIG_ACPI
 static inline int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
 {
@@ -56,27 +51,6 @@ static inline int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
 int prepare_acpi(struct domain *d, struct kernel_info *kinfo);
 #endif
 
-#ifdef CONFIG_STATIC_MEMORY
-void allocate_static_memory(struct domain *d, struct kernel_info *kinfo,
-                            const struct dt_device_node *node);
-void assign_static_memory_11(struct domain *d, struct kernel_info *kinfo,
-                             const struct dt_device_node *node);
-#else
-static inline void allocate_static_memory(struct domain *d,
-                                          struct kernel_info *kinfo,
-                                          const struct dt_device_node *node)
-{
-    ASSERT_UNREACHABLE();
-}
-
-static inline void assign_static_memory_11(struct domain *d,
-                                           struct kernel_info *kinfo,
-                                           const struct dt_device_node *node)
-{
-    ASSERT_UNREACHABLE();
-}
-#endif
-
 #endif
 
 /*
xen/arch/arm/include/asm/static-memory.h new file +50 -0

50 lines not on this page · raw message

xen/arch/arm/include/asm/static-shmem.h new file +71 -0

71 lines not on this page · raw message

xen/arch/arm/setup.c +1 -24
index 60b544b67b4e..f6019c0c42cd 100644
@@ -44,6 +44,7 @@
 #include <asm/platform.h>
 #include <asm/procinfo.h>
 #include <asm/setup.h>
+#include <asm/static-memory.h>
 #include <xsm/xsm.h>
 #include <asm/acpi.h>
 
@@ -758,30 +759,6 @@ static void __init init_pdx(void)
     }
 }
 
-/* Static memory initialization */
-static void __init init_staticmem_pages(void)
-{
-#ifdef CONFIG_STATIC_MEMORY
-    unsigned int bank;
-
-    for ( bank = 0 ; bank < bootinfo.reserved_mem.nr_banks; bank++ )
-    {
-        if ( bootinfo.reserved_mem.bank[bank].type == MEMBANK_STATIC_DOMAIN )
-        {
-            mfn_t bank_start = _mfn(PFN_UP(bootinfo.reserved_mem.bank[bank].start));
-            unsigned long bank_pages = PFN_DOWN(bootinfo.reserved_mem.bank[bank].size);
-            mfn_t bank_end = mfn_add(bank_start, bank_pages);
-
-            if ( mfn_x(bank_end) <= mfn_x(bank_start) )
-                return;
-
-            unprepare_staticmem_pages(mfn_to_page(bank_start),
-                                      bank_pages, false);
-        }
-    }
-#endif
-}
-
 /*
  * Populate the boot allocator.
  * If a static heap was not provided by the admin, all the RAM but the
xen/arch/arm/static-memory.c new file +294 -0

294 lines not on this page · raw message

xen/arch/arm/static-shmem.c new file +554 -0

554 lines not on this page · raw message

Signature · 1 line
2.34.1
#8 lore raw

PATCH v4 5/5 arm/dom0less: introduce Kconfig for dom0less feature

In reply to Luca Fancellu

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.

---
Changes from v3:
- Update Kconfig (Michal)
Changes from v2:
- protect allocate_bank_memory with the new Kconfig

---
 xen/arch/arm/Kconfig                      |  8 ++++++++
 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 ++
 xen/common/Kconfig                        |  2 +-
 7 files changed, 30 insertions(+), 2 deletions(-)
xen/arch/arm/Kconfig +8 -0
index 0045a3762d86..f321381a6e87 100644
@@ -88,6 +88,14 @@ config GICV2
 	  Driver for the ARM Generic Interrupt Controller v2.
 	  If unsure, say Y
 
+config DOM0LESS_BOOT
+	bool "Dom0less boot support" if EXPERT
+	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
xen/arch/arm/Makefile +1 -1
index 89ef0c9075b5..5daf8f10114d 100644
@@ -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
xen/arch/arm/domain_build.c +2 -0
index 615faaffba9f..9c5e7835b544 100644
@@ -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
xen/arch/arm/efi/efi-boot.h +4 -0
index 1c3640bb65fd..689dc016d081 100644
@@ -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);
xen/arch/arm/include/asm/dom0less-build.h +12 -0
index 75502b562548..1c6fc0962b07 100644
@@ -3,9 +3,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_ */
 
 /*
xen/arch/arm/include/asm/domain_build.h +2 -0
index da9e6025f37c..6df61fa1d587 100644
@@ -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_chosen_node(const struct kernel_info *kinfo);
xen/common/Kconfig +1 -1
index 4d6fe051641d..310ad4229cdf 100644
@@ -100,7 +100,7 @@ config NUMA
 
 config STATIC_MEMORY
 	bool "Static Allocation Support (UNSUPPORTED)" if UNSUPPORTED
-	depends on ARM
+	depends on DOM0LESS_BOOT
 	help
 	  Static Allocation refers to system or sub-system(domains) for
 	  which memory areas are pre-defined by configuration using physical
Signature · 1 line
2.34.1