Skip to contentSkip to conversation

exec/cpu-common.h: Reduce header list further

PATCH Applied Philippe Mathieu-Daudé 2 participants 12 messages Jun 17 – Jun 18

lore
Share & tools
lore
#0 lore raw

cover exec/cpu-common.h: Reduce header list further

More trivial inclusion cleanups on a core header file.

Philippe Mathieu-Daudé (5):
target/sparc: Include missing 'accel/tcg/cpu-ops.h' header in cpu.c exec/cpu-common.h: Include missing 'qemu/thread.h' header exec/cpu-common.h: Avoid including unused 'exec/vaddr.h' header exec/cpu-common.h: Avoid including unused 'tcg/debug-assert.h' header exec/cpu-common.h: Avoid including unused exec/page-protection.h
header

 include/exec/cpu-common.h      | 4 +---
 linux-user/qemu.h              | 1 +
 target/ppc/mmu-hash32.h        | 1 +
 hw/ppc/ppc_booke.c             | 1 +
 linux-user/arm/elfload.c       | 1 +
 linux-user/hppa/elfload.c      | 1 +
 linux-user/x86_64/elfload.c    | 1 +
 target/arm/tcg/cpregs-at.c     | 1 +
 target/loongarch/cpu_helper.c  | 1 +
 target/loongarch/tcg/tcg_cpu.c | 1 +
 target/ppc/cpu_init.c          | 1 +
 target/sparc/cpu.c             | 1 +
 12 files changed, 12 insertions(+), 3 deletions(-)
Signature · 1 line
2.53.0
#1 lore raw

PATCH 1/5 target/sparc: Include missing 'accel/tcg/cpu-ops.h' header in cpu.c

target/sparc/cpu.c implement a TCGCPUOps structure, which is defined in "accel/tcg/cpu-ops.h":

  1040 static const TCGCPUOps sparc_tcg_ops = {
  ...

While this header is currently included indirectly, make the inclusion explicit to avoid issue when refactoring unrelated headers.

---
 target/sparc/cpu.c | 1 +
 1 file changed, 1 insertion(+)
target/sparc/cpu.c +1 -0
index 3df199ada7b..13ebb122a38 100644
@@ -23,6 +23,7 @@
 #include "qemu/module.h"
 #include "qemu/qemu-print.h"
 #include "accel/tcg/cpu-mmu-index.h"
+#include "accel/tcg/cpu-ops.h"
 #include "exec/translation-block.h"
 #include "hw/core/qdev-properties.h"
 #include "qapi/visitor.h"
Signature · 1 line
2.53.0
Reviewed-by on v1 1/5
#2 lore raw

Re: [PATCH 1/5] target/sparc: Include missing 'accel/tcg/cpu-ops.h' header in cpu.c

Quoted 6 lines · Philippe Mathieu-Daudé

target/sparc/cpu.c implement a TCGCPUOps structure, which is defined in "accel/tcg/cpu-ops.h":

   1040 static const TCGCPUOps sparc_tcg_ops = {
   ...
Quoted 8 lines

While this header is currently included indirectly, make the inclusion explicit to avoid issue when refactoring unrelated headers.

---
  target/sparc/cpu.c | 1 +
  1 file changed, 1 insertion(+)

r~

#3 lore raw

PATCH 2/5 exec/cpu-common.h: Include missing 'qemu/thread.h' header

In reply to Philippe Mathieu-Daudé

Unfortunately we need to include "qemu/thread.h" -- which is currently indirectly pulled in -- to get the QemuMutex type definition:

extern QemuMutex qemu_cpu_list_lock;

---
 include/exec/cpu-common.h | 1 +
 1 file changed, 1 insertion(+)
include/exec/cpu-common.h +1 -0
index 74337d84640..8cddd32ca8b 100644
@@ -8,6 +8,7 @@
 #ifndef CPU_COMMON_H
 #define CPU_COMMON_H
 
+#include "qemu/thread.h"
 #include "exec/vaddr.h"
 #include "hw/core/cpu.h"
 #include "tcg/debug-assert.h"
Signature · 1 line
2.53.0
Reviewed-by on v1 2/5
#4 lore raw

Re: [PATCH 2/5] exec/cpu-common.h: Include missing 'qemu/thread.h' header

Quoted 16 lines · Philippe Mathieu-Daudé

Unfortunately we need to include "qemu/thread.h" -- which is currently indirectly pulled in -- to get the QemuMutex type definition:

   extern QemuMutex qemu_cpu_list_lock;
---
  include/exec/cpu-common.h | 1 +
  1 file changed, 1 insertion(+)
include/exec/cpu-common.h +0 -0
index 74337d84640..8cddd32ca8b 100644

include/exec/cpu-common.h line 14

Quoted 7 lines
include/exec/cpu-common.h +1 -0
@@ -8,6 +8,7 @@
  #ifndef CPU_COMMON_H
  #define CPU_COMMON_H
 
+#include "qemu/thread.h"
  #include "exec/vaddr.h"
  #include "hw/core/cpu.h"
  #include "tcg/debug-assert.h"

r~

#5 lore raw

PATCH 3/5 exec/cpu-common.h: Avoid including unused 'exec/vaddr.h' header

In reply to Philippe Mathieu-Daudé

We neglected to remove the "exec/vaddr.h" header when moving cpu_memory_rw_debug() around in commit e9048f099b3 ("exec/cpu:
Declare cpu_memory_rw_debug() in 'hw/core/cpu.h' and document").

---
 include/exec/cpu-common.h | 1 -
 1 file changed, 1 deletion(-)
include/exec/cpu-common.h +0 -1
index 8cddd32ca8b..7dc8cab3263 100644
@@ -9,7 +9,6 @@
 #define CPU_COMMON_H
 
 #include "qemu/thread.h"
-#include "exec/vaddr.h"
 #include "hw/core/cpu.h"
 #include "tcg/debug-assert.h"
 #include "exec/page-protection.h"
Signature · 1 line
2.53.0
Reviewed-by on v1 3/5
#6 lore raw

Re: [PATCH 3/5] exec/cpu-common.h: Avoid including unused 'exec/vaddr.h' header

Quoted 14 lines · Philippe Mathieu-Daudé

We neglected to remove the "exec/vaddr.h" header when moving cpu_memory_rw_debug() around in commit e9048f099b3 ("exec/cpu:
Declare cpu_memory_rw_debug() in 'hw/core/cpu.h' and document").

---
  include/exec/cpu-common.h | 1 -
  1 file changed, 1 deletion(-)
include/exec/cpu-common.h +0 -0
index 8cddd32ca8b..7dc8cab3263 100644

include/exec/cpu-common.h line 14

Quoted 7 lines
include/exec/cpu-common.h +0 -1
@@ -9,7 +9,6 @@
  #define CPU_COMMON_H
 
  #include "qemu/thread.h"
-#include "exec/vaddr.h"
  #include "hw/core/cpu.h"
  #include "tcg/debug-assert.h"
  #include "exec/page-protection.h"

r~

#7 lore raw

PATCH 4/5 exec/cpu-common.h: Avoid including unused 'tcg/debug-assert.h' header

In reply to Philippe Mathieu-Daudé

Since commit efe25c260cd ("include/exec: Split out accel/tcg/cpu-mmu-index.h") the "exec/cpu-common.h" isn't using anything defined in "tcg/debug-assert.h".

Include it in target/loongarch/tcg/tcg_cpu.c however, where it is required but included indirectly, otherwise we'd get:

target/loongarch/tcg/tcg_cpu.c:291:5: error: call to undeclared function 'tcg_debug_assert'

  291 |     tcg_debug_assert(!tcg_cflags_has(cs, CF_PCREL));
      |     ^
---
 include/exec/cpu-common.h      | 1 -
 target/loongarch/tcg/tcg_cpu.c | 1 +
 2 files changed, 1 insertion(+), 1 deletion(-)
include/exec/cpu-common.h +0 -1
index 7dc8cab3263..d1a04025363 100644
@@ -10,7 +10,6 @@
 
 #include "qemu/thread.h"
 #include "hw/core/cpu.h"
-#include "tcg/debug-assert.h"
 #include "exec/page-protection.h"
 
 #define EXCP_INTERRUPT  0x10000 /* async interruption */
target/loongarch/tcg/tcg_cpu.c +1 -0
index f556234d9d2..83291c22c2a 100644
@@ -13,6 +13,7 @@
 #include "accel/tcg/cpu-ops.h"
 #include "exec/translation-block.h"
 #include "exec/target_page.h"
+#include "tcg/debug-assert.h"
 #include "tcg_loongarch.h"
 #include "internals.h"
 
Signature · 1 line
2.53.0
Reviewed-by on v1 4/5
#8 lore raw

Re: [PATCH 4/5] exec/cpu-common.h: Avoid including unused 'tcg/debug-assert.h' header

Quoted 34 lines · Philippe Mathieu-Daudé

Since commit efe25c260cd ("include/exec: Split out accel/tcg/cpu-mmu-index.h") the "exec/cpu-common.h" isn't using anything defined in "tcg/debug-assert.h".

Include it in target/loongarch/tcg/tcg_cpu.c however, where it is required but included indirectly, otherwise we'd get:

   target/loongarch/tcg/tcg_cpu.c:291:5: error: call to undeclared function 'tcg_debug_assert'
   291 |     tcg_debug_assert(!tcg_cflags_has(cs, CF_PCREL));
       |     ^
---
  include/exec/cpu-common.h      | 1 -
  target/loongarch/tcg/tcg_cpu.c | 1 +
  2 files changed, 1 insertion(+), 1 deletion(-)
include/exec/cpu-common.h +0 -1
index 7dc8cab3263..d1a04025363 100644
@@ -10,7 +10,6 @@
 
  #include "qemu/thread.h"
  #include "hw/core/cpu.h"
-#include "tcg/debug-assert.h"
  #include "exec/page-protection.h"
 
  #define EXCP_INTERRUPT  0x10000 /* async interruption */
target/loongarch/tcg/tcg_cpu.c +0 -0
index f556234d9d2..83291c22c2a 100644

target/loongarch/tcg/tcg_cpu.c line 19

Quoted 7 lines
target/loongarch/tcg/tcg_cpu.c +1 -0
@@ -13,6 +13,7 @@
  #include "accel/tcg/cpu-ops.h"
  #include "exec/translation-block.h"
  #include "exec/target_page.h"
+#include "tcg/debug-assert.h"
  #include "tcg_loongarch.h"
  #include "internals.h"
 

r~

#9 lore raw

PATCH 5/5 exec/cpu-common.h: Avoid including unused exec/page-protection.h header

In reply to Philippe Mathieu-Daudé

Since commit e74781c0888e ("exec/cpu: Extract page-protection definitions to page-protection.h") the "exec/cpu-common.h" isn't using anything defined in "exec/page-protection.h"; remove it.

Include it in few files where it is currently pulled in indirectly, otherwise we'd get:

linux-user/qemu.h:182:22: error: ‘PAGE_READ’ undeclared

    182 | #define VERIFY_READ  PAGE_READ
        |                      ^~~~~~~~~
  target/loongarch/cpu_helper.c:329:25: error: use of undeclared identifier 'PAGE_READ'
    329 |         context->prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC;
        |                         ^
  target/loongarch/cpu_helper.c:329:37: error: use of undeclared identifier 'PAGE_WRITE'
    329 |         context->prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC;
        |                                     ^
  target/loongarch/cpu_helper.c:329:50: error: use of undeclared identifier 'PAGE_EXEC'
    329 |         context->prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC;
        |                                                  ^
  target/ppc/mmu-hash32.h:98:20: error: use of undeclared identifier 'PAGE_READ'
     98 |             prot = PAGE_READ | PAGE_WRITE;
        |                    ^
  target/ppc/mmu-hash32.h:98:32: error: use of undeclared identifier 'PAGE_WRITE'
     98 |             prot = PAGE_READ | PAGE_WRITE;
        |                                ^
  hw/ppc/ppc_booke.c:39:17: error: use of undeclared identifier 'PAGE_RWX'
     39 |     tlb->prot = PAGE_RWX << 4 | PAGE_VALID;
        |                 ^
  hw/ppc/ppc_booke.c:39:33: error: use of undeclared identifier 'PAGE_VALID'
     39 |     tlb->prot = PAGE_RWX << 4 | PAGE_VALID;
        |                                 ^
---
 include/exec/cpu-common.h     | 1 -
 linux-user/qemu.h             | 1 +
 target/ppc/mmu-hash32.h       | 1 +
 hw/ppc/ppc_booke.c            | 1 +
 linux-user/arm/elfload.c      | 1 +
 linux-user/hppa/elfload.c     | 1 +
 linux-user/x86_64/elfload.c   | 1 +
 target/arm/tcg/cpregs-at.c    | 1 +
 target/loongarch/cpu_helper.c | 1 +
 target/ppc/cpu_init.c         | 1 +
 10 files changed, 9 insertions(+), 1 deletion(-)
include/exec/cpu-common.h +0 -1
index d1a04025363..7eb45a95b6c 100644
@@ -10,7 +10,6 @@
 
 #include "qemu/thread.h"
 #include "hw/core/cpu.h"
-#include "exec/page-protection.h"
 
 #define EXCP_INTERRUPT  0x10000 /* async interruption */
 #define EXCP_HLT        0x10001 /* hlt instruction reached */
linux-user/qemu.h +1 -0
index 07fe8016282..fc5d7973021 100644
@@ -6,6 +6,7 @@
 
 #include "user/abitypes.h"
 #include "user/page-protection.h"
+#include "exec/page-protection.h"
 
 #include "syscall_defs.h"
 #include "target_syscall.h"
target/ppc/mmu-hash32.h +1 -0
index bfea03ea872..c6e2c60db19 100644
@@ -3,6 +3,7 @@
 
 #ifndef CONFIG_USER_ONLY
 
+#include "exec/page-protection.h"
 #include "system/memory.h"
 
 bool ppc_hash32_xlate(PowerPCCPU *cpu, vaddr eaddr, MMUAccessType access_type,
hw/ppc/ppc_booke.c +1 -0
index 052c8c931ae..6f0cad1c752 100644
@@ -24,6 +24,7 @@
 
 #include "qemu/osdep.h"
 #include "target/ppc/cpu.h"
+#include "exec/page-protection.h"
 #include "exec/target_page.h"
 #include "hw/ppc/ppc.h"
 #include "qemu/timer.h"
linux-user/arm/elfload.c +1 -0
index fef61022a3d..13b589ea2c5 100644
@@ -2,6 +2,7 @@
 
 #include "qemu/osdep.h"
 #include "qemu.h"
+#include "exec/page-protection.h"
 #include "loader.h"
 #include "user-internals.h"
 #include "target_elf.h"
linux-user/hppa/elfload.c +1 -0
index 3354e1b840d..2ebb9924f19 100644
@@ -1,6 +1,7 @@
 /* SPDX-License-Identifier: GPL-2.0-or-later */
 
 #include "qemu/osdep.h"
+#include "exec/page-protection.h"
 #include "qemu.h"
 #include "loader.h"
 #include "target_elf.h"
linux-user/x86_64/elfload.c +1 -0
index 5914f76e833..49a6f6180e0 100644
@@ -2,6 +2,7 @@
 
 #include "qemu/osdep.h"
 #include "qemu/error-report.h"
+#include "exec/page-protection.h"
 #include "qemu.h"
 #include "loader.h"
 #include "target_elf.h"
target/arm/tcg/cpregs-at.c +1 -0
index 1c819c1cdb2..d6d5b73430a 100644
@@ -4,6 +4,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "exec/page-protection.h"
 #include "cpu.h"
 #include "cpu-features.h"
 #include "internals.h"
target/loongarch/cpu_helper.c +1 -0
index 7f0e64a8739..123cad3d930 100644
@@ -11,6 +11,7 @@
 #include "system/tcg.h"
 #include "cpu.h"
 #include "accel/tcg/cpu-mmu-index.h"
+#include "exec/page-protection.h"
 #include "exec/target_page.h"
 #include "internals.h"
 #include "cpu-csr.h"
target/ppc/cpu_init.c +1 -0
index d25f69f13ba..a02187ce5af 100644
@@ -40,6 +40,7 @@
 #include "qemu/cutils.h"
 #include "disas/capstone.h"
 #include "fpu/softfloat.h"
+#include "exec/page-protection.h"
 #include "exec/watchpoint.h"
 #include "helper_regs.h"
 #include "internal.h"
Signature · 1 line
2.53.0
Reviewed-by on v1 5/5
#10 lore raw

Re: [PATCH 5/5] exec/cpu-common.h: Avoid including unused exec/page-protection.h header

Quoted 33 lines · Philippe Mathieu-Daudé

Since commit e74781c0888e ("exec/cpu: Extract page-protection definitions to page-protection.h") the "exec/cpu-common.h" isn't using anything defined in "exec/page-protection.h"; remove it.

Include it in few files where it is currently pulled in indirectly, otherwise we'd get:

linux-user/qemu.h:182:22: error: ‘PAGE_READ’ undeclared

     182 | #define VERIFY_READ  PAGE_READ
         |                      ^~~~~~~~~
   target/loongarch/cpu_helper.c:329:25: error: use of undeclared identifier 'PAGE_READ'
     329 |         context->prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC;
         |                         ^
   target/loongarch/cpu_helper.c:329:37: error: use of undeclared identifier 'PAGE_WRITE'
     329 |         context->prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC;
         |                                     ^
   target/loongarch/cpu_helper.c:329:50: error: use of undeclared identifier 'PAGE_EXEC'
     329 |         context->prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC;
         |                                                  ^
   target/ppc/mmu-hash32.h:98:20: error: use of undeclared identifier 'PAGE_READ'
      98 |             prot = PAGE_READ | PAGE_WRITE;
         |                    ^
   target/ppc/mmu-hash32.h:98:32: error: use of undeclared identifier 'PAGE_WRITE'
      98 |             prot = PAGE_READ | PAGE_WRITE;
         |                                ^
   hw/ppc/ppc_booke.c:39:17: error: use of undeclared identifier 'PAGE_RWX'
      39 |     tlb->prot = PAGE_RWX << 4 | PAGE_VALID;
         |                 ^
   hw/ppc/ppc_booke.c:39:33: error: use of undeclared identifier 'PAGE_VALID'
      39 |     tlb->prot = PAGE_RWX << 4 | PAGE_VALID;
         |                                 ^
Quoted 12 lines
---
  include/exec/cpu-common.h     | 1 -
  linux-user/qemu.h             | 1 +
  target/ppc/mmu-hash32.h       | 1 +
  hw/ppc/ppc_booke.c            | 1 +
  linux-user/arm/elfload.c      | 1 +
  linux-user/hppa/elfload.c     | 1 +
  linux-user/x86_64/elfload.c   | 1 +
  target/arm/tcg/cpregs-at.c    | 1 +
  target/loongarch/cpu_helper.c | 1 +
  target/ppc/cpu_init.c         | 1 +
  10 files changed, 9 insertions(+), 1 deletion(-)

r~

#11 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 8 lines

Philippe Mathieu-Daudé (5):
target/sparc: Include missing 'accel/tcg/cpu-ops.h' header in cpu.c exec/cpu-common.h: Include missing 'qemu/thread.h' header exec/cpu-common.h: Avoid including unused 'exec/vaddr.h' header exec/cpu-common.h: Avoid including unused 'tcg/debug-assert.h' header exec/cpu-common.h: Avoid including unused exec/page-protection.h
header

Queued, thanks.