Skip to contentSkip to conversation

Introduce generic headers

PATCH In review Oleksii Kurochko 6 participants 23 messages Feb 16, 2024 – Mar 7, 2024 RISC-V

lore
Share & tools
lore
#0 lore raw

v9 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 V9:
- Drop the patch "[PATCH v8 1/7] automation: ensure values in EXTRA_FIXED_RANDCONFIG are separated by new line" as better solution was suggested.
- introduce new follow-up patch for "xen/asm-generic: introduce generic device.h" ( it can be merged with patches 4,5 of this patch series ).
- All other changes please find in revision log to a patch.
---
Changes in V8:
- Add Acked-by Acked-by: Tamas K Lengyel <[email protected]> for patches:
[PATCH v7 4/7] xen/asm-generic: ifdef inclusion of <asm/mem_access.h> [PATCH v7 3/7] xen/asm-generic: introduce stub header monitor.h
- Update the commit messages for patches:
[PATCH v7 5/7] xen/asm-generic: introduce generic device.h
[PATCH v7 6/7] xen/arm: switch Arm to use asm-generic/device.h
- Drop #ifdef HAS_PCI in asm-generic/device.h to be consistent with other pci-related things in the header.
- Code styles fixes.
---
Changes in V7:
- The following patches were dropped because of rebasing as they were merged to staging:
- [PATCH v6 3/9] xen/asm-generic: introduce generic div64.h header
- [PATCH v6 6/9] xen/asm-generic: introduce stub header softirq.h
- [PATCH v6 7/9] xen: ifdef inclusion of <asm/grant_table.h> in <xen/grant_table.h>
- [PATCH v6 8/9] xen/asm-generic: ifdef inclusion of <asm/mem_access.h>
- [PATCH v6 5/9] xen/asm-generic: introduce stub header numa.h was dropped becaus of the patch: "[PATCH v2] NUMA: no need for asm/numa.h when !NUMA"
- Drop definition of arch_monitor_domctl_event for PPC.
- define arch_monitor_domctl_event in asm-generic/monitor.h.
- Add "define HAS_ARCH_MONITOR_DOMCTL_EVENT" in arm/.../monitor.h as it has arch specific implementation.
- keeping DEVICE_PCI_HOSTBRIDGE available for every build based on the reply:

    https://lore.kernel.org/xen-devel/[email protected]/

- add comment above enum device_type.h with explanation about DEV_TYPE_MAX.
- drop #ifdef HAS_PCI around "(device_get_class(dev) == DEVICE_PCI_HOSTBRIDGE))" in ARM code.
- separate patch "[PATCH v6 9/9] xen/asm-generic: introduce generic device.h" into 3 patches.
---
Changes in V6:
- Fix the build script to work properly with EXTRA_FIXED_RANDCONFIG.
- Introduce separate randconfig yaml with fixed configs for RISC-V.
- Disable CONFIG_GRANT_TABLE and CONFIG_MEM_ACCESS for PPC and RISC-V.
- Remove change in Kconfig/common for CONFIG_GRANT_TABLE and CONFIG_MEM_ACCESS.
- Rebase on top of the latest staging.
---
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):
automation: introduce fixed randconfig for RISC-V xen/asm-generic: introduce stub header monitor.h xen/asm-generic: ifdef inclusion of <asm/mem_access.h> xen/asm-generic: introduce generic device.h xen/arm: switch Arm to use asm-generic/device.h xen/ppc: switch PPC to use asm-generic/device.h xen/asm-generic: fold struct devarch into struct dev

 automation/gitlab-ci/build.yaml               |  14 ++-
 xen/arch/arm/device.c                         |   5 +
 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/arm/include/asm/monitor.h            |  25 +---
 xen/arch/arm/p2m.c                            |   1 +
 xen/arch/arm/traps.c                          |   1 +
 xen/arch/arm/xen.lds.S                        |   2 +
 xen/arch/ppc/configs/ppc64_defconfig          |   1 +
 xen/arch/ppc/include/asm/Makefile             |   1 +
 xen/arch/ppc/include/asm/device.h             |  53 --------
 xen/arch/ppc/include/asm/mem_access.h         |   5 -
 xen/arch/ppc/include/asm/monitor.h            |  28 +----
 xen/arch/ppc/stubs.c                          |   8 --
 xen/arch/riscv/configs/tiny64_defconfig       |   1 +
 xen/drivers/passthrough/arm/smmu.c            |  12 +-
 .../asm => include/asm-generic}/device.h      | 113 ++++++++++--------
 xen/include/asm-generic/monitor.h             |  64 ++++++++++
 xen/include/xen/mem_access.h                  |   2 +
 22 files changed, 170 insertions(+), 183 deletions(-)
 delete mode 100644 xen/arch/ppc/include/asm/device.h
 delete mode 100644 xen/arch/ppc/include/asm/mem_access.h
 rename xen/{arch/arm/include/asm => include/asm-generic}/device.h (70%)
 create mode 100644 xen/include/asm-generic/monitor.h
Signature · 1 line
2.43.0
#1 lore raw

PATCH v9 1/7 automation: introduce fixed randconfig for RISC-V

This patch introduces the anchor riscv-fixed-randconfig, which includes all configurations that should be disabled for randconfig builds.

---
The patch were introduced after discussion in a topic:
https://lore.kernel.org/xen-devel/[email protected]/
---
Changes in V9:
- add '|' symbol after EXTRA_FIXED_RANDCONFIG to make variables in EXTRA_FIXED_RANDCONFIG be separated by new line.
- instead of introduction of new file for riscv-fixed-randconfig, introduce an anchor inside build.yaml
---
Changes in V8:
- Nothing changed. Only rebase
---
Changes in V7:
- Nothing changed. Only rebase
---
Changes in V6:
- The patch was introduced in this version of patch series.

---
 automation/gitlab-ci/build.yaml | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
automation/gitlab-ci/build.yaml +10 -4
index 6d2cb18b88..aac29ee13a 100644
@@ -512,6 +512,14 @@ alpine-3.18-gcc-debug-arm64-boot-cpupools:
       CONFIG_BOOT_TIME_CPUPOOLS=y
 
 # RISC-V 64 cross-build
+.riscv-fixed-randconfig:
+  variables: &riscv-fixed-randconfig
+    EXTRA_FIXED_RANDCONFIG: |
+      CONFIG_COVERAGE=n
+      CONFIG_EXPERT=y
+      CONFIG_GRANT_TABLE=n
+      CONFIG_MEM_ACCESS=n
+
 archlinux-current-gcc-riscv64:
   extends: .gcc-riscv64-cross-build
   variables:
@@ -532,8 +540,7 @@ archlinux-current-gcc-riscv64-randconfig:
     CONTAINER: archlinux:current-riscv64
     KBUILD_DEFCONFIG: tiny64_defconfig
     RANDCONFIG: y
-    EXTRA_FIXED_RANDCONFIG:
-      CONFIG_COVERAGE=n
+    <<: *riscv-fixed-randconfig
 
 archlinux-current-gcc-riscv64-debug-randconfig:
   extends: .gcc-riscv64-cross-build-debug
@@ -541,8 +548,7 @@ archlinux-current-gcc-riscv64-debug-randconfig:
     CONTAINER: archlinux:current-riscv64
     KBUILD_DEFCONFIG: tiny64_defconfig
     RANDCONFIG: y
-    EXTRA_FIXED_RANDCONFIG:
-      CONFIG_COVERAGE=n
+    <<: *riscv-fixed-randconfig
 
 # Power cross-build
 debian-bullseye-gcc-ppc64le:
Signature · 1 line
2.43.0
author
#3 lore raw

Re: [PATCH v9 1/7] automation: introduce fixed randconfig for RISC-V

In reply to Oleksii Kurochko

Hello Doug and Stefano,

While Michal has reviewed this patch, I understand that I still need your Acked-by.

Could you please take a moment to review the patch?

Thanks in advance.

~ Oleksii

Quoted 72 lines · Oleksii Kurochko

This patch introduces the anchor riscv-fixed-randconfig, which includes all configurations that should be disabled for randconfig builds.

---
The patch were introduced after discussion in a topic:

https://lore.kernel.org/xen-devel/[email protected]
/
---
Changes in V9:
 - add '|' symbol after EXTRA_FIXED_RANDCONFIG to make variables in EXTRA_FIXED_RANDCONFIG
   be separated by new line.
 - instead of introduction of new file for riscv-fixed-randconfig, introduce an anchor
   inside build.yaml
---
Changes in V8:
 - Nothing changed. Only rebase
---
Changes in V7:
 - Nothing changed. Only rebase
---
Changes in V6:
 - The patch was introduced in this version of patch series.
---
 automation/gitlab-ci/build.yaml | 14 ++++++++++----

 1 file changed, 10 insertions(+), 4 deletions(-)
automation/gitlab- renamed from automation/gitlab-ci/build.yaml +0 -0

ci/build.yaml
index 6d2cb18b88..aac29ee13a 100644

automation/gitlab-ci/build.yaml +0 -0
@@ -512,6 +512,14 @@ alpine-3.18-gcc-debug-arm64-boot-cpupools:

       CONFIG_BOOT_TIME_CPUPOOLS=y

 # RISC-V 64 cross-build
+.riscv-fixed-randconfig:
+  variables: &riscv-fixed-randconfig
+    EXTRA_FIXED_RANDCONFIG: |
+      CONFIG_COVERAGE=n
+      CONFIG_EXPERT=y
+      CONFIG_GRANT_TABLE=n
+      CONFIG_MEM_ACCESS=n
+
 archlinux-current-gcc-riscv64:
   extends: .gcc-riscv64-cross-build
   variables:

automation/gitlab-ci/build.yaml +0 -0
@@ -532,8 +540,7 @@ archlinux-current-gcc-riscv64-randconfig:

     CONTAINER: archlinux:current-riscv64
     KBUILD_DEFCONFIG: tiny64_defconfig
     RANDCONFIG: y
-    EXTRA_FIXED_RANDCONFIG:
-      CONFIG_COVERAGE=n
+    <<: *riscv-fixed-randconfig

 archlinux-current-gcc-riscv64-debug-randconfig:
   extends: .gcc-riscv64-cross-build-debug

automation/gitlab-ci/build.yaml +0 -0
@@ -541,8 +548,7 @@ archlinux-current-gcc-riscv64-debug-randconfig:

     CONTAINER: archlinux:current-riscv64
     KBUILD_DEFCONFIG: tiny64_defconfig
     RANDCONFIG: y
-    EXTRA_FIXED_RANDCONFIG:
-      CONFIG_COVERAGE=n
+    <<: *riscv-fixed-randconfig

 # Power cross-build
 debian-bullseye-gcc-ppc64le:

#4 lore raw

Re: [PATCH v9 1/7] automation: introduce fixed randconfig for RISC-V

Quoted 8 lines · Oleksii

Hello Doug and Stefano,

While Michal has reviewed this patch, I understand that I still need your Acked-by.

Could you please take a moment to review the patch?

Thanks in advance.

Quoted 76 lines

~ Oleksii

Quoted 72 lines · Oleksii Kurochko

This patch introduces the anchor riscv-fixed-randconfig, which includes all configurations that should be disabled for randconfig builds.

---
The patch were introduced after discussion in a topic:

https://lore.kernel.org/xen-devel/[email protected]
/
---
Changes in V9:
 - add '|' symbol after EXTRA_FIXED_RANDCONFIG to make variables in EXTRA_FIXED_RANDCONFIG
   be separated by new line.
 - instead of introduction of new file for riscv-fixed-randconfig, introduce an anchor
   inside build.yaml
---
Changes in V8:
 - Nothing changed. Only rebase
---
Changes in V7:
 - Nothing changed. Only rebase
---
Changes in V6:
 - The patch was introduced in this version of patch series.
---
 automation/gitlab-ci/build.yaml | 14 ++++++++++----

 1 file changed, 10 insertions(+), 4 deletions(-)
automation/gitlab- renamed from automation/gitlab-ci/build.yaml +0 -0

ci/build.yaml
index 6d2cb18b88..aac29ee13a 100644

automation/gitlab-ci/build.yaml +0 -0
@@ -512,6 +512,14 @@ alpine-3.18-gcc-debug-arm64-boot-cpupools:

       CONFIG_BOOT_TIME_CPUPOOLS=y

 # RISC-V 64 cross-build
+.riscv-fixed-randconfig:
+  variables: &riscv-fixed-randconfig
+    EXTRA_FIXED_RANDCONFIG: |
+      CONFIG_COVERAGE=n
+      CONFIG_EXPERT=y
+      CONFIG_GRANT_TABLE=n
+      CONFIG_MEM_ACCESS=n
+
 archlinux-current-gcc-riscv64:
   extends: .gcc-riscv64-cross-build
   variables:

automation/gitlab-ci/build.yaml +0 -0
@@ -532,8 +540,7 @@ archlinux-current-gcc-riscv64-randconfig:

     CONTAINER: archlinux:current-riscv64
     KBUILD_DEFCONFIG: tiny64_defconfig
     RANDCONFIG: y
-    EXTRA_FIXED_RANDCONFIG:
-      CONFIG_COVERAGE=n
+    <<: *riscv-fixed-randconfig

 archlinux-current-gcc-riscv64-debug-randconfig:
   extends: .gcc-riscv64-cross-build-debug

automation/gitlab-ci/build.yaml +0 -0
@@ -541,8 +548,7 @@ archlinux-current-gcc-riscv64-debug-randconfig:

     CONTAINER: archlinux:current-riscv64
     KBUILD_DEFCONFIG: tiny64_defconfig
     RANDCONFIG: y
-    EXTRA_FIXED_RANDCONFIG:
-      CONFIG_COVERAGE=n
+    <<: *riscv-fixed-randconfig

 # Power cross-build
 debian-bullseye-gcc-ppc64le:

#5 lore raw

PATCH v9 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 V9:
- Add Acked-by: Julien Grall <[email protected]> for Arm part
---
Changes in V8:
- Add Acked-by: Tamas K Lengyel <[email protected]>
---
Changes in V7:
- Drop definition of arch_monitor_domctl_event for PPC.
- define arch_monitor_domctl_event in asm-generic/monitor.h.
- add "define HAS_ARCH_MONITOR_DOMCTL_EVENT" in arm/.../monitor.h as it has arch specific implementation.
---
Changes in V6:
- Rebase only.
---
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 | 25 +-----------
 xen/arch/ppc/include/asm/monitor.h | 28 +------------
 xen/arch/ppc/stubs.c               |  8 ----
 xen/include/asm-generic/monitor.h  | 64 ++++++++++++++++++++++++++++++
 4 files changed, 67 insertions(+), 58 deletions(-)
 create mode 100644 xen/include/asm-generic/monitor.h
xen/arch/arm/include/asm/monitor.h +2 -23
index 7567be66bd..77a3c1a36c 100644
@@ -25,34 +25,13 @@
 #include <xen/sched.h>
 #include <public/domctl.h>
 
-static inline
-void arch_monitor_allow_userspace(struct domain *d, bool allow_userspace)
-{
-}
+#define HAS_ARCH_MONITOR_DOMCTL_EVENT
 
-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;
-}
+#include <asm-generic/monitor.h>
 
 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. */
-}
-
 static inline uint32_t arch_monitor_get_capabilities(struct domain *d)
 {
     uint32_t capabilities = 0;
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/arch/ppc/stubs.c +0 -8
index a96e45626d..da193839bd 100644
@@ -95,14 +95,6 @@ void arch_get_domain_info(const struct domain *d,
     BUG_ON("unimplemented");
 }
 
-/* monitor.c */
-
-int arch_monitor_domctl_event(struct domain *d,
-                              struct xen_domctl_monitor_op *mop)
-{
-    BUG_ON("unimplemented");
-}
-
 /* smp.c */
 
 void arch_flush_tlb_mask(const cpumask_t *mask)
xen/include/asm-generic/monitor.h new file +64 -0

64 lines not on this page · raw message

Signature · 1 line
2.43.0
author
#6 lore raw

Re: [PATCH v9 2/7] xen/asm-generic: introduce stub header monitor.h

Oleksii

Quoted 235 lines · 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 V9:
 - Add Acked-by: Julien Grall <[email protected]> for Arm part
---
Changes in V8:
 - Add Acked-by: Tamas K Lengyel <[email protected]>
---
Changes in V7:
 - Drop definition of arch_monitor_domctl_event for PPC.
 - define arch_monitor_domctl_event in asm-generic/monitor.h.
 - add "define HAS_ARCH_MONITOR_DOMCTL_EVENT" in arm/.../monitor.h as it has arch specific implementation.
---
Changes in V6:
 - Rebase only.
---
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 | 25 +----------- xen/arch/ppc/include/asm/monitor.h | 28 +------------ xen/arch/ppc/stubs.c               |  8 ---- xen/include/asm-generic/monitor.h  | 64
++++++++++++++++++++++++++++++

 4 files changed, 67 insertions(+), 58 deletions(-)

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

xen/arch/arm/include/asm/monitor.h +0 -0
index 7567be66bd..77a3c1a36c 100644
@@ -25,34 +25,13 @@
  #include <xen/sched.h>
  #include <public/domctl.h>

xen/arch/arm/include/asm/monitor.h +0 -2
-static inline
-void arch_monitor_allow_userspace(struct domain *d, bool

allow_userspace)

xen/arch/arm/include/asm/monitor.h +1 -2
-{
-}
+#define HAS_ARCH_MONITOR_DOMCTL_EVENT

xen/arch/arm/include/asm/monitor.h +0 -2
-static inline
-int arch_monitor_domctl_op(struct domain *d, struct

xen_domctl_monitor_op *mop)

xen/arch/arm/include/asm/monitor.h +1 -4
-{
-    /* No arch-specific monitor ops on ARM. */
-    return -EOPNOTSUPP;
-}
+#include <asm-generic/monitor.h>


 int arch_monitor_domctl_event(struct domain *d,
                               struct xen_domctl_monitor_op *mop);

xen/arch/arm/include/asm/monitor.h +0 -13
-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. */
-}
-

 static inline uint32_t arch_monitor_get_capabilities(struct domain *d)
 {
     uint32_t capabilities = 0;

xen/arch/ppc/include/asm/monitor.h +0 -0
index e5b0282bf1..89000dacc6 100644
@@ -6,33 +6,7 @@
  #include <public/domctl.h>
  #include <xen/errno.h>

xen/arch/ppc/include/asm/monitor.h +0 -2
-static inline
-void arch_monitor_allow_userspace(struct domain *d, bool

allow_userspace)

xen/arch/ppc/include/asm/monitor.h +0 -5
-{
-}
-
-static inline
-int arch_monitor_domctl_op(struct domain *d, struct

xen_domctl_monitor_op *mop)

xen/arch/ppc/include/asm/monitor.h +1 -20
-{
-    /* 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/arch/ppc/stubs.c +0 -0
index a96e45626d..da193839bd 100644
@@ -95,14 +95,6 @@ void arch_get_domain_info(const struct domain *d,
      BUG_ON("unimplemented");
  }

xen/arch/ppc/stubs.c +0 -8
-/* monitor.c */
-
-int arch_monitor_domctl_event(struct domain *d,
-                              struct xen_domctl_monitor_op *mop)
-{
-    BUG_ON("unimplemented");
-}
-

 /* smp.c */

 void arch_flush_tlb_mask(const cpumask_t *mask)

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

generic/monitor.h
new file mode 100644
index 0000000000..1ade289099

xen/include/asm-generic/monitor.h new file +22 -0
@@ -0,0 +1,64 @@
+/* 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/errno.h>
+#include <xen/lib.h>
+
+struct domain;
+struct xen_domctl_monitor_op;
+
+static inline
+void arch_monitor_allow_userspace(struct domain *d, bool

allow_userspace)

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 +37 -0
+{
+    /* No arch-specific monitor ops on GENERIC. */
+    return -EOPNOTSUPP;
+}
+
+#ifndef HAS_ARCH_MONITOR_DOMCTL_EVENT
+static inline
+int arch_monitor_domctl_event(struct domain *d,
+                              struct xen_domctl_monitor_op *mop)
+{
+    BUG_ON("unimplemented");
+}
+#endif
+
+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. */
+}
+
+#endif /* __ASM_GENERIC_MONITOR_H__ */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: BSD
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
Acked-by on v9 2/7
#7 lore raw

Re: [PATCH v9 2/7] xen/asm-generic: introduce stub header monitor.h

In reply to Oleksii Kurochko

Hi Oleksii,

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

Thanks,
Shawn

#8 lore raw

PATCH v9 3/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 V9:
- Acked-by: Julien Grall <[email protected]>
---
Changes in V8:
- Add Acked-by: Tamas K Lengyel <[email protected]>
---
Changes in V7:
- Nothing changed. Only rebase
---
Changes in V6:
- Remove the way how CONFIG_MEM_ACCESS is disabled for PPC and RISC-V.
- Disable the config in ppc64_defconfig and tiny64_defconfig (RISC-V).
---
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/configs/ppc64_defconfig    | 1 +
 xen/arch/ppc/include/asm/mem_access.h   | 5 -----
 xen/arch/riscv/configs/tiny64_defconfig | 1 +
 xen/include/xen/mem_access.h            | 2 ++
 6 files changed, 6 insertions(+), 5 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 9c10e8f78c..8ddca643d4 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/configs/ppc64_defconfig +1 -0
index f7cc075e45..48a053237a 100644
@@ -6,6 +6,7 @@
 # CONFIG_HYPFS is not set
 # CONFIG_GRANT_TABLE is not set
 # CONFIG_SPECULATIVE_HARDEN_ARRAY is not set
+# CONFIG_MEM_ACCESS is not set
 
 CONFIG_PPC64=y
 CONFIG_DEBUG=y
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/arch/riscv/configs/tiny64_defconfig +1 -0
index 3c9a2ff941..09defe236b 100644
@@ -6,6 +6,7 @@
 # CONFIG_HYPFS is not set
 # CONFIG_GRANT_TABLE is not set
 # CONFIG_SPECULATIVE_HARDEN_ARRAY is not set
+# CONFIG_MEM_ACCESS is not set
 
 CONFIG_RISCV_64=y
 CONFIG_DEBUG=y
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
Acked-by on v9 3/7
#9 lore raw

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

Hi Oleksii,

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

Quoted 8 lines

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.

Thanks,
Shawn

#10 lore raw

PATCH v9 4/7 xen/asm-generic: introduce generic device.h

In reply to Oleksii Kurochko

Arm, PPC and RISC-V introduce the same things in asm/device.h, so generic device.h was introduced.
Arm's device.h was taken as a base with the following changes:
- #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.

---
Changes in V9:
- move 'struct device_desc' to #ifdef CONFIG_HAS_DEVICE_TREE as it is expected to have this structure only in case of CONFIG_HAS_DEVICE_TREE.
- rename name_, namestr_, class_ to dev_name, ident and cls in DT_DEVICE_START and ACPI_DEVICE_START macros.
- Add Acked-by: Jan Beulich <[email protected]>
---
Changes in V8:
- drop #ifdef HAS_PCI around DEV_PCI in enum device_type to be consistent with DEVICE_PCI_HOSTBRIDGE
- drop the comment above enum device_type, after DEV_PCI is alaways present in enum device_type, so there is no need anymore in comment and DEV_TYPE_MAX.
- drop #ifdef HAS_PCI around dev_is_pci() as DEV_PCI is alwayds define now.
- rename args _name, _namestr, _class to name, namestr, class.
- drop unnessary backslash after .class = class in defines ACPI_DEVICE_START() and DT_DEVICE_START()
- update the commit message
---
Changes in V7:
- keeping DEVICE_PCI_HOSTBRIDGE available for every build based on the reply:

    https://lore.kernel.org/xen-devel/[email protected]/

- add comment above enum device_type.h with explanation about DEV_TYPE_MAX.
- separate patch "[PATCH v6 9/9] xen/asm-generic: introduce generic device.h" into 3 patches.
---
Changes in V6:
- Rebase only.
---
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/include/asm-generic/device.h | 145 +++++++++++++++++++++++++++++++
 1 file changed, 145 insertions(+)
 create mode 100644 xen/include/asm-generic/device.h
xen/include/asm-generic/device.h new file +145 -0
new file mode 100644
index 0000000000..f91bb7f771
@@ -0,0 +1,145 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __ASM_GENERIC_DEVICE_H__
+#define __ASM_GENERIC_DEVICE_H__
+
+#include <xen/stdbool.h>
+
+enum device_type
+{
+#ifdef CONFIG_HAS_DEVICE_TREE
+    DEV_DT,
+#endif
+    DEV_PCI
+};
+
+enum device_class
+{
+    DEVICE_SERIAL,
+    DEVICE_IOMMU,
+    DEVICE_INTERRUPT_CONTROLLER,
+    DEVICE_PCI_HOSTBRIDGE,
+    /* Use for error */
+    DEVICE_UNKNOWN,
+};
+
+struct dev_archdata {
+#ifdef CONFIG_HAS_PASSTHROUGH
+    void *iommu;    /* IOMMU private data */
+#endif
+};
+
+/* 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;
+#ifdef CONFIG_HAS_PASSTHROUGH
+    struct iommu_fwspec *iommu_fwspec; /* per-device IOMMU instance data */
+#endif
+};
+
+typedef struct device device_t;
+
+#ifdef CONFIG_HAS_DEVICE_TREE
+
+#include <xen/device_tree.h>
+
+#define dev_is_dt(dev)  ((dev)->type == DEV_DT)
+
+/**
+ *  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(dev_name, ident, cls)                   \
+static const struct device_desc __dev_desc_##dev_name __used    \
+__section(".dev.info") = {                                      \
+    .name = ident,                                              \
+    .class = cls,
+
+#define DT_DEVICE_END                                           \
+};
+
+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);
+};
+
+#else /* !CONFIG_HAS_DEVICE_TREE */
+#define dev_is_dt(dev) ((void)(dev), false)
+#endif /* CONFIG_HAS_DEVICE_TREE */
+
+#define dev_is_pci(dev) ((dev)->type == DEV_PCI)
+
+#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);
+
+#define ACPI_DEVICE_START(dev_name, ident, cls)                     \
+static const struct acpi_device_desc __dev_desc_##dev_name __used   \
+__section(".adev.info") = {                                         \
+    .name = ident,                                                  \
+    .class = cls,
+
+#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.43.0
Acked-by on v9 4/7
#11 lore raw

Re: [PATCH v9 4/7] xen/asm-generic: introduce generic device.h

Hi Oleksii,

Quoted 11 lines · Oleksii Kurochko

Arm, PPC and RISC-V introduce the same things in asm/device.h, so generic device.h was introduced.
Arm's device.h was taken as a base with the following changes:
- #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.

Cheers,

Signature · 1 line
Julien Grall
#12 lore raw

PATCH v9 5/7 xen/arm: switch Arm to use asm-generic/device.h

In reply to Oleksii Kurochko

The following changes were done as a result of switching to asm-generic/device.h:
* DEVICE_GIC was renamed to DEVICE_INTERRUPT_CONTROLLER according to definition of enum device_class in asm-generic/device.h.
* acpi-related things in Arm code were guarded by #ifdef CONFIG_ACPI as struct acpi_device_desc was guarded in asm-generic, also functions acpi_device_init() was guarded too as they are using structure acpi_device_desc inside.
* drop arm/include/asm/device.h and update arm/include/asm/Makefile to use asm-generic/device.h instead.

As 'struct device_desc' is protected by CONFIG_HAS_DEVICE_TREE, _sdevice, _edevice, device_init(), and device_get_class should also be protected.
However, this protection was not implemented because Arm always has CONFIG_HAS_DEVICE_TREE=y at the moment.

---
Changes in V9:
- protect .adev_info in Arm linker script by #ifdef CONFIG_ACPI.
- update the commit message.
- add Reviewed-by: Julien Grall <[email protected]>
---
Changes in V8:
- update the commit message
---
Changes in V7:
- newly introduced patch which is based on the previous version of the patch:
[PATCH v6 9/9] xen/asm-generic: introduce generic device.h

---
 xen/arch/arm/device.c             |   5 ++
 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/arm/include/asm/device.h | 124 ------------------------------
 xen/arch/arm/xen.lds.S            |   2 +
 8 files changed, 16 insertions(+), 132 deletions(-)
 delete mode 100644 xen/arch/arm/include/asm/device.h
xen/arch/arm/device.c +5 -0
index 1f631d3274..3e02cff008 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)
 {
xen/arch/arm/domain_build.c +1 -1
index 46161848dc..085d88671e 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 bf0e5c1b75..1cb1360606 100644
@@ -1909,7 +1909,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
@@ -1924,12 +1924,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 505cb49090..4a4036c951 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 += paging.h
xen/arch/arm/include/asm/device.h deleted +0 -124

124 lines not on this page · raw message

xen/arch/arm/xen.lds.S +2 -0
index 470c8f2208..2266c9536f 100644
@@ -138,12 +138,14 @@ SECTIONS
       _edevice = .;
   } :text
 
+#ifdef CONFIG_ACPI
   . = ALIGN(8);
   .adev.info : {
       _asdevice = .;
       *(.adev.info)
       _aedevice = .;
   } :text
+#endif
 
   . = ALIGN(8);
   .teemediator.info : {
Signature · 1 line
2.43.0
#13 lore raw

PATCH v9 6/7 xen/ppc: switch PPC to use asm-generic/device.h

In reply to Oleksii Kurochko

---
Changed in V8:
- nothing changed. only rebase.
---
Changes in V7:
- newly introduced patch which is based on the previous version of the patch:
[PATCH v6 9/9] xen/asm-generic: introduce generic device.h

---
 xen/arch/ppc/include/asm/Makefile |  1 +
 xen/arch/ppc/include/asm/device.h | 53 -------------------------------
 2 files changed, 1 insertion(+), 53 deletions(-)
 delete mode 100644 xen/arch/ppc/include/asm/device.h
xen/arch/ppc/include/asm/Makefile +1 -0
index 3fd893f3e0..ced02e26ed 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

Signature · 1 line
2.43.0
author
#14 lore raw

Re: [PATCH v9 6/7] xen/ppc: switch PPC to use asm-generic/device.h

Hello Shawn,

Would you mind taking a look at this patch?

Thanks in advance.

Best regards,
Oleksii

Quoted 95 lines · Oleksii Kurochko

---
Changed in V8:
 - nothing changed. only rebase.
---
Changes in V7:
 - newly introduced patch which is based on the previous version of the patch:
     [PATCH v6 9/9] xen/asm-generic: introduce generic device.h
---
 xen/arch/ppc/include/asm/Makefile |  1 + xen/arch/ppc/include/asm/device.h | 53 ----------------------------- --

 2 files changed, 1 insertion(+), 53 deletions(-)

 delete mode 100644 xen/arch/ppc/include/asm/device.h

xen/arch/ppc/include/asm/Makefile +0 -0
index 3fd893f3e0..ced02e26ed 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 -14
deleted file mode 100644
index 8253e61d51..0000000000
@@ -1,53 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-#ifndef __ASM_PPC_DEVICE_H__
-#define __ASM_PPC_DEVICE_H__
-
-enum device_type
-{
-    DEV_DT,
-    DEV_PCI,
-};
-
-struct device {
-    enum device_type type;
-#ifdef CONFIG_HAS_DEVICE_TREE
-    struct dt_device_node *of_node; /* Used by drivers imported from

Linux */

xen/arch/ppc/include/asm/device.h deleted +0 -30
-#endif
-};
-
-enum device_class
-{
-    DEVICE_SERIAL,
-    DEVICE_IOMMU,
-    DEVICE_PCI_HOSTBRIDGE,
-    /* 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);
-};
-
-typedef struct device device_t;
-
-#define DT_DEVICE_START(name_, namestr_, class_)                   

\
-static const struct device_desc __dev_desc_##name_ __used \
-__section(".dev.info") = {
\
-    .name = namestr_,
\
-    .class = class_,
\

xen/arch/ppc/include/asm/device.h deleted +0 -2
-
-#define DT_DEVICE_END                                              

\

xen/arch/ppc/include/asm/device.h deleted +0 -3
-};
-
-#endif /* __ASM_PPC_DEVICE_H__ */
#16 lore raw

PATCH v9 7/7 xen/asm-generic: fold struct devarch into struct dev

In reply to Oleksii Kurochko

The current patch is a follow-up to the patch titled:
xen/asm-generic: introduce generic device.h
Also, a prerequisite for this patch is, without which a compilation error will occur:
xen/arm: switch Arm to use asm-generic/device.h

The 'struct dev_archdata' is exclusively used within 'struct device', so it could be merged into 'struct device.'

After the merger, it is necessary to update the 'dev_archdata()' macros and the comments above 'struct arm_smmu_xen_device' in drivers/passthrough/arm/smmu.c.
Additionally, it is required to update instances of "dev->archdata->iommu" to "dev->iommu".

---
This patch can be merged with patches 4 and 5 of this patch series.
---
Changes in V9:
- newly introduced patch.

---
 xen/drivers/passthrough/arm/smmu.c | 12 ++++++------
 xen/include/asm-generic/device.h   |  8 +-------
 2 files changed, 7 insertions(+), 13 deletions(-)
xen/drivers/passthrough/arm/smmu.c +6 -6
index 32e2ff279b..4a272c8779 100644
@@ -227,9 +227,9 @@ struct arm_smmu_xen_domain {
 };
 
 /*
- * Xen: Information about each device stored in dev->archdata.iommu
+ * Xen: Information about each device stored in dev->iommu
  *
- * Initially dev->archdata.iommu only stores the iommu_domain (runtime
+ * Initially dev->iommu only stores the iommu_domain (runtime
  * configuration of the SMMU) but, on Xen, we also have to store the
  * iommu_group (list of streamIDs associated to the device).
  *
@@ -242,7 +242,7 @@ struct arm_smmu_xen_device {
 	struct iommu_group *group;
 };
 
-#define dev_archdata(dev) ((struct arm_smmu_xen_device *)dev->archdata.iommu)
+#define dev_archdata(dev) ((struct arm_smmu_xen_device *)dev->iommu)
 #define dev_iommu_domain(dev) (dev_archdata(dev)->domain)
 #define dev_iommu_group(dev) (dev_archdata(dev)->group)
 
@@ -2777,9 +2777,9 @@ static int arm_smmu_assign_dev(struct domain *d, u8 devfn,
 
 	xen_domain = dom_iommu(d)->arch.priv;
 
-	if (!dev->archdata.iommu) {
-		dev->archdata.iommu = xzalloc(struct arm_smmu_xen_device);
-		if (!dev->archdata.iommu)
+	if (!dev->iommu) {
+		dev->iommu = xzalloc(struct arm_smmu_xen_device);
+		if (!dev->iommu)
 			return -ENOMEM;
 	}
 
xen/include/asm-generic/device.h +1 -7
index f91bb7f771..1acd1ba1d8 100644
@@ -22,12 +22,6 @@ enum device_class
     DEVICE_UNKNOWN,
 };
 
-struct dev_archdata {
-#ifdef CONFIG_HAS_PASSTHROUGH
-    void *iommu;    /* IOMMU private data */
-#endif
-};
-
 /* struct device - The basic device structure */
 struct device
 {
@@ -35,8 +29,8 @@ struct device
 #ifdef CONFIG_HAS_DEVICE_TREE
     struct dt_device_node *of_node; /* Used by drivers imported from Linux */
 #endif
-    struct dev_archdata archdata;
 #ifdef CONFIG_HAS_PASSTHROUGH
+    void *iommu; /* IOMMU private data */;
     struct iommu_fwspec *iommu_fwspec; /* per-device IOMMU instance data */
 #endif
 };
Signature · 1 line
2.43.0
#17 lore raw

Re: [PATCH v9 7/7] xen/asm-generic: fold struct devarch into struct dev

Quoted 44 lines · Oleksii Kurochko

The current patch is a follow-up to the patch titled:
xen/asm-generic: introduce generic device.h
Also, a prerequisite for this patch is, without which a compilation error will occur:
xen/arm: switch Arm to use asm-generic/device.h

The 'struct dev_archdata' is exclusively used within 'struct device', so it could be merged into 'struct device.'

After the merger, it is necessary to update the 'dev_archdata()' macros and the comments above 'struct arm_smmu_xen_device' in drivers/passthrough/arm/smmu.c.
Additionally, it is required to update instances of "dev->archdata->iommu" to "dev->iommu".

---
This patch can be merged with patches 4 and 5 of this patch series.
---
Changes in V9:
- newly introduced patch.

---
 xen/drivers/passthrough/arm/smmu.c | 12 ++++++------
 xen/include/asm-generic/device.h   |  8 +-------
 2 files changed, 7 insertions(+), 13 deletions(-)
xen/drivers/passthrough/arm/smmu.c +2 -2
index 32e2ff279b..4a272c8779 100644
@@ -227,9 +227,9 @@ struct arm_smmu_xen_domain {
 };
 
 /*
- * Xen: Information about each device stored in dev->archdata.iommu
+ * Xen: Information about each device stored in dev->iommu
  *
- * Initially dev->archdata.iommu only stores the iommu_domain (runtime
+ * Initially dev->iommu only stores the iommu_domain (runtime
  * configuration of the SMMU) but, on Xen, we also have to store the
  * iommu_group (list of streamIDs associated to the device).
  *

xen/drivers/passthrough/arm/smmu.c struct arm_smmu_xen_device { · line 245

Quoted 5 lines
xen/drivers/passthrough/arm/smmu.c +1 -1
@@ -242,7 +242,7 @@ struct arm_smmu_xen_device {
 	struct iommu_group *group;
 };
 
-#define dev_archdata(dev) ((struct arm_smmu_xen_device *)dev->archdata.iommu)
+#define dev_archdata(dev) ((struct arm_smmu_xen_device *)dev->iommu)

I find in particular the naming here odd. But I'll let Julien judge whether this really is along the lines of what he suggested.

Jan

#18 lore raw

Re: [PATCH v9 7/7] xen/asm-generic: fold struct devarch into struct dev

Hi Jan,

Quoted 48 lines · Jan Beulich
Quoted 47 lines · Oleksii Kurochko

The current patch is a follow-up to the patch titled:
xen/asm-generic: introduce generic device.h
Also, a prerequisite for this patch is, without which a compilation error will occur:
xen/arm: switch Arm to use asm-generic/device.h

The 'struct dev_archdata' is exclusively used within 'struct device', so it could be merged into 'struct device.'

After the merger, it is necessary to update the 'dev_archdata()' macros and the comments above 'struct arm_smmu_xen_device' in drivers/passthrough/arm/smmu.c.
Additionally, it is required to update instances of "dev->archdata->iommu" to "dev->iommu".

---
This patch can be merged with patches 4 and 5 of this patch series.
---
Changes in V9:
- newly introduced patch.

---
  xen/drivers/passthrough/arm/smmu.c | 12 ++++++------
  xen/include/asm-generic/device.h   |  8 +-------
  2 files changed, 7 insertions(+), 13 deletions(-)
xen/drivers/passthrough/arm/smmu.c +2 -2
index 32e2ff279b..4a272c8779 100644
@@ -227,9 +227,9 @@ struct arm_smmu_xen_domain {
  };
 
  /*
- * Xen: Information about each device stored in dev->archdata.iommu
+ * Xen: Information about each device stored in dev->iommu
   *
- * Initially dev->archdata.iommu only stores the iommu_domain (runtime
+ * Initially dev->iommu only stores the iommu_domain (runtime
   * configuration of the SMMU) but, on Xen, we also have to store the
   * iommu_group (list of streamIDs associated to the device).
   *
@@ -242,7 +242,7 @@ struct arm_smmu_xen_device {
  	struct iommu_group *group;
  };
 
Quoted 5 lines

xen/drivers/passthrough/arm/smmu.c struct arm_smmu_xen_device { · line 245

Quoted 2 lines
xen/drivers/passthrough/arm/smmu.c +1 -1
-#define dev_archdata(dev) ((struct arm_smmu_xen_device *)dev->archdata.iommu)
+#define dev_archdata(dev) ((struct arm_smmu_xen_device *)dev->iommu)

I find in particular the naming here odd. But I'll let Julien judge whether this really is along the lines of what he suggested.

It is. The naming is not great, but the SMMU code is intended to stay close to Linux. So we want to do the minimum amount of change (at least until we decide we should diverge).

Cheers,

Signature · 1 line
Julien Grall
Reviewed-by on v9 7/7
#19 lore raw

Re: [PATCH v9 7/7] xen/asm-generic: fold struct devarch into struct dev

In reply to Oleksii Kurochko

Hi,

Quoted 15 lines · Oleksii Kurochko

The current patch is a follow-up to the patch titled:
xen/asm-generic: introduce generic device.h
Also, a prerequisite for this patch is, without which a compilation error will occur:
xen/arm: switch Arm to use asm-generic/device.h

The 'struct dev_archdata' is exclusively used within 'struct device', so it could be merged into 'struct device.'

After the merger, it is necessary to update the 'dev_archdata()' macros and the comments above 'struct arm_smmu_xen_device' in drivers/passthrough/arm/smmu.c.
Additionally, it is required to update instances of "dev->archdata->iommu" to "dev->iommu".

Quoted 4 lines

---
This patch can be merged with patches 4 and 5 of this patch series.

I am a bit puzzled with this comment. If this is the case, then why was it done in a separate patch?

I know I suggested to create the separate patch but this was only in the case you decided to handle it after this series is merged. So this should have been merged when sending. Maybe I should have been clearer.

Anyway, regardless that:

Cheers,

Signature · 1 line
Julien Grall
author
#20 lore raw

Re: [PATCH v9 7/7] xen/asm-generic: fold struct devarch into struct dev

Hi Julien,

Quoted 29 lines · Julien Grall

Hi,

Quoted 16 lines · Oleksii Kurochko

The current patch is a follow-up to the patch titled:
     xen/asm-generic: introduce generic device.h
Also, a prerequisite for this patch is, without which a compilation error will occur:
     xen/arm: switch Arm to use asm-generic/device.h

The 'struct dev_archdata' is exclusively used within 'struct device',
so it could be merged into 'struct device.'

After the merger, it is necessary to update the 'dev_archdata()' macros and the comments above 'struct arm_smmu_xen_device' in drivers/passthrough/arm/smmu.c.
Additionally, it is required to update instances of "dev->archdata->iommu" to "dev->iommu".

Quoted 5 lines

---
   This patch can be merged with patches 4 and 5 of this patch series.

I am a bit puzzled with this comment. If this is the case, then why was
it done in a separate patch?

Quoted 5 lines

I know I suggested to create the separate patch but this was only in the
case you decided to handle it after this series is merged. So this should have been merged when sending. Maybe I should have been clearer.

I can submit a new version of the patch series in which this patch will be incorporated into patches 4 and 5, respectively.

In this case, should all the "reviewed-by" and "acked-by" tags for patch 4 be removed?

Quoted 4 lines

Anyway, regardless that:

Thanks.

~ Oleksii

#21 lore raw

Re: [PATCH v9 7/7] xen/asm-generic: fold struct devarch into struct dev

Hi Oleksii,

Quoted 32 lines · Oleksii

Hi Julien,

Quoted 29 lines · Julien Grall

Hi,

Quoted 16 lines · Oleksii Kurochko

The current patch is a follow-up to the patch titled:
     xen/asm-generic: introduce generic device.h
Also, a prerequisite for this patch is, without which a compilation error will occur:
     xen/arm: switch Arm to use asm-generic/device.h

The 'struct dev_archdata' is exclusively used within 'struct device',
so it could be merged into 'struct device.'

After the merger, it is necessary to update the 'dev_archdata()' macros and the comments above 'struct arm_smmu_xen_device' in drivers/passthrough/arm/smmu.c.
Additionally, it is required to update instances of "dev->archdata->iommu" to "dev->iommu".

Quoted 5 lines

---
   This patch can be merged with patches 4 and 5 of this patch
series.

I am a bit puzzled with this comment. If this is the case, then why was
it done in a separate patch?

Quoted 7 lines
Quoted 5 lines

I know I suggested to create the separate patch but this was only in the
case you decided to handle it after this series is merged. So this should have been merged when sending. Maybe I should have been clearer.

I can submit a new version of the patch series in which this patch will be incorporated into patches 4 and 5, respectively.

AFAICT the series is fully acked. So no need to send a new version. But please keep the request in mind for future series.

Cheers,

Signature · 1 line
Julien Grall
#22 lore raw

Re: [PATCH v9 7/7] xen/asm-generic: fold struct devarch into struct dev

In reply to Oleksii Kurochko
Quoted 5 lines · Oleksii Kurochko

The current patch is a follow-up to the patch titled:
xen/asm-generic: introduce generic device.h
Also, a prerequisite for this patch is, without which a compilation error will occur:
xen/arm: switch Arm to use asm-generic/device.h

I've dropped this while committing; it belongs ...

Quoted 9 lines

The 'struct dev_archdata' is exclusively used within 'struct device', so it could be merged into 'struct device.'

After the merger, it is necessary to update the 'dev_archdata()' macros and the comments above 'struct arm_smmu_xen_device' in drivers/passthrough/arm/smmu.c.
Additionally, it is required to update instances of "dev->archdata->iommu" to "dev->iommu".

Quoted 4 lines

---
This patch can be merged with patches 4 and 5 of this patch series.

... somewhere here.

I didn't touch patch 5's subject, but I think the duplicate "Arm" in there would better have been avoided.

Jan