[PATCH v1 4/9] asm-generic: move Arm's static-memory.h to asm-generic

Oleksii Kurochko posted 9 patches 11 months, 2 weeks ago
There is a newer version of this series
[PATCH v1 4/9] asm-generic: move Arm's static-memory.h to asm-generic
Posted by Oleksii Kurochko 11 months, 2 weeks ago
Except moving Arm's static-memory.h to asm-generic #ifdef header guard
is updated: s/__ASM_STATIC_MEMORY_H_/__ASM_GENERIC_STATIC_MEMORY_H__.

Update arm/include/asm/Makefile to use asm-generic version of
static-memory.h for Arm.

Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
---
 xen/arch/arm/include/asm/Makefile        |  1 +
 xen/arch/arm/include/asm/static-memory.h | 58 ------------------------
 xen/include/asm-generic/static-memory.h  | 58 ++++++++++++++++++++++++
 3 files changed, 59 insertions(+), 58 deletions(-)
 delete mode 100644 xen/arch/arm/include/asm/static-memory.h
 create mode 100644 xen/include/asm-generic/static-memory.h

diff --git a/xen/arch/arm/include/asm/Makefile b/xen/arch/arm/include/asm/Makefile
index 831c914cce..ac8208a81f 100644
--- a/xen/arch/arm/include/asm/Makefile
+++ b/xen/arch/arm/include/asm/Makefile
@@ -8,4 +8,5 @@ generic-y += paging.h
 generic-y += percpu.h
 generic-y += random.h
 generic-y += softirq.h
+generic-y += static-memory.h
 generic-y += vm_event.h
diff --git a/xen/arch/arm/include/asm/static-memory.h b/xen/arch/arm/include/asm/static-memory.h
deleted file mode 100644
index 804166e541..0000000000
--- a/xen/arch/arm/include/asm/static-memory.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-
-#ifndef __ASM_STATIC_MEMORY_H_
-#define __ASM_STATIC_MEMORY_H_
-
-#include <xen/pfn.h>
-#include <asm/kernel.h>
-
-#ifdef CONFIG_STATIC_MEMORY
-
-static inline void init_staticmem_bank(const struct membank *bank)
-{
-    mfn_t bank_start = _mfn(PFN_UP(bank->start));
-    unsigned long bank_pages = PFN_DOWN(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);
-}
-
-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);
-void init_staticmem_pages(void);
-
-#else /* !CONFIG_STATIC_MEMORY */
-
-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();
-}
-
-static inline void init_staticmem_pages(void) {};
-
-#endif /* CONFIG_STATIC_MEMORY */
-
-#endif /* __ASM_STATIC_MEMORY_H_ */
-
-/*
- * Local variables:
- * mode: C
- * c-file-style: "BSD"
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- */
diff --git a/xen/include/asm-generic/static-memory.h b/xen/include/asm-generic/static-memory.h
new file mode 100644
index 0000000000..43b8740d46
--- /dev/null
+++ b/xen/include/asm-generic/static-memory.h
@@ -0,0 +1,58 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef __ASM_GENERIC_STATIC_MEMORY_H__
+#define __ASM_GENERIC_STATIC_MEMORY_H__
+
+#include <xen/pfn.h>
+#include <asm/kernel.h>
+
+#ifdef CONFIG_STATIC_MEMORY
+
+static inline void init_staticmem_bank(const struct membank *bank)
+{
+    mfn_t bank_start = _mfn(PFN_UP(bank->start));
+    unsigned long bank_pages = PFN_DOWN(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);
+}
+
+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);
+void init_staticmem_pages(void);
+
+#else /* !CONFIG_STATIC_MEMORY */
+
+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();
+}
+
+static inline void init_staticmem_pages(void) {};
+
+#endif /* CONFIG_STATIC_MEMORY */
+
+#endif /* __ASM_GENERIC_STATIC_MEMORY_H__ */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
-- 
2.47.1
Re: [PATCH v1 4/9] asm-generic: move Arm's static-memory.h to asm-generic
Posted by Jan Beulich 10 months, 3 weeks ago
On 08.01.2025 12:13, Oleksii Kurochko wrote:
> Except moving Arm's static-memory.h to asm-generic #ifdef header guard
> is updated: s/__ASM_STATIC_MEMORY_H_/__ASM_GENERIC_STATIC_MEMORY_H__.
> 
> Update arm/include/asm/Makefile to use asm-generic version of
> static-memory.h for Arm.
> 
> Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>

Here as well as in patch 5 the "why" is again missing. Moving is fine, as
long as it's clear that this will actually be used by another arch (e.g.
RISC-V). Whether you have such (immediate or at least near term) plans is
unclear though, as both features look like relatively advanced ones, and
hence more basic functionality may want to appear first in RISC-V.

Jan
Re: [PATCH v1 4/9] asm-generic: move Arm's static-memory.h to asm-generic
Posted by Oleksii Kurochko 10 months, 2 weeks ago
On 1/27/25 12:19 PM, Jan Beulich wrote:
> On 08.01.2025 12:13, Oleksii Kurochko wrote:
>> Except moving Arm's static-memory.h to asm-generic #ifdef header guard
>> is updated: s/__ASM_STATIC_MEMORY_H_/__ASM_GENERIC_STATIC_MEMORY_H__.
>>
>> Update arm/include/asm/Makefile to use asm-generic version of
>> static-memory.h for Arm.
>>
>> Signed-off-by: Oleksii Kurochko<oleksii.kurochko@gmail.com>
> Here as well as in patch 5 the "why" is again missing. Moving is fine, as
> long as it's clear that this will actually be used by another arch (e.g.
> RISC-V). Whether you have such (immediate or at least near term) plans is
> unclear though, as both features look like relatively advanced ones, and
> hence more basic functionality may want to appear first in RISC-V.

The reason is that suggested generic dom0less solution is using allocate_static_memory() and
assign_static_memory_11() so I decided that it would be better to have stubs for them in
asm-generic header that wrapping by the code by "#ifdef CONFIG_STATIC_MEMORY" the places where
it is used.
But considering the status of RISC-V's Xen downstream and I still don't have cases where CONFIG_STATIC_MEMORY
is used for RISC-V, probably, it would be better just to use wrapping in generic code instead of
stubs.

~ Oleksii