Skip to contentSkip to conversation

Introduce generic headers

PATCH Superseded Oleksii Kurochko 2 participants 47 messages Nov 10, 2023 – Nov 17, 2023

v2 of 9 Superseded Latest is v9 →

lore
Share & tools
lore
#0 lore raw

v2 cover Introduce generic headers

Some headers are common between several architectures, so the current patch series provide them.

Another one reason to have them as generic is a simplification of adding support necessary to make a complete Xen build as it was/is being done in the patch series [1] and [2].

Also, instead of providing generic/stub headers, it was used "#ifdef CONFIG_* #include <asm/*.h> #endif" instead of providing empty headers.

Some headers are still arguable if they should be in asm-generic, and it wasn't a response so I decided to leave headers for now and made some updates for them.

Some patches related to delay.h, pci.h and xenoprof.h were sent as separate patches: [3], [4] and [5].

[1] https://lore.kernel.org/xen-devel/[email protected]/
[2] https://lore.kernel.org/xen-devel/[email protected]/
[3] https://lore.kernel.org/xen-devel/3d55bce44bd6ab9973cbe0ea2fc136cc44d35df2.1698759633.git.oleksii.kurochko@gmail.com/
[4] https://lore.kernel.org/xen-devel/[email protected]/T/#t
[5] https://gitlab.com/xen-project/xen/-/commit/ad193a79c25ae24f1de5f37900e1da74ab48e8bd

---
Changes in V2:
- Update the commit message of the cover letter.
- Drop the following patches because they are arch-specific or was sent as a separate patch:
- xen/asm-generic: introduce stub header event.h
- xen/asm-generic: introduce stub header spinlock.h
- [PATCH v1 03/29] xen/asm-generic: introduce stub header cpufeature.h
- [PATCH v1 07/29] xen/asm-generic: introduce stub header guest_atomics.h
- [PATCH v1 10/29] xen/asm-generic: introduce stub header iommu.h
- [PATCH v1 12/29] xen/asm-generic: introduce stub header pci.h because separate patch was sent [5]
- [PATCH v1 14/29] xen/asm-generic: introduce stub header setup.h
- [PATCH v1 15/29] xen/asm-generic: introduce stub header xenoprof.h because of [3].
- [PATCH v1 16/29] xen/asm-generic: introduce stub header flushtlb.h
- [PATCH v1 22/29] xen/asm-generic: introduce stub header delay.h because of [3]
- [PATCH v1 23/29] xen/asm-generic: introduce stub header domain.h
- [PATCH v1 24/29] xen/asm-generic: introduce stub header guest_access.h
- [PATCH v1 25/29] xen/asm-generic: introduce stub header irq.h ( probably not so generic as I expected, I'll back to it if it will be necessary in the future )
- [PATCH v1 28/29] xen/asm-generic: introduce stub header p2m.h ( probably not so generic as I expected, I'll back to it if it will be necessary in the future )
- For the rest of the patches please look at changes for each patch separately.

Oleksii Kurochko (15):
xen/asm-generic: introduce stub header paging.h xen/asm-generic: introduce generic device.h
xen: ifdef inclusion of <asm/grant_table.h> in <xen/grant_table.h> xen/asm-generic: introduce generic hypercall.h xen/asm-generic: introduce generic header iocap.h xen/asm-generic: ifdef inclusion of <asm/mem_access.h> xen/asm-generic: introduce stub header <asm/random.h> xen/asm-generic: introduce generic header percpu.h xen/asm-generic: introduce generic header smp.h xen/asm-generic: introduce generalized hardirq.h xen/asm-generic: introduce generic div64.h header xen/asm-generic: introduce generic header altp2m.h xen/asm-generic: introduce stub header monitor.h xen/asm-generic: introduce stub header numa.h xen/asm-generic: introduce stub header softirq.h

 xen/arch/arm/include/asm/Makefile   |   1 +
 xen/arch/arm/include/asm/paging.h   |  16 ----
 xen/arch/ppc/include/asm/Makefile   |   1 +
 xen/arch/ppc/include/asm/paging.h   |   7 --
 xen/include/asm-generic/altp2m.h    |  34 +++++++
 xen/include/asm-generic/device.h    | 140 ++++++++++++++++++++++++++++
 xen/include/asm-generic/div64.h     |  27 ++++++
 xen/include/asm-generic/hardirq.h   |  29 ++++++
 xen/include/asm-generic/hypercall.h |  18 ++++
 xen/include/asm-generic/iocap.h     |  17 ++++
 xen/include/asm-generic/monitor.h   |  62 ++++++++++++
 xen/include/asm-generic/numa.h      |  40 ++++++++
 xen/include/asm-generic/paging.h    |  19 ++++
 xen/include/asm-generic/percpu.h    |  35 +++++++
 xen/include/asm-generic/random.h    |  20 ++++
 xen/include/asm-generic/smp.h       |  28 ++++++
 xen/include/asm-generic/softirq.h   |  17 ++++
 xen/include/xen/grant_table.h       |   3 +
 xen/include/xen/mem_access.h        |   2 +
 19 files changed, 493 insertions(+), 23 deletions(-)
 delete mode 100644 xen/arch/arm/include/asm/paging.h
 delete mode 100644 xen/arch/ppc/include/asm/paging.h
 create mode 100644 xen/include/asm-generic/altp2m.h
 create mode 100644 xen/include/asm-generic/device.h
 create mode 100644 xen/include/asm-generic/div64.h
 create mode 100644 xen/include/asm-generic/hardirq.h
 create mode 100644 xen/include/asm-generic/hypercall.h
 create mode 100644 xen/include/asm-generic/iocap.h
 create mode 100644 xen/include/asm-generic/monitor.h
 create mode 100644 xen/include/asm-generic/numa.h
 create mode 100644 xen/include/asm-generic/paging.h
 create mode 100644 xen/include/asm-generic/percpu.h
 create mode 100644 xen/include/asm-generic/random.h
 create mode 100644 xen/include/asm-generic/smp.h
 create mode 100644 xen/include/asm-generic/softirq.h
Signature · 1 line
2.41.0
#1 lore raw

PATCH v2 1/15 xen/asm-generic: introduce stub header paging.h

The patch introduces generic paging.h header for Arm, PPC and RISC-V.

All mentioned above architectures use hardware virt extensions and hardware pagetable extensions thereby it makes sense to set paging_mode_translate and paging_mode_external by default.

Also in this patch Arm and PPC architectures are switched to generic paging.h header.

---
Changes in V2:
- evaluate argument of macros
- covert macros to true
- use proper tabs
- switch Arm & PPC to generic paging.h
- update commit message

---
 xen/arch/arm/include/asm/Makefile |  1 +
 xen/arch/arm/include/asm/paging.h | 16 ----------------
 xen/arch/ppc/include/asm/Makefile |  1 +
 xen/arch/ppc/include/asm/paging.h |  7 -------
 xen/include/asm-generic/paging.h  | 19 +++++++++++++++++++
 5 files changed, 21 insertions(+), 23 deletions(-)
 delete mode 100644 xen/arch/arm/include/asm/paging.h
 delete mode 100644 xen/arch/ppc/include/asm/paging.h
 create mode 100644 xen/include/asm-generic/paging.h
xen/arch/arm/include/asm/Makefile +1 -0
index 821addb0bf..2128bb015f 100644
@@ -1,2 +1,3 @@
 # SPDX-License-Identifier: GPL-2.0-only
 generic-y += vm_event.h
+generic-y += paging.h
xen/arch/arm/include/asm/paging.h deleted +0 -16
deleted file mode 100644
index 6d1a000246..0000000000
@@ -1,16 +0,0 @@
-#ifndef _XEN_PAGING_H
-#define _XEN_PAGING_H
-
-#define paging_mode_translate(d)              (1)
-#define paging_mode_external(d)               (1)
-
-#endif /* XEN_PAGING_H */
-
-/*
- * Local variables:
- * mode: C
- * c-file-style: "BSD"
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- */
xen/arch/ppc/include/asm/Makefile +1 -0
index 821addb0bf..2128bb015f 100644
@@ -1,2 +1,3 @@
 # SPDX-License-Identifier: GPL-2.0-only
 generic-y += vm_event.h
+generic-y += paging.h
xen/arch/ppc/include/asm/paging.h deleted +0 -7
deleted file mode 100644
index eccacece29..0000000000
@@ -1,7 +0,0 @@
-#ifndef __ASM_PPC_PAGING_H__
-#define __ASM_PPC_PAGING_H__
-
-#define paging_mode_translate(d)              (1)
-#define paging_mode_external(d)               (1)
-
-#endif /* __ASM_PPC_PAGING_H__ */
xen/include/asm-generic/paging.h new file +19 -0
new file mode 100644
index 0000000000..8df534cfdc
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __ASM_GENERIC_PAGING_H__
+#define __ASM_GENERIC_PAGING_H__
+
+#include <xen/stdbool.h>
+
+#define paging_mode_translate(d)    ((void)(d), true)
+#define paging_mode_external(d)     ((void)(d), true)
+
+#endif /* __ASM_GENERIC_PAGING_H__ */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
Signature · 1 line
2.41.0
#3 lore raw

PATCH v2 2/15 xen/asm-generic: introduce generic device.h

In reply to Oleksii Kurochko

Arm, PPC and RISC-V use the same device.h thereby device.h was moved to asm-generic. Arm's device.h was taken as a base with the following changes:
- #ifdef PCI related things.
- #ifdef ACPI related things.
- Rename #ifdef guards.
- Add SPDX tag.

---
It is still open question if device.h should be in asm-generic. Need more opinions.

Changes in V2:
- take ( as common ) device.h from Arm as PPC and RISC-V use it as a base.
- #ifdef PCI related things.
- #ifdef ACPI related things.
- rename DEVICE_GIC to DEVIC_IC.
- rename #ifdef guards.
- switch Arm and PPC to generic device.h
- add SPDX tag
- update the commit message

---
 xen/include/asm-generic/device.h | 140 +++++++++++++++++++++++++++++++
 1 file changed, 140 insertions(+)
 create mode 100644 xen/include/asm-generic/device.h
xen/include/asm-generic/device.h new file +140 -0
new file mode 100644
index 0000000000..5478fc11ca
@@ -0,0 +1,140 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __ASM_GENERIC_DEVICE_H__
+#define __ASM_GENERIC_DEVICE_H__
+
+enum device_type
+{
+    DEV_DT,
+#ifdef HAS_PCI
+    DEV_PCI,
+#endif
+};
+
+struct dev_archdata {
+    void *iommu;    /* IOMMU private data */
+};
+
+/* struct device - The basic device structure */
+struct device
+{
+    enum device_type type;
+#ifdef CONFIG_HAS_DEVICE_TREE
+    struct dt_device_node *of_node; /* Used by drivers imported from Linux */
+#endif
+    struct dev_archdata archdata;
+    struct iommu_fwspec *iommu_fwspec; /* per-device IOMMU instance data */
+};
+
+typedef struct device device_t;
+
+#include <xen/device_tree.h>
+
+#ifdef HAS_PCI
+#define dev_is_pci(dev) ((dev)->type == DEV_PCI)
+#endif
+
+#define dev_is_dt(dev)  ((dev)->type == DEV_DT)
+
+enum device_class
+{
+    DEVICE_SERIAL,
+    DEVICE_IOMMU,
+    DEVICE_IC,
+#ifdef HAS_PCI
+    DEVICE_PCI_HOSTBRIDGE,
+#endif
+    /* Use for error */
+    DEVICE_UNKNOWN,
+};
+
+struct device_desc {
+    /* Device name */
+    const char *name;
+    /* Device class */
+    enum device_class class;
+    /* List of devices supported by this driver */
+    const struct dt_device_match *dt_match;
+    /*
+     * Device initialization.
+     *
+     * -EAGAIN is used to indicate that device probing is deferred.
+     */
+    int (*init)(struct dt_device_node *dev, const void *data);
+};
+
+#ifdef CONFIG_ACPI
+
+struct acpi_device_desc {
+    /* Device name */
+    const char *name;
+    /* Device class */
+    enum device_class class;
+    /* type of device supported by the driver */
+    const int class_type;
+    /* Device initialization */
+    int (*init)(const void *data);
+};
+
+/**
+ *  acpi_device_init - Initialize a device
+ *  @class: class of the device (serial, network...)
+ *  @data: specific data for initializing the device
+ *
+ *  Return 0 on success.
+ */
+int acpi_device_init(enum device_class class,
+                     const void *data, int class_type);
+
+#endif /* CONFIG_ACPI */
+
+/**
+ *  device_init - Initialize a device
+ *  @dev: device to initialize
+ *  @class: class of the device (serial, network...)
+ *  @data: specific data for initializing the device
+ *
+ *  Return 0 on success.
+ */
+int device_init(struct dt_device_node *dev, enum device_class class,
+                const void *data);
+
+/**
+ * device_get_type - Get the type of the device
+ * @dev: device to match
+ *
+ * Return the device type on success or DEVICE_ANY on failure
+ */
+enum device_class device_get_class(const struct dt_device_node *dev);
+
+#define DT_DEVICE_START(_name, _namestr, _class)                    \
+static const struct device_desc __dev_desc_##_name __used           \
+__section(".dev.info") = {                                          \
+    .name = _namestr,                                               \
+    .class = _class,                                                \
+
+#define DT_DEVICE_END                                               \
+};
+
+#ifdef CONFIG_ACPI
+
+#define ACPI_DEVICE_START(_name, _namestr, _class)                    \
+static const struct acpi_device_desc __dev_desc_##_name __used           \
+__section(".adev.info") = {                       \
+    .name = _namestr,                                               \
+    .class = _class,                                                \
+
+#define ACPI_DEVICE_END                                               \
+};
+
+#endif /* CONFIG_ACPI */
+
+#endif /* __ASM_GENERIC_DEVICE_H__ */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
Signature · 1 line
2.41.0
#11 lore raw

PATCH v2 4/15 xen/asm-generic: introduce generic hypercall.h

In reply to Oleksii Kurochko

Introduce an empty generic hypercall.h for archs which don't implement it.

---
Changes in V2:
- add check that <asm/hypercall.h> isn't included directly.

---
 xen/include/asm-generic/hypercall.h | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
 create mode 100644 xen/include/asm-generic/hypercall.h
xen/include/asm-generic/hypercall.h new file +18 -0
new file mode 100644
index 0000000000..7743b35c0d
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __XEN_HYPERCALL_H__
+#error "asm/hypercall.h should not be included directly - include xen/hypercall.h instead"
+#endif
+
+#ifndef __ASM_GENERIC_HYPERCALL_H__
+#define __ASM_GENERIC_HYPERCALL_H__
+
+#endif /* __ASM_GENERIC_HYPERCALL_H__ */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
Signature · 1 line
2.41.0
#15 lore raw

PATCH v2 5/15 xen/asm-generic: introduce generic header iocap.h

In reply to Oleksii Kurochko

iocap.h is common for Arm, PPC and RISC-V architectures thereby it was moved to asm-generic.

---
The same question as with device.h. Should it be in asm-generic?

Changes in V2:
- update the commit message

---
 xen/include/asm-generic/iocap.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 xen/include/asm-generic/iocap.h
xen/include/asm-generic/iocap.h new file +17 -0
new file mode 100644
index 0000000000..dd7cb45488
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __ASM_GENERIC_IOCAP_H__
+#define __ASM_GENERIC_IOCAP_H__
+
+#define cache_flush_permitted(d)                        \
+    (!rangeset_is_empty((d)->iomem_caps))
+
+#endif /* __ASM_GENERIC_IOCAP_H__ */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
Signature · 1 line
2.41.0
#18 lore raw

PATCH v2 6/15 xen/asm-generic: ifdef inclusion of <asm/mem_access.h>

In reply to Oleksii Kurochko

ifdefing inclusion of <asm/mem_access.h> in <xen/mem_access.h> allows to avoid generation of empty <asm/mem_access.h> header for the case when !CONFIG_MEM_ACCESS.

---
Changes in V2:
- add Suggested-by: Jan Beulich <[email protected]>
- update the commit message
- remove <asm-generic/mem_access.h>

---
 xen/include/xen/mem_access.h | 2 ++
 1 file changed, 2 insertions(+)
xen/include/xen/mem_access.h +2 -0
index 4e4811680d..87d93b31f6 100644
@@ -33,7 +33,9 @@
  */
 struct vm_event_st;
 
+#ifdef CONFIG_MEM_ACCESS
 #include <asm/mem_access.h>
+#endif
 
 /*
  * Additional access types, which are used to further restrict
Signature · 1 line
2.41.0
#6 lore raw

PATCH v2 3/15 xen: ifdef inclusion of <asm/grant_table.h> in <xen/grant_table.h>

In reply to Oleksii Kurochko

Ifdefing inclusion of <asm/grant_table.h> allows to avoid generation of empty <asm/grant_table.h> for cases when CONFIG_GRANT_TABLE is not enabled.

---
Changes in V2:
- ifdef inclusion of asm/grant_table.h in xen/grant_table.h to avoid generation of empty headers for PPC and RISC-V archs.
- update commit message
- add Suggested-by: Jan Beulich <[email protected]>
- Remove provided before asm-generic/grant_table.h header.

---
 xen/include/xen/grant_table.h | 3 +++
 1 file changed, 3 insertions(+)
xen/include/xen/grant_table.h +3 -0
index 85fe6b7b5e..50edfecfb6 100644
@@ -26,7 +26,10 @@
 #include <xen/mm-frame.h>
 #include <xen/rwlock.h>
 #include <public/grant_table.h>
+
+#ifdef CONFIG_GRANT_TABLE
 #include <asm/grant_table.h>
+#endif
 
 struct grant_table;
 
Signature · 1 line
2.41.0
#32 lore raw

PATCH v2 9/15 xen/asm-generic: introduce generic header smp.h

In reply to Oleksii Kurochko

<asm/smp.h> is expcted to be generic between Arm, PPC and RISC-V there by it is moved to asm-generic.

Right now it is common only by PPC and RISC-V but during work on support of the mentioned arhcs <asm/smp.h> is expected to be the same.

---
Changes in V2:
- drop #ifded ASSEMBLY as this header isn't expected to be included in asm files.
- update the commit message.

---
 xen/include/asm-generic/smp.h | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
 create mode 100644 xen/include/asm-generic/smp.h
xen/include/asm-generic/smp.h new file +28 -0
new file mode 100644
index 0000000000..6740a2064c
@@ -0,0 +1,28 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __ASM_GENERIC_SMP_H
+#define __ASM_GENERIC_SMP_H
+
+#include <xen/cpumask.h>
+#include <xen/percpu.h>
+
+DECLARE_PER_CPU(cpumask_var_t, cpu_sibling_mask);
+DECLARE_PER_CPU(cpumask_var_t, cpu_core_mask);
+
+#define cpu_is_offline(cpu) unlikely(!cpu_online(cpu))
+
+/*
+ * Do we, for platform reasons, need to actually keep CPUs online when we
+ * would otherwise prefer them to be off?
+ */
+#define park_offline_cpus false
+
+#endif
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: BSD
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
Signature · 1 line
2.41.0
#26 lore raw

PATCH v2 8/15 xen/asm-generic: introduce generic header percpu.h

In reply to Oleksii Kurochko

---
Changes in V2:
- use smp_processor_id() instead of get_processor_id().
- update commit message .

---
 xen/include/asm-generic/percpu.h | 35 ++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
 create mode 100644 xen/include/asm-generic/percpu.h
xen/include/asm-generic/percpu.h new file +35 -0
new file mode 100644
index 0000000000..85a3f3ef17
@@ -0,0 +1,35 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __ASM_GENERIC_PERCPU_H__
+#define __ASM_GENERIC_PERCPU_H__
+
+#ifndef __ASSEMBLY__
+
+#include <xen/types.h>
+
+extern char __per_cpu_start[], __per_cpu_data_end[];
+extern unsigned long __per_cpu_offset[NR_CPUS];
+void percpu_init_areas(void);
+
+#define per_cpu(var, cpu)  \
+    (*RELOC_HIDE(&per_cpu__##var, __per_cpu_offset[cpu]))
+
+#define this_cpu(var) \
+    (*RELOC_HIDE(&per_cpu__##var, __per_cpu_offset[smp_processor_id()]))
+
+#define per_cpu_ptr(var, cpu)  \
+    (*RELOC_HIDE(var, __per_cpu_offset[cpu]))
+#define this_cpu_ptr(var) \
+    (*RELOC_HIDE(var, smp_processor_id()))
+
+#endif
+
+#endif /* __ASM_GENERIC_PERCPU_H__ */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
Signature · 1 line
2.41.0
#34 lore raw

PATCH v2 10/15 xen/asm-generic: introduce generalized hardirq.h

In reply to Oleksii Kurochko

<asm/hardirq.h> is common through archs thereby it is moved to asm-generic.

---
Changes in V2:
- add #include <xen/cache.h>.
- update the commit message

---
 xen/include/asm-generic/hardirq.h | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
 create mode 100644 xen/include/asm-generic/hardirq.h
xen/include/asm-generic/hardirq.h new file +29 -0
new file mode 100644
index 0000000000..ddccf460b9
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __ASM_GENERIC_HARDIRQ_H
+#define __ASM_GENERIC_HARDIRQ_H
+
+#include <xen/cache.h>
+#include <xen/smp.h>
+
+typedef struct {
+        unsigned long __softirq_pending;
+        unsigned int __local_irq_count;
+} __cacheline_aligned irq_cpustat_t;
+
+#include <xen/irq_cpustat.h>    /* Standard mappings for irq_cpustat_t above */
+
+#define in_irq() (local_irq_count(smp_processor_id()) != 0)
+
+#define irq_enter()     (local_irq_count(smp_processor_id())++)
+#define irq_exit()      (local_irq_count(smp_processor_id())--)
+
+#endif /* __ASM_GENERIC_HARDIRQ_H */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
Signature · 1 line
2.41.0
#22 lore raw

PATCH v2 7/15 xen/asm-generic: introduce stub header <asm/random.h>

In reply to Oleksii Kurochko

<asm/random.h> is common for Arm, PPC and RISC-V thereby it is moved to asm-generic.

---
Changes in V2:
- update the commit messages

---
 xen/include/asm-generic/random.h | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
 create mode 100644 xen/include/asm-generic/random.h
xen/include/asm-generic/random.h new file +20 -0
new file mode 100644
index 0000000000..cd2307e70b
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __ASM_GENERIC_RANDOM_H__
+#define __ASM_GENERIC_RANDOM_H__
+
+static inline unsigned int arch_get_random(void)
+{
+    return 0;
+}
+
+#endif /* __ASM_GENERIC_RANDOM_H__ */
+
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: BSD
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
Signature · 1 line
2.41.0
#37 lore raw

PATCH v2 13/15 xen/asm-generic: introduce stub header monitor.h

In reply to Oleksii Kurochko

The header is shared between archs so it is moved to asm-generic.

---
Changes in V2:
- remove inclusion of "+#include <public/domctl.h>"
- add "struct xen_domctl_monitor_op;"
- remove one of SPDX tags.

---
 xen/include/asm-generic/monitor.h | 62 +++++++++++++++++++++++++++++++
 1 file changed, 62 insertions(+)
 create mode 100644 xen/include/asm-generic/monitor.h
xen/include/asm-generic/monitor.h new file +62 -0
new file mode 100644
index 0000000000..4e46f2e91a
@@ -0,0 +1,62 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * include/asm-GENERIC/monitor.h
+ *
+ * Arch-specific monitor_op domctl handler.
+ *
+ * Copyright (c) 2015 Tamas K Lengyel ([email protected])
+ * Copyright (c) 2016, Bitdefender S.R.L.
+ *
+ */
+
+#ifndef __ASM_GENERIC_MONITOR_H__
+#define __ASM_GENERIC_MONITOR_H__
+
+#include <xen/sched.h>
+
+struct xen_domctl_monitor_op;
+
+static inline
+void arch_monitor_allow_userspace(struct domain *d, bool allow_userspace)
+{
+}
+
+static inline
+int arch_monitor_domctl_op(struct domain *d, struct xen_domctl_monitor_op *mop)
+{
+    /* No arch-specific monitor ops on GENERIC. */
+    return -EOPNOTSUPP;
+}
+
+int arch_monitor_domctl_event(struct domain *d,
+                              struct xen_domctl_monitor_op *mop);
+
+static inline
+int arch_monitor_init_domain(struct domain *d)
+{
+    /* No arch-specific domain initialization on GENERIC. */
+    return 0;
+}
+
+static inline
+void arch_monitor_cleanup_domain(struct domain *d)
+{
+    /* No arch-specific domain cleanup on GENERIC. */
+}
+
+static inline uint32_t arch_monitor_get_capabilities(struct domain *d)
+{
+    return 0;
+}
+
+#endif /* __ASM_GENERIC_MONITOR_H__ */
+
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: BSD
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
Signature · 1 line
2.41.0
#42 lore raw

PATCH v2 14/15 xen/asm-generic: introduce stub header numa.h

In reply to Oleksii Kurochko

<asm/numa.h> is common through some archs so it is moved to asm-generic.

---
Changes in V2:
- update the commit message.
- change u8 to uint8_t.
- add ifnded CONFIG_NUMA.

---
 xen/include/asm-generic/numa.h | 40 ++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)
 create mode 100644 xen/include/asm-generic/numa.h
xen/include/asm-generic/numa.h new file +40 -0
new file mode 100644
index 0000000000..353642c353
@@ -0,0 +1,40 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __ARCH_GENERIC_NUMA_H
+#define __ARCH_GENERIC_NUMA_H
+
+#include <xen/types.h>
+#include <xen/mm.h>
+
+typedef uint8_t nodeid_t;
+
+#ifndef CONFIG_NUMA
+
+/* Fake one node for now. See also node_online_map. */
+#define cpu_to_node(cpu) 0
+#define node_to_cpumask(node)   (cpu_online_map)
+
+/*
+ * TODO: make first_valid_mfn static when NUMA is supported on Arm, this
+ * is required because the dummy helpers are using it.
+ */
+extern mfn_t first_valid_mfn;
+
+/* XXX: implement NUMA support */
+#define node_spanned_pages(nid) (max_page - mfn_x(first_valid_mfn))
+#define node_start_pfn(nid) (mfn_x(first_valid_mfn))
+#define __node_distance(a, b) (20)
+
+#endif
+
+#define arch_want_default_dmazone() (false)
+
+#endif /* __ARCH_GENERIC_NUMA_H */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
Signature · 1 line
2.41.0
#35 lore raw

PATCH v2 11/15 xen/asm-generic: introduce generic div64.h header

In reply to Oleksii Kurochko

All archs have the do_div implementation for BITS_PER_LONG == 64 so do_div64.h is moved to asm-generic.

The patch introduces header stub necessry for full Xen build.

---
Changes in V2:
- rename base to divisor
- add "#if BITS_PER_LONG == 64"
- fix code style

---
 xen/include/asm-generic/div64.h | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
 create mode 100644 xen/include/asm-generic/div64.h
xen/include/asm-generic/div64.h new file +27 -0
new file mode 100644
index 0000000000..068d8a11ad
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __ASM_GENERIC_DIV64
+#define __ASM_GENERIC_DIV64
+
+#include <xen/types.h>
+
+#if BITS_PER_LONG == 64
+
+#define do_div(n, divisor) ({                   \
+    uint32_t divisor_ = (divisor);              \
+    uint32_t rem_ = (uint64_t)(n) % divisor_;   \
+    (n) = (uint64_t)(n) / divisor_;             \
+    rem_;                                       \
+})
+
+#endif /* BITS_PER_LONG */
+
+#endif
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
Signature · 1 line
2.41.0
#36 lore raw

PATCH v2 12/15 xen/asm-generic: introduce generic header altp2m.h

In reply to Oleksii Kurochko

<asm/alt2pm.h> is common between archs so it is moved to asm-generic.

---
Changes in V2:
- change uint16_t to unsigned int in declaration of altp2m_vcpu_idx
- update the commit message

---
 xen/include/asm-generic/altp2m.h | 34 ++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
 create mode 100644 xen/include/asm-generic/altp2m.h
xen/include/asm-generic/altp2m.h new file +34 -0
new file mode 100644
index 0000000000..39865a842a
@@ -0,0 +1,34 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __ASM_GENERIC_ALTP2M_H
+#define __ASM_GENERIC_ALTP2M_H
+
+#include <xen/bug.h>
+
+struct domain;
+struct vcpu;
+
+/* Alternate p2m on/off per domain */
+static inline bool altp2m_active(const struct domain *d)
+{
+    /* Not implemented on GENERIC. */
+    return false;
+}
+
+/* Alternate p2m VCPU */
+static inline unsigned int altp2m_vcpu_idx(const struct vcpu *v)
+{
+    /* Not implemented on GENERIC, should not be reached. */
+    BUG();
+    return 0;
+}
+
+#endif /* __ASM_GENERIC_ALTP2M_H */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: BSD
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
Signature · 1 line
2.41.0
#46 lore raw

PATCH v2 15/15 xen/asm-generic: introduce stub header softirq.h

In reply to Oleksii Kurochko

<asm/softirq.h> is common between Arm, PPC and RISC-V so it is moved to asm-generic.

---
Changes in V2:
- update the commit message.

---
 xen/include/asm-generic/softirq.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 xen/include/asm-generic/softirq.h
xen/include/asm-generic/softirq.h new file +17 -0
new file mode 100644
index 0000000000..83be855e50
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __ASM_GENERIC_SOFTIRQ_H__
+#define __ASM_GENERIC_SOFTIRQ_H__
+
+#define NR_ARCH_SOFTIRQS       0
+
+#define arch_skip_send_event_check(cpu) 0
+
+#endif /* __ASM_GENERIC_SOFTIRQ_H__ */
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
Signature · 1 line
2.41.0
author
#19 lore raw

Re: [PATCH v2 06/15] xen/asm-generic: ifdef inclusion of <asm/mem_access.h>

In reply to Oleksii Kurochko

This patch should be reworked as it fails Arm builds:
https://gitlab.com/xen-project/people/olkur/xen/-/pipelines/1068867920

It looks like it is not possible just to #ifdef CONFIG_MEM_ACCESS.

An empty asm-generic mem_access.h will be better solution.

Could you please share your opinion?

~ Oleksii

Quoted 30 lines · Oleksii Kurochko

ifdefing inclusion of <asm/mem_access.h> in <xen/mem_access.h> allows to avoid generation of empty <asm/mem_access.h> header for the case when !CONFIG_MEM_ACCESS.

---
Changes in V2:
        - add Suggested-by: Jan Beulich <[email protected]>
        - update the commit message
        - remove <asm-generic/mem_access.h>
---
 xen/include/xen/mem_access.h | 2 ++

 1 file changed, 2 insertions(+)
xen/include/xen/mem_access.h +0 -0
index 4e4811680d..87d93b31f6 100644
@@ -33,7 +33,9 @@
   */
  struct vm_event_st;


+#ifdef CONFIG_MEM_ACCESS
 #include <asm/mem_access.h>
+#endif

 /*
  * Additional access types, which are used to further restrict

author
#7 lore raw

Re: [PATCH v2 03/15] xen: ifdef inclusion of <asm/grant_table.h> in <xen/grant_table.h>

In reply to Oleksii Kurochko

I missed to check the patch properly.

The patch fails for Arm randconfigs:
https://gitlab.com/xen-project/people/olkur/xen/-/pipelines/1068865674

I need to do an additional investigation.

Does it make sense to re-send this patch separately out of this patch series?

~ Oleksii

Quoted 34 lines · Oleksii Kurochko

Ifdefing inclusion of <asm/grant_table.h> allows to avoid generation of empty <asm/grant_table.h> for cases when CONFIG_GRANT_TABLE is not enabled.

---
Changes in V2:
        - ifdef inclusion of asm/grant_table.h in xen/grant_table.h to avoid
          generation of empty headers for PPC and RISC-V archs.
        - update commit message
        - add Suggested-by: Jan Beulich <[email protected]>
        - Remove provided before asm-generic/grant_table.h header.
---
 xen/include/xen/grant_table.h | 3 +++

 1 file changed, 3 insertions(+)
xen/include/xen/grant_table.h +3 -0
index 85fe6b7b5e..50edfecfb6 100644
@@ -26,7 +26,10 @@
  #include <xen/mm-frame.h>
  #include <xen/rwlock.h>
  #include <public/grant_table.h>
+
+#ifdef CONFIG_GRANT_TABLE
  #include <asm/grant_table.h>
+#endif


 struct grant_table;

author
#8 lore raw

Re: [PATCH v2 03/15] xen: ifdef inclusion of <asm/grant_table.h> in <xen/grant_table.h>

Quoted 6 lines · Oleksii

I missed to check the patch properly.

The patch fails for Arm randconfigs:
https://gitlab.com/xen-project/people/olkur/xen/-/pipelines/1068865674

I need to do an additional investigation.

So the only one macro cause compile issue if move it to xen/grant_table.h compilation will pass:

xen/include/xen/grant_table.h +13 -0
@@ -23,10 +23,14 @@
 #ifndef __XEN_GRANT_TABLE_H__
 #define __XEN_GRANT_TABLE_H__
 
+#include <xen/kernel.h>
 #include <xen/mm-frame.h>
 #include <xen/rwlock.h>
 #include <public/grant_table.h>
+
+#ifdef CONFIG_GRANT_TABLE
 #include <asm/grant_table.h>
+#endif
 
 struct grant_table;
 
@@ -112,6 +116,16 @@ static inline int gnttab_acquire_resource(
     return -EINVAL;
 }
 
+/*
+ * The region used by Xen on the memory will never be mapped in DOM0
+ * memory layout. Therefore it can be used for the grant table.
+ *
+ * Only use the text section as it's always present and will contain
+ * enough space for a large grant table
+ */
+#define gnttab_dom0_frames()                                         
\
+    min_t(unsigned int, opt_max_grant_frames, PFN_DOWN(_etext -

_stext))
+
#endif /* CONFIG_GRANT_TABLE */

#endif /* __XEN_GRANT_TABLE_H__ */

But gnttab_dom0_frames() is used only for ARM, so probably moving it to <xen/grant_table.h> is not a good idea.

Could you please tell me your opinion? Thanks in advance.

~ Oleksii

Quoted 42 lines

Does it make sense to re-send this patch separately out of this patch series?

~ Oleksii

Quoted 34 lines · Oleksii Kurochko

Ifdefing inclusion of <asm/grant_table.h> allows to avoid generation of empty <asm/grant_table.h> for cases when CONFIG_GRANT_TABLE is not enabled.

---
Changes in V2:
        - ifdef inclusion of asm/grant_table.h in xen/grant_table.h to avoid
          generation of empty headers for PPC and RISC-V archs.
        - update commit message
        - add Suggested-by: Jan Beulich <[email protected]>
        - Remove provided before asm-generic/grant_table.h header.
---
 xen/include/xen/grant_table.h | 3 +++

 1 file changed, 3 insertions(+)
xen/include/xen/grant_table.h +3 -0
index 85fe6b7b5e..50edfecfb6 100644
@@ -26,7 +26,10 @@
  #include <xen/mm-frame.h>
  #include <xen/rwlock.h>
  #include <public/grant_table.h>
+
+#ifdef CONFIG_GRANT_TABLE
  #include <asm/grant_table.h>
+#endif


 struct grant_table;

#9 lore raw

Re: [PATCH v2 03/15] xen: ifdef inclusion of <asm/grant_table.h> in <xen/grant_table.h>

Quoted 45 lines · Oleksii
Quoted 6 lines · Oleksii

I missed to check the patch properly.

The patch fails for Arm randconfigs:
https://gitlab.com/xen-project/people/olkur/xen/-/pipelines/1068865674

I need to do an additional investigation.

So the only one macro cause compile issue if move it to xen/grant_table.h compilation will pass:

xen/include/xen/grant_table.h +14 -0
@@ -23,10 +23,14 @@
 #ifndef __XEN_GRANT_TABLE_H__
 #define __XEN_GRANT_TABLE_H__
 
+#include <xen/kernel.h>
 #include <xen/mm-frame.h>
 #include <xen/rwlock.h>
 #include <public/grant_table.h>
+
+#ifdef CONFIG_GRANT_TABLE
 #include <asm/grant_table.h>
+#endif
 
 struct grant_table;
 
@@ -112,6 +116,16 @@ static inline int gnttab_acquire_resource(
     return -EINVAL;
 }
 
+/*
+ * The region used by Xen on the memory will never be mapped in DOM0
+ * memory layout. Therefore it can be used for the grant table.
+ *
+ * Only use the text section as it's always present and will contain
+ * enough space for a large grant table
+ */
+#define gnttab_dom0_frames()                                         
 \
+    min_t(unsigned int, opt_max_grant_frames, PFN_DOWN(_etext -
 _stext))
+
 #endif /* CONFIG_GRANT_TABLE */
Quoted 5 lines

#endif /* __XEN_GRANT_TABLE_H__ */

But gnttab_dom0_frames() is used only for ARM, so probably moving it to <xen/grant_table.h> is not a good idea.

Indeed. But wouldn't dealing with this again be a matter of having Arm's domain_build.c simply include asm/grant_table.h explicitly, if need be alongside xen/grant_table.h?

Jan

author
#10 lore raw

Re: [PATCH v2 03/15] xen: ifdef inclusion of <asm/grant_table.h> in <xen/grant_table.h>

Quoted 52 lines · Jan Beulich
Quoted 51 lines · Oleksii
Quoted 6 lines · Oleksii

I missed to check the patch properly.

The patch fails for Arm randconfigs:
https://gitlab.com/xen-project/people/olkur/xen/-/pipelines/1068865674

I need to do an additional investigation.

So the only one macro cause compile issue if move it to xen/grant_table.h compilation will pass:

xen/include/xen/grant_table.h +0 -0
@@ -23,10 +23,14 @@
  #ifndef __XEN_GRANT_TABLE_H__
  #define __XEN_GRANT_TABLE_H__


+#include <xen/kernel.h>
 #include <xen/mm-frame.h>
 #include <xen/rwlock.h>
 #include <public/grant_table.h>

xen/include/xen/grant_table.h +2 -0
+
+#ifdef CONFIG_GRANT_TABLE

 #include <asm/grant_table.h>
+#endif

 struct grant_table;

xen/include/xen/grant_table.h +0 -0
@@ -112,6 +116,16 @@ static inline int gnttab_acquire_resource(
      return -EINVAL;
  }


+/*
+ * The region used by Xen on the memory will never be mapped in DOM0
+ * memory layout. Therefore it can be used for the grant table.
+ *
+ * Only use the text section as it's always present and will contain
+ * enough space for a large grant table
+ */
+#define
gnttab_dom0_frames()
\
+    min_t(unsigned int, opt_max_grant_frames, PFN_DOWN(_etext - _stext))
+
 #endif /* CONFIG_GRANT_TABLE */

 #endif /* __XEN_GRANT_TABLE_H__ */

Quoted 8 lines
Quoted 3 lines

But gnttab_dom0_frames() is used only for ARM, so probably moving it to
<xen/grant_table.h> is not a good idea.

Indeed. But wouldn't dealing with this again be a matter of having Arm's domain_build.c simply include asm/grant_table.h explicitly, if need
be alongside xen/grant_table.h?

It can be a solution. Then I'll send a separate patch.

Thanks.

~ Oleksii

Reviewed-by on v2 1/15
#2 lore raw

Re: [PATCH v2 01/15] xen/asm-generic: introduce stub header paging.h

In reply to Oleksii Kurochko
Quoted 11 lines · Oleksii Kurochko

The patch introduces generic paging.h header for Arm, PPC and RISC-V.

All mentioned above architectures use hardware virt extensions and hardware pagetable extensions thereby it makes sense to set paging_mode_translate and paging_mode_external by default.

Also in this patch Arm and PPC architectures are switched to generic paging.h header.

with one nit (applicable twice):

xen/arch/arm/include/asm/Makefile line 3

Quoted 6 lines
xen/arch/arm/include/asm/Makefile +1 -0
@@ -1,2 +1,3 @@
 # SPDX-License-Identifier: GPL-2.0-only
 generic-y += vm_event.h
+generic-y += paging.h

Like in obj-y lists it would be nice for the items here and ...

xen/arch/ppc/include/asm/Makefile line 3

Quoted 6 lines
xen/arch/ppc/include/asm/Makefile +1 -0
@@ -1,2 +1,3 @@
 # SPDX-License-Identifier: GPL-2.0-only
 generic-y += vm_event.h
+generic-y += paging.h

... here to be sorted alphabetically from the beginning. Right here I'd be happy to make the change while committing, but I'm not going to promise making the same offer on subsequent changes (should the same issue exist there).

Jan

#4 lore raw

Re: [PATCH v2 02/15] xen/asm-generic: introduce generic device.h

In reply to Oleksii Kurochko
Quoted 16 lines · Oleksii Kurochko
xen/include/asm-generic/device.h new file +13 -0
@@ -0,0 +1,140 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __ASM_GENERIC_DEVICE_H__
+#define __ASM_GENERIC_DEVICE_H__
+
+enum device_type
+{
+    DEV_DT,
+#ifdef HAS_PCI
+    DEV_PCI,
+#endif
+};
+
+struct dev_archdata {

xen/include/asm-generic/device.h line 23

Quoted 10 lines
xen/include/asm-generic/device.h new file +10 -0
+    void *iommu;    /* IOMMU private data */
+};
+
+/* struct device - The basic device structure */
+struct device
+{
+    enum device_type type;
+#ifdef CONFIG_HAS_DEVICE_TREE
+    struct dt_device_node *of_node; /* Used by drivers imported from Linux */
+#endif

There's just this instance where HAS_DEVICE_TREE is checked. Why not elsewhere? Imo, if you really want this header in asm-generic/, then it wants to be truly generic (i.e. not implying DT just like you're not implying PCI or ACPI).

Jan

#16 lore raw

Re: [PATCH v2 05/15] xen/asm-generic: introduce generic header iocap.h

In reply to Oleksii Kurochko
Quoted 6 lines · Oleksii Kurochko

iocap.h is common for Arm, PPC and RISC-V architectures thereby it was moved to asm-generic.

---
The same question as with device.h. Should it be in asm-generic?

I think it's okay(ish) here, considering that ...

xen/include/asm-generic/iocap.h line 6

Quoted 9 lines
xen/include/asm-generic/iocap.h new file +6 -0
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __ASM_GENERIC_IOCAP_H__
+#define __ASM_GENERIC_IOCAP_H__
+
+#define cache_flush_permitted(d)                        \
+    (!rangeset_is_empty((d)->iomem_caps))

... the only thing referenced (iomem_caps) is a common entity. And again Arm demonstrates that an arch can get away with just this.

Jan

#13 lore raw

Re: [PATCH v2 04/15] xen/asm-generic: introduce generic hypercall.h

In reply to Jan Beulich
Quoted 9 lines · Jan Beulich
Quoted 4 lines · Oleksii Kurochko

Introduce an empty generic hypercall.h for archs which don't implement it.

Since - judging from Arm's present header - it looks technically possible for an arch to get away with this:

Actually - why does this patch not drop PPC's now redundant header right away, along the lines of what you do in patch 1? This is also why I refrained from offering A-b on patch 5.

Jan

#20 lore raw

Re: [PATCH v2 06/15] xen/asm-generic: ifdef inclusion of <asm/mem_access.h>

In reply to Oleksii
Quoted 2 lines · Oleksii

This patch should be reworked as it fails Arm builds:
https://gitlab.com/xen-project/people/olkur/xen/-/pipelines/1068867920

Took me a while to actually find the error. Would have been nice if you had explained what's going wrong, supplying the link only as extra info.

Quoted 3 lines

It looks like it is not possible just to #ifdef CONFIG_MEM_ACCESS.

An empty asm-generic mem_access.h will be better solution.

I remain unconvinced. The issue looks to be with p2m_mem_access_check(). One solution would be to move that declaration into the common header. But there's no common code referencing it, so Arm's and x86's version might as well diverge at some point. Hence from my pov it again boils down to Arm's traps.c including asm/mem_access.h explicitly, to bring the declaration in scope. None of the common files really have a need to have a dependency on the arch-specific header when MEM_ACCESS=n.

Jan

author
#21 lore raw

Re: [PATCH v2 06/15] xen/asm-generic: ifdef inclusion of <asm/mem_access.h>

Quoted 8 lines · Jan Beulich
Quoted 2 lines · Oleksii

This patch should be reworked as it fails Arm builds:
https://gitlab.com/xen-project/people/olkur/xen/-/pipelines/1068867920

Took me a while to actually find the error. Would have been nice if you
had explained what's going wrong, supplying the link only as extra info.

Sorry about that. I'll be more precise with links next time! But the issue is exactly what you wrote below ( with p2m_mem_access_check and some others from <asm/mem_access.h> ) .

Quoted 5 lines
Quoted 4 lines

It looks like it is not possible just to #ifdef CONFIG_MEM_ACCESS.

An empty asm-generic mem_access.h will be better solution.

Quoted 9 lines

I remain unconvinced. The issue looks to be with p2m_mem_access_check().
One solution would be to move that declaration into the common header.
But there's no common code referencing it, so Arm's and x86's version might as well diverge at some point. Hence from my pov it again boils down to Arm's traps.c including asm/mem_access.h explicitly, to bring the declaration in scope. None of the common files really have a need to have a dependency on the arch-specific header when MEM_ACCESS=n.

I started to do that in that way you mentioned.

It should be included in 2 files, at least: p2m.c and traps.c. I am finishind the testing if it is enough.
If it is enough, I will send a separate patch.

~ Oleksii

author
#14 lore raw

Re: [PATCH v2 04/15] xen/asm-generic: introduce generic hypercall.h

In reply to Jan Beulich
Quoted 12 lines · Jan Beulich
Quoted 10 lines · Jan Beulich
Quoted 4 lines · Oleksii Kurochko

Introduce an empty generic hypercall.h for archs which don't implement it.

Since - judging from Arm's present header - it looks technically possible
for an arch to get away with this:

Quoted 4 lines

Actually - why does this patch not drop PPC's now redundant header right
away, along the lines of what you do in patch 1? This is also why I refrained from offering A-b on patch 5.

Missed that. I'll send a new patch series with dropped PPC's redundant header.

Thanks.

~ Oleksii

author
#17 lore raw

Re: [PATCH v2 05/15] xen/asm-generic: introduce generic header iocap.h

In reply to Jan Beulich
Quoted 10 lines · Jan Beulich
Quoted 6 lines · Oleksii Kurochko

iocap.h is common for Arm, PPC and RISC-V architectures thereby it was moved to asm-generic.

---
The same question as with device.h. Should it be in asm-generic?

I think it's okay(ish) here, considering that ...

Quoted 12 lines

xen/include/asm-generic/iocap.h line 6

Quoted 9 lines
xen/include/asm-generic/iocap.h new file +6 -0
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __ASM_GENERIC_IOCAP_H__
+#define __ASM_GENERIC_IOCAP_H__
+
+#define cache_flush_permitted(d)                        \
+    (!rangeset_is_empty((d)->iomem_caps))

... the only thing referenced (iomem_caps) is a common entity. And again Arm demonstrates that an arch can get away with just this.

Thanks.

Then I remove redundant headers from Arm and PPC and send new patch serires.

~ Oleksii

author
#5 lore raw

Re: [PATCH v2 02/15] xen/asm-generic: introduce generic device.h

In reply to Jan Beulich
Quoted 27 lines · Jan Beulich
Quoted 26 lines · Oleksii Kurochko
xen/include/asm-generic/device.h new file +22 -0
@@ -0,0 +1,140 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __ASM_GENERIC_DEVICE_H__
+#define __ASM_GENERIC_DEVICE_H__
+
+enum device_type
+{
+    DEV_DT,
+#ifdef HAS_PCI
+    DEV_PCI,
+#endif
+};
+
+struct dev_archdata {
+    void *iommu;    /* IOMMU private data */
+};
+
+/* struct device - The basic device structure */
+struct device
+{
+    enum device_type type;
+#ifdef CONFIG_HAS_DEVICE_TREE
+    struct dt_device_node *of_node; /* Used by drivers imported

from Linux */

Quoted 8 lines
Quoted 1 line

+#endif

There's just this instance where HAS_DEVICE_TREE is checked. Why not elsewhere?
Imo, if you really want this header in asm-generic/, then it wants to be truly
generic (i.e. not implying DT just like you're not implying PCI or ACPI).

Mostly copied this file from Arm and only that one part was #ifdef-ed with HAS_DEVICE_TREE.
But it makes sense to #ifdef DEV_DT, inclusion of <xen/device_tree.h> and definiotn of dev_is_dt() macros.

I'll made the changes in next version of patch series.

Thanks for comments.

~ Oleksii

#23 lore raw

Re: [PATCH v2 07/15] xen/asm-generic: introduce stub header <asm/random.h>

In reply to Oleksii Kurochko
Quoted 2 lines · Oleksii Kurochko

<asm/random.h> is common for Arm, PPC and RISC-V thereby it is moved to asm-generic.

When you say "moved", ...

Quoted 8 lines

---
Changes in V2:
- update the commit messages

---
 xen/include/asm-generic/random.h | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
 create mode 100644 xen/include/asm-generic/random.h

... you also want to actually move things.

Since the above comment matches ones on earlier patches, yet otoh in your submissions of two individual patches you mentioned you sent them separately because this series wasn't fully reviewed yet, would you mind clarifying whether further going through this version of the series is actually going to be a good use of time?

Jan

#38 lore raw

Re: [PATCH v2 13/15] xen/asm-generic: introduce stub header monitor.h

In reply to Oleksii Kurochko
Quoted 8 lines · Oleksii Kurochko
xen/include/asm-generic/monitor.h new file +5 -0
@@ -0,0 +1,62 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * include/asm-GENERIC/monitor.h
+ *
+ * Arch-specific monitor_op domctl handler.

xen/include/asm-generic/monitor.h line 15

Quoted 10 lines
xen/include/asm-generic/monitor.h new file +10 -0
+ *
+ * Copyright (c) 2015 Tamas K Lengyel ([email protected])
+ * Copyright (c) 2016, Bitdefender S.R.L.
+ *
+ */
+
+#ifndef __ASM_GENERIC_MONITOR_H__
+#define __ASM_GENERIC_MONITOR_H__
+
+#include <xen/sched.h>

What is this needed for? I expect ...

xen/include/asm-generic/monitor.h line 20

Quoted 4 lines
xen/include/asm-generic/monitor.h new file +4 -0
+struct xen_domctl_monitor_op;
+
+static inline
+void arch_monitor_allow_userspace(struct domain *d, bool allow_userspace)

... struct domain, but since you never de-reference any such pointer, forward- declaring that (just like struct xen_domctl_monitor_op) would do here. Which would leave you with needing at most xen/types.h, but maybe as little as xen/stdbool.h and xen/stdint.h.

Jan

Quoted 42 lines
xen/include/asm-generic/monitor.h new file +42 -0
+{
+}
+
+static inline
+int arch_monitor_domctl_op(struct domain *d, struct xen_domctl_monitor_op *mop)
+{
+    /* No arch-specific monitor ops on GENERIC. */
+    return -EOPNOTSUPP;
+}
+
+int arch_monitor_domctl_event(struct domain *d,
+                              struct xen_domctl_monitor_op *mop);
+
+static inline
+int arch_monitor_init_domain(struct domain *d)
+{
+    /* No arch-specific domain initialization on GENERIC. */
+    return 0;
+}
+
+static inline
+void arch_monitor_cleanup_domain(struct domain *d)
+{
+    /* No arch-specific domain cleanup on GENERIC. */
+}
+
+static inline uint32_t arch_monitor_get_capabilities(struct domain *d)
+{
+    return 0;
+}
+
+#endif /* __ASM_GENERIC_MONITOR_H__ */
+
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: BSD
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
#43 lore raw

Re: [PATCH v2 14/15] xen/asm-generic: introduce stub header numa.h

In reply to Oleksii Kurochko

xen/include/asm-generic/numa.h line 6

Quoted 9 lines · Oleksii Kurochko
xen/include/asm-generic/numa.h new file +6 -0
@@ -0,0 +1,40 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __ARCH_GENERIC_NUMA_H
+#define __ARCH_GENERIC_NUMA_H
+
+#include <xen/types.h>
+#include <xen/mm.h>

I'm afraid I can't spot what you need these for here. You clearly need xen/stdint.h, and you need xen/mm-frame.h for mfn_t. Yes, max_page is declared in xen/mm.h, but its questionable whether the header needs including here for that reason, as all uses are in macros. (We aren't anywhere near consistent in this regard). Plus you don't also include xen/cpumask.h to pull in cpu_online_map (which another macro references).

xen/include/asm-generic/numa.h line 10

Quoted 3 lines
xen/include/asm-generic/numa.h new file +3 -0
+typedef uint8_t nodeid_t;
+
+#ifndef CONFIG_NUMA

Isn't it an error to include this header when NUMA=y?

Quoted 29 lines
xen/include/asm-generic/numa.h new file +29 -0
+/* Fake one node for now. See also node_online_map. */
+#define cpu_to_node(cpu) 0
+#define node_to_cpumask(node)   (cpu_online_map)
+
+/*
+ * TODO: make first_valid_mfn static when NUMA is supported on Arm, this
+ * is required because the dummy helpers are using it.
+ */
+extern mfn_t first_valid_mfn;
+
+/* XXX: implement NUMA support */
+#define node_spanned_pages(nid) (max_page - mfn_x(first_valid_mfn))
+#define node_start_pfn(nid) (mfn_x(first_valid_mfn))
+#define __node_distance(a, b) (20)
+
+#endif
+
+#define arch_want_default_dmazone() (false)
+
+#endif /* __ARCH_GENERIC_NUMA_H */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
author
#24 lore raw

Re: [PATCH v2 07/15] xen/asm-generic: introduce stub header <asm/random.h>

In reply to Jan Beulich
Quoted 15 lines · Jan Beulich
Quoted 2 lines · Oleksii Kurochko

<asm/random.h> is common for Arm, PPC and RISC-V thereby it is moved to asm-generic.

When you say "moved", ...

Quoted 8 lines

---
Changes in V2:
 - update the commit messages
---
 xen/include/asm-generic/random.h | 20 ++++++++++++++++++++

 1 file changed, 20 insertions(+)

 create mode 100644 xen/include/asm-generic/random.h

Quoted 1 line

... you also want to actually move things.

Sure, I'll delete Arm and PPC's random.h in the next patch series version.

Quoted 9 lines

Since the above comment matches ones on earlier patches, yet otoh in your
submissions of two individual patches you mentioned you sent them separately because this series wasn't fully reviewed yet, would you mind
clarifying whether further going through this version of the series is
actually going to be a good use of time?

I think it still makes sense to review this series.

I probably have to stop sending patches from this series separately. I thought merging almost-ready patches would be a little faster if they moved outside the patch series.

If it is possible to merge approved patches separately without getting approved for the whole patch series, then what I did before doesn't make sense, and I am sorry for this inconvenience.

I can return the patches I sent separately to this patch series.

~ Oleksii

author
#39 lore raw

Re: [PATCH v2 13/15] xen/asm-generic: introduce stub header monitor.h

In reply to Jan Beulich
Quoted 22 lines · Jan Beulich
Quoted 8 lines · Oleksii Kurochko
xen/include/asm-generic/monitor.h new file +5 -0
@@ -0,0 +1,62 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * include/asm-GENERIC/monitor.h
+ *
+ * Arch-specific monitor_op domctl handler.

xen/include/asm-generic/monitor.h line 15

Quoted 10 lines
xen/include/asm-generic/monitor.h new file +10 -0
+ *
+ * Copyright (c) 2015 Tamas K Lengyel ([email protected])
+ * Copyright (c) 2016, Bitdefender S.R.L.
+ *
+ */
+
+#ifndef __ASM_GENERIC_MONITOR_H__
+#define __ASM_GENERIC_MONITOR_H__
+
+#include <xen/sched.h>

What is this needed for? I expect ...

Quoted 13 lines
Quoted 5 lines
xen/include/asm-generic/monitor.h new file +4 -0
+struct xen_domctl_monitor_op;
+
+static inline
+void arch_monitor_allow_userspace(struct domain *d, bool

allow_userspace)

... struct domain, but since you never de-reference any such pointer, forward-
declaring that (just like struct xen_domctl_monitor_op) would do here. Which
would leave you with needing at most xen/types.h, but maybe as little as
xen/stdbool.h and xen/stdint.h.

Yes, the reason for " #include <xen/sched.h> " was ' struct domain '. Let's switch to forward-declaring.

Shouldn't it be included <xen/compiler.h> too for inline?

~ Oleksii

Quoted 45 lines
Quoted 44 lines
xen/include/asm-generic/monitor.h new file +5 -0
+{
+}
+
+static inline
+int arch_monitor_domctl_op(struct domain *d, struct

xen_domctl_monitor_op *mop)

xen/include/asm-generic/monitor.h new file +22 -0
+{
+    /* No arch-specific monitor ops on GENERIC. */
+    return -EOPNOTSUPP;
+}
+
+int arch_monitor_domctl_event(struct domain *d,
+                              struct xen_domctl_monitor_op *mop);
+
+static inline
+int arch_monitor_init_domain(struct domain *d)
+{
+    /* No arch-specific domain initialization on GENERIC. */
+    return 0;
+}
+
+static inline
+void arch_monitor_cleanup_domain(struct domain *d)
+{
+    /* No arch-specific domain cleanup on GENERIC. */
+}
+
+static inline uint32_t arch_monitor_get_capabilities(struct domain

*d)

xen/include/asm-generic/monitor.h new file +15 -0
+{
+    return 0;
+}
+
+#endif /* __ASM_GENERIC_MONITOR_H__ */
+
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: BSD
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
author
#44 lore raw

Re: [PATCH v2 14/15] xen/asm-generic: introduce stub header numa.h

In reply to Jan Beulich
Quoted 11 lines · Jan Beulich

xen/include/asm-generic/numa.h line 6

Quoted 9 lines · Oleksii Kurochko
xen/include/asm-generic/numa.h new file +6 -0
@@ -0,0 +1,40 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __ARCH_GENERIC_NUMA_H
+#define __ARCH_GENERIC_NUMA_H
+
+#include <xen/types.h>
+#include <xen/mm.h>
Quoted 8 lines

I'm afraid I can't spot what you need these for here. You clearly need
xen/stdint.h, and you need xen/mm-frame.h for mfn_t. Yes, max_page is declared in xen/mm.h, but its questionable whether the header needs including here for that reason, as all uses are in macros. (We aren't anywhere near consistent in this regard). Plus you don't also include xen/cpumask.h to pull in cpu_online_map (which another macro references).

I agree with almost you wrote but should <xen/cpumas.h> be included then? It looks like it is the same situation as with max_page and <xen/mm.h>.

Quoted 6 lines

xen/include/asm-generic/numa.h line 10

Quoted 4 lines
xen/include/asm-generic/numa.h new file +3 -0
+typedef uint8_t nodeid_t;
+
+#ifndef CONFIG_NUMA

Isn't it an error to include this header when NUMA=y?

It's still need to define arch_want_default_dmazone() macros which is used by common code.
All other code is under #ifndef CONFIG_NUMA so it won't conflict with defintions in <xen/numa.h>.

Quoted 24 lines
Quoted 24 lines
xen/include/asm-generic/numa.h new file +6 -0
+/* Fake one node for now. See also node_online_map. */
+#define cpu_to_node(cpu) 0
+#define node_to_cpumask(node)   (cpu_online_map)
+
+/*
+ * TODO: make first_valid_mfn static when NUMA is supported on

Arm, this
+ * is required because the dummy helpers are using it.
+ */

xen/include/asm-generic/numa.h new file +4 -0
+extern mfn_t first_valid_mfn;
+
+/* XXX: implement NUMA support */
+#define node_spanned_pages(nid) (max_page -

mfn_x(first_valid_mfn))

xen/include/asm-generic/numa.h new file +9 -0
+#define node_start_pfn(nid) (mfn_x(first_valid_mfn))
+#define __node_distance(a, b) (20)
+
+#endif
+
+#define arch_want_default_dmazone() (false)
+
+#endif /* __ARCH_GENERIC_NUMA_H */
+
Quoted 9 lines
Quoted 8 lines

+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */

~ Oleksii

author
#40 lore raw

Re: [PATCH v2 13/15] xen/asm-generic: introduce stub header monitor.h

In reply to Oleksii
Quoted 38 lines · Oleksii
Quoted 22 lines · Jan Beulich
Quoted 8 lines · Oleksii Kurochko
xen/include/asm-generic/monitor.h new file +5 -0
@@ -0,0 +1,62 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * include/asm-GENERIC/monitor.h
+ *
+ * Arch-specific monitor_op domctl handler.

xen/include/asm-generic/monitor.h line 15

Quoted 10 lines
xen/include/asm-generic/monitor.h new file +10 -0
+ *
+ * Copyright (c) 2015 Tamas K Lengyel ([email protected])
+ * Copyright (c) 2016, Bitdefender S.R.L.
+ *
+ */
+
+#ifndef __ASM_GENERIC_MONITOR_H__
+#define __ASM_GENERIC_MONITOR_H__
+
+#include <xen/sched.h>

What is this needed for? I expect ...

Quoted 15 lines
Quoted 5 lines
xen/include/asm-generic/monitor.h new file +4 -0
+struct xen_domctl_monitor_op;
+
+static inline
+void arch_monitor_allow_userspace(struct domain *d, bool

allow_userspace)

... struct domain, but since you never de-reference any such pointer,
forward-
declaring that (just like struct xen_domctl_monitor_op) would do here. Which
would leave you with needing at most xen/types.h, but maybe as little
as
xen/stdbool.h and xen/stdint.h.

Quoted 4 lines

Yes, the reason for " #include <xen/sched.h> " was ' struct domain '. Let's switch to forward-declaring.

Shouldn't it be included <xen/compiler.h> too for inline?

It should be added "#include <xen/errno.h>" because EOPNOTSUPP is used in arch_monitor_domctl_op.

Quoted 51 lines

~ Oleksii

Quoted 47 lines
Quoted 46 lines
xen/include/asm-generic/monitor.h new file +5 -0
+{
+}
+
+static inline
+int arch_monitor_domctl_op(struct domain *d, struct

xen_domctl_monitor_op *mop)

xen/include/asm-generic/monitor.h new file +7 -0
+{
+    /* No arch-specific monitor ops on GENERIC. */
+    return -EOPNOTSUPP;
+}
+
+int arch_monitor_domctl_event(struct domain *d,
+                              struct xen_domctl_monitor_op

*mop);

xen/include/asm-generic/monitor.h new file +15 -0
+
+static inline
+int arch_monitor_init_domain(struct domain *d)
+{
+    /* No arch-specific domain initialization on GENERIC. */
+    return 0;
+}
+
+static inline
+void arch_monitor_cleanup_domain(struct domain *d)
+{
+    /* No arch-specific domain cleanup on GENERIC. */
+}
+
+static inline uint32_t arch_monitor_get_capabilities(struct

domain
*d)

xen/include/asm-generic/monitor.h new file +15 -0
+{
+    return 0;
+}
+
+#endif /* __ASM_GENERIC_MONITOR_H__ */
+
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: BSD
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
author
#27 lore raw

Re: [PATCH v2 08/15] xen/asm-generic: introduce generic header percpu.h

In reply to Oleksii Kurochko

I have to drop arch specific headers and switch to asm-generic version. I'll do the same for patches 09-12 in the next patch version.

~ Oleksii

Quoted 54 lines · Oleksii Kurochko

---
Changes in V2:
        - use smp_processor_id() instead of get_processor_id().
        - update commit message .
---
 xen/include/asm-generic/percpu.h | 35
++++++++++++++++++++++++++++++++

 1 file changed, 35 insertions(+)

 create mode 100644 xen/include/asm-generic/percpu.h

xen/include/asm- renamed from xen/include/asm-generic/percpu.h +0 -0

generic/percpu.h
new file mode 100644
index 0000000000..85a3f3ef17

xen/include/asm-generic/percpu.h new file +17 -0
@@ -0,0 +1,35 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __ASM_GENERIC_PERCPU_H__
+#define __ASM_GENERIC_PERCPU_H__
+
+#ifndef __ASSEMBLY__
+
+#include <xen/types.h>
+
+extern char __per_cpu_start[], __per_cpu_data_end[];
+extern unsigned long __per_cpu_offset[NR_CPUS];
+void percpu_init_areas(void);
+
+#define per_cpu(var, cpu)  \
+    (*RELOC_HIDE(&per_cpu__##var, __per_cpu_offset[cpu]))
+
+#define this_cpu(var) \
+    (*RELOC_HIDE(&per_cpu__##var,

__per_cpu_offset[smp_processor_id()]))

xen/include/asm-generic/percpu.h new file +18 -0
+
+#define per_cpu_ptr(var, cpu)  \
+    (*RELOC_HIDE(var, __per_cpu_offset[cpu]))
+#define this_cpu_ptr(var) \
+    (*RELOC_HIDE(var, smp_processor_id()))
+
+#endif
+
+#endif /* __ASM_GENERIC_PERCPU_H__ */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
#25 lore raw

Re: [PATCH v2 07/15] xen/asm-generic: introduce stub header <asm/random.h>

In reply to Oleksii
Quoted 29 lines · Oleksii
Quoted 15 lines · Jan Beulich
Quoted 2 lines · Oleksii Kurochko

<asm/random.h> is common for Arm, PPC and RISC-V thereby it is moved to asm-generic.

When you say "moved", ...

Quoted 8 lines

---
Changes in V2:
 - update the commit messages
---
 xen/include/asm-generic/random.h | 20 ++++++++++++++++++++

 1 file changed, 20 insertions(+)

 create mode 100644 xen/include/asm-generic/random.h

Quoted 1 line

... you also want to actually move things.

Sure, I'll delete Arm and PPC's random.h in the next patch series version.

Quoted 9 lines

Since the above comment matches ones on earlier patches, yet otoh in your
submissions of two individual patches you mentioned you sent them separately because this series wasn't fully reviewed yet, would you mind
clarifying whether further going through this version of the series is
actually going to be a good use of time?

Quoted 8 lines

I think it still makes sense to review this series.

I probably have to stop sending patches from this series separately. I thought merging almost-ready patches would be a little faster if they moved outside the patch series.

If it is possible to merge approved patches separately without getting approved for the whole patch series,

We do this quite frequently, as long as it's clear that later patches in a series (which are approved and hence can go in) don't depend on earlier ones. Ones at the beginning of a series can go individually anyway; the only time that I can think of right away where this would not be desirable is if they introduced then-dead code.

Jan

Quoted 7 lines

then what I did before doesn't
make sense, and I am sorry for this inconvenience.

I can return the patches I sent separately to this patch series.

~ Oleksii

#41 lore raw

Re: [PATCH v2 13/15] xen/asm-generic: introduce stub header monitor.h

In reply to Oleksii
Quoted 36 lines · Oleksii
Quoted 22 lines · Jan Beulich
Quoted 8 lines · Oleksii Kurochko
xen/include/asm-generic/monitor.h new file +5 -0
@@ -0,0 +1,62 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * include/asm-GENERIC/monitor.h
+ *
+ * Arch-specific monitor_op domctl handler.

xen/include/asm-generic/monitor.h line 15

Quoted 10 lines
xen/include/asm-generic/monitor.h new file +10 -0
+ *
+ * Copyright (c) 2015 Tamas K Lengyel ([email protected])
+ * Copyright (c) 2016, Bitdefender S.R.L.
+ *
+ */
+
+#ifndef __ASM_GENERIC_MONITOR_H__
+#define __ASM_GENERIC_MONITOR_H__
+
+#include <xen/sched.h>

What is this needed for? I expect ...

Quoted 13 lines
Quoted 5 lines
xen/include/asm-generic/monitor.h new file +4 -0
+struct xen_domctl_monitor_op;
+
+static inline
+void arch_monitor_allow_userspace(struct domain *d, bool

allow_userspace)

... struct domain, but since you never de-reference any such pointer, forward-
declaring that (just like struct xen_domctl_monitor_op) would do here. Which
would leave you with needing at most xen/types.h, but maybe as little as
xen/stdbool.h and xen/stdint.h.

Quoted 4 lines

Yes, the reason for " #include <xen/sched.h> " was ' struct domain '. Let's switch to forward-declaring.

Shouldn't it be included <xen/compiler.h> too for inline?

I'm actually not sure why we (still?) override "inline" there. It's a normal keyword in C99. IOW I don't think xen/compiler.h would be needed here (just for that).

Jan

#45 lore raw

Re: [PATCH v2 14/15] xen/asm-generic: introduce stub header numa.h

In reply to Oleksii
Quoted 20 lines · Oleksii
Quoted 11 lines · Jan Beulich

xen/include/asm-generic/numa.h line 6

Quoted 9 lines · Oleksii Kurochko
xen/include/asm-generic/numa.h new file +6 -0
@@ -0,0 +1,40 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __ARCH_GENERIC_NUMA_H
+#define __ARCH_GENERIC_NUMA_H
+
+#include <xen/types.h>
+#include <xen/mm.h>
Quoted 8 lines

I'm afraid I can't spot what you need these for here. You clearly need
xen/stdint.h, and you need xen/mm-frame.h for mfn_t. Yes, max_page is declared in xen/mm.h, but its questionable whether the header needs including here for that reason, as all uses are in macros. (We aren't anywhere near consistent in this regard). Plus you don't also include xen/cpumask.h to pull in cpu_online_map (which another macro references).

Quoted 3 lines

I agree with almost you wrote but should <xen/cpumas.h> be included then? It looks like it is the same situation as with max_page and <xen/mm.h>.

Well, yes and no: Indeed the minimal requirement is to be consistent (either include both or include neither). Personally I'd prefer if headers would be included only if they are needed to successfully compiler the header on its own. That limits needless dependencies on the (otherwise) included headers. But I can easily see that others might take the other sensible perspective.

Quoted 7 lines
Quoted 5 lines

xen/include/asm-generic/numa.h line 10

Quoted 3 lines
xen/include/asm-generic/numa.h new file +3 -0
+typedef uint8_t nodeid_t;
+
+#ifndef CONFIG_NUMA

Isn't it an error to include this header when NUMA=y?

It's still need to define arch_want_default_dmazone() macros which is used by common code.

Oh, yes. I somehow managed to overlook that. Some of the #include-s then want to move inside the #ifndef, though. (Ultimately I question the placement of this #define in this header, but we can deal with that separately.)

Jan

#28 lore raw

Re: [PATCH v2 08/15] xen/asm-generic: introduce generic header percpu.h

In reply to Oleksii Kurochko

xen/include/asm-generic/percpu.h line 9

Quoted 12 lines · Oleksii Kurochko
xen/include/asm-generic/percpu.h new file +9 -0
@@ -0,0 +1,35 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __ASM_GENERIC_PERCPU_H__
+#define __ASM_GENERIC_PERCPU_H__
+
+#ifndef __ASSEMBLY__
+
+#include <xen/types.h>
+
+extern char __per_cpu_start[], __per_cpu_data_end[];

Can we go one tiny step beyond what Arm presently has and make the latter of the two const?

Jan

author
#29 lore raw

Re: [PATCH v2 08/15] xen/asm-generic: introduce generic header percpu.h

Quoted 16 lines · Jan Beulich

xen/include/asm-generic/percpu.h line 9

Quoted 12 lines · Oleksii Kurochko
xen/include/asm-generic/percpu.h new file +9 -0
@@ -0,0 +1,35 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __ASM_GENERIC_PERCPU_H__
+#define __ASM_GENERIC_PERCPU_H__
+
+#ifndef __ASSEMBLY__
+
+#include <xen/types.h>
+
+extern char __per_cpu_start[], __per_cpu_data_end[];

Can we go one tiny step beyond what Arm presently has and make the latter of the two const?

I am not sure I think we will have compilation issue with the following code in Arm and x86 because of [-Werror=discarded-qualifiers]:

static void cf_check _free_percpu_area(struct rcu_head *head)

{
    struct free_info *info = container_of(head, struct free_info, rcu);
    unsigned int cpu = info->cpu;
    char *p = __per_cpu_start + __per_cpu_offset[cpu];

    free_xenheap_pages(p, PERCPU_ORDER);
    __per_cpu_offset[cpu] = INVALID_PERCPU_AREA;
}

I guess cast can help.

~ Oleksii

#30 lore raw

Re: [PATCH v2 08/15] xen/asm-generic: introduce generic header percpu.h

Quoted 21 lines · Oleksii
Quoted 16 lines · Jan Beulich

xen/include/asm-generic/percpu.h line 9

Quoted 12 lines · Oleksii Kurochko
xen/include/asm-generic/percpu.h new file +9 -0
@@ -0,0 +1,35 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __ASM_GENERIC_PERCPU_H__
+#define __ASM_GENERIC_PERCPU_H__
+
+#ifndef __ASSEMBLY__
+
+#include <xen/types.h>
+
+extern char __per_cpu_start[], __per_cpu_data_end[];

Can we go one tiny step beyond what Arm presently has and make the latter of the two const?

I am not sure I think we will have compilation issue with the following code in Arm and x86 because of [-Werror=discarded-qualifiers]:

static void cf_check _free_percpu_area(struct rcu_head *head)

Quoted 8 lines
{
    struct free_info *info = container_of(head, struct free_info, rcu);
    unsigned int cpu = info->cpu;
    char *p = __per_cpu_start + __per_cpu_offset[cpu];

    free_xenheap_pages(p, PERCPU_ORDER);
    __per_cpu_offset[cpu] = INVALID_PERCPU_AREA;
}

There's no use of __per_cpu_data_end here; I specifically didn't ask for both of the declarations to have const added.

Quoted 1 line

I guess cast can help.

There may not be casts casting away constness, except maybe in very delicate situations.

Jan

author
#31 lore raw

Re: [PATCH v2 08/15] xen/asm-generic: introduce generic header percpu.h

Quoted 30 lines · Jan Beulich
Quoted 29 lines · Oleksii
Quoted 17 lines · Jan Beulich

xen/include/asm-generic/percpu.h line 9

Quoted 12 lines · Oleksii Kurochko
xen/include/asm-generic/percpu.h new file +9 -0
@@ -0,0 +1,35 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __ASM_GENERIC_PERCPU_H__
+#define __ASM_GENERIC_PERCPU_H__
+
+#ifndef __ASSEMBLY__
+
+#include <xen/types.h>
+
+extern char __per_cpu_start[], __per_cpu_data_end[];

Can we go one tiny step beyond what Arm presently has and make the
latter of the two const?

I am not sure I think we will have compilation issue with the following
code in Arm and x86 because of [-Werror=discarded-qualifiers]:

static void cf_check _free_percpu_area(struct rcu_head *head) {
    struct free_info *info = container_of(head, struct free_info, rcu);
    unsigned int cpu = info->cpu;
    char *p = __per_cpu_start + __per_cpu_offset[cpu];

Quoted 7 lines
Quoted 3 lines

    free_xenheap_pages(p, PERCPU_ORDER);
    __per_cpu_offset[cpu] = INVALID_PERCPU_AREA;
}

There's no use of __per_cpu_data_end here; I specifically didn't ask for both
of the declarations to have const added.

Yes, I misread your comment.

Quoted 7 lines
Quoted 2 lines

I guess cast can help.

There may not be casts casting away constness, except maybe in very delicate
situations.

~ Oleksii

author
#33 lore raw

Re: [PATCH v2 09/15] xen/asm-generic: introduce generic header smp.h

In reply to Oleksii Kurochko

I will drop this patch as it will be hard to make it generic for Arm, PPC and RISC-V.

~ Oleksii

Quoted 54 lines · Oleksii Kurochko

<asm/smp.h> is expcted to be generic between Arm, PPC and RISC-V there by it is moved to asm-generic.

Right now it is common only by PPC and RISC-V but during work on support of the mentioned arhcs <asm/smp.h> is expected to be the same.

---
Changes in V2:
        - drop #ifded ASSEMBLY as this header isn't expected to be included in asm files.
        - update the commit message.
---
 xen/include/asm-generic/smp.h | 28 ++++++++++++++++++++++++++++

 1 file changed, 28 insertions(+)

 create mode 100644 xen/include/asm-generic/smp.h

xen/include/asm- renamed from xen/include/asm-generic/smp.h +0 -0

generic/smp.h
new file mode 100644
index 0000000000..6740a2064c

xen/include/asm-generic/smp.h new file +14 -0
@@ -0,0 +1,28 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __ASM_GENERIC_SMP_H
+#define __ASM_GENERIC_SMP_H
+
+#include <xen/cpumask.h>
+#include <xen/percpu.h>
+
+DECLARE_PER_CPU(cpumask_var_t, cpu_sibling_mask);
+DECLARE_PER_CPU(cpumask_var_t, cpu_core_mask);
+
+#define cpu_is_offline(cpu) unlikely(!cpu_online(cpu))
+
+/*
+ * Do we, for platform reasons, need to actually keep CPUs online

when we
+ * would otherwise prefer them to be off?
+ */

xen/include/asm-generic/smp.h new file +12 -0
+#define park_offline_cpus false
+
+#endif
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: BSD
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */