Skip to contentSkip to conversation

Introduce generic headers

PATCH Superseded Oleksii Kurochko 2 participants 21 messages Dec 1, 2023 – Dec 12, 2023

v5 of 9 Superseded Latest is v9 →

lore
Share & tools
lore
#0 lore raw

v5 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.

This patch series is a pre-requisite for "Enable build of full Xen for RISC-V" [3].

[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/[email protected]/

---
Changes in V5:
- Update the patch series message as patch related to delay.h was merged.
- Rebase on top of staging because half of the patches of the patch series were
merged to staging branch.
- Add A-by for some of the patches.
- Add "depends on X86 || Arm" for CONFIG_GRANT_TABLE and CONFIG_MEM_ACCESS to be
sure it won't be turned on by randconfig in CI.
- Partly switch Arm and PPC to asm-generic/monitor.h.
- Some other minor changes
---
Changes in V4:
- Update the cover letter message
- Add Reviewed-by/Acked-by for patches:
[PATCH v3 01/14] xen/asm-generic: introduce stub header paging.h
[PATCH v3 03/14] xen/asm-generic: introduce generic hypercall.h
[PATCH v3 04/14] xen/asm-generic: introduce generic header iocap.h
[PATCH v3 05/14] xen/asm-generic: introduce stub header <asm/random.h>
[PATCH v3 06/14] xen/asm-generic: introduce generic header percpu.h
[PATCH v3 07/14] xen/asm-generic: introduce generalized hardirq.h
[PATCH v3 08/14] xen/asm-generic: introduce generic div64.h header
[PATCH v3 09/14] xen/asm-generic: introduce generic header altp2m.h
[PATCH v3 10/14] xen/asm-generic: introduce stub header monitor.h
[PATCH v3 11/14] xen/asm-generic: introduce stub header numa.h
[PATCH v3 12/14] xen/asm-generic: introduce stub header softirq.h
- Fix some code style and minor issues.
- Use asm-generic version of device.h for Arm and PPC.
---
Changes in V3:
- Update the commit message of the cover letter.
- Drop the following patch as it can be arch-specific enough:
* [PATCH v2 09/15] xen/asm-generic: introduce generic header smp.h
- Drop correspondent arch specific headers and use asm-generic version of
a header.
- Back to the patch series patches:
* xen: ifdef inclusion of <asm/grant_table.h> in <xen/grant_table.h>
* xen/asm-generic: ifdef inclusion of <asm/mem_access.h>
---
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 (7):
xen/asm-generic: introduce generic div64.h header 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: ifdef inclusion of <asm/grant_table.h> in <xen/grant_table.h> xen/asm-generic: ifdef inclusion of <asm/mem_access.h> xen/asm-generic: introduce generic device.h

 xen/arch/arm/device.c                         |  15 ++-
 xen/arch/arm/domain_build.c                   |   3 +-
 xen/arch/arm/gic-v2.c                         |   4 +-
 xen/arch/arm/gic-v3.c                         |   6 +-
 xen/arch/arm/gic.c                            |   4 +-
 xen/arch/arm/include/asm/Makefile             |   3 +
 xen/arch/arm/include/asm/div64.h              |   8 +-
 xen/arch/arm/include/asm/monitor.h            |  28 +---
 xen/arch/arm/p2m.c                            |   1 +
 xen/arch/arm/traps.c                          |   1 +
 xen/arch/ppc/include/asm/Makefile             |   4 +
 xen/arch/ppc/include/asm/device.h             |  53 --------
 xen/arch/ppc/include/asm/div64.h              |  14 --
 xen/arch/ppc/include/asm/grant_table.h        |   5 -
 xen/arch/ppc/include/asm/mem_access.h         |   5 -
 xen/arch/ppc/include/asm/monitor.h            |  28 +---
 xen/arch/ppc/include/asm/numa.h               |  26 ----
 xen/arch/ppc/include/asm/softirq.h            |   8 --
 xen/arch/x86/include/asm/Makefile             |   1 +
 xen/arch/x86/include/asm/div64.h              |  14 --
 xen/common/Kconfig                            |   3 +-
 .../asm => include/asm-generic}/device.h      | 125 +++++++++++-------
 xen/include/asm-generic/div64.h               |  27 ++++
 xen/include/asm-generic/monitor.h             |  57 ++++++++
 .../asm => include/asm-generic}/numa.h        |  16 ++-
 .../asm => include/asm-generic}/softirq.h     |   7 +-
 xen/include/xen/grant_table.h                 |   3 +
 xen/include/xen/mem_access.h                  |   2 +
 28 files changed, 219 insertions(+), 252 deletions(-)
 delete mode 100644 xen/arch/ppc/include/asm/device.h
 delete mode 100644 xen/arch/ppc/include/asm/div64.h
 delete mode 100644 xen/arch/ppc/include/asm/grant_table.h
 delete mode 100644 xen/arch/ppc/include/asm/mem_access.h
 delete mode 100644 xen/arch/ppc/include/asm/numa.h
 delete mode 100644 xen/arch/ppc/include/asm/softirq.h
 delete mode 100644 xen/arch/x86/include/asm/div64.h
 rename xen/{arch/arm/include/asm => include/asm-generic}/device.h (79%)
 create mode 100644 xen/include/asm-generic/div64.h
 create mode 100644 xen/include/asm-generic/monitor.h
 rename xen/{arch/arm/include/asm => include/asm-generic}/numa.h (67%)
 rename xen/{arch/arm/include/asm => include/asm-generic}/softirq.h (56%)
Signature · 1 line
2.43.0
#1 lore raw

PATCH v5 1/7 xen/asm-generic: introduce generic div64.h header

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

x86 and PPC were switched to asm-generic version of div64.h. Arm was switched partly because Arm has different implementation for 32-bits.

---
Changes in V5:
- add Acked-by: Shawn Anastasio <[email protected]>
- Update the commit message
- Partly switch Arm's div64.h to asm-generic version. Arm has different implementation for 32-bits so only 64-bit version was switched.
---
Changes in V4:
- Added Acked-by: Jan Beulich <[email protected]>.
- include <asm-generic/div64.h> in Arm's div64.h for 64-bit case.
---
Changes in V3:
- Drop x86 and PPC's div64.h.
- Update the commit message.
---
Changes in V2:
- rename base to divisor
- add "#if BITS_PER_LONG == 64"
- fix code style

---
 xen/arch/arm/include/asm/div64.h  |  8 +-------
 xen/arch/ppc/include/asm/Makefile |  1 +
 xen/arch/ppc/include/asm/div64.h  | 14 --------------
 xen/arch/x86/include/asm/Makefile |  1 +
 xen/arch/x86/include/asm/div64.h  | 14 --------------
 xen/include/asm-generic/div64.h   | 27 +++++++++++++++++++++++++++
 6 files changed, 30 insertions(+), 35 deletions(-)
 delete mode 100644 xen/arch/ppc/include/asm/div64.h
 delete mode 100644 xen/arch/x86/include/asm/div64.h
 create mode 100644 xen/include/asm-generic/div64.h
xen/arch/arm/include/asm/div64.h +1 -7
index fc667a80f9..0459d5cc01 100644
@@ -24,13 +24,7 @@
 
 #if BITS_PER_LONG == 64
 
-# define do_div(n,base) ({                                      \
-        uint32_t __base = (base);                               \
-        uint32_t __rem;                                         \
-        __rem = ((uint64_t)(n)) % __base;                       \
-        (n) = ((uint64_t)(n)) / __base;                         \
-        __rem;                                                  \
- })
+#include <asm-generic/div64.h>
 
 #elif BITS_PER_LONG == 32
 
xen/arch/ppc/include/asm/Makefile +1 -0
index 2da995bb2f..a8e848d4d0 100644
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0-only
 generic-y += altp2m.h
+generic-y += div64.h
 generic-y += hardirq.h
 generic-y += hypercall.h
 generic-y += iocap.h
xen/arch/ppc/include/asm/div64.h deleted +0 -14
deleted file mode 100644
index d213e50585..0000000000
@@ -1,14 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-#ifndef __ASM_PPC_DIV64_H__
-#define __ASM_PPC_DIV64_H__
-
-#include <xen/types.h>
-
-#define do_div(n, base) ({                       \
-    uint32_t base_ = (base);                     \
-    uint32_t rem_ = (uint64_t)(n) % base_;       \
-    (n) = (uint64_t)(n) / base_;                 \
-    rem_;                                        \
-})
-
-#endif /* __ASM_PPC_DIV64_H__ */
xen/arch/x86/include/asm/Makefile +1 -0
index 874429ed30..daab34ff0a 100644
@@ -1,2 +1,3 @@
 # SPDX-License-Identifier: GPL-2.0-only
+generic-y += div64.h
 generic-y += percpu.h
xen/arch/x86/include/asm/div64.h deleted +0 -14
deleted file mode 100644
index dd49f64a3b..0000000000
@@ -1,14 +0,0 @@
-#ifndef __X86_DIV64
-#define __X86_DIV64
-
-#include <xen/types.h>
-
-#define do_div(n,base) ({                       \
-    uint32_t __base = (base);                   \
-    uint32_t __rem;                             \
-    __rem = ((uint64_t)(n)) % __base;           \
-    (n) = ((uint64_t)(n)) / __base;             \
-    __rem;                                      \
-})
-
-#endif
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.43.0
#2 lore raw

PATCH v5 2/7 xen/asm-generic: introduce stub header monitor.h

In reply to Oleksii Kurochko

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

Switch partly Arm and PPC to asm-generic/monitor.h and only arch_monitor_get_capabilities() left in arch-specific/monitor.h.

---
Changes in V5:
- Switched partly Arm and PPC to asm-generic monitor.h only arch_monitor_get_capabilities() left in arch-specific/monitor.h.
- Updated the commit message.
---
Changes in V4:
- Removed the double blank line.
- Added Acked-by: Jan Beulich <[email protected]>.
- Update the commit message
---
Changes in V3:
- Use forward-declaration of struct domain instead of " #include <xen/sched.h> ".
- Add ' include <xen/errno.h> '
- Drop PPC's monitor.h.
---
Changes in V2:
- remove inclusion of "+#include <public/domctl.h>"
- add "struct xen_domctl_monitor_op;"
- remove one of SPDX tags.

---
 xen/arch/arm/include/asm/monitor.h | 28 +--------------
 xen/arch/ppc/include/asm/monitor.h | 28 +--------------
 xen/include/asm-generic/monitor.h  | 57 ++++++++++++++++++++++++++++++
 3 files changed, 59 insertions(+), 54 deletions(-)
 create mode 100644 xen/include/asm-generic/monitor.h
xen/arch/arm/include/asm/monitor.h +1 -27
index 7567be66bd..045217c310 100644
@@ -25,33 +25,7 @@
 #include <xen/sched.h>
 #include <public/domctl.h>
 
-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 ARM. */
-    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 ARM. */
-    return 0;
-}
-
-static inline
-void arch_monitor_cleanup_domain(struct domain *d)
-{
-    /* No arch-specific domain cleanup on ARM. */
-}
+#include <asm-generic/monitor.h>
 
 static inline uint32_t arch_monitor_get_capabilities(struct domain *d)
 {
xen/arch/ppc/include/asm/monitor.h +1 -27
index e5b0282bf1..89000dacc6 100644
@@ -6,33 +6,7 @@
 #include <public/domctl.h>
 #include <xen/errno.h>
 
-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 PPC. */
-    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 PPC. */
-    return 0;
-}
-
-static inline
-void arch_monitor_cleanup_domain(struct domain *d)
-{
-    /* No arch-specific domain cleanup on PPC. */
-}
+#include <asm-generic/monitor.h>
 
 static inline uint32_t arch_monitor_get_capabilities(struct domain *d)
 {
xen/include/asm-generic/monitor.h new file +57 -0

57 lines not on this page · raw message

Signature · 1 line
2.43.0
#3 lore raw

PATCH v5 3/7 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 V5:
- Added Acked-by: Jan Beulich <[email protected]>
- Updated the comment around first_valid_mfn. ( Arm -> GENERIC )
- Added Acked-by: Shawn Anastasio <[email protected]>
---
Changes in V4:
- Updated guards name: *ARCH_GENERIC* -> *ASM_GENERIC*.
- Moved inclusion of xen/mm-frame.h under "#ifndef CONFIG_NUMA".
- Added Reviewed-by: Michal Orzel <[email protected]>.
---
Changes in V3:
- Remove old header inclusion in asm-generic numa.h and include <xen/mm-frame.h> and <xen/stdint.h>
- Drop Arm and PPC's numa.h and use asm-generic version instead.
---
Changes in V2:
- update the commit message.
- change u8 to uint8_t.
- add ifnded CONFIG_NUMA.

---
 xen/arch/arm/include/asm/Makefile             |  1 +
 xen/arch/ppc/include/asm/Makefile             |  1 +
 xen/arch/ppc/include/asm/numa.h               | 26 -------------------
 .../asm => include/asm-generic}/numa.h        | 16 +++++++-----
 4 files changed, 12 insertions(+), 32 deletions(-)
 delete mode 100644 xen/arch/ppc/include/asm/numa.h
 rename xen/{arch/arm/include/asm => include/asm-generic}/numa.h (67%)
xen/arch/arm/include/asm/Makefile +1 -0
index 8221429c2c..0c855a798a 100644
@@ -2,6 +2,7 @@
 generic-y += altp2m.h
 generic-y += hardirq.h
 generic-y += iocap.h
+generic-y += numa.h
 generic-y += paging.h
 generic-y += percpu.h
 generic-y += random.h
xen/arch/ppc/include/asm/Makefile +1 -0
index a8e848d4d0..f09c5ea8a1 100644
@@ -4,6 +4,7 @@ generic-y += div64.h
 generic-y += hardirq.h
 generic-y += hypercall.h
 generic-y += iocap.h
+generic-y += numa.h
 generic-y += paging.h
 generic-y += percpu.h
 generic-y += random.h
xen/arch/ppc/include/asm/numa.h deleted +0 -26
deleted file mode 100644
index 7fdf66c3da..0000000000
@@ -1,26 +0,0 @@
-#ifndef __ASM_PPC_NUMA_H__
-#define __ASM_PPC_NUMA_H__
-
-#include <xen/types.h>
-#include <xen/mm.h>
-
-typedef uint8_t nodeid_t;
-
-/* 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 PPC, 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)
-
-#define arch_want_default_dmazone() (false)
-
-#endif /* __ASM_PPC_NUMA_H__ */
xen/include/asm-generic/numa.h renamed from xen/arch/arm/include/asm/numa.h +10 -6
similarity index 67%
rename from xen/arch/arm/include/asm/numa.h
rename to xen/include/asm-generic/numa.h
index e2bee2bd82..7f95a77e89 100644
@@ -1,18 +1,21 @@
-#ifndef __ARCH_ARM_NUMA_H
-#define __ARCH_ARM_NUMA_H
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __ASM_GENERIC_NUMA_H
+#define __ASM_GENERIC_NUMA_H
 
-#include <xen/mm.h>
+#include <xen/stdint.h>
 
-typedef u8 nodeid_t;
+typedef uint8_t nodeid_t;
 
 #ifndef CONFIG_NUMA
 
+#include <xen/mm-frame.h>
+
 /* 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
+ * TODO: make first_valid_mfn static when NUMA is supported on GENERIC, this
  * is required because the dummy helpers are using it.
  */
 extern mfn_t first_valid_mfn;
@@ -26,7 +29,8 @@ extern mfn_t first_valid_mfn;
 
 #define arch_want_default_dmazone() (false)
 
-#endif /* __ARCH_ARM_NUMA_H */
+#endif /* __ASM_GENERIC_NUMA_H */
+
 /*
  * Local variables:
  * mode: C
Signature · 1 line
2.43.0
#4 lore raw

PATCH v5 4/7 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.

Drop Arm and PPC's softirq.h and use asm-generic version instead.

---
Changes in V5:
- Strayed "Added" in commit message
- Added Acked-by: Shawn Anastasio <[email protected]>
---
Changes in V4:
- Added Reviewed-by: Michal Orzel <[email protected]>
- Added Acked-by: Jan Beulich <[email protected]>
---
Changes in V3:
- Drop Arm and PPC's softirq.h
- Update the commit message.
---
Changes in V2:
- update the commit message.

---
 xen/arch/arm/include/asm/Makefile                         | 1 +
 xen/arch/ppc/include/asm/Makefile                         | 1 +
 xen/arch/ppc/include/asm/softirq.h                        | 8 --------
 .../arm/include/asm => include/asm-generic}/softirq.h     | 7 ++++---
 4 files changed, 6 insertions(+), 11 deletions(-)
 delete mode 100644 xen/arch/ppc/include/asm/softirq.h
 rename xen/{arch/arm/include/asm => include/asm-generic}/softirq.h (56%)
xen/arch/arm/include/asm/Makefile +1 -0
index 0c855a798a..a28cc5d1b1 100644
@@ -6,4 +6,5 @@ generic-y += numa.h
 generic-y += paging.h
 generic-y += percpu.h
 generic-y += random.h
+generic-y += softirq.h
 generic-y += vm_event.h
xen/arch/ppc/include/asm/Makefile +1 -0
index f09c5ea8a1..efd72862c8 100644
@@ -8,4 +8,5 @@ generic-y += numa.h
 generic-y += paging.h
 generic-y += percpu.h
 generic-y += random.h
+generic-y += softirq.h
 generic-y += vm_event.h
xen/arch/ppc/include/asm/softirq.h deleted +0 -8
deleted file mode 100644
index a0b28a5e51..0000000000
@@ -1,8 +0,0 @@
-#ifndef __ASM_PPC_SOFTIRQ_H__
-#define __ASM_PPC_SOFTIRQ_H__
-
-#define NR_ARCH_SOFTIRQS 0
-
-#define arch_skip_send_event_check(cpu) 0
-
-#endif /* __ASM_PPC_SOFTIRQ_H__ */
xen/include/asm-generic/softirq.h renamed from xen/arch/arm/include/asm/softirq.h +4 -3
similarity index 56%
rename from xen/arch/arm/include/asm/softirq.h
rename to xen/include/asm-generic/softirq.h
index 976e0ebd70..83be855e50 100644
@@ -1,11 +1,12 @@
-#ifndef __ASM_SOFTIRQ_H__
-#define __ASM_SOFTIRQ_H__
+/* 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_SOFTIRQ_H__ */
+#endif /* __ASM_GENERIC_SOFTIRQ_H__ */
 /*
  * Local variables:
  * mode: C
Signature · 1 line
2.43.0
#5 lore raw

PATCH v5 5/7 xen: ifdef inclusion of <asm/grant_table.h> in <xen/grant_table.h>

In reply to Oleksii Kurochko

Ifdef-ing 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.

The following changes were done for Arm:
<asm/grant_table.h> should be included directly because it contains gnttab_dom0_frames() macros which is unique for Arm and is used in arch/arm/domain_build.c.
<asm/grant_table.h> is #ifdef-ed with CONFIG_GRANT_TABLE in <xen/grant_table.h> so in case of !CONFIG_GRANT_TABLE gnttab_dom0_frames won't be available for use in arch/arm/domain_build.c.

---
Changes in V5:
- Added dependencies for "Config GRANT_TABLE" to be sure that randconfig will not turn on the config.
---
Changes in V4:
- Nothing changed. Only rebase.
---
Changes in V3:
- Remove unnecessary comment.

---
 xen/arch/arm/domain_build.c            | 1 +
 xen/arch/ppc/include/asm/grant_table.h | 5 -----
 xen/common/Kconfig                     | 1 +
 xen/include/xen/grant_table.h          | 3 +++
 4 files changed, 5 insertions(+), 5 deletions(-)
 delete mode 100644 xen/arch/ppc/include/asm/grant_table.h
xen/arch/arm/domain_build.c +1 -0
index df66fb88d8..28df515a3d 100644
@@ -36,6 +36,7 @@
 
 #include <xen/irq.h>
 #include <xen/grant_table.h>
+#include <asm/grant_table.h>
 #include <xen/serial.h>
 
 #define STATIC_EVTCHN_NODE_SIZE_CELLS 2
xen/arch/ppc/include/asm/grant_table.h deleted +0 -5
deleted file mode 100644
index d0ff58dd3d..0000000000
@@ -1,5 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-#ifndef __ASM_PPC_GRANT_TABLE_H__
-#define __ASM_PPC_GRANT_TABLE_H__
-
-#endif /* __ASM_PPC_GRANT_TABLE_H__ */
xen/common/Kconfig +1 -0
index 310ad4229c..13e26ca06f 100644
@@ -15,6 +15,7 @@ config CORE_PARKING
 config GRANT_TABLE
 	bool "Grant table support" if EXPERT
 	default y
+	depends on ARM || X86
 	---help---
 	  Grant table provides a generic mechanism to memory sharing
 	  between domains. This shared memory interface underpins the
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.43.0
#6 lore raw

Re: [PATCH v5 5/7] xen: ifdef inclusion of <asm/grant_table.h> in <xen/grant_table.h>

Quoted 12 lines · Oleksii Kurochko

Ifdef-ing 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.

The following changes were done for Arm:
<asm/grant_table.h> should be included directly because it contains gnttab_dom0_frames() macros which is unique for Arm and is used in arch/arm/domain_build.c.
<asm/grant_table.h> is #ifdef-ed with CONFIG_GRANT_TABLE in <xen/grant_table.h> so in case of !CONFIG_GRANT_TABLE gnttab_dom0_frames won't be available for use in arch/arm/domain_build.c.

Quoted 1 line

Not really, no: In particular ...

xen/common/Kconfig config CORE_PARKING · line 18

Quoted 7 lines
xen/common/Kconfig +1 -0
@@ -15,6 +15,7 @@ config CORE_PARKING
 config GRANT_TABLE
 	bool "Grant table support" if EXPERT
 	default y
+	depends on ARM || X86

... this I explicitly said I consider wrong to add.

Jan

author
#7 lore raw

Re: [PATCH v5 5/7] xen: ifdef inclusion of <asm/grant_table.h> in <xen/grant_table.h>

Quoted 18 lines · Jan Beulich
Quoted 13 lines · Oleksii Kurochko

Ifdef-ing 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.

The following changes were done for Arm:
<asm/grant_table.h> should be included directly because it contains gnttab_dom0_frames() macros which is unique for Arm and is used in arch/arm/domain_build.c.
<asm/grant_table.h> is #ifdef-ed with CONFIG_GRANT_TABLE in <xen/grant_table.h> so in case of !CONFIG_GRANT_TABLE gnttab_dom0_frames
won't be available for use in arch/arm/domain_build.c.

Quoted 1 line

Not really, no: In particular ...

Quoted 9 lines

xen/common/Kconfig config CORE_PARKING · line 18

Quoted 7 lines
xen/common/Kconfig +0 -0
@@ -15,6 +15,7 @@ config CORE_PARKING

 config GRANT_TABLE
  bool "Grant table support" if EXPERT
  default y

xen/common/Kconfig +1 -0
+	depends on ARM || X86

... this I explicitly said I consider wrong to add.

Then I misunderstood you.

What about to do the same as with MEM_ACCESS config and introduce HAS_GRANT_TABLE?

Or would it be better just update "depends on" to !RISCV && !PPC?

~ Oleksii

#8 lore raw

Re: [PATCH v5 5/7] xen: ifdef inclusion of <asm/grant_table.h> in <xen/grant_table.h>

Quoted 28 lines · Oleksii
Quoted 18 lines · Jan Beulich
Quoted 13 lines · Oleksii Kurochko

Ifdef-ing 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.

The following changes were done for Arm:
<asm/grant_table.h> should be included directly because it contains gnttab_dom0_frames() macros which is unique for Arm and is used in arch/arm/domain_build.c.
<asm/grant_table.h> is #ifdef-ed with CONFIG_GRANT_TABLE in <xen/grant_table.h> so in case of !CONFIG_GRANT_TABLE gnttab_dom0_frames
won't be available for use in arch/arm/domain_build.c.

Quoted 1 line

Not really, no: In particular ...

Quoted 9 lines

xen/common/Kconfig config CORE_PARKING · line 18

Quoted 7 lines
xen/common/Kconfig +0 -0
@@ -15,6 +15,7 @@ config CORE_PARKING

 config GRANT_TABLE
  bool "Grant table support" if EXPERT
  default y

xen/common/Kconfig +1 -0
+	depends on ARM || X86

... this I explicitly said I consider wrong to add.

Quoted 4 lines

Then I misunderstood you.

What about to do the same as with MEM_ACCESS config and introduce HAS_GRANT_TABLE?

That's an option, provided (and I put that under question before) there realistically can be ports which don't mean to support grant tables. You mentioned that things are fine for the dom0less setup you're testing, but I don't think a fully-functional Xen port makes sense to only support dom0less. But of course I'm willing to hear arguments to the contrary.

Quoted 1 line

Or would it be better just update "depends on" to !RISCV && !PPC?

Definitely not.

Jan

author
#9 lore raw

Re: [PATCH v5 5/7] xen: ifdef inclusion of <asm/grant_table.h> in <xen/grant_table.h>

Quoted 18 lines · Jan Beulich
Quoted 17 lines · Oleksii
Quoted 16 lines · Jan Beulich
Quoted 15 lines · Oleksii Kurochko

Ifdef-ing 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.

The following changes were done for Arm:
<asm/grant_table.h> should be included directly because it contains
gnttab_dom0_frames() macros which is unique for Arm and is used in
arch/arm/domain_build.c.
<asm/grant_table.h> is #ifdef-ed with CONFIG_GRANT_TABLE in <xen/grant_table.h> so in case of !CONFIG_GRANT_TABLE gnttab_dom0_frames
won't be available for use in arch/arm/domain_build.c.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

Not really, no: In particular ...

If it is comment was addressed to Suggested-by. Then it was added when we didn't have a discussion about config GRANT_TABLE and depends on things.
Probably I had to remove it after I started to update Kconfig things.

I am really sorry if I had to remove that before send this patch version.

Quoted 15 lines
Quoted 10 lines
Quoted 10 lines

xen/common/Kconfig config CORE_PARKING · line 18

Quoted 8 lines
xen/common/Kconfig +0 -0
@@ -15,6 +15,7 @@ config CORE_PARKING

 config GRANT_TABLE
  bool "Grant table support" if EXPERT
  default y

xen/common/Kconfig +1 -0
+	depends on ARM || X86

... this I explicitly said I consider wrong to add.

Quoted 4 lines

Then I misunderstood you.

What about to do the same as with MEM_ACCESS config and introduce HAS_GRANT_TABLE?

Quoted 9 lines

That's an option, provided (and I put that under question before) there
realistically can be ports which don't mean to support grant tables. You mentioned that things are fine for the dom0less setup you're testing,
but I don't think a fully-functional Xen port makes sense to only support
dom0less. But of course I'm willing to hear arguments to the contrary.

Unfortunately, I am not experienced in the depths of Xen, but I used grant tables in Arm to share frames between dom0 and guest in PV drivers. It should be another usage of grant tables.

I assume it is possible not to use grant tables and come up with another solution, but it isn't the best idea, and I don't have any reason not to use what already exists and works. Are there any cases where something else, instead of grant tables, is used?

Therefore, I agree that a fully functional Xen port will support only dom0less, but it can live for a long time only with dom0less. And in non-dom0less grant tables will be used somewhere sooner or later.

Quoted 4 lines
Quoted 2 lines

Or would it be better just update "depends on" to !RISCV && !PPC?

Definitely not.

So we have a "weird" situation.

Considering the message above, grant tables are likely to be used anyway. From this point of view, there is not a lot of sense in introducing "temporary" HAS_GRANT_TABLE as, at some point, every architecture will use grant tables ( the same is with "depends on !RISCV && &!PPC or any other combination ), and HAS_GRANT_TABLE won't be needed any more except the time when support for new architecture will be started and it will live without grant tables for some time.

But an introduction of HAS_GRANT_TABLE makes sense ( at least, when the work on support for new architectures will be started ) for me.

If you ( or anyone else ) don't mind, I'll update the patch with an introduction of HAS_GRANT_TABLE.

~ Oleksii

#10 lore raw

Re: [PATCH v5 5/7] xen: ifdef inclusion of <asm/grant_table.h> in <xen/grant_table.h>

Quoted 2 lines · Oleksii

If you ( or anyone else ) don't mind, I'll update the patch with an introduction of HAS_GRANT_TABLE.

I won't NAK such a patch, but unless convincing arguments appear I also won't ACK it.

Jan

author
#11 lore raw

Re: [PATCH v5 5/7] xen: ifdef inclusion of <asm/grant_table.h> in <xen/grant_table.h>

Quoted 7 lines · Jan Beulich
Quoted 2 lines · Oleksii

If you ( or anyone else ) don't mind, I'll update the patch with an introduction of HAS_GRANT_TABLE.

I won't NAK such a patch, but unless convincing arguments appear I also
won't ACK it.

I am going to disable GRANT_TABLE config for RISC-V ( and PPC? ) by providing a separate YAML file ( riscv-fixed-randconfig.yaml ) with the following content:
.riscv-fixed-randconfig:
variables:
EXTRA_FIXED_RANDCONFIG:
CONFIG_COVERAGE=n
CONFIG_GRANT_TABLE=n
CONFIG_MEM_ACCESS=n # this I'll add in the next patch where asm-
geneic for mem_access.h is introduced

And then for riscv*randconfig jobs do the following:
archlinux-current-gcc-riscv64-randconfig:
extends:
- .gcc-riscv64-cross-build
variables:
CONTAINER: archlinux:current-riscv64
KBUILD_DEFCONFIG: tiny64_defconfig
RANDCONFIG: y
EXTRA_FIXED_RANDCONFIG: !reference [.riscv-fixed-randconfig,
variables, EXTRA_FIXED_RANDCONFIG]

For RISC-V, I prefer having a separate file for all the EXTRA_FIXED_RANDCONFIG because in another patch series [1], I'll introduce a large number of disabled configs for randconfig.

For PPC, I don't think it's necessary to introduce a separate YAML file for EXTRA_FIXED_RANDCONFIG. For the time being, it is only necessary to disable two configs: CONFIG_GRANT_TABLE and CONFIG_MEM_ACCESS (in the next patch of this series).

If this solution is acceptable to you, can I retain your 'Suggested- by'?"

[1]:
https://lore.kernel.org/xen-devel/b4e85f8f58787b4d179022973ce25673d6b56e36.1700761381.git.oleksii.kurochko@gmail.com/

~ Oleksii

#12 lore raw

Re: [PATCH v5 5/7] xen: ifdef inclusion of <asm/grant_table.h> in <xen/grant_table.h>

Quoted 30 lines · Oleksii
Quoted 7 lines · Jan Beulich
Quoted 2 lines · Oleksii

If you ( or anyone else ) don't mind, I'll update the patch with an introduction of HAS_GRANT_TABLE.

I won't NAK such a patch, but unless convincing arguments appear I also
won't ACK it.

I am going to disable GRANT_TABLE config for RISC-V ( and PPC? ) by providing a separate YAML file ( riscv-fixed-randconfig.yaml ) with the following content:
.riscv-fixed-randconfig:
variables:
EXTRA_FIXED_RANDCONFIG:
CONFIG_COVERAGE=n
CONFIG_GRANT_TABLE=n
CONFIG_MEM_ACCESS=n # this I'll add in the next patch where asm-
geneic for mem_access.h is introduced

And then for riscv*randconfig jobs do the following:
archlinux-current-gcc-riscv64-randconfig:
extends:
- .gcc-riscv64-cross-build
variables:
CONTAINER: archlinux:current-riscv64
KBUILD_DEFCONFIG: tiny64_defconfig
RANDCONFIG: y
EXTRA_FIXED_RANDCONFIG: !reference [.riscv-fixed-randconfig,
variables, EXTRA_FIXED_RANDCONFIG]

Quoted 8 lines

For RISC-V, I prefer having a separate file for all the EXTRA_FIXED_RANDCONFIG because in another patch series [1], I'll introduce a large number of disabled configs for randconfig.

For PPC, I don't think it's necessary to introduce a separate YAML file for EXTRA_FIXED_RANDCONFIG. For the time being, it is only necessary to disable two configs: CONFIG_GRANT_TABLE and CONFIG_MEM_ACCESS (in the next patch of this series).

Why would this be different for PPC and RISC-V?

Quoted 2 lines

If this solution is acceptable to you, can I retain your 'Suggested- by'?"

No, please don't. I've replied to Andrew on the other thread - I don't see why helping just gitlab-CI is desirable. I'm actually surprised Linux have no solution ready for use, as the underlying problem of not all settings necessarily being valid to use ought to affect them as well. Then again perhaps this really only is a transient issue during arch bringup ... In which case the approach taken here may be fine, but it still wouldn't be what I suggested. It may then be Stefano or Andrew who you could consider for such a tag.

Jan

author
#13 lore raw

Re: [PATCH v5 5/7] xen: ifdef inclusion of <asm/grant_table.h> in <xen/grant_table.h>

Quoted 47 lines · Jan Beulich
Quoted 38 lines · Oleksii
Quoted 9 lines · Jan Beulich
Quoted 3 lines · Oleksii

If you ( or anyone else ) don't mind, I'll update the patch with an
introduction of HAS_GRANT_TABLE.

I won't NAK such a patch, but unless convincing arguments appear I
also
won't ACK it.

I am going to disable GRANT_TABLE config for RISC-V ( and PPC? ) by providing a separate YAML file ( riscv-fixed-randconfig.yaml ) with the
following content:
.riscv-fixed-randconfig:
  variables:
    EXTRA_FIXED_RANDCONFIG:
      CONFIG_COVERAGE=n
      CONFIG_GRANT_TABLE=n
      CONFIG_MEM_ACCESS=n # this I'll add in the next patch where asm-
geneic for mem_access.h is introduced

And then for riscv*randconfig jobs do the following:
archlinux-current-gcc-riscv64-randconfig:
  extends:
    - .gcc-riscv64-cross-build
  variables:
    CONTAINER: archlinux:current-riscv64
    KBUILD_DEFCONFIG: tiny64_defconfig
    RANDCONFIG: y
    EXTRA_FIXED_RANDCONFIG: !reference [.riscv-fixed-randconfig, variables, EXTRA_FIXED_RANDCONFIG]

For RISC-V, I prefer having a separate file for all the EXTRA_FIXED_RANDCONFIG because in another patch series [1], I'll introduce a large number of disabled configs for randconfig.

Quoted 7 lines

For PPC, I don't think it's necessary to introduce a separate YAML file
for EXTRA_FIXED_RANDCONFIG. For the time being, it is only necessary to
disable two configs: CONFIG_GRANT_TABLE and CONFIG_MEM_ACCESS (in the
next patch of this series).

Quoted 1 line

Why would this be different for PPC and RISC-V?

I haven't investigated that. Perhaps Shawn covered more stubs for a larger numberof configs, so he didn't encounter issues with some configs. For example, during my tests with the inclusion of riscv-fixed-
randconfig.yaml,
randconfig jobs for RISC-V failed several times on perf.c.
At least, during the inclusion of #include <asm/perfc.h>, which is not
provided
for RISC-V, so CONFIG_PERFC_COUNTER is disabled for RISC-V.

However, Shawn either provided necessary stubs for CONFIG_PERF_COUNTERS,
or it is just luck that such an issue didn't occur for PPC."

Quoted 8 lines
Quoted 4 lines

If this solution is acceptable to you, can I retain your 'Suggested-
by'?"

No, please don't. I've replied to Andrew on the other thread - I don't
see why helping just gitlab-CI is desirable. I'm actually surprised

Well, now I understand your point better, and it makes sense. I was more confident in the GitLab-CI solution before you replied on the other thread.

However, it seems to me that randconfig exists only for testing purposes and usually doesn't require running locally. Therefore, it makes sense to perform all these tasks only for GitLab-CI to avoid complicating things around the Makefile in case anything related to KCONFIG_ALLCONFIG needs to be in sync with Linux.

In any case, I believe it's a good idea to wait for Andrew's feedback.

Quoted 5 lines

Linux have no solution ready for use, as the underlying problem of not
all settings necessarily being valid to use ought to affect them as well. Then again perhaps this really only is a transient issue during arch bringup ...

"It is challenging for me, at least, to predict whether all options mentioned in EXTRA_FIXED_RANDCONFIG will be disabled in the future. Most of them will likely be implemented, but certainty is difficult to ascertain."

Quoted 4 lines

 In which case the approach taken here may be fine, but it still wouldn't be what I suggested. It may then be Stefano or Andrew
who you could consider for such a tag.

I'm a bit confused again. In this case, it seems that both you andStefano or Andrew should be on the suggested list. You proposed the approach with "#ifdef CONFIG_GRANT_TABLE #include
<asm/grant_table.h> #endif".
Stefano and Andrew suggested how to disable CONFIG_GRANT_TABLE for the
config.

Could you please clarify where my understanding is incorrect?

~ Oleksii

#14 lore raw

Re: [PATCH v5 5/7] xen: ifdef inclusion of <asm/grant_table.h> in <xen/grant_table.h>

Quoted 8 lines · Oleksii
Quoted 4 lines · Jan Beulich

 In which case the approach taken here may be fine, but it still wouldn't be what I suggested. It may then be Stefano or Andrew
who you could consider for such a tag.

I'm a bit confused again. In this case, it seems that both you andStefano or Andrew should be on the suggested list. You proposed the approach with "#ifdef CONFIG_GRANT_TABLE #include
<asm/grant_table.h> #endif".

But you're not meaning to use that approach anymore, are you?

Jan

Quoted 6 lines

Stefano and Andrew suggested how to disable CONFIG_GRANT_TABLE for the config.

Could you please clarify where my understanding is incorrect?

~ Oleksii

author
#15 lore raw

Re: [PATCH v5 5/7] xen: ifdef inclusion of <asm/grant_table.h> in <xen/grant_table.h>

Quoted 6 lines · Jan Beulich
Quoted 5 lines · Oleksii
Quoted 4 lines · Jan Beulich

 In which case the approach taken here may be fine, but it still wouldn't be what I suggested. It may then be Stefano or Andrew
who you could consider for such a tag.

Quoted 6 lines
Quoted 4 lines

I'm a bit confused again. In this case, it seems that both you andStefano or Andrew should be on the suggested list. You proposed the approach with "#ifdef CONFIG_GRANT_TABLE #include <asm/grant_table.h> #endif".

But you're not meaning to use that approach anymore, are you?

No, I am going to use it because there is still a need to use #ifdef for #include <asm/grant_table.h> in <xen/grant_table.h> to avoid providing a useless empty asm/grant_table.h header if CONFIG_GRANT_TABLE isn't supported.

~ Oleksii

#16 lore raw

Re: [PATCH v5 5/7] xen: ifdef inclusion of <asm/grant_table.h> in <xen/grant_table.h>

Quoted 12 lines · Oleksii
Quoted 11 lines · Jan Beulich
Quoted 9 lines · Oleksii
Quoted 4 lines · Jan Beulich

 In which case the approach taken here may be fine, but it still wouldn't be what I suggested. It may then be Stefano or Andrew
who you could consider for such a tag.

I'm a bit confused again. In this case, it seems that both you andStefano or Andrew should be on the suggested list. You proposed the approach with "#ifdef CONFIG_GRANT_TABLE #include <asm/grant_table.h> #endif".

Quoted 5 lines
Quoted 1 line

But you're not meaning to use that approach anymore, are you?

No, I am going to use it because there is still a need to use #ifdef for #include <asm/grant_table.h> in <xen/grant_table.h> to avoid providing a useless empty asm/grant_table.h header if CONFIG_GRANT_TABLE isn't supported.

Then _there_ keeping the tag is okay of course. But the CI change (or whatever is come of it) will need treating in whichever way it is going to move.

Jan

#17 lore raw

PATCH v5 6/7 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.

For Arm it was explicitly added inclusion of <asm/mem_access.h> for p2m.c and traps.c because they require some functions from <asm/mem_access.h> which aren't available in case of !CONFIG_MEM_ACCESS.

---
Changes in V5:
- Added dependencies for "Config MEM_ACCESS" to be sure that randconfig will not turn on the config.
---
Changes in V4:
- Nothing changed. Only rebase.
---
Changes in V3:
- Remove unnecessary comment.

---
 xen/arch/arm/p2m.c                    | 1 +
 xen/arch/arm/traps.c                  | 1 +
 xen/arch/ppc/include/asm/mem_access.h | 5 -----
 xen/common/Kconfig                    | 2 +-
 xen/include/xen/mem_access.h          | 2 ++
 5 files changed, 5 insertions(+), 6 deletions(-)
 delete mode 100644 xen/arch/ppc/include/asm/mem_access.h
xen/arch/arm/p2m.c +1 -0
index b991b76ce4..2465c266e9 100644
@@ -7,6 +7,7 @@
 #include <asm/event.h>
 #include <asm/flushtlb.h>
 #include <asm/guest_walk.h>
+#include <asm/mem_access.h>
 #include <asm/page.h>
 #include <asm/traps.h>
 
xen/arch/arm/traps.c +1 -0
index 3784e8276e..37a457f4b1 100644
@@ -35,6 +35,7 @@
 #include <asm/cpufeature.h>
 #include <asm/event.h>
 #include <asm/hsr.h>
+#include <asm/mem_access.h>
 #include <asm/mmio.h>
 #include <asm/regs.h>
 #include <asm/smccc.h>
xen/arch/ppc/include/asm/mem_access.h deleted +0 -5
deleted file mode 100644
index e7986dfdbd..0000000000
@@ -1,5 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-#ifndef __ASM_PPC_MEM_ACCESS_H__
-#define __ASM_PPC_MEM_ACCESS_H__
-
-#endif /* __ASM_PPC_MEM_ACCESS_H__ */
xen/common/Kconfig +1 -1
index 13e26ca06f..d84e395a0b 100644
@@ -87,7 +87,7 @@ config MEM_ACCESS_ALWAYS_ON
 config MEM_ACCESS
 	def_bool MEM_ACCESS_ALWAYS_ON
 	prompt "Memory Access and VM events" if !MEM_ACCESS_ALWAYS_ON
-	depends on HVM
+	depends on HVM && (ARM || X86)
 	---help---
 
 	  Framework to configure memory access types for guests and receive
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.43.0
#18 lore raw

Re: [PATCH v5 6/7] xen/asm-generic: ifdef inclusion of <asm/mem_access.h>

xen/common/Kconfig config MEM_ACCESS_ALWAYS_ON · line 90

Quoted 8 lines · Oleksii Kurochko
xen/common/Kconfig +1 -1
@@ -87,7 +87,7 @@ config MEM_ACCESS_ALWAYS_ON
 config MEM_ACCESS
 	def_bool MEM_ACCESS_ALWAYS_ON
 	prompt "Memory Access and VM events" if !MEM_ACCESS_ALWAYS_ON
-	depends on HVM
+	depends on HVM && (ARM || X86)

While - unlike for GRANT_TABLE - I view going this route as an option, I still think it wants doing without explicitly naming architectures here. There wants to be a HAS_MEM_ACCESS, selected by Arm's Kconfig and by MEM_ACCESS_ALWAYS_ON (which in turn x86 selects). This could then also replace the HVM dependency here - x86 ought to select MEM_ACCESS_ALWAYS_ON only when HVM is enabled.

Jan

author
#19 lore raw

Re: [PATCH v5 6/7] xen/asm-generic: ifdef inclusion of <asm/mem_access.h>

Quoted 13 lines · Jan Beulich

xen/common/Kconfig config MEM_ACCESS_ALWAYS_ON · line 90

Quoted 9 lines · Oleksii Kurochko
xen/common/Kconfig +0 -0
@@ -87,7 +87,7 @@ config MEM_ACCESS_ALWAYS_ON

 config MEM_ACCESS
  def_bool MEM_ACCESS_ALWAYS_ON
  prompt "Memory Access and VM events" if
!MEM_ACCESS_ALWAYS_ON

xen/common/Kconfig +1 -1
-	depends on HVM
+	depends on HVM && (ARM || X86)

While - unlike for GRANT_TABLE - I view going this route as an option, I

Quoted 8 lines

still think it wants doing without explicitly naming architectures here.
There wants to be a HAS_MEM_ACCESS, selected by Arm's Kconfig and by MEM_ACCESS_ALWAYS_ON (which in turn x86 selects). This could then also
replace the HVM dependency here - x86 ought to select MEM_ACCESS_ALWAYS_ON
only when HVM is enabled.

Thanks.

It will be definetely better to introduce HAS_MEM_ACCESS.

~ Oleksii

#20 lore raw

PATCH v5 7/7 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.
- #ifdef CONFIG_HAS_DEVICE_TREE related things.
- #ifdef-ing iommu related things with CONFIG_HAS_PASSTHROUGH.

Also Arm and PPC are switched to asm-generic version of device.h

---

Jan wrote the following:
Overall I think there are too many changes done all in one go here. But it's mostly Arm which is affected, so I'll leave judging about that to the Arm maintainers.

Arm maintainers will it be fine for you to not split the patch?

---
Changes in V5:
- Removed generated file: xen/include/headers++.chk.new
- Removed pointless #ifdef CONFIG_HAS_DEVICE_TREE ... #endif for PPC as CONFIG_HAS_DEVICE_TREE will be always used for PPC.
---
Changes in V4:
- Updated the commit message
- Switched Arm and PPC to asm-generic version of device.h
- Replaced HAS_PCI with CONFIG_HAS_PCI
- ifdef-ing iommu filed of dev_archdata struct with CONFIG_HAS_PASSTHROUGH
- ifdef-ing iommu_fwspec of device struct with CONFIG_HAS_PASSTHROUGH
- ifdef-ing DT related things with CONFIG_HAS_DEVICE_TREE
- Updated the commit message ( remove a note with question about
if device.h should be in asm-generic or not )
- Replaced DEVICE_IC with DEVICE_INTERRUPT_CONTROLLER
- Rationalized usage of CONFIG_HAS_* in device.h
- Fixed indents for ACPI_DEVICE_START and ACPI_DEVICE_END
---
Changes in V3:
- ifdef device tree related things.
- update the commit message
---
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/arch/arm/device.c                         |  15 ++-
 xen/arch/arm/domain_build.c                   |   2 +-
 xen/arch/arm/gic-v2.c                         |   4 +-
 xen/arch/arm/gic-v3.c                         |   6 +-
 xen/arch/arm/gic.c                            |   4 +-
 xen/arch/arm/include/asm/Makefile             |   1 +
 xen/arch/ppc/include/asm/Makefile             |   1 +
 xen/arch/ppc/include/asm/device.h             |  53 --------
 .../asm => include/asm-generic}/device.h      | 125 +++++++++++-------
 9 files changed, 102 insertions(+), 109 deletions(-)
 delete mode 100644 xen/arch/ppc/include/asm/device.h
 rename xen/{arch/arm/include/asm => include/asm-generic}/device.h (79%)
xen/arch/arm/device.c +12 -3
index 1f631d3274..affbe79f9a 100644
@@ -16,7 +16,10 @@
 #include <xen/lib.h>
 
 extern const struct device_desc _sdevice[], _edevice[];
+
+#ifdef CONFIG_ACPI
 extern const struct acpi_device_desc _asdevice[], _aedevice[];
+#endif
 
 int __init device_init(struct dt_device_node *dev, enum device_class class,
                        const void *data)
@@ -45,6 +48,7 @@ int __init device_init(struct dt_device_node *dev, enum device_class class,
     return -EBADF;
 }
 
+#ifdef CONFIG_ACPI
 int __init acpi_device_init(enum device_class class, const void *data, int class_type)
 {
     const struct acpi_device_desc *desc;
@@ -61,6 +65,7 @@ int __init acpi_device_init(enum device_class class, const void *data, int class
 
     return -EBADF;
 }
+#endif
 
 enum device_class device_get_class(const struct dt_device_node *dev)
 {
@@ -329,9 +334,13 @@ int handle_device(struct domain *d, struct dt_device_node *dev, p2m_type_t p2mt,
     struct map_range_data mr_data = {
         .d = d,
         .p2mt = p2mt,
-        .skip_mapping = !own_device ||
-                        (is_pci_passthrough_enabled() &&
-                        (device_get_class(dev) == DEVICE_PCI_HOSTBRIDGE)),
+        .skip_mapping =
+                        !own_device
+#ifdef CONFIG_HAS_PCI
+                        || (is_pci_passthrough_enabled() &&
+                        (device_get_class(dev) == DEVICE_PCI_HOSTBRIDGE))
+#endif
+                        ,
         .iomem_ranges = iomem_ranges,
         .irq_ranges = irq_ranges
     };
xen/arch/arm/domain_build.c +1 -1
index 28df515a3d..a0518993b1 100644
@@ -1651,7 +1651,7 @@ static int __init handle_node(struct domain *d, struct kernel_info *kinfo,
      * Replace these nodes with our own. Note that the original may be
      * used_by DOMID_XEN so this check comes first.
      */
-    if ( device_get_class(node) == DEVICE_GIC )
+    if ( device_get_class(node) == DEVICE_INTERRUPT_CONTROLLER )
         return make_gic_node(d, kinfo->fdt, node);
     if ( dt_match_node(timer_matches, node) )
         return make_timer_node(kinfo);
xen/arch/arm/gic-v2.c +2 -2
index cf392bfd1c..5d6885e389 100644
@@ -1366,7 +1366,7 @@ static const struct dt_device_match gicv2_dt_match[] __initconst =
     { /* sentinel */ },
 };
 
-DT_DEVICE_START(gicv2, "GICv2", DEVICE_GIC)
+DT_DEVICE_START(gicv2, "GICv2", DEVICE_INTERRUPT_CONTROLLER)
         .dt_match = gicv2_dt_match,
         .init = gicv2_dt_preinit,
 DT_DEVICE_END
@@ -1381,7 +1381,7 @@ static int __init gicv2_acpi_preinit(const void *data)
     return 0;
 }
 
-ACPI_DEVICE_START(agicv2, "GICv2", DEVICE_GIC)
+ACPI_DEVICE_START(agicv2, "GICv2", DEVICE_INTERRUPT_CONTROLLER)
         .class_type = ACPI_MADT_GIC_VERSION_V2,
         .init = gicv2_acpi_preinit,
 ACPI_DEVICE_END
xen/arch/arm/gic-v3.c +3 -3
index 18289cd645..9e135aeb3d 100644
@@ -1879,7 +1879,7 @@ static const struct dt_device_match gicv3_dt_match[] __initconst =
     { /* sentinel */ },
 };
 
-DT_DEVICE_START(gicv3, "GICv3", DEVICE_GIC)
+DT_DEVICE_START(gicv3, "GICv3", DEVICE_INTERRUPT_CONTROLLER)
         .dt_match = gicv3_dt_match,
         .init = gicv3_dt_preinit,
 DT_DEVICE_END
@@ -1894,12 +1894,12 @@ static int __init gicv3_acpi_preinit(const void *data)
     return 0;
 }
 
-ACPI_DEVICE_START(agicv3, "GICv3", DEVICE_GIC)
+ACPI_DEVICE_START(agicv3, "GICv3", DEVICE_INTERRUPT_CONTROLLER)
         .class_type = ACPI_MADT_GIC_VERSION_V3,
         .init = gicv3_acpi_preinit,
 ACPI_DEVICE_END
 
-ACPI_DEVICE_START(agicv4, "GICv4", DEVICE_GIC)
+ACPI_DEVICE_START(agicv4, "GICv4", DEVICE_INTERRUPT_CONTROLLER)
         .class_type = ACPI_MADT_GIC_VERSION_V4,
         .init = gicv3_acpi_preinit,
 ACPI_DEVICE_END
xen/arch/arm/gic.c +2 -2
index d922ea67aa..b5a9c8266c 100644
@@ -234,7 +234,7 @@ static void __init gic_dt_preinit(void)
         if ( !dt_get_parent(node) )
             continue;
 
-        rc = device_init(node, DEVICE_GIC, NULL);
+        rc = device_init(node, DEVICE_INTERRUPT_CONTROLLER, NULL);
         if ( !rc )
         {
             /* NOTE: Only one GIC is supported */
@@ -262,7 +262,7 @@ static void __init gic_acpi_preinit(void)
 
     dist = container_of(header, struct acpi_madt_generic_distributor, header);
 
-    if ( acpi_device_init(DEVICE_GIC, NULL, dist->version) )
+    if ( acpi_device_init(DEVICE_INTERRUPT_CONTROLLER, NULL, dist->version) )
         panic("Unable to find compatible GIC in the ACPI table\n");
 }
 #else
xen/arch/arm/include/asm/Makefile +1 -0
index a28cc5d1b1..c3f4291ee2 100644
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0-only
 generic-y += altp2m.h
+generic-y += device.h
 generic-y += hardirq.h
 generic-y += iocap.h
 generic-y += numa.h
xen/arch/ppc/include/asm/Makefile +1 -0
index efd72862c8..adb752b804 100644
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0-only
 generic-y += altp2m.h
+generic-y += device.h
 generic-y += div64.h
 generic-y += hardirq.h
 generic-y += hypercall.h
xen/arch/ppc/include/asm/device.h deleted +0 -53

53 lines not on this page · raw message

xen/include/asm-generic/device.h renamed from xen/arch/arm/include/asm/device.h +80 -45

177 lines not on this page · raw message

Signature · 1 line
2.43.0