Received: from eggs.gnu.org ([2001:4830:134:3::10]:53023) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZflo-0005nX-EG for qemu-devel@nongnu.org; Wed, 09 Sep 2015 09:50:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZfll-00034Q-NU for qemu-devel@nongnu.org; Wed, 09 Sep 2015 09:50:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51367) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZfll-00034F-Id for qemu-devel@nongnu.org; Wed, 09 Sep 2015 09:50:37 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 4286BC0AA266 for ; Wed, 9 Sep 2015 13:50:37 +0000 (UTC) Received: from donizetti.redhat.com (ovpn-112-83.ams2.redhat.com [10.36.112.83]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t89DoEhw030571 for ; Wed, 9 Sep 2015 09:50:36 -0400 From: Paolo Bonzini Date: Wed, 9 Sep 2015 15:49:43 +0200 Message-Id: <1441806613-13775-14-git-send-email-pbonzini@redhat.com> In-Reply-To: <1441806613-13775-1-git-send-email-pbonzini@redhat.com> References: <1441806613-13775-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PULL 13/43] tcg: synchronize cpu->exit_request and cpu->tcg_exit_req accesses List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Reviewed-by: Richard Henderson Signed-off-by: Paolo Bonzini --- cpu-exec.c | 6 +++++- qom/cpu.c | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/cpu-exec.c b/cpu-exec.c index 567ae8b..e24c640 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -507,8 +507,12 @@ int cpu_exec(CPUState *cpu) * loop. Whatever requested the exit will also * have set something else (eg exit_request or * interrupt_request) which we will handle - * next time around the loop. + * next time around the loop. But we need to + * ensure the tcg_exit_req read in generated code + * comes before the next read of cpu->exit_request + * or cpu->interrupt_request. */ + smp_rmb(); next_tb = 0; break; case TB_EXIT_ICOUNT_EXPIRED: diff --git a/qom/cpu.c b/qom/cpu.c index 62f4b5d..02b56f7 100644 --- a/qom/cpu.c +++ b/qom/cpu.c @@ -114,6 +114,8 @@ void cpu_reset_interrupt(CPUState *cpu, int mask) void cpu_exit(CPUState *cpu) { cpu->exit_request = 1; + /* Ensure cpu_exec will see the exit request after TCG has exited. */ + smp_wmb(); cpu->tcg_exit_req = 1; } -- 2.4.3