binutils-gdb/sim/common
Mike Frysinger 891e7fb179 sim: change to 64bit time keeping to avoid 32bit overflows
The sim-events code jumps through some hoops to avoid using 64bit math
to manage the current time.  One fundamental assumption here is that by
constantly scheduling the sim poll event a short time into the future,
the 64bit difference will always fall into a signed 32bit value.  This
does work most of the time, except for when processing the sim poll event
itself.

Normally, sim_events_process() will dequeue the sim poll event, update
the current time (time_from_event) according to the next pending event,
process the sim poll event (which will then requeue the sim poll event),
and then continue on.

The problem here of course is that the current time is updated in that
small window before the sim poll event gets a chance to reschedule itself.
So if the 64bit difference between the current time and the next event
does not fit into the signed 32bit value, time_from_event overflows, and
the internal assert at the end of update_time_from_event() triggers.

Since attempts at tweaking sim_events_process() logic introduced other
subtle bugs (due to tangled assumptions between most pieces of the sim
time keeping code), change the time_from_event to a real 64bit value.
Tests on my system between a 32bit ELF and a 64bit ELF show no practical
difference (it's all lost in the system noise).  Basically, I booted a
Linux kernel to userspace and then paniced it; this gave me a constant
sample size of about 18 million insns.

This was noticed when simulating Blackfin Das U-Boot.  The simulated core
timer is given the max unsigned timeout value possible on a 32bit processor
(0xffffffff).  This timeout value is used directly to schedule a hw event
in the sim future (the IRQ firing).  Once the sim poll event is kicked off,
the next pending event is the core timer event which is more than 2^31
ticks in the future, and the sim aborts with:
sim-events.c:435: assertion failed - current_time == sim_events_time (sd)

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2011-02-14 04:58:12 +00:00
..
ChangeLog sim: change to 64bit time keeping to avoid 32bit overflows 2011-02-14 04:58:12 +00:00
Make-common.in run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
Makefile.in run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
aclocal.m4 sim: fix handling of 2nd arg to SIM_AC_OPTION_HARDWARE 2011-01-10 21:53:27 +00:00
callback.c run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
cgen-accfp.c common/ 2010-01-25 04:08:52 +00:00
cgen-cpu.h run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
cgen-defs.h run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
cgen-engine.h run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
cgen-fpu.c
cgen-fpu.h common/ 2010-01-25 04:08:52 +00:00
cgen-mem.h run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
cgen-ops.h run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
cgen-par.c run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
cgen-par.h run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
cgen-run.c run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
cgen-scache.c run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
cgen-scache.h run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
cgen-sim.h run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
cgen-trace.c run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
cgen-trace.h run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
cgen-types.h run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
cgen-utils.c run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
cgen.sh * Make-common.in (CGEN_CPU_EXTR,CGEN_CPU_READ): Pass canonical 2009-07-07 08:09:19 +00:00
common.m4 * common/aclocal.m4: Add include of ../../config/zlib.m4. 2009-11-24 22:58:08 +00:00
config.in sim: use socklen_t with accept() 2010-03-30 23:09:48 +00:00
configure sim: use socklen_t with accept() 2010-03-30 23:09:48 +00:00
configure.ac sim: use socklen_t with accept() 2010-03-30 23:09:48 +00:00
dv-core.c run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
dv-glue.c run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
dv-pal.c run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
dv-sockser.c run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
dv-sockser.h sim: dv-sockser: add a write buffer variant 2010-11-16 19:10:29 +00:00
gdbinit.in
genmloop.sh run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
gennltvals.sh gdb/ 2009-05-18 13:25:35 +00:00
gentmap.c
gentvals.sh
hw-alloc.c run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
hw-alloc.h run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
hw-base.c run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
hw-base.h run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
hw-device.c run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
hw-device.h sim: add noreturn markings to more hw abort/halt funcs 2011-01-10 21:52:08 +00:00
hw-events.c run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
hw-events.h run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
hw-handles.c run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
hw-handles.h run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
hw-instances.c run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
hw-instances.h run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
hw-main.h run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
hw-ports.c run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
hw-ports.h run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
hw-properties.c run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
hw-properties.h run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
hw-tree.c run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
hw-tree.h run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
nltvals.def gdb/ 2009-05-18 13:25:35 +00:00
nrun.c run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
run-sim.h run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
run.1 Update the copyright year for most remaining files in GDB 2011-01-05 05:09:55 +00:00
run.c run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
sim-abort.c run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
sim-alu.h run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
sim-arange.c run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
sim-arange.h run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
sim-assert.h
sim-base.h run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
sim-basics.h run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
sim-bits.c run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
sim-bits.h run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
sim-config.c run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
sim-config.h run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
sim-core.c run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
sim-core.h run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
sim-cpu.c run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
sim-cpu.h run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
sim-endian.c run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
sim-endian.h run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
sim-engine.c run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
sim-engine.h run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
sim-events.c run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
sim-events.h sim: change to 64bit time keeping to avoid 32bit overflows 2011-02-14 04:58:12 +00:00
sim-fpu.c run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
sim-fpu.h run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
sim-hload.c run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
sim-hrw.c run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
sim-hw.c sim: enable hw_tree_delete in sim_hw_uninstall 2011-01-12 22:10:46 +00:00
sim-hw.h sim: add noreturn markings to more hw abort/halt funcs 2011-01-10 21:52:08 +00:00
sim-info.c run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
sim-inline.c run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
sim-inline.h run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
sim-io.c run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
sim-io.h run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
sim-load.c sim: tweak load buffer type to avoid signed warnings 2011-01-05 17:13:36 +00:00
sim-memopt.c sim: allow memory maps to default to mapped files 2011-01-11 17:58:56 +00:00
sim-memopt.h run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
sim-model.c run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
sim-model.h run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
sim-module.c sim: check asprintf return values 2011-01-12 21:58:08 +00:00
sim-module.h run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
sim-n-bits.h run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
sim-n-core.h run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
sim-n-endian.h run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
sim-options.c sim: check asprintf return values 2011-01-12 21:58:08 +00:00
sim-options.h run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
sim-profile.c run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
sim-profile.h run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
sim-reason.c run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
sim-reg.c run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
sim-resume.c run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
sim-run.c run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
sim-signal.c run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
sim-signal.h run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
sim-stop.c run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
sim-trace.c run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
sim-trace.h run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
sim-types.h run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
sim-utils.c sim: check asprintf return values 2011-01-12 21:58:08 +00:00
sim-utils.h run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
sim-watch.c sim: check asprintf return values 2011-01-12 21:58:08 +00:00
sim-watch.h run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
syscall.c run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
tconfig.in
version.h run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00