Skip to contentSkip to conversation

target/arm: More header rework around arm_feature() & multiprocessing.h

PATCH In review Philippe Mathieu-Daudé 4 participants 37 messages May 13, 2025 – May 29, 2025

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

cover target/arm: More header rework around arm_feature() & multiprocessing.h

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: <[email protected]>
"single-binary: compile target/arm twice"

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

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
Signature · 1 line
2.47.1
#1 lore raw

PATCH 1/19 target/arm/tcg-stubs: compile file once (system)

---
 target/arm/meson.build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/arm/meson.build +1 -1
index b404fa54863..e568dfb706a 100644
@@ -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}
Signature · 1 line
2.47.1
#2 lore raw

Re: [PATCH 01/19] target/arm/tcg-stubs: compile file once (system)

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

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

Quoted 18 lines
---
  target/arm/meson.build | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
target/arm/meson.build +1 -1
index b404fa54863..e568dfb706a 100644
@@ -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 on v1 1/19
#4 lore raw

Re: [PATCH 01/19] target/arm/tcg-stubs: compile file once (system)

In reply to Philippe Mathieu-Daudé
Quoted 10 lines · Philippe Mathieu-Daudé
---
  target/arm/meson.build | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
target/arm/meson.build +0 -0
index b404fa54863..e568dfb706a 100644

target/arm/meson.build subdir('hvf') · line 54

Quoted 8 lines
target/arm/meson.build +1 -1
@@ -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}

r~

#5 lore raw

PATCH 2/19 target/arm/hvf_arm: Avoid using poisoned CONFIG_HVF definition

In reply to Philippe Mathieu-Daudé

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

---
 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
MAINTAINERS +1 -0
index 6dacd6d004d..7431f88b5d9 100644
@@ -509,6 +509,7 @@ Apple Silicon HVF CPUs
 M: Alexander Graf <[email protected]>
 S: Maintained
 F: target/arm/hvf/
+F: target/arm/hvf-stub.c
 
 X86 HVF CPUs
 M: Cameron Esfahani <[email protected]>
target/arm/hvf_arm.h +0 -16
index 26c717b3826..7a44e092620 100644
@@ -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
target/arm/hvf-stub.c new file +20 -0
new file mode 100644
index 00000000000..ff137267a03
@@ -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();
+}
target/arm/meson.build +1 -0
index e568dfb706a..2747f4b404c 100644
@@ -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',
Signature · 1 line
2.47.1
Reviewed-by on v1 2/19
#6 lore raw

Re: [PATCH 02/19] target/arm/hvf_arm: Avoid using poisoned CONFIG_HVF definition

Quoted 11 lines · Philippe Mathieu-Daudé

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

---
  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 on v1 2/19
#7 lore raw

Re: [PATCH 02/19] target/arm/hvf_arm: Avoid using poisoned CONFIG_HVF definition

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

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

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

r~

#8 lore raw

PATCH 3/19 target/arm: Only link with zlib when TCG is enabled

In reply to Philippe Mathieu-Daudé

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

---
 target/arm/meson.build     | 1 -
 target/arm/tcg/meson.build | 2 ++
 2 files changed, 2 insertions(+), 1 deletion(-)
target/arm/meson.build +0 -1
index 2747f4b404c..dcba4ef3792 100644
@@ -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',
target/arm/tcg/meson.build +2 -0
index 2d1502ba882..c59f0f03a1b 100644
@@ -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',
Signature · 1 line
2.47.1
Reviewed-by on v1 3/19
#9 lore raw

Re: [PATCH 03/19] target/arm: Only link with zlib when TCG is enabled

Quoted 9 lines · Philippe Mathieu-Daudé

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

---
  target/arm/meson.build     | 1 -
  target/arm/tcg/meson.build | 2 ++
  2 files changed, 2 insertions(+), 1 deletion(-)
#10 lore raw

PATCH 4/19 target/arm/cpregs: Include missing 'target/arm/cpu.h' header

In reply to 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);
                            ^
---
 target/arm/cpregs.h | 1 +
 1 file changed, 1 insertion(+)
target/arm/cpregs.h +1 -0
index 2183de8eda6..c1a7ae37356 100644
@@ -23,6 +23,7 @@
 
 #include "hw/registerfields.h"
 #include "target/arm/kvm-consts.h"
+#include "cpu.h"
 
 /*
  * ARMCPRegInfo type field bits:
Signature · 1 line
2.47.1
#11 lore raw

PATCH 5/19 hw/arm/boot: Include missing 'system/memory.h' header

In reply to 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,
    ^
---
 hw/arm/boot.c | 1 +
 1 file changed, 1 insertion(+)
hw/arm/boot.c +1 -0
index f94b940bc31..79afb51b8a5 100644
@@ -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"
Signature · 1 line
2.47.1
#12 lore raw

PATCH 6/19 target/arm/cpu-features: Include missing 'cpu.h' header

In reply to 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;
        |            ^
---
 target/arm/cpu-features.h | 1 +
 1 file changed, 1 insertion(+)
target/arm/cpu-features.h +1 -0
index 525e4cee12f..4452e7c21e3 100644
@@ -22,6 +22,7 @@
 
 #include "hw/registerfields.h"
 #include "qemu/host-utils.h"
+#include "cpu.h"
 
 /*
  * Naming convention for isar_feature functions:
Signature · 1 line
2.47.1
#13 lore raw

PATCH 7/19 target/arm/qmp: Include missing 'cpu.h' header

In reply to 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);
        |                   ^
---
 target/arm/arm-qmp-cmds.c | 1 +
 1 file changed, 1 insertion(+)
target/arm/arm-qmp-cmds.c +1 -0
index a1a944adb43..930ec37413d 100644
@@ -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)
 {
Signature · 1 line
2.47.1
#14 lore raw

PATCH 8/19 target/arm/kvm: Include missing 'cpu-qom.h' header

In reply to 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);
        |                             ^
---
 target/arm/kvm_arm.h | 1 +
 1 file changed, 1 insertion(+)
target/arm/kvm_arm.h +1 -0
index c4178d1327c..7dc83caed5c 100644
@@ -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)
Signature · 1 line
2.47.1
#15 lore raw

PATCH 9/19 target/arm/hvf: Include missing 'cpu-qom.h' header

In reply to 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);
        |                                         ^
---
 target/arm/hvf_arm.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/arm/hvf_arm.h +1 -1
index 7a44e092620..ea82f2691df 100644
@@ -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
Signature · 1 line
2.47.1
#16 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 6 lines · Philippe Mathieu-Daudé

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

#17 lore raw
Quoted 10 lines · Philippe Mathieu-Daudé
Quoted 6 lines · Philippe Mathieu-Daudé

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

#18 lore raw

PATCH 10/19 hw/arm: Remove unnecessary 'cpu.h' header

In reply to Philippe Mathieu-Daudé
---
 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(-)
hw/arm/exynos4210.c +0 -1
index 76001ff0dfc..56267ec2bd2 100644
@@ -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"
hw/arm/highbank.c +0 -1
index 3ae26ebebdc..5b2719555af 100644
@@ -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
hw/arm/mps3r.c +0 -1
index 48c73acc62e..889d291401e 100644
@@ -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"
hw/arm/smmuv3.c +0 -1
index ab679723533..37b39c9f84f 100644
@@ -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"
Signature · 1 line
2.47.1
#19 lore raw

PATCH 11/19 target/arm: Restrict inclusion of 'multiprocessing.h'

In reply to Philippe Mathieu-Daudé

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

---
 target/arm/cpu.h | 1 -
 target/arm/cpu.c | 1 +
 2 files changed, 1 insertion(+), 1 deletion(-)
target/arm/cpu.h +0 -1
index 6ed6409cb7a..33ac0c9f818 100644
@@ -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 */
target/arm/cpu.c +1 -0
index a604e4ccac8..8c9d161f2ef 100644
@@ -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)
 {
Signature · 1 line
2.47.1
#20 lore raw

PATCH 12/19 target/arm: Move some definitions from 'cpu.h' to 'multiprocessing.h'

In reply to 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.

---
 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(-)
target/arm/cpu.h +0 -17
index 33ac0c9f818..b70c7a3ecd2 100644
@@ -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;
 
target/arm/multiprocessing.h +18 -0
index 81715d345c2..8eec79b11d8 100644
@@ -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
hw/arm/aspeed_ast2600.c +1 -0
index d12707f0abe..62a9200dac6 100644
@@ -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
hw/arm/aspeed_ast27x0.c +1 -0
index 1974a257660..a38c2a19751 100644
@@ -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
hw/arm/exynos4210.c +1 -0
index 56267ec2bd2..e83a88d3369 100644
@@ -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
 
hw/arm/npcm8xx.c +1 -0
index d7ee306de7a..e6c16537eef 100644
@@ -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
hw/arm/sbsa-ref.c +1 -0
index deae5cf9861..25ffb029ff4 100644
@@ -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)
hw/vmapple/vmapple.c +1 -0
index 16e6110b68f..47f23b6e2c0 100644
@@ -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;
target/arm/kvm.c +1 -0
index a08a269ad61..5969249b579 100644
@@ -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[] = {
Signature · 1 line
2.47.1
#21 lore raw

PATCH 13/19 hw/arm: Include missing 'target/arm/gtimer.h' header

In reply to Philippe Mathieu-Daudé
---
 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(+)
hw/arm/aspeed_ast27x0.c +1 -0
index a38c2a19751..ad017237f3f 100644
@@ -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
hw/arm/bcm2838.c +1 -0
index 22aa754613c..20709bf19e8 100644
@@ -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
hw/arm/exynos4210.c +1 -0
index e83a88d3369..24b3c0b5d29 100644
@@ -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
hw/arm/fsl-imx8mp.c +1 -0
index 23e662c16ca..3528adb90f1 100644
@@ -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"
 
hw/arm/mps3r.c +1 -0
index 889d291401e..8c743be3cb5 100644
@@ -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 {
hw/arm/npcm8xx.c +1 -0
index e6c16537eef..7802768c384 100644
@@ -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"
 
 /*
hw/vmapple/vmapple.c +1 -0
index 47f23b6e2c0..2dc5e15e791 100644
@@ -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 {
target/arm/tcg/op_helper.c +1 -0
index 575e566280b..073a8319fa5 100644
@@ -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
Signature · 1 line
2.47.1
#22 lore raw

PATCH 14/19 target/arm: Extract PSCI definitions to 'psci.h'

In reply to 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.

---
 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
include/hw/arm/boot.h +2 -1
index b12bf61ca81..648fdb88862 100644
@@ -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;
target/arm/cpu.h +2 -5
index b70c7a3ecd2..116745975fa 100644
@@ -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 */
target/arm/psci.h new file +18 -0
new file mode 100644
index 00000000000..8b868dfbb91
@@ -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
hw/arm/bananapi_m2u.c +1 -0
index b750a575f72..61e01a38099 100644
@@ -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;
 
hw/arm/boot.c +1 -0
index 79afb51b8a5..b81a850819b 100644
@@ -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
hw/arm/highbank.c +1 -0
index 5b2719555af..0ce39877822 100644
@@ -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
hw/arm/imx8mp-evk.c +1 -0
index b3082fa60d8..81fe0361ea7 100644
@@ -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)
hw/arm/mcimx6ul-evk.c +1 -0
index 86982cb0772..be5e50abf17 100644
@@ -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)
 {
hw/arm/mcimx7d-sabre.c +1 -0
index 33119610113..e0f25b92594 100644
@@ -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)
 {
hw/arm/orangepi.c +1 -0
index e0956880d11..99037a09a36 100644
@@ -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;
 
hw/arm/sbsa-ref.c +1 -0
index 25ffb029ff4..d5ce15b688f 100644
@@ -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)
hw/arm/virt-acpi-build.c +1 -0
index 7e8e0f0298d..20dc93fbc54 100644
@@ -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
 
hw/arm/virt.c +1 -0
index 9a6cd085a37..d110cb07943 100644
@@ -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"
hw/arm/xlnx-versal-virt.c +1 -0
index adadbb72902..7e1b93b782d 100644
@@ -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")
hw/arm/xlnx-zcu102.c +1 -0
index 14b6641a713..c46bf11ce24 100644
@@ -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;
hw/vmapple/vmapple.c +1 -0
index 2dc5e15e791..b61f5ea51a4 100644
@@ -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;
target/arm/helper.c +1 -0
index 76312102879..7859729c39f 100644
@@ -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"
target/arm/hvf/hvf.c +1 -0
index 42258cc2d88..8fbd4c4be59 100644
@@ -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"
 
target/arm/tcg/op_helper.c +1 -0
index 073a8319fa5..e0f9c91450a 100644
@@ -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
target/arm/tcg/psci.c +1 -0
index cabed43e8a8..0313cdd6ba2 100644
@@ -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)
 {
Signature · 1 line
2.47.1
#23 lore raw

PATCH 15/19 target/arm: Extract feature definitions to 'cpu_has_feature.h' header

In reply to Philippe Mathieu-Daudé
---
 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
target/arm/cpu.h +1 -53
index 116745975fa..cf3ff21965c 100644
@@ -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;
target/arm/cpu_has_feature.h new file +65 -0

65 lines not on this page · raw message

Signature · 1 line
2.47.1
#24 lore raw

PATCH 16/19 target/arm: Add arm_cpu_has_feature() helper

In reply to 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/.

---
 target/arm/cpu_has_feature.h | 2 ++
 target/arm/cpu.c             | 7 +++++++
 2 files changed, 9 insertions(+)
target/arm/cpu_has_feature.h +2 -0
index 2adfccd9208..352f9d75bed 100644
@@ -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
target/arm/cpu.c +7 -0
index 8c9d161f2ef..759636a3b0e 100644
@@ -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);
Signature · 1 line
2.47.1
#25 lore raw

Re: [PATCH 16/19] target/arm: Add arm_cpu_has_feature() helper

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

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~

Quoted 37 lines
---
  target/arm/cpu_has_feature.h | 2 ++
  target/arm/cpu.c             | 7 +++++++
  2 files changed, 9 insertions(+)
target/arm/cpu_has_feature.h +2 -0
index 2adfccd9208..352f9d75bed 100644
@@ -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
target/arm/cpu.c +7 -0
index 8c9d161f2ef..759636a3b0e 100644
@@ -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);
#26 lore raw

Re: [PATCH 16/19] target/arm: Add arm_cpu_has_feature() helper

Quoted 6 lines · Richard Henderson
Quoted 3 lines · 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/.

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.

Quoted 43 lines

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

r~

Quoted 35 lines

---
  target/arm/cpu_has_feature.h | 2 ++
  target/arm/cpu.c             | 7 +++++++

  2 files changed, 9 insertions(+)
target/arm/cpu_has_feature.h +0 -0
index 2adfccd9208..352f9d75bed 100644
@@ -62,4 +62,6 @@ typedef enum arm_features {

      ARM_FEATURE_BACKCOMPAT_CNTFRQ, /* 62.5MHz timer default */ } ArmCpuFeature;

target/arm/cpu_has_feature.h +2 -0
+bool arm_cpu_has_feature(ARMCPU *cpu, ArmCpuFeature feature);
+

  #endif

target/arm/cpu.c +7 -0
index 8c9d161f2ef..759636a3b0e 100644
@@ -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);
#27 lore raw

Re: [PATCH 16/19] target/arm: Add arm_cpu_has_feature() helper

Quoted 6 lines · Philippe Mathieu-Daudé
Quoted 5 lines · Richard Henderson
Quoted 3 lines · 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/.

Quoted 7 lines
Quoted 1 line

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.

Quoted 44 lines
Quoted 43 lines

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

r~

Quoted 35 lines
---
   target/arm/cpu_has_feature.h | 2 ++
   target/arm/cpu.c             | 7 +++++++
   2 files changed, 9 insertions(+)
target/arm/cpu_has_feature.h +2 -0
index 2adfccd9208..352f9d75bed 100644
@@ -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
target/arm/cpu.c +7 -0
index 8c9d161f2ef..759636a3b0e 100644
@@ -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);
#28 lore raw

Re: [PATCH 16/19] target/arm: Add arm_cpu_has_feature() helper

Quoted 15 lines · Pierrick Bouvier
Quoted 6 lines · Philippe Mathieu-Daudé
Quoted 5 lines · Richard Henderson
Quoted 3 lines · 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/.

Quoted 7 lines
Quoted 1 line

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.

Quoted 3 lines

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.

#29 lore raw

Re: [PATCH 16/19] target/arm: Add arm_cpu_has_feature() helper

Quoted 19 lines · Philippe Mathieu-Daudé
Quoted 18 lines · Pierrick Bouvier
Quoted 6 lines · Philippe Mathieu-Daudé
Quoted 5 lines · Richard Henderson
Quoted 3 lines · 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/.

Quoted 7 lines
Quoted 1 line

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.

Quoted 9 lines
Quoted 3 lines

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.

Quoted 3 lines

Regards,

Phil.

#30 lore raw

Re: [PATCH 16/19] target/arm: Add arm_cpu_has_feature() helper

Quoted 24 lines · Pierrick Bouvier
Quoted 23 lines · Philippe Mathieu-Daudé
Quoted 21 lines · Pierrick Bouvier
Quoted 6 lines · Philippe Mathieu-Daudé
Quoted 5 lines · Richard Henderson
Quoted 3 lines · 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/.

Quoted 7 lines
Quoted 1 line

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.

Quoted 7 lines
Quoted 5 lines

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

#31 lore raw

Re: [PATCH 16/19] target/arm: Add arm_cpu_has_feature() helper

Quoted 27 lines · Philippe Mathieu-Daudé
Quoted 26 lines · Pierrick Bouvier
Quoted 25 lines · Philippe Mathieu-Daudé
Quoted 15 lines · Pierrick Bouvier
Quoted 6 lines · Philippe Mathieu-Daudé
Quoted 5 lines · Richard Henderson
Quoted 3 lines · 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/.

Quoted 7 lines
Quoted 1 line

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.

Quoted 6 lines

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.

Quoted 9 lines
Quoted 6 lines
Quoted 3 lines

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.

Quoted 1 line

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

#32 lore raw

PATCH 17/19 hw/arm/realview: Replace arm_feature() -> arm_cpu_has_feature()

In reply to Philippe Mathieu-Daudé

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

---
 hw/arm/realview.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
hw/arm/realview.c +4 -6
index 5c9050490b4..4c0a8b42709 100644
@@ -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;
Signature · 1 line
2.47.1
#33 lore raw

PATCH 18/19 hw/arm/virt-acpi: Replace arm_feature() -> arm_cpu_has_feature()

In reply to Philippe Mathieu-Daudé

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

---
 hw/arm/virt-acpi-build.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/arm/virt-acpi-build.c +2 -1
index 20dc93fbc54..cc4ec7ad465 100644
@@ -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) {
Signature · 1 line
2.47.1
#34 lore raw

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

In reply to Philippe Mathieu-Daudé

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

---
 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(-)
target/arm/cpregs.h +1 -1
index c1a7ae37356..25a7c2928ba 100644
@@ -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:
target/arm/cpu-features.h +1 -1
index 4452e7c21e3..90c5efd6eac 100644
@@ -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:
target/arm/tcg/translate.h +1 -1
index 1bfdb0fb9bb..f8eb0d4a5a8 100644
@@ -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"
target/arm/arch_dump.c +1 -1
index 1dd79849c13..9c90430d1b6 100644
@@ -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"
target/arm/arm-powerctl.c +1 -1
index 20c70c7d6bb..4cffe557e37 100644
@@ -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"
target/arm/arm-qmp-cmds.c +1 -1
index 930ec37413d..392887d3b48 100644
@@ -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)
 {
target/arm/cortex-regs.c +1 -1
index ae817b08ddf..2caa8855f02 100644
@@ -7,7 +7,7 @@
  */
 
 #include "qemu/osdep.h"
-#include "cpu.h"
+#include "target/arm/cpu.h"
 #include "cpregs.h"
 
 
target/arm/cpu.c +1 -1
index 759636a3b0e..00f06916e62 100644
@@ -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"
target/arm/cpu64.c +1 -1
index 00629a5d1d1..34f43094da9 100644
@@ -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"
target/arm/debug_helper.c +1 -1
index 69fb1d0d9ff..a6199a73740 100644
@@ -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"
target/arm/gdbstub.c +1 -1
index ce4497ad7c3..d148d8434f1 100644
@@ -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"
target/arm/gdbstub64.c +1 -1
index 64ee9b3b567..b6033f431d8 100644
@@ -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"
target/arm/helper.c +1 -1
index 7859729c39f..05a50c5c750 100644
@@ -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"
target/arm/hyp_gdbstub.c +1 -1
index bb5969720ce..73c9a9a8333 100644
@@ -10,7 +10,7 @@
  */
 
 #include "qemu/osdep.h"
-#include "cpu.h"
+#include "target/arm/cpu.h"
 #include "internals.h"
 #include "gdbstub/enums.h"
 
target/arm/kvm-stub.c +1 -1
index 34e57fab011..532018b745e 100644
@@ -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)
target/arm/kvm.c +1 -1
index 5969249b579..d280d08a63e 100644
@@ -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"
target/arm/machine.c +1 -1
index e442d485241..f0524615fe1 100644
@@ -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"
target/arm/ptw.c +1 -1
index 44170d831cc..03047d10d87 100644
@@ -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"
target/arm/tcg-stubs.c +1 -1
index 5e5166c0490..672b5b01db0 100644
@@ -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)
target/arm/tcg/cpu-v7m.c +1 -1
index 95b23d9b55d..9b7108d9678 100644
@@ -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"
 
target/arm/tcg/cpu32.c +1 -1
index 2c45b7eddda..5bf78d9240a 100644
@@ -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"
target/arm/tcg/cpu64.c +1 -1
index 29ab0ac79da..c95036df2a5 100644
@@ -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"
target/arm/tcg/helper-a64.c +1 -1
index 4f618ae390e..1713348a55d 100644
@@ -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"
target/arm/tcg/hflags.c +1 -1
index 1ccec63bbd4..d77eacb7338 100644
@@ -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"
target/arm/tcg/iwmmxt_helper.c +1 -1
index ba054b6b4db..3489f6d01c3 100644
@@ -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"
target/arm/tcg/m_helper.c +1 -1
index 6614719832e..5d657f5c753 100644
@@ -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"
target/arm/tcg/mte_helper.c +1 -1
index 0efc18a181e..66e90b03520 100644
@@ -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
target/arm/tcg/mve_helper.c +1 -1
index 506d1c34757..105fc0a4b9d 100644
@@ -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"
target/arm/tcg/neon_helper.c +1 -1
index 2cc8241f1e4..44f1aafd17d 100644
@@ -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"
target/arm/tcg/op_helper.c +1 -1
index e0f9c91450a..3a4a76e999e 100644
@@ -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"
target/arm/tcg/pauth_helper.c +1 -1
index c591c3052c3..0ae329710ac 100644
@@ -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"
target/arm/tcg/psci.c +1 -1
index 0313cdd6ba2..05ecd647c9f 100644
@@ -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"
target/arm/tcg/sme_helper.c +1 -1
index de0c6e54d4b..a2104b4751d 100644
@@ -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"
target/arm/tcg/sve_helper.c +1 -1
index a2c363a4e17..afd110431cd 100644
@@ -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"
target/arm/tcg/tlb-insns.c +1 -1
index 95c26c6d463..bc8353cdbb5 100644
@@ -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"
target/arm/tcg/tlb_helper.c +1 -1
index 23c72a99f5c..ea7d0c74c88 100644
@@ -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"
 
target/arm/tcg/vec_helper.c +1 -1
index 986eaf8ffa4..9e2715e34de 100644
@@ -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"
target/arm/tcg/vfp_helper.c +1 -1
index b1324c5c0a6..ac532ef8511 100644
@@ -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"
target/arm/vfp_fpscr.c +1 -1
index 92ea60ebbf2..a196bcfa803 100644
@@ -18,7 +18,7 @@
  */
 
 #include "qemu/osdep.h"
-#include "cpu.h"
+#include "target/arm/cpu.h"
 #include "internals.h"
 #include "cpu-features.h"
 
Signature · 1 line
2.47.1
Reviewed-by on v1 19/19
#35 lore raw

Re: [PATCH 19/19] target/arm: Always include full path to 'cpu.h'

Quoted 38 lines · Philippe Mathieu-Daudé

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

---
  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 +-
Quoted 8 lines
  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(-)
#36 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 11 lines · 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: <[email protected]>
"single-binary: compile target/arm twice"

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

Quoted 10 lines

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.

Quoted 1 line

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.

Quoted 1 line

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

Quoted 9 lines

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