Browse Source

sim: cpu: change default init to handle all cpus

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.
users/ahajkova/try-frob
Mike Frysinger 4 years ago
parent
commit
883be19774
  1. 2
      sim/aarch64/interp.c
  2. 2
      sim/arm/wrapper.c
  3. 2
      sim/avr/interp.c
  4. 2
      sim/bfin/interp.c
  5. 2
      sim/bpf/sim-if.c
  6. 5
      sim/common/sim-cpu.c
  7. 2
      sim/cr16/interp.c
  8. 2
      sim/cris/sim-if.c
  9. 2
      sim/d10v/interp.c
  10. 2
      sim/example-synacor/interp.c
  11. 2
      sim/frv/sim-if.c
  12. 2
      sim/ft32/interp.c
  13. 2
      sim/h8300/compile.c
  14. 2
      sim/iq2000/sim-if.c
  15. 2
      sim/lm32/sim-if.c
  16. 2
      sim/m32r/sim-if.c
  17. 2
      sim/m68hc11/interp.c
  18. 2
      sim/mcore/interp.c
  19. 2
      sim/microblaze/interp.c
  20. 2
      sim/mips/interp.c
  21. 2
      sim/mn10300/interp.c
  22. 2
      sim/moxie/interp.c
  23. 2
      sim/msp430/msp430-sim.c
  24. 2
      sim/or1k/sim-if.c
  25. 2
      sim/pru/interp.c
  26. 2
      sim/riscv/interp.c
  27. 2
      sim/sh/interp.c
  28. 2
      sim/v850/interp.c

2
sim/aarch64/interp.c

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

2
sim/arm/wrapper.c

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

2
sim/avr/interp.c

@ -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);

2
sim/bfin/interp.c

@ -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);

2
sim/bpf/sim-if.c

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

5
sim/common/sim-cpu.c

@ -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;
}

2
sim/cr16/interp.c

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

2
sim/cris/sim-if.c

@ -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);

2
sim/d10v/interp.c

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

2
sim/example-synacor/interp.c

@ -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);

2
sim/frv/sim-if.c

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

2
sim/ft32/interp.c

@ -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);

2
sim/h8300/compile.c

@ -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);

2
sim/iq2000/sim-if.c

@ -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);

2
sim/lm32/sim-if.c

@ -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);

2
sim/m32r/sim-if.c

@ -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);

2
sim/m68hc11/interp.c

@ -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);

2
sim/mcore/interp.c

@ -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);

2
sim/microblaze/interp.c

@ -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);

2
sim/mips/interp.c

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

2
sim/mn10300/interp.c

@ -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 */

2
sim/moxie/interp.c

@ -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);

2
sim/msp430/msp430-sim.c

@ -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);

2
sim/or1k/sim-if.c

@ -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);

2
sim/pru/interp.c

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

2
sim/riscv/interp.c

@ -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);

2
sim/sh/interp.c

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

2
sim/v850/interp.c

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

Loading…
Cancel
Save