Skip to contentSkip to conversation

accel: Try to build without target-specific knowledge

PATCH In review Philippe Mathieu-Daudé 4 participants 15 messages Feb 25 – Mar 9

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover accel: Try to build without target-specific knowledge

Code in accel/ aims to be target-agnostic. Not all accelerators are ready for that, but start by enforcing a few easy ones.

Philippe Mathieu-Daudé (5):
accel/kvm: Include missing 'exec/cpu-common.h' header accel/mshv: Forward-declare mshv_root_hvcall structure accel/mshv: Build without target-specific knowledge accel/hvf: Build without target-specific knowledge accel/xen: Build without target-specific knowledge

 include/system/mshv_int.h | 5 ++---
 accel/kvm/kvm-accel-ops.c | 1 +
 accel/mshv/mshv-all.c     | 2 +-
 accel/hvf/meson.build     | 5 +----
 accel/mshv/meson.build    | 5 +----
 accel/xen/meson.build     | 2 +-
 6 files changed, 7 insertions(+), 13 deletions(-)
Signature · 1 line
2.52.0
#1 lore raw

PATCH 1/5 accel/kvm: Include missing 'exec/cpu-common.h' header

kvm-accel-ops.c uses EXCP_DEBUG, itself defined in "exec/cpu-common.h". Include it explicitly, otherwise we get when modifying unrelated headers:

../accel/kvm/kvm-accel-ops.c: In function ‘kvm_vcpu_thread_fn’:
../accel/kvm/kvm-accel-ops.c:54:22: error: ‘EXCP_DEBUG’ undeclared (first use in this function)

     54 |             if (r == EXCP_DEBUG) {
        |                      ^~~~~~~~~~
---
 accel/kvm/kvm-accel-ops.c | 1 +
 1 file changed, 1 insertion(+)
accel/kvm/kvm-accel-ops.c +1 -0
index 8ed6945c2f7..6d9140e549f 100644
@@ -16,6 +16,7 @@
 #include "qemu/osdep.h"
 #include "qemu/error-report.h"
 #include "qemu/main-loop.h"
+#include "exec/cpu-common.h"
 #include "accel/accel-cpu-ops.h"
 #include "system/kvm.h"
 #include "system/kvm_int.h"
Signature · 1 line
2.52.0
Reviewed-by on v1 1/5
#2 lore raw

Re: [PATCH 1/5] accel/kvm: Include missing 'exec/cpu-common.h' header

Quoted 5 lines · Philippe Mathieu-Daudé

kvm-accel-ops.c uses EXCP_DEBUG, itself defined in "exec/cpu-common.h". Include it explicitly, otherwise we get when modifying unrelated headers:

../accel/kvm/kvm-accel-ops.c: In function ‘kvm_vcpu_thread_fn’:

Quoted 9 lines
   ../accel/kvm/kvm-accel-ops.c:54:22: error: ‘EXCP_DEBUG’ undeclared (first use in this function)
      54 |             if (r == EXCP_DEBUG) {
         |                      ^~~~~~~~~~
---
  accel/kvm/kvm-accel-ops.c | 1 +
  1 file changed, 1 insertion(+)
#3 lore raw

PATCH 2/5 accel/mshv: Forward-declare mshv_root_hvcall structure

In reply to Philippe Mathieu-Daudé

Forward-declare the target-specific mshv_root_hvcall structure in order to keep 'system/mshv_int.h' target-agnostic.

---
 include/system/mshv_int.h | 5 ++---
 accel/mshv/mshv-all.c     | 2 +-
 2 files changed, 3 insertions(+), 4 deletions(-)
include/system/mshv_int.h +2 -3
index ad4d001c3cd..35386c422fa 100644
@@ -96,9 +96,8 @@ void mshv_arch_amend_proc_features(
     union hv_partition_synthetic_processor_features *features);
 int mshv_arch_post_init_vm(int vm_fd);
 
-#if defined COMPILING_PER_TARGET && defined CONFIG_MSHV_IS_POSSIBLE
-int mshv_hvcall(int fd, const struct mshv_root_hvcall *args);
-#endif
+typedef struct mshv_root_hvcall mshv_root_hvcall;
+int mshv_hvcall(int fd, const mshv_root_hvcall *args);
 
 /* memory */
 typedef struct MshvMemoryRegion {
accel/mshv/mshv-all.c +1 -1
index ddc4c18cba4..d4cc7f53715 100644
@@ -381,7 +381,7 @@ static void register_mshv_memory_listener(MshvState *s, MshvMemoryListener *mml,
     }
 }
 
-int mshv_hvcall(int fd, const struct mshv_root_hvcall *args)
+int mshv_hvcall(int fd, const mshv_root_hvcall *args)
 {
     int ret = 0;
 
Signature · 1 line
2.52.0
Reviewed-by on v1 2/5
#4 lore raw

Re: [PATCH 2/5] accel/mshv: Forward-declare mshv_root_hvcall structure

Quoted 9 lines · Philippe Mathieu-Daudé

Forward-declare the target-specific mshv_root_hvcall structure in order to keep 'system/mshv_int.h' target-agnostic.

---
  include/system/mshv_int.h | 5 ++---
  accel/mshv/mshv-all.c     | 2 +-
  2 files changed, 3 insertions(+), 4 deletions(-)
#5 lore raw

PATCH 3/5 accel/mshv: Build without target-specific knowledge

In reply to Philippe Mathieu-Daudé

Code in accel/ aims to be target-agnostic. Enforce that by moving the MSHV file units to system_ss[], which is target-agnostic.

---
 accel/mshv/meson.build | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
accel/mshv/meson.build +1 -4
index d3a2b325811..c1b1787c5e6 100644
@@ -1,9 +1,6 @@
-mshv_ss = ss.source_set()
-mshv_ss.add(if_true: files(
+system_ss.add(when: 'CONFIG_MSHV', if_true: files(
   'irq.c',
   'mem.c',
   'msr.c',
   'mshv-all.c'
 ))
-
-specific_ss.add_all(when: 'CONFIG_MSHV', if_true: mshv_ss)
Signature · 1 line
2.52.0
Reviewed-by on v1 3/5
#6 lore raw

Re: [PATCH 3/5] accel/mshv: Build without target-specific knowledge

Quoted 9 lines · Philippe Mathieu-Daudé

Code in accel/ aims to be target-agnostic. Enforce that by moving the MSHV file units to system_ss[], which is target-agnostic.

---
  accel/mshv/meson.build | 5 +----
  1 file changed, 1 insertion(+), 4 deletions(-)
#7 lore raw

PATCH 4/5 accel/hvf: Build without target-specific knowledge

In reply to Philippe Mathieu-Daudé

Code in accel/ aims to be target-agnostic. Enforce that by moving the MSHV file units to system_ss[], which is target-agnostic.

---
 accel/hvf/meson.build | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
accel/hvf/meson.build +1 -4
index fc52cb78433..6e2dcc4a5f0 100644
@@ -1,7 +1,4 @@
-hvf_ss = ss.source_set()
-hvf_ss.add(files(
+system_ss.add(when: 'CONFIG_HVF', if_true: files(
   'hvf-all.c',
   'hvf-accel-ops.c',
 ))
-
-specific_ss.add_all(when: 'CONFIG_HVF', if_true: hvf_ss)
Signature · 1 line
2.52.0
#8 lore raw

Re: [PATCH 4/5] accel/hvf: Build without target-specific knowledge

Quoted 2 lines · Philippe Mathieu-Daudé

Code in accel/ aims to be target-agnostic. Enforce that by moving the MSHV file units to system_ss[], which is

s/MSHV/HVF/

Quoted 20 lines

target-agnostic.

---
  accel/hvf/meson.build | 5 +----
  1 file changed, 1 insertion(+), 4 deletions(-)
accel/hvf/meson.build +1 -4
index fc52cb78433..6e2dcc4a5f0 100644
@@ -1,7 +1,4 @@
-hvf_ss = ss.source_set()
-hvf_ss.add(files(
+system_ss.add(when: 'CONFIG_HVF', if_true: files(
    'hvf-all.c',
    'hvf-accel-ops.c',
  ))
-
-specific_ss.add_all(when: 'CONFIG_HVF', if_true: hvf_ss)
Reviewed-by on v1 4/5
#9 lore raw

Re: [PATCH 4/5] accel/hvf: Build without target-specific knowledge

In reply to Philippe Mathieu-Daudé
Quoted 9 lines · Philippe Mathieu-Daudé

Code in accel/ aims to be target-agnostic. Enforce that by moving the MSHV file units to system_ss[], which is target-agnostic.

---
  accel/hvf/meson.build | 5 +----
  1 file changed, 1 insertion(+), 4 deletions(-)
#10 lore raw

PATCH 5/5 accel/xen: Build without target-specific knowledge

In reply to Philippe Mathieu-Daudé

Code in accel/ aims to be target-agnostic. Enforce that by moving the MSHV file units to system_ss[], which is target-agnostic.

---
 accel/xen/meson.build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
accel/xen/meson.build +1 -1
index 002bdb03c62..455ad5d6be4 100644
@@ -1 +1 @@
-specific_ss.add(when: 'CONFIG_XEN', if_true: files('xen-all.c'))
+system_ss.add(when: 'CONFIG_XEN', if_true: files('xen-all.c'))
Signature · 1 line
2.52.0
Acked-by on v1 5/5
#11 lore raw

Re: [PATCH 5/5] accel/xen: Build without target-specific knowledge

Quoted 2 lines · Philippe Mathieu-Daudé

Code in accel/ aims to be target-agnostic. Enforce that by moving the MSHV file units to system_ss[], which is

You mean Xen ^ here ?

Quoted 3 lines

target-agnostic.

In anycase, it seems to works fine for me:

Thanks,

--
Anthony Perard | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech

Reviewed-by on v1 5/5
#12 lore raw

Re: [PATCH 5/5] accel/xen: Build without target-specific knowledge

In reply to Philippe Mathieu-Daudé
Quoted 9 lines · Philippe Mathieu-Daudé

Code in accel/ aims to be target-agnostic. Enforce that by moving the MSHV file units to system_ss[], which is target-agnostic.

---
  accel/xen/meson.build | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by on the v1 series
#13 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 9 lines · Philippe Mathieu-Daudé

Code in accel/ aims to be target-agnostic. Not all accelerators are ready for that, but start by enforcing a few easy ones.

Philippe Mathieu-Daudé (5):
accel/kvm: Include missing 'exec/cpu-common.h' header accel/mshv: Forward-declare mshv_root_hvcall structure accel/mshv: Build without target-specific knowledge accel/hvf: Build without target-specific knowledge accel/xen: Build without target-specific knowledge

r~

#14 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 6 lines · Philippe Mathieu-Daudé

Philippe Mathieu-Daudé (5):
accel/kvm: Include missing 'exec/cpu-common.h' header accel/mshv: Forward-declare mshv_root_hvcall structure accel/mshv: Build without target-specific knowledge accel/hvf: Build without target-specific knowledge accel/xen: Build without target-specific knowledge

Series queued, thanks.