From nobody Wed Nov 5 20:16:09 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1537202986742861.3885395617059; Mon, 17 Sep 2018 09:49:46 -0700 (PDT) Received: from localhost ([::1]:36535 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g1wiX-0004wL-Ce for importer@patchew.org; Mon, 17 Sep 2018 12:49:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41118) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g1wQo-0006Qh-RL for qemu-devel@nongnu.org; Mon, 17 Sep 2018 12:31:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g1wQl-0002BL-Qu for qemu-devel@nongnu.org; Mon, 17 Sep 2018 12:31:26 -0400 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:53639) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g1wQl-0001qm-CL for qemu-devel@nongnu.org; Mon, 17 Sep 2018 12:31:23 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id D843F536; Mon, 17 Sep 2018 12:31:11 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Mon, 17 Sep 2018 12:31:12 -0400 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 357F6E49C7; Mon, 17 Sep 2018 12:31:11 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h=cc :date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=mesmtp; bh=CQs0jtIvoqX44H vh8iJ48dyFTmAHSgPQM3njTh9rXI0=; b=pSvUjx0wjgvwbyNj5A7rQC6EaiMeX7 tMjRlBVPaVAFeNg83N2y1BSHJx1ecK2OIrvTDbWBmuTNxSrhHh2S4hUS6ocAfkXX 3dWA8gwH90EJgSP9obSJQBCg0MgKb0dv7H5GRYHVmoT76U0us19jCqtJqwzyQ5s6 H3bfNyLmgzrL4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=CQs0jtIvoqX44Hvh8iJ48dyFTmAHSgPQM3njTh9rXI0=; b=OHWRSdb4 WVhhlzoo3cL2eo94kG8T2s7PvMcDMXwCNbOnXclJB1dwJDyYUi7/KK52cRpNIgI8 NHJSeOMAZdR1AIR8dXUse1Zl679QwZe8P/khlq1sis8bYesfE1hOQtkLHRSrZfDd coVn7OAhnoyHkIxWTddD5Q/bxz+HzrMaN8d+qR+KpEAX3PKOLdmWzZqhzwEYYAvC C8ga7tg3BrzvRxAMynNIau54V6l15y8xnzMPKN3by+tCEmUZYIEcVR1aVCbPc+ql 44qIgnkP9ie0NmlQivENo/+vxcHNoGZJrdYu74EMCFbKA9f1u00I5CV4alPBrFHS OC6Qs5pPU7g+cw== X-ME-Proxy: X-ME-Sender: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Mon, 17 Sep 2018 12:30:56 -0400 Message-Id: <20180917163103.6113-29-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180917163103.6113-1-cota@braap.org> References: <20180917163103.6113-1-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 64.147.123.25 Subject: [Qemu-devel] [PATCH 28/35] exec: access cpu->interrupt_request with atomics X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Richard Henderson , Peter Crosthwaite Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Paolo Bonzini Cc: Peter Crosthwaite Cc: Richard Henderson Signed-off-by: Paolo Bonzini Signed-off-by: Emilio G. Cota --- accel/tcg/cpu-exec.c | 6 +++--- accel/tcg/tcg-all.c | 3 +-- accel/tcg/translate-all.c | 2 +- qom/cpu.c | 6 +++--- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 7ca00725ec..2383763f9b 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -426,7 +426,7 @@ static inline bool cpu_handle_halt(CPUState *cpu) { if (cpu->halted) { #if defined(TARGET_I386) && !defined(CONFIG_USER_ONLY) - if ((cpu->interrupt_request & CPU_INTERRUPT_POLL) + if ((atomic_read(&cpu->interrupt_request) & CPU_INTERRUPT_POLL) && replay_interrupt()) { X86CPU *x86_cpu =3D X86_CPU(cpu); qemu_mutex_lock_iothread(); @@ -527,7 +527,7 @@ static inline bool cpu_handle_interrupt(CPUState *cpu, if (unlikely(atomic_read(&cpu->interrupt_request))) { int interrupt_request; qemu_mutex_lock_iothread(); - interrupt_request =3D cpu->interrupt_request; + interrupt_request =3D atomic_read(&cpu->interrupt_request); if (unlikely(cpu->singlestep_enabled & SSTEP_NOIRQ)) { /* Mask out external interrupts for this step. */ interrupt_request &=3D ~CPU_INTERRUPT_SSTEP_MASK; @@ -579,7 +579,7 @@ static inline bool cpu_handle_interrupt(CPUState *cpu, } /* The target hook may have updated the 'cpu->interrupt_reques= t'; * reload the 'interrupt_request' value */ - interrupt_request =3D cpu->interrupt_request; + interrupt_request =3D atomic_read(&cpu->interrupt_request); } if (interrupt_request & CPU_INTERRUPT_EXITTB) { cpu_reset_interrupt(cpu, CPU_INTERRUPT_EXITTB); diff --git a/accel/tcg/tcg-all.c b/accel/tcg/tcg-all.c index 3d25bdcc17..69ad44bd54 100644 --- a/accel/tcg/tcg-all.c +++ b/accel/tcg/tcg-all.c @@ -41,8 +41,7 @@ static void tcg_handle_interrupt(CPUState *cpu, int mask) int old_mask; g_assert(qemu_mutex_iothread_locked()); =20 - old_mask =3D cpu->interrupt_request; - cpu->interrupt_request |=3D mask; + old_mask =3D atomic_fetch_or(&cpu->interrupt_request, mask); =20 /* * If called from iothread context, wake the target cpu in diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index f7784bbc2d..364757c677 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -2351,7 +2351,7 @@ void dump_opcount_info(FILE *f, fprintf_function cpu_= fprintf) void cpu_interrupt(CPUState *cpu, int mask) { g_assert(qemu_mutex_iothread_locked()); - cpu->interrupt_request |=3D mask; + atomic_or(&cpu->interrupt_request, mask); atomic_set(&cpu->icount_decr.u16.high, -1); } =20 diff --git a/qom/cpu.c b/qom/cpu.c index 20ad54d43f..e2dfbde7c4 100644 --- a/qom/cpu.c +++ b/qom/cpu.c @@ -103,7 +103,7 @@ void cpu_reset_interrupt(CPUState *cpu, int mask) if (need_lock) { qemu_mutex_lock_iothread(); } - cpu->interrupt_request &=3D ~mask; + atomic_and(&cpu->interrupt_request, ~mask); if (need_lock) { qemu_mutex_unlock_iothread(); } @@ -261,7 +261,7 @@ static void cpu_common_reset(CPUState *cpu) log_cpu_state(cpu, cc->reset_dump_flags); } =20 - cpu->interrupt_request =3D 0; + atomic_set(&cpu->interrupt_request, 0); cpu->halted =3D 0; cpu->mem_io_pc =3D 0; cpu->mem_io_vaddr =3D 0; @@ -395,7 +395,7 @@ static vaddr cpu_adjust_watchpoint_address(CPUState *cp= u, vaddr addr, int len) =20 static void generic_handle_interrupt(CPUState *cpu, int mask) { - cpu->interrupt_request |=3D mask; + atomic_or(&cpu->interrupt_request, mask); =20 if (!qemu_cpu_is_self(cpu)) { qemu_cpu_kick(cpu); --=20 2.17.1