Skip to contentSkip to conversation

Fine granular configuration

PATCH Superseded Luca Fancellu 3 participants 18 messages Nov 9, 2023 – Nov 13, 2023

v3 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v3 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                      |   28 +
 xen/arch/arm/Makefile                     |    7 +-
 xen/arch/arm/bootfdt.c                    |  161 +-
 xen/arch/arm/dom0less-build.c             | 1018 ++++++
 xen/arch/arm/domain_build.c               | 3623 ++++++---------------
 xen/arch/arm/efi/efi-boot.h               |    4 +
 xen/arch/arm/gic-v3.c                     |    4 +
 xen/arch/arm/include/asm/dom0less-build.h |   35 +
 xen/arch/arm/include/asm/domain_build.h   |   38 +
 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   |   72 +
 xen/arch/arm/setup.c                      |   58 +-
 xen/arch/arm/static-memory.c              |  294 ++
 xen/arch/arm/static-shmem.c               |  515 +++
 xen/arch/arm/vgic.c                       |    2 +
 xen/arch/arm/vgic/Makefile                |    4 +-
 18 files changed, 3088 insertions(+), 2827 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 v3 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 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 v3 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 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 v3 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 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 |   25 +
 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, 1245 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 +25 -0
new file mode 100644
index 000000000000..0d28fa1bee46
@@ -0,0 +1,25 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * xen/arch/arm/include/asm/dom0less-build.h
+ *
+ * Copyright (C) 2023 Arm Ltd.
+ */
+
+#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 v3 3/5] arm/dom0less: put dom0less feature code in a separate module

Hi Luca,

Quoted 10 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.

Quoted 7 lines

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

This one, despite the name, is strictly related to shmem. Shouldn't we move it to static-shmem?

Quoted 8 lines

- make_hypervisor_node
- make_psci_node
- make_cpus_node
- make_timer_node
- handle_device_interrupts
- construct_domain
- process_shm
- allocate_bank_memory

What about static event channels? Does it make sense to leave it unguarded? Reading the docs,
it looks like at least one domU needs to be present (dom0-domU or domU-domU). Hovever, looking at the code it should be possible for a loopback. That said, I don't really find it useful given that loopback does not really need this feature.

Quoted 15 lines

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.

Quoted 7 lines

No functional change is intended.

---
Changes from v2:
- move allocate_bank_memory back in domain_build.c, remove header from dom0less-build.c.

I can see you removed the copyright from .c but .h still has it. This also applies to other newly introduced files that were subject only to code movement.

~Michal

#5 lore raw

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

Hi Michal,

Quoted 15 lines · Michal Orzel

Hi Luca,

Quoted 10 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.

Quoted 8 lines
Quoted 7 lines

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

This one, despite the name, is strictly related to shmem. Shouldn't we move it to static-shmem?

Yes you are right, good catch!

Quoted 9 lines
Quoted 9 lines

- make_hypervisor_node
- make_psci_node
- make_cpus_node
- make_timer_node
- handle_device_interrupts
- construct_domain
- process_shm
- allocate_bank_memory

Quoted 3 lines

What about static event channels? Does it make sense to leave it unguarded? Reading the docs,
it looks like at least one domU needs to be present (dom0-domU or domU-domU). Hovever, looking at the code it should be possible for a loopback. That said, I don't really find it useful given that loopback does not really need this feature.

I think you could be right, but maybe it ought to be on a module on its own? Like static-evtch.c? I would like to ear the opinions of the other maintainer on that, since it might be controversial as you explained above.

Quoted 18 lines
Quoted 18 lines

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.

Quoted 7 lines
Quoted 5 lines

---
Changes from v2:
- move allocate_bank_memory back in domain_build.c, remove header from dom0less-build.c.

I can see you removed the copyright from .c but .h still has it. This also applies to other newly introduced files that were subject only to code movement.

Yes I forgot about it, I will remove it in the next push

Quoted 2 lines

~Michal

#6 lore raw

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

In reply to Michal Orzel
Quoted 18 lines
Quoted 18 lines

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.

Quoted 7 lines
Quoted 5 lines

---
Changes from v2:
- move allocate_bank_memory back in domain_build.c, remove header from dom0less-build.c.

I can see you removed the copyright from .c but .h still has it. This also applies to other newly introduced files that were subject only to code movement.

I’ve just read again your comment, I pushed the v4 but removing the header only from dom0less-build.h.
I left the header in the other static-* because that I think was code produced by Arm, please let me know your thoughts about that (you and the Arm maintainers)

Cheers,
Luca

#7 lore raw

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

Hi Luca,

Quoted 25 lines · Luca Fancellu
Quoted 24 lines
Quoted 24 lines

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 v2:
- move allocate_bank_memory back in domain_build.c, remove header from dom0less-build.c.

Quoted 7 lines
Quoted 2 lines

I can see you removed the copyright from .c but .h still has it. This also applies to other newly introduced files that were subject only to code movement.

I’ve just read again your comment, I pushed the v4 but removing the header only from dom0less-build.h.
I left the header in the other static-* because that I think was code produced by Arm, please let me know your thoughts about that (you and the Arm maintainers)

Even if true, adding the copyright after is a bit odd.
I do not think this is code on which the copyright really has impact so I would not add it during the move.

Cheers
Bertrand

Quoted 4 lines

Cheers,
Luca

#8 lore raw

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

Quoted 11 lines
Quoted 8 lines
Quoted 3 lines

I can see you removed the copyright from .c but .h still has it. This also applies to other newly introduced files that were subject only to code movement.

I’ve just read again your comment, I pushed the v4 but removing the header only from dom0less-build.h.
I left the header in the other static-* because that I think was code produced by Arm, please let me know your thoughts about that (you and the Arm maintainers)

Even if true, adding the copyright after is a bit odd.
I do not think this is code on which the copyright really has impact so I would not add it during the move.

Sure, I’ll drop it

#9 lore raw

PATCH v3 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 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               | 614 +---------------------
 xen/arch/arm/include/asm/dom0less-build.h |   2 -
 xen/arch/arm/include/asm/domain_build.h   |  24 -
 xen/arch/arm/include/asm/static-memory.h  |  50 ++
 xen/arch/arm/include/asm/static-shmem.h   |  72 +++
 xen/arch/arm/setup.c                      |  25 +-
 xen/arch/arm/static-memory.c              | 294 +++++++++++
 xen/arch/arm/static-shmem.c               | 515 ++++++++++++++++++
 11 files changed, 939 insertions(+), 824 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 -612

646 lines not on this page · raw message

xen/arch/arm/include/asm/dom0less-build.h +0 -2
index 0d28fa1bee46..d95cb6234b62 100644
@@ -8,8 +8,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 -24
index b9ae0d170c5c..13118b5ff956 100644
@@ -42,9 +42,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 +53,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 +72 -0

72 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 +515 -0

515 lines not on this page · raw message

Signature · 1 line
2.34.1
#10 lore raw

Re: [PATCH v3 4/5] xen/arm: Move static memory build code in separate modules

Hi Luca,

Quoted 9 lines · 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.

What about process_domain_node()? This function is related to "xen,domain" compatible that is only present for dom0less domUs.

~Michal

#11 lore raw

Re: [PATCH v3 4/5] xen/arm: Move static memory build code in separate modules

Quoted 14 lines · Michal Orzel

Hi Luca,

Quoted 7 lines · 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.

Quoted 4 lines
Quoted 2 lines

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

What about process_domain_node()? This function is related to "xen,domain" compatible that is only present for dom0less domUs.

I see it a bit tricky to do, in fact putting it on the static-memory module would need to have it externally visible from its module, but also it needs to have device_tree_get_meminfo externally visible from the bootfdt.

I think that one is more a glue-code mostly related to dt and this cross dependency suggests me to keep it as it is.

Cheers,
Luca

#12 lore raw

PATCH v3 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 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(-)
xen/arch/arm/Kconfig +9 -0
index 0045a3762d86..0399f2faf734 100644
@@ -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
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 c2c17f075450..87eade449006 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 d95cb6234b62..859944eece16 100644
@@ -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_ */
 
 /*
xen/arch/arm/include/asm/domain_build.h +2 -0
index 13118b5ff956..3950f0276e55 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_resv_memory_node(const struct domain *d, void *fdt, int addrcells,
Signature · 1 line
2.34.1
#13 lore raw

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

Hi Luca,

Quoted 32 lines · 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 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(-)
xen/arch/arm/Kconfig +0 -0
index 0045a3762d86..0399f2faf734 100644

xen/arch/arm/Kconfig config GICV2 · line 93

Quoted 6 lines
xen/arch/arm/Kconfig +3 -0
@@ -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

#14 lore raw

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

Hi Michal,

Quoted 9 lines

xen/arch/arm/Kconfig config GICV2 · line 93

Quoted 4 lines
xen/arch/arm/Kconfig +3 -0
+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

Quoted 2 lines

~Michal

#15 lore raw

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

Quoted 10 lines · Luca Fancellu

Hi Michal,

Quoted 4 lines
Quoted 4 lines
(quoted diff) +3 -0
+config DOM0LESS_BOOT
+       bool "Dom0less boot support" if EXPERT
+       depends on ARM
Quoted 7 lines
Quoted 5 lines

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?

xen/arch/arm/Kconfig +1 -2
index 0399f2faf734..d9c5340ff3a2 100644
@@ -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.
 
xen/common/Kconfig +1 -1
index 4d6fe051641d..e0e5f4485d1f 100644
@@ -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
#16 lore raw

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

Hi,

Quoted 12 lines · Luca Fancellu
Quoted 12 lines · Luca Fancellu

Hi Michal,

Quoted 6 lines

Review

Quoted 4 lines
(quoted diff) +3 -0
+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).

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

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

Quoted 14 lines
xen/arch/arm/Kconfig +0 -1
index 0399f2faf734..d9c5340ff3a2 100644
@@ -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

xen/arch/arm/Kconfig source "arch/arm/tee/Kconfig" · line 216

Quoted 5 lines
xen/arch/arm/Kconfig +1 -1
@@ -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

xen/common/Kconfig config NUMA · line 103

Quoted 13 lines
xen/arch/arm/Kconfig +0 -0
        help
          This option enables statically shared memory on a dom0less system.
 
xen/common/Kconfig +1 -1
index 4d6fe051641d..e0e5f4485d1f 100644
@@ -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

#17 lore raw

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

Quoted 43 lines · Michal Orzel

Hi,

Quoted 12 lines · Luca Fancellu
Quoted 12 lines · Luca Fancellu

Hi Michal,

Quoted 6 lines

Review

Quoted 4 lines
(quoted diff) +3 -0
+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).

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

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

Quoted 15 lines
xen/arch/arm/Kconfig +0 -0
index 0399f2faf734..d9c5340ff3a2 100644
@@ -90,7 +90,6 @@ config GICV2
 

config DOM0LESS_BOOT
bool "Dom0less boot support" if EXPERT

xen/arch/arm/Kconfig +0 -1
-       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"
 
Quoted 5 lines

xen/arch/arm/Kconfig source "arch/arm/tee/Kconfig" · line 216

Quoted 4 lines

config STATIC_SHM
bool "Statically shared memory on a dom0less system" if UNSUPPORTED

xen/arch/arm/Kconfig +1 -1
-       depends on STATIC_MEMORY
+       depends on STATIC_MEMORY && DOM0LESS_BOOT

no need for && DOM0LESS_BOOT

Thanks, yes I was unsure about that indeed

Quoted 10 lines
Quoted 10 lines

help
This option enables statically shared memory on a dom0less system.

xen/common/Kconfig +0 -0
index 4d6fe051641d..e0e5f4485d1f 100644
@@ -100,7 +100,7 @@ config NUMA
 
Quoted 5 lines

xen/common/Kconfig config NUMA · line 103

Quoted 4 lines

config STATIC_MEMORY
bool "Static Allocation Support (UNSUPPORTED)" if UNSUPPORTED

xen/common/Kconfig +1 -1
-       depends on ARM
+       depends on ARM && DOM0LESS_BOOT

no need for ARM. DOM0LESS_BOOT already depends on ARM.

Ok, I’ll update it

Quoted 3 lines

~Michal