From patchwork Fri Oct 19 06:06:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 149218 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp2903327lji; Thu, 18 Oct 2018 23:07:31 -0700 (PDT) X-Google-Smtp-Source: ACcGV61VLobfQsvo60zUNKXXbzhzlFU15Srzi3n/eF/MBb53Ew6ABWldUEfuzFlTtmKHUJsIwnME X-Received: by 2002:ac8:6a0b:: with SMTP id t11-v6mr5947351qtr.360.1539929251825; Thu, 18 Oct 2018 23:07:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539929251; cv=none; d=google.com; s=arc-20160816; b=j05a2tNdCgjI/cWs9aeGuYUsVniJgB2W3lSb4+UUdIBQw03W+0LCfoV1wEKdV0l99y utJcO6FQWcpRZDEsjl65ZaADQG4MlVwak6UMfePj+i8TEEfnndLVQgW8mPOMhd/vYO20 jzHzqVU/bbq3ZlbwuJ+7bLnG0/Xv0AUFkosn06LFAFrV2x/WR73QcTSIek/wmwV02cNI fuM/cYFLAFkEdTuKwF00dFSSTnRbxdsbXBX2B8i8hzAYdqqywQgcnKjHLbNg5c1FjKrA 2gFId7n6DNwMnqlJYUUYW6YP7Y7U7uFBy0zLj4B42OFSZdM5miF0A2gObDyO0/ioVoJ5 tmaA== 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=3X8XXtx5Pa7ryzvgIMx7/IpjfYnMODQDL1ycP2pUNCA=; b=Fc5Q0vfxQcvwchmyaSSho+NRYfpLXT8A2kB/q0/8JBc4bOll3CZiBMO0pD+5asnCLg 3kmlPJqxSEqE8Q0zyM+/GSFlpDhplbCoACxys7VcIArClLTJeB6iurpav8Pl00ZJAlCd 7x1SFIWkzIcNDgB+maW2DEqXG5Qg68a6KnDWt5boq02LR2ZGsP75Jqi/KQ8Z4Ty0siTq +F8txRA+l2Q/rukhnYnygL58y0IsES5iTFUeTJiO2f23wbAfLdH+EEPTB1hsHI36n1tL FCRdSP4r/TSIjTxRe1anTfHzibPxTEpM/UPnzvJLEc35zfOgaxO+kSE2YMkz1ZAqe1AN E8DA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=SOO8KVpo; 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 i31-v6si169578qvd.196.2018.10.18.23.07.31 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 18 Oct 2018 23:07:31 -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=SOO8KVpo; 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]:47216 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDNwZ-0003yA-8N for patch@linaro.org; Fri, 19 Oct 2018 02:07:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38880) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDNw8-0003xT-KE for qemu-devel@nongnu.org; Fri, 19 Oct 2018 02:07:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gDNw7-0001n1-MT for qemu-devel@nongnu.org; Fri, 19 Oct 2018 02:07:04 -0400 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]:40784) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gDNw7-0001iG-2n for qemu-devel@nongnu.org; Fri, 19 Oct 2018 02:07:03 -0400 Received: by mail-pg1-x543.google.com with SMTP id n31-v6so15307656pgm.7 for ; Thu, 18 Oct 2018 23:07:02 -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=3X8XXtx5Pa7ryzvgIMx7/IpjfYnMODQDL1ycP2pUNCA=; b=SOO8KVpofg1W95lmd/ax1mKTgne31jLQXJcT6a0jskdmrAPEWBNV8dZlPZVqJWJiJB FPTdQ3sMrmNj78YHDHxLjD/A9vogeIVLtXeFNMDmY54b+BfYx/rsWSpIA92xt9shq7nq lYQqf07God9OhyL50GqoTzQOK+os6CPVoBc/Y= 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=3X8XXtx5Pa7ryzvgIMx7/IpjfYnMODQDL1ycP2pUNCA=; b=BDqwfGhzYMZgQdfYEinq3aawv6r1k6/gDp7xq40f+xnysd5XmC7A7YCoRDH8onKZmK TZcVEW/YM34fw269+GeJDHBVafzpDpeCNW9A9MVQDs7xrtb6wDN3pKD0ePtmQqO0igp5 xVM0dqyrV7YRvXL2fKLkXB48BNm0KY/GCRYqYSUtySMXcxQF80WxoA40JUdoC0JTitjf +tbn9qjoU29HQW1eMQ/Cv5T7GyCV7ek0YPnYHbQY4uOOUa7agug4HLg7bJz/slS3iiE6 tDLQpWknQBseCxGRnhPbGarh0toQimub/KhZ9PKlH7uobFsRX37t1oDymZniLF/bIGwg zitw== X-Gm-Message-State: ABuFfoi3409MqoGZSgSR2S0lhY/kLQo0nK5XWcvmxs831NQpWMynunrV j5koCqleUXVb94tquBB6tl8ojqYccM8= X-Received: by 2002:a63:cc51:: with SMTP id q17-v6mr30967990pgi.291.1539929221425; Thu, 18 Oct 2018 23:07:01 -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 q24-v6sm25609327pff.83.2018.10.18.23.07.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Oct 2018 23:07:00 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 18 Oct 2018 23:06:37 -0700 Message-Id: <20181019060656.7968-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181019060656.7968-1-richard.henderson@linaro.org> References: <20181019060656.7968-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::543 Subject: [Qemu-devel] [PULL v2 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 f7746546d0..9ad1372d57 100644 --- a/qom/cpu.c +++ b/qom/cpu.c @@ -265,7 +265,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;