qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/19] target/arm: More header rework around arm_feature() & multiprocessing.h
@ 2025-05-13 17:39 Philippe Mathieu-Daudé
  2025-05-13 17:39 ` [PATCH 01/19] target/arm/tcg-stubs: compile file once (system) Philippe Mathieu-Daudé
                   ` (20 more replies)
  0 siblings, 21 replies; 37+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-05-13 17:39 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, qemu-arm, Richard Henderson, Pierrick Bouvier,
	Philippe Mathieu-Daudé

Before I respin my "single-binary: Make hw/arm/ common" [1] I'm
extracting these random cleanup patches. Some aren't necessary
anymore because now units in arm_common_ss[] can access "cpu.h",
but the patches are reviewed and simplify a bit IMO.

Based-on: <20250512180502.2395029-1-pierrick.bouvier@linaro.org>
          "single-binary: compile target/arm twice"

[1] https://lore.kernel.org/qemu-devel/20250403235821.9909-1-philmd@linaro.org/

Philippe Mathieu-Daudé (19):
  target/arm/tcg-stubs: compile file once (system)
  target/arm/hvf_arm: Avoid using poisoned CONFIG_HVF definition
  target/arm: Only link with zlib when TCG is enabled
  target/arm/cpregs: Include missing 'target/arm/cpu.h' header
  hw/arm/boot: Include missing 'system/memory.h' header
  target/arm/cpu-features: Include missing 'cpu.h' header
  target/arm/qmp: Include missing 'cpu.h' header
  target/arm/kvm: Include missing 'cpu-qom.h' header
  target/arm/hvf: Include missing 'cpu-qom.h' header
  hw/arm: Remove unnecessary 'cpu.h' header
  target/arm: Restrict inclusion of 'multiprocessing.h'
  target/arm: Move some definitions from 'cpu.h' to 'multiprocessing.h'
  hw/arm: Include missing 'target/arm/gtimer.h' header
  target/arm: Extract PSCI definitions to 'psci.h'
  target/arm: Extract feature definitions to 'cpu_has_feature.h' header
  target/arm: Add arm_cpu_has_feature() helper
  hw/arm/realview: Replace arm_feature() -> arm_cpu_has_feature()
  hw/arm/virt-acpi: Replace arm_feature() -> arm_cpu_has_feature()
  target/arm: Always include full path to 'cpu.h'

 MAINTAINERS                    |  1 +
 include/hw/arm/boot.h          |  3 +-
 target/arm/cpregs.h            |  1 +
 target/arm/cpu-features.h      |  1 +
 target/arm/cpu.h               | 79 ++--------------------------------
 target/arm/cpu_has_feature.h   | 67 ++++++++++++++++++++++++++++
 target/arm/hvf_arm.h           | 18 +-------
 target/arm/kvm_arm.h           |  1 +
 target/arm/multiprocessing.h   | 18 ++++++++
 target/arm/psci.h              | 18 ++++++++
 target/arm/tcg/translate.h     |  2 +-
 hw/arm/aspeed_ast2600.c        |  1 +
 hw/arm/aspeed_ast27x0.c        |  2 +
 hw/arm/bananapi_m2u.c          |  1 +
 hw/arm/bcm2838.c               |  1 +
 hw/arm/boot.c                  |  2 +
 hw/arm/exynos4210.c            |  3 +-
 hw/arm/fsl-imx8mp.c            |  1 +
 hw/arm/highbank.c              |  2 +-
 hw/arm/imx8mp-evk.c            |  1 +
 hw/arm/mcimx6ul-evk.c          |  1 +
 hw/arm/mcimx7d-sabre.c         |  1 +
 hw/arm/mps3r.c                 |  2 +-
 hw/arm/npcm8xx.c               |  2 +
 hw/arm/orangepi.c              |  1 +
 hw/arm/realview.c              | 10 ++---
 hw/arm/sbsa-ref.c              |  2 +
 hw/arm/smmuv3.c                |  1 -
 hw/arm/virt-acpi-build.c       |  4 +-
 hw/arm/virt.c                  |  1 +
 hw/arm/xlnx-versal-virt.c      |  1 +
 hw/arm/xlnx-zcu102.c           |  1 +
 hw/vmapple/vmapple.c           |  3 ++
 target/arm/arch_dump.c         |  2 +-
 target/arm/arm-powerctl.c      |  2 +-
 target/arm/arm-qmp-cmds.c      |  1 +
 target/arm/cortex-regs.c       |  2 +-
 target/arm/cpu.c               | 10 ++++-
 target/arm/cpu64.c             |  2 +-
 target/arm/debug_helper.c      |  2 +-
 target/arm/gdbstub.c           |  2 +-
 target/arm/gdbstub64.c         |  2 +-
 target/arm/helper.c            |  3 +-
 target/arm/hvf-stub.c          | 20 +++++++++
 target/arm/hvf/hvf.c           |  1 +
 target/arm/hyp_gdbstub.c       |  2 +-
 target/arm/kvm-stub.c          |  2 +-
 target/arm/kvm.c               |  3 +-
 target/arm/machine.c           |  2 +-
 target/arm/ptw.c               |  2 +-
 target/arm/tcg-stubs.c         |  2 +-
 target/arm/tcg/cpu-v7m.c       |  2 +-
 target/arm/tcg/cpu32.c         |  2 +-
 target/arm/tcg/cpu64.c         |  2 +-
 target/arm/tcg/helper-a64.c    |  2 +-
 target/arm/tcg/hflags.c        |  2 +-
 target/arm/tcg/iwmmxt_helper.c |  2 +-
 target/arm/tcg/m_helper.c      |  2 +-
 target/arm/tcg/mte_helper.c    |  2 +-
 target/arm/tcg/mve_helper.c    |  2 +-
 target/arm/tcg/neon_helper.c   |  2 +-
 target/arm/tcg/op_helper.c     |  4 +-
 target/arm/tcg/pauth_helper.c  |  2 +-
 target/arm/tcg/psci.c          |  3 +-
 target/arm/tcg/sme_helper.c    |  2 +-
 target/arm/tcg/sve_helper.c    |  2 +-
 target/arm/tcg/tlb-insns.c     |  2 +-
 target/arm/tcg/tlb_helper.c    |  2 +-
 target/arm/tcg/vec_helper.c    |  2 +-
 target/arm/tcg/vfp_helper.c    |  2 +-
 target/arm/vfp_fpscr.c         |  2 +-
 target/arm/meson.build         |  4 +-
 target/arm/tcg/meson.build     |  2 +
 73 files changed, 221 insertions(+), 143 deletions(-)
 create mode 100644 target/arm/cpu_has_feature.h
 create mode 100644 target/arm/psci.h
 create mode 100644 target/arm/hvf-stub.c

-- 
2.47.1



^ permalink raw reply	[flat|nested] 37+ messages in thread

* [PATCH 01/19] target/arm/tcg-stubs: compile file once (system)
  2025-05-13 17:39 [PATCH 00/19] target/arm: More header rework around arm_feature() & multiprocessing.h Philippe Mathieu-Daudé
@ 2025-05-13 17:39 ` Philippe Mathieu-Daudé
  2025-05-13 17:43   ` Philippe Mathieu-Daudé
                     ` (2 more replies)
  2025-05-13 17:39 ` [PATCH 02/19] target/arm/hvf_arm: Avoid using poisoned CONFIG_HVF definition Philippe Mathieu-Daudé
                   ` (19 subsequent siblings)
  20 siblings, 3 replies; 37+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-05-13 17:39 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, qemu-arm, Richard Henderson, Pierrick Bouvier,
	Philippe Mathieu-Daudé

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/arm/meson.build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target/arm/meson.build b/target/arm/meson.build
index b404fa54863..e568dfb706a 100644
--- a/target/arm/meson.build
+++ b/target/arm/meson.build
@@ -48,7 +48,7 @@ subdir('hvf')
 if 'CONFIG_TCG' in config_all_accel
    subdir('tcg')
 else
-    arm_ss.add(files('tcg-stubs.c'))
+    arm_common_system_ss.add(files('tcg-stubs.c'))
 endif
 
 target_arch += {'arm': arm_ss}
-- 
2.47.1



^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 02/19] target/arm/hvf_arm: Avoid using poisoned CONFIG_HVF definition
  2025-05-13 17:39 [PATCH 00/19] target/arm: More header rework around arm_feature() & multiprocessing.h Philippe Mathieu-Daudé
  2025-05-13 17:39 ` [PATCH 01/19] target/arm/tcg-stubs: compile file once (system) Philippe Mathieu-Daudé
@ 2025-05-13 17:39 ` Philippe Mathieu-Daudé
  2025-05-13 22:58   ` Pierrick Bouvier
  2025-05-14  8:19   ` Richard Henderson
  2025-05-13 17:39 ` [PATCH 03/19] target/arm: Only link with zlib when TCG is enabled Philippe Mathieu-Daudé
                   ` (18 subsequent siblings)
  20 siblings, 2 replies; 37+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-05-13 17:39 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, qemu-arm, Richard Henderson, Pierrick Bouvier,
	Philippe Mathieu-Daudé

In order to allow non-target specific code to include
"hvf_arm.h", define the stubs in hvf-stub.c.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 MAINTAINERS            |  1 +
 target/arm/hvf_arm.h   | 16 ----------------
 target/arm/hvf-stub.c  | 20 ++++++++++++++++++++
 target/arm/meson.build |  1 +
 4 files changed, 22 insertions(+), 16 deletions(-)
 create mode 100644 target/arm/hvf-stub.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 6dacd6d004d..7431f88b5d9 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -509,6 +509,7 @@ Apple Silicon HVF CPUs
 M: Alexander Graf <agraf@csgraf.de>
 S: Maintained
 F: target/arm/hvf/
+F: target/arm/hvf-stub.c
 
 X86 HVF CPUs
 M: Cameron Esfahani <dirty@apple.com>
diff --git a/target/arm/hvf_arm.h b/target/arm/hvf_arm.h
index 26c717b3826..7a44e092620 100644
--- a/target/arm/hvf_arm.h
+++ b/target/arm/hvf_arm.h
@@ -22,23 +22,7 @@ void hvf_arm_init_debug(void);
 
 void hvf_arm_set_cpu_features_from_host(ARMCPU *cpu);
 
-#ifdef CONFIG_HVF
-
 uint32_t hvf_arm_get_default_ipa_bit_size(void);
 uint32_t hvf_arm_get_max_ipa_bit_size(void);
 
-#else
-
-static inline uint32_t hvf_arm_get_default_ipa_bit_size(void)
-{
-    return 0;
-}
-
-static inline uint32_t hvf_arm_get_max_ipa_bit_size(void)
-{
-    return 0;
-}
-
-#endif
-
 #endif
diff --git a/target/arm/hvf-stub.c b/target/arm/hvf-stub.c
new file mode 100644
index 00000000000..ff137267a03
--- /dev/null
+++ b/target/arm/hvf-stub.c
@@ -0,0 +1,20 @@
+/*
+ * QEMU Hypervisor.framework (HVF) stubs for ARM
+ *
+ *  Copyright (c) Linaro
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "hvf_arm.h"
+
+uint32_t hvf_arm_get_default_ipa_bit_size(void)
+{
+    g_assert_not_reached();
+}
+
+uint32_t hvf_arm_get_max_ipa_bit_size(void)
+{
+    g_assert_not_reached();
+}
diff --git a/target/arm/meson.build b/target/arm/meson.build
index e568dfb706a..2747f4b404c 100644
--- a/target/arm/meson.build
+++ b/target/arm/meson.build
@@ -32,6 +32,7 @@ arm_common_system_ss.add(files('cpu.c'), capstone)
 arm_common_system_ss.add(when: 'TARGET_AARCH64', if_false: files(
   'cpu32-stubs.c'))
 arm_common_system_ss.add(when: 'CONFIG_KVM', if_false: files('kvm-stub.c'))
+arm_common_system_ss.add(when: 'CONFIG_HVF', if_false: files('hvf-stub.c'))
 arm_common_system_ss.add(files(
   'arch_dump.c',
   'arm-powerctl.c',
-- 
2.47.1



^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 03/19] target/arm: Only link with zlib when TCG is enabled
  2025-05-13 17:39 [PATCH 00/19] target/arm: More header rework around arm_feature() & multiprocessing.h Philippe Mathieu-Daudé
  2025-05-13 17:39 ` [PATCH 01/19] target/arm/tcg-stubs: compile file once (system) Philippe Mathieu-Daudé
  2025-05-13 17:39 ` [PATCH 02/19] target/arm/hvf_arm: Avoid using poisoned CONFIG_HVF definition Philippe Mathieu-Daudé
@ 2025-05-13 17:39 ` Philippe Mathieu-Daudé
  2025-05-13 22:58   ` Pierrick Bouvier
  2025-05-13 17:39 ` [PATCH 04/19] target/arm/cpregs: Include missing 'target/arm/cpu.h' header Philippe Mathieu-Daudé
                   ` (17 subsequent siblings)
  20 siblings, 1 reply; 37+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-05-13 17:39 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, qemu-arm, Richard Henderson, Pierrick Bouvier,
	Philippe Mathieu-Daudé

Since commit 538b764d341 ("target/arm: Move minor arithmetic
helpers out of helper.c") we only use the zlib helpers under
TCG.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/arm/meson.build     | 1 -
 target/arm/tcg/meson.build | 2 ++
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/target/arm/meson.build b/target/arm/meson.build
index 2747f4b404c..dcba4ef3792 100644
--- a/target/arm/meson.build
+++ b/target/arm/meson.build
@@ -3,7 +3,6 @@ arm_common_ss = ss.source_set()
 arm_ss.add(files(
   'gdbstub.c',
 ))
-arm_ss.add(zlib)
 
 arm_ss.add(when: 'TARGET_AARCH64', if_true: files(
   'cpu64.c',
diff --git a/target/arm/tcg/meson.build b/target/arm/tcg/meson.build
index 2d1502ba882..c59f0f03a1b 100644
--- a/target/arm/tcg/meson.build
+++ b/target/arm/tcg/meson.build
@@ -56,6 +56,8 @@ arm_system_ss.add(files(
 arm_system_ss.add(when: 'CONFIG_ARM_V7M', if_true: files('cpu-v7m.c'))
 arm_user_ss.add(when: 'TARGET_AARCH64', if_false: files('cpu-v7m.c'))
 
+arm_common_ss.add(zlib)
+
 arm_common_ss.add(files(
   'arith_helper.c',
   'crypto_helper.c',
-- 
2.47.1



^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 04/19] target/arm/cpregs: Include missing 'target/arm/cpu.h' header
  2025-05-13 17:39 [PATCH 00/19] target/arm: More header rework around arm_feature() & multiprocessing.h Philippe Mathieu-Daudé
                   ` (2 preceding siblings ...)
  2025-05-13 17:39 ` [PATCH 03/19] target/arm: Only link with zlib when TCG is enabled Philippe Mathieu-Daudé
@ 2025-05-13 17:39 ` Philippe Mathieu-Daudé
  2025-05-13 17:39 ` [PATCH 05/19] hw/arm/boot: Include missing 'system/memory.h' header Philippe Mathieu-Daudé
                   ` (16 subsequent siblings)
  20 siblings, 0 replies; 37+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-05-13 17:39 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, qemu-arm, Richard Henderson, Pierrick Bouvier,
	Philippe Mathieu-Daudé

CPReadFn type definitions use the CPUARMState type, itself
declared in "cpu.h". Include this file in order to avoid when
refactoring headers:

  ../target/arm/cpregs.h:241:27: error: unknown type name 'CPUARMState'
  typedef uint64_t CPReadFn(CPUARMState *env, const ARMCPRegInfo *opaque);
                            ^

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/arm/cpregs.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h
index 2183de8eda6..c1a7ae37356 100644
--- a/target/arm/cpregs.h
+++ b/target/arm/cpregs.h
@@ -23,6 +23,7 @@
 
 #include "hw/registerfields.h"
 #include "target/arm/kvm-consts.h"
+#include "cpu.h"
 
 /*
  * ARMCPRegInfo type field bits:
-- 
2.47.1



^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 05/19] hw/arm/boot: Include missing 'system/memory.h' header
  2025-05-13 17:39 [PATCH 00/19] target/arm: More header rework around arm_feature() & multiprocessing.h Philippe Mathieu-Daudé
                   ` (3 preceding siblings ...)
  2025-05-13 17:39 ` [PATCH 04/19] target/arm/cpregs: Include missing 'target/arm/cpu.h' header Philippe Mathieu-Daudé
@ 2025-05-13 17:39 ` Philippe Mathieu-Daudé
  2025-05-13 17:39 ` [PATCH 06/19] target/arm/cpu-features: Include missing 'cpu.h' header Philippe Mathieu-Daudé
                   ` (15 subsequent siblings)
  20 siblings, 0 replies; 37+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-05-13 17:39 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, qemu-arm, Richard Henderson, Pierrick Bouvier,
	Philippe Mathieu-Daudé

default_reset_secondary() uses address_space_stl_notdirty(),
itself declared in "system/memory.h". Include this header in
order to avoid when refactoring headers:

  ../hw/arm/boot.c:281:5: error: implicit declaration of function 'address_space_stl_notdirty' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    address_space_stl_notdirty(as, info->smp_bootreg_addr,
    ^

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/arm/boot.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/arm/boot.c b/hw/arm/boot.c
index f94b940bc31..79afb51b8a5 100644
--- a/hw/arm/boot.c
+++ b/hw/arm/boot.c
@@ -19,6 +19,7 @@
 #include "system/kvm.h"
 #include "system/tcg.h"
 #include "system/system.h"
+#include "system/memory.h"
 #include "system/numa.h"
 #include "hw/boards.h"
 #include "system/reset.h"
-- 
2.47.1



^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 06/19] target/arm/cpu-features: Include missing 'cpu.h' header
  2025-05-13 17:39 [PATCH 00/19] target/arm: More header rework around arm_feature() & multiprocessing.h Philippe Mathieu-Daudé
                   ` (4 preceding siblings ...)
  2025-05-13 17:39 ` [PATCH 05/19] hw/arm/boot: Include missing 'system/memory.h' header Philippe Mathieu-Daudé
@ 2025-05-13 17:39 ` Philippe Mathieu-Daudé
  2025-05-13 17:39 ` [PATCH 07/19] target/arm/qmp: " Philippe Mathieu-Daudé
                   ` (14 subsequent siblings)
  20 siblings, 0 replies; 37+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-05-13 17:39 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, qemu-arm, Richard Henderson, Pierrick Bouvier,
	Philippe Mathieu-Daudé

"target/arm/cpu-features.h" dereferences the ARMISARegisters
structure, which is defined in "cpu.h". Include the latter to
avoid when refactoring unrelated headers:

  In file included from target/arm/internals.h:33:
  target/arm/cpu-features.h:45:54: error: unknown type name 'ARMISARegisters'
     45 | static inline bool isar_feature_aa32_thumb_div(const ARMISARegisters *id)
        |                                                      ^
  target/arm/cpu-features.h:47:12: error: use of undeclared identifier 'R_ID_ISAR0_DIVIDE_SHIFT'
     47 |     return FIELD_EX32(id->id_isar0, ID_ISAR0, DIVIDE) != 0;
        |            ^

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
 target/arm/cpu-features.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/target/arm/cpu-features.h b/target/arm/cpu-features.h
index 525e4cee12f..4452e7c21e3 100644
--- a/target/arm/cpu-features.h
+++ b/target/arm/cpu-features.h
@@ -22,6 +22,7 @@
 
 #include "hw/registerfields.h"
 #include "qemu/host-utils.h"
+#include "cpu.h"
 
 /*
  * Naming convention for isar_feature functions:
-- 
2.47.1



^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 07/19] target/arm/qmp: Include missing 'cpu.h' header
  2025-05-13 17:39 [PATCH 00/19] target/arm: More header rework around arm_feature() & multiprocessing.h Philippe Mathieu-Daudé
                   ` (5 preceding siblings ...)
  2025-05-13 17:39 ` [PATCH 06/19] target/arm/cpu-features: Include missing 'cpu.h' header Philippe Mathieu-Daudé
@ 2025-05-13 17:39 ` Philippe Mathieu-Daudé
  2025-05-13 17:39 ` [PATCH 08/19] target/arm/kvm: Include missing 'cpu-qom.h' header Philippe Mathieu-Daudé
                   ` (13 subsequent siblings)
  20 siblings, 0 replies; 37+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-05-13 17:39 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, qemu-arm, Richard Henderson, Pierrick Bouvier,
	Philippe Mathieu-Daudé

arm-qmp-cmds.c uses ARM_MAX_VQ, which is defined in "cpu.h".
Include the latter to avoid when refactoring unrelated headers:

  target/arm/arm-qmp-cmds.c:83:19: error: use of undeclared identifier 'ARM_MAX_VQ'
     83 | QEMU_BUILD_BUG_ON(ARM_MAX_VQ > 16);
        |                   ^

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
 target/arm/arm-qmp-cmds.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/target/arm/arm-qmp-cmds.c b/target/arm/arm-qmp-cmds.c
index a1a944adb43..930ec37413d 100644
--- a/target/arm/arm-qmp-cmds.c
+++ b/target/arm/arm-qmp-cmds.c
@@ -30,6 +30,7 @@
 #include "qapi/qapi-commands-misc-target.h"
 #include "qobject/qdict.h"
 #include "qom/qom-qobject.h"
+#include "cpu.h"
 
 static GICCapability *gic_cap_new(int version)
 {
-- 
2.47.1



^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 08/19] target/arm/kvm: Include missing 'cpu-qom.h' header
  2025-05-13 17:39 [PATCH 00/19] target/arm: More header rework around arm_feature() & multiprocessing.h Philippe Mathieu-Daudé
                   ` (6 preceding siblings ...)
  2025-05-13 17:39 ` [PATCH 07/19] target/arm/qmp: " Philippe Mathieu-Daudé
@ 2025-05-13 17:39 ` Philippe Mathieu-Daudé
  2025-05-13 17:39 ` [PATCH 09/19] target/arm/hvf: " Philippe Mathieu-Daudé
                   ` (12 subsequent siblings)
  20 siblings, 0 replies; 37+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-05-13 17:39 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, qemu-arm, Richard Henderson, Pierrick Bouvier,
	Philippe Mathieu-Daudé

ARMCPU typedef is declared in "cpu-qom.h". Include it in
order to avoid when refactoring unrelated headers:

  target/arm/kvm_arm.h:54:29: error: unknown type name 'ARMCPU'
     54 | bool write_list_to_kvmstate(ARMCPU *cpu, int level);
        |                             ^

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
 target/arm/kvm_arm.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h
index c4178d1327c..7dc83caed5c 100644
--- a/target/arm/kvm_arm.h
+++ b/target/arm/kvm_arm.h
@@ -12,6 +12,7 @@
 #define QEMU_KVM_ARM_H
 
 #include "system/kvm.h"
+#include "target/arm/cpu-qom.h"
 
 #define KVM_ARM_VGIC_V2   (1 << 0)
 #define KVM_ARM_VGIC_V3   (1 << 1)
-- 
2.47.1



^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 09/19] target/arm/hvf: Include missing 'cpu-qom.h' header
  2025-05-13 17:39 [PATCH 00/19] target/arm: More header rework around arm_feature() & multiprocessing.h Philippe Mathieu-Daudé
                   ` (7 preceding siblings ...)
  2025-05-13 17:39 ` [PATCH 08/19] target/arm/kvm: Include missing 'cpu-qom.h' header Philippe Mathieu-Daudé
@ 2025-05-13 17:39 ` Philippe Mathieu-Daudé
  2025-05-13 17:39 ` [PATCH 10/19] hw/arm: Remove unnecessary 'cpu.h' header Philippe Mathieu-Daudé
                   ` (11 subsequent siblings)
  20 siblings, 0 replies; 37+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-05-13 17:39 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, qemu-arm, Richard Henderson, Pierrick Bouvier,
	Philippe Mathieu-Daudé

ARMCPU typedef is declared in "cpu-qom.h". Include it in
order to avoid when refactoring unrelated headers:

  target/arm/hvf_arm.h:23:41: error: unknown type name 'ARMCPU'
     23 | void hvf_arm_set_cpu_features_from_host(ARMCPU *cpu);
        |                                         ^

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
 target/arm/hvf_arm.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target/arm/hvf_arm.h b/target/arm/hvf_arm.h
index 7a44e092620..ea82f2691df 100644
--- a/target/arm/hvf_arm.h
+++ b/target/arm/hvf_arm.h
@@ -11,7 +11,7 @@
 #ifndef QEMU_HVF_ARM_H
 #define QEMU_HVF_ARM_H
 
-#include "cpu.h"
+#include "target/arm/cpu-qom.h"
 
 /**
  * hvf_arm_init_debug() - initialize guest debug capabilities
-- 
2.47.1



^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 10/19] hw/arm: Remove unnecessary 'cpu.h' header
  2025-05-13 17:39 [PATCH 00/19] target/arm: More header rework around arm_feature() & multiprocessing.h Philippe Mathieu-Daudé
                   ` (8 preceding siblings ...)
  2025-05-13 17:39 ` [PATCH 09/19] target/arm/hvf: " Philippe Mathieu-Daudé
@ 2025-05-13 17:39 ` Philippe Mathieu-Daudé
  2025-05-13 17:39 ` [PATCH 11/19] target/arm: Restrict inclusion of 'multiprocessing.h' Philippe Mathieu-Daudé
                   ` (10 subsequent siblings)
  20 siblings, 0 replies; 37+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-05-13 17:39 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, qemu-arm, Richard Henderson, Pierrick Bouvier,
	Philippe Mathieu-Daudé

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
 hw/arm/exynos4210.c | 1 -
 hw/arm/highbank.c   | 1 -
 hw/arm/mps3r.c      | 1 -
 hw/arm/smmuv3.c     | 1 -
 4 files changed, 4 deletions(-)

diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c
index 76001ff0dfc..56267ec2bd2 100644
--- a/hw/arm/exynos4210.c
+++ b/hw/arm/exynos4210.c
@@ -24,7 +24,6 @@
 #include "qemu/osdep.h"
 #include "qapi/error.h"
 #include "exec/tswap.h"
-#include "cpu.h"
 #include "hw/cpu/a9mpcore.h"
 #include "hw/irq.h"
 #include "system/blockdev.h"
diff --git a/hw/arm/highbank.c b/hw/arm/highbank.c
index 3ae26ebebdc..5b2719555af 100644
--- a/hw/arm/highbank.c
+++ b/hw/arm/highbank.c
@@ -35,7 +35,6 @@
 #include "hw/cpu/a15mpcore.h"
 #include "qemu/log.h"
 #include "qom/object.h"
-#include "cpu.h"
 #include "target/arm/cpu-qom.h"
 
 #define SMP_BOOT_ADDR           0x100
diff --git a/hw/arm/mps3r.c b/hw/arm/mps3r.c
index 48c73acc62e..889d291401e 100644
--- a/hw/arm/mps3r.c
+++ b/hw/arm/mps3r.c
@@ -29,7 +29,6 @@
 #include "qapi/error.h"
 #include "qobject/qlist.h"
 #include "system/address-spaces.h"
-#include "cpu.h"
 #include "system/system.h"
 #include "hw/boards.h"
 #include "hw/or-irq.h"
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
index ab679723533..37b39c9f84f 100644
--- a/hw/arm/smmuv3.c
+++ b/hw/arm/smmuv3.c
@@ -24,7 +24,6 @@
 #include "hw/qdev-properties.h"
 #include "hw/qdev-core.h"
 #include "hw/pci/pci.h"
-#include "cpu.h"
 #include "exec/target_page.h"
 #include "trace.h"
 #include "qemu/log.h"
-- 
2.47.1



^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 11/19] target/arm: Restrict inclusion of 'multiprocessing.h'
  2025-05-13 17:39 [PATCH 00/19] target/arm: More header rework around arm_feature() & multiprocessing.h Philippe Mathieu-Daudé
                   ` (9 preceding siblings ...)
  2025-05-13 17:39 ` [PATCH 10/19] hw/arm: Remove unnecessary 'cpu.h' header Philippe Mathieu-Daudé
@ 2025-05-13 17:39 ` Philippe Mathieu-Daudé
  2025-05-13 17:39 ` [PATCH 12/19] target/arm: Move some definitions from 'cpu.h' to 'multiprocessing.h' Philippe Mathieu-Daudé
                   ` (9 subsequent siblings)
  20 siblings, 0 replies; 37+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-05-13 17:39 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, qemu-arm, Richard Henderson, Pierrick Bouvier,
	Philippe Mathieu-Daudé

Only cpu.c requires "multiprocessing.h" definitions so far.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
 target/arm/cpu.h | 1 -
 target/arm/cpu.c | 1 +
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/target/arm/cpu.h b/target/arm/cpu.h
index 6ed6409cb7a..33ac0c9f818 100644
--- a/target/arm/cpu.h
+++ b/target/arm/cpu.h
@@ -30,7 +30,6 @@
 #include "exec/gdbstub.h"
 #include "exec/page-protection.h"
 #include "qapi/qapi-types-common.h"
-#include "target/arm/multiprocessing.h"
 #include "target/arm/gtimer.h"
 
 #define EXCP_UDEF            1   /* undefined instruction */
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
index a604e4ccac8..8c9d161f2ef 100644
--- a/target/arm/cpu.c
+++ b/target/arm/cpu.c
@@ -52,6 +52,7 @@
 #include "cpregs.h"
 #include "target/arm/cpu-qom.h"
 #include "target/arm/gtimer.h"
+#include "target/arm/multiprocessing.h"
 
 static void arm_cpu_set_pc(CPUState *cs, vaddr value)
 {
-- 
2.47.1



^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 12/19] target/arm: Move some definitions from 'cpu.h' to 'multiprocessing.h'
  2025-05-13 17:39 [PATCH 00/19] target/arm: More header rework around arm_feature() & multiprocessing.h Philippe Mathieu-Daudé
                   ` (10 preceding siblings ...)
  2025-05-13 17:39 ` [PATCH 11/19] target/arm: Restrict inclusion of 'multiprocessing.h' Philippe Mathieu-Daudé
@ 2025-05-13 17:39 ` Philippe Mathieu-Daudé
  2025-05-13 17:39 ` [PATCH 13/19] hw/arm: Include missing 'target/arm/gtimer.h' header Philippe Mathieu-Daudé
                   ` (8 subsequent siblings)
  20 siblings, 0 replies; 37+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-05-13 17:39 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, qemu-arm, Richard Henderson, Pierrick Bouvier,
	Philippe Mathieu-Daudé

arm_build_mp_affinity() and affinity mask definitionss are
related to multiprocessing. Move them to "multiprocessing.h",
including this header when necessary.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
 target/arm/cpu.h             | 17 -----------------
 target/arm/multiprocessing.h | 18 ++++++++++++++++++
 hw/arm/aspeed_ast2600.c      |  1 +
 hw/arm/aspeed_ast27x0.c      |  1 +
 hw/arm/exynos4210.c          |  1 +
 hw/arm/npcm8xx.c             |  1 +
 hw/arm/sbsa-ref.c            |  1 +
 hw/vmapple/vmapple.c         |  1 +
 target/arm/kvm.c             |  1 +
 9 files changed, 25 insertions(+), 17 deletions(-)

diff --git a/target/arm/cpu.h b/target/arm/cpu.h
index 33ac0c9f818..b70c7a3ecd2 100644
--- a/target/arm/cpu.h
+++ b/target/arm/cpu.h
@@ -1155,23 +1155,6 @@ void gt_rme_post_el_change(ARMCPU *cpu, void *opaque);
 
 void arm_cpu_post_init(Object *obj);
 
-#define ARM_AFF0_SHIFT 0
-#define ARM_AFF0_MASK  (0xFFULL << ARM_AFF0_SHIFT)
-#define ARM_AFF1_SHIFT 8
-#define ARM_AFF1_MASK  (0xFFULL << ARM_AFF1_SHIFT)
-#define ARM_AFF2_SHIFT 16
-#define ARM_AFF2_MASK  (0xFFULL << ARM_AFF2_SHIFT)
-#define ARM_AFF3_SHIFT 32
-#define ARM_AFF3_MASK  (0xFFULL << ARM_AFF3_SHIFT)
-#define ARM_DEFAULT_CPUS_PER_CLUSTER 8
-
-#define ARM32_AFFINITY_MASK (ARM_AFF0_MASK | ARM_AFF1_MASK | ARM_AFF2_MASK)
-#define ARM64_AFFINITY_MASK \
-    (ARM_AFF0_MASK | ARM_AFF1_MASK | ARM_AFF2_MASK | ARM_AFF3_MASK)
-#define ARM64_AFFINITY_INVALID (~ARM64_AFFINITY_MASK)
-
-uint64_t arm_build_mp_affinity(int idx, uint8_t clustersz);
-
 #ifndef CONFIG_USER_ONLY
 extern const VMStateDescription vmstate_arm_cpu;
 
diff --git a/target/arm/multiprocessing.h b/target/arm/multiprocessing.h
index 81715d345c2..8eec79b11d8 100644
--- a/target/arm/multiprocessing.h
+++ b/target/arm/multiprocessing.h
@@ -11,6 +11,24 @@
 
 #include "target/arm/cpu-qom.h"
 
+#define ARM_AFF0_SHIFT 0
+#define ARM_AFF0_MASK  (0xFFULL << ARM_AFF0_SHIFT)
+#define ARM_AFF1_SHIFT 8
+#define ARM_AFF1_MASK  (0xFFULL << ARM_AFF1_SHIFT)
+#define ARM_AFF2_SHIFT 16
+#define ARM_AFF2_MASK  (0xFFULL << ARM_AFF2_SHIFT)
+#define ARM_AFF3_SHIFT 32
+#define ARM_AFF3_MASK  (0xFFULL << ARM_AFF3_SHIFT)
+#define ARM_DEFAULT_CPUS_PER_CLUSTER 8
+
+#define ARM32_AFFINITY_MASK \
+            (ARM_AFF0_MASK|ARM_AFF1_MASK|ARM_AFF2_MASK)
+#define ARM64_AFFINITY_MASK \
+            (ARM_AFF0_MASK|ARM_AFF1_MASK|ARM_AFF2_MASK|ARM_AFF3_MASK)
+#define ARM64_AFFINITY_INVALID (~ARM64_AFFINITY_MASK)
+
+uint64_t arm_build_mp_affinity(int idx, uint8_t clustersz);
+
 uint64_t arm_cpu_mp_affinity(ARMCPU *cpu);
 
 #endif
diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c
index d12707f0abe..62a9200dac6 100644
--- a/hw/arm/aspeed_ast2600.c
+++ b/hw/arm/aspeed_ast2600.c
@@ -17,6 +17,7 @@
 #include "net/net.h"
 #include "system/system.h"
 #include "target/arm/cpu-qom.h"
+#include "target/arm/multiprocessing.h"
 
 #define ASPEED_SOC_IOMEM_SIZE       0x00200000
 #define ASPEED_SOC_DPMCU_SIZE       0x00040000
diff --git a/hw/arm/aspeed_ast27x0.c b/hw/arm/aspeed_ast27x0.c
index 1974a257660..a38c2a19751 100644
--- a/hw/arm/aspeed_ast27x0.c
+++ b/hw/arm/aspeed_ast27x0.c
@@ -22,6 +22,7 @@
 #include "hw/intc/arm_gicv3.h"
 #include "qobject/qlist.h"
 #include "qemu/log.h"
+#include "target/arm/multiprocessing.h"
 
 #define AST2700_SOC_IO_SIZE          0x01000000
 #define AST2700_SOC_IOMEM_SIZE       0x01000000
diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c
index 56267ec2bd2..e83a88d3369 100644
--- a/hw/arm/exynos4210.c
+++ b/hw/arm/exynos4210.c
@@ -36,6 +36,7 @@
 #include "hw/sd/sdhci.h"
 #include "hw/usb/hcd-ehci.h"
 #include "target/arm/cpu-qom.h"
+#include "target/arm/multiprocessing.h"
 
 #define EXYNOS4210_CHIPID_ADDR         0x10000000
 
diff --git a/hw/arm/npcm8xx.c b/hw/arm/npcm8xx.c
index d7ee306de7a..e6c16537eef 100644
--- a/hw/arm/npcm8xx.c
+++ b/hw/arm/npcm8xx.c
@@ -29,6 +29,7 @@
 #include "qapi/error.h"
 #include "qemu/units.h"
 #include "system/system.h"
+#include "target/arm/multiprocessing.h"
 
 /*
  * This covers the whole MMIO space. We'll use this to catch any MMIO accesses
diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c
index deae5cf9861..25ffb029ff4 100644
--- a/hw/arm/sbsa-ref.c
+++ b/hw/arm/sbsa-ref.c
@@ -52,6 +52,7 @@
 #include "qom/object.h"
 #include "target/arm/cpu-qom.h"
 #include "target/arm/gtimer.h"
+#include "target/arm/multiprocessing.h"
 
 #define RAMLIMIT_GB 8192
 #define RAMLIMIT_BYTES (RAMLIMIT_GB * GiB)
diff --git a/hw/vmapple/vmapple.c b/hw/vmapple/vmapple.c
index 16e6110b68f..47f23b6e2c0 100644
--- a/hw/vmapple/vmapple.c
+++ b/hw/vmapple/vmapple.c
@@ -51,6 +51,7 @@
 #include "system/reset.h"
 #include "system/runstate.h"
 #include "system/system.h"
+#include "target/arm/multiprocessing.h"
 
 struct VMAppleMachineState {
     MachineState parent;
diff --git a/target/arm/kvm.c b/target/arm/kvm.c
index a08a269ad61..5969249b579 100644
--- a/target/arm/kvm.c
+++ b/target/arm/kvm.c
@@ -39,6 +39,7 @@
 #include "hw/acpi/acpi.h"
 #include "hw/acpi/ghes.h"
 #include "target/arm/gtimer.h"
+#include "target/arm/multiprocessing.h"
 #include "migration/blocker.h"
 
 const KVMCapabilityInfo kvm_arch_required_capabilities[] = {
-- 
2.47.1



^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 13/19] hw/arm: Include missing 'target/arm/gtimer.h' header
  2025-05-13 17:39 [PATCH 00/19] target/arm: More header rework around arm_feature() & multiprocessing.h Philippe Mathieu-Daudé
                   ` (11 preceding siblings ...)
  2025-05-13 17:39 ` [PATCH 12/19] target/arm: Move some definitions from 'cpu.h' to 'multiprocessing.h' Philippe Mathieu-Daudé
@ 2025-05-13 17:39 ` Philippe Mathieu-Daudé
  2025-05-13 17:39 ` [PATCH 14/19] target/arm: Extract PSCI definitions to 'psci.h' Philippe Mathieu-Daudé
                   ` (7 subsequent siblings)
  20 siblings, 0 replies; 37+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-05-13 17:39 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, qemu-arm, Richard Henderson, Pierrick Bouvier,
	Philippe Mathieu-Daudé

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
 hw/arm/aspeed_ast27x0.c    | 1 +
 hw/arm/bcm2838.c           | 1 +
 hw/arm/exynos4210.c        | 1 +
 hw/arm/fsl-imx8mp.c        | 1 +
 hw/arm/mps3r.c             | 1 +
 hw/arm/npcm8xx.c           | 1 +
 hw/vmapple/vmapple.c       | 1 +
 target/arm/tcg/op_helper.c | 1 +
 8 files changed, 8 insertions(+)

diff --git a/hw/arm/aspeed_ast27x0.c b/hw/arm/aspeed_ast27x0.c
index a38c2a19751..ad017237f3f 100644
--- a/hw/arm/aspeed_ast27x0.c
+++ b/hw/arm/aspeed_ast27x0.c
@@ -22,6 +22,7 @@
 #include "hw/intc/arm_gicv3.h"
 #include "qobject/qlist.h"
 #include "qemu/log.h"
+#include "target/arm/gtimer.h"
 #include "target/arm/multiprocessing.h"
 
 #define AST2700_SOC_IO_SIZE          0x01000000
diff --git a/hw/arm/bcm2838.c b/hw/arm/bcm2838.c
index 22aa754613c..20709bf19e8 100644
--- a/hw/arm/bcm2838.c
+++ b/hw/arm/bcm2838.c
@@ -12,6 +12,7 @@
 #include "hw/arm/raspi_platform.h"
 #include "hw/sysbus.h"
 #include "hw/arm/bcm2838.h"
+#include "target/arm/gtimer.h"
 #include "trace.h"
 
 #define GIC400_MAINTENANCE_IRQ      9
diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c
index e83a88d3369..24b3c0b5d29 100644
--- a/hw/arm/exynos4210.c
+++ b/hw/arm/exynos4210.c
@@ -36,6 +36,7 @@
 #include "hw/sd/sdhci.h"
 #include "hw/usb/hcd-ehci.h"
 #include "target/arm/cpu-qom.h"
+#include "target/arm/gtimer.h"
 #include "target/arm/multiprocessing.h"
 
 #define EXYNOS4210_CHIPID_ADDR         0x10000000
diff --git a/hw/arm/fsl-imx8mp.c b/hw/arm/fsl-imx8mp.c
index 23e662c16ca..3528adb90f1 100644
--- a/hw/arm/fsl-imx8mp.c
+++ b/hw/arm/fsl-imx8mp.c
@@ -17,6 +17,7 @@
 #include "hw/boards.h"
 #include "system/system.h"
 #include "target/arm/cpu-qom.h"
+#include "target/arm/gtimer.h"
 #include "qapi/error.h"
 #include "qobject/qlist.h"
 
diff --git a/hw/arm/mps3r.c b/hw/arm/mps3r.c
index 889d291401e..8c743be3cb5 100644
--- a/hw/arm/mps3r.c
+++ b/hw/arm/mps3r.c
@@ -47,6 +47,7 @@
 #include "hw/ssi/pl022.h"
 #include "hw/timer/cmsdk-apb-dualtimer.h"
 #include "hw/watchdog/cmsdk-apb-watchdog.h"
+#include "target/arm/gtimer.h"
 
 /* Define the layout of RAM and ROM in a board */
 typedef struct RAMInfo {
diff --git a/hw/arm/npcm8xx.c b/hw/arm/npcm8xx.c
index e6c16537eef..7802768c384 100644
--- a/hw/arm/npcm8xx.c
+++ b/hw/arm/npcm8xx.c
@@ -29,6 +29,7 @@
 #include "qapi/error.h"
 #include "qemu/units.h"
 #include "system/system.h"
+#include "target/arm/gtimer.h"
 #include "target/arm/multiprocessing.h"
 
 /*
diff --git a/hw/vmapple/vmapple.c b/hw/vmapple/vmapple.c
index 47f23b6e2c0..2dc5e15e791 100644
--- a/hw/vmapple/vmapple.c
+++ b/hw/vmapple/vmapple.c
@@ -51,6 +51,7 @@
 #include "system/reset.h"
 #include "system/runstate.h"
 #include "system/system.h"
+#include "target/arm/gtimer.h"
 #include "target/arm/multiprocessing.h"
 
 struct VMAppleMachineState {
diff --git a/target/arm/tcg/op_helper.c b/target/arm/tcg/op_helper.c
index 575e566280b..073a8319fa5 100644
--- a/target/arm/tcg/op_helper.c
+++ b/target/arm/tcg/op_helper.c
@@ -25,6 +25,7 @@
 #include "cpu-features.h"
 #include "accel/tcg/cpu-ldst.h"
 #include "accel/tcg/probe.h"
+#include "target/arm/gtimer.h"
 #include "cpregs.h"
 
 #define SIGNBIT (uint32_t)0x80000000
-- 
2.47.1



^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 14/19] target/arm: Extract PSCI definitions to 'psci.h'
  2025-05-13 17:39 [PATCH 00/19] target/arm: More header rework around arm_feature() & multiprocessing.h Philippe Mathieu-Daudé
                   ` (12 preceding siblings ...)
  2025-05-13 17:39 ` [PATCH 13/19] hw/arm: Include missing 'target/arm/gtimer.h' header Philippe Mathieu-Daudé
@ 2025-05-13 17:39 ` Philippe Mathieu-Daudé
  2025-05-13 17:39 ` [PATCH 15/19] target/arm: Extract feature definitions to 'cpu_has_feature.h' header Philippe Mathieu-Daudé
                   ` (6 subsequent siblings)
  20 siblings, 0 replies; 37+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-05-13 17:39 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, qemu-arm, Richard Henderson, Pierrick Bouvier,
	Philippe Mathieu-Daudé

Extract PSCI definitions (which are not target specific)
to the new "target/arm/psci.h", so code from hw/arm/ can
use them without having to include the target specific
"cpu.h" header.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
 include/hw/arm/boot.h      |  3 ++-
 target/arm/cpu.h           |  7 ++-----
 target/arm/psci.h          | 18 ++++++++++++++++++
 hw/arm/bananapi_m2u.c      |  1 +
 hw/arm/boot.c              |  1 +
 hw/arm/highbank.c          |  1 +
 hw/arm/imx8mp-evk.c        |  1 +
 hw/arm/mcimx6ul-evk.c      |  1 +
 hw/arm/mcimx7d-sabre.c     |  1 +
 hw/arm/orangepi.c          |  1 +
 hw/arm/sbsa-ref.c          |  1 +
 hw/arm/virt-acpi-build.c   |  1 +
 hw/arm/virt.c              |  1 +
 hw/arm/xlnx-versal-virt.c  |  1 +
 hw/arm/xlnx-zcu102.c       |  1 +
 hw/vmapple/vmapple.c       |  1 +
 target/arm/helper.c        |  1 +
 target/arm/hvf/hvf.c       |  1 +
 target/arm/tcg/op_helper.c |  1 +
 target/arm/tcg/psci.c      |  1 +
 20 files changed, 39 insertions(+), 6 deletions(-)
 create mode 100644 target/arm/psci.h

diff --git a/include/hw/arm/boot.h b/include/hw/arm/boot.h
index b12bf61ca81..648fdb88862 100644
--- a/include/hw/arm/boot.h
+++ b/include/hw/arm/boot.h
@@ -12,6 +12,7 @@
 #define HW_ARM_BOOT_H
 
 #include "target/arm/cpu-qom.h"
+//#include "target/arm/psci.h"
 #include "qemu/notify.h"
 
 typedef enum {
@@ -100,7 +101,7 @@ struct arm_boot_info {
      * as the conduit specifies calls should go to (eg guest firmware booted
      * to EL3) then PSCI will not be enabled.
      */
-    int psci_conduit;
+    int psci_conduit;//
     /* Used internally by arm_boot.c */
     int is_linux;
     hwaddr initrd_start;
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
index b70c7a3ecd2..116745975fa 100644
--- a/target/arm/cpu.h
+++ b/target/arm/cpu.h
@@ -3098,11 +3098,8 @@ static inline bool bswap_code(bool sctlr_b)
 #endif
 }
 
-enum {
-    QEMU_PSCI_CONDUIT_DISABLED = 0,
-    QEMU_PSCI_CONDUIT_SMC = 1,
-    QEMU_PSCI_CONDUIT_HVC = 2,
-};
+void cpu_get_tb_cpu_state(CPUARMState *env, vaddr *pc,
+                          uint64_t *cs_base, uint32_t *flags);
 
 #ifndef CONFIG_USER_ONLY
 /* Return the address space index to use for a memory access */
diff --git a/target/arm/psci.h b/target/arm/psci.h
new file mode 100644
index 00000000000..8b868dfbb91
--- /dev/null
+++ b/target/arm/psci.h
@@ -0,0 +1,18 @@
+/*
+ * ARM Power State Coordination Interface (PSCI) definitions
+ *
+ *  Copyright (c) 2003 Fabrice Bellard
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+
+#ifndef TARGET_ARM_PSCI_H
+#define TARGET_ARM_PSCI_H
+
+enum {
+    QEMU_PSCI_CONDUIT_DISABLED = 0,
+    QEMU_PSCI_CONDUIT_SMC = 1,
+    QEMU_PSCI_CONDUIT_HVC = 2,
+};
+
+#endif
diff --git a/hw/arm/bananapi_m2u.c b/hw/arm/bananapi_m2u.c
index b750a575f72..61e01a38099 100644
--- a/hw/arm/bananapi_m2u.c
+++ b/hw/arm/bananapi_m2u.c
@@ -27,6 +27,7 @@
 #include "hw/qdev-properties.h"
 #include "hw/arm/allwinner-r40.h"
 #include "hw/arm/boot.h"
+#include "target/arm/psci.h"
 
 static struct arm_boot_info bpim2u_binfo;
 
diff --git a/hw/arm/boot.c b/hw/arm/boot.c
index 79afb51b8a5..b81a850819b 100644
--- a/hw/arm/boot.c
+++ b/hw/arm/boot.c
@@ -29,6 +29,7 @@
 #include "qemu/config-file.h"
 #include "qemu/option.h"
 #include "qemu/units.h"
+#include "target/arm/psci.h"
 
 /* Kernel boot protocol is specified in the kernel docs
  * Documentation/arm/Booting and Documentation/arm64/booting.txt
diff --git a/hw/arm/highbank.c b/hw/arm/highbank.c
index 5b2719555af..0ce39877822 100644
--- a/hw/arm/highbank.c
+++ b/hw/arm/highbank.c
@@ -36,6 +36,7 @@
 #include "qemu/log.h"
 #include "qom/object.h"
 #include "target/arm/cpu-qom.h"
+#include "target/arm/psci.h"
 
 #define SMP_BOOT_ADDR           0x100
 #define SMP_BOOT_REG            0x40
diff --git a/hw/arm/imx8mp-evk.c b/hw/arm/imx8mp-evk.c
index b3082fa60d8..81fe0361ea7 100644
--- a/hw/arm/imx8mp-evk.c
+++ b/hw/arm/imx8mp-evk.c
@@ -15,6 +15,7 @@
 #include "system/qtest.h"
 #include "qemu/error-report.h"
 #include "qapi/error.h"
+#include "target/arm/psci.h"
 #include <libfdt.h>
 
 static void imx8mp_evk_modify_dtb(const struct arm_boot_info *info, void *fdt)
diff --git a/hw/arm/mcimx6ul-evk.c b/hw/arm/mcimx6ul-evk.c
index 86982cb0772..be5e50abf17 100644
--- a/hw/arm/mcimx6ul-evk.c
+++ b/hw/arm/mcimx6ul-evk.c
@@ -18,6 +18,7 @@
 #include "hw/qdev-properties.h"
 #include "qemu/error-report.h"
 #include "system/qtest.h"
+#include "target/arm/psci.h"
 
 static void mcimx6ul_evk_init(MachineState *machine)
 {
diff --git a/hw/arm/mcimx7d-sabre.c b/hw/arm/mcimx7d-sabre.c
index 33119610113..e0f25b92594 100644
--- a/hw/arm/mcimx7d-sabre.c
+++ b/hw/arm/mcimx7d-sabre.c
@@ -20,6 +20,7 @@
 #include "hw/qdev-properties.h"
 #include "qemu/error-report.h"
 #include "system/qtest.h"
+#include "target/arm/psci.h"
 
 static void mcimx7d_sabre_init(MachineState *machine)
 {
diff --git a/hw/arm/orangepi.c b/hw/arm/orangepi.c
index e0956880d11..99037a09a36 100644
--- a/hw/arm/orangepi.c
+++ b/hw/arm/orangepi.c
@@ -26,6 +26,7 @@
 #include "hw/qdev-properties.h"
 #include "hw/arm/allwinner-h3.h"
 #include "hw/arm/boot.h"
+#include "target/arm/psci.h"
 
 static struct arm_boot_info orangepi_binfo;
 
diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c
index 25ffb029ff4..d5ce15b688f 100644
--- a/hw/arm/sbsa-ref.c
+++ b/hw/arm/sbsa-ref.c
@@ -53,6 +53,7 @@
 #include "target/arm/cpu-qom.h"
 #include "target/arm/gtimer.h"
 #include "target/arm/multiprocessing.h"
+#include "target/arm/psci.h"
 
 #define RAMLIMIT_GB 8192
 #define RAMLIMIT_BYTES (RAMLIMIT_GB * GiB)
diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
index 7e8e0f0298d..20dc93fbc54 100644
--- a/hw/arm/virt-acpi-build.c
+++ b/hw/arm/virt-acpi-build.c
@@ -59,6 +59,7 @@
 #include "hw/acpi/viot.h"
 #include "hw/virtio/virtio-acpi.h"
 #include "target/arm/multiprocessing.h"
+#include "target/arm/psci.h"
 
 #define ARM_SPI_BASE 32
 
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 9a6cd085a37..d110cb07943 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -79,6 +79,7 @@
 #include "target/arm/internals.h"
 #include "target/arm/multiprocessing.h"
 #include "target/arm/gtimer.h"
+#include "target/arm/psci.h"
 #include "hw/mem/pc-dimm.h"
 #include "hw/mem/nvdimm.h"
 #include "hw/acpi/generic_event_device.h"
diff --git a/hw/arm/xlnx-versal-virt.c b/hw/arm/xlnx-versal-virt.c
index adadbb72902..7e1b93b782d 100644
--- a/hw/arm/xlnx-versal-virt.c
+++ b/hw/arm/xlnx-versal-virt.c
@@ -21,6 +21,7 @@
 #include "hw/arm/xlnx-versal.h"
 #include "hw/arm/boot.h"
 #include "target/arm/multiprocessing.h"
+#include "target/arm/psci.h"
 #include "qom/object.h"
 
 #define TYPE_XLNX_VERSAL_VIRT_MACHINE MACHINE_TYPE_NAME("xlnx-versal-virt")
diff --git a/hw/arm/xlnx-zcu102.c b/hw/arm/xlnx-zcu102.c
index 14b6641a713..c46bf11ce24 100644
--- a/hw/arm/xlnx-zcu102.c
+++ b/hw/arm/xlnx-zcu102.c
@@ -26,6 +26,7 @@
 #include "qom/object.h"
 #include "net/can_emu.h"
 #include "audio/audio.h"
+#include "target/arm/psci.h"
 
 struct XlnxZCU102 {
     MachineState parent_obj;
diff --git a/hw/vmapple/vmapple.c b/hw/vmapple/vmapple.c
index 2dc5e15e791..b61f5ea51a4 100644
--- a/hw/vmapple/vmapple.c
+++ b/hw/vmapple/vmapple.c
@@ -53,6 +53,7 @@
 #include "system/system.h"
 #include "target/arm/gtimer.h"
 #include "target/arm/multiprocessing.h"
+#include "target/arm/psci.h"
 
 struct VMAppleMachineState {
     MachineState parent;
diff --git a/target/arm/helper.c b/target/arm/helper.c
index 76312102879..7859729c39f 100644
--- a/target/arm/helper.c
+++ b/target/arm/helper.c
@@ -34,6 +34,7 @@
 #endif
 #include "cpregs.h"
 #include "target/arm/gtimer.h"
+#include "target/arm/psci.h"
 
 #define HELPER_H "tcg/helper.h"
 #include "exec/helper-proto.h.inc"
diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
index 42258cc2d88..8fbd4c4be59 100644
--- a/target/arm/hvf/hvf.c
+++ b/target/arm/hvf/hvf.c
@@ -33,6 +33,7 @@
 #include "target/arm/internals.h"
 #include "target/arm/multiprocessing.h"
 #include "target/arm/gtimer.h"
+#include "target/arm/psci.h"
 #include "trace.h"
 #include "migration/vmstate.h"
 
diff --git a/target/arm/tcg/op_helper.c b/target/arm/tcg/op_helper.c
index 073a8319fa5..e0f9c91450a 100644
--- a/target/arm/tcg/op_helper.c
+++ b/target/arm/tcg/op_helper.c
@@ -26,6 +26,7 @@
 #include "accel/tcg/cpu-ldst.h"
 #include "accel/tcg/probe.h"
 #include "target/arm/gtimer.h"
+#include "target/arm/psci.h"
 #include "cpregs.h"
 
 #define SIGNBIT (uint32_t)0x80000000
diff --git a/target/arm/tcg/psci.c b/target/arm/tcg/psci.c
index cabed43e8a8..0313cdd6ba2 100644
--- a/target/arm/tcg/psci.c
+++ b/target/arm/tcg/psci.c
@@ -25,6 +25,7 @@
 #include "internals.h"
 #include "arm-powerctl.h"
 #include "target/arm/multiprocessing.h"
+#include "target/arm/psci.h"
 
 bool arm_is_psci_call(ARMCPU *cpu, int excp_type)
 {
-- 
2.47.1



^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 15/19] target/arm: Extract feature definitions to 'cpu_has_feature.h' header
  2025-05-13 17:39 [PATCH 00/19] target/arm: More header rework around arm_feature() & multiprocessing.h Philippe Mathieu-Daudé
                   ` (13 preceding siblings ...)
  2025-05-13 17:39 ` [PATCH 14/19] target/arm: Extract PSCI definitions to 'psci.h' Philippe Mathieu-Daudé
@ 2025-05-13 17:39 ` Philippe Mathieu-Daudé
  2025-05-13 17:39 ` [PATCH 16/19] target/arm: Add arm_cpu_has_feature() helper Philippe Mathieu-Daudé
                   ` (5 subsequent siblings)
  20 siblings, 0 replies; 37+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-05-13 17:39 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, qemu-arm, Richard Henderson, Pierrick Bouvier,
	Philippe Mathieu-Daudé

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
 target/arm/cpu.h             | 54 +-----------------------------
 target/arm/cpu_has_feature.h | 65 ++++++++++++++++++++++++++++++++++++
 2 files changed, 66 insertions(+), 53 deletions(-)
 create mode 100644 target/arm/cpu_has_feature.h

diff --git a/target/arm/cpu.h b/target/arm/cpu.h
index 116745975fa..cf3ff21965c 100644
--- a/target/arm/cpu.h
+++ b/target/arm/cpu.h
@@ -30,6 +30,7 @@
 #include "exec/gdbstub.h"
 #include "exec/page-protection.h"
 #include "qapi/qapi-types-common.h"
+#include "target/arm/cpu_has_feature.h"
 #include "target/arm/gtimer.h"
 
 #define EXCP_UDEF            1   /* undefined instruction */
@@ -2376,59 +2377,6 @@ FIELD(MFAR, NS, 63, 1)
 
 QEMU_BUILD_BUG_ON(ARRAY_SIZE(((ARMCPU *)0)->ccsidr) <= R_V7M_CSSELR_INDEX_MASK);
 
-/* If adding a feature bit which corresponds to a Linux ELF
- * HWCAP bit, remember to update the feature-bit-to-hwcap
- * mapping in linux-user/elfload.c:get_elf_hwcap().
- */
-enum arm_features {
-    ARM_FEATURE_AUXCR,  /* ARM1026 Auxiliary control register.  */
-    ARM_FEATURE_XSCALE, /* Intel XScale extensions.  */
-    ARM_FEATURE_IWMMXT, /* Intel iwMMXt extension.  */
-    ARM_FEATURE_V6,
-    ARM_FEATURE_V6K,
-    ARM_FEATURE_V7,
-    ARM_FEATURE_THUMB2,
-    ARM_FEATURE_PMSA,   /* no MMU; may have Memory Protection Unit */
-    ARM_FEATURE_NEON,
-    ARM_FEATURE_M, /* Microcontroller profile.  */
-    ARM_FEATURE_OMAPCP, /* OMAP specific CP15 ops handling.  */
-    ARM_FEATURE_THUMB2EE,
-    ARM_FEATURE_V7MP,    /* v7 Multiprocessing Extensions */
-    ARM_FEATURE_V7VE, /* v7 Virtualization Extensions (non-EL2 parts) */
-    ARM_FEATURE_V4T,
-    ARM_FEATURE_V5,
-    ARM_FEATURE_STRONGARM,
-    ARM_FEATURE_VAPA, /* cp15 VA to PA lookups */
-    ARM_FEATURE_GENERIC_TIMER,
-    ARM_FEATURE_MVFR, /* Media and VFP Feature Registers 0 and 1 */
-    ARM_FEATURE_DUMMY_C15_REGS, /* RAZ/WI all of cp15 crn=15 */
-    ARM_FEATURE_CACHE_TEST_CLEAN, /* 926/1026 style test-and-clean ops */
-    ARM_FEATURE_CACHE_DIRTY_REG, /* 1136/1176 cache dirty status register */
-    ARM_FEATURE_CACHE_BLOCK_OPS, /* v6 optional cache block operations */
-    ARM_FEATURE_MPIDR, /* has cp15 MPIDR */
-    ARM_FEATURE_LPAE, /* has Large Physical Address Extension */
-    ARM_FEATURE_V8,
-    ARM_FEATURE_AARCH64, /* supports 64 bit mode */
-    ARM_FEATURE_CBAR, /* has cp15 CBAR */
-    ARM_FEATURE_CBAR_RO, /* has cp15 CBAR and it is read-only */
-    ARM_FEATURE_EL2, /* has EL2 Virtualization support */
-    ARM_FEATURE_EL3, /* has EL3 Secure monitor support */
-    ARM_FEATURE_THUMB_DSP, /* DSP insns supported in the Thumb encodings */
-    ARM_FEATURE_PMU, /* has PMU support */
-    ARM_FEATURE_VBAR, /* has cp15 VBAR */
-    ARM_FEATURE_M_SECURITY, /* M profile Security Extension */
-    ARM_FEATURE_M_MAIN, /* M profile Main Extension */
-    ARM_FEATURE_V8_1M, /* M profile extras only in v8.1M and later */
-    /*
-     * ARM_FEATURE_BACKCOMPAT_CNTFRQ makes the CPU default cntfrq be 62.5MHz
-     * if the board doesn't set a value, instead of 1GHz. It is for backwards
-     * compatibility and used only with CPU definitions that were already
-     * in QEMU before we changed the default. It should not be set on any
-     * CPU types added in future.
-     */
-    ARM_FEATURE_BACKCOMPAT_CNTFRQ, /* 62.5MHz timer default */
-};
-
 static inline int arm_feature(CPUARMState *env, int feature)
 {
     return (env->features & (1ULL << feature)) != 0;
diff --git a/target/arm/cpu_has_feature.h b/target/arm/cpu_has_feature.h
new file mode 100644
index 00000000000..2adfccd9208
--- /dev/null
+++ b/target/arm/cpu_has_feature.h
@@ -0,0 +1,65 @@
+/*
+ * Helper to check ARM CPU has features
+ *
+ *  Copyright (c) 2003 Fabrice Bellard
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+#ifndef TARGET_ARM_CPU_HAS_FEATURE_H
+#define TARGET_ARM_CPU_HAS_FEATURE_H
+
+/*
+ * If adding a feature bit which corresponds to a Linux ELF
+ * HWCAP bit, remember to update the feature-bit-to-hwcap
+ * mapping in linux-user/elfload.c:get_elf_hwcap().
+ */
+typedef enum arm_features {
+    ARM_FEATURE_AUXCR,  /* ARM1026 Auxiliary control register.  */
+    ARM_FEATURE_XSCALE, /* Intel XScale extensions.  */
+    ARM_FEATURE_IWMMXT, /* Intel iwMMXt extension.  */
+    ARM_FEATURE_V6,
+    ARM_FEATURE_V6K,
+    ARM_FEATURE_V7,
+    ARM_FEATURE_THUMB2,
+    ARM_FEATURE_PMSA,   /* no MMU; may have Memory Protection Unit */
+    ARM_FEATURE_NEON,
+    ARM_FEATURE_M, /* Microcontroller profile.  */
+    ARM_FEATURE_OMAPCP, /* OMAP specific CP15 ops handling.  */
+    ARM_FEATURE_THUMB2EE,
+    ARM_FEATURE_V7MP,    /* v7 Multiprocessing Extensions */
+    ARM_FEATURE_V7VE, /* v7 Virtualization Extensions (non-EL2 parts) */
+    ARM_FEATURE_V4T,
+    ARM_FEATURE_V5,
+    ARM_FEATURE_STRONGARM,
+    ARM_FEATURE_VAPA, /* cp15 VA to PA lookups */
+    ARM_FEATURE_GENERIC_TIMER,
+    ARM_FEATURE_MVFR, /* Media and VFP Feature Registers 0 and 1 */
+    ARM_FEATURE_DUMMY_C15_REGS, /* RAZ/WI all of cp15 crn=15 */
+    ARM_FEATURE_CACHE_TEST_CLEAN, /* 926/1026 style test-and-clean ops */
+    ARM_FEATURE_CACHE_DIRTY_REG, /* 1136/1176 cache dirty status register */
+    ARM_FEATURE_CACHE_BLOCK_OPS, /* v6 optional cache block operations */
+    ARM_FEATURE_MPIDR, /* has cp15 MPIDR */
+    ARM_FEATURE_LPAE, /* has Large Physical Address Extension */
+    ARM_FEATURE_V8,
+    ARM_FEATURE_AARCH64, /* supports 64 bit mode */
+    ARM_FEATURE_CBAR, /* has cp15 CBAR */
+    ARM_FEATURE_CBAR_RO, /* has cp15 CBAR and it is read-only */
+    ARM_FEATURE_EL2, /* has EL2 Virtualization support */
+    ARM_FEATURE_EL3, /* has EL3 Secure monitor support */
+    ARM_FEATURE_THUMB_DSP, /* DSP insns supported in the Thumb encodings */
+    ARM_FEATURE_PMU, /* has PMU support */
+    ARM_FEATURE_VBAR, /* has cp15 VBAR */
+    ARM_FEATURE_M_SECURITY, /* M profile Security Extension */
+    ARM_FEATURE_M_MAIN, /* M profile Main Extension */
+    ARM_FEATURE_V8_1M, /* M profile extras only in v8.1M and later */
+    /*
+     * ARM_FEATURE_BACKCOMPAT_CNTFRQ makes the CPU default cntfrq be 62.5MHz
+     * if the board doesn't set a value, instead of 1GHz. It is for backwards
+     * compatibility and used only with CPU definitions that were already
+     * in QEMU before we changed the default. It should not be set on any
+     * CPU types added in future.
+     */
+    ARM_FEATURE_BACKCOMPAT_CNTFRQ, /* 62.5MHz timer default */
+} ArmCpuFeature;
+
+#endif
-- 
2.47.1



^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 16/19] target/arm: Add arm_cpu_has_feature() helper
  2025-05-13 17:39 [PATCH 00/19] target/arm: More header rework around arm_feature() & multiprocessing.h Philippe Mathieu-Daudé
                   ` (14 preceding siblings ...)
  2025-05-13 17:39 ` [PATCH 15/19] target/arm: Extract feature definitions to 'cpu_has_feature.h' header Philippe Mathieu-Daudé
@ 2025-05-13 17:39 ` Philippe Mathieu-Daudé
  2025-05-14  8:24   ` Richard Henderson
  2025-05-13 17:39 ` [PATCH 17/19] hw/arm/realview: Replace arm_feature() -> arm_cpu_has_feature() Philippe Mathieu-Daudé
                   ` (4 subsequent siblings)
  20 siblings, 1 reply; 37+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-05-13 17:39 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, qemu-arm, Richard Henderson, Pierrick Bouvier,
	Philippe Mathieu-Daudé

arm_cpu_has_feature() is equivalent of arm_feature(), however
while the latter uses CPUARMState so is target-specific, the
former doesn't and can be called by target-agnostic code in hw/.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
 target/arm/cpu_has_feature.h | 2 ++
 target/arm/cpu.c             | 7 +++++++
 2 files changed, 9 insertions(+)

diff --git a/target/arm/cpu_has_feature.h b/target/arm/cpu_has_feature.h
index 2adfccd9208..352f9d75bed 100644
--- a/target/arm/cpu_has_feature.h
+++ b/target/arm/cpu_has_feature.h
@@ -62,4 +62,6 @@ typedef enum arm_features {
     ARM_FEATURE_BACKCOMPAT_CNTFRQ, /* 62.5MHz timer default */
 } ArmCpuFeature;
 
+bool arm_cpu_has_feature(ARMCPU *cpu, ArmCpuFeature feature);
+
 #endif
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
index 8c9d161f2ef..759636a3b0e 100644
--- a/target/arm/cpu.c
+++ b/target/arm/cpu.c
@@ -54,6 +54,13 @@
 #include "target/arm/gtimer.h"
 #include "target/arm/multiprocessing.h"
 
+bool arm_cpu_has_feature(ARMCPU *cpu, ArmCpuFeature feature)
+{
+    CPUARMState *env = &cpu->env;
+
+    return arm_feature(env, feature);
+}
+
 static void arm_cpu_set_pc(CPUState *cs, vaddr value)
 {
     ARMCPU *cpu = ARM_CPU(cs);
-- 
2.47.1



^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 17/19] hw/arm/realview: Replace arm_feature() -> arm_cpu_has_feature()
  2025-05-13 17:39 [PATCH 00/19] target/arm: More header rework around arm_feature() & multiprocessing.h Philippe Mathieu-Daudé
                   ` (15 preceding siblings ...)
  2025-05-13 17:39 ` [PATCH 16/19] target/arm: Add arm_cpu_has_feature() helper Philippe Mathieu-Daudé
@ 2025-05-13 17:39 ` Philippe Mathieu-Daudé
  2025-05-13 17:39 ` [PATCH 18/19] hw/arm/virt-acpi: " Philippe Mathieu-Daudé
                   ` (3 subsequent siblings)
  20 siblings, 0 replies; 37+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-05-13 17:39 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, qemu-arm, Richard Henderson, Pierrick Bouvier,
	Philippe Mathieu-Daudé

By using arm_cpu_has_feature() instead of arm_feature()
we don't need to include "cpu.h" anymore.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
 hw/arm/realview.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/hw/arm/realview.c b/hw/arm/realview.c
index 5c9050490b4..4c0a8b42709 100644
--- a/hw/arm/realview.c
+++ b/hw/arm/realview.c
@@ -9,7 +9,6 @@
 
 #include "qemu/osdep.h"
 #include "qapi/error.h"
-#include "cpu.h"
 #include "hw/sysbus.h"
 #include "hw/arm/boot.h"
 #include "hw/arm/primecell.h"
@@ -31,6 +30,7 @@
 #include "hw/sd/sd.h"
 #include "audio/audio.h"
 #include "target/arm/cpu-qom.h"
+#include "target/arm/cpu_has_feature.h"
 
 #define SMP_BOOT_ADDR 0xe0000000
 #define SMP_BOOTREG_ADDR 0x10000030
@@ -77,7 +77,6 @@ static void realview_init(MachineState *machine,
                           enum realview_board_type board_type)
 {
     ARMCPU *cpu = NULL;
-    CPUARMState *env;
     MemoryRegion *sysmem = get_system_memory();
     MemoryRegion *ram_lo;
     MemoryRegion *ram_hi = g_new(MemoryRegion, 1);
@@ -138,16 +137,15 @@ static void realview_init(MachineState *machine,
         cpu_irq[n] = qdev_get_gpio_in(DEVICE(cpuobj), ARM_CPU_IRQ);
     }
     cpu = ARM_CPU(first_cpu);
-    env = &cpu->env;
-    if (arm_feature(env, ARM_FEATURE_V7)) {
+    if (arm_cpu_has_feature(cpu, ARM_FEATURE_V7)) {
         if (is_mpcore) {
             proc_id = 0x0c000000;
         } else {
             proc_id = 0x0e000000;
         }
-    } else if (arm_feature(env, ARM_FEATURE_V6K)) {
+    } else if (arm_cpu_has_feature(cpu, ARM_FEATURE_V6K)) {
         proc_id = 0x06000000;
-    } else if (arm_feature(env, ARM_FEATURE_V6)) {
+    } else if (arm_cpu_has_feature(cpu, ARM_FEATURE_V6)) {
         proc_id = 0x04000000;
     } else {
         proc_id = 0x02000000;
-- 
2.47.1



^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 18/19] hw/arm/virt-acpi: Replace arm_feature() -> arm_cpu_has_feature()
  2025-05-13 17:39 [PATCH 00/19] target/arm: More header rework around arm_feature() & multiprocessing.h Philippe Mathieu-Daudé
                   ` (16 preceding siblings ...)
  2025-05-13 17:39 ` [PATCH 17/19] hw/arm/realview: Replace arm_feature() -> arm_cpu_has_feature() Philippe Mathieu-Daudé
@ 2025-05-13 17:39 ` Philippe Mathieu-Daudé
  2025-05-13 17:39 ` [PATCH 19/19] target/arm: Always include full path to 'cpu.h' Philippe Mathieu-Daudé
                   ` (2 subsequent siblings)
  20 siblings, 0 replies; 37+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-05-13 17:39 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, qemu-arm, Richard Henderson, Pierrick Bouvier,
	Philippe Mathieu-Daudé

Using arm_cpu_has_feature() instead of arm_feature() remove
a dependency on (the indirectly included) "cpu.h" header.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
 hw/arm/virt-acpi-build.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
index 20dc93fbc54..cc4ec7ad465 100644
--- a/hw/arm/virt-acpi-build.c
+++ b/hw/arm/virt-acpi-build.c
@@ -58,6 +58,7 @@
 #include "hw/acpi/ghes.h"
 #include "hw/acpi/viot.h"
 #include "hw/virtio/virtio-acpi.h"
+#include "target/arm/cpu_has_feature.h"
 #include "target/arm/multiprocessing.h"
 #include "target/arm/psci.h"
 
@@ -693,7 +694,7 @@ build_madt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
         ARMCPU *armcpu = ARM_CPU(qemu_get_cpu(i));
         uint64_t physical_base_address = 0, gich = 0, gicv = 0;
         uint32_t vgic_interrupt = vms->virt ? ARCH_GIC_MAINT_IRQ : 0;
-        uint32_t pmu_interrupt = arm_feature(&armcpu->env, ARM_FEATURE_PMU) ?
+        uint32_t pmu_interrupt = arm_cpu_has_feature(armcpu, ARM_FEATURE_PMU) ?
                                              VIRTUAL_PMU_IRQ : 0;
 
         if (vms->gic_version == VIRT_GIC_VERSION_2) {
-- 
2.47.1



^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 19/19] target/arm: Always include full path to 'cpu.h'
  2025-05-13 17:39 [PATCH 00/19] target/arm: More header rework around arm_feature() & multiprocessing.h Philippe Mathieu-Daudé
                   ` (17 preceding siblings ...)
  2025-05-13 17:39 ` [PATCH 18/19] hw/arm/virt-acpi: " Philippe Mathieu-Daudé
@ 2025-05-13 17:39 ` Philippe Mathieu-Daudé
  2025-05-13 22:57   ` Pierrick Bouvier
  2025-05-13 17:42 ` [PATCH 00/19] target/arm: More header rework around arm_feature() & multiprocessing.h Philippe Mathieu-Daudé
  2025-05-29 15:37 ` Peter Maydell
  20 siblings, 1 reply; 37+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-05-13 17:39 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, qemu-arm, Richard Henderson, Pierrick Bouvier,
	Philippe Mathieu-Daudé

Some files include "cpu.h", others "target/arm/cpu.h".
Unify by using the latter which is more explicit.

Suggested-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/arm/cpregs.h            | 2 +-
 target/arm/cpu-features.h      | 2 +-
 target/arm/tcg/translate.h     | 2 +-
 target/arm/arch_dump.c         | 2 +-
 target/arm/arm-powerctl.c      | 2 +-
 target/arm/arm-qmp-cmds.c      | 2 +-
 target/arm/cortex-regs.c       | 2 +-
 target/arm/cpu.c               | 2 +-
 target/arm/cpu64.c             | 2 +-
 target/arm/debug_helper.c      | 2 +-
 target/arm/gdbstub.c           | 2 +-
 target/arm/gdbstub64.c         | 2 +-
 target/arm/helper.c            | 2 +-
 target/arm/hyp_gdbstub.c       | 2 +-
 target/arm/kvm-stub.c          | 2 +-
 target/arm/kvm.c               | 2 +-
 target/arm/machine.c           | 2 +-
 target/arm/ptw.c               | 2 +-
 target/arm/tcg-stubs.c         | 2 +-
 target/arm/tcg/cpu-v7m.c       | 2 +-
 target/arm/tcg/cpu32.c         | 2 +-
 target/arm/tcg/cpu64.c         | 2 +-
 target/arm/tcg/helper-a64.c    | 2 +-
 target/arm/tcg/hflags.c        | 2 +-
 target/arm/tcg/iwmmxt_helper.c | 2 +-
 target/arm/tcg/m_helper.c      | 2 +-
 target/arm/tcg/mte_helper.c    | 2 +-
 target/arm/tcg/mve_helper.c    | 2 +-
 target/arm/tcg/neon_helper.c   | 2 +-
 target/arm/tcg/op_helper.c     | 2 +-
 target/arm/tcg/pauth_helper.c  | 2 +-
 target/arm/tcg/psci.c          | 2 +-
 target/arm/tcg/sme_helper.c    | 2 +-
 target/arm/tcg/sve_helper.c    | 2 +-
 target/arm/tcg/tlb-insns.c     | 2 +-
 target/arm/tcg/tlb_helper.c    | 2 +-
 target/arm/tcg/vec_helper.c    | 2 +-
 target/arm/tcg/vfp_helper.c    | 2 +-
 target/arm/vfp_fpscr.c         | 2 +-
 39 files changed, 39 insertions(+), 39 deletions(-)

diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h
index c1a7ae37356..25a7c2928ba 100644
--- a/target/arm/cpregs.h
+++ b/target/arm/cpregs.h
@@ -23,7 +23,7 @@
 
 #include "hw/registerfields.h"
 #include "target/arm/kvm-consts.h"
-#include "cpu.h"
+#include "target/arm/cpu.h"
 
 /*
  * ARMCPRegInfo type field bits:
diff --git a/target/arm/cpu-features.h b/target/arm/cpu-features.h
index 4452e7c21e3..90c5efd6eac 100644
--- a/target/arm/cpu-features.h
+++ b/target/arm/cpu-features.h
@@ -22,7 +22,7 @@
 
 #include "hw/registerfields.h"
 #include "qemu/host-utils.h"
-#include "cpu.h"
+#include "target/arm/cpu.h"
 
 /*
  * Naming convention for isar_feature functions:
diff --git a/target/arm/tcg/translate.h b/target/arm/tcg/translate.h
index 1bfdb0fb9bb..f8eb0d4a5a8 100644
--- a/target/arm/tcg/translate.h
+++ b/target/arm/tcg/translate.h
@@ -1,7 +1,7 @@
 #ifndef TARGET_ARM_TRANSLATE_H
 #define TARGET_ARM_TRANSLATE_H
 
-#include "cpu.h"
+#include "target/arm/cpu.h"
 #include "tcg/tcg-op.h"
 #include "tcg/tcg-op-gvec.h"
 #include "exec/translator.h"
diff --git a/target/arm/arch_dump.c b/target/arm/arch_dump.c
index 1dd79849c13..9c90430d1b6 100644
--- a/target/arm/arch_dump.c
+++ b/target/arm/arch_dump.c
@@ -19,7 +19,7 @@
  */
 
 #include "qemu/osdep.h"
-#include "cpu.h"
+#include "target/arm/cpu.h"
 #include "elf.h"
 #include "system/dump.h"
 #include "cpu-features.h"
diff --git a/target/arm/arm-powerctl.c b/target/arm/arm-powerctl.c
index 20c70c7d6bb..4cffe557e37 100644
--- a/target/arm/arm-powerctl.c
+++ b/target/arm/arm-powerctl.c
@@ -9,7 +9,7 @@
  */
 
 #include "qemu/osdep.h"
-#include "cpu.h"
+#include "target/arm/cpu.h"
 #include "cpu-qom.h"
 #include "internals.h"
 #include "arm-powerctl.h"
diff --git a/target/arm/arm-qmp-cmds.c b/target/arm/arm-qmp-cmds.c
index 930ec37413d..392887d3b48 100644
--- a/target/arm/arm-qmp-cmds.c
+++ b/target/arm/arm-qmp-cmds.c
@@ -30,7 +30,7 @@
 #include "qapi/qapi-commands-misc-target.h"
 #include "qobject/qdict.h"
 #include "qom/qom-qobject.h"
-#include "cpu.h"
+#include "target/arm/cpu.h"
 
 static GICCapability *gic_cap_new(int version)
 {
diff --git a/target/arm/cortex-regs.c b/target/arm/cortex-regs.c
index ae817b08ddf..2caa8855f02 100644
--- a/target/arm/cortex-regs.c
+++ b/target/arm/cortex-regs.c
@@ -7,7 +7,7 @@
  */
 
 #include "qemu/osdep.h"
-#include "cpu.h"
+#include "target/arm/cpu.h"
 #include "cpregs.h"
 
 
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
index 759636a3b0e..00f06916e62 100644
--- a/target/arm/cpu.c
+++ b/target/arm/cpu.c
@@ -27,7 +27,7 @@
 #include "target/arm/idau.h"
 #include "qemu/module.h"
 #include "qapi/error.h"
-#include "cpu.h"
+#include "target/arm/cpu.h"
 #ifdef CONFIG_TCG
 #include "exec/translation-block.h"
 #include "accel/tcg/cpu-ops.h"
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
index 00629a5d1d1..34f43094da9 100644
--- a/target/arm/cpu64.c
+++ b/target/arm/cpu64.c
@@ -20,7 +20,7 @@
 
 #include "qemu/osdep.h"
 #include "qapi/error.h"
-#include "cpu.h"
+#include "target/arm/cpu.h"
 #include "cpregs.h"
 #include "qemu/module.h"
 #include "qemu/units.h"
diff --git a/target/arm/debug_helper.c b/target/arm/debug_helper.c
index 69fb1d0d9ff..a6199a73740 100644
--- a/target/arm/debug_helper.c
+++ b/target/arm/debug_helper.c
@@ -7,7 +7,7 @@
  */
 #include "qemu/osdep.h"
 #include "qemu/log.h"
-#include "cpu.h"
+#include "target/arm/cpu.h"
 #include "internals.h"
 #include "cpu-features.h"
 #include "cpregs.h"
diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c
index ce4497ad7c3..d148d8434f1 100644
--- a/target/arm/gdbstub.c
+++ b/target/arm/gdbstub.c
@@ -18,7 +18,7 @@
  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  */
 #include "qemu/osdep.h"
-#include "cpu.h"
+#include "target/arm/cpu.h"
 #include "exec/gdbstub.h"
 #include "gdbstub/helpers.h"
 #include "gdbstub/commands.h"
diff --git a/target/arm/gdbstub64.c b/target/arm/gdbstub64.c
index 64ee9b3b567..b6033f431d8 100644
--- a/target/arm/gdbstub64.c
+++ b/target/arm/gdbstub64.c
@@ -18,7 +18,7 @@
  */
 #include "qemu/osdep.h"
 #include "qemu/log.h"
-#include "cpu.h"
+#include "target/arm/cpu.h"
 #include "internals.h"
 #include "gdbstub/helpers.h"
 #include "gdbstub/commands.h"
diff --git a/target/arm/helper.c b/target/arm/helper.c
index 7859729c39f..05a50c5c750 100644
--- a/target/arm/helper.c
+++ b/target/arm/helper.c
@@ -9,7 +9,7 @@
 #include "qemu/osdep.h"
 #include "qemu/log.h"
 #include "trace.h"
-#include "cpu.h"
+#include "target/arm/cpu.h"
 #include "internals.h"
 #include "cpu-features.h"
 #include "exec/page-protection.h"
diff --git a/target/arm/hyp_gdbstub.c b/target/arm/hyp_gdbstub.c
index bb5969720ce..73c9a9a8333 100644
--- a/target/arm/hyp_gdbstub.c
+++ b/target/arm/hyp_gdbstub.c
@@ -10,7 +10,7 @@
  */
 
 #include "qemu/osdep.h"
-#include "cpu.h"
+#include "target/arm/cpu.h"
 #include "internals.h"
 #include "gdbstub/enums.h"
 
diff --git a/target/arm/kvm-stub.c b/target/arm/kvm-stub.c
index 34e57fab011..532018b745e 100644
--- a/target/arm/kvm-stub.c
+++ b/target/arm/kvm-stub.c
@@ -10,7 +10,7 @@
  *
  */
 #include "qemu/osdep.h"
-#include "cpu.h"
+#include "target/arm/cpu.h"
 #include "kvm_arm.h"
 
 bool write_kvmstate_to_list(ARMCPU *cpu)
diff --git a/target/arm/kvm.c b/target/arm/kvm.c
index 5969249b579..d280d08a63e 100644
--- a/target/arm/kvm.c
+++ b/target/arm/kvm.c
@@ -25,7 +25,7 @@
 #include "system/kvm.h"
 #include "system/kvm_int.h"
 #include "kvm_arm.h"
-#include "cpu.h"
+#include "target/arm/cpu.h"
 #include "trace.h"
 #include "internals.h"
 #include "hw/pci/pci.h"
diff --git a/target/arm/machine.c b/target/arm/machine.c
index e442d485241..f0524615fe1 100644
--- a/target/arm/machine.c
+++ b/target/arm/machine.c
@@ -1,5 +1,5 @@
 #include "qemu/osdep.h"
-#include "cpu.h"
+#include "target/arm/cpu.h"
 #include "qemu/error-report.h"
 #include "system/kvm.h"
 #include "system/tcg.h"
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
index 44170d831cc..03047d10d87 100644
--- a/target/arm/ptw.c
+++ b/target/arm/ptw.c
@@ -14,7 +14,7 @@
 #include "exec/target_page.h"
 #include "exec/tlb-flags.h"
 #include "accel/tcg/probe.h"
-#include "cpu.h"
+#include "target/arm/cpu.h"
 #include "internals.h"
 #include "cpu-features.h"
 #include "idau.h"
diff --git a/target/arm/tcg-stubs.c b/target/arm/tcg-stubs.c
index 5e5166c0490..672b5b01db0 100644
--- a/target/arm/tcg-stubs.c
+++ b/target/arm/tcg-stubs.c
@@ -8,7 +8,7 @@
  */
 
 #include "qemu/osdep.h"
-#include "cpu.h"
+#include "target/arm/cpu.h"
 #include "internals.h"
 
 void write_v7m_exception(CPUARMState *env, uint32_t new_exc)
diff --git a/target/arm/tcg/cpu-v7m.c b/target/arm/tcg/cpu-v7m.c
index 95b23d9b55d..9b7108d9678 100644
--- a/target/arm/tcg/cpu-v7m.c
+++ b/target/arm/tcg/cpu-v7m.c
@@ -9,7 +9,7 @@
  */
 
 #include "qemu/osdep.h"
-#include "cpu.h"
+#include "target/arm/cpu.h"
 #include "accel/tcg/cpu-ops.h"
 #include "internals.h"
 
diff --git a/target/arm/tcg/cpu32.c b/target/arm/tcg/cpu32.c
index 2c45b7eddda..5bf78d9240a 100644
--- a/target/arm/tcg/cpu32.c
+++ b/target/arm/tcg/cpu32.c
@@ -9,7 +9,7 @@
  */
 
 #include "qemu/osdep.h"
-#include "cpu.h"
+#include "target/arm/cpu.h"
 #include "accel/tcg/cpu-ops.h"
 #include "internals.h"
 #include "target/arm/idau.h"
diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c
index 29ab0ac79da..c95036df2a5 100644
--- a/target/arm/tcg/cpu64.c
+++ b/target/arm/tcg/cpu64.c
@@ -20,7 +20,7 @@
 
 #include "qemu/osdep.h"
 #include "qapi/error.h"
-#include "cpu.h"
+#include "target/arm/cpu.h"
 #include "qemu/module.h"
 #include "qapi/visitor.h"
 #include "hw/qdev-properties.h"
diff --git a/target/arm/tcg/helper-a64.c b/target/arm/tcg/helper-a64.c
index 4f618ae390e..1713348a55d 100644
--- a/target/arm/tcg/helper-a64.c
+++ b/target/arm/tcg/helper-a64.c
@@ -19,7 +19,7 @@
 
 #include "qemu/osdep.h"
 #include "qemu/units.h"
-#include "cpu.h"
+#include "target/arm/cpu.h"
 #include "gdbstub/helpers.h"
 #include "exec/helper-proto.h"
 #include "qemu/host-utils.h"
diff --git a/target/arm/tcg/hflags.c b/target/arm/tcg/hflags.c
index 1ccec63bbd4..d77eacb7338 100644
--- a/target/arm/tcg/hflags.c
+++ b/target/arm/tcg/hflags.c
@@ -6,7 +6,7 @@
  * SPDX-License-Identifier: GPL-2.0-or-later
  */
 #include "qemu/osdep.h"
-#include "cpu.h"
+#include "target/arm/cpu.h"
 #include "internals.h"
 #include "cpu-features.h"
 #include "exec/translation-block.h"
diff --git a/target/arm/tcg/iwmmxt_helper.c b/target/arm/tcg/iwmmxt_helper.c
index ba054b6b4db..3489f6d01c3 100644
--- a/target/arm/tcg/iwmmxt_helper.c
+++ b/target/arm/tcg/iwmmxt_helper.c
@@ -21,7 +21,7 @@
 
 #include "qemu/osdep.h"
 
-#include "cpu.h"
+#include "target/arm/cpu.h"
 
 #define HELPER_H "tcg/helper.h"
 #include "exec/helper-proto.h.inc"
diff --git a/target/arm/tcg/m_helper.c b/target/arm/tcg/m_helper.c
index 6614719832e..5d657f5c753 100644
--- a/target/arm/tcg/m_helper.c
+++ b/target/arm/tcg/m_helper.c
@@ -7,7 +7,7 @@
  */
 
 #include "qemu/osdep.h"
-#include "cpu.h"
+#include "target/arm/cpu.h"
 #include "internals.h"
 #include "cpu-features.h"
 #include "gdbstub/helpers.h"
diff --git a/target/arm/tcg/mte_helper.c b/target/arm/tcg/mte_helper.c
index 0efc18a181e..66e90b03520 100644
--- a/target/arm/tcg/mte_helper.c
+++ b/target/arm/tcg/mte_helper.c
@@ -19,7 +19,7 @@
 
 #include "qemu/osdep.h"
 #include "qemu/log.h"
-#include "cpu.h"
+#include "target/arm/cpu.h"
 #include "internals.h"
 #include "exec/page-protection.h"
 #ifdef CONFIG_USER_ONLY
diff --git a/target/arm/tcg/mve_helper.c b/target/arm/tcg/mve_helper.c
index 506d1c34757..105fc0a4b9d 100644
--- a/target/arm/tcg/mve_helper.c
+++ b/target/arm/tcg/mve_helper.c
@@ -18,7 +18,7 @@
  */
 
 #include "qemu/osdep.h"
-#include "cpu.h"
+#include "target/arm/cpu.h"
 #include "internals.h"
 #include "vec_internal.h"
 #include "exec/helper-proto.h"
diff --git a/target/arm/tcg/neon_helper.c b/target/arm/tcg/neon_helper.c
index 2cc8241f1e4..44f1aafd17d 100644
--- a/target/arm/tcg/neon_helper.c
+++ b/target/arm/tcg/neon_helper.c
@@ -8,7 +8,7 @@
  */
 
 #include "qemu/osdep.h"
-#include "cpu.h"
+#include "target/arm/cpu.h"
 #include "tcg/tcg-gvec-desc.h"
 #include "fpu/softfloat.h"
 #include "vec_internal.h"
diff --git a/target/arm/tcg/op_helper.c b/target/arm/tcg/op_helper.c
index e0f9c91450a..3a4a76e999e 100644
--- a/target/arm/tcg/op_helper.c
+++ b/target/arm/tcg/op_helper.c
@@ -18,7 +18,7 @@
  */
 #include "qemu/osdep.h"
 #include "qemu/main-loop.h"
-#include "cpu.h"
+#include "target/arm/cpu.h"
 #include "exec/helper-proto.h"
 #include "exec/target_page.h"
 #include "internals.h"
diff --git a/target/arm/tcg/pauth_helper.c b/target/arm/tcg/pauth_helper.c
index c591c3052c3..0ae329710ac 100644
--- a/target/arm/tcg/pauth_helper.c
+++ b/target/arm/tcg/pauth_helper.c
@@ -18,7 +18,7 @@
  */
 
 #include "qemu/osdep.h"
-#include "cpu.h"
+#include "target/arm/cpu.h"
 #include "internals.h"
 #include "cpu-features.h"
 #include "accel/tcg/cpu-ldst.h"
diff --git a/target/arm/tcg/psci.c b/target/arm/tcg/psci.c
index 0313cdd6ba2..05ecd647c9f 100644
--- a/target/arm/tcg/psci.c
+++ b/target/arm/tcg/psci.c
@@ -17,7 +17,7 @@
  */
 
 #include "qemu/osdep.h"
-#include "cpu.h"
+#include "target/arm/cpu.h"
 #include "exec/helper-proto.h"
 #include "kvm-consts.h"
 #include "qemu/main-loop.h"
diff --git a/target/arm/tcg/sme_helper.c b/target/arm/tcg/sme_helper.c
index de0c6e54d4b..a2104b4751d 100644
--- a/target/arm/tcg/sme_helper.c
+++ b/target/arm/tcg/sme_helper.c
@@ -18,7 +18,7 @@
  */
 
 #include "qemu/osdep.h"
-#include "cpu.h"
+#include "target/arm/cpu.h"
 #include "internals.h"
 #include "tcg/tcg-gvec-desc.h"
 #include "exec/helper-proto.h"
diff --git a/target/arm/tcg/sve_helper.c b/target/arm/tcg/sve_helper.c
index a2c363a4e17..afd110431cd 100644
--- a/target/arm/tcg/sve_helper.c
+++ b/target/arm/tcg/sve_helper.c
@@ -18,7 +18,7 @@
  */
 
 #include "qemu/osdep.h"
-#include "cpu.h"
+#include "target/arm/cpu.h"
 #include "internals.h"
 #include "exec/page-protection.h"
 #include "exec/helper-proto.h"
diff --git a/target/arm/tcg/tlb-insns.c b/target/arm/tcg/tlb-insns.c
index 95c26c6d463..bc8353cdbb5 100644
--- a/target/arm/tcg/tlb-insns.c
+++ b/target/arm/tcg/tlb-insns.c
@@ -9,7 +9,7 @@
 #include "qemu/log.h"
 #include "exec/cputlb.h"
 #include "exec/target_page.h"
-#include "cpu.h"
+#include "target/arm/cpu.h"
 #include "internals.h"
 #include "cpu-features.h"
 #include "cpregs.h"
diff --git a/target/arm/tcg/tlb_helper.c b/target/arm/tcg/tlb_helper.c
index 23c72a99f5c..ea7d0c74c88 100644
--- a/target/arm/tcg/tlb_helper.c
+++ b/target/arm/tcg/tlb_helper.c
@@ -6,7 +6,7 @@
  * SPDX-License-Identifier: GPL-2.0-or-later
  */
 #include "qemu/osdep.h"
-#include "cpu.h"
+#include "target/arm/cpu.h"
 #include "internals.h"
 #include "cpu-features.h"
 
diff --git a/target/arm/tcg/vec_helper.c b/target/arm/tcg/vec_helper.c
index 986eaf8ffa4..9e2715e34de 100644
--- a/target/arm/tcg/vec_helper.c
+++ b/target/arm/tcg/vec_helper.c
@@ -18,7 +18,7 @@
  */
 
 #include "qemu/osdep.h"
-#include "cpu.h"
+#include "target/arm/cpu.h"
 #include "exec/helper-proto.h"
 #include "tcg/tcg-gvec-desc.h"
 #include "fpu/softfloat.h"
diff --git a/target/arm/tcg/vfp_helper.c b/target/arm/tcg/vfp_helper.c
index b1324c5c0a6..ac532ef8511 100644
--- a/target/arm/tcg/vfp_helper.c
+++ b/target/arm/tcg/vfp_helper.c
@@ -18,7 +18,7 @@
  */
 
 #include "qemu/osdep.h"
-#include "cpu.h"
+#include "target/arm/cpu.h"
 #include "internals.h"
 #include "cpu-features.h"
 #include "fpu/softfloat.h"
diff --git a/target/arm/vfp_fpscr.c b/target/arm/vfp_fpscr.c
index 92ea60ebbf2..a196bcfa803 100644
--- a/target/arm/vfp_fpscr.c
+++ b/target/arm/vfp_fpscr.c
@@ -18,7 +18,7 @@
  */
 
 #include "qemu/osdep.h"
-#include "cpu.h"
+#include "target/arm/cpu.h"
 #include "internals.h"
 #include "cpu-features.h"
 
-- 
2.47.1



^ permalink raw reply related	[flat|nested] 37+ messages in thread

* Re: [PATCH 00/19] target/arm: More header rework around arm_feature() & multiprocessing.h
  2025-05-13 17:39 [PATCH 00/19] target/arm: More header rework around arm_feature() & multiprocessing.h Philippe Mathieu-Daudé
                   ` (18 preceding siblings ...)
  2025-05-13 17:39 ` [PATCH 19/19] target/arm: Always include full path to 'cpu.h' Philippe Mathieu-Daudé
@ 2025-05-13 17:42 ` Philippe Mathieu-Daudé
  2025-05-13 23:00   ` Pierrick Bouvier
  2025-05-29 15:37 ` Peter Maydell
  20 siblings, 1 reply; 37+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-05-13 17:42 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell, qemu-arm, Richard Henderson, Pierrick Bouvier

On 13/5/25 19:39, Philippe Mathieu-Daudé wrote:

> Philippe Mathieu-Daudé (19):
>    target/arm/tcg-stubs: compile file once (system)
>    target/arm/hvf_arm: Avoid using poisoned CONFIG_HVF definition
>    target/arm: Only link with zlib when TCG is enabled

>    target/arm: Always include full path to 'cpu.h'

Missing review: 1-3 & 19


^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 01/19] target/arm/tcg-stubs: compile file once (system)
  2025-05-13 17:39 ` [PATCH 01/19] target/arm/tcg-stubs: compile file once (system) Philippe Mathieu-Daudé
@ 2025-05-13 17:43   ` Philippe Mathieu-Daudé
  2025-05-13 22:59   ` Pierrick Bouvier
  2025-05-14  8:18   ` Richard Henderson
  2 siblings, 0 replies; 37+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-05-13 17:43 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell, qemu-arm, Richard Henderson, Pierrick Bouvier

On 13/5/25 19:39, Philippe Mathieu-Daudé wrote:

The objective is to remove the arm_ss[] source set soon.

> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   target/arm/meson.build | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/target/arm/meson.build b/target/arm/meson.build
> index b404fa54863..e568dfb706a 100644
> --- a/target/arm/meson.build
> +++ b/target/arm/meson.build
> @@ -48,7 +48,7 @@ subdir('hvf')
>   if 'CONFIG_TCG' in config_all_accel
>      subdir('tcg')
>   else
> -    arm_ss.add(files('tcg-stubs.c'))
> +    arm_common_system_ss.add(files('tcg-stubs.c'))
>   endif
>   
>   target_arch += {'arm': arm_ss}



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 19/19] target/arm: Always include full path to 'cpu.h'
  2025-05-13 17:39 ` [PATCH 19/19] target/arm: Always include full path to 'cpu.h' Philippe Mathieu-Daudé
@ 2025-05-13 22:57   ` Pierrick Bouvier
  0 siblings, 0 replies; 37+ messages in thread
From: Pierrick Bouvier @ 2025-05-13 22:57 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Peter Maydell, qemu-arm, Richard Henderson

On 5/13/25 10:39 AM, Philippe Mathieu-Daudé wrote:
> Some files include "cpu.h", others "target/arm/cpu.h".
> Unify by using the latter which is more explicit.
> 
> Suggested-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   target/arm/cpregs.h            | 2 +-
>   target/arm/cpu-features.h      | 2 +-
>   target/arm/tcg/translate.h     | 2 +-
>   target/arm/arch_dump.c         | 2 +-
>   target/arm/arm-powerctl.c      | 2 +-
>   target/arm/arm-qmp-cmds.c      | 2 +-
>   target/arm/cortex-regs.c       | 2 +-
>   target/arm/cpu.c               | 2 +-
>   target/arm/cpu64.c             | 2 +-
>   target/arm/debug_helper.c      | 2 +-
>   target/arm/gdbstub.c           | 2 +-
>   target/arm/gdbstub64.c         | 2 +-
>   target/arm/helper.c            | 2 +-
>   target/arm/hyp_gdbstub.c       | 2 +-
>   target/arm/kvm-stub.c          | 2 +-
>   target/arm/kvm.c               | 2 +-
>   target/arm/machine.c           | 2 +-
>   target/arm/ptw.c               | 2 +-
>   target/arm/tcg-stubs.c         | 2 +-
>   target/arm/tcg/cpu-v7m.c       | 2 +-
>   target/arm/tcg/cpu32.c         | 2 +-
>   target/arm/tcg/cpu64.c         | 2 +-
>   target/arm/tcg/helper-a64.c    | 2 +-
>   target/arm/tcg/hflags.c        | 2 +-
>   target/arm/tcg/iwmmxt_helper.c | 2 +-
>   target/arm/tcg/m_helper.c      | 2 +-
>   target/arm/tcg/mte_helper.c    | 2 +-
>   target/arm/tcg/mve_helper.c    | 2 +-
>   target/arm/tcg/neon_helper.c   | 2 +-
>   target/arm/tcg/op_helper.c     | 2 +-
>   target/arm/tcg/pauth_helper.c  | 2 +-
>   target/arm/tcg/psci.c          | 2 +-
>   target/arm/tcg/sme_helper.c    | 2 +-
>   target/arm/tcg/sve_helper.c    | 2 +-
>   target/arm/tcg/tlb-insns.c     | 2 +-
>   target/arm/tcg/tlb_helper.c    | 2 +-
>   target/arm/tcg/vec_helper.c    | 2 +-
>   target/arm/tcg/vfp_helper.c    | 2 +-
>   target/arm/vfp_fpscr.c         | 2 +-
>   39 files changed, 39 insertions(+), 39 deletions(-)

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 03/19] target/arm: Only link with zlib when TCG is enabled
  2025-05-13 17:39 ` [PATCH 03/19] target/arm: Only link with zlib when TCG is enabled Philippe Mathieu-Daudé
@ 2025-05-13 22:58   ` Pierrick Bouvier
  0 siblings, 0 replies; 37+ messages in thread
From: Pierrick Bouvier @ 2025-05-13 22:58 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Peter Maydell, qemu-arm, Richard Henderson

On 5/13/25 10:39 AM, Philippe Mathieu-Daudé wrote:
> Since commit 538b764d341 ("target/arm: Move minor arithmetic
> helpers out of helper.c") we only use the zlib helpers under
> TCG.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   target/arm/meson.build     | 1 -
>   target/arm/tcg/meson.build | 2 ++
>   2 files changed, 2 insertions(+), 1 deletion(-)

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 02/19] target/arm/hvf_arm: Avoid using poisoned CONFIG_HVF definition
  2025-05-13 17:39 ` [PATCH 02/19] target/arm/hvf_arm: Avoid using poisoned CONFIG_HVF definition Philippe Mathieu-Daudé
@ 2025-05-13 22:58   ` Pierrick Bouvier
  2025-05-14  8:19   ` Richard Henderson
  1 sibling, 0 replies; 37+ messages in thread
From: Pierrick Bouvier @ 2025-05-13 22:58 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Peter Maydell, qemu-arm, Richard Henderson

On 5/13/25 10:39 AM, Philippe Mathieu-Daudé wrote:
> In order to allow non-target specific code to include
> "hvf_arm.h", define the stubs in hvf-stub.c.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   MAINTAINERS            |  1 +
>   target/arm/hvf_arm.h   | 16 ----------------
>   target/arm/hvf-stub.c  | 20 ++++++++++++++++++++
>   target/arm/meson.build |  1 +
>   4 files changed, 22 insertions(+), 16 deletions(-)
>   create mode 100644 target/arm/hvf-stub.c

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 01/19] target/arm/tcg-stubs: compile file once (system)
  2025-05-13 17:39 ` [PATCH 01/19] target/arm/tcg-stubs: compile file once (system) Philippe Mathieu-Daudé
  2025-05-13 17:43   ` Philippe Mathieu-Daudé
@ 2025-05-13 22:59   ` Pierrick Bouvier
  2025-05-14  8:18   ` Richard Henderson
  2 siblings, 0 replies; 37+ messages in thread
From: Pierrick Bouvier @ 2025-05-13 22:59 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Peter Maydell, qemu-arm, Richard Henderson

On 5/13/25 10:39 AM, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   target/arm/meson.build | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 00/19] target/arm: More header rework around arm_feature() & multiprocessing.h
  2025-05-13 17:42 ` [PATCH 00/19] target/arm: More header rework around arm_feature() & multiprocessing.h Philippe Mathieu-Daudé
@ 2025-05-13 23:00   ` Pierrick Bouvier
  0 siblings, 0 replies; 37+ messages in thread
From: Pierrick Bouvier @ 2025-05-13 23:00 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Peter Maydell, qemu-arm, Richard Henderson

On 5/13/25 10:42 AM, Philippe Mathieu-Daudé wrote:
> On 13/5/25 19:39, Philippe Mathieu-Daudé wrote:
> 
>> Philippe Mathieu-Daudé (19):
>>     target/arm/tcg-stubs: compile file once (system)
>>     target/arm/hvf_arm: Avoid using poisoned CONFIG_HVF definition
>>     target/arm: Only link with zlib when TCG is enabled
> 
>>     target/arm: Always include full path to 'cpu.h'
> 
> Missing review: 1-3 & 19

Thanks Philippe,
hopefully it can be pulled at the same than its base series.

Pierrick


^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 01/19] target/arm/tcg-stubs: compile file once (system)
  2025-05-13 17:39 ` [PATCH 01/19] target/arm/tcg-stubs: compile file once (system) Philippe Mathieu-Daudé
  2025-05-13 17:43   ` Philippe Mathieu-Daudé
  2025-05-13 22:59   ` Pierrick Bouvier
@ 2025-05-14  8:18   ` Richard Henderson
  2 siblings, 0 replies; 37+ messages in thread
From: Richard Henderson @ 2025-05-14  8:18 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Peter Maydell, qemu-arm, Pierrick Bouvier

On 5/13/25 18:39, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   target/arm/meson.build | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/target/arm/meson.build b/target/arm/meson.build
> index b404fa54863..e568dfb706a 100644
> --- a/target/arm/meson.build
> +++ b/target/arm/meson.build
> @@ -48,7 +48,7 @@ subdir('hvf')
>   if 'CONFIG_TCG' in config_all_accel
>      subdir('tcg')
>   else
> -    arm_ss.add(files('tcg-stubs.c'))
> +    arm_common_system_ss.add(files('tcg-stubs.c'))
>   endif
>   
>   target_arch += {'arm': arm_ss}

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~


^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 02/19] target/arm/hvf_arm: Avoid using poisoned CONFIG_HVF definition
  2025-05-13 17:39 ` [PATCH 02/19] target/arm/hvf_arm: Avoid using poisoned CONFIG_HVF definition Philippe Mathieu-Daudé
  2025-05-13 22:58   ` Pierrick Bouvier
@ 2025-05-14  8:19   ` Richard Henderson
  1 sibling, 0 replies; 37+ messages in thread
From: Richard Henderson @ 2025-05-14  8:19 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Peter Maydell, qemu-arm, Pierrick Bouvier

On 5/13/25 18:39, Philippe Mathieu-Daudé wrote:
> In order to allow non-target specific code to include
> "hvf_arm.h", define the stubs in hvf-stub.c.
> 
> Signed-off-by: Philippe Mathieu-Daudé<philmd@linaro.org>
> ---
>   MAINTAINERS            |  1 +
>   target/arm/hvf_arm.h   | 16 ----------------
>   target/arm/hvf-stub.c  | 20 ++++++++++++++++++++
>   target/arm/meson.build |  1 +
>   4 files changed, 22 insertions(+), 16 deletions(-)
>   create mode 100644 target/arm/hvf-stub.c

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~


^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 16/19] target/arm: Add arm_cpu_has_feature() helper
  2025-05-13 17:39 ` [PATCH 16/19] target/arm: Add arm_cpu_has_feature() helper Philippe Mathieu-Daudé
@ 2025-05-14  8:24   ` Richard Henderson
  2025-05-14 16:53     ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 37+ messages in thread
From: Richard Henderson @ 2025-05-14  8:24 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Peter Maydell, qemu-arm, Pierrick Bouvier

On 5/13/25 18:39, Philippe Mathieu-Daudé wrote:
> arm_cpu_has_feature() is equivalent of arm_feature(), however
> while the latter uses CPUARMState so is target-specific, the
> former doesn't and can be called by target-agnostic code in hw/.

CPUARMState is no more target-specific than ARMCPU.

Did you really mean to use CPUState?
Or is it merely that arm_cpu_has_feature is out-of-line?


r~

> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> ---
>   target/arm/cpu_has_feature.h | 2 ++
>   target/arm/cpu.c             | 7 +++++++
>   2 files changed, 9 insertions(+)
> 
> diff --git a/target/arm/cpu_has_feature.h b/target/arm/cpu_has_feature.h
> index 2adfccd9208..352f9d75bed 100644
> --- a/target/arm/cpu_has_feature.h
> +++ b/target/arm/cpu_has_feature.h
> @@ -62,4 +62,6 @@ typedef enum arm_features {
>       ARM_FEATURE_BACKCOMPAT_CNTFRQ, /* 62.5MHz timer default */
>   } ArmCpuFeature;
>   
> +bool arm_cpu_has_feature(ARMCPU *cpu, ArmCpuFeature feature);
> +
>   #endif
> diff --git a/target/arm/cpu.c b/target/arm/cpu.c
> index 8c9d161f2ef..759636a3b0e 100644
> --- a/target/arm/cpu.c
> +++ b/target/arm/cpu.c
> @@ -54,6 +54,13 @@
>   #include "target/arm/gtimer.h"
>   #include "target/arm/multiprocessing.h"
>   
> +bool arm_cpu_has_feature(ARMCPU *cpu, ArmCpuFeature feature)
> +{
> +    CPUARMState *env = &cpu->env;
> +
> +    return arm_feature(env, feature);
> +}
> +
>   static void arm_cpu_set_pc(CPUState *cs, vaddr value)
>   {
>       ARMCPU *cpu = ARM_CPU(cs);



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 16/19] target/arm: Add arm_cpu_has_feature() helper
  2025-05-14  8:24   ` Richard Henderson
@ 2025-05-14 16:53     ` Philippe Mathieu-Daudé
  2025-05-14 16:59       ` Pierrick Bouvier
  0 siblings, 1 reply; 37+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-05-14 16:53 UTC (permalink / raw)
  To: Richard Henderson, qemu-devel; +Cc: Peter Maydell, qemu-arm, Pierrick Bouvier

On 14/5/25 10:24, Richard Henderson wrote:
> On 5/13/25 18:39, Philippe Mathieu-Daudé wrote:
>> arm_cpu_has_feature() is equivalent of arm_feature(), however
>> while the latter uses CPUARMState so is target-specific, the
>> former doesn't and can be called by target-agnostic code in hw/.
> 
> CPUARMState is no more target-specific than ARMCPU.

ARMCPU is forward-declared as opaque pointer in target/arm/cpu-qom.h,
so we can expose prototypes using it to non-ARM units.
CPUARMState is only declared in "cpu.h", itself only accessible by
ARM-related units.

> 
> Did you really mean to use CPUState?
> Or is it merely that arm_cpu_has_feature is out-of-line?
> 
> 
> r~
> 
>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
>> ---
>>   target/arm/cpu_has_feature.h | 2 ++
>>   target/arm/cpu.c             | 7 +++++++
>>   2 files changed, 9 insertions(+)
>>
>> diff --git a/target/arm/cpu_has_feature.h b/target/arm/cpu_has_feature.h
>> index 2adfccd9208..352f9d75bed 100644
>> --- a/target/arm/cpu_has_feature.h
>> +++ b/target/arm/cpu_has_feature.h
>> @@ -62,4 +62,6 @@ typedef enum arm_features {
>>       ARM_FEATURE_BACKCOMPAT_CNTFRQ, /* 62.5MHz timer default */
>>   } ArmCpuFeature;
>> +bool arm_cpu_has_feature(ARMCPU *cpu, ArmCpuFeature feature);
>> +
>>   #endif
>> diff --git a/target/arm/cpu.c b/target/arm/cpu.c
>> index 8c9d161f2ef..759636a3b0e 100644
>> --- a/target/arm/cpu.c
>> +++ b/target/arm/cpu.c
>> @@ -54,6 +54,13 @@
>>   #include "target/arm/gtimer.h"
>>   #include "target/arm/multiprocessing.h"
>> +bool arm_cpu_has_feature(ARMCPU *cpu, ArmCpuFeature feature)
>> +{
>> +    CPUARMState *env = &cpu->env;
>> +
>> +    return arm_feature(env, feature);
>> +}
>> +
>>   static void arm_cpu_set_pc(CPUState *cs, vaddr value)
>>   {
>>       ARMCPU *cpu = ARM_CPU(cs);
> 



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 16/19] target/arm: Add arm_cpu_has_feature() helper
  2025-05-14 16:53     ` Philippe Mathieu-Daudé
@ 2025-05-14 16:59       ` Pierrick Bouvier
  2025-05-15 11:05         ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 37+ messages in thread
From: Pierrick Bouvier @ 2025-05-14 16:59 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, Richard Henderson, qemu-devel
  Cc: Peter Maydell, qemu-arm

On 5/14/25 9:53 AM, Philippe Mathieu-Daudé wrote:
> On 14/5/25 10:24, Richard Henderson wrote:
>> On 5/13/25 18:39, Philippe Mathieu-Daudé wrote:
>>> arm_cpu_has_feature() is equivalent of arm_feature(), however
>>> while the latter uses CPUARMState so is target-specific, the
>>> former doesn't and can be called by target-agnostic code in hw/.
>>
>> CPUARMState is no more target-specific than ARMCPU.
> 
> ARMCPU is forward-declared as opaque pointer in target/arm/cpu-qom.h,
> so we can expose prototypes using it to non-ARM units.
> CPUARMState is only declared in "cpu.h", itself only accessible by
> ARM-related units.
> 

Maybe we can simply postpone introduction of arm_cpu_has_feature() when 
it will be really needed.

Patches 17 and 18 are not strictly needed, as cpu.h (which resolves to 
target/arm/cpu.h implicitely) is perfectly accessible to code in hw/arm 
without any problem.

I asked in the past if there was a real need for this function, but 
didn't have a clear answer on where it's mandatory. In this series, it's 
an optional change.

That said, I don't want block any work arguing over this, so if you feel 
it's better to have it, so be it, and let's pull this.

>>
>> Did you really mean to use CPUState?
>> Or is it merely that arm_cpu_has_feature is out-of-line?
>>
>>
>> r~
>>
>>>
>>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>>> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
>>> ---
>>>    target/arm/cpu_has_feature.h | 2 ++
>>>    target/arm/cpu.c             | 7 +++++++
>>>    2 files changed, 9 insertions(+)
>>>
>>> diff --git a/target/arm/cpu_has_feature.h b/target/arm/cpu_has_feature.h
>>> index 2adfccd9208..352f9d75bed 100644
>>> --- a/target/arm/cpu_has_feature.h
>>> +++ b/target/arm/cpu_has_feature.h
>>> @@ -62,4 +62,6 @@ typedef enum arm_features {
>>>        ARM_FEATURE_BACKCOMPAT_CNTFRQ, /* 62.5MHz timer default */
>>>    } ArmCpuFeature;
>>> +bool arm_cpu_has_feature(ARMCPU *cpu, ArmCpuFeature feature);
>>> +
>>>    #endif
>>> diff --git a/target/arm/cpu.c b/target/arm/cpu.c
>>> index 8c9d161f2ef..759636a3b0e 100644
>>> --- a/target/arm/cpu.c
>>> +++ b/target/arm/cpu.c
>>> @@ -54,6 +54,13 @@
>>>    #include "target/arm/gtimer.h"
>>>    #include "target/arm/multiprocessing.h"
>>> +bool arm_cpu_has_feature(ARMCPU *cpu, ArmCpuFeature feature)
>>> +{
>>> +    CPUARMState *env = &cpu->env;
>>> +
>>> +    return arm_feature(env, feature);
>>> +}
>>> +
>>>    static void arm_cpu_set_pc(CPUState *cs, vaddr value)
>>>    {
>>>        ARMCPU *cpu = ARM_CPU(cs);
>>
> 



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 16/19] target/arm: Add arm_cpu_has_feature() helper
  2025-05-14 16:59       ` Pierrick Bouvier
@ 2025-05-15 11:05         ` Philippe Mathieu-Daudé
  2025-05-15 15:22           ` Pierrick Bouvier
  0 siblings, 1 reply; 37+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-05-15 11:05 UTC (permalink / raw)
  To: Peter Maydell, Pierrick Bouvier; +Cc: qemu-arm, Richard Henderson, qemu-devel

On 14/5/25 18:59, Pierrick Bouvier wrote:
> On 5/14/25 9:53 AM, Philippe Mathieu-Daudé wrote:
>> On 14/5/25 10:24, Richard Henderson wrote:
>>> On 5/13/25 18:39, Philippe Mathieu-Daudé wrote:
>>>> arm_cpu_has_feature() is equivalent of arm_feature(), however
>>>> while the latter uses CPUARMState so is target-specific, the
>>>> former doesn't and can be called by target-agnostic code in hw/.
>>>
>>> CPUARMState is no more target-specific than ARMCPU.
>>
>> ARMCPU is forward-declared as opaque pointer in target/arm/cpu-qom.h,
>> so we can expose prototypes using it to non-ARM units.
>> CPUARMState is only declared in "cpu.h", itself only accessible by
>> ARM-related units.
>>
> 
> Maybe we can simply postpone introduction of arm_cpu_has_feature() when 
> it will be really needed.
> 
> Patches 17 and 18 are not strictly needed, as cpu.h (which resolves to 
> target/arm/cpu.h implicitely) is perfectly accessible to code in hw/arm 
> without any problem.

OK.

Peter, would you be OK to take reviewed patches #1 up to #15 (the
previous one) or do you rather I respin them?

Regards,

Phil.


^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 16/19] target/arm: Add arm_cpu_has_feature() helper
  2025-05-15 11:05         ` Philippe Mathieu-Daudé
@ 2025-05-15 15:22           ` Pierrick Bouvier
  2025-05-15 16:14             ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 37+ messages in thread
From: Pierrick Bouvier @ 2025-05-15 15:22 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, Peter Maydell
  Cc: qemu-arm, Richard Henderson, qemu-devel

On 5/15/25 4:05 AM, Philippe Mathieu-Daudé wrote:
> On 14/5/25 18:59, Pierrick Bouvier wrote:
>> On 5/14/25 9:53 AM, Philippe Mathieu-Daudé wrote:
>>> On 14/5/25 10:24, Richard Henderson wrote:
>>>> On 5/13/25 18:39, Philippe Mathieu-Daudé wrote:
>>>>> arm_cpu_has_feature() is equivalent of arm_feature(), however
>>>>> while the latter uses CPUARMState so is target-specific, the
>>>>> former doesn't and can be called by target-agnostic code in hw/.
>>>>
>>>> CPUARMState is no more target-specific than ARMCPU.
>>>
>>> ARMCPU is forward-declared as opaque pointer in target/arm/cpu-qom.h,
>>> so we can expose prototypes using it to non-ARM units.
>>> CPUARMState is only declared in "cpu.h", itself only accessible by
>>> ARM-related units.
>>>
>>
>> Maybe we can simply postpone introduction of arm_cpu_has_feature() when
>> it will be really needed.
>>
>> Patches 17 and 18 are not strictly needed, as cpu.h (which resolves to
>> target/arm/cpu.h implicitely) is perfectly accessible to code in hw/arm
>> without any problem.
> 
> OK.
> 
> Peter, would you be OK to take reviewed patches #1 up to #15 (the
> previous one) or do you rather I respin them?
>

In case you respin, feel free to include the base series, so we can 
combine both.

> Regards,
> 
> Phil.



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 16/19] target/arm: Add arm_cpu_has_feature() helper
  2025-05-15 15:22           ` Pierrick Bouvier
@ 2025-05-15 16:14             ` Philippe Mathieu-Daudé
  2025-05-15 16:20               ` Pierrick Bouvier
  0 siblings, 1 reply; 37+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-05-15 16:14 UTC (permalink / raw)
  To: Pierrick Bouvier, Peter Maydell; +Cc: qemu-arm, Richard Henderson, qemu-devel

On 15/5/25 17:22, Pierrick Bouvier wrote:
> On 5/15/25 4:05 AM, Philippe Mathieu-Daudé wrote:
>> On 14/5/25 18:59, Pierrick Bouvier wrote:
>>> On 5/14/25 9:53 AM, Philippe Mathieu-Daudé wrote:
>>>> On 14/5/25 10:24, Richard Henderson wrote:
>>>>> On 5/13/25 18:39, Philippe Mathieu-Daudé wrote:
>>>>>> arm_cpu_has_feature() is equivalent of arm_feature(), however
>>>>>> while the latter uses CPUARMState so is target-specific, the
>>>>>> former doesn't and can be called by target-agnostic code in hw/.
>>>>>
>>>>> CPUARMState is no more target-specific than ARMCPU.
>>>>
>>>> ARMCPU is forward-declared as opaque pointer in target/arm/cpu-qom.h,
>>>> so we can expose prototypes using it to non-ARM units.
>>>> CPUARMState is only declared in "cpu.h", itself only accessible by
>>>> ARM-related units.
>>>>
>>>
>>> Maybe we can simply postpone introduction of arm_cpu_has_feature() when
>>> it will be really needed.
>>>
>>> Patches 17 and 18 are not strictly needed, as cpu.h (which resolves to
>>> target/arm/cpu.h implicitely) is perfectly accessible to code in hw/arm
>>> without any problem.
>>
>> OK.
>>
>> Peter, would you be OK to take reviewed patches #1 up to #15 (the
>> previous one) or do you rather I respin them?
>>
> 
> In case you respin, feel free to include the base series, so we can 
> combine both.

Isn't the base already pulled in by Peter? I thought it was:

https://lore.kernel.org/qemu-devel/20250515102546.2149601-1-peter.maydell@linaro.org/


^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 16/19] target/arm: Add arm_cpu_has_feature() helper
  2025-05-15 16:14             ` Philippe Mathieu-Daudé
@ 2025-05-15 16:20               ` Pierrick Bouvier
  0 siblings, 0 replies; 37+ messages in thread
From: Pierrick Bouvier @ 2025-05-15 16:20 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, Peter Maydell
  Cc: qemu-arm, Richard Henderson, qemu-devel

On 5/15/25 9:14 AM, Philippe Mathieu-Daudé wrote:
> On 15/5/25 17:22, Pierrick Bouvier wrote:
>> On 5/15/25 4:05 AM, Philippe Mathieu-Daudé wrote:
>>> On 14/5/25 18:59, Pierrick Bouvier wrote:
>>>> On 5/14/25 9:53 AM, Philippe Mathieu-Daudé wrote:
>>>>> On 14/5/25 10:24, Richard Henderson wrote:
>>>>>> On 5/13/25 18:39, Philippe Mathieu-Daudé wrote:
>>>>>>> arm_cpu_has_feature() is equivalent of arm_feature(), however
>>>>>>> while the latter uses CPUARMState so is target-specific, the
>>>>>>> former doesn't and can be called by target-agnostic code in hw/.
>>>>>>
>>>>>> CPUARMState is no more target-specific than ARMCPU.
>>>>>
>>>>> ARMCPU is forward-declared as opaque pointer in target/arm/cpu-qom.h,
>>>>> so we can expose prototypes using it to non-ARM units.
>>>>> CPUARMState is only declared in "cpu.h", itself only accessible by
>>>>> ARM-related units.
>>>>>
>>>>
>>>> Maybe we can simply postpone introduction of arm_cpu_has_feature() when
>>>> it will be really needed.
>>>>
>>>> Patches 17 and 18 are not strictly needed, as cpu.h (which resolves to
>>>> target/arm/cpu.h implicitely) is perfectly accessible to code in hw/arm
>>>> without any problem.
>>>
>>> OK.
>>>
>>> Peter, would you be OK to take reviewed patches #1 up to #15 (the
>>> previous one) or do you rather I respin them?
>>>
>>
>> In case you respin, feel free to include the base series, so we can
>> combine both.
> 
> Isn't the base already pulled in by Peter? I thought it was:
>

Oh, I missed it, thanks.

> https://lore.kernel.org/qemu-devel/20250515102546.2149601-1-peter.maydell@linaro.org/



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 00/19] target/arm: More header rework around arm_feature() & multiprocessing.h
  2025-05-13 17:39 [PATCH 00/19] target/arm: More header rework around arm_feature() & multiprocessing.h Philippe Mathieu-Daudé
                   ` (19 preceding siblings ...)
  2025-05-13 17:42 ` [PATCH 00/19] target/arm: More header rework around arm_feature() & multiprocessing.h Philippe Mathieu-Daudé
@ 2025-05-29 15:37 ` Peter Maydell
  20 siblings, 0 replies; 37+ messages in thread
From: Peter Maydell @ 2025-05-29 15:37 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: qemu-devel, qemu-arm, Richard Henderson, Pierrick Bouvier

On Tue, 13 May 2025 at 18:39, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>
> Before I respin my "single-binary: Make hw/arm/ common" [1] I'm
> extracting these random cleanup patches. Some aren't necessary
> anymore because now units in arm_common_ss[] can access "cpu.h",
> but the patches are reviewed and simplify a bit IMO.
>
> Based-on: <20250512180502.2395029-1-pierrick.bouvier@linaro.org>
>           "single-binary: compile target/arm twice"
>
> [1] https://lore.kernel.org/qemu-devel/20250403235821.9909-1-philmd@linaro.org/
>
> Philippe Mathieu-Daudé (19):
>   target/arm/tcg-stubs: compile file once (system)
>   target/arm/hvf_arm: Avoid using poisoned CONFIG_HVF definition
>   target/arm: Only link with zlib when TCG is enabled
>   target/arm/cpregs: Include missing 'target/arm/cpu.h' header
>   hw/arm/boot: Include missing 'system/memory.h' header
>   target/arm/cpu-features: Include missing 'cpu.h' header
>   target/arm/qmp: Include missing 'cpu.h' header
>   target/arm/kvm: Include missing 'cpu-qom.h' header
>   target/arm/hvf: Include missing 'cpu-qom.h' header

Hi; I've applied these patches to target-arm.next.

>   hw/arm: Remove unnecessary 'cpu.h' header

After this patch things fail to compile:

../../hw/arm/exynos4210.c:511:20: error: use of undeclared identifier
'ARM_AFF1_SHIFT'
  511 |     return (0x9 << ARM_AFF1_SHIFT) | cpu;

../../hw/arm/mps3r.c:295:14: error: use of undeclared identifier
'GTIMER_PHYS'; did you mean 'ITIMER_PROF'?
  295 |             [GTIMER_PHYS] = ARCH_TIMER_NS_EL1_IRQ,

etc. Probably this patch needs to go later in the series.

>   target/arm: Restrict inclusion of 'multiprocessing.h'

Starting somewhere around here the patches don't apply any
more (trivial rebase conflicts, I think, but given the compile
error above I didn't spend time on trying to sort them out).

>   target/arm: Move some definitions from 'cpu.h' to 'multiprocessing.h'

>   hw/arm: Include missing 'target/arm/gtimer.h' header
>   target/arm: Extract PSCI definitions to 'psci.h'
>   target/arm: Extract feature definitions to 'cpu_has_feature.h' header
>   target/arm: Add arm_cpu_has_feature() helper
>   hw/arm/realview: Replace arm_feature() -> arm_cpu_has_feature()
>   hw/arm/virt-acpi: Replace arm_feature() -> arm_cpu_has_feature()
>   target/arm: Always include full path to 'cpu.h'

I'm not sure about the arm_cpu_has_feature() patches at
the tail end of the series, and there seemed to be some
review comments to the effect that maybe we don't need
them any more?

thanks
-- PMM


^ permalink raw reply	[flat|nested] 37+ messages in thread

end of thread, other threads:[~2025-05-29 15:38 UTC | newest]

Thread overview: 37+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-13 17:39 [PATCH 00/19] target/arm: More header rework around arm_feature() & multiprocessing.h Philippe Mathieu-Daudé
2025-05-13 17:39 ` [PATCH 01/19] target/arm/tcg-stubs: compile file once (system) Philippe Mathieu-Daudé
2025-05-13 17:43   ` Philippe Mathieu-Daudé
2025-05-13 22:59   ` Pierrick Bouvier
2025-05-14  8:18   ` Richard Henderson
2025-05-13 17:39 ` [PATCH 02/19] target/arm/hvf_arm: Avoid using poisoned CONFIG_HVF definition Philippe Mathieu-Daudé
2025-05-13 22:58   ` Pierrick Bouvier
2025-05-14  8:19   ` Richard Henderson
2025-05-13 17:39 ` [PATCH 03/19] target/arm: Only link with zlib when TCG is enabled Philippe Mathieu-Daudé
2025-05-13 22:58   ` Pierrick Bouvier
2025-05-13 17:39 ` [PATCH 04/19] target/arm/cpregs: Include missing 'target/arm/cpu.h' header Philippe Mathieu-Daudé
2025-05-13 17:39 ` [PATCH 05/19] hw/arm/boot: Include missing 'system/memory.h' header Philippe Mathieu-Daudé
2025-05-13 17:39 ` [PATCH 06/19] target/arm/cpu-features: Include missing 'cpu.h' header Philippe Mathieu-Daudé
2025-05-13 17:39 ` [PATCH 07/19] target/arm/qmp: " Philippe Mathieu-Daudé
2025-05-13 17:39 ` [PATCH 08/19] target/arm/kvm: Include missing 'cpu-qom.h' header Philippe Mathieu-Daudé
2025-05-13 17:39 ` [PATCH 09/19] target/arm/hvf: " Philippe Mathieu-Daudé
2025-05-13 17:39 ` [PATCH 10/19] hw/arm: Remove unnecessary 'cpu.h' header Philippe Mathieu-Daudé
2025-05-13 17:39 ` [PATCH 11/19] target/arm: Restrict inclusion of 'multiprocessing.h' Philippe Mathieu-Daudé
2025-05-13 17:39 ` [PATCH 12/19] target/arm: Move some definitions from 'cpu.h' to 'multiprocessing.h' Philippe Mathieu-Daudé
2025-05-13 17:39 ` [PATCH 13/19] hw/arm: Include missing 'target/arm/gtimer.h' header Philippe Mathieu-Daudé
2025-05-13 17:39 ` [PATCH 14/19] target/arm: Extract PSCI definitions to 'psci.h' Philippe Mathieu-Daudé
2025-05-13 17:39 ` [PATCH 15/19] target/arm: Extract feature definitions to 'cpu_has_feature.h' header Philippe Mathieu-Daudé
2025-05-13 17:39 ` [PATCH 16/19] target/arm: Add arm_cpu_has_feature() helper Philippe Mathieu-Daudé
2025-05-14  8:24   ` Richard Henderson
2025-05-14 16:53     ` Philippe Mathieu-Daudé
2025-05-14 16:59       ` Pierrick Bouvier
2025-05-15 11:05         ` Philippe Mathieu-Daudé
2025-05-15 15:22           ` Pierrick Bouvier
2025-05-15 16:14             ` Philippe Mathieu-Daudé
2025-05-15 16:20               ` Pierrick Bouvier
2025-05-13 17:39 ` [PATCH 17/19] hw/arm/realview: Replace arm_feature() -> arm_cpu_has_feature() Philippe Mathieu-Daudé
2025-05-13 17:39 ` [PATCH 18/19] hw/arm/virt-acpi: " Philippe Mathieu-Daudé
2025-05-13 17:39 ` [PATCH 19/19] target/arm: Always include full path to 'cpu.h' Philippe Mathieu-Daudé
2025-05-13 22:57   ` Pierrick Bouvier
2025-05-13 17:42 ` [PATCH 00/19] target/arm: More header rework around arm_feature() & multiprocessing.h Philippe Mathieu-Daudé
2025-05-13 23:00   ` Pierrick Bouvier
2025-05-29 15:37 ` Peter Maydell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).