Skip to contentSkip to conversation

target/misc: Protect few system binaries for target_ulong use

PATCH In review Philippe Mathieu-Daudé 3 participants 21 messages Jan 7 – Jan 11 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

cover target/misc: Protect few system binaries for target_ulong use

Omnibus series for architectures with few maintainers.

It took some time but to remove the target_[u]long uses but we now have some system files in target/ clean of it (rx, sh4, tricore and openrisc).
Move the source files to the meson target_common_system_arch[] array to forbid further uses to creep in.
Keep cleaning hppa & m68k. More to come.

Philippe Mathieu-Daudé (9):
target/rx: Build system units in common source set target/sh4: Build system units in common source set target/tricore: Build system units in common source set target/openrisc: Remove unused 'gdbstub/helpers.h' header in helper.c target/openrisc: Avoid target-specific migration headers in machine.c target/openrisc: Build system units in common source set target/hppa: Avoid target-specific migration headers in machine.c target/hppa: Remove target_ulong use in disas_log() handler target/m68k: Replace MD_TLONG -> MD_I32 in monitor.c

 target/hppa/machine.c       |  3 +-
 target/hppa/translate.c     |  2 +-
 target/m68k/monitor.c       | 60 ++++++++++++++++++-------------------
 target/openrisc/interrupt.c |  1 -
 target/openrisc/machine.c   |  3 +-
 target/openrisc/mmu.c       |  1 -
 target/openrisc/meson.build |  2 +-
 target/rx/meson.build       |  2 +-
 target/sh4/meson.build      |  2 +-
 target/tricore/meson.build  |  2 +-
 10 files changed, 39 insertions(+), 39 deletions(-)
Signature · 1 line
2.52.0
#1 lore raw

PATCH 1/9 target/rx: Build system units in common source set

Since commit range 2982b948a9f..86114e43ffd we remove all uses of the target_ulong type in target/rx/. Use the meson target_common_system_arch[] source set to prevent further uses of target-specific types.

---
 target/rx/meson.build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/rx/meson.build +1 -1
index d196737ce33..86dc231eb0a 100644
@@ -13,4 +13,4 @@ rx_ss.add(files(
   'disas.c'))
 
 target_arch += {'rx': rx_ss}
-target_system_arch += {'rx': ss.source_set()}
+target_common_system_arch += {'rx': ss.source_set()}
Signature · 1 line
2.52.0
Reviewed-by on v1 1/9
#2 lore raw

Re: [PATCH 1/9] target/rx: Build system units in common source set

Quoted 9 lines · Philippe Mathieu-Daudé

Since commit range 2982b948a9f..86114e43ffd we remove all uses of the target_ulong type in target/rx/. Use the meson target_common_system_arch[] source set to prevent further uses of target-specific types.

---
  target/rx/meson.build | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

r~

#3 lore raw

PATCH 2/9 target/sh4: Build system units in common source set

In reply to Philippe Mathieu-Daudé

Since commit range 42c90609b8f..82a1e739010 we remove all uses of the target_ulong type in target/rx/. Use the meson target_common_system_arch[] source set to prevent further uses of target-specific types.

---
 target/sh4/meson.build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/sh4/meson.build +1 -1
index fe09f96684b..221700bcf8c 100644
@@ -11,4 +11,4 @@ sh4_system_ss = ss.source_set()
 sh4_system_ss.add(files('monitor.c'))
 
 target_arch += {'sh4': sh4_ss}
-target_system_arch += {'sh4': sh4_system_ss}
+target_common_system_arch += {'sh4': sh4_system_ss}
Signature · 1 line
2.52.0
Reviewed-by on v1 2/9
#4 lore raw

Re: [PATCH 2/9] target/sh4: Build system units in common source set

Quoted 9 lines · Philippe Mathieu-Daudé

Since commit range 42c90609b8f..82a1e739010 we remove all uses of the target_ulong type in target/rx/. Use the meson target_common_system_arch[] source set to prevent further uses of target-specific types.

---
  target/sh4/meson.build | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

r~

#5 lore raw

PATCH 3/9 target/tricore: Build system units in common source set

In reply to Philippe Mathieu-Daudé

Since commit range 809b460f305..cd08bcaa36b we remove all uses of the target_ulong type in target/rx/. Use the meson target_common_system_arch[] source set to prevent further uses of target-specific types.

---
 target/tricore/meson.build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/tricore/meson.build +1 -1
index 45f49f01288..f40daee61ed 100644
@@ -12,4 +12,4 @@ tricore_ss.add(zlib)
 tricore_system_ss = ss.source_set()
 
 target_arch += {'tricore': tricore_ss}
-target_system_arch += {'tricore': tricore_system_ss}
+target_common_system_arch += {'tricore': tricore_system_ss}
Signature · 1 line
2.52.0
Reviewed-by on v1 3/9
#6 lore raw

Re: [PATCH 3/9] target/tricore: Build system units in common source set

Quoted 9 lines · Philippe Mathieu-Daudé

Since commit range 809b460f305..cd08bcaa36b we remove all uses of the target_ulong type in target/rx/. Use the meson target_common_system_arch[] source set to prevent further uses of target-specific types.

---
  target/tricore/meson.build | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

r~

#7 lore raw

PATCH 4/9 target/openrisc: Remove unused 'gdbstub/helpers.h' header in helper.c

In reply to Philippe Mathieu-Daudé

"gdbstub/helpers.h" uses target-specific symbols, but we don't need it, so remove it.

---
 target/openrisc/interrupt.c | 1 -
 target/openrisc/mmu.c       | 1 -
 2 files changed, 2 deletions(-)
target/openrisc/interrupt.c +0 -1
index 5528b80e7b8..6e89157639a 100644
@@ -20,7 +20,6 @@
 #include "qemu/osdep.h"
 #include "qemu/log.h"
 #include "cpu.h"
-#include "gdbstub/helpers.h"
 #include "qemu/host-utils.h"
 #ifndef CONFIG_USER_ONLY
 #include "hw/core/loader.h"
target/openrisc/mmu.c +0 -1
index b2b2b3c4a98..315debaf3e5 100644
@@ -24,7 +24,6 @@
 #include "exec/cputlb.h"
 #include "exec/page-protection.h"
 #include "exec/target_page.h"
-#include "gdbstub/helpers.h"
 #include "qemu/host-utils.h"
 #include "hw/core/loader.h"
 
Signature · 1 line
2.52.0
#9 lore raw

PATCH 5/9 target/openrisc: Avoid target-specific migration headers in machine.c

In reply to Philippe Mathieu-Daudé

machine.c doesn't use any target-specific macro defined by the "migration/cpu.h" header. Use the minimum header requiered:
"migration/qemu-file-types.h" and "migration/vmstate.h", which are not target-specific.

---
 target/openrisc/machine.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
target/openrisc/machine.c +2 -1
index f2853674f0f..2d5ca16c511 100644
@@ -19,7 +19,8 @@
 
 #include "qemu/osdep.h"
 #include "cpu.h"
-#include "migration/cpu.h"
+#include "migration/qemu-file-types.h"
+#include "migration/vmstate.h"
 
 static const VMStateDescription vmstate_tlb_entry = {
     .name = "tlb_entry",
Signature · 1 line
2.52.0
Reviewed-by on v1 5/9
#10 lore raw

Re: [PATCH 5/9] target/openrisc: Avoid target-specific migration headers in machine.c

Quoted 2 lines · Philippe Mathieu-Daudé

machine.c doesn't use any target-specific macro defined by the "migration/cpu.h" header. Use the minimum header requiered:

* requiered -> required

Quoted 1 line

"migration/qemu-file-types.h" and "migration/vmstate.h", which are not target-specific.

* They are included via migration/cpu.h too; Still the change looks fine.

Quoted 5 lines
target/openrisc/machine.c +0 -0
index f2853674f0f..2d5ca16c511 100644

target/openrisc/machine.c line 26

Quoted 9 lines
target/openrisc/machine.c +2 -1
@@ -19,7 +19,8 @@
 
 #include "qemu/osdep.h"
 #include "cpu.h"
-#include "migration/cpu.h"
+#include "migration/qemu-file-types.h"
+#include "migration/vmstate.h"
 
 static const VMStateDescription vmstate_tlb_entry = {
     .name = "tlb_entry",

Thank you.
---
- Prasad

Reviewed-by on v1 5/9
#11 lore raw

Re: [PATCH 5/9] target/openrisc: Avoid target-specific migration headers in machine.c

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

machine.c doesn't use any target-specific macro defined by the "migration/cpu.h" header. Use the minimum header requiered:
"migration/qemu-file-types.h" and "migration/vmstate.h", which are not target-specific.

---
  target/openrisc/machine.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

r~

#12 lore raw

PATCH 6/9 target/openrisc: Build system units in common source set

In reply to Philippe Mathieu-Daudé

Since previous 2 commits and range 2795bc52af4..5b67dbf1dc3 we remove all uses of the target_ulong type in target/rx/. Use the meson target_common_system_arch[] source set to prevent further uses of target-specific types.

---
 target/openrisc/meson.build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/openrisc/meson.build +1 -1
index 31608b6dc7f..d51ea1ab753 100644
@@ -22,4 +22,4 @@ openrisc_system_ss.add(files(
 ))
 
 target_arch += {'openrisc': openrisc_ss}
-target_system_arch += {'openrisc': openrisc_system_ss}
+target_common_system_arch += {'openrisc': openrisc_system_ss}
Signature · 1 line
2.52.0
Reviewed-by on v1 6/9
#13 lore raw

Re: [PATCH 6/9] target/openrisc: Build system units in common source set

Quoted 9 lines · Philippe Mathieu-Daudé

Since previous 2 commits and range 2795bc52af4..5b67dbf1dc3 we remove all uses of the target_ulong type in target/rx/. Use the meson target_common_system_arch[] source set to prevent further uses of target-specific types.

---
  target/openrisc/meson.build | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

r~

#14 lore raw

PATCH 7/9 target/hppa: Avoid target-specific migration headers in machine.c

In reply to Philippe Mathieu-Daudé

machine.c doesn't use any target-specific macro defined by the "migration/cpu.h" header. Use the minimum header requiered:
"migration/qemu-file-types.h" and "migration/vmstate.h", which are not target-specific.

---
 target/hppa/machine.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
target/hppa/machine.c +2 -1
index 13e555151a6..6a143cf8df2 100644
@@ -19,7 +19,8 @@
 
 #include "qemu/osdep.h"
 #include "cpu.h"
-#include "migration/cpu.h"
+#include "migration/qemu-file-types.h"
+#include "migration/vmstate.h"
 
 
 static int get_psw(QEMUFile *f, void *opaque, size_t size,
Signature · 1 line
2.52.0
Reviewed-by on v1 7/9
#15 lore raw

Re: [PATCH 7/9] target/hppa: Avoid target-specific migration headers in machine.c

Quoted 2 lines · Philippe Mathieu-Daudé

machine.c doesn't use any target-specific macro defined by the "migration/cpu.h" header. Use the minimum header requiered:

* requiered -> required

Quoted 1 line

"migration/qemu-file-types.h" and "migration/vmstate.h", which are not target-specific.

* They are included via migration/cpu.h; Still the change looks okay.

target/hppa/machine.c line 23

Quoted 11 lines
target/hppa/machine.c +2 -1
index 13e555151a6..6a143cf8df2 100644
@@ -19,7 +19,8 @@
 
 #include "qemu/osdep.h"
 #include "cpu.h"
-#include "migration/cpu.h"
+#include "migration/qemu-file-types.h"
+#include "migration/vmstate.h"

Thank you.
---
- Prasad

Reviewed-by on v1 7/9
#16 lore raw

Re: [PATCH 7/9] target/hppa: Avoid target-specific migration headers in machine.c

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

machine.c doesn't use any target-specific macro defined by the "migration/cpu.h" header. Use the minimum header requiered:
"migration/qemu-file-types.h" and "migration/vmstate.h", which are not target-specific.

---
  target/hppa/machine.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

r~

#17 lore raw

PATCH 8/9 target/hppa: Remove target_ulong use in disas_log() handler

In reply to Philippe Mathieu-Daudé

Since commit 85c19af63e7 ("include/exec: Use vaddr in DisasContextBase virtual addresses") the DisasContextBase::pc_first field is a vaddr type.

---
 target/hppa/translate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/hppa/translate.c +1 -1
index 0b7074649b7..0f8a66f7732 100644
@@ -4864,7 +4864,7 @@ static void hppa_tr_tb_stop(DisasContextBase *dcbase, CPUState *cs)
 static bool hppa_tr_disas_log(const DisasContextBase *dcbase,
                               CPUState *cs, FILE *logfile)
 {
-    target_ulong pc = dcbase->pc_first;
+    vaddr pc = dcbase->pc_first;
 
     switch (pc) {
     case 0x00:
Signature · 1 line
2.52.0
Reviewed-by on v1 8/9
#18 lore raw

Re: [PATCH 8/9] target/hppa: Remove target_ulong use in disas_log() handler

Quoted 14 lines · Philippe Mathieu-Daudé

Since commit 85c19af63e7 ("include/exec: Use vaddr in DisasContextBase virtual addresses") the DisasContextBase::pc_first field is a vaddr type.

---
  target/hppa/translate.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
target/hppa/translate.c +0 -0
index 0b7074649b7..0f8a66f7732 100644

target/hppa/translate.c static void hppa_tr_tb_stop(DisasContextBase *dcbase, CPUState *cs) · line 4870

Quoted 8 lines
target/hppa/translate.c +1 -1
@@ -4864,7 +4864,7 @@ static void hppa_tr_tb_stop(DisasContextBase *dcbase, CPUState *cs)
  static bool hppa_tr_disas_log(const DisasContextBase *dcbase,
                                CPUState *cs, FILE *logfile)
  {
-    target_ulong pc = dcbase->pc_first;
+    vaddr pc = dcbase->pc_first;
 
      switch (pc) {
      case 0x00:

r~

#19 lore raw

PATCH 9/9 target/m68k: Replace MD_TLONG -> MD_I32 in monitor.c

In reply to Philippe Mathieu-Daudé

m68k's monitor_defs[] array implicitly uses type=MD_TLONG for all its entries. Since we only build this target as 32-bit, use the explicit MD_I32 type to avoid an indirect target_long use.

---
 target/m68k/monitor.c | 60 +++++++++++++++++++++----------------------
 1 file changed, 30 insertions(+), 30 deletions(-)
target/m68k/monitor.c +30 -30
index 784f5730919..6d101c75df0 100644
@@ -24,36 +24,36 @@ void hmp_info_tlb(Monitor *mon, const QDict *qdict)
 }
 
 static const MonitorDef monitor_defs[] = {
-    { "d0", offsetof(CPUM68KState, dregs[0]) },
-    { "d1", offsetof(CPUM68KState, dregs[1]) },
-    { "d2", offsetof(CPUM68KState, dregs[2]) },
-    { "d3", offsetof(CPUM68KState, dregs[3]) },
-    { "d4", offsetof(CPUM68KState, dregs[4]) },
-    { "d5", offsetof(CPUM68KState, dregs[5]) },
-    { "d6", offsetof(CPUM68KState, dregs[6]) },
-    { "d7", offsetof(CPUM68KState, dregs[7]) },
-    { "a0", offsetof(CPUM68KState, aregs[0]) },
-    { "a1", offsetof(CPUM68KState, aregs[1]) },
-    { "a2", offsetof(CPUM68KState, aregs[2]) },
-    { "a3", offsetof(CPUM68KState, aregs[3]) },
-    { "a4", offsetof(CPUM68KState, aregs[4]) },
-    { "a5", offsetof(CPUM68KState, aregs[5]) },
-    { "a6", offsetof(CPUM68KState, aregs[6]) },
-    { "a7", offsetof(CPUM68KState, aregs[7]) },
-    { "pc", offsetof(CPUM68KState, pc) },
-    { "sr", offsetof(CPUM68KState, sr) },
-    { "ssp", offsetof(CPUM68KState, sp[0]) },
-    { "usp", offsetof(CPUM68KState, sp[1]) },
-    { "isp", offsetof(CPUM68KState, sp[2]) },
-    { "sfc", offsetof(CPUM68KState, sfc) },
-    { "dfc", offsetof(CPUM68KState, dfc) },
-    { "urp", offsetof(CPUM68KState, mmu.urp) },
-    { "srp", offsetof(CPUM68KState, mmu.srp) },
-    { "dttr0", offsetof(CPUM68KState, mmu.ttr[M68K_DTTR0]) },
-    { "dttr1", offsetof(CPUM68KState, mmu.ttr[M68K_DTTR1]) },
-    { "ittr0", offsetof(CPUM68KState, mmu.ttr[M68K_ITTR0]) },
-    { "ittr1", offsetof(CPUM68KState, mmu.ttr[M68K_ITTR1]) },
-    { "mmusr", offsetof(CPUM68KState, mmu.mmusr) },
+    { "d0", offsetof(CPUM68KState, dregs[0]), NULL, MD_I32 },
+    { "d1", offsetof(CPUM68KState, dregs[1]), NULL, MD_I32 },
+    { "d2", offsetof(CPUM68KState, dregs[2]), NULL, MD_I32 },
+    { "d3", offsetof(CPUM68KState, dregs[3]), NULL, MD_I32 },
+    { "d4", offsetof(CPUM68KState, dregs[4]), NULL, MD_I32 },
+    { "d5", offsetof(CPUM68KState, dregs[5]), NULL, MD_I32 },
+    { "d6", offsetof(CPUM68KState, dregs[6]), NULL, MD_I32 },
+    { "d7", offsetof(CPUM68KState, dregs[7]), NULL, MD_I32 },
+    { "a0", offsetof(CPUM68KState, aregs[0]), NULL, MD_I32 },
+    { "a1", offsetof(CPUM68KState, aregs[1]), NULL, MD_I32 },
+    { "a2", offsetof(CPUM68KState, aregs[2]), NULL, MD_I32 },
+    { "a3", offsetof(CPUM68KState, aregs[3]), NULL, MD_I32 },
+    { "a4", offsetof(CPUM68KState, aregs[4]), NULL, MD_I32 },
+    { "a5", offsetof(CPUM68KState, aregs[5]), NULL, MD_I32 },
+    { "a6", offsetof(CPUM68KState, aregs[6]), NULL, MD_I32 },
+    { "a7", offsetof(CPUM68KState, aregs[7]), NULL, MD_I32 },
+    { "pc", offsetof(CPUM68KState, pc), NULL, MD_I32 },
+    { "sr", offsetof(CPUM68KState, sr), NULL, MD_I32 },
+    { "ssp", offsetof(CPUM68KState, sp[0]), NULL, MD_I32 },
+    { "usp", offsetof(CPUM68KState, sp[1]), NULL, MD_I32 },
+    { "isp", offsetof(CPUM68KState, sp[2]), NULL, MD_I32 },
+    { "sfc", offsetof(CPUM68KState, sfc), NULL, MD_I32 },
+    { "dfc", offsetof(CPUM68KState, dfc), NULL, MD_I32 },
+    { "urp", offsetof(CPUM68KState, mmu.urp), NULL, MD_I32 },
+    { "srp", offsetof(CPUM68KState, mmu.srp), NULL, MD_I32 },
+    { "dttr0", offsetof(CPUM68KState, mmu.ttr[M68K_DTTR0]), NULL, MD_I32 },
+    { "dttr1", offsetof(CPUM68KState, mmu.ttr[M68K_DTTR1]), NULL, MD_I32 },
+    { "ittr0", offsetof(CPUM68KState, mmu.ttr[M68K_ITTR0]), NULL, MD_I32 },
+    { "ittr1", offsetof(CPUM68KState, mmu.ttr[M68K_ITTR1]), NULL, MD_I32 },
+    { "mmusr", offsetof(CPUM68KState, mmu.mmusr), NULL, MD_I32 },
     { NULL },
 };
 
Signature · 1 line
2.52.0
Reviewed-by on v1 9/9
#20 lore raw

Re: [PATCH 9/9] target/m68k: Replace MD_TLONG -> MD_I32 in monitor.c

Quoted 9 lines · Philippe Mathieu-Daudé

m68k's monitor_defs[] array implicitly uses type=MD_TLONG for all its entries. Since we only build this target as 32-bit, use the explicit MD_I32 type to avoid an indirect target_long use.

---
  target/m68k/monitor.c | 60 +++++++++++++++++++++----------------------
  1 file changed, 30 insertions(+), 30 deletions(-)

r~