From nobody Tue Apr 8 22:25: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; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1539714387617816.919104111206; Tue, 16 Oct 2018 11:26:27 -0700 (PDT) Received: from localhost ([::1]:59601 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gCU30-0004eP-D7 for importer@patchew.org; Tue, 16 Oct 2018 14:26:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59698) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gCTTP-00046V-6H for qemu-devel@nongnu.org; Tue, 16 Oct 2018 13:49:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gCTTL-00010T-1V for qemu-devel@nongnu.org; Tue, 16 Oct 2018 13:49:38 -0400 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]:34559) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gCTTK-0000fG-LU for qemu-devel@nongnu.org; Tue, 16 Oct 2018 13:49:34 -0400 Received: by mail-pf1-x429.google.com with SMTP id f78-v6so6060615pfe.1 for ; Tue, 16 Oct 2018 10:49:18 -0700 (PDT) Received: from cloudburst.twiddle.net (174-21-9-133.tukw.qwest.net. [174.21.9.133]) by smtp.gmail.com with ESMTPSA id 6-v6sm17441210pgl.6.2018.10.16.10.49.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Oct 2018 10:49:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=w2Bp504AhgXMpCvkutSLGODfC2pPE7Pe3qOAFYLZ3OM=; b=QuHesdlDa4Zg7r33c+v6PzJYBHzJorvcjeOS7JHinX5v6XREj+pm7vEULcObKo8eHU mdilLbiOFJ2d7iuf1lU29jQR6hvRP6L/xvGgd3LV5fcr7aVxZmPSrcEBmm95ju9JLRme xHLAugFDEGUVPUhWfvqEZfHXRfVIf2QdDEmmE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=w2Bp504AhgXMpCvkutSLGODfC2pPE7Pe3qOAFYLZ3OM=; b=hNYhtr7moFpdLqUT0ev2eqeTG4IH/gENS4DjOzPphiP/eUOA3pz+4JB0U29vuItVZd 9UGyA79+Rm62/3BLOcqlEe8+boBXvjO7iW/ssrdOjuVgK0ZN9Um8Viasyc3GME9Osu0g 0TrhiLsDScM6n4FqW1GJ7VQCJYE/P4H++0JW/Sdy16Fo9JIx7VDPUbHspBFHrSfFYRd1 /908eRnuvXWgE8RHSz6GshYu4Wl8WdkWPa7wCzN/EseuRzlcU0TgZ7GMjhCdH4aPWpz+ GsEjO+i3Ma9Lj9sDkHkkfyuXJ4C8mcV68WzJB+k/rA7dzfpfM6X9zBs/P7ZrBJ4O5fso SGug== X-Gm-Message-State: ABuFfohpQvfDhT96bb1FsbE2/yKgcP8sGURUilcGjHpoPr64BrcKEoNn qS3/BbdLHB6WbCrIEc9v1B1jwZ6pyZE= X-Google-Smtp-Source: ACcGV62KCdyGm1c13YF2h5OpV0HFSH2q0WA0GU8WEyzrr2Z43NYykONeWjC4e7iwLioWf+er3sSfKA== X-Received: by 2002:a63:6c4a:: with SMTP id h71-v6mr20888859pgc.326.1539712156756; Tue, 16 Oct 2018 10:49:16 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 16 Oct 2018 10:48:52 -0700 Message-Id: <20181016174911.9052-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181016174911.9052-1-richard.henderson@linaro.org> References: <20181016174911.9052-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::429 Subject: [Qemu-devel] [PULL 02/21] 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: peter.maydell@linaro.org, "Emilio G. Cota" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Emilio G. Cota" 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 Message-Id: <20181010144853.13005-2-cota@braap.org> Signed-off-by: Richard Henderson --- 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.2