From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59989) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xwua1-0003bv-QK for qemu-devel@nongnu.org; Fri, 05 Dec 2014 10:14:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XwuZr-0002TL-BF for qemu-devel@nongnu.org; Fri, 05 Dec 2014 10:14:01 -0500 Received: from mail-wi0-x22e.google.com ([2a00:1450:400c:c05::22e]:46787) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XwuZr-0002T1-3l for qemu-devel@nongnu.org; Fri, 05 Dec 2014 10:13:51 -0500 Received: by mail-wi0-f174.google.com with SMTP id h11so1712522wiw.13 for ; Fri, 05 Dec 2014 07:13:49 -0800 (PST) Sender: Paolo Bonzini Message-ID: <5481CBA7.80202@redhat.com> Date: Fri, 05 Dec 2014 16:13:43 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <20141126103841.7772.11864.stgit@PASHA-ISP> <20141126103925.7772.13043.stgit@PASHA-ISP> <547EE34D.4000500@redhat.com> <000c01d00fb1$c2010860$46031920$@Dovgaluk@ispras.ru> <548082E2.2060602@redhat.com> <000301d0104d$29dc3d10$7d94b730$@Dovgaluk@ispras.ru> <54818AC0.50400@redhat.com> <001301d0107a$0388b5d0$0a9a2170$@Dovgaluk@ispras.ru> <54819A74.9090607@redhat.com> <12880.8243353435$1417784373@news.gmane.org> In-Reply-To: <12880.8243353435$1417784373@news.gmane.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RFC PATCH v5 07/31] icount: implement icount requesting List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Pavel Dovgaluk , qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, peter.crosthwaite@xilinx.com, mark.burton@greensocs.com, real@ispras.ru, batuzovk@ispras.ru, maria.klimushenkova@ispras.ru, alex.bennee@linaro.org, afaerber@suse.de, fred.konrad@greensocs.com On 05/12/2014 13:59, Pavel Dovgaluk wrote: >> From: Paolo Bonzini [mailto:pbonzini@redhat.com] >> On 05/12/2014 11:55, Pavel Dovgaluk wrote: >>>>> >>>>> And why is can_do_io zero? :) Is the fix to move the place where >>>>> can_do_io becomes nonzero? >>> can_do_io is set by gen_io_start function. >>> As I understand, it is used to protect determinism in icount mode, >>> because it allows non-deterministic (port io, raising interrupt) >>> operations only at the end of the translation blocks. >>> When someone tries to use MMIO in the middle of TB, that TB is >>> recompiled to place this instruction at the end of the block. >>> >>> Do you mean that we can set can_do_io before execution of the block >>> and reset it at the beginning of the execution? >> >> Yes, we could try setting it after execution of the block and clearing >> it afterwards. Peter knows that part of icount better though (I know >> mostly the timer/warping parts). > > Ok, how about these changes? > > diff --git a/cpu-exec.c b/cpu-exec.c > index f52f292..88675ca 100644 > --- a/cpu-exec.c > +++ b/cpu-exec.c > @@ -168,7 +168,9 @@ static inline tcg_target_ulong cpu_tb_exec(CPUState *cpu, uint8_t *tb_ptr) > } > #endif /* DEBUG_DISAS */ > > + cpu->can_do_io = 0; > next_tb = tcg_qemu_tb_exec(env, tb_ptr); > + cpu->can_do_io = 1; > trace_exec_tb_exit((void *) (next_tb & ~TB_EXIT_MASK), > next_tb & TB_EXIT_MASK); > > @@ -548,6 +550,7 @@ int cpu_exec(CPUArchState *env) > cpu = current_cpu; > env = cpu->env_ptr; > cc = CPU_GET_CLASS(cpu); > + cpu->can_do_io = 1; > #ifdef TARGET_I386 > x86_cpu = X86_CPU(cpu); > #endif > diff --git a/cpus.c b/cpus.c > index 0c33458..7a45a51 100644 > --- a/cpus.c > +++ b/cpus.c > @@ -934,6 +934,7 @@ static void *qemu_kvm_cpu_thread_fn(void *arg) > qemu_mutex_lock(&qemu_global_mutex); > qemu_thread_get_self(cpu->thread); > cpu->thread_id = qemu_get_thread_id(); > + cpu->can_do_io = 1; > current_cpu = cpu; > > r = kvm_init_vcpu(cpu); > @@ -974,6 +975,7 @@ static void *qemu_dummy_cpu_thread_fn(void *arg) > qemu_mutex_lock_iothread(); > qemu_thread_get_self(cpu->thread); > cpu->thread_id = qemu_get_thread_id(); > + cpu->can_do_io = 1; > > sigemptyset(&waitset); > sigaddset(&waitset, SIG_IPI); > @@ -1016,6 +1018,7 @@ static void *qemu_tcg_cpu_thread_fn(void *arg) > CPU_FOREACH(cpu) { > cpu->thread_id = qemu_get_thread_id(); > cpu->created = true; > + cpu->can_do_io = 1; > } > qemu_cond_signal(&qemu_cpu_cond); Yes, this would work too, thanks for trying it! Paolo