When TCG runs with '-icount', resetting a vCPU from inside
cpu_exec() can advance the virtual clock by the whole unused
part of that vCPU's current instruction budget.

Fix by accounting the instructions executed so far immediately
before the common CPU reset path clears the decrementer. Resets
outside active cpu_exec() remain unchanged.

Philippe Mathieu-Daudé (2):
  accel/tcg: Extract icount_cpu_reset() helper
  accel/tcg: Fix icount accounting on CPU reset

 include/exec/icount.h         |   2 +
 accel/tcg/icount-common.c     |  16 +++++
 hw/core/cpu-common.c          |   4 +-
 stubs/icount.c                |   3 +
 tests/qtest/icount-x86-test.c | 119 ++++++++++++++++++++++++++++++++++
 tests/qtest/meson.build       |   2 +
 6 files changed, 144 insertions(+), 2 deletions(-)
 create mode 100644 tests/qtest/icount-x86-test.c

-- 
2.55.0


Reply via email to