From nobody Fri Nov 7 12:30:11 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 1539183188660900.5753729341271; Wed, 10 Oct 2018 07:53:08 -0700 (PDT) Received: from localhost ([::1]:57711 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gAFrH-0005R2-Nl for importer@patchew.org; Wed, 10 Oct 2018 10:53:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58915) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gAFnU-0002nu-GB for qemu-devel@nongnu.org; Wed, 10 Oct 2018 10:49:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gAFnP-0004ba-MU for qemu-devel@nongnu.org; Wed, 10 Oct 2018 10:49:12 -0400 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:41295) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gAFnP-0004aP-F0 for qemu-devel@nongnu.org; Wed, 10 Oct 2018 10:49:07 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 0318C21F86; Wed, 10 Oct 2018 10:49:05 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Wed, 10 Oct 2018 10:49:05 -0400 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 93FA4102F0; Wed, 10 Oct 2018 10:49:04 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h= from:to:cc:subject:date:message-id:in-reply-to:references; s= mesmtp; bh=kQovQBwyOE8NRXGBmyghO6a5DpCuC7KJZuJpXboCGBw=; b=wGFp7 1dd1YxNBoBnbGvujoUGiwCn7m4fVPvbvt4ZPXhjNbuHtGLC6pKh4M9M+VmVCiV3o d1p8LnNfqfWhHK7B33+aov39KrzdhaglnC3tys5unYy4jZZHuV3jNQ8s+FaM5gAv 9J3twmtt3kxrVookwnvqyD8Zt8AKYUebQh4B9g= 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-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=kQovQBwyOE8NRXGBmyghO6a5DpCuC 7KJZuJpXboCGBw=; b=xwTKg13WzMfp0NAkk1p+fnJUbVgbWIBlperfCcVuGBGsJ m6JcHtAi+wgonz69pseN+MVjE9Vqj895iXYwSVTRnK/8L65MhI6G58jzAQIxgHLQ eTWUkNnGVOqYUWrXAdPnt4dEmfGEJ6RQmxBZMTbcC/r05Ze0PSelWlL4mybx9oL2 lS38YnfkF5FpGEObBKfpipUmSWWAKyXMav0PTpcftaYkbJRsKnVzzni2D4OVBRzG Cf5FeC+N8wHiieuomAJLTJL4GDIXhWe7pqgkMyMzcRZsCTZ9BHsyRcLQInNEm7um lrmV4A9MelKbl/O8WAS+yUwgXjYHKnKjKDYeUOyRA== X-ME-Sender: X-ME-Proxy: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Wed, 10 Oct 2018 10:48:50 -0400 Message-Id: <20181010144853.13005-2-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181010144853.13005-1-cota@braap.org> References: <20181010144853.13005-1-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.111.4.27 Subject: [Qemu-devel] [PATCH 1/4] tcg: access cpu->icount_decr.u16.high 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: Richard Henderson 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" Consistently access u16.high with atomics to avoid undefined behaviour in MTTCG. Note that icount_decr.u16.low is only used in icount mode, so regular accesses to it are OK. Reviewed-by: Richard Henderson Signed-off-by: Emilio G. Cota --- accel/tcg/tcg-all.c | 2 +- accel/tcg/translate-all.c | 2 +- qom/cpu.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/accel/tcg/tcg-all.c b/accel/tcg/tcg-all.c index 56dbb56a16..3d25bdcc17 100644 --- a/accel/tcg/tcg-all.c +++ b/accel/tcg/tcg-all.c @@ -51,7 +51,7 @@ static void tcg_handle_interrupt(CPUState *cpu, int mask) if (!qemu_cpu_is_self(cpu)) { qemu_cpu_kick(cpu); } else { - cpu->icount_decr.u16.high =3D -1; + atomic_set(&cpu->icount_decr.u16.high, -1); if (use_icount && !cpu->can_do_io && (mask & ~old_mask) !=3D 0) { diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index ad5c758246..356dcd0948 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -2341,7 +2341,7 @@ void cpu_interrupt(CPUState *cpu, int mask) { g_assert(qemu_mutex_iothread_locked()); cpu->interrupt_request |=3D mask; - cpu->icount_decr.u16.high =3D -1; + atomic_set(&cpu->icount_decr.u16.high, -1); } =20 /* diff --git a/qom/cpu.c b/qom/cpu.c index 92599f3541..20ad54d43f 100644 --- a/qom/cpu.c +++ b/qom/cpu.c @@ -266,7 +266,7 @@ static void cpu_common_reset(CPUState *cpu) cpu->mem_io_pc =3D 0; cpu->mem_io_vaddr =3D 0; cpu->icount_extra =3D 0; - cpu->icount_decr.u32 =3D 0; + atomic_set(&cpu->icount_decr.u32, 0); cpu->can_do_io =3D 1; cpu->exception_index =3D -1; cpu->crash_occurred =3D false; --=20 2.17.1