From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (woodpecker.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) by sourceware.org (Postfix) with ESMTP id 85EF03850F02 for ; Sun, 25 Dec 2022 07:14:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 85EF03850F02 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gentoo.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gentoo.org Received: by smtp.gentoo.org (Postfix, from userid 559) id 4D99E340F90; Sun, 25 Dec 2022 07:14:53 +0000 (UTC) From: Mike Frysinger To: gdb-patches@sourceware.org Subject: [PATCH 7/9] sim: cpu: change default init to handle all cpus Date: Sun, 25 Dec 2022 02:14:32 -0500 Message-Id: <20221225071434.30014-7-vapier@gentoo.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20221225071434.30014-1-vapier@gentoo.org> References: <20221225071434.30014-1-vapier@gentoo.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00,GIT_PATCH_0,JMQ_SPF_NEUTRAL,KAM_DMARC_STATUS,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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. --- sim/aarch64/interp.c | 2 +- sim/arm/wrapper.c | 2 +- sim/avr/interp.c | 2 +- sim/bfin/interp.c | 2 +- sim/bpf/sim-if.c | 2 +- sim/common/sim-cpu.c | 5 +++++ sim/cr16/interp.c | 2 +- sim/cris/sim-if.c | 2 +- sim/d10v/interp.c | 2 +- sim/example-synacor/interp.c | 2 +- sim/frv/sim-if.c | 2 +- sim/ft32/interp.c | 2 +- sim/h8300/compile.c | 2 +- sim/iq2000/sim-if.c | 2 +- sim/lm32/sim-if.c | 2 +- sim/m32r/sim-if.c | 2 +- sim/m68hc11/interp.c | 2 +- sim/mcore/interp.c | 2 +- sim/microblaze/interp.c | 2 +- sim/mips/interp.c | 2 +- sim/mn10300/interp.c | 2 +- sim/moxie/interp.c | 2 +- sim/msp430/msp430-sim.c | 2 +- sim/or1k/sim-if.c | 2 +- sim/pru/interp.c | 2 +- sim/riscv/interp.c | 2 +- sim/sh/interp.c | 2 +- sim/v850/interp.c | 2 +- 28 files changed, 32 insertions(+), 27 deletions(-) diff --git a/sim/aarch64/interp.c b/sim/aarch64/interp.c index 234d978a7685..03efb42e6b5e 100644 --- a/sim/aarch64/interp.c +++ b/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 diff --git a/sim/arm/wrapper.c b/sim/arm/wrapper.c index 5eb61df14378..4e8007804546 100644 --- a/sim/arm/wrapper.c +++ b/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; diff --git a/sim/avr/interp.c b/sim/avr/interp.c index ddd9e1ff1eae..27834f15dbc3 100644 --- a/sim/avr/interp.c +++ b/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); diff --git a/sim/bfin/interp.c b/sim/bfin/interp.c index 04c1773eaf42..e904506bf228 100644 --- a/sim/bfin/interp.c +++ b/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); diff --git a/sim/bpf/sim-if.c b/sim/bpf/sim-if.c index b29300f03287..4c9aa83232aa 100644 --- a/sim/bpf/sim-if.c +++ b/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) diff --git a/sim/common/sim-cpu.c b/sim/common/sim-cpu.c index 024bd050ab3d..9f64d9d06e8d 100644 --- a/sim/common/sim-cpu.c +++ b/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; } diff --git a/sim/cr16/interp.c b/sim/cr16/interp.c index 1830e348a060..fe1e24bed68b 100644 --- a/sim/cr16/interp.c +++ b/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; diff --git a/sim/cris/sim-if.c b/sim/cris/sim-if.c index 47862edf4f5a..d939854e32d1 100644 --- a/sim/cris/sim-if.c +++ b/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); diff --git a/sim/d10v/interp.c b/sim/d10v/interp.c index 9beedf8f445e..aebd98ab6ac6 100644 --- a/sim/d10v/interp.c +++ b/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; diff --git a/sim/example-synacor/interp.c b/sim/example-synacor/interp.c index 20ae057d43a1..25e519d9f2ab 100644 --- a/sim/example-synacor/interp.c +++ b/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); diff --git a/sim/frv/sim-if.c b/sim/frv/sim-if.c index 6e0f1bbaba64..ad94423f40b6 100644 --- a/sim/frv/sim-if.c +++ b/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; diff --git a/sim/ft32/interp.c b/sim/ft32/interp.c index dfea4720c220..1eda9a7a2869 100644 --- a/sim/ft32/interp.c +++ b/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); diff --git a/sim/h8300/compile.c b/sim/h8300/compile.c index cc8b52c5d654..467eeafde610 100644 --- a/sim/h8300/compile.c +++ b/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); diff --git a/sim/iq2000/sim-if.c b/sim/iq2000/sim-if.c index e9b66b6a7ef9..e02a413103e2 100644 --- a/sim/iq2000/sim-if.c +++ b/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); diff --git a/sim/lm32/sim-if.c b/sim/lm32/sim-if.c index 82f2e117671e..b51028055124 100644 --- a/sim/lm32/sim-if.c +++ b/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); diff --git a/sim/m32r/sim-if.c b/sim/m32r/sim-if.c index 7fe6b42801e7..1305ea6d1021 100644 --- a/sim/m32r/sim-if.c +++ b/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); diff --git a/sim/m68hc11/interp.c b/sim/m68hc11/interp.c index b80f5cb82bb0..82155213330a 100644 --- a/sim/m68hc11/interp.c +++ b/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); diff --git a/sim/mcore/interp.c b/sim/mcore/interp.c index 84b243f07059..ae554c77d31c 100644 --- a/sim/mcore/interp.c +++ b/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); diff --git a/sim/microblaze/interp.c b/sim/microblaze/interp.c index 8a8cb9f2b832..df7f41fcff56 100644 --- a/sim/microblaze/interp.c +++ b/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); diff --git a/sim/mips/interp.c b/sim/mips/interp.c index fa192d36f2e9..d44c474ae1d6 100644 --- a/sim/mips/interp.c +++ b/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; diff --git a/sim/mn10300/interp.c b/sim/mn10300/interp.c index 8467070addb6..2915551253f3 100644 --- a/sim/mn10300/interp.c +++ b/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 */ diff --git a/sim/moxie/interp.c b/sim/moxie/interp.c index 144d83cbe8e7..2bc241db6f56 100644 --- a/sim/moxie/interp.c +++ b/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); diff --git a/sim/msp430/msp430-sim.c b/sim/msp430/msp430-sim.c index e7b58bab1347..c02e7ca4b6f5 100644 --- a/sim/msp430/msp430-sim.c +++ b/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); diff --git a/sim/or1k/sim-if.c b/sim/or1k/sim-if.c index 799812bb741e..3bbf4f05738f 100644 --- a/sim/or1k/sim-if.c +++ b/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); diff --git a/sim/pru/interp.c b/sim/pru/interp.c index 250a32a889a5..0e1874c11805 100644 --- a/sim/pru/interp.c +++ b/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; diff --git a/sim/riscv/interp.c b/sim/riscv/interp.c index a49ad0476c45..601753e02916 100644 --- a/sim/riscv/interp.c +++ b/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); diff --git a/sim/sh/interp.c b/sim/sh/interp.c index b2d30e386c1a..5a90cd2cf74c 100644 --- a/sim/sh/interp.c +++ b/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; diff --git a/sim/v850/interp.c b/sim/v850/interp.c index efe35c606ffb..948b7245c3f0 100644 --- a/sim/v850/interp.c +++ b/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; -- 2.39.0