From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41360) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZUOPg-0002aI-Eo for qemu-devel@nongnu.org; Tue, 25 Aug 2015 20:18:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZUOPf-0000Nh-N0 for qemu-devel@nongnu.org; Tue, 25 Aug 2015 20:18:00 -0400 Received: from mail-wi0-x230.google.com ([2a00:1450:400c:c05::230]:34269) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZUOPf-0000N2-GN for qemu-devel@nongnu.org; Tue, 25 Aug 2015 20:17:59 -0400 Received: by widdq5 with SMTP id dq5so30735024wid.1 for ; Tue, 25 Aug 2015 17:17:58 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Wed, 26 Aug 2015 02:17:42 +0200 Message-Id: <1440548265-4755-7-git-send-email-pbonzini@redhat.com> In-Reply-To: <1440548265-4755-1-git-send-email-pbonzini@redhat.com> References: <1440548265-4755-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 6/9] 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 Cc: mttcg@greensocs.com, cota@braap.org, rth@twiddle.net 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 7fcc46f..2128bf1 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -542,8 +542,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 3e93223..3841f0d 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