Received: from eggs.gnu.org ([2001:4830:134:3::10]:58355) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YxZsv-0004gt-Rm for qemu-devel@nongnu.org; Wed, 27 May 2015 07:52:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YxZsr-0007Dw-Ed for qemu-devel@nongnu.org; Wed, 27 May 2015 07:52:33 -0400 Received: from zimbra3.corp.accelance.fr ([213.162.49.233]:42851) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YxZsr-0007DV-67 for qemu-devel@nongnu.org; Wed, 27 May 2015 07:52:29 -0400 From: Victor CLEMENT Date: Wed, 27 May 2015 13:52:02 +0200 Message-Id: <1432727523-2008-3-git-send-email-victor.clement@openwide.fr> In-Reply-To: <1432727523-2008-1-git-send-email-victor.clement@openwide.fr> References: <1432727523-2008-1-git-send-email-victor.clement@openwide.fr> Subject: [Qemu-devel] [PATCH 2/3] icount: add rt parameter to the -icount option to toogle icount_no_rt mode List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: francois.guerret@hotmail.fr, Victor CLEMENT The 'rt' parameter sets the icount_no_rt mode, which is not enabled by default. To enable it, add the 'nort' parameter (or 'rt=off') to the qemu -icount option. Signed-off-by: Victor CLEMENT --- cpus.c | 15 +++++++++++++-- qemu-options.hx | 12 ++++++++++-- vl.c | 3 +++ 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/cpus.c b/cpus.c index 012d14b..eac3e19 100644 --- a/cpus.c +++ b/cpus.c @@ -520,9 +520,18 @@ void configure_icount(QemuOpts *opts, Error **errp) } return; } + + icount_no_rt = !qemu_opt_get_bool(opts, "rt", true); + if (!icount_no_rt) { + icount_warp_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL_RT, + icount_warp_rt, NULL); + } + icount_align_option = qemu_opt_get_bool(opts, "align", false); - icount_warp_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL_RT, - icount_warp_rt, NULL); + + if (icount_align_option && icount_no_rt) { + error_setg(errp, "align and nort options are incompatible"); + } if (strcmp(option, "auto") != 0) { errno = 0; icount_time_shift = strtol(option, &rem_str, 0); @@ -533,6 +542,8 @@ void configure_icount(QemuOpts *opts, Error **errp) return; } else if (icount_align_option) { error_setg(errp, "shift=auto and align=on are incompatible"); + } else if (icount_no_rt) { + error_setg(errp, "shift=auto and nort are incompatible"); } use_icount = 2; diff --git a/qemu-options.hx b/qemu-options.hx index ec356f6..531bed7 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -3086,9 +3086,10 @@ re-inject them. ETEXI DEF("icount", HAS_ARG, QEMU_OPTION_icount, \ - "-icount [shift=N|auto][,align=on|off]\n" \ + "-icount [shift=N|auto][,align=on|off][,nort]\n" \ " enable virtual instruction counter with 2^N clock ticks per\n" \ - " instruction and enable aligning the host and virtual clocks\n", QEMU_ARCH_ALL) + " instruction, enable aligning the host and virtual clocks\n" \ + " or disable real time cpu sleeping\n", QEMU_ARCH_ALL) STEXI @item -icount [shift=@var{N}|auto] @findex -icount @@ -3097,6 +3098,13 @@ instruction every 2^@var{N} ns of virtual time. If @code{auto} is specified then the virtual cpu speed will be automatically adjusted to keep virtual time within a few seconds of real time. +When the virtual cpu is sleeping, the virtual time will advance at default +speed unless @option{nort} is specified. +With @option{nort}, the virtual time will jump to the next timer deadline +instantly whenever the virtual cpu goes to sleep mode and will not advance +if no timer is enabled. This behavior give deterministic execution times from +the guest point of view. + Note that while this option can give deterministic behavior, it does not provide cycle accurate emulation. Modern CPUs contain superscalar out of order cores with complex cache hierarchies. The number of instructions diff --git a/vl.c b/vl.c index 15bccc4..0c377e8 100644 --- a/vl.c +++ b/vl.c @@ -470,6 +470,9 @@ static QemuOptsList qemu_icount_opts = { }, { .name = "align", .type = QEMU_OPT_BOOL, + }, { + .name = "rt", + .type = QEMU_OPT_BOOL, }, { /* end of list */ } }, -- 2.3.7