From patchwork Tue Oct 16 17:48:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 148986 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp5439440lji; Tue, 16 Oct 2018 11:25:09 -0700 (PDT) X-Google-Smtp-Source: ACcGV63uRuze5cpdrtmCTkrS+9cY0KJS7q7nOwawl0nj3cfWbJjV11RLWBJbSayhaFbS2t7UL/Ov X-Received: by 2002:a37:7dc4:: with SMTP id y187-v6mr22131854qkc.211.1539714309444; Tue, 16 Oct 2018 11:25:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539714309; cv=none; d=google.com; s=arc-20160816; b=QY2Wai10/rsSGq0hLgdRzs0zPbWVDU0VbO9PnSWjg44x/49s4gFNzSy5VC8ljFNM5Z qGC7KsM5sWQFAMzPOi4spGBQIFR10VN63xBkxzUV5vvcAF579+QuTS1+3R1aUdrhTYxr pOfc0dQu9QZ2tKHdcwkc9jVk7NwhEzpW7N6e6WTD83S1qTNihKNgVihyMQYHgNBwb22+ byCV/MH2SIEGOPYbCOz52CRiLFkIUEi1vIUPbDZBxMypvEKz4e8EHzmTnMDGbD13lhdO dgmNneRo19bAWbUP4FEYrJ1KwzYyrymlYaHsTpg8Zl+W4POSQ3dTYeiQN3Kv1HvZmmBI W7SQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=w2Bp504AhgXMpCvkutSLGODfC2pPE7Pe3qOAFYLZ3OM=; b=rVLgv2g5AK7KziuK8IYtiXoCjdeIffXG3xnMI9zb4MnJx+yLAXl2FtD6f2JOrGekJ5 46TCWvgSSRjpdKAXcLqzxy08M2CnnQrvVVNVWjPu6gtuaj4oluSu4zRrOvfNxY4uipR2 yfeJO5lASAey8bwbQhpySxK/JeuEJuEgPYbw7XJmcCTO94Ofklw97bL6gGeZbJ8wGTH3 +/TPcfzBALQey23Ui59t61R54SATac+JH7A4z825x82Zh/CSenaHZYVXcJ8o+QpO8BvY Bkvzl/KfAOvkU5U4nj1MoFQvJ3H6hzqIh5+mgagMZ7L9vvf/ai9+9hj6ykvDdrFkBFRe 7icQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=QuHesdlD; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id k96-v6si1438574qte.276.2018.10.16.11.25.09 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 16 Oct 2018 11:25:09 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=QuHesdlD; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:59589 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gCU1k-0003Yu-S5 for patch@linaro.org; Tue, 16 Oct 2018 14:25:08 -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) 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-Received: by 2002:a63:6c4a:: with SMTP id h71-v6mr20888859pgc.326.1539712156756; Tue, 16 Oct 2018 10:49:16 -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) 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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(-) -- 2.17.2 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 = -1; + atomic_set(&cpu->icount_decr.u16.high, -1); if (use_icount && !cpu->can_do_io && (mask & ~old_mask) != 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 |= mask; - cpu->icount_decr.u16.high = -1; + atomic_set(&cpu->icount_decr.u16.high, -1); } /* 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 = 0; cpu->mem_io_vaddr = 0; cpu->icount_extra = 0; - cpu->icount_decr.u32 = 0; + atomic_set(&cpu->icount_decr.u32, 0); cpu->can_do_io = 1; cpu->exception_index = -1; cpu->crash_occurred = false;