For some devices/machines, we'll need to access target configuration,
but without relying to target headers. Thus, we'll add the needed
information in target-info.

At this moment, we duplicate code between all configs/targets/*.c and
target-info-stub.c but we will clean up this before the end of this
series.

Signed-off-by: Pierrick Bouvier <[email protected]>
---
 configs/targets/aarch64-softmmu.c | 11 +++++++++++
 configs/targets/arm-softmmu.c     | 11 +++++++++++
 configs/targets/riscv32-softmmu.c | 11 +++++++++++
 configs/targets/riscv64-softmmu.c | 11 +++++++++++
 include/qemu/target-info-impl.h   |  3 +++
 include/qemu/target-info.h        |  7 +++++++
 meson.build                       |  2 +-
 target-info-stub.c                | 12 ++++++++++++
 target-info.c                     |  5 +++++
 9 files changed, 72 insertions(+), 1 deletion(-)

diff --git a/configs/targets/aarch64-softmmu.c 
b/configs/targets/aarch64-softmmu.c
index 75d95b0e743..af65da80d04 100644
--- a/configs/targets/aarch64-softmmu.c
+++ b/configs/targets/aarch64-softmmu.c
@@ -12,6 +12,9 @@
 #include "hw/arm/machines-qom.h"
 #include "target/arm/cpu-qom.h"
 #include "target/arm/cpu-param.h"
+#ifndef CONFIG_USER_ONLY
+#include CONFIG_DEVICES
+#endif
 
 static const TargetInfo target_info_aarch64_system = {
     .target_name = "aarch64",
@@ -22,6 +25,14 @@ static const TargetInfo target_info_aarch64_system = {
     .endianness = ENDIAN_MODE_LITTLE,
     .page_bits_vary = true,
     .page_bits_init = TARGET_PAGE_BITS_LEGACY,
+
+#ifndef CONFIG_USER_ONLY
+# ifdef CONFIG_MULTIPROCESS
+    .config_multiprocess = true,
+# else
+    .config_multiprocess = false,
+# endif
+#endif
 };
 
 target_info_init(target_info_aarch64_system)
diff --git a/configs/targets/arm-softmmu.c b/configs/targets/arm-softmmu.c
index 73546fa5737..501956403cc 100644
--- a/configs/targets/arm-softmmu.c
+++ b/configs/targets/arm-softmmu.c
@@ -12,6 +12,9 @@
 #include "hw/arm/machines-qom.h"
 #include "target/arm/cpu-qom.h"
 #include "target/arm/cpu-param.h"
+#ifndef CONFIG_USER_ONLY
+#include CONFIG_DEVICES
+#endif
 
 static const TargetInfo target_info_arm_system = {
     .target_name = "arm",
@@ -22,6 +25,14 @@ static const TargetInfo target_info_arm_system = {
     .endianness = ENDIAN_MODE_LITTLE,
     .page_bits_vary = true,
     .page_bits_init = TARGET_PAGE_BITS_LEGACY,
+
+#ifndef CONFIG_USER_ONLY
+# ifdef CONFIG_MULTIPROCESS
+    .config_multiprocess = true,
+# else
+    .config_multiprocess = false,
+# endif
+#endif
 };
 
 target_info_init(target_info_arm_system)
diff --git a/configs/targets/riscv32-softmmu.c 
b/configs/targets/riscv32-softmmu.c
index 752c813077e..69053f3945e 100644
--- a/configs/targets/riscv32-softmmu.c
+++ b/configs/targets/riscv32-softmmu.c
@@ -12,6 +12,9 @@
 #include "hw/riscv/machines-qom.h"
 #include "target/riscv/cpu-qom.h"
 #include "target/riscv/cpu-param.h"
+#ifndef CONFIG_USER_ONLY
+#include CONFIG_DEVICES
+#endif
 
 static const TargetInfo target_info_riscv32_system = {
     .target_name = "riscv32",
@@ -21,6 +24,14 @@ static const TargetInfo target_info_riscv32_system = {
     .machine_typename = TYPE_TARGET_RISCV32_MACHINE,
     .endianness = ENDIAN_MODE_LITTLE,
     .page_bits_init = TARGET_PAGE_BITS,
+
+#ifndef CONFIG_USER_ONLY
+# ifdef CONFIG_MULTIPROCESS
+    .config_multiprocess = true,
+# else
+    .config_multiprocess = false,
+# endif
+#endif
 };
 
 target_info_init(target_info_riscv32_system)
diff --git a/configs/targets/riscv64-softmmu.c 
b/configs/targets/riscv64-softmmu.c
index 5150f0fe9d9..cd0fb555986 100644
--- a/configs/targets/riscv64-softmmu.c
+++ b/configs/targets/riscv64-softmmu.c
@@ -12,6 +12,9 @@
 #include "hw/riscv/machines-qom.h"
 #include "target/riscv/cpu-qom.h"
 #include "target/riscv/cpu-param.h"
+#ifndef CONFIG_USER_ONLY
+#include CONFIG_DEVICES
+#endif
 
 static const TargetInfo target_info_riscv64_system = {
     .target_name = "riscv64",
@@ -21,6 +24,14 @@ static const TargetInfo target_info_riscv64_system = {
     .machine_typename = TYPE_TARGET_RISCV64_MACHINE,
     .endianness = ENDIAN_MODE_LITTLE,
     .page_bits_init = TARGET_PAGE_BITS,
+
+#ifndef CONFIG_USER_ONLY
+# ifdef CONFIG_MULTIPROCESS
+    .config_multiprocess = true,
+# else
+    .config_multiprocess = false,
+# endif
+#endif
 };
 
 target_info_init(target_info_riscv64_system)
diff --git a/include/qemu/target-info-impl.h b/include/qemu/target-info-impl.h
index c917d546eab..0496eeac046 100644
--- a/include/qemu/target-info-impl.h
+++ b/include/qemu/target-info-impl.h
@@ -32,6 +32,9 @@ typedef struct TargetInfo {
     unsigned page_bits_init;
     /* runtime equivalent of TARGET_PAGE_BITS_VARY definition */
     bool page_bits_vary;
+
+    /* CONFIG_MULTIPROCESS */
+    bool config_multiprocess;
 } TargetInfo;
 
 /**
diff --git a/include/qemu/target-info.h b/include/qemu/target-info.h
index 88ccef2a988..996780150a0 100644
--- a/include/qemu/target-info.h
+++ b/include/qemu/target-info.h
@@ -120,4 +120,11 @@ bool target_riscv32(void);
  */
 bool target_riscv64(void);
 
+/**
+ * target_config_multiprocess:
+ *
+ * Returns true if target defines CONFIG_MULTIPROCESS.
+ */
+bool target_config_multiprocess(void);
+
 #endif
diff --git a/meson.build b/meson.build
index 49a5baf5b52..2b5db0d096a 100644
--- a/meson.build
+++ b/meson.build
@@ -4259,7 +4259,7 @@ foreach target : target_dirs
   arch_deps = []
   c_args = ['-DCOMPILING_PER_TARGET',
             '-DCONFIG_TARGET="@[email protected]"'.format(target),
-  ]
+            '-DCONFIG_DEVICES="@[email protected]"'.format(target)]
   link_args = emulator_link_args
 
   target_inc = [include_directories('target' / 
config_target['TARGET_BASE_ARCH'])]
diff --git a/target-info-stub.c b/target-info-stub.c
index 22b7911201c..99c1b1cd7ef 100644
--- a/target-info-stub.c
+++ b/target-info-stub.c
@@ -14,6 +14,10 @@
 #include "cpu.h"
 #include "exec/cpu-defs.h"
 #include "exec/page-vary.h"
+#ifndef CONFIG_USER_ONLY
+#include CONFIG_DEVICES
+#endif
+#include CONFIG_TARGET
 
 /* Validate correct placement of CPUArchState. */
 QEMU_BUILD_BUG_ON(offsetof(ArchCPU, parent_obj) != 0);
@@ -40,6 +44,14 @@ static const TargetInfo target_info_stub = {
     .page_bits_vary = false,
     .page_bits_init = TARGET_PAGE_BITS,
 #endif
+
+#ifndef CONFIG_USER_ONLY
+# ifdef CONFIG_MULTIPROCESS
+    .config_multiprocess = true,
+# else
+    .config_multiprocess = false,
+# endif
+#endif
 };
 
 target_info_init(target_info_stub)
diff --git a/target-info.c b/target-info.c
index 7ac2260b182..07fde91b1ec 100644
--- a/target-info.c
+++ b/target-info.c
@@ -114,3 +114,8 @@ bool target_riscv64(void)
 {
     return target_arch() == SYS_EMU_TARGET_RISCV64;
 }
+
+bool target_config_multiprocess(void)
+{
+    return target_info()->config_multiprocess;
+}
-- 
2.43.0


Reply via email to