]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
sim: cpu: change default init to handle all cpus
authorMike Frysinger <vapier@gentoo.org>
Sun, 25 Dec 2022 05:53:25 +0000 (00:53 -0500)
committerMike Frysinger <vapier@gentoo.org>
Sun, 25 Dec 2022 07:10:46 +0000 (02:10 -0500)
All the runtimes were only initializing a single CPU.  When SMP is
enabled, things quickly crash as none of the other CPU structs are
setup.  Change the default from 0 to the compile time value.

28 files changed:
sim/aarch64/interp.c
sim/arm/wrapper.c
sim/avr/interp.c
sim/bfin/interp.c
sim/bpf/sim-if.c
sim/common/sim-cpu.c
sim/cr16/interp.c
sim/cris/sim-if.c
sim/d10v/interp.c
sim/example-synacor/interp.c
sim/frv/sim-if.c
sim/ft32/interp.c
sim/h8300/compile.c
sim/iq2000/sim-if.c
sim/lm32/sim-if.c
sim/m32r/sim-if.c
sim/m68hc11/interp.c
sim/mcore/interp.c
sim/microblaze/interp.c
sim/mips/interp.c
sim/mn10300/interp.c
sim/moxie/interp.c
sim/msp430/msp430-sim.c
sim/or1k/sim-if.c
sim/pru/interp.c
sim/riscv/interp.c
sim/sh/interp.c
sim/v850/interp.c

index 234d978a76854d6b32662c9c2b7f2c92eed071e5..03efb42e6b5ebe5e313a52abb8f6fe7107cb6552 100644 (file)
@@ -348,7 +348,7 @@ sim_open (SIM_OPEN_KIND                  kind,
   current_alignment = NONSTRICT_ALIGNMENT;
 
   /* Perform the initialization steps one by one.  */
-  if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct aarch64_sim_cpu))
+  if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct aarch64_sim_cpu))
       != SIM_RC_OK
       || sim_pre_argv_init (sd, argv[0]) != SIM_RC_OK
       || sim_parse_args (sd, argv) != SIM_RC_OK
index 5eb61df143782a0cc2f22196dccfe30e1ee59973..4e800780454698f7574de9a2dab9672885140e19 100644 (file)
@@ -822,7 +822,7 @@ sim_open (SIM_OPEN_KIND kind,
   current_alignment = STRICT_ALIGNMENT;
 
   /* The cpu data is kept in a separately allocated chunk of memory.  */
-  if (sim_cpu_alloc_all (sd, 1) != SIM_RC_OK)
+  if (sim_cpu_alloc_all (sd, 0) != SIM_RC_OK)
     {
       free_state (sd);
       return 0;
index ddd9e1ff1eae58a21f282c680a276b45146bc52a..27834f15dbc38498062c5b7104175448a58b82a2 100644 (file)
@@ -1703,7 +1703,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *cb,
   current_target_byte_order = BFD_ENDIAN_LITTLE;
 
   /* The cpu data is kept in a separately allocated chunk of memory.  */
-  if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct avr_sim_cpu))
+  if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct avr_sim_cpu))
       != SIM_RC_OK)
     {
       free_state (sd);
index 04c1773eaf42a194099d0c98ed5b4a11a1ffc0aa..e904506bf228299d84b6b87ec221f6518c8c6b70 100644 (file)
@@ -675,7 +675,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback,
   current_target_byte_order = BFD_ENDIAN_LITTLE;
 
   /* The cpu data is kept in a separately allocated chunk of memory.  */
-  if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct bfin_cpu_state))
+  if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct bfin_cpu_state))
       != SIM_RC_OK)
     {
       free_state (sd);
index b29300f032879efa6c4b81e2069f601cfc619c6a..4c9aa83232aab0ecd16927c5e2f7b391e0a7a53c 100644 (file)
@@ -132,7 +132,7 @@ sim_open (SIM_OPEN_KIND kind,
   STATE_MACHS (sd) = bpf_sim_machs;
   STATE_MODEL_NAME (sd) = "bpf-def";
 
-  if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct bpf_sim_cpu)) != SIM_RC_OK)
+  if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct bpf_sim_cpu)) != SIM_RC_OK)
     goto error;
 
   if (sim_pre_argv_init (sd, argv[0]) != SIM_RC_OK)
index 024bd050ab3da8fd68ba0e9abc7cf0fc9e995957..9f64d9d06e8d7d58a9d6dc99380ee21cfa735bce 100644 (file)
@@ -35,8 +35,13 @@ sim_cpu_alloc_all_extra (SIM_DESC sd, int ncpus, size_t extra_bytes)
 {
   int c;
 
+  /* TODO: This should be a command line option for users to control.  */
+  if (ncpus == 0)
+    ncpus = MAX_NR_PROCESSORS;
+
   for (c = 0; c < ncpus; ++c)
     STATE_CPU (sd, c) = sim_cpu_alloc_extra (sd, extra_bytes);
+
   return SIM_RC_OK;
 }
 
index 1830e348a06017516dd227bb7afffb5af33782f3..fe1e24bed68bc259e6e25168322caece6633103e 100644 (file)
@@ -407,7 +407,7 @@ sim_open (SIM_OPEN_KIND kind, struct host_callback_struct *cb,
   cb->syscall_map = cb_cr16_syscall_map;
 
   /* The cpu data is kept in a separately allocated chunk of memory.  */
-  if (sim_cpu_alloc_all (sd, 1) != SIM_RC_OK)
+  if (sim_cpu_alloc_all (sd, 0) != SIM_RC_OK)
     {
       free_state (sd);
       return 0;
index 47862edf4f5a8ae7721b576bd0a45513d104aa23..d939854e32d12e506aef689ab0aed6ad7cc40e68 100644 (file)
@@ -670,7 +670,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback, struct bfd *abfd,
   current_target_byte_order = BFD_ENDIAN_LITTLE;
 
   /* The cpu data is kept in a separately allocated chunk of memory.  */
-  if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct cris_sim_cpu))
+  if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct cris_sim_cpu))
       != SIM_RC_OK)
     {
       free_state (sd);
index 9beedf8f445e6905f79bd5605d702a0c9337e34b..aebd98ab6ac637c700f74aa7ccbe15b29befad18 100644 (file)
@@ -765,7 +765,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *cb,
   cb->syscall_map = cb_d10v_syscall_map;
 
   /* The cpu data is kept in a separately allocated chunk of memory.  */
-  if (sim_cpu_alloc_all (sd, 1) != SIM_RC_OK)
+  if (sim_cpu_alloc_all (sd, 0) != SIM_RC_OK)
     {
       free_state (sd);
       return 0;
index 20ae057d43a1624500c21038a0f002f76ef4008a..25e519d9f2ab7721ce68a8d929880ce819288b6b 100644 (file)
@@ -90,7 +90,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback,
   current_target_byte_order = BFD_ENDIAN_LITTLE;
 
   /* The cpu data is kept in a separately allocated chunk of memory.  */
-  if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct example_sim_cpu))
+  if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct example_sim_cpu))
       != SIM_RC_OK)
     {
       free_state (sd);
index 6e0f1bbaba64133211583bad54b7c951549ea34f..ad94423f40b68c633781164c87def528e0782170 100644 (file)
@@ -65,7 +65,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback, bfd *abfd,
   current_target_byte_order = BFD_ENDIAN_BIG;
 
   /* The cpu data is kept in a separately allocated chunk of memory.  */
-  if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct frv_sim_cpu)) != SIM_RC_OK)
+  if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct frv_sim_cpu)) != SIM_RC_OK)
     {
       free_state (sd);
       return 0;
index dfea4720c2200d9e18e7edc89788dacde67fd718..1eda9a7a28692f6bcf840841f90e63067cfa9b6f 100644 (file)
@@ -823,7 +823,7 @@ sim_open (SIM_OPEN_KIND kind,
   current_target_byte_order = BFD_ENDIAN_LITTLE;
 
   /* The cpu data is kept in a separately allocated chunk of memory.  */
-  if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct ft32_cpu_state))
+  if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct ft32_cpu_state))
       != SIM_RC_OK)
     {
       free_state (sd);
index cc8b52c5d6548ceb4ba30f8864820092f5abfb08..467eeafde610112a2b38ea8bedef298a8b98b876 100644 (file)
@@ -4631,7 +4631,7 @@ sim_open (SIM_OPEN_KIND kind,
   current_target_byte_order = BFD_ENDIAN_BIG;
 
   /* The cpu data is kept in a separately allocated chunk of memory.  */
-  if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct h8300_sim_cpu))
+  if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct h8300_sim_cpu))
       != SIM_RC_OK)
     {
       free_state (sd);
index e9b66b6a7ef9f4ce4bac8635d2530c4679a49e28..e02a413103e2985942e86be3570081371a3fc1c9 100644 (file)
@@ -70,7 +70,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback, struct bfd *abfd,
   current_target_byte_order = BFD_ENDIAN_BIG;
 
   /* The cpu data is kept in a separately allocated chunk of memory.  */
-  if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct iq2000_sim_cpu))
+  if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct iq2000_sim_cpu))
       != SIM_RC_OK)
     {
       free_state (sd);
index 82f2e117671ed536b8108f1c49ed76ec0cae72f4..b51028055124ee244904430c46f0766f13cc9f49 100644 (file)
@@ -101,7 +101,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback, struct bfd *abfd,
   current_target_byte_order = BFD_ENDIAN_BIG;
 
   /* The cpu data is kept in a separately allocated chunk of memory.  */
-  if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct lm32_sim_cpu))
+  if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct lm32_sim_cpu))
       != SIM_RC_OK)
     {
       free_state (sd);
index 7fe6b42801e75646b0da4d24c8bb09795fcaec99..1305ea6d10213484c5ff18cca7a36c5ce6863312 100644 (file)
@@ -68,7 +68,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback, struct bfd *abfd,
   current_target_byte_order = BFD_ENDIAN_BIG;
 
   /* The cpu data is kept in a separately allocated chunk of memory.  */
-  if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct m32r_sim_cpu))
+  if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct m32r_sim_cpu))
       != SIM_RC_OK)
     {
       free_state (sd);
index b80f5cb82bb07931b7dc446d100647ba3c6203ce..82155213330a48898473f9ff8dd41050874bb618 100644 (file)
@@ -422,7 +422,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback,
   current_target_byte_order = BFD_ENDIAN_BIG;
 
   /* The cpu data is kept in a separately allocated chunk of memory.  */
-  if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct m68hc11_sim_cpu))
+  if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct m68hc11_sim_cpu))
       != SIM_RC_OK)
     {
       free_state (sd);
index 84b243f07059707ad04a3ec3403bcb5edd863bef..ae554c77d31c47070b4d3772b832d2638f7a0012 100644 (file)
@@ -1370,7 +1370,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *cb,
   cb->syscall_map = cb_mcore_syscall_map;
 
   /* The cpu data is kept in a separately allocated chunk of memory.  */
-  if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct mcore_sim_cpu))
+  if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct mcore_sim_cpu))
       != SIM_RC_OK)
     {
       free_state (sd);
index 8a8cb9f2b83259db562c7c750587b00cb4d74454..df7f41fcff5667e5c4eb76cf0dbc73ec44570fd9 100644 (file)
@@ -410,7 +410,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *cb,
   SIM_ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER);
 
   /* The cpu data is kept in a separately allocated chunk of memory.  */
-  if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct microblaze_regset))
+  if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct microblaze_regset))
       != SIM_RC_OK)
     {
       free_state (sd);
index fa192d36f2e93edd60087754171109d882971693..d44c474ae1d686044ebca468ce0af9771db72c8a 100644 (file)
@@ -351,7 +351,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *cb,
   SIM_ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER);
 
   /* The cpu data is kept in a separately allocated chunk of memory.  */
-  if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct mips_sim_cpu))
+  if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct mips_sim_cpu))
       != SIM_RC_OK)
     return 0;
 
index 8467070addb65820f636719a2d5c6f418a82abac..2915551253f34ecef42d5257a25d65e9b77b309b 100644 (file)
@@ -97,7 +97,7 @@ sim_open (SIM_OPEN_KIND kind,
   current_target_byte_order = BFD_ENDIAN_LITTLE;
 
   /* The cpu data is kept in a separately allocated chunk of memory.  */
-  if (sim_cpu_alloc_all (sd, 1) != SIM_RC_OK)
+  if (sim_cpu_alloc_all (sd, 0) != SIM_RC_OK)
     return 0;
 
   /* for compatibility */
index 144d83cbe8e7eec8c41ace2d0fe4ea1778d3c2ce..2bc241db6f567b5f4697402d9f51faea372e8cc3 100644 (file)
@@ -1202,7 +1202,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *cb,
   current_target_byte_order = BFD_ENDIAN_BIG;
 
   /* The cpu data is kept in a separately allocated chunk of memory.  */
-  if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct moxie_sim_cpu))
+  if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct moxie_sim_cpu))
       != SIM_RC_OK)
     {
       free_state (sd);
index e7b58bab13476137ebf65f33ac0093f252ec1144..c02e7ca4b6f547497f97b72c937bde4df6044ba2 100644 (file)
@@ -123,7 +123,7 @@ sim_open (SIM_OPEN_KIND kind,
   /* Set default options before parsing user options.  */
   current_target_byte_order = BFD_ENDIAN_LITTLE;
 
-  if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct msp430_cpu_state))
+  if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct msp430_cpu_state))
       != SIM_RC_OK)
     {
       sim_state_free (sd);
index 799812bb741e249c0023a5df11d23a46838702fc..3bbf4f05738f99900df957bf2b1ccf542915250e 100644 (file)
@@ -168,7 +168,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback, struct bfd *abfd,
   current_target_byte_order = BFD_ENDIAN_BIG;
 
   /* The cpu data is kept in a separately allocated chunk of memory.  */
-  if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct or1k_sim_cpu))
+  if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct or1k_sim_cpu))
       != SIM_RC_OK)
     {
       free_state (sd);
index 250a32a889a5e7f11d0389eb76a787ee09ec8632..0e1874c118055d8b72d9851af829a220c524ef54 100644 (file)
@@ -774,7 +774,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *cb,
   current_target_byte_order = BFD_ENDIAN_LITTLE;
 
   /* The cpu data is kept in a separately allocated chunk of memory.  */
-  if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct pru_regset)) != SIM_RC_OK)
+  if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct pru_regset)) != SIM_RC_OK)
     {
       free_state (sd);
       return 0;
index a49ad0476c4553291aefdfdd54ef4154ba14e228..601753e029161f1c5a4f25ec4263d13d50a869b2 100644 (file)
@@ -77,7 +77,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback,
   callback->syscall_map = cb_riscv_syscall_map;
 
   /* The cpu data is kept in a separately allocated chunk of memory.  */
-  if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct riscv_sim_cpu))
+  if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct riscv_sim_cpu))
       != SIM_RC_OK)
     {
       free_state (sd);
index b2d30e386c1a804ad88cfee93b553e3025759975..5a90cd2cf74c4a92bf98de2e29d48fb177adcb7b 100644 (file)
@@ -2350,7 +2350,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *cb,
   cb->syscall_map = cb_sh_syscall_map;
 
   /* The cpu data is kept in a separately allocated chunk of memory.  */
-  if (sim_cpu_alloc_all (sd, 1) != SIM_RC_OK)
+  if (sim_cpu_alloc_all (sd, 0) != SIM_RC_OK)
     {
       free_state (sd);
       return 0;
index efe35c606ffbf8a2c38cf45c8e06556293ec5e83..948b7245c3f07f2aac106c4a59193c0037812ee0 100644 (file)
@@ -206,7 +206,7 @@ sim_open (SIM_OPEN_KIND    kind,
   cb->syscall_map = cb_v850_syscall_map;
 
   /* The cpu data is kept in a separately allocated chunk of memory.  */
-  if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct v850_sim_cpu))
+  if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct v850_sim_cpu))
       != SIM_RC_OK)
     return 0;