From patchwork Fri Oct 19 06:06:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 149219 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp2905460lji; Thu, 18 Oct 2018 23:10:08 -0700 (PDT) X-Google-Smtp-Source: ACcGV63L6cXyPcUhu6GvII8fXe7givEF2RI0ed8f14JGpx2YxotaKgT0llKops63jdK7sNp1Squp X-Received: by 2002:aed:2a73:: with SMTP id k48-v6mr32069374qtf.102.1539929408572; Thu, 18 Oct 2018 23:10:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539929408; cv=none; d=google.com; s=arc-20160816; b=0QPrkush5iBoCdTkprKnQSKSmtbCq+OiTS8RdCJ3C5GJ1Um3sEE4k39cg69JXiZIsM n25EMrOTmng1KdEFPV2wodeqXn7WiF0doQGH3zfdtml+ZPZoCfzGxsQVEedW+/pXXKgJ Mi3X396aRryyBhonWtiZ1+gDmbxca1y94Nz1dmImb+wfSm3oifTLDqgl1HWTzZO2nwhn gun4JuzILPFnhOFkFTEKnZ1aLbIBpaTVP/rNWf9KVx/ATLpHky8I4W8Mnk1NDBRTSpZo JvhISu917+us2O48M02PGJat8yRHQwtf83aS9FuOWMkKFABLTueA98gJTQQyhHs2Mu/3 rDUA== 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=v87Nv8KtOwBwH1Vf6pnmPV08acciS7b2jzoCLS0sc10=; b=PutIawyEqsVDsuIc6uzk6Km/n+/JX9Tft0106/551uPxYpXJk2sZDU3qP1FjlJwJGY AHycGFVsgOKIV2lgeVVwm3+tiPrxq4hOF5OhClWQ4xjV/VqXoI7w92GeeDa/bfdInPxM 8rDMqXKs7+cifrJRe7NsoWT2wsg8fT9I7L+glf02TbVmmKfSzvB1TMQ1em2PmMOcmHPq TZ4CUFPNJC9eB520TJ956CZF8W/Jiy44/RLMz5UzrxXEhDH/q08iDQXtHd/Gf2JdyzXm gDDJxNR2rTBr912aVUi9jd/qkp3QBT+tzCfkxZ8x2NetMHexcErwWY3E17ktGgrwX8+l Ed6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=K0BBlLlm; 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 l101-v6si3007664qkh.92.2018.10.18.23.10.08 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 18 Oct 2018 23:10:08 -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=K0BBlLlm; 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]:47224 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDNz6-0006nt-0k for patch@linaro.org; Fri, 19 Oct 2018 02:10:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38872) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDNw8-0003xQ-BF 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 1gDNw5-0001hP-MF for qemu-devel@nongnu.org; Fri, 19 Oct 2018 02:07:04 -0400 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]:43018) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gDNw5-0001er-B8 for qemu-devel@nongnu.org; Fri, 19 Oct 2018 02:07:01 -0400 Received: by mail-pl1-x62a.google.com with SMTP id 30-v6so15380354plb.10 for ; Thu, 18 Oct 2018 23:07:01 -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=v87Nv8KtOwBwH1Vf6pnmPV08acciS7b2jzoCLS0sc10=; b=K0BBlLlmZ6zlo02qYbbp74EFNVbr91nZXUwOn7sKxTwBONq6yjdMQSmT3D4vG+Zy0p cYG37Zwv0/zLm8SNX+j5vXGTvdeAObvPCe3EaOYuajpgZCoS6wEHNuBAONWZognwqUWT iRw8EGsWwWbyT3sVKTDlQcTGLFKJFRDgivMv0= 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=v87Nv8KtOwBwH1Vf6pnmPV08acciS7b2jzoCLS0sc10=; b=iI6FxbV03jHgARboRyXLHjcuEyuWRIrkI9Za+K4q16L+9YG8eHvKkDPErFHRN/oCDV bdx3cIrLJHG+RY7lREERs6v1PXHVWiUcnKpjglEEX5toqgsv1HisXMPOGcUfzGBkjNcn wJcUoJVyqOFi86nSbV13TRVe0K1/W6lvmLbPazaqnp2BF5wfe+DLjhMDmeL2NGEa47jt XE+dlzLDT0GwG7aEwywZ047K7b7792VC76eIdLYtDAWrfPdsqZmH/ppfxzrgjdl66Ea+ uF0E4KMnk9POWUJKiCF50gcXw93fAWRiXDeCQv3KvkEl/L3BxnszJkhdxL+tRHvHXNqw 9/cQ== X-Gm-Message-State: ABuFfoh33jGP8nwwFSgyUG+ue4HVtmuXztw248f7cTEiPyohBidNqq0t 5PckA6D/KXQjoxPKDUQ7VLHnEXI1k7s= X-Received: by 2002:a17:902:d881:: with SMTP id b1-v6mr33462873plz.10.1539929219987; Thu, 18 Oct 2018 23:06:59 -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.06.58 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Oct 2018 23:06:59 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 18 Oct 2018 23:06:36 -0700 Message-Id: <20181019060656.7968-2-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::62a Subject: [Qemu-devel] [PULL v2 01/21] tcg: Implement CPU_LOG_TB_NOCHAIN during expansion 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 Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Rather than test NOCHAIN before linking, do not emit the goto_tb opcode at all. We already do this for goto_ptr. Signed-off-by: Richard Henderson --- accel/tcg/cpu-exec.c | 2 +- tcg/tcg-op.c | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) -- 2.17.2 diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 6bcb6d99bd..870027d435 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -416,7 +416,7 @@ static inline TranslationBlock *tb_find(CPUState *cpu, } #endif /* See if we can patch the calling TB. */ - if (last_tb && !qemu_loglevel_mask(CPU_LOG_TB_NOCHAIN)) { + if (last_tb) { tb_add_jump(last_tb, tb_exit, tb); } return tb; diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c index daa416a143..7a8015c5a9 100644 --- a/tcg/tcg-op.c +++ b/tcg/tcg-op.c @@ -2586,6 +2586,10 @@ void tcg_gen_exit_tb(TranslationBlock *tb, unsigned idx) seen this numbered exit before, via tcg_gen_goto_tb. */ tcg_debug_assert(tcg_ctx->goto_tb_issue_mask & (1 << idx)); #endif + /* When not chaining, exit without indicating a link. */ + if (qemu_loglevel_mask(CPU_LOG_TB_NOCHAIN)) { + val = 0; + } } else { /* This is an exit via the exitreq label. */ tcg_debug_assert(idx == TB_EXIT_REQUESTED); @@ -2603,7 +2607,10 @@ void tcg_gen_goto_tb(unsigned idx) tcg_debug_assert((tcg_ctx->goto_tb_issue_mask & (1 << idx)) == 0); tcg_ctx->goto_tb_issue_mask |= 1 << idx; #endif - tcg_gen_op1i(INDEX_op_goto_tb, idx); + /* When not chaining, we simply fall through to the "fallback" exit. */ + if (!qemu_loglevel_mask(CPU_LOG_TB_NOCHAIN)) { + tcg_gen_op1i(INDEX_op_goto_tb, idx); + } } void tcg_gen_lookup_and_goto_ptr(void) 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; From patchwork Fri Oct 19 06:06:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 149220 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp2905462lji; Thu, 18 Oct 2018 23:10:08 -0700 (PDT) X-Google-Smtp-Source: ACcGV62bwq0FCRosMaJz9c4zGKfu0V+0cLeIQu9oWSBLTQff5tXW7Utq2588av33YN+N++5Bt/sr X-Received: by 2002:ac8:548d:: with SMTP id h13-v6mr5104602qtq.222.1539929408617; Thu, 18 Oct 2018 23:10:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539929408; cv=none; d=google.com; s=arc-20160816; b=w5d0a4gfq9koof8lOANYnWp4S58noiHjPrdetiwLQOa3tkLTbK8ebsKFB7GCT9o9kJ 3/vxggdqRkML8UKNUhzydrjgs8C18ZJgy9wrG129CXp7qjDZieZuprci3UBT83Stsdnm tRk8G+Yo3JkLdK+cNYQM97j/QFR1aT2bmzP6hsOFKK5Gg9FRbIkphbilL0qbG0V4u8tw UwTOhXW7vJfnXGoNdwNinpcZFE3DiUVgB2DcoBSdLAOr2kuMOw2S9JeVK+PipLkjtSTL dzmm2t0qTvndwgL5ni8Q3Rt3fyNOTX0O/wfIvclU08o07i5SJ7FzBOTQScw+pVpbYKVf TiWw== 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 :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=XPHfakviOHeoyHH8+nY/3eH0/sW+Fz1CCwfjdYYgSx4=; b=LyYAdU+ZO3tpbnjiDRI7pSJtGnGRj5zkddZVtYLRMOqXca1upajX3ZCIyeYpnXB2r6 czzL2qwCGMKHG7UUg40ZtW0IZLbiAyd4CG0uD+icjAioI7t92kk3GUt9NKXBnjlrM4Fc baL6CfXlCnp3dPNk4PSWBhCXRRXZ+TKRsf/VBOrtfGM5IEjM2luUWo9Up5Ke8dXAzTij ajbHagLV+rVP8xmUvykRXXAzTpCqfLvrYduqRL/iONMCZva23icFYrj9hgLwaXAjzL7Q pviXofTFwvQW5XUSDjvuDldcmqC1ZkkyWJiREVHH0YIXaatcTkgw5mpnTXumCFmqPU7D m3OA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Wy5lKIDH; 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 g2-v6si6144008qtg.304.2018.10.18.23.10.08 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 18 Oct 2018 23:10:08 -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=Wy5lKIDH; 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]:47225 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDNz6-0006nx-2K for patch@linaro.org; Fri, 19 Oct 2018 02:10:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38908) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDNw9-0003xZ-Bb 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 1gDNw8-0001r1-FC for qemu-devel@nongnu.org; Fri, 19 Oct 2018 02:07:05 -0400 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]:39159) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gDNw8-0001m7-4Q for qemu-devel@nongnu.org; Fri, 19 Oct 2018 02:07:04 -0400 Received: by mail-pl1-x631.google.com with SMTP id e67-v6so6414027plb.6 for ; Thu, 18 Oct 2018 23:07:03 -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 :mime-version:content-transfer-encoding; bh=XPHfakviOHeoyHH8+nY/3eH0/sW+Fz1CCwfjdYYgSx4=; b=Wy5lKIDHx3rn15O7krEwOZ+kr5jhmauxDDHYcRHN4/OQzskUL8OgJpFAztS0QqBz1J TLd9uwPuk27+cNBY1hPmc0VIHAKojT0AaojZAMPLsBPPh+kcwVCi/JHfGzufJO68SHZ8 Tvb7RKFayIH2dLEuh2NDXCcXx40fbN/feO+nM= 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:mime-version:content-transfer-encoding; bh=XPHfakviOHeoyHH8+nY/3eH0/sW+Fz1CCwfjdYYgSx4=; b=D8SyWhrc76d93uTQcES6ux/ZTS6uwFmL04v5P73PhpOs2R90cy2Wo1KZg04GKTUc9O 3T+rm+N000I2SSHZNiR6boFd3p1noVoKv/igrbqfid8NQFniE4Bji+ysbhwxQJucSI55 PUHZuNqYKH4WLTZEIAkxtp6/L/T7KUY2u8g1Sx0PAEgRB6M7x0GB4ShYbgMD/ekHQFNk 3/am1egZ/yzjTJ5jYpN3IPdTDoWbfngDXJiGxL01Y8Eyliu401QkbYM6Usre650oCUr5 tzOj36uU1qPi8xyKwhTt9rdNQR5vGmRgLQNO2SkWVrrO86jX9hlf9ZweVsWLCEeis7r4 MDSA== X-Gm-Message-State: ABuFfojH10s77+mPLe9gpUZu4Co2M+FgKc5G41Cw+1mU0xtybvXyLYTS mU2Kk0es66iChhrk9bFEGL0jfWsGvZ0= X-Received: by 2002:a17:902:16a4:: with SMTP id h33-v6mr32155001plh.3.1539929222805; Thu, 18 Oct 2018 23:07:02 -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.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Oct 2018 23:07:01 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 18 Oct 2018 23:06:38 -0700 Message-Id: <20181019060656.7968-4-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> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::631 Subject: [Qemu-devel] [PULL v2 03/21] tcg: fix use of uninitialized variable under CONFIG_PROFILER 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" We forgot to initialize n in commit 15fa08f845 ("tcg: Dynamically allocate TCGOps", 2017-12-29). Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Emilio G. Cota Message-Id: <20181010144853.13005-3-cota@braap.org> Signed-off-by: Richard Henderson --- tcg/tcg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.17.2 diff --git a/tcg/tcg.c b/tcg/tcg.c index f27b22bd3c..8f26916b99 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -3430,7 +3430,7 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) #ifdef CONFIG_PROFILER { - int n; + int n = 0; QTAILQ_FOREACH(op, &s->ops, link) { n++; From patchwork Fri Oct 19 06:06:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 149223 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp2907822lji; Thu, 18 Oct 2018 23:13:03 -0700 (PDT) X-Google-Smtp-Source: ACcGV63AxXNWtod4saPKeBNKZiHFWHwJb/kBoVQ5MTb9vIoyJCqS8xjHrZzq/HdRHxOmQoorr7mQ X-Received: by 2002:a0c:d1d5:: with SMTP id k21mr7918928qvh.156.1539929583466; Thu, 18 Oct 2018 23:13:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539929583; cv=none; d=google.com; s=arc-20160816; b=jIARBlIQ6Z/ddGiazEsO1GdSNwWkTcvU/t9hEAytsBh2kFuyEyCiZDKYe8Oe+zQHIj UpB4uYTH5p4d3MxsrxGboZYlVCWe+i9bD4Jwj5raWue1k/EC9f3IPvcd/BsstuODSFJR r1i63c7u30PLirdYkUAeELqdMpmpGzNROSWrDTYESxK7acghtndu8JwUpbraKrZiyY9T ytVsfwTJqpFNMRl5T+g81QoPqWamQ1iY8Wb//CjaBnY+tarygFb7se0s0yKFaaoGuBEq vf8TGzyHqG17L3GyiqX8srgLJK2qdF3HA93lU/YN1FxXfqWPeiCP04ZQ7vEaYEgYrA/h 5sYw== 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=HIK9nMwv5A9Xjvh/YPMt/fmhRKI03KqcehqyTqQt1wo=; b=biJt1DyV1MQWCIVYrrRmqlUiBUAa6iGyIRf6iPWVpQcJzSrWqwZ3+cjVU0frw07J/b oIhJUjzauTAIItio8bv8aQA9R/Ky8loqDWxipAWvGm/6lL500FjEYdbKLNbfH5K5XnyR ATZHi8xQcGbi2DLUb6khGWwz0F12qqmWnJy8DMesvrUtvjSMP+xMN4e3cKugK6KjeJN0 nno7tUSrlHbxM/iNhJGyYhD0cWmG86/t4vTq4iKezwxODwXjf48AXbkmZwOO/UWSHQga lt/HXsTWjZJ4ZYsUicfQ2aT8I/+/I3VpNn30CZNiL7jGHyL16b7AQtw772bvuH6Yu7Ih 2O8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=hL12PzB1; 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 h9si7798906qvh.213.2018.10.18.23.13.03 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 18 Oct 2018 23:13:03 -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=hL12PzB1; 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]:47241 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDO1u-0001Ne-T6 for patch@linaro.org; Fri, 19 Oct 2018 02:13:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38938) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDNwB-0003y4-8R for qemu-devel@nongnu.org; Fri, 19 Oct 2018 02:07:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gDNwA-0001w5-0h for qemu-devel@nongnu.org; Fri, 19 Oct 2018 02:07:07 -0400 Received: from mail-pg1-x52b.google.com ([2607:f8b0:4864:20::52b]:43667) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gDNw9-0001sT-M4 for qemu-devel@nongnu.org; Fri, 19 Oct 2018 02:07:05 -0400 Received: by mail-pg1-x52b.google.com with SMTP id d8-v6so4085495pgv.10 for ; Thu, 18 Oct 2018 23:07:05 -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=HIK9nMwv5A9Xjvh/YPMt/fmhRKI03KqcehqyTqQt1wo=; b=hL12PzB1Dqn8u1peKtSkoROGo2gtHqD6y0PIPBddrNHwV9vmBLg5lsyxDCmmcoDGMs iEaIxhcmAF+AhuI6bPRE3QSh0LBjXgNDlImGN1p0tEP9CgkH9xAp9ZSm2e1M49RxmxJ/ XFq/2WivczccfzXQb+ju34G3Ak8B6+WmmPmvQ= 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=HIK9nMwv5A9Xjvh/YPMt/fmhRKI03KqcehqyTqQt1wo=; b=txbzXcBpVHthpPzwKbczK9GBf3O6OqPzeAX8u8OpxOCgulEG/2qydjQZ81cruvR4/4 NeJEc7OeItOf0QPaHUK8HbCMaDsgya9an1dOtle9A0EhZzjmY7OdDa2I2l/ISjUB8PSB iS0H5JCDQOBY6QVZ2T3v+CJw+SRX6ugCK9zAFBhiGP6DGwyPzG/IY369W8+4B3ePtCUx usUuDMWLvQr3E5dKqDTUMEllOjnyT0olJ/l6qe9WniVTf03JyPGqoh3xvCI5I60SxnSJ gpJHS3VADIAxjbBFaBIXyGP0PjtVzWvcZH47loSIleNgFr7TgEGXEsiL7OYBHjF5YWGQ iizg== X-Gm-Message-State: ABuFfoiCNF+JRAH1MHC8Pud4iNFHgmq5ofm2Okwjzs5Zvc4wR02bRuQw /Fc+80iap/qibQZjVfanMQeeY1NSblg= X-Received: by 2002:a63:a902:: with SMTP id u2-v6mr31411669pge.207.1539929224198; Thu, 18 Oct 2018 23:07:04 -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.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Oct 2018 23:07:03 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 18 Oct 2018 23:06:39 -0700 Message-Id: <20181019060656.7968-5-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::52b Subject: [Qemu-devel] [PULL v2 04/21] tcg: plug holes in struct TCGProfile 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" This plugs two 4-byte holes in 64-bit. Signed-off-by: Emilio G. Cota Message-Id: <20181010144853.13005-4-cota@braap.org> Signed-off-by: Richard Henderson --- tcg/tcg.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.17.2 diff --git a/tcg/tcg.h b/tcg/tcg.h index f9f12378e9..d80ef2a883 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -633,8 +633,8 @@ typedef struct TCGProfile { int64_t tb_count; int64_t op_count; /* total insn count */ int op_count_max; /* max insn per TB */ - int64_t temp_count; int temp_count_max; + int64_t temp_count; int64_t del_op_count; int64_t code_in_len; int64_t code_out_len; From patchwork Fri Oct 19 06:06:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 149224 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp2907829lji; Thu, 18 Oct 2018 23:13:04 -0700 (PDT) X-Google-Smtp-Source: ACcGV63Dd1NbooRn2UyiYetbPb1SoAKvmcSgA1fIHGMt02W7laluMX7KjcEFsCE8OsaPpG5+3ysc X-Received: by 2002:a0c:d606:: with SMTP id c6mr10615892qvj.230.1539929584177; Thu, 18 Oct 2018 23:13:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539929584; cv=none; d=google.com; s=arc-20160816; b=YX2z9k9Dwh2Vuit3N2MwXBEYvyyHHbc85d+qjFEepSm23nyIsZqrmBGrAv+9N510nX OJYoOLIf+hgJUjM2YXataQQZcWcMjYGb3Lh+14wHXHp71C/qlsCEl3s2cgUxHI+P08hR j0F75eg2oRPwuYsCmTfuoZvNY7N3qvSzReRgE+frIgq5xT7obWTgBW7/cLSKH0BA0nlQ XbEIzwDZWBf+PHsN0rZtXLN778diAdhQqsQPEaqX2kpJWNpgflp6QPLNf6MPFqJG9g1R wfTI67yB5tPWGqWb1hnSPkwPPMT9ZlA+GVR8Ivx1+hzJWimAoFaGr0Pyag7gpYAFC36p KAww== 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=TgDCiAlCqNyacH51QEaK7ppBxrOCvC2iTKIGNr6fsnY=; b=iW1FjpA4lmAF0GmH+vsCEDZXOpbrGebvf/PIBVri9yAjFAcM/BHUDT71ZVa6dR8uyM vhZpsPKSG4S2Qiql3FoBXUn1priWGZgEP2TULyvb4hQCa3BD2MxVO2gwBmk8OQq3qaub GuHrd7y53wA063cDWuFOIiVcOeCG516SoSkhBi7ESMeOIvSVto9x35TFMEQpaBRT2jYi Bgf4KuSHPx7CjD9WEqeW8XpKH9rorlGaTMQY7ilChwlAe5tmn9Rb3V3slVAPT/EtFJcg DGIgHOdxS3hVxXOVu1LjHR37zODbndApyKO0cqtswF040qU7LygPryRKEVZM/DQvaX6W /JPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=haQ8xveq; 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 b44-v6si7879946qte.363.2018.10.18.23.13.03 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 18 Oct 2018 23:13:04 -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=haQ8xveq; 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]:47242 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDO1v-0001OA-GG for patch@linaro.org; Fri, 19 Oct 2018 02:13:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38962) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDNwD-00040e-Gc for qemu-devel@nongnu.org; Fri, 19 Oct 2018 02:07:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gDNwB-00020K-Iz for qemu-devel@nongnu.org; Fri, 19 Oct 2018 02:07:09 -0400 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:46866) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gDNwB-0001yl-3S for qemu-devel@nongnu.org; Fri, 19 Oct 2018 02:07:07 -0400 Received: by mail-pf1-x441.google.com with SMTP id r64-v6so15987817pfb.13 for ; Thu, 18 Oct 2018 23:07:06 -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=TgDCiAlCqNyacH51QEaK7ppBxrOCvC2iTKIGNr6fsnY=; b=haQ8xveqFl3z22Q7dFPyS0127ruPQ25+sTF+GHRzWc/YC2iNhVrw6B/AfIVRqBzbEh Jm9+kSijWVKCqj8HgYQ7w9VZUOeERl9f2e/4++MGzyDLNDzV/QgryaBmMvqrXZcVm7FU UQxkGPApZ9Sut2iv953kuCKZ24a54jwhGv8YU= 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=TgDCiAlCqNyacH51QEaK7ppBxrOCvC2iTKIGNr6fsnY=; b=Evq8EIow8XetGg2lY1ce8w6JfHDNbIQg/cjfvnEYzT6XFSuLQhm2veGKB6xyBSyCQd r5QXZziiLMvLA4mzMHXK9EmFtBz2V+lIp3dnl+KHXSlwWarUTMBRCwhK0+DJB/OmWWDf u/f2GTuD8MNBKuQjhkTA+obgshy5zeRdoJA/+wGE0M+CjaG98SLsM7Y9cmSpHl/ErwBT tyyJFx8XijQrX0zopdi1Q8bP5OYyI59dKa8t9w43pFbjeIG80P1JtJgUtIO0qET8tSDC JJjQidBu4n42Ohvai6O3a5wBbdui4+kkUsAyo8YJBbdaSG5lmvCJfC4Qg5D8623U3J1Z svFw== X-Gm-Message-State: ABuFfoguXAmvtV6WofcPhObY8HjPX6i7KbjCdjOxS+W0EfDG5sGQe4EC h2bZs96OpB96KJoOrLCswb8wGe98/7E= X-Received: by 2002:a62:42d4:: with SMTP id h81-v6mr34220583pfd.0.1539929225613; Thu, 18 Oct 2018 23:07:05 -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.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Oct 2018 23:07:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 18 Oct 2018 23:06:40 -0700 Message-Id: <20181019060656.7968-6-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::441 Subject: [Qemu-devel] [PULL v2 05/21] tcg: distribute tcg_time into TCG contexts 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" When we implemented per-vCPU TCG contexts, we forgot to also distribute the tcg_time counter, which has remained as a global accessed without any serialization, leading to potentially missed counts. Fix it by distributing the field over the TCG contexts, embedding it into TCGProfile with a field called "cpu_exec_time", which is more descriptive than "tcg_time". Add a function to query this value directly, and for completeness, fill in the field in tcg_profile_snapshot, even though its callers do not use it. Signed-off-by: Emilio G. Cota Message-Id: <20181010144853.13005-5-cota@braap.org> Signed-off-by: Richard Henderson --- include/qemu/timer.h | 1 - tcg/tcg.h | 2 ++ cpus.c | 3 ++- monitor.c | 13 ++++++++++--- tcg/tcg.c | 23 +++++++++++++++++++++++ 5 files changed, 37 insertions(+), 5 deletions(-) -- 2.17.2 diff --git a/include/qemu/timer.h b/include/qemu/timer.h index a005ed2692..dfecd03e28 100644 --- a/include/qemu/timer.h +++ b/include/qemu/timer.h @@ -1046,7 +1046,6 @@ static inline int64_t profile_getclock(void) return get_clock(); } -extern int64_t tcg_time; extern int64_t dev_time; #endif diff --git a/tcg/tcg.h b/tcg/tcg.h index d80ef2a883..c59f254e27 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -629,6 +629,7 @@ typedef struct TCGOp { QEMU_BUILD_BUG_ON(NB_OPS > (1 << 8)); typedef struct TCGProfile { + int64_t cpu_exec_time; int64_t tb_count1; int64_t tb_count; int64_t op_count; /* total insn count */ @@ -1002,6 +1003,7 @@ int tcg_check_temp_count(void); #define tcg_check_temp_count() 0 #endif +int64_t tcg_cpu_exec_time(void); void tcg_dump_info(FILE *f, fprintf_function cpu_fprintf); void tcg_dump_op_count(FILE *f, fprintf_function cpu_fprintf); diff --git a/cpus.c b/cpus.c index 361678e459..cce64874e6 100644 --- a/cpus.c +++ b/cpus.c @@ -1425,7 +1425,8 @@ static int tcg_cpu_exec(CPUState *cpu) ret = cpu_exec(cpu); cpu_exec_end(cpu); #ifdef CONFIG_PROFILER - tcg_time += profile_getclock() - ti; + atomic_set(&tcg_ctx->prof.cpu_exec_time, + tcg_ctx->prof.cpu_exec_time + profile_getclock() - ti); #endif return ret; } diff --git a/monitor.c b/monitor.c index b9258a7438..823b5a1099 100644 --- a/monitor.c +++ b/monitor.c @@ -83,6 +83,7 @@ #include "sysemu/cpus.h" #include "sysemu/iothread.h" #include "qemu/cutils.h" +#include "tcg/tcg.h" #if defined(TARGET_S390X) #include "hw/s390x/storage-keys.h" @@ -1966,16 +1967,22 @@ static void hmp_info_numa(Monitor *mon, const QDict *qdict) #ifdef CONFIG_PROFILER -int64_t tcg_time; int64_t dev_time; static void hmp_info_profile(Monitor *mon, const QDict *qdict) { + static int64_t last_cpu_exec_time; + int64_t cpu_exec_time; + int64_t delta; + + cpu_exec_time = tcg_cpu_exec_time(); + delta = cpu_exec_time - last_cpu_exec_time; + monitor_printf(mon, "async time %" PRId64 " (%0.3f)\n", dev_time, dev_time / (double)NANOSECONDS_PER_SECOND); monitor_printf(mon, "qemu time %" PRId64 " (%0.3f)\n", - tcg_time, tcg_time / (double)NANOSECONDS_PER_SECOND); - tcg_time = 0; + delta, delta / (double)NANOSECONDS_PER_SECOND); + last_cpu_exec_time = cpu_exec_time; dev_time = 0; } #else diff --git a/tcg/tcg.c b/tcg/tcg.c index 8f26916b99..e85133ef05 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -30,6 +30,7 @@ /* Define to jump the ELF file used to communicate with GDB. */ #undef DEBUG_JIT +#include "qemu/error-report.h" #include "qemu/cutils.h" #include "qemu/host-utils.h" #include "qemu/timer.h" @@ -3361,6 +3362,7 @@ void tcg_profile_snapshot(TCGProfile *prof, bool counters, bool table) const TCGProfile *orig = &s->prof; if (counters) { + PROF_ADD(prof, orig, cpu_exec_time); PROF_ADD(prof, orig, tb_count1); PROF_ADD(prof, orig, tb_count); PROF_ADD(prof, orig, op_count); @@ -3412,11 +3414,32 @@ void tcg_dump_op_count(FILE *f, fprintf_function cpu_fprintf) prof.table_op_count[i]); } } + +int64_t tcg_cpu_exec_time(void) +{ + unsigned int n_ctxs = atomic_read(&n_tcg_ctxs); + unsigned int i; + int64_t ret = 0; + + for (i = 0; i < n_ctxs; i++) { + const TCGContext *s = atomic_read(&tcg_ctxs[i]); + const TCGProfile *prof = &s->prof; + + ret += atomic_read(&prof->cpu_exec_time); + } + return ret; +} #else void tcg_dump_op_count(FILE *f, fprintf_function cpu_fprintf) { cpu_fprintf(f, "[TCG profiler not compiled]\n"); } + +int64_t tcg_cpu_exec_time(void) +{ + error_report("%s: TCG profiler not compiled", __func__); + exit(EXIT_FAILURE); +} #endif From patchwork Fri Oct 19 06:06:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 149227 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp2909906lji; Thu, 18 Oct 2018 23:15:49 -0700 (PDT) X-Google-Smtp-Source: ACcGV62p3KbSBuDQTNA0TKHyNtXKjfIn8x2PGGpsvW6xGyhIfOs2OCoJFUi+Vyvc4/aKAPx5mMVV X-Received: by 2002:a37:b042:: with SMTP id z63-v6mr30928205qke.94.1539929749188; Thu, 18 Oct 2018 23:15:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539929749; cv=none; d=google.com; s=arc-20160816; b=GVPDaLxAGjZ7dkO1P3ncBRMoo0DBx4a8UVXC3AbD6vnYNHAX1UTt2iuBIY4BcqlS/w 10sQ8zpxk8Em1Onz6A4KXezCyEAj7b6tp3Q/IVrgIQeiKoxP8Aq8LGvu6xFZxGSDM0gC AfwQ3kPRLa5VGNQT4hyKb3aBtyxXxXJVhKtYbe2gHtOmv2hgBtJXcSIeH5SDszD2iPTh kPZlD0aKoBlcRINaYcdL7JRlNb0ZtUF6fmQENTJoLIhaOxbmbMcBXhyQpihNzt7HXSiD lmBEyL96UOhWo4NOtb08lkMafDdeQKnwJitPq1owdmcHun0APGyi4vnlfBcR9QrwyiLK HhbA== 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 :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=pJ03w/05K8uS57fQC05w2JHgSo9jMtdD8AAptElnit8=; b=V9LYCtyNCoRlrELVlZoOKa/wFWTwbzUmiD302ct95L6ihDXNkpyajPv24G+HhNmB+h znO4ApTVq9D3eKpBv04R/6PE2NbSX2Tso53r8ssKWX8HlzptG2DC3If5SuSCWDeRtCCE bd5OhC3RPbLFih2IGYt8YZ4XxeNdh5QQSsXS0+QYGA2wcBT8EbZ/t3cDx/0goNB0R0QW GvAnPkwuSEocJ+gyV5D1aizzg5JwcJe771r459x08V5yKYznml0l2ZI0nfA4sED5aEtk AfHtd1BgNUTJZ4snl63wuzdow6a19PR5Ed/b16a7WNkKxtu0l5QZpEydJBrRXpd5N6xr Q96w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=aF3XeR0D; 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 i16-v6si180100qtp.400.2018.10.18.23.15.49 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 18 Oct 2018 23:15:49 -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=aF3XeR0D; 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]:47260 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDO4a-0003ij-HO for patch@linaro.org; Fri, 19 Oct 2018 02:15:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38994) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDNwP-00048M-UH for qemu-devel@nongnu.org; Fri, 19 Oct 2018 02:07:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gDNwD-00022Z-O0 for qemu-devel@nongnu.org; Fri, 19 Oct 2018 02:07:13 -0400 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]:36546) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gDNwD-00020Z-37 for qemu-devel@nongnu.org; Fri, 19 Oct 2018 02:07:09 -0400 Received: by mail-pl1-x62a.google.com with SMTP id y11-v6so15394306plt.3 for ; Thu, 18 Oct 2018 23:07:08 -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 :mime-version:content-transfer-encoding; bh=pJ03w/05K8uS57fQC05w2JHgSo9jMtdD8AAptElnit8=; b=aF3XeR0Dy+XP0LEd/iCVCiW4efRpERqeRmjHXmzeAt2B8eAOIvvp2z8S54BL19Zkom ZjKSqeeaVmu1xQJFv6N4EWnXRlf2U2xSkeSYpMCiKei2NxNf/uHOz4fzc5z54BA0Fnq8 nu0wtke1F/qbAUoWeGyBVdmZJGpx6y2PynOEU= 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:mime-version:content-transfer-encoding; bh=pJ03w/05K8uS57fQC05w2JHgSo9jMtdD8AAptElnit8=; b=f3B0It0o4ri0HoFgT+1YZb1gV8k0577kLWv//X9TgIgO0zjS6CFtm8Evvfgg4fCCqA QfBVgT9ElYUNEHMGZCL18T6BE+duDqUEKbnRWp3ksfGa+XlU07PfMnFDe26H230fAXZl WIT2wb04PhmL33gLj1TUBNkTNUlodubqMjvJBBY0tumxASB1rKdQ9HflU3x26+joDC7R uSDVaA1/2kP37/r/5BWf7//vVhR+WG1M1WJp6bw81A+lkYbBn5NW27sJ3JPBSLSTVM+Y MX4FQLfHk02drnLtmwQtI1ubiQE5ER2JvW3rCJdS4oytTc4tuvxTEx/xExwIk67wMuZQ WgdA== X-Gm-Message-State: ABuFfoibNv6k1HmGEam1MVD4h+jsMQriFDPLVX8noezFnV4VJdP23tIj gyq7n2hXKQM5Exqn9fKToSFslgpRzhU= X-Received: by 2002:a17:902:788d:: with SMTP id q13-v6mr31359030pll.329.1539929227045; Thu, 18 Oct 2018 23:07:07 -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.05 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Oct 2018 23:07:06 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 18 Oct 2018 23:06:41 -0700 Message-Id: <20181019060656.7968-7-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> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::62a Subject: [Qemu-devel] [PULL v2 06/21] target/alpha: remove tlb_flush from alpha_cpu_initfn 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" As far as I can tell tlb_flush does not need to be called this early. tlb_flush is eventually called after the CPU has been realized. This change paves the way to the introduction of tlb_init, which will be called from cpu_exec_realizefn. Reviewed-by: Alex Bennée Reviewed-by: Richard Henderson Signed-off-by: Emilio G. Cota Message-Id: <20181009174557.16125-2-cota@braap.org> Signed-off-by: Richard Henderson --- target/alpha/cpu.c | 1 - 1 file changed, 1 deletion(-) -- 2.17.2 diff --git a/target/alpha/cpu.c b/target/alpha/cpu.c index b08078e7fc..a953897fcc 100644 --- a/target/alpha/cpu.c +++ b/target/alpha/cpu.c @@ -201,7 +201,6 @@ static void alpha_cpu_initfn(Object *obj) CPUAlphaState *env = &cpu->env; cs->env_ptr = env; - tlb_flush(cs); env->lock_addr = -1; #if defined(CONFIG_USER_ONLY) From patchwork Fri Oct 19 06:06:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 149231 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp2911860lji; Thu, 18 Oct 2018 23:18:25 -0700 (PDT) X-Google-Smtp-Source: ACcGV603o2sYh9zmNwaFqjD7zalpESemDepfmD5pwrczcVlMaQJmszHslTkjlbWdRbknux66of3V X-Received: by 2002:ac8:1c43:: with SMTP id j3-v6mr240818qtk.320.1539929905197; Thu, 18 Oct 2018 23:18:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539929905; cv=none; d=google.com; s=arc-20160816; b=oUqoftXIsaKLw9PXAKqBCyGB9P5tvHkEUMY9bAoYe1StGiqeOeCnAJ7Tpz5AR420oU yqmz3Ltj9SGvPwnzQ+flD03lFxlj0KuCSCLS8EGK5zAFkin0Y20edpeYJfI4kSZYiJhR 2GFEM7S6Rv1tFFwJ9mleY1qUDpmIGrMHjmK4VMis3wFPA/lgfvxSOV0Wi6G1C63RF2vc Uv4Q46CpaZ330RkYnxG+wxF1oT90GZ9s4kpVk0QmQwv+Z/OHmWIEGDI6LaVrxwoSfjEt 3NMxWGPF//tzDEy+f8xp/K5B0l4aoEY5QOElZWsB3lypnkIAPX58mNF7JRyK5Hrr+F5Z g1VA== 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 :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=iQuRnp6tSFYZasKkNBV6hIxMETb4h2l2cVJHyyzAdxw=; b=1KMAdawsp249m2wVFODhnjR47fmeSdnZEzTuSc1QMVAU8F/VdL4cKiFPePkymbVw+Z lmNNfhSSpoScKYt4B8jAumyyjmlGJSSSi5k+stJfvV8akN5zORqIaBUaQDmpcqp6/rN0 wqXQDosbRNTx6W6wednKQPElDSazK4EiJLfbIM8ca1yeNfaiY86SNjGGf5qQRluc81o4 44B8IxIdYnNHP23pvamYTJ4NBqtAWM/uv3D+T9/Uw8/0TJ2ggIAK5xwY83YOZQ53efts 2oN/v7ET1saC0vzeDLZ4wHQUxdp/wBy5TgFQN+8M2w1Lr8JLKuailofvnklSuCekNWqC /7Lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=YMJsc6bs; 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 h61-v6si323314qtd.117.2018.10.18.23.18.25 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 18 Oct 2018 23:18:25 -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=YMJsc6bs; 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]:47272 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDO76-00067d-KB for patch@linaro.org; Fri, 19 Oct 2018 02:18:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39072) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDNwa-0004FN-7F for qemu-devel@nongnu.org; Fri, 19 Oct 2018 02:07:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gDNwP-0002Fx-Vt for qemu-devel@nongnu.org; Fri, 19 Oct 2018 02:07:29 -0400 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]:37374) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gDNwD-00021n-U2 for qemu-devel@nongnu.org; Fri, 19 Oct 2018 02:07:11 -0400 Received: by mail-pf1-x433.google.com with SMTP id j23-v6so16001238pfi.4 for ; Thu, 18 Oct 2018 23:07:09 -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 :mime-version:content-transfer-encoding; bh=iQuRnp6tSFYZasKkNBV6hIxMETb4h2l2cVJHyyzAdxw=; b=YMJsc6bsR5yT2OVpRgo54ClXprfa1GTTA0OdrlqvhDYX3aipg8eYTehVlrkjv/Idzq yq7GJnq95NCic5KAqi0x7aohU3WI5IBLvKYZ2yfYUr80aoMnnp9JTsVjytp1LnvlQBC7 q86VmSAySa8bO3/yCySCMPMv62q7fN8/q8qaY= 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:mime-version:content-transfer-encoding; bh=iQuRnp6tSFYZasKkNBV6hIxMETb4h2l2cVJHyyzAdxw=; b=DRJM0ChDqnOr1LapiUl9VX8fVV+VDNWeIlEh6WYbAfq1rU/wR+/ijhIqOxNpovTBh7 jeJ/zEifGqW+XChTwh51myKY9OixhWkbt86NIFNHmOeD796mq+56hAJaooSUjVZjM1Gs ISkDER1kiehzA+saPWcCiHso5eB0WEOWiaW9dhFpft1YtaQVbhFeoVo1sIWEBbcWRvCS V/3dDxXleYcuZQTlabWutEom/ykHMHA76wRVbGtZiMY0ctInfOP0ecgcm3MZDfTn/JhS UiQ1Tka5Tmcm7htLXg5OETjBmTAbYvfko2yFXcGAr3+hxx1TELuW0Sq2WSm4UTBLc7Fu QdqQ== X-Gm-Message-State: ABuFfoiVkEVWf/TCOjeAk/HsiEG2tsSU2zAfZhObZDEDOMn7k7jpIz7t KF8L+EslRBm87HtDXYCr4WGM3ozJX+w= X-Received: by 2002:a62:4ec9:: with SMTP id c192-v6mr33165133pfb.221.1539929228403; Thu, 18 Oct 2018 23:07:08 -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.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Oct 2018 23:07:07 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 18 Oct 2018 23:06:42 -0700 Message-Id: <20181019060656.7968-8-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> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::433 Subject: [Qemu-devel] [PULL v2 07/21] target/unicore32: remove tlb_flush from uc32_init_fn 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: Guan Xuetao , peter.maydell@linaro.org, "Emilio G. Cota" Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" As far as I can tell tlb_flush does not need to be called this early. tlb_flush is eventually called after the CPU has been realized. This change paves the way to the introduction of tlb_init, which will be called from cpu_exec_realizefn. Cc: Guan Xuetao Reviewed-by: Alex Bennée Reviewed-by: Richard Henderson Signed-off-by: Emilio G. Cota Message-Id: <20181009174557.16125-3-cota@braap.org> Signed-off-by: Richard Henderson --- target/unicore32/cpu.c | 2 -- 1 file changed, 2 deletions(-) -- 2.17.2 diff --git a/target/unicore32/cpu.c b/target/unicore32/cpu.c index 68f978d80b..2b49d1ca40 100644 --- a/target/unicore32/cpu.c +++ b/target/unicore32/cpu.c @@ -116,8 +116,6 @@ static void uc32_cpu_initfn(Object *obj) env->uncached_asr = ASR_MODE_PRIV; env->regs[31] = 0x03000000; #endif - - tlb_flush(cs); } static const VMStateDescription vmstate_uc32_cpu = { From patchwork Fri Oct 19 06:06:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 149222 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp2905920lji; Thu, 18 Oct 2018 23:10:40 -0700 (PDT) X-Google-Smtp-Source: ACcGV60iDhnwBzZ4DNueGLOmxzB3Ua5+uTTkdJ48K4Exy/D8vFMjnqsg9TLaDVFAcwyUsnbMuzN1 X-Received: by 2002:ac8:f29:: with SMTP id e38-v6mr2536195qtk.262.1539929440124; Thu, 18 Oct 2018 23:10:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539929440; cv=none; d=google.com; s=arc-20160816; b=mVBJcsE3PRvt2Nf9t4MX5AcR+iGZHtOVlKEapGK1jU2OBDKzab4Q1sDY2G+6nMsrQn eqV98c5RQ7OSA9P2LzPfXwUiw41TmzqW1o04stjmd3fVC9qHF53/nLUmbgG46M8jOQA6 KR8c8Rci6tRu7N4E4WrIRl8sQk6qK4MEZdHkO6tDVtkbAQ41wGJUX6qTu6UvStu7TvUe R+CCpiypGThshu3HKgp0rhysnN0HLzx+HVFJsXKsXphB8kRTqAOHA7OCRoD4gh39lM9P NyS2jib4iU6fHXlHvxnOCDgyHLdfjAhe/H4uMfUfp9WlaqK2xuA80pTg0O3s1D9yRTet WPRQ== 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 :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=LKN2z9Wa6kilfugmhk5H2yz/XJ83s7o6//DumOkcw8c=; b=DYBRrXPDBnVyiLjcnFfJF+ct5xhUNy4DDlMRMpHsP5Wf9tPZkthDVZ1zGCkP0eSyCM 8jwI/YbCpI73M0Dme3Cbb+FQutnqPQIHr7YXkGLqf7RHwEAu84MMUOP9MemRo8NS1QWF jTbDoOB29gMUe8lEGg2he7kCXl+lEFKezxhsCuWbNhY6RSbAf0A0LCYgcwVt/m+uGF60 xKvZ9BCtmsnhpvDymrT6ZZJmoUWwrnc3GALzBEDfMj+PYHaZuIH0Kzw2h9gbVQtqelDZ Phh/Ts6b4XoYG2Nd4PqVFJjALIffyHSkx0QrxPxu0fbvIscgtUHqrfzR7YM1GQTcmOKI muiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="VIkVC5O/"; 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 q8-v6si472892qtp.2.2018.10.18.23.10.39 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 18 Oct 2018 23:10:40 -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="VIkVC5O/"; 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]:47233 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDNzb-0007Hc-E8 for patch@linaro.org; Fri, 19 Oct 2018 02:10:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39068) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDNwa-0004FL-6i for qemu-devel@nongnu.org; Fri, 19 Oct 2018 02:07:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gDNwT-0002L4-2G for qemu-devel@nongnu.org; Fri, 19 Oct 2018 02:07:29 -0400 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:42564) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gDNwK-00024u-98 for qemu-devel@nongnu.org; Fri, 19 Oct 2018 02:07:20 -0400 Received: by mail-pl1-x641.google.com with SMTP id c8-v6so15376081plo.9 for ; Thu, 18 Oct 2018 23:07:11 -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 :mime-version:content-transfer-encoding; bh=LKN2z9Wa6kilfugmhk5H2yz/XJ83s7o6//DumOkcw8c=; b=VIkVC5O/lHKdzuaT8U1Mwcn+qfMDWiu7qQmOu0BNuc67vL6HhjvWa5jhvtoVZj7NiZ 1ZDMlF21ss4NwEtxmc70cM3ScCrn0aaeafwM3IU1EdzvrzXaefdjh6Cw5J8+ku9P9Dr5 uBbehl1QxFpnZXGv3OYHd6qII+wJUlHCM+8V4= 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:mime-version:content-transfer-encoding; bh=LKN2z9Wa6kilfugmhk5H2yz/XJ83s7o6//DumOkcw8c=; b=lR5Cw8OVlAJkhoQFhar7gVhl7ydKyMmn4u1htOwNN+MqN9/3IcwXIf+4aEoYZeVUhH ePjoxoSBTj5XTzSsxJ77lF1P3PTseUXNi6fY1jlUWmzH8qM4LypC9Z+irysPuBp/oY/r jlEUgE5LJZc/jcKcgCtD7nLYWpfgOrXFlUrExcy+LOE4JwCmY3QbeeulZdCSSjZ80RpS SBBIT+Wl4k/upVN4p05r6uP77u0282oWVIMCPCQuSBJHkAhxwB9j2cvJ7Lh/vWuSMF/h TyDw8Zwz2xj5eL4qs7Nb48yQXB9fgsG03OF+6eWpT9WN2PnxeboNxFw9/DceYeIZLojE TC+w== X-Gm-Message-State: ABuFfoi5Bb0dn2oVLbq4ry2rflnc0+lRREo/H+Ilry8+HoBtbj89quYl rzw4K570/0VLR7EiXT3NOraFXxzffLw= X-Received: by 2002:a17:902:6689:: with SMTP id e9-v6mr8841189plk.128.1539929229788; Thu, 18 Oct 2018 23:07:09 -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.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Oct 2018 23:07:08 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 18 Oct 2018 23:06:43 -0700 Message-Id: <20181019060656.7968-9-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> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::641 Subject: [Qemu-devel] [PULL v2 08/21] exec: introduce tlb_init 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" Paves the way for the addition of a per-TLB lock. Reviewed-by: Alex Bennée Reviewed-by: Richard Henderson Signed-off-by: Emilio G. Cota Message-Id: <20181009174557.16125-4-cota@braap.org> Signed-off-by: Richard Henderson --- include/exec/exec-all.h | 8 ++++++++ accel/tcg/cputlb.c | 4 ++++ exec.c | 1 + 3 files changed, 13 insertions(+) -- 2.17.2 diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index 5f78125582..815e5b1e83 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -99,6 +99,11 @@ void cpu_address_space_init(CPUState *cpu, int asidx, #if !defined(CONFIG_USER_ONLY) && defined(CONFIG_TCG) /* cputlb.c */ +/** + * tlb_init - initialize a CPU's TLB + * @cpu: CPU whose TLB should be initialized + */ +void tlb_init(CPUState *cpu); /** * tlb_flush_page: * @cpu: CPU whose TLB should be flushed @@ -258,6 +263,9 @@ void tlb_set_page(CPUState *cpu, target_ulong vaddr, void probe_write(CPUArchState *env, target_ulong addr, int size, int mmu_idx, uintptr_t retaddr); #else +static inline void tlb_init(CPUState *cpu) +{ +} static inline void tlb_flush_page(CPUState *cpu, target_ulong addr) { } diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index f4702ce91f..502eea2850 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -73,6 +73,10 @@ QEMU_BUILD_BUG_ON(sizeof(target_ulong) > sizeof(run_on_cpu_data)); QEMU_BUILD_BUG_ON(NB_MMU_MODES > 16); #define ALL_MMUIDX_BITS ((1 << NB_MMU_MODES) - 1) +void tlb_init(CPUState *cpu) +{ +} + /* flush_all_helper: run fn across all cpus * * If the wait flag is set then the src cpu's helper will be queued as diff --git a/exec.c b/exec.c index 5d99ef5c93..bb6170dbff 100644 --- a/exec.c +++ b/exec.c @@ -965,6 +965,7 @@ void cpu_exec_realizefn(CPUState *cpu, Error **errp) tcg_target_initialized = true; cc->tcg_initialize(); } + tlb_init(cpu); #ifndef CONFIG_USER_ONLY if (qdev_get_vmsd(DEVICE(cpu)) == NULL) { From patchwork Fri Oct 19 06:06:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 149239 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp2917507lji; Thu, 18 Oct 2018 23:25:54 -0700 (PDT) X-Google-Smtp-Source: ACcGV636RzpvBMMAZL8VBeSKaDu7MJi/CVYp2UxILZEoFttrdo0460+1btLZzCCfarr2yNbV6OEp X-Received: by 2002:a0c:e54f:: with SMTP id n15mr24977561qvm.242.1539930354041; Thu, 18 Oct 2018 23:25:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539930354; cv=none; d=google.com; s=arc-20160816; b=RmIqRDhReDhy6jaSleRClzyUT+KQ2OhR6eK/iCcb9D/ZXzvAV49VgBExzq2NN5/+0p t91p3tYCFUJgZ7JS4dNeNSo4coVG97yl6q8e537WZ/RjNzl2wHOIZSXbOe4K2oWTX3sp WKkelskwK4JVBNroQKccqYIHhpG0IOvmDCSNrmyoxVzgJZ+1AkUKCT2KGIDxgEYWxsnp D8IlDzmW91/7jGhjoQUAISXMTrOZVbEhLD3JJpSjgRw81nt/69xRSEpW2/Ky01U38P1o RBkBJji9f5K1xWXKZbQIKYC2XQaeMByGvPQpAtN6CXgTpExM/LEQ74vh6DGcxp032gUk kJ4w== 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 :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=R6mtWCX2I06Nt9gLSmekIxRYDH7dbVsVhYig7687N1E=; b=KeeHDu7CfnoMrnhZg8V96PaPEVgRp4LZbxdM0ROC6OEaULqEJnCr8pUR2mm9myvL+y t/wj5oDiK6EGtSYMsiqPrqjySZh32b+mOv0HNN0/t/XhzC5OAKjkwTkznODVMH5tEgNh CzcLAskM9X4I16tBa4cL38WPkNDEhK2wo01LlXaoNBeBQctzDBLobeXurUm5x3HKviJE bis8LjLCNOwaLJ4v9af8q+0Zlnfn5R6tKlfMfCqu78QrUvyisMmNO36OJtma1M4zBwKS o+bljYmwuU6cpzbBzQyldxWOyf1zNq120JRgdH1S6IHP1kLa3yEXXewYb+WvgQHwNL6o aOIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=jx7Q49Ow; 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 m12-v6si212088qkm.25.2018.10.18.23.25.53 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 18 Oct 2018 23:25:54 -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=jx7Q49Ow; 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]:47351 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDOEL-0003MP-Jl for patch@linaro.org; Fri, 19 Oct 2018 02:25:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39262) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDNwj-0004Tr-A2 for qemu-devel@nongnu.org; Fri, 19 Oct 2018 02:07:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gDNwg-0002nt-9z for qemu-devel@nongnu.org; Fri, 19 Oct 2018 02:07:41 -0400 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]:38372) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gDNwf-00027G-QK for qemu-devel@nongnu.org; Fri, 19 Oct 2018 02:07:38 -0400 Received: by mail-pl1-x634.google.com with SMTP id q19-v6so12325465pll.5 for ; Thu, 18 Oct 2018 23:07:12 -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 :mime-version:content-transfer-encoding; bh=R6mtWCX2I06Nt9gLSmekIxRYDH7dbVsVhYig7687N1E=; b=jx7Q49OwZ1muJj0gUevZ0KVVArqNkmsHH48SRZslF83Bj5ou3v21BjgCxGSGQO91wm wU9wQV0gtfadXCpXeIAaathV1Lh0giO26MyUfBkdY3v50q7CKLiUbX2dBXjaHoHGn4hf r5RNbpCz8p3X7gmxlQzrscagdOre/efW04Ct8= 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:mime-version:content-transfer-encoding; bh=R6mtWCX2I06Nt9gLSmekIxRYDH7dbVsVhYig7687N1E=; b=qLpAWskiBh3m4t3eK7RM4edLoN7KdavQLcOSOk+DUNphEQOML4QmgzLHMLj+r/WJFH aanZlEHHmv3rPRKvDsJ8Thr4kXZGGekS3FDszlrmF89LF4TEpMUVKAQ5J5Ez0Ig0SiEh 4I8707vEGq2ISQBslD36GTVHYsjzissK98qnEI+Eq6/ZbEqdlFxBukphWC4Wt0dzuW4e vCmaR0bRvzfJ+dVI5JuV8nByah2FP/DrNjJKgMsaTRPLsJBcOZm5bZzk/BHNPGsM4btQ xPlFMEZuynYCkYtZRswKclvzlanoycHvIBYsPyhYOM/mmJlVyerq6lxmzBPowKZP43Uj u+4g== X-Gm-Message-State: ABuFfohDKV1ic8CK1bgzoxROhZLxsG0hJKTxMHuAAFjXDRPIVqwIlx3X kHpgzZTolEwbtbBKCtOFFcRWUkNs8kI= X-Received: by 2002:a17:902:9002:: with SMTP id a2-v6mr9574019plp.291.1539929231234; Thu, 18 Oct 2018 23:07:11 -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.09 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Oct 2018 23:07:10 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 18 Oct 2018 23:06:44 -0700 Message-Id: <20181019060656.7968-10-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> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::634 Subject: [Qemu-devel] [PULL v2 09/21] cputlb: fix assert_cpu_is_self macro 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" Reviewed-by: Richard Henderson Reviewed-by: Alex Bennée Signed-off-by: Emilio G. Cota Message-Id: <20181009174557.16125-5-cota@braap.org> Signed-off-by: Richard Henderson --- accel/tcg/cputlb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.17.2 diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index 502eea2850..f6b388c961 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -58,9 +58,9 @@ } \ } while (0) -#define assert_cpu_is_self(this_cpu) do { \ +#define assert_cpu_is_self(cpu) do { \ if (DEBUG_TLB_GATE) { \ - g_assert(!cpu->created || qemu_cpu_is_self(cpu)); \ + g_assert(!(cpu)->created || qemu_cpu_is_self(cpu)); \ } \ } while (0) From patchwork Fri Oct 19 06:06:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 149228 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp2909934lji; Thu, 18 Oct 2018 23:15:51 -0700 (PDT) X-Google-Smtp-Source: ACcGV60RFd2tV4WM54AJ98fpIBxQl1/neU9L8JSOpa8Y+s+oAZt/V34OFY+g4iU8fG5ZPQmZHnLw X-Received: by 2002:ac8:1988:: with SMTP id u8-v6mr30272122qtj.86.1539929751176; Thu, 18 Oct 2018 23:15:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539929751; cv=none; d=google.com; s=arc-20160816; b=rTPDP8R8iGA5VxyasukSDQ2+1h9MZ/F9Z0BHV8E2fxuJxbbpfGD6W3MThD+4Wwc9eD b1H0F0ag81vtNwL1HIO42Z7JF/SKwLzp8ZWcrNpOZ3M0uEo8UgK2Ay8XqULrGTN7pgym FOz/IjYiirJAFOETezvjNnFDOGrVMTqUuo43Z6W7ZZrJIWlkTYld7U5oFU8H6lsW64HT DLHcpcYbubjGg+npFlCFSz1mHcipwEZgIaJQXYs8D6KkeVflYFNsBAt7YkZ7xFh04UAi na2K85wOw+48XpM1VJRdCiRxQpbrZrK/jAhA9M6MoKyn6XtbGLtxRDf6NW1XPbOU6QYS K+LA== 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 :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=cE+f8hj2LV4MNdZZfNJ1txs6SrJLXsbsS3xsy84Ye68=; b=VzeukL4Ug9mSiiEsWb0f9vQp4lkMZPbmZI853lUm5KjLCn27SS9TfW1PIenrppe5YW 8Xhz/5M9Xc87KDo2ZK+hbsgmN8/Iy/pgmLub+CnbhC7kkMNKFP9ze5TOh8Qy2haP21bD H+0sG2oVUlno05LCGGBxs803hUTRv26b8b4St5E4/j3PL2yo272tzwI0LJi/2FZfRV6l jQPSFgaSybdmYHx5v/ksLrJLpVCONnjcErFEOJIw/iN1PCgMa0jsZ+M8Gj9IQTrdybtx 9KCrqToAyQ08OJCJzZ9WIhiM7NzanjlXKeg8M7AF2EwR3yP/6yYPf/ypK2QuUurUWTRr TRaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=AvPmYWs4; 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 q6si1163098qvo.96.2018.10.18.23.15.50 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 18 Oct 2018 23:15:51 -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=AvPmYWs4; 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]:47262 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDO4c-0003kU-HV for patch@linaro.org; Fri, 19 Oct 2018 02:15:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39107) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDNwe-0004Iv-Cr for qemu-devel@nongnu.org; Fri, 19 Oct 2018 02:07:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gDNwc-0002ZX-8D for qemu-devel@nongnu.org; Fri, 19 Oct 2018 02:07:36 -0400 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]:45602) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gDNwY-00029B-9h for qemu-devel@nongnu.org; Fri, 19 Oct 2018 02:07:32 -0400 Received: by mail-pl1-x643.google.com with SMTP id y15-v6so15390367plr.12 for ; Thu, 18 Oct 2018 23:07:14 -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 :mime-version:content-transfer-encoding; bh=cE+f8hj2LV4MNdZZfNJ1txs6SrJLXsbsS3xsy84Ye68=; b=AvPmYWs4RiIBKkzz5pt3u5RXZWbbpTatSUhMHIWwAgBAsvpgBWinNAoTOr4uIrLd7d ZahOLU7DFuZCY+viC1Yii5rWQVpmL7yrf9V9MzS9Ff1B4saSavTl4NuErMwA43jPmUMU YXE6pqw97yrdmmCzMyieSrnGpTbVy52V+BITw= 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:mime-version:content-transfer-encoding; bh=cE+f8hj2LV4MNdZZfNJ1txs6SrJLXsbsS3xsy84Ye68=; b=hMld8IU+Y9M5oHI715N2cIrS/nqRjhS+fwORuP6076i7yy4VpM03CkVgfcaMZCzXa5 0+3MSBEmvi/MJx8uiNm7br0EEiyaiKrt2FynKzI6+HyFv1NQGGEJakuVye27sIhiAsKf qDHPusGCTxRChWkQ4m2HTJDfMWIwnW1WrBT5wjWnsq1rZag6mFS9QxNJbqM9sxHNDExm p6uxyVPAMSYKJMyD6IA7aw+fxuhJMlgLU8dl/8WDnKDikzeSUvLnPAPnypslBYUL4pMH Fee+eyI/dMBs2kAOrvrnDHAv8g9ZlAwysZj25prqQM0uoO6sHgP2S2klYS8LiqawViQr xy5w== X-Gm-Message-State: ABuFfoggYqDpyAnAK2Ww9KPg+bG7ipgB3DhaXjHuixsRsolFShx5RvA1 41WlncCDAGUy/c8iQ6Wfu3TVlQB1TcA= X-Received: by 2002:a17:902:9a45:: with SMTP id x5-v6mr32606025plv.213.1539929232725; Thu, 18 Oct 2018 23:07:12 -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.11 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Oct 2018 23:07:11 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 18 Oct 2018 23:06:45 -0700 Message-Id: <20181019060656.7968-11-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> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::643 Subject: [Qemu-devel] [PULL v2 10/21] cputlb: serialize tlb updates with env->tlb_lock 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" Currently we rely on atomic operations for cross-CPU invalidations. There are two cases that these atomics miss: cross-CPU invalidations can race with either (1) vCPU threads flushing their TLB, which happens via memset, or (2) vCPUs calling tlb_reset_dirty on their TLB, which updates .addr_write with a regular store. This results in undefined behaviour, since we're mixing regular and atomic ops on concurrent accesses. Fix it by using tlb_lock, a per-vCPU lock. All updaters of tlb_table and the corresponding victim cache now hold the lock. The readers that do not hold tlb_lock must use atomic reads when reading .addr_write, since this field can be updated by other threads; the conversion to atomic reads is done in the next patch. Note that an alternative fix would be to expand the use of atomic ops. However, in the case of TLB flushes this would have a huge performance impact, since (1) TLB flushes can happen very frequently and (2) we currently use a full memory barrier to flush each TLB entry, and a TLB has many entries. Instead, acquiring the lock is barely slower than a full memory barrier since it is uncontended, and with a single lock acquisition we can flush the entire TLB. Tested-by: Alex Bennée Reviewed-by: Alex Bennée Signed-off-by: Emilio G. Cota Message-Id: <20181009174557.16125-6-cota@braap.org> Signed-off-by: Richard Henderson --- include/exec/cpu-defs.h | 3 + accel/tcg/cputlb.c | 155 ++++++++++++++++++++++------------------ 2 files changed, 87 insertions(+), 71 deletions(-) -- 2.17.2 diff --git a/include/exec/cpu-defs.h b/include/exec/cpu-defs.h index a171ffc1a4..4ff62f32bf 100644 --- a/include/exec/cpu-defs.h +++ b/include/exec/cpu-defs.h @@ -24,6 +24,7 @@ #endif #include "qemu/host-utils.h" +#include "qemu/thread.h" #include "qemu/queue.h" #ifdef CONFIG_TCG #include "tcg-target.h" @@ -142,6 +143,8 @@ typedef struct CPUIOTLBEntry { #define CPU_COMMON_TLB \ /* The meaning of the MMU modes is defined in the target code. */ \ + /* tlb_lock serializes updates to tlb_table and tlb_v_table */ \ + QemuSpin tlb_lock; \ CPUTLBEntry tlb_table[NB_MMU_MODES][CPU_TLB_SIZE]; \ CPUTLBEntry tlb_v_table[NB_MMU_MODES][CPU_VTLB_SIZE]; \ CPUIOTLBEntry iotlb[NB_MMU_MODES][CPU_TLB_SIZE]; \ diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index f6b388c961..c2a6190674 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -75,6 +75,9 @@ QEMU_BUILD_BUG_ON(NB_MMU_MODES > 16); void tlb_init(CPUState *cpu) { + CPUArchState *env = cpu->env_ptr; + + qemu_spin_init(&env->tlb_lock); } /* flush_all_helper: run fn across all cpus @@ -129,8 +132,17 @@ static void tlb_flush_nocheck(CPUState *cpu) atomic_set(&env->tlb_flush_count, env->tlb_flush_count + 1); tlb_debug("(count: %zu)\n", tlb_flush_count()); + /* + * tlb_table/tlb_v_table updates from any thread must hold tlb_lock. + * However, updates from the owner thread (as is the case here; see the + * above assert_cpu_is_self) do not need atomic_set because all reads + * that do not hold the lock are performed by the same owner thread. + */ + qemu_spin_lock(&env->tlb_lock); memset(env->tlb_table, -1, sizeof(env->tlb_table)); memset(env->tlb_v_table, -1, sizeof(env->tlb_v_table)); + qemu_spin_unlock(&env->tlb_lock); + cpu_tb_jmp_cache_clear(cpu); env->vtlb_index = 0; @@ -182,6 +194,7 @@ static void tlb_flush_by_mmuidx_async_work(CPUState *cpu, run_on_cpu_data data) tlb_debug("start: mmu_idx:0x%04lx\n", mmu_idx_bitmask); + qemu_spin_lock(&env->tlb_lock); for (mmu_idx = 0; mmu_idx < NB_MMU_MODES; mmu_idx++) { if (test_bit(mmu_idx, &mmu_idx_bitmask)) { @@ -191,6 +204,7 @@ static void tlb_flush_by_mmuidx_async_work(CPUState *cpu, run_on_cpu_data data) memset(env->tlb_v_table[mmu_idx], -1, sizeof(env->tlb_v_table[0])); } } + qemu_spin_unlock(&env->tlb_lock); cpu_tb_jmp_cache_clear(cpu); @@ -247,19 +261,24 @@ static inline bool tlb_hit_page_anyprot(CPUTLBEntry *tlb_entry, tlb_hit_page(tlb_entry->addr_code, page); } -static inline void tlb_flush_entry(CPUTLBEntry *tlb_entry, target_ulong page) +/* Called with tlb_lock held */ +static inline void tlb_flush_entry_locked(CPUTLBEntry *tlb_entry, + target_ulong page) { if (tlb_hit_page_anyprot(tlb_entry, page)) { memset(tlb_entry, -1, sizeof(*tlb_entry)); } } -static inline void tlb_flush_vtlb_page(CPUArchState *env, int mmu_idx, - target_ulong page) +/* Called with tlb_lock held */ +static inline void tlb_flush_vtlb_page_locked(CPUArchState *env, int mmu_idx, + target_ulong page) { int k; + + assert_cpu_is_self(ENV_GET_CPU(env)); for (k = 0; k < CPU_VTLB_SIZE; k++) { - tlb_flush_entry(&env->tlb_v_table[mmu_idx][k], page); + tlb_flush_entry_locked(&env->tlb_v_table[mmu_idx][k], page); } } @@ -286,10 +305,12 @@ static void tlb_flush_page_async_work(CPUState *cpu, run_on_cpu_data data) addr &= TARGET_PAGE_MASK; i = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); + qemu_spin_lock(&env->tlb_lock); for (mmu_idx = 0; mmu_idx < NB_MMU_MODES; mmu_idx++) { - tlb_flush_entry(&env->tlb_table[mmu_idx][i], addr); - tlb_flush_vtlb_page(env, mmu_idx, addr); + tlb_flush_entry_locked(&env->tlb_table[mmu_idx][i], addr); + tlb_flush_vtlb_page_locked(env, mmu_idx, addr); } + qemu_spin_unlock(&env->tlb_lock); tb_flush_jmp_cache(cpu, addr); } @@ -326,12 +347,14 @@ static void tlb_flush_page_by_mmuidx_async_work(CPUState *cpu, tlb_debug("page:%d addr:"TARGET_FMT_lx" mmu_idx:0x%lx\n", page, addr, mmu_idx_bitmap); + qemu_spin_lock(&env->tlb_lock); for (mmu_idx = 0; mmu_idx < NB_MMU_MODES; mmu_idx++) { if (test_bit(mmu_idx, &mmu_idx_bitmap)) { - tlb_flush_entry(&env->tlb_table[mmu_idx][page], addr); - tlb_flush_vtlb_page(env, mmu_idx, addr); + tlb_flush_entry_locked(&env->tlb_table[mmu_idx][page], addr); + tlb_flush_vtlb_page_locked(env, mmu_idx, addr); } } + qemu_spin_unlock(&env->tlb_lock); tb_flush_jmp_cache(cpu, addr); } @@ -454,72 +477,44 @@ void tlb_unprotect_code(ram_addr_t ram_addr) * most usual is detecting writes to code regions which may invalidate * generated code. * - * Because we want other vCPUs to respond to changes straight away we - * update the te->addr_write field atomically. If the TLB entry has - * been changed by the vCPU in the mean time we skip the update. + * Other vCPUs might be reading their TLBs during guest execution, so we update + * te->addr_write with atomic_set. We don't need to worry about this for + * oversized guests as MTTCG is disabled for them. * - * As this function uses atomic accesses we also need to ensure - * updates to tlb_entries follow the same access rules. We don't need - * to worry about this for oversized guests as MTTCG is disabled for - * them. + * Called with tlb_lock held. */ - -static void tlb_reset_dirty_range(CPUTLBEntry *tlb_entry, uintptr_t start, - uintptr_t length) +static void tlb_reset_dirty_range_locked(CPUTLBEntry *tlb_entry, + uintptr_t start, uintptr_t length) { -#if TCG_OVERSIZED_GUEST uintptr_t addr = tlb_entry->addr_write; if ((addr & (TLB_INVALID_MASK | TLB_MMIO | TLB_NOTDIRTY)) == 0) { addr &= TARGET_PAGE_MASK; addr += tlb_entry->addend; if ((addr - start) < length) { +#if TCG_OVERSIZED_GUEST tlb_entry->addr_write |= TLB_NOTDIRTY; - } - } #else - /* paired with atomic_mb_set in tlb_set_page_with_attrs */ - uintptr_t orig_addr = atomic_mb_read(&tlb_entry->addr_write); - uintptr_t addr = orig_addr; - - if ((addr & (TLB_INVALID_MASK | TLB_MMIO | TLB_NOTDIRTY)) == 0) { - addr &= TARGET_PAGE_MASK; - addr += atomic_read(&tlb_entry->addend); - if ((addr - start) < length) { - uintptr_t notdirty_addr = orig_addr | TLB_NOTDIRTY; - atomic_cmpxchg(&tlb_entry->addr_write, orig_addr, notdirty_addr); + atomic_set(&tlb_entry->addr_write, + tlb_entry->addr_write | TLB_NOTDIRTY); +#endif } } -#endif } -/* For atomic correctness when running MTTCG we need to use the right - * primitives when copying entries */ -static inline void copy_tlb_helper(CPUTLBEntry *d, CPUTLBEntry *s, - bool atomic_set) +/* + * Called with tlb_lock held. + * Called only from the vCPU context, i.e. the TLB's owner thread. + */ +static inline void copy_tlb_helper_locked(CPUTLBEntry *d, const CPUTLBEntry *s) { -#if TCG_OVERSIZED_GUEST *d = *s; -#else - if (atomic_set) { - d->addr_read = s->addr_read; - d->addr_code = s->addr_code; - atomic_set(&d->addend, atomic_read(&s->addend)); - /* Pairs with flag setting in tlb_reset_dirty_range */ - atomic_mb_set(&d->addr_write, atomic_read(&s->addr_write)); - } else { - d->addr_read = s->addr_read; - d->addr_write = atomic_read(&s->addr_write); - d->addr_code = s->addr_code; - d->addend = atomic_read(&s->addend); - } -#endif } /* This is a cross vCPU call (i.e. another vCPU resetting the flags of - * the target vCPU). As such care needs to be taken that we don't - * dangerously race with another vCPU update. The only thing actually - * updated is the target TLB entry ->addr_write flags. + * the target vCPU). + * We must take tlb_lock to avoid racing with another vCPU update. The only + * thing actually updated is the target TLB entry ->addr_write flags. */ void tlb_reset_dirty(CPUState *cpu, ram_addr_t start1, ram_addr_t length) { @@ -528,22 +523,26 @@ void tlb_reset_dirty(CPUState *cpu, ram_addr_t start1, ram_addr_t length) int mmu_idx; env = cpu->env_ptr; + qemu_spin_lock(&env->tlb_lock); for (mmu_idx = 0; mmu_idx < NB_MMU_MODES; mmu_idx++) { unsigned int i; for (i = 0; i < CPU_TLB_SIZE; i++) { - tlb_reset_dirty_range(&env->tlb_table[mmu_idx][i], - start1, length); + tlb_reset_dirty_range_locked(&env->tlb_table[mmu_idx][i], start1, + length); } for (i = 0; i < CPU_VTLB_SIZE; i++) { - tlb_reset_dirty_range(&env->tlb_v_table[mmu_idx][i], - start1, length); + tlb_reset_dirty_range_locked(&env->tlb_v_table[mmu_idx][i], start1, + length); } } + qemu_spin_unlock(&env->tlb_lock); } -static inline void tlb_set_dirty1(CPUTLBEntry *tlb_entry, target_ulong vaddr) +/* Called with tlb_lock held */ +static inline void tlb_set_dirty1_locked(CPUTLBEntry *tlb_entry, + target_ulong vaddr) { if (tlb_entry->addr_write == (vaddr | TLB_NOTDIRTY)) { tlb_entry->addr_write = vaddr; @@ -562,16 +561,18 @@ void tlb_set_dirty(CPUState *cpu, target_ulong vaddr) vaddr &= TARGET_PAGE_MASK; i = (vaddr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); + qemu_spin_lock(&env->tlb_lock); for (mmu_idx = 0; mmu_idx < NB_MMU_MODES; mmu_idx++) { - tlb_set_dirty1(&env->tlb_table[mmu_idx][i], vaddr); + tlb_set_dirty1_locked(&env->tlb_table[mmu_idx][i], vaddr); } for (mmu_idx = 0; mmu_idx < NB_MMU_MODES; mmu_idx++) { int k; for (k = 0; k < CPU_VTLB_SIZE; k++) { - tlb_set_dirty1(&env->tlb_v_table[mmu_idx][k], vaddr); + tlb_set_dirty1_locked(&env->tlb_v_table[mmu_idx][k], vaddr); } } + qemu_spin_unlock(&env->tlb_lock); } /* Our TLB does not support large pages, so remember the area covered by @@ -658,9 +659,6 @@ void tlb_set_page_with_attrs(CPUState *cpu, target_ulong vaddr, addend = (uintptr_t)memory_region_get_ram_ptr(section->mr) + xlat; } - /* Make sure there's no cached translation for the new page. */ - tlb_flush_vtlb_page(env, mmu_idx, vaddr_page); - code_address = address; iotlb = memory_region_section_get_iotlb(cpu, section, vaddr_page, paddr_page, xlat, prot, &address); @@ -668,6 +666,18 @@ void tlb_set_page_with_attrs(CPUState *cpu, target_ulong vaddr, index = (vaddr_page >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); te = &env->tlb_table[mmu_idx][index]; + /* + * Hold the TLB lock for the rest of the function. We could acquire/release + * the lock several times in the function, but it is faster to amortize the + * acquisition cost by acquiring it just once. Note that this leads to + * a longer critical section, but this is not a concern since the TLB lock + * is unlikely to be contended. + */ + qemu_spin_lock(&env->tlb_lock); + + /* Make sure there's no cached translation for the new page. */ + tlb_flush_vtlb_page_locked(env, mmu_idx, vaddr_page); + /* * Only evict the old entry to the victim tlb if it's for a * different page; otherwise just overwrite the stale data. @@ -677,7 +687,7 @@ void tlb_set_page_with_attrs(CPUState *cpu, target_ulong vaddr, CPUTLBEntry *tv = &env->tlb_v_table[mmu_idx][vidx]; /* Evict the old entry into the victim tlb. */ - copy_tlb_helper(tv, te, true); + copy_tlb_helper_locked(tv, te); env->iotlb_v[mmu_idx][vidx] = env->iotlb[mmu_idx][index]; } @@ -729,9 +739,8 @@ void tlb_set_page_with_attrs(CPUState *cpu, target_ulong vaddr, } } - /* Pairs with flag setting in tlb_reset_dirty_range */ - copy_tlb_helper(te, &tn, true); - /* atomic_mb_set(&te->addr_write, write_address); */ + copy_tlb_helper_locked(te, &tn); + qemu_spin_unlock(&env->tlb_lock); } /* Add a new TLB entry, but without specifying the memory @@ -895,6 +904,8 @@ static bool victim_tlb_hit(CPUArchState *env, size_t mmu_idx, size_t index, size_t elt_ofs, target_ulong page) { size_t vidx; + + assert_cpu_is_self(ENV_GET_CPU(env)); for (vidx = 0; vidx < CPU_VTLB_SIZE; ++vidx) { CPUTLBEntry *vtlb = &env->tlb_v_table[mmu_idx][vidx]; target_ulong cmp = *(target_ulong *)((uintptr_t)vtlb + elt_ofs); @@ -903,9 +914,11 @@ static bool victim_tlb_hit(CPUArchState *env, size_t mmu_idx, size_t index, /* Found entry in victim tlb, swap tlb and iotlb. */ CPUTLBEntry tmptlb, *tlb = &env->tlb_table[mmu_idx][index]; - copy_tlb_helper(&tmptlb, tlb, false); - copy_tlb_helper(tlb, vtlb, true); - copy_tlb_helper(vtlb, &tmptlb, true); + qemu_spin_lock(&env->tlb_lock); + copy_tlb_helper_locked(&tmptlb, tlb); + copy_tlb_helper_locked(tlb, vtlb); + copy_tlb_helper_locked(vtlb, &tmptlb); + qemu_spin_unlock(&env->tlb_lock); CPUIOTLBEntry tmpio, *io = &env->iotlb[mmu_idx][index]; CPUIOTLBEntry *vio = &env->iotlb_v[mmu_idx][vidx]; From patchwork Fri Oct 19 06:06:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 149236 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp2914645lji; Thu, 18 Oct 2018 23:22:01 -0700 (PDT) X-Google-Smtp-Source: ACcGV60MiURiTPPGhq8a7aO0Z7LgL0Yc6q3ImEqvH7GZVfafzU/PhilUVkfOlR2L3Tu/lFQmjIpB X-Received: by 2002:aed:20e7:: with SMTP id 94-v6mr31835728qtb.296.1539930121325; Thu, 18 Oct 2018 23:22:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539930121; cv=none; d=google.com; s=arc-20160816; b=z/KoD0kZEdjewv37fp7Td0a1gSfwahcJsK66+3g+5h5hXwEUSofqkNc8/GY+k2p/hA yQj0yU4aMxRySX8djrPLrldoxpGt39CjtStXt2Bm7x1UPgg0RWwl9UCnVwDZfqpMTdvb LdAUZDeePn2xOJOwMoBKHo4WCFXi4k6hrXUIXkF2GaNC4rEudQ+CA6qNgzAniBhm0fg6 bCMAFj8xjPCNEFMHJK/Zj+TlWZSSyco7rIVplukdXGSEHja3DKdn/84gHDfPxqKm6FDg EOCLwJFlVdVuxGjfJ/lH374UF9RFuXrgc6OjB0SiP8uvPwPuMDnOL94gHnTI60PpdsQd WflA== 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 :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=o0Gn4P0MUk+NIJcPA0w+sPPaPE/w/HgOCjbNmj2ovC0=; b=O6QuRSnWHek9yZOlQIc1nWSD5sqKHZ+KjhGSGNOyre2G/0JnoOtfU5rbHwKtD5tBR8 57qaj68hfiK/wjUbbTDp1tWq+39/De3wobdamAmdZOaq7aoXSDMAXZYGiYRNTRZuH+CO UJNVDknTOvdiZWp3BEAPr5nkGga/XgYI7getnRUvNg2e/CUwgvS4XdhAnkLQkmBCgm/I j1aqtj9jeEjpbukKxrDTf06jzqOEqfbXT3OX+/xBzuHJGHs+EDxdBEqQQpwxl0ldZmee NDCoCACM5nJO149BxCyN78CVtWkbpxwniiYz2ajlzD8w/8zRtbEB0HmSNhoXb7VbTwa8 6Xvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ULOyiSxa; 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 z14-v6si336908qti.157.2018.10.18.23.22.01 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 18 Oct 2018 23:22:01 -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=ULOyiSxa; 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]:47299 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDOAa-0000Fh-QH for patch@linaro.org; Fri, 19 Oct 2018 02:22:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39350) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDNwl-0004Up-Lk for qemu-devel@nongnu.org; Fri, 19 Oct 2018 02:07:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gDNwf-0002mR-PX for qemu-devel@nongnu.org; Fri, 19 Oct 2018 02:07:43 -0400 Received: from mail-pg1-x529.google.com ([2607:f8b0:4864:20::529]:34881) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gDNwf-0002AC-4K for qemu-devel@nongnu.org; Fri, 19 Oct 2018 02:07:37 -0400 Received: by mail-pg1-x529.google.com with SMTP id 32-v6so4127647pgu.2 for ; Thu, 18 Oct 2018 23:07: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 :mime-version:content-transfer-encoding; bh=o0Gn4P0MUk+NIJcPA0w+sPPaPE/w/HgOCjbNmj2ovC0=; b=ULOyiSxa03d70RfLPiufespEkb5U+7qQSGtIYeBb1NPwaLrfVHZHrcK7D8cWcrWsXW +QCEZ8Qz0qhKJXCfgcYOf8b8sIEqxwhbcSrTbw7eEqrEYOs0fGrISFXRqUMFNkitX7Gy RBMmQOkSF/FnV9uLCWy9qcL3yLawzrGSlViAA= 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:mime-version:content-transfer-encoding; bh=o0Gn4P0MUk+NIJcPA0w+sPPaPE/w/HgOCjbNmj2ovC0=; b=PWOpLv3cGHYJJ1delXzwdGC101yzRro3OQ4q6MKbN4wfIxaeR6Rgt7wOc8Kd0qNZnF uMcNMgxDT1IPzn1jsbXU7l8ZDp06MnCkZxlhak2fiUKm7GEno3h9Xhan6kSROzBYrmqP EKlGxIN2UG9wXYg4mzQLwZPlNIb6i7sJQgiTJd+csdfjw4EX9KSm/MvuJ44WtcvCH7U0 of0Q0nkELhKhvW3z3R6YyvnyeTw0h+Kcyz0nmg+4GHOHJYPJHYS3AZ0wGXUdWUpe3lqq fnwrNsVSseiGMc2VY4hJ8QinLqVUimC6iENRlf4FlrXoL63weD5pPnrpEHfD4znrAmbz erVw== X-Gm-Message-State: ABuFfohkcZVBbQAnqqRuaahpJsXyT46BNx6mOutuNzd0mqISh67Z6J9E /9KyFbc07P6CDXilKH9dnQS+q/zlXDU= X-Received: by 2002:a63:31cc:: with SMTP id x195-v6mr5432753pgx.226.1539929233895; Thu, 18 Oct 2018 23:07:13 -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.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Oct 2018 23:07:13 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 18 Oct 2018 23:06:46 -0700 Message-Id: <20181019060656.7968-12-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> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::529 Subject: [Qemu-devel] [PULL v2 11/21] tcg: Add tlb_index and tlb_entry helpers 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" Isolate the computation of an index from an address into a helper before we change that function. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson [ cota: convert tlb_vaddr_to_host; use atomic_read on addr_write ] Signed-off-by: Emilio G. Cota Message-Id: <20181009175129.17888-2-cota@braap.org> --- accel/tcg/softmmu_template.h | 64 +++++++++++++++++--------------- include/exec/cpu_ldst.h | 19 ++++++++-- include/exec/cpu_ldst_template.h | 25 +++++++------ accel/tcg/cputlb.c | 60 ++++++++++++++---------------- 4 files changed, 90 insertions(+), 78 deletions(-) -- 2.17.2 diff --git a/accel/tcg/softmmu_template.h b/accel/tcg/softmmu_template.h index f060a693d4..09538b5349 100644 --- a/accel/tcg/softmmu_template.h +++ b/accel/tcg/softmmu_template.h @@ -111,9 +111,10 @@ static inline DATA_TYPE glue(io_read, SUFFIX)(CPUArchState *env, WORD_TYPE helper_le_ld_name(CPUArchState *env, target_ulong addr, TCGMemOpIdx oi, uintptr_t retaddr) { - unsigned mmu_idx = get_mmuidx(oi); - int index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); - target_ulong tlb_addr = env->tlb_table[mmu_idx][index].ADDR_READ; + uintptr_t mmu_idx = get_mmuidx(oi); + uintptr_t index = tlb_index(env, mmu_idx, addr); + CPUTLBEntry *entry = tlb_entry(env, mmu_idx, addr); + target_ulong tlb_addr = entry->ADDR_READ; unsigned a_bits = get_alignment_bits(get_memop(oi)); uintptr_t haddr; DATA_TYPE res; @@ -129,7 +130,7 @@ WORD_TYPE helper_le_ld_name(CPUArchState *env, target_ulong addr, tlb_fill(ENV_GET_CPU(env), addr, DATA_SIZE, READ_ACCESS_TYPE, mmu_idx, retaddr); } - tlb_addr = env->tlb_table[mmu_idx][index].ADDR_READ; + tlb_addr = entry->ADDR_READ; } /* Handle an IO access. */ @@ -166,7 +167,7 @@ WORD_TYPE helper_le_ld_name(CPUArchState *env, target_ulong addr, return res; } - haddr = addr + env->tlb_table[mmu_idx][index].addend; + haddr = addr + entry->addend; #if DATA_SIZE == 1 res = glue(glue(ld, LSUFFIX), _p)((uint8_t *)haddr); #else @@ -179,9 +180,10 @@ WORD_TYPE helper_le_ld_name(CPUArchState *env, target_ulong addr, WORD_TYPE helper_be_ld_name(CPUArchState *env, target_ulong addr, TCGMemOpIdx oi, uintptr_t retaddr) { - unsigned mmu_idx = get_mmuidx(oi); - int index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); - target_ulong tlb_addr = env->tlb_table[mmu_idx][index].ADDR_READ; + uintptr_t mmu_idx = get_mmuidx(oi); + uintptr_t index = tlb_index(env, mmu_idx, addr); + CPUTLBEntry *entry = tlb_entry(env, mmu_idx, addr); + target_ulong tlb_addr = entry->ADDR_READ; unsigned a_bits = get_alignment_bits(get_memop(oi)); uintptr_t haddr; DATA_TYPE res; @@ -197,7 +199,7 @@ WORD_TYPE helper_be_ld_name(CPUArchState *env, target_ulong addr, tlb_fill(ENV_GET_CPU(env), addr, DATA_SIZE, READ_ACCESS_TYPE, mmu_idx, retaddr); } - tlb_addr = env->tlb_table[mmu_idx][index].ADDR_READ; + tlb_addr = entry->ADDR_READ; } /* Handle an IO access. */ @@ -234,7 +236,7 @@ WORD_TYPE helper_be_ld_name(CPUArchState *env, target_ulong addr, return res; } - haddr = addr + env->tlb_table[mmu_idx][index].addend; + haddr = addr + entry->addend; res = glue(glue(ld, LSUFFIX), _be_p)((uint8_t *)haddr); return res; } @@ -275,9 +277,10 @@ static inline void glue(io_write, SUFFIX)(CPUArchState *env, void helper_le_st_name(CPUArchState *env, target_ulong addr, DATA_TYPE val, TCGMemOpIdx oi, uintptr_t retaddr) { - unsigned mmu_idx = get_mmuidx(oi); - int index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); - target_ulong tlb_addr = env->tlb_table[mmu_idx][index].addr_write; + uintptr_t mmu_idx = get_mmuidx(oi); + uintptr_t index = tlb_index(env, mmu_idx, addr); + CPUTLBEntry *entry = tlb_entry(env, mmu_idx, addr); + target_ulong tlb_addr = entry->addr_write; unsigned a_bits = get_alignment_bits(get_memop(oi)); uintptr_t haddr; @@ -292,7 +295,7 @@ void helper_le_st_name(CPUArchState *env, target_ulong addr, DATA_TYPE val, tlb_fill(ENV_GET_CPU(env), addr, DATA_SIZE, MMU_DATA_STORE, mmu_idx, retaddr); } - tlb_addr = env->tlb_table[mmu_idx][index].addr_write & ~TLB_INVALID_MASK; + tlb_addr = entry->addr_write & ~TLB_INVALID_MASK; } /* Handle an IO access. */ @@ -313,16 +316,16 @@ void helper_le_st_name(CPUArchState *env, target_ulong addr, DATA_TYPE val, if (DATA_SIZE > 1 && unlikely((addr & ~TARGET_PAGE_MASK) + DATA_SIZE - 1 >= TARGET_PAGE_SIZE)) { - int i, index2; - target_ulong page2, tlb_addr2; + int i; + target_ulong page2; + CPUTLBEntry *entry2; do_unaligned_access: /* Ensure the second page is in the TLB. Note that the first page is already guaranteed to be filled, and that the second page cannot evict the first. */ page2 = (addr + DATA_SIZE) & TARGET_PAGE_MASK; - index2 = (page2 >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); - tlb_addr2 = env->tlb_table[mmu_idx][index2].addr_write; - if (!tlb_hit_page(tlb_addr2, page2) + entry2 = tlb_entry(env, mmu_idx, page2); + if (!tlb_hit_page(entry2->addr_write, page2) && !VICTIM_TLB_HIT(addr_write, page2)) { tlb_fill(ENV_GET_CPU(env), page2, DATA_SIZE, MMU_DATA_STORE, mmu_idx, retaddr); @@ -340,7 +343,7 @@ void helper_le_st_name(CPUArchState *env, target_ulong addr, DATA_TYPE val, return; } - haddr = addr + env->tlb_table[mmu_idx][index].addend; + haddr = addr + entry->addend; #if DATA_SIZE == 1 glue(glue(st, SUFFIX), _p)((uint8_t *)haddr, val); #else @@ -352,9 +355,10 @@ void helper_le_st_name(CPUArchState *env, target_ulong addr, DATA_TYPE val, void helper_be_st_name(CPUArchState *env, target_ulong addr, DATA_TYPE val, TCGMemOpIdx oi, uintptr_t retaddr) { - unsigned mmu_idx = get_mmuidx(oi); - int index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); - target_ulong tlb_addr = env->tlb_table[mmu_idx][index].addr_write; + uintptr_t mmu_idx = get_mmuidx(oi); + uintptr_t index = tlb_index(env, mmu_idx, addr); + CPUTLBEntry *entry = tlb_entry(env, mmu_idx, addr); + target_ulong tlb_addr = entry->addr_write; unsigned a_bits = get_alignment_bits(get_memop(oi)); uintptr_t haddr; @@ -369,7 +373,7 @@ void helper_be_st_name(CPUArchState *env, target_ulong addr, DATA_TYPE val, tlb_fill(ENV_GET_CPU(env), addr, DATA_SIZE, MMU_DATA_STORE, mmu_idx, retaddr); } - tlb_addr = env->tlb_table[mmu_idx][index].addr_write & ~TLB_INVALID_MASK; + tlb_addr = entry->addr_write & ~TLB_INVALID_MASK; } /* Handle an IO access. */ @@ -390,16 +394,16 @@ void helper_be_st_name(CPUArchState *env, target_ulong addr, DATA_TYPE val, if (DATA_SIZE > 1 && unlikely((addr & ~TARGET_PAGE_MASK) + DATA_SIZE - 1 >= TARGET_PAGE_SIZE)) { - int i, index2; - target_ulong page2, tlb_addr2; + int i; + target_ulong page2; + CPUTLBEntry *entry2; do_unaligned_access: /* Ensure the second page is in the TLB. Note that the first page is already guaranteed to be filled, and that the second page cannot evict the first. */ page2 = (addr + DATA_SIZE) & TARGET_PAGE_MASK; - index2 = (page2 >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); - tlb_addr2 = env->tlb_table[mmu_idx][index2].addr_write; - if (!tlb_hit_page(tlb_addr2, page2) + entry2 = tlb_entry(env, mmu_idx, page2); + if (!tlb_hit_page(entry2->addr_write, page2) && !VICTIM_TLB_HIT(addr_write, page2)) { tlb_fill(ENV_GET_CPU(env), page2, DATA_SIZE, MMU_DATA_STORE, mmu_idx, retaddr); @@ -417,7 +421,7 @@ void helper_be_st_name(CPUArchState *env, target_ulong addr, DATA_TYPE val, return; } - haddr = addr + env->tlb_table[mmu_idx][index].addend; + haddr = addr + entry->addend; glue(glue(st, SUFFIX), _be_p)((uint8_t *)haddr, val); } #endif /* DATA_SIZE > 1 */ diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h index 41ed0526e2..f54d91ff68 100644 --- a/include/exec/cpu_ldst.h +++ b/include/exec/cpu_ldst.h @@ -126,6 +126,20 @@ extern __thread uintptr_t helper_retaddr; /* The memory helpers for tcg-generated code need tcg_target_long etc. */ #include "tcg.h" +/* Find the TLB index corresponding to the mmu_idx + address pair. */ +static inline uintptr_t tlb_index(CPUArchState *env, uintptr_t mmu_idx, + target_ulong addr) +{ + return (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); +} + +/* Find the TLB entry corresponding to the mmu_idx + address pair. */ +static inline CPUTLBEntry *tlb_entry(CPUArchState *env, uintptr_t mmu_idx, + target_ulong addr) +{ + return &env->tlb_table[mmu_idx][tlb_index(env, mmu_idx, addr)]; +} + #ifdef MMU_MODE0_SUFFIX #define CPU_MMU_INDEX 0 #define MEMSUFFIX MMU_MODE0_SUFFIX @@ -416,8 +430,7 @@ static inline void *tlb_vaddr_to_host(CPUArchState *env, abi_ptr addr, #if defined(CONFIG_USER_ONLY) return g2h(addr); #else - int index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); - CPUTLBEntry *tlbentry = &env->tlb_table[mmu_idx][index]; + CPUTLBEntry *tlbentry = tlb_entry(env, mmu_idx, addr); abi_ptr tlb_addr; uintptr_t haddr; @@ -445,7 +458,7 @@ static inline void *tlb_vaddr_to_host(CPUArchState *env, abi_ptr addr, return NULL; } - haddr = addr + env->tlb_table[mmu_idx][index].addend; + haddr = addr + tlbentry->addend; return (void *)haddr; #endif /* defined(CONFIG_USER_ONLY) */ } diff --git a/include/exec/cpu_ldst_template.h b/include/exec/cpu_ldst_template.h index 4db2302962..d21a0b59bf 100644 --- a/include/exec/cpu_ldst_template.h +++ b/include/exec/cpu_ldst_template.h @@ -81,7 +81,7 @@ glue(glue(glue(cpu_ld, USUFFIX), MEMSUFFIX), _ra)(CPUArchState *env, target_ulong ptr, uintptr_t retaddr) { - int page_index; + CPUTLBEntry *entry; RES_TYPE res; target_ulong addr; int mmu_idx; @@ -94,15 +94,15 @@ glue(glue(glue(cpu_ld, USUFFIX), MEMSUFFIX), _ra)(CPUArchState *env, #endif addr = ptr; - page_index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); mmu_idx = CPU_MMU_INDEX; - if (unlikely(env->tlb_table[mmu_idx][page_index].ADDR_READ != + entry = tlb_entry(env, mmu_idx, addr); + if (unlikely(entry->ADDR_READ != (addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))))) { oi = make_memop_idx(SHIFT, mmu_idx); res = glue(glue(helper_ret_ld, URETSUFFIX), MMUSUFFIX)(env, addr, oi, retaddr); } else { - uintptr_t hostaddr = addr + env->tlb_table[mmu_idx][page_index].addend; + uintptr_t hostaddr = addr + entry->addend; res = glue(glue(ld, USUFFIX), _p)((uint8_t *)hostaddr); } return res; @@ -120,7 +120,8 @@ glue(glue(glue(cpu_lds, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env, target_ulong ptr, uintptr_t retaddr) { - int res, page_index; + CPUTLBEntry *entry; + int res; target_ulong addr; int mmu_idx; TCGMemOpIdx oi; @@ -132,15 +133,15 @@ glue(glue(glue(cpu_lds, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env, #endif addr = ptr; - page_index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); mmu_idx = CPU_MMU_INDEX; - if (unlikely(env->tlb_table[mmu_idx][page_index].ADDR_READ != + entry = tlb_entry(env, mmu_idx, addr); + if (unlikely(entry->ADDR_READ != (addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))))) { oi = make_memop_idx(SHIFT, mmu_idx); res = (DATA_STYPE)glue(glue(helper_ret_ld, SRETSUFFIX), MMUSUFFIX)(env, addr, oi, retaddr); } else { - uintptr_t hostaddr = addr + env->tlb_table[mmu_idx][page_index].addend; + uintptr_t hostaddr = addr + entry->addend; res = glue(glue(lds, SUFFIX), _p)((uint8_t *)hostaddr); } return res; @@ -162,7 +163,7 @@ glue(glue(glue(cpu_st, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env, target_ulong ptr, RES_TYPE v, uintptr_t retaddr) { - int page_index; + CPUTLBEntry *entry; target_ulong addr; int mmu_idx; TCGMemOpIdx oi; @@ -174,15 +175,15 @@ glue(glue(glue(cpu_st, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env, #endif addr = ptr; - page_index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); mmu_idx = CPU_MMU_INDEX; - if (unlikely(env->tlb_table[mmu_idx][page_index].addr_write != + entry = tlb_entry(env, mmu_idx, addr); + if (unlikely(entry->addr_write != (addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))))) { oi = make_memop_idx(SHIFT, mmu_idx); glue(glue(helper_ret_st, SUFFIX), MMUSUFFIX)(env, addr, v, oi, retaddr); } else { - uintptr_t hostaddr = addr + env->tlb_table[mmu_idx][page_index].addend; + uintptr_t hostaddr = addr + entry->addend; glue(glue(st, SUFFIX), _p)((uint8_t *)hostaddr, v); } } diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index c2a6190674..e4993d72fb 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -286,7 +286,6 @@ static void tlb_flush_page_async_work(CPUState *cpu, run_on_cpu_data data) { CPUArchState *env = cpu->env_ptr; target_ulong addr = (target_ulong) data.target_ptr; - int i; int mmu_idx; assert_cpu_is_self(cpu); @@ -304,10 +303,9 @@ static void tlb_flush_page_async_work(CPUState *cpu, run_on_cpu_data data) } addr &= TARGET_PAGE_MASK; - i = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); qemu_spin_lock(&env->tlb_lock); for (mmu_idx = 0; mmu_idx < NB_MMU_MODES; mmu_idx++) { - tlb_flush_entry_locked(&env->tlb_table[mmu_idx][i], addr); + tlb_flush_entry_locked(tlb_entry(env, mmu_idx, addr), addr); tlb_flush_vtlb_page_locked(env, mmu_idx, addr); } qemu_spin_unlock(&env->tlb_lock); @@ -339,18 +337,17 @@ static void tlb_flush_page_by_mmuidx_async_work(CPUState *cpu, target_ulong addr_and_mmuidx = (target_ulong) data.target_ptr; target_ulong addr = addr_and_mmuidx & TARGET_PAGE_MASK; unsigned long mmu_idx_bitmap = addr_and_mmuidx & ALL_MMUIDX_BITS; - int page = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); int mmu_idx; assert_cpu_is_self(cpu); - tlb_debug("page:%d addr:"TARGET_FMT_lx" mmu_idx:0x%lx\n", - page, addr, mmu_idx_bitmap); + tlb_debug("flush page addr:"TARGET_FMT_lx" mmu_idx:0x%lx\n", + addr, mmu_idx_bitmap); qemu_spin_lock(&env->tlb_lock); for (mmu_idx = 0; mmu_idx < NB_MMU_MODES; mmu_idx++) { if (test_bit(mmu_idx, &mmu_idx_bitmap)) { - tlb_flush_entry_locked(&env->tlb_table[mmu_idx][page], addr); + tlb_flush_entry_locked(tlb_entry(env, mmu_idx, addr), addr); tlb_flush_vtlb_page_locked(env, mmu_idx, addr); } } @@ -554,16 +551,14 @@ static inline void tlb_set_dirty1_locked(CPUTLBEntry *tlb_entry, void tlb_set_dirty(CPUState *cpu, target_ulong vaddr) { CPUArchState *env = cpu->env_ptr; - int i; int mmu_idx; assert_cpu_is_self(cpu); vaddr &= TARGET_PAGE_MASK; - i = (vaddr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); qemu_spin_lock(&env->tlb_lock); for (mmu_idx = 0; mmu_idx < NB_MMU_MODES; mmu_idx++) { - tlb_set_dirty1_locked(&env->tlb_table[mmu_idx][i], vaddr); + tlb_set_dirty1_locked(tlb_entry(env, mmu_idx, vaddr), vaddr); } for (mmu_idx = 0; mmu_idx < NB_MMU_MODES; mmu_idx++) { @@ -663,8 +658,8 @@ void tlb_set_page_with_attrs(CPUState *cpu, target_ulong vaddr, iotlb = memory_region_section_get_iotlb(cpu, section, vaddr_page, paddr_page, xlat, prot, &address); - index = (vaddr_page >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); - te = &env->tlb_table[mmu_idx][index]; + index = tlb_index(env, mmu_idx, vaddr_page); + te = tlb_entry(env, mmu_idx, vaddr_page); /* * Hold the TLB lock for the rest of the function. We could acquire/release @@ -786,16 +781,16 @@ static uint64_t io_readx(CPUArchState *env, CPUIOTLBEntry *iotlbentry, * repeat the MMU check here. This tlb_fill() call might * longjump out if this access should cause a guest exception. */ - int index; + CPUTLBEntry *entry; target_ulong tlb_addr; tlb_fill(cpu, addr, size, MMU_DATA_LOAD, mmu_idx, retaddr); - index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); - tlb_addr = env->tlb_table[mmu_idx][index].addr_read; + entry = tlb_entry(env, mmu_idx, addr); + tlb_addr = entry->addr_read; if (!(tlb_addr & ~(TARGET_PAGE_MASK | TLB_RECHECK))) { /* RAM access */ - uintptr_t haddr = addr + env->tlb_table[mmu_idx][index].addend; + uintptr_t haddr = addr + entry->addend; return ldn_p((void *)haddr, size); } @@ -853,16 +848,16 @@ static void io_writex(CPUArchState *env, CPUIOTLBEntry *iotlbentry, * repeat the MMU check here. This tlb_fill() call might * longjump out if this access should cause a guest exception. */ - int index; + CPUTLBEntry *entry; target_ulong tlb_addr; tlb_fill(cpu, addr, size, MMU_DATA_STORE, mmu_idx, retaddr); - index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); - tlb_addr = env->tlb_table[mmu_idx][index].addr_write; + entry = tlb_entry(env, mmu_idx, addr); + tlb_addr = entry->addr_write; if (!(tlb_addr & ~(TARGET_PAGE_MASK | TLB_RECHECK))) { /* RAM access */ - uintptr_t haddr = addr + env->tlb_table[mmu_idx][index].addend; + uintptr_t haddr = addr + entry->addend; stn_p((void *)haddr, size, val); return; @@ -941,20 +936,19 @@ static bool victim_tlb_hit(CPUArchState *env, size_t mmu_idx, size_t index, */ tb_page_addr_t get_page_addr_code(CPUArchState *env, target_ulong addr) { - int mmu_idx, index; + uintptr_t mmu_idx = cpu_mmu_index(env, true); + uintptr_t index = tlb_index(env, mmu_idx, addr); + CPUTLBEntry *entry = tlb_entry(env, mmu_idx, addr); void *p; - index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); - mmu_idx = cpu_mmu_index(env, true); - if (unlikely(!tlb_hit(env->tlb_table[mmu_idx][index].addr_code, addr))) { + if (unlikely(!tlb_hit(entry->addr_code, addr))) { if (!VICTIM_TLB_HIT(addr_code, addr)) { tlb_fill(ENV_GET_CPU(env), addr, 0, MMU_INST_FETCH, mmu_idx, 0); } - assert(tlb_hit(env->tlb_table[mmu_idx][index].addr_code, addr)); + assert(tlb_hit(entry->addr_code, addr)); } - if (unlikely(env->tlb_table[mmu_idx][index].addr_code & - (TLB_RECHECK | TLB_MMIO))) { + if (unlikely(entry->addr_code & (TLB_RECHECK | TLB_MMIO))) { /* * Return -1 if we can't translate and execute from an entire * page of RAM here, which will cause us to execute by loading @@ -966,7 +960,7 @@ tb_page_addr_t get_page_addr_code(CPUArchState *env, target_ulong addr) return -1; } - p = (void *)((uintptr_t)addr + env->tlb_table[mmu_idx][index].addend); + p = (void *)((uintptr_t)addr + entry->addend); return qemu_ram_addr_from_host_nofail(p); } @@ -979,10 +973,10 @@ tb_page_addr_t get_page_addr_code(CPUArchState *env, target_ulong addr) void probe_write(CPUArchState *env, target_ulong addr, int size, int mmu_idx, uintptr_t retaddr) { - int index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); - target_ulong tlb_addr = env->tlb_table[mmu_idx][index].addr_write; + uintptr_t index = tlb_index(env, mmu_idx, addr); + CPUTLBEntry *entry = tlb_entry(env, mmu_idx, addr); - if (!tlb_hit(tlb_addr, addr)) { + if (!tlb_hit(entry->addr_write, addr)) { /* TLB entry is for a different page */ if (!VICTIM_TLB_HIT(addr_write, addr)) { tlb_fill(ENV_GET_CPU(env), addr, size, MMU_DATA_STORE, @@ -998,8 +992,8 @@ static void *atomic_mmu_lookup(CPUArchState *env, target_ulong addr, NotDirtyInfo *ndi) { size_t mmu_idx = get_mmuidx(oi); - size_t index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); - CPUTLBEntry *tlbe = &env->tlb_table[mmu_idx][index]; + uintptr_t index = tlb_index(env, mmu_idx, addr); + CPUTLBEntry *tlbe = tlb_entry(env, mmu_idx, addr); target_ulong tlb_addr = tlbe->addr_write; TCGMemOp mop = get_memop(oi); int a_bits = get_alignment_bits(mop); From patchwork Fri Oct 19 06:06:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 149230 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp2911282lji; Thu, 18 Oct 2018 23:17:41 -0700 (PDT) X-Google-Smtp-Source: ACcGV61RkuQRmKevu1tuFVTs3THBeAciDRhdgybpfUMIb7eQSdNS5NOQj3uCrzFWaLv9nsyA7wYH X-Received: by 2002:a0c:8757:: with SMTP id 23mr33091825qvi.223.1539929861874; Thu, 18 Oct 2018 23:17:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539929861; cv=none; d=google.com; s=arc-20160816; b=vORERHpUE4b73VCjghIRgNCp0+Z347Zzz3MxqbQOmL17CaSdccHPA+1UYJff3UxIGy Bt559FBj6qhf4aZUm9N62ENcX6cFkf0vVyr6E7kC0gVsv3KyRg2hgDzOUcuNcBY4UXDi x8RtA0HCuj/yE5lW4RwN5jatD0hQEhhOhmjj+zlXj3kLL4gtWPqVL7VwkYt3APXkoMO9 +IxzF91ppUlGTJG3PfISzXNibGez71CHYlrK4SypBy/8GEs6dVqWrhymgujOiC76hAre Ch7gXoNBo+SAXCQ4PiMcHoqUZAgv1qV5wldxFWN+xit+0J7K0IEMvfx6FStXLVPyeWIM VsfQ== 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=C9pdHJk1oS/hehjI3GGCQgqs2vnMiQM0+5IHSdZutzM=; b=a1DPtNfHbd8usizTl4GKJFfX4A6ZvafGUOUAi6YVNMmKZHgCTdB1QWuCCRLc5uQn/g Bn2gBru5ErYf32eXUFNi9MHi5eDSQqOXJ6F1J63+FUldw4TnTuDjUvINlDSB3pVbmUgO nG4KIG/eSb+tVv4G1Ed8VlLXasjFysZjgsvuQNllHl8Y4VWPI7Yb4D56frtdELMyLokA 12fHMMSZjFzD9J5NG7FlZKJirJs9gxyABqG9xRBfSR6KApN9s3qQlSHm+fcU4bnK4Ynn wqjpBVyzMjJTxf2V27If3kQ/9rCZK/GQcYohlQeUoxKnrn+zGKbqsxaOFcSvJHy3OqHF mfPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=BbNAlU54; 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 o60-v6si5429645qtd.267.2018.10.18.23.17.41 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 18 Oct 2018 23:17:41 -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=BbNAlU54; 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]:47271 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDO6P-0004lm-9y for patch@linaro.org; Fri, 19 Oct 2018 02:17:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39355) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDNwl-0004Uz-PZ for qemu-devel@nongnu.org; Fri, 19 Oct 2018 02:07:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gDNwg-0002nY-73 for qemu-devel@nongnu.org; Fri, 19 Oct 2018 02:07:43 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]:41601) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gDNwf-0002As-Hn for qemu-devel@nongnu.org; Fri, 19 Oct 2018 02:07:37 -0400 Received: by mail-pl1-x636.google.com with SMTP id p5-v6so484395plq.8 for ; Thu, 18 Oct 2018 23:07:16 -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=C9pdHJk1oS/hehjI3GGCQgqs2vnMiQM0+5IHSdZutzM=; b=BbNAlU54CS0Nw2EWBgmQUZ8tww8Tb3NfLRcn+OSebze87LkxvRVq6C5OG5UuJBD2NE 69UbpeY2J0xq+SumXhcTqcnWWBszgTj72WdF5z6cp39CRiDuBsLbccv9cZomuqZ0OH5o wz3illwpBtWCrzK7TahHvHBuQr7AwZRuiUbPY= 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=C9pdHJk1oS/hehjI3GGCQgqs2vnMiQM0+5IHSdZutzM=; b=NflquBCqt/IuJYQQ6dvrUtV5oImrhzffoRckmF7gdMCJqW78Sr1HcZ5ixJYddoTMO5 n5wV+Cb+htikxuu5UBUDLgeXJXBwhyk2FcQEPiKajHQrTeADtMNSOtMp6ILa3TN2Qf+p 5GnP0VKmdadCVqPlT9HlhsY9QauAbOfNOQc2rYY+bwQyXmCjQnVEJI5jQLnRxL+onUlg e6tnMT6VhYyhr3btJH6WGffXtJh02rt+b+UViM836VbhDjJSPJvEnxspu2TtV5pkV7HC gOcIM5ViLgu8U3T0sdhpj1+do6FnFrKrSPiogmFIfdYfyOjTZNGctf55h1XHag1UIf0l i9qQ== X-Gm-Message-State: ABuFfogP1Bm/n9H20scMWUnPOg3A62eawpOyG9Ag6Bq47pHBvO9nO5Vx UExFNvvX7LHE7mEb+qxD69AdGqhp354= X-Received: by 2002:a17:902:8342:: with SMTP id z2-v6mr32427790pln.147.1539929235162; Thu, 18 Oct 2018 23:07:15 -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.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Oct 2018 23:07:14 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 18 Oct 2018 23:06:47 -0700 Message-Id: <20181019060656.7968-13-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::636 Subject: [Qemu-devel] [PULL v2 12/21] tcg: Split CONFIG_ATOMIC128 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 Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" GCC7+ will no longer advertise support for 16-byte __atomic operations if only cmpxchg is supported, as for x86_64. Fortunately, x86_64 still has support for __sync_compare_and_swap_16 and we can make use of that. AArch64 does not have, nor ever has had such support, so open-code it. Reviewed-by: Emilio G. Cota Signed-off-by: Richard Henderson --- accel/tcg/atomic_template.h | 20 ++++- include/qemu/atomic128.h | 153 ++++++++++++++++++++++++++++++++++++ include/qemu/compiler.h | 11 +++ tcg/tcg.h | 16 ++-- accel/tcg/cputlb.c | 3 +- accel/tcg/user-exec.c | 5 +- configure | 19 +++++ 7 files changed, 213 insertions(+), 14 deletions(-) create mode 100644 include/qemu/atomic128.h -- 2.17.2 diff --git a/accel/tcg/atomic_template.h b/accel/tcg/atomic_template.h index d751bcba48..efde12fdb2 100644 --- a/accel/tcg/atomic_template.h +++ b/accel/tcg/atomic_template.h @@ -100,19 +100,24 @@ ABI_TYPE ATOMIC_NAME(cmpxchg)(CPUArchState *env, target_ulong addr, DATA_TYPE ret; ATOMIC_TRACE_RMW; +#if DATA_SIZE == 16 + ret = atomic16_cmpxchg(haddr, cmpv, newv); +#else ret = atomic_cmpxchg__nocheck(haddr, cmpv, newv); +#endif ATOMIC_MMU_CLEANUP; return ret; } #if DATA_SIZE >= 16 +#if HAVE_ATOMIC128 ABI_TYPE ATOMIC_NAME(ld)(CPUArchState *env, target_ulong addr EXTRA_ARGS) { ATOMIC_MMU_DECLS; DATA_TYPE val, *haddr = ATOMIC_MMU_LOOKUP; ATOMIC_TRACE_LD; - __atomic_load(haddr, &val, __ATOMIC_RELAXED); + val = atomic16_read(haddr); ATOMIC_MMU_CLEANUP; return val; } @@ -124,9 +129,10 @@ void ATOMIC_NAME(st)(CPUArchState *env, target_ulong addr, DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP; ATOMIC_TRACE_ST; - __atomic_store(haddr, &val, __ATOMIC_RELAXED); + atomic16_set(haddr, val); ATOMIC_MMU_CLEANUP; } +#endif #else ABI_TYPE ATOMIC_NAME(xchg)(CPUArchState *env, target_ulong addr, ABI_TYPE val EXTRA_ARGS) @@ -228,19 +234,24 @@ ABI_TYPE ATOMIC_NAME(cmpxchg)(CPUArchState *env, target_ulong addr, DATA_TYPE ret; ATOMIC_TRACE_RMW; +#if DATA_SIZE == 16 + ret = atomic16_cmpxchg(haddr, BSWAP(cmpv), BSWAP(newv)); +#else ret = atomic_cmpxchg__nocheck(haddr, BSWAP(cmpv), BSWAP(newv)); +#endif ATOMIC_MMU_CLEANUP; return BSWAP(ret); } #if DATA_SIZE >= 16 +#if HAVE_ATOMIC128 ABI_TYPE ATOMIC_NAME(ld)(CPUArchState *env, target_ulong addr EXTRA_ARGS) { ATOMIC_MMU_DECLS; DATA_TYPE val, *haddr = ATOMIC_MMU_LOOKUP; ATOMIC_TRACE_LD; - __atomic_load(haddr, &val, __ATOMIC_RELAXED); + val = atomic16_read(haddr); ATOMIC_MMU_CLEANUP; return BSWAP(val); } @@ -253,9 +264,10 @@ void ATOMIC_NAME(st)(CPUArchState *env, target_ulong addr, ATOMIC_TRACE_ST; val = BSWAP(val); - __atomic_store(haddr, &val, __ATOMIC_RELAXED); + atomic16_set(haddr, val); ATOMIC_MMU_CLEANUP; } +#endif #else ABI_TYPE ATOMIC_NAME(xchg)(CPUArchState *env, target_ulong addr, ABI_TYPE val EXTRA_ARGS) diff --git a/include/qemu/atomic128.h b/include/qemu/atomic128.h new file mode 100644 index 0000000000..a6af22ff10 --- /dev/null +++ b/include/qemu/atomic128.h @@ -0,0 +1,153 @@ +/* + * Simple interface for 128-bit atomic operations. + * + * Copyright (C) 2018 Linaro, Ltd. + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + * + * See docs/devel/atomics.txt for discussion about the guarantees each + * atomic primitive is meant to provide. + */ + +#ifndef QEMU_ATOMIC128_H +#define QEMU_ATOMIC128_H + +/* + * GCC is a house divided about supporting large atomic operations. + * + * For hosts that only have large compare-and-swap, a legalistic reading + * of the C++ standard means that one cannot implement __atomic_read on + * read-only memory, and thus all atomic operations must synchronize + * through libatomic. + * + * See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80878 + * + * This interpretation is not especially helpful for QEMU. + * For softmmu, all RAM is always read/write from the hypervisor. + * For user-only, if the guest doesn't implement such an __atomic_read + * then the host need not worry about it either. + * + * Moreover, using libatomic is not an option, because its interface is + * built for std::atomic, and requires that *all* accesses to such an + * object go through the library. In our case we do not have an object + * in the C/C++ sense, but a view of memory as seen by the guest. + * The guest may issue a large atomic operation and then access those + * pieces using word-sized accesses. From the hypervisor, we have no + * way to connect those two actions. + * + * Therefore, special case each platform. + */ + +#if defined(CONFIG_ATOMIC128) +static inline Int128 atomic16_cmpxchg(Int128 *ptr, Int128 cmp, Int128 new) +{ + return atomic_cmpxchg__nocheck(ptr, cmp, new); +} +# define HAVE_CMPXCHG128 1 +#elif defined(CONFIG_CMPXCHG128) +static inline Int128 atomic16_cmpxchg(Int128 *ptr, Int128 cmp, Int128 new) +{ + return __sync_val_compare_and_swap_16(ptr, cmp, new); +} +# define HAVE_CMPXCHG128 1 +#elif defined(__aarch64__) +/* Through gcc 8, aarch64 has no support for 128-bit at all. */ +static inline Int128 atomic16_cmpxchg(Int128 *ptr, Int128 cmp, Int128 new) +{ + uint64_t cmpl = int128_getlo(cmp), cmph = int128_gethi(cmp); + uint64_t newl = int128_getlo(new), newh = int128_gethi(new); + uint64_t oldl, oldh; + uint32_t tmp; + + asm("0: ldaxp %[oldl], %[oldh], %[mem]\n\t" + "cmp %[oldl], %[cmpl]\n\t" + "ccmp %[oldh], %[cmph], #0, eq\n\t" + "b.ne 1f\n\t" + "stlxp %w[tmp], %[newl], %[newh], %[mem]\n\t" + "cbnz %w[tmp], 0b\n" + "1:" + : [mem] "+m"(*ptr), [tmp] "=&r"(tmp), + [oldl] "=&r"(oldl), [oldh] "=r"(oldh) + : [cmpl] "r"(cmpl), [cmph] "r"(cmph), + [newl] "r"(newl), [newh] "r"(newh) + : "memory", "cc"); + + return int128_make128(oldl, oldh); +} +# define HAVE_CMPXCHG128 1 +#else +/* Fallback definition that must be optimized away, or error. */ +Int128 QEMU_ERROR("unsupported atomic") + atomic16_cmpxchg(Int128 *ptr, Int128 cmp, Int128 new); +# define HAVE_CMPXCHG128 0 +#endif /* Some definition for HAVE_CMPXCHG128 */ + + +#if defined(CONFIG_ATOMIC128) +static inline Int128 atomic16_read(Int128 *ptr) +{ + return atomic_read__nocheck(ptr); +} + +static inline void atomic16_set(Int128 *ptr, Int128 val) +{ + atomic_set__nocheck(ptr, val); +} + +# define HAVE_ATOMIC128 1 +#elif !defined(CONFIG_USER_ONLY) && defined(__aarch64__) +/* We can do better than cmpxchg for AArch64. */ +static inline Int128 atomic16_read(Int128 *ptr) +{ + uint64_t l, h; + uint32_t tmp; + + /* The load must be paired with the store to guarantee not tearing. */ + asm("0: ldxp %[l], %[h], %[mem]\n\t" + "stxp %w[tmp], %[l], %[h], %[mem]\n\t" + "cbnz %w[tmp], 0b" + : [mem] "+m"(*ptr), [tmp] "=r"(tmp), [l] "=r"(l), [h] "=r"(h)); + + return int128_make128(l, h); +} + +static inline void atomic16_set(Int128 *ptr, Int128 val) +{ + uint64_t l = int128_getlo(val), h = int128_gethi(val); + uint64_t t1, t2; + + /* Load into temporaries to acquire the exclusive access lock. */ + asm("0: ldxp %[t1], %[t2], %[mem]\n\t" + "stxp %w[t1], %[l], %[h], %[mem]\n\t" + "cbnz %w[t1], 0b" + : [mem] "+m"(*ptr), [t1] "=&r"(t1), [t2] "=&r"(t2) + : [l] "r"(l), [h] "r"(h)); +} + +# define HAVE_ATOMIC128 1 +#elif !defined(CONFIG_USER_ONLY) && HAVE_CMPXCHG128 +static inline Int128 atomic16_read(Int128 *ptr) +{ + /* Maybe replace 0 with 0, returning the old value. */ + return atomic16_cmpxchg(ptr, 0, 0); +} + +static inline void atomic16_set(Int128 *ptr, Int128 val) +{ + Int128 old = *ptr, cmp; + do { + cmp = old; + old = atomic16_cmpxchg(ptr, cmp, val); + } while (old != cmp); +} + +# define HAVE_ATOMIC128 1 +#else +/* Fallback definitions that must be optimized away, or error. */ +Int128 QEMU_ERROR("unsupported atomic") atomic16_read(Int128 *ptr); +void QEMU_ERROR("unsupported atomic") atomic16_set(Int128 *ptr, Int128 val); +# define HAVE_ATOMIC128 0 +#endif /* Some definition for HAVE_ATOMIC128 */ + +#endif /* QEMU_ATOMIC128_H */ diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h index 66f8c241dc..6b92710487 100644 --- a/include/qemu/compiler.h +++ b/include/qemu/compiler.h @@ -146,6 +146,17 @@ # define QEMU_FLATTEN #endif +/* + * If __attribute__((error)) is present, use it to produce an error at + * compile time. Otherwise, one must wait for the linker to diagnose + * the missing symbol. + */ +#if __has_attribute(error) +# define QEMU_ERROR(X) __attribute__((error(X))) +#else +# define QEMU_ERROR(X) +#endif + /* Implement C11 _Generic via GCC builtins. Example: * * QEMU_GENERIC(x, (float, sinf), (long double, sinl), sin) (x) diff --git a/tcg/tcg.h b/tcg/tcg.h index c59f254e27..f4efbaa680 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -32,6 +32,7 @@ #include "qemu/queue.h" #include "tcg-mo.h" #include "tcg-target.h" +#include "qemu/int128.h" /* XXX: make safe guess about sizes */ #define MAX_OP_PER_INSTR 266 @@ -1456,11 +1457,14 @@ GEN_ATOMIC_HELPER_ALL(xchg) #undef GEN_ATOMIC_HELPER #endif /* CONFIG_SOFTMMU */ -#ifdef CONFIG_ATOMIC128 -#include "qemu/int128.h" - -/* These aren't really a "proper" helpers because TCG cannot manage Int128. - However, use the same format as the others, for use by the backends. */ +/* + * These aren't really a "proper" helpers because TCG cannot manage Int128. + * However, use the same format as the others, for use by the backends. + * + * The cmpxchg functions are only defined if HAVE_CMPXCHG128; + * the ld/st functions are only defined if HAVE_ATOMIC128, + * as defined by . + */ Int128 helper_atomic_cmpxchgo_le_mmu(CPUArchState *env, target_ulong addr, Int128 cmpv, Int128 newv, TCGMemOpIdx oi, uintptr_t retaddr); @@ -1477,6 +1481,4 @@ void helper_atomic_sto_le_mmu(CPUArchState *env, target_ulong addr, Int128 val, void helper_atomic_sto_be_mmu(CPUArchState *env, target_ulong addr, Int128 val, TCGMemOpIdx oi, uintptr_t retaddr); -#endif /* CONFIG_ATOMIC128 */ - #endif /* TCG_H */ diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index e4993d72fb..28b770a404 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -32,6 +32,7 @@ #include "exec/log.h" #include "exec/helper-proto.h" #include "qemu/atomic.h" +#include "qemu/atomic128.h" /* DEBUG defines, enable DEBUG_TLB_LOG to log to the CPU_LOG_MMU target */ /* #define DEBUG_TLB */ @@ -1112,7 +1113,7 @@ static void *atomic_mmu_lookup(CPUArchState *env, target_ulong addr, #include "atomic_template.h" #endif -#ifdef CONFIG_ATOMIC128 +#if HAVE_CMPXCHG128 || HAVE_ATOMIC128 #define DATA_SIZE 16 #include "atomic_template.h" #endif diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index 26a3ffbba1..cd75829cf2 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -25,6 +25,7 @@ #include "exec/cpu_ldst.h" #include "translate-all.h" #include "exec/helper-proto.h" +#include "qemu/atomic128.h" #undef EAX #undef ECX @@ -615,7 +616,7 @@ static void *atomic_mmu_lookup(CPUArchState *env, target_ulong addr, /* The following is only callable from other helpers, and matches up with the softmmu version. */ -#ifdef CONFIG_ATOMIC128 +#if HAVE_ATOMIC128 || HAVE_CMPXCHG128 #undef EXTRA_ARGS #undef ATOMIC_NAME @@ -628,4 +629,4 @@ static void *atomic_mmu_lookup(CPUArchState *env, target_ulong addr, #define DATA_SIZE 16 #include "atomic_template.h" -#endif /* CONFIG_ATOMIC128 */ +#endif diff --git a/configure b/configure index 9138af37f8..1d267b49cc 100755 --- a/configure +++ b/configure @@ -5154,6 +5154,21 @@ EOF fi fi +cmpxchg128=no +if test "$int128" = yes -a "$atomic128" = no; then + cat > $TMPC << EOF +int main(void) +{ + unsigned __int128 x = 0, y = 0; + __sync_val_compare_and_swap_16(&x, y, x); + return 0; +} +EOF + if compile_prog "" "" ; then + cmpxchg128=yes + fi +fi + ######################################### # See if 64-bit atomic operations are supported. # Note that without __atomic builtins, we can only @@ -6663,6 +6678,10 @@ if test "$atomic128" = "yes" ; then echo "CONFIG_ATOMIC128=y" >> $config_host_mak fi +if test "$cmpxchg128" = "yes" ; then + echo "CONFIG_CMPXCHG128=y" >> $config_host_mak +fi + if test "$atomic64" = "yes" ; then echo "CONFIG_ATOMIC64=y" >> $config_host_mak fi From patchwork Fri Oct 19 06:06:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 149233 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp2912198lji; Thu, 18 Oct 2018 23:18:53 -0700 (PDT) X-Google-Smtp-Source: ACcGV62ZukR4Zae7mTTBjDZryMYmSoeHPl3b2BADc+8JZtaJKlFnr/k/yJv7AHfLLjqg55X390dv X-Received: by 2002:ae9:eb05:: with SMTP id b5-v6mr31423406qkg.127.1539929932789; Thu, 18 Oct 2018 23:18:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539929932; cv=none; d=google.com; s=arc-20160816; b=V4eJFaeL7hs5XMFi71N01/ghRhenpOUkz3FF1+BTOKnhP1Sqvh2EQrD6QhJYc6zFkz Tci4n7kwImPtExr2OOuX2Dzp1OdvtY+/ODPtEI0iP9FpHkdE/FnTKo6zYNXilROd95ul wO7/pR++PnP+z1s8XJ4jzLRiMUY8VH9qI6tFHUhfhfGWQNAQOKUg/rCS+0TNudQKd3IB vclPcXcA5jHBQxbUrxCUCeBiJxQpnM0Ui5F7mLxfvkU6dVsMzfWI9s/do0Sc/hA2d8Dj wzyVz51AVedCheZBaKF/tIfAWZFwXQWvS5Krz8EnMhyC81/uxcYoeZCl7IegtqUjvyWq snzg== 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 :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=DB1b/fVktprVB9+vgwXapy40A76LQaCwLNLh795KUCE=; b=W1/3nPU/2HsPSHnNCTB0PLsW0xqhsjxCq29tmm237JKzjYekUE0bAAIBRxngzacqmZ glSs5g22ZAyN9QPiPqN049tbMNKVwuBnM03vKSiL6lpe/XAvU67HGpfuhNYvHMJ4eBAr jVp7aZJcxv/RXzpbL1qPScOZh4Ey6mZEOjBSFEDahPc5gH38r0zqxRRSTY32UAd8U+bE Nj1itOFXJXgOnntnhznzSrlbLmheGsDRlOUEgC24O/s0/+DWbDR/Yf4gw4eIu85jLxzU EX90aO02JaXuCbLGu1ruoAWy5fFPnALo6ldXvRirIJJO09hpFROenN8qxqWZMakAP26c j1NQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=OfgkD7u7; 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 b1-v6si3688640qke.230.2018.10.18.23.18.52 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 18 Oct 2018 23:18:52 -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=OfgkD7u7; 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]:47275 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDO7Y-0006BM-8b for patch@linaro.org; Fri, 19 Oct 2018 02:18:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39205) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDNwh-0004S5-CH for qemu-devel@nongnu.org; Fri, 19 Oct 2018 02:07:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gDNwf-0002mW-QO for qemu-devel@nongnu.org; Fri, 19 Oct 2018 02:07:39 -0400 Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]:43674) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gDNwf-0002Bk-8F for qemu-devel@nongnu.org; Fri, 19 Oct 2018 02:07:37 -0400 Received: by mail-pg1-x532.google.com with SMTP id d8-v6so4085700pgv.10 for ; Thu, 18 Oct 2018 23:07:17 -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 :mime-version:content-transfer-encoding; bh=DB1b/fVktprVB9+vgwXapy40A76LQaCwLNLh795KUCE=; b=OfgkD7u7gg5rsmQEdFKdvOWhuaXQ6kCZPVdYEkth/JaSCUtV9UQHH48eXl9yXnIPTz qiGoHYfuFrKKC6MlHOkiFJzxoFjweKp86LfhJ8i0fOKlsOCqAgd4aM3zzRgAU8F5sfTY iATv++L6re3bAnB4/S+3AeWmKZGVxYbtcUqJc= 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:mime-version:content-transfer-encoding; bh=DB1b/fVktprVB9+vgwXapy40A76LQaCwLNLh795KUCE=; b=Gz0WptPgBvRHLt+FlnEd3yiTdcWaN9LFB6sYYTUbTDl+92D7bWmIsAXeGPrL/GVLof oKgL7jxNk3rFssHb8ZZU+yd/7wPy2W1VpUo9m3hvynS5KYCiiJh3k4b+ahlDo4hvNObg dhtS3IcuuLok0Pn+mCYqbbHGOfb/HS/8K9BxX8aoeKDCHSzdzgMpoJqCp/qpElYVGzmS gvcGQN6xvs7nv8NpAWqGnRIA5tfaEMiGP3K/2JKyYB9XyDXzrURB9G9Xw8uQNhfsSG3x FgNauATXWhMgDYRWBdjcsjhAzd7jduznxnyOGXbCCMtY9O3mvgcftApMuzhpJBTXHBCw RdHg== X-Gm-Message-State: ABuFfogp4p84X17m5x8/kHSuQDP3BY4nlSE/NG9jSRt3vyBy/wv4hxll XCVtcrM7oLPPof58cYmSgItyiZiVY4Q= X-Received: by 2002:a63:6ec4:: with SMTP id j187-v6mr31673988pgc.3.1539929236302; Thu, 18 Oct 2018 23:07: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 q24-v6sm25609327pff.83.2018.10.18.23.07.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Oct 2018 23:07:15 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 18 Oct 2018 23:06:48 -0700 Message-Id: <20181019060656.7968-14-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> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::532 Subject: [Qemu-devel] [PULL v2 13/21] target/i386: Convert to HAVE_CMPXCHG128 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 Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Reviewed-by: Emilio G. Cota Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- target/i386/mem_helper.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) -- 2.17.2 diff --git a/target/i386/mem_helper.c b/target/i386/mem_helper.c index 30c26b9d9c..6cc53bcb40 100644 --- a/target/i386/mem_helper.c +++ b/target/i386/mem_helper.c @@ -23,6 +23,7 @@ #include "exec/exec-all.h" #include "exec/cpu_ldst.h" #include "qemu/int128.h" +#include "qemu/atomic128.h" #include "tcg.h" void helper_cmpxchg8b_unlocked(CPUX86State *env, target_ulong a0) @@ -137,10 +138,7 @@ void helper_cmpxchg16b(CPUX86State *env, target_ulong a0) if ((a0 & 0xf) != 0) { raise_exception_ra(env, EXCP0D_GPF, ra); - } else { -#ifndef CONFIG_ATOMIC128 - cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); -#else + } else if (HAVE_CMPXCHG128) { int eflags = cpu_cc_compute_all(env, CC_OP); Int128 cmpv = int128_make128(env->regs[R_EAX], env->regs[R_EDX]); @@ -159,7 +157,8 @@ void helper_cmpxchg16b(CPUX86State *env, target_ulong a0) eflags &= ~CC_Z; } CC_SRC = eflags; -#endif + } else { + cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); } } #endif From patchwork Fri Oct 19 06:06:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 149237 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp2916430lji; Thu, 18 Oct 2018 23:24:25 -0700 (PDT) X-Google-Smtp-Source: ACcGV62Nua7HN4GTHbAlY3RoxL4CkdBUhD3fMvPIHANsFjFWcMWLZY3YIulRsTnlzkZ2ZyF9JBBM X-Received: by 2002:a0c:8950:: with SMTP id 16mr27821077qvq.56.1539930265036; Thu, 18 Oct 2018 23:24:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539930265; cv=none; d=google.com; s=arc-20160816; b=sqb/nSM7eNLGMPxsYxsHG9sPAYmka2B69ggSc88zeQqen9DHMMKl0uIwb74sb13JJr wTsYLAkY0VEuMR/ljQa6Ym8BgL8uc/r7+elkkFsqsZX9lb+DrBdfvl4S+fd9k6qq1BJU 9REq1g7BJma+Jqr/m61Vx9QPINef/l/sV7q9Zl7/OiZ5iTB1uaCXIsRVhGm+XC2gwJ2F OhLSFsCO8fUacRjd3fEfXyKucrACBgP9UJaLib7PPod43gxIzjxkKjn7RHj1t5LNagN4 RDxSScbmRKhh0qLV9pPQVQxhRcIzJA24tKi74opOOJazYqwYXffCajHDz22+lV9sQOXD yJvw== 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=GD9NqgN0J6Q9+tZrThmYjpkOVAgxL4AGDXRS5MRouLU=; b=0PrxjpISpF4L07qUJfCeoMm4oAs7AVTb2aUgjvieeCz6QrW85rIHhni3NUojxTLHMI 5YP3Ew8p6M3nAnow2SYmv19daXcbNq5zz6b2rRhBcFFRAo9eDtfGu5HcALkRKsTNVNQ/ cGOc8dfh9jXtpiHztDteB0OGoMUtS/wCAu53pASJKPZ0r6BLV51KTPiVJwXf/dHXvdLS hCSQZKQ5SXdOYpwT4GEe1sL5VZeikXMroiIxKgcz4ixNe64sVNf8ZYFZ+BclKnCeZkzy niIPmBfE5aE9UgIJ6/Fj7b6QdZjkdeQoDERDWWPMhGipdA7Vco5EbZGI000l00Go2oyj oRhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=dUtTbloa; 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 z16-v6si10310218qtq.23.2018.10.18.23.24.24 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 18 Oct 2018 23:24:25 -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=dUtTbloa; 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]:47338 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDOCu-0002Vt-IQ for patch@linaro.org; Fri, 19 Oct 2018 02:24:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39201) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDNwh-0004S3-Ad for qemu-devel@nongnu.org; Fri, 19 Oct 2018 02:07:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gDNwe-0002ir-Qa for qemu-devel@nongnu.org; Fri, 19 Oct 2018 02:07:39 -0400 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]:46507) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gDNwe-0002Cx-6A for qemu-devel@nongnu.org; Fri, 19 Oct 2018 02:07:36 -0400 Received: by mail-pl1-x643.google.com with SMTP id v5-v6so15386807plz.13 for ; Thu, 18 Oct 2018 23:07: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=GD9NqgN0J6Q9+tZrThmYjpkOVAgxL4AGDXRS5MRouLU=; b=dUtTbloajRQRhsVa8hROunmqP9fGPqX1zgv33LPNnW9mHREXD/6KN07tQ26sBDFE0A Wt2tedL3PH/lhV4JoPDBABSnnwhn2zTRknGzB69KjE4g6inSZdIWILYWJUsFZ67pjKbW zDuJQ8igoJFQ6Q3JJMFuXp++w1cf9yN/0j1E0= 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=GD9NqgN0J6Q9+tZrThmYjpkOVAgxL4AGDXRS5MRouLU=; b=cvBanKLIgansJXuO2D4DsK4ROG2tMAxXeaBhhpmuowh2ooUeVmDDn2k5dEctvCPeUR R8CnS9Vz3btfoIIMhW+GHnJqhSM9asYquSrArT6UIWOY3cXGAa3MQdwYlpXWg1P114o2 /8vlXoEPDuM1VXrG7Gv0PO0MwTeTasWJSvvQi3uiei4nnp6NHBVEXOIpxJ0sElZJOLwt AVllsKp9ka+dpvjNyeNmPyRjNQhBH6rvag/eGfuOf4oIoOwFrzBUUFBYro9ClKk2C/3Z VuNY6H3hBp8WX/+SwgpX5s9E/MNP9rJYHQhCnPm9hAVeDJedVVpLGeizOWrr/Toilxkz QTFQ== X-Gm-Message-State: ABuFfoia/b7v0fnyJ4XK3zk/Y3fG5eqXRhGiCWNTHAMIGZHY5rR/qCcA 1Xmwwm1g0O4zY0ACmtLvPx7F7r0FSjg= X-Received: by 2002:a17:902:d704:: with SMTP id w4-v6mr33303245ply.230.1539929237613; Thu, 18 Oct 2018 23:07:17 -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.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Oct 2018 23:07:16 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 18 Oct 2018 23:06:49 -0700 Message-Id: <20181019060656.7968-15-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::643 Subject: [Qemu-devel] [PULL v2 14/21] target/arm: Convert to HAVE_CMPXCHG128 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 Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Reviewed-by: Emilio G. Cota Signed-off-by: Richard Henderson --- target/arm/helper-a64.c | 259 +++++++++++++++++++++------------------- 1 file changed, 133 insertions(+), 126 deletions(-) -- 2.17.2 diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c index 7f6ad3000b..6e4e1b8a19 100644 --- a/target/arm/helper-a64.c +++ b/target/arm/helper-a64.c @@ -30,6 +30,7 @@ #include "exec/exec-all.h" #include "exec/cpu_ldst.h" #include "qemu/int128.h" +#include "qemu/atomic128.h" #include "tcg.h" #include "fpu/softfloat.h" #include /* For crc32 */ @@ -509,189 +510,195 @@ uint64_t HELPER(crc32c_64)(uint64_t acc, uint64_t val, uint32_t bytes) return crc32c(acc, buf, bytes) ^ 0xffffffff; } -/* Returns 0 on success; 1 otherwise. */ -static uint64_t do_paired_cmpxchg64_le(CPUARMState *env, uint64_t addr, - uint64_t new_lo, uint64_t new_hi, - bool parallel, uintptr_t ra) +uint64_t HELPER(paired_cmpxchg64_le)(CPUARMState *env, uint64_t addr, + uint64_t new_lo, uint64_t new_hi) { - Int128 oldv, cmpv, newv; + Int128 cmpv = int128_make128(env->exclusive_val, env->exclusive_high); + Int128 newv = int128_make128(new_lo, new_hi); + Int128 oldv; + uintptr_t ra = GETPC(); + uint64_t o0, o1; bool success; - cmpv = int128_make128(env->exclusive_val, env->exclusive_high); - newv = int128_make128(new_lo, new_hi); - - if (parallel) { -#ifndef CONFIG_ATOMIC128 - cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); -#else - int mem_idx = cpu_mmu_index(env, false); - TCGMemOpIdx oi = make_memop_idx(MO_LEQ | MO_ALIGN_16, mem_idx); - oldv = helper_atomic_cmpxchgo_le_mmu(env, addr, cmpv, newv, oi, ra); - success = int128_eq(oldv, cmpv); -#endif - } else { - uint64_t o0, o1; - #ifdef CONFIG_USER_ONLY - /* ??? Enforce alignment. */ - uint64_t *haddr = g2h(addr); + /* ??? Enforce alignment. */ + uint64_t *haddr = g2h(addr); - helper_retaddr = ra; - o0 = ldq_le_p(haddr + 0); - o1 = ldq_le_p(haddr + 1); - oldv = int128_make128(o0, o1); + helper_retaddr = ra; + o0 = ldq_le_p(haddr + 0); + o1 = ldq_le_p(haddr + 1); + oldv = int128_make128(o0, o1); - success = int128_eq(oldv, cmpv); - if (success) { - stq_le_p(haddr + 0, int128_getlo(newv)); - stq_le_p(haddr + 1, int128_gethi(newv)); - } - helper_retaddr = 0; -#else - int mem_idx = cpu_mmu_index(env, false); - TCGMemOpIdx oi0 = make_memop_idx(MO_LEQ | MO_ALIGN_16, mem_idx); - TCGMemOpIdx oi1 = make_memop_idx(MO_LEQ, mem_idx); - - o0 = helper_le_ldq_mmu(env, addr + 0, oi0, ra); - o1 = helper_le_ldq_mmu(env, addr + 8, oi1, ra); - oldv = int128_make128(o0, o1); - - success = int128_eq(oldv, cmpv); - if (success) { - helper_le_stq_mmu(env, addr + 0, int128_getlo(newv), oi1, ra); - helper_le_stq_mmu(env, addr + 8, int128_gethi(newv), oi1, ra); - } -#endif + success = int128_eq(oldv, cmpv); + if (success) { + stq_le_p(haddr + 0, int128_getlo(newv)); + stq_le_p(haddr + 1, int128_gethi(newv)); } + helper_retaddr = 0; +#else + int mem_idx = cpu_mmu_index(env, false); + TCGMemOpIdx oi0 = make_memop_idx(MO_LEQ | MO_ALIGN_16, mem_idx); + TCGMemOpIdx oi1 = make_memop_idx(MO_LEQ, mem_idx); + + o0 = helper_le_ldq_mmu(env, addr + 0, oi0, ra); + o1 = helper_le_ldq_mmu(env, addr + 8, oi1, ra); + oldv = int128_make128(o0, o1); + + success = int128_eq(oldv, cmpv); + if (success) { + helper_le_stq_mmu(env, addr + 0, int128_getlo(newv), oi1, ra); + helper_le_stq_mmu(env, addr + 8, int128_gethi(newv), oi1, ra); + } +#endif return !success; } -uint64_t HELPER(paired_cmpxchg64_le)(CPUARMState *env, uint64_t addr, - uint64_t new_lo, uint64_t new_hi) -{ - return do_paired_cmpxchg64_le(env, addr, new_lo, new_hi, false, GETPC()); -} - uint64_t HELPER(paired_cmpxchg64_le_parallel)(CPUARMState *env, uint64_t addr, uint64_t new_lo, uint64_t new_hi) -{ - return do_paired_cmpxchg64_le(env, addr, new_lo, new_hi, true, GETPC()); -} - -static uint64_t do_paired_cmpxchg64_be(CPUARMState *env, uint64_t addr, - uint64_t new_lo, uint64_t new_hi, - bool parallel, uintptr_t ra) { Int128 oldv, cmpv, newv; + uintptr_t ra = GETPC(); bool success; + int mem_idx; + TCGMemOpIdx oi; - /* high and low need to be switched here because this is not actually a - * 128bit store but two doublewords stored consecutively - */ - cmpv = int128_make128(env->exclusive_high, env->exclusive_val); - newv = int128_make128(new_hi, new_lo); - - if (parallel) { -#ifndef CONFIG_ATOMIC128 + if (!HAVE_CMPXCHG128) { cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); -#else - int mem_idx = cpu_mmu_index(env, false); - TCGMemOpIdx oi = make_memop_idx(MO_BEQ | MO_ALIGN_16, mem_idx); - oldv = helper_atomic_cmpxchgo_be_mmu(env, addr, cmpv, newv, oi, ra); - success = int128_eq(oldv, cmpv); -#endif - } else { - uint64_t o0, o1; - -#ifdef CONFIG_USER_ONLY - /* ??? Enforce alignment. */ - uint64_t *haddr = g2h(addr); - - helper_retaddr = ra; - o1 = ldq_be_p(haddr + 0); - o0 = ldq_be_p(haddr + 1); - oldv = int128_make128(o0, o1); - - success = int128_eq(oldv, cmpv); - if (success) { - stq_be_p(haddr + 0, int128_gethi(newv)); - stq_be_p(haddr + 1, int128_getlo(newv)); - } - helper_retaddr = 0; -#else - int mem_idx = cpu_mmu_index(env, false); - TCGMemOpIdx oi0 = make_memop_idx(MO_BEQ | MO_ALIGN_16, mem_idx); - TCGMemOpIdx oi1 = make_memop_idx(MO_BEQ, mem_idx); - - o1 = helper_be_ldq_mmu(env, addr + 0, oi0, ra); - o0 = helper_be_ldq_mmu(env, addr + 8, oi1, ra); - oldv = int128_make128(o0, o1); - - success = int128_eq(oldv, cmpv); - if (success) { - helper_be_stq_mmu(env, addr + 0, int128_gethi(newv), oi1, ra); - helper_be_stq_mmu(env, addr + 8, int128_getlo(newv), oi1, ra); - } -#endif } + mem_idx = cpu_mmu_index(env, false); + oi = make_memop_idx(MO_LEQ | MO_ALIGN_16, mem_idx); + + cmpv = int128_make128(env->exclusive_val, env->exclusive_high); + newv = int128_make128(new_lo, new_hi); + oldv = helper_atomic_cmpxchgo_le_mmu(env, addr, cmpv, newv, oi, ra); + + success = int128_eq(oldv, cmpv); return !success; } uint64_t HELPER(paired_cmpxchg64_be)(CPUARMState *env, uint64_t addr, uint64_t new_lo, uint64_t new_hi) { - return do_paired_cmpxchg64_be(env, addr, new_lo, new_hi, false, GETPC()); + /* + * High and low need to be switched here because this is not actually a + * 128bit store but two doublewords stored consecutively + */ + Int128 cmpv = int128_make128(env->exclusive_val, env->exclusive_high); + Int128 newv = int128_make128(new_lo, new_hi); + Int128 oldv; + uintptr_t ra = GETPC(); + uint64_t o0, o1; + bool success; + +#ifdef CONFIG_USER_ONLY + /* ??? Enforce alignment. */ + uint64_t *haddr = g2h(addr); + + helper_retaddr = ra; + o1 = ldq_be_p(haddr + 0); + o0 = ldq_be_p(haddr + 1); + oldv = int128_make128(o0, o1); + + success = int128_eq(oldv, cmpv); + if (success) { + stq_be_p(haddr + 0, int128_gethi(newv)); + stq_be_p(haddr + 1, int128_getlo(newv)); + } + helper_retaddr = 0; +#else + int mem_idx = cpu_mmu_index(env, false); + TCGMemOpIdx oi0 = make_memop_idx(MO_BEQ | MO_ALIGN_16, mem_idx); + TCGMemOpIdx oi1 = make_memop_idx(MO_BEQ, mem_idx); + + o1 = helper_be_ldq_mmu(env, addr + 0, oi0, ra); + o0 = helper_be_ldq_mmu(env, addr + 8, oi1, ra); + oldv = int128_make128(o0, o1); + + success = int128_eq(oldv, cmpv); + if (success) { + helper_be_stq_mmu(env, addr + 0, int128_gethi(newv), oi1, ra); + helper_be_stq_mmu(env, addr + 8, int128_getlo(newv), oi1, ra); + } +#endif + + return !success; } uint64_t HELPER(paired_cmpxchg64_be_parallel)(CPUARMState *env, uint64_t addr, - uint64_t new_lo, uint64_t new_hi) + uint64_t new_lo, uint64_t new_hi) { - return do_paired_cmpxchg64_be(env, addr, new_lo, new_hi, true, GETPC()); + Int128 oldv, cmpv, newv; + uintptr_t ra = GETPC(); + bool success; + int mem_idx; + TCGMemOpIdx oi; + + if (!HAVE_CMPXCHG128) { + cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); + } + + mem_idx = cpu_mmu_index(env, false); + oi = make_memop_idx(MO_BEQ | MO_ALIGN_16, mem_idx); + + /* + * High and low need to be switched here because this is not actually a + * 128bit store but two doublewords stored consecutively + */ + cmpv = int128_make128(env->exclusive_high, env->exclusive_val); + newv = int128_make128(new_hi, new_lo); + oldv = helper_atomic_cmpxchgo_be_mmu(env, addr, cmpv, newv, oi, ra); + + success = int128_eq(oldv, cmpv); + return !success; } /* Writes back the old data into Rs. */ void HELPER(casp_le_parallel)(CPUARMState *env, uint32_t rs, uint64_t addr, uint64_t new_lo, uint64_t new_hi) { - uintptr_t ra = GETPC(); -#ifndef CONFIG_ATOMIC128 - cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); -#else Int128 oldv, cmpv, newv; + uintptr_t ra = GETPC(); + int mem_idx; + TCGMemOpIdx oi; + + if (!HAVE_CMPXCHG128) { + cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); + } + + mem_idx = cpu_mmu_index(env, false); + oi = make_memop_idx(MO_LEQ | MO_ALIGN_16, mem_idx); cmpv = int128_make128(env->xregs[rs], env->xregs[rs + 1]); newv = int128_make128(new_lo, new_hi); - - int mem_idx = cpu_mmu_index(env, false); - TCGMemOpIdx oi = make_memop_idx(MO_LEQ | MO_ALIGN_16, mem_idx); oldv = helper_atomic_cmpxchgo_le_mmu(env, addr, cmpv, newv, oi, ra); env->xregs[rs] = int128_getlo(oldv); env->xregs[rs + 1] = int128_gethi(oldv); -#endif } void HELPER(casp_be_parallel)(CPUARMState *env, uint32_t rs, uint64_t addr, uint64_t new_hi, uint64_t new_lo) { - uintptr_t ra = GETPC(); -#ifndef CONFIG_ATOMIC128 - cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); -#else Int128 oldv, cmpv, newv; + uintptr_t ra = GETPC(); + int mem_idx; + TCGMemOpIdx oi; + + if (!HAVE_CMPXCHG128) { + cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); + } + + mem_idx = cpu_mmu_index(env, false); + oi = make_memop_idx(MO_LEQ | MO_ALIGN_16, mem_idx); cmpv = int128_make128(env->xregs[rs + 1], env->xregs[rs]); newv = int128_make128(new_lo, new_hi); - - int mem_idx = cpu_mmu_index(env, false); - TCGMemOpIdx oi = make_memop_idx(MO_LEQ | MO_ALIGN_16, mem_idx); oldv = helper_atomic_cmpxchgo_be_mmu(env, addr, cmpv, newv, oi, ra); env->xregs[rs + 1] = int128_getlo(oldv); env->xregs[rs] = int128_gethi(oldv); -#endif } /* From patchwork Fri Oct 19 06:06:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 149225 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp2908163lji; Thu, 18 Oct 2018 23:13:32 -0700 (PDT) X-Google-Smtp-Source: ACcGV62lzhWtxM/YNhTfhiGaf17uxmBLWUS7fpxd7cXbiBnOEfzPgA2qEfM8H7EhY7/UWozjLbaT X-Received: by 2002:a0c:ac0a:: with SMTP id l10mr28596723qvb.226.1539929611914; Thu, 18 Oct 2018 23:13:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539929611; cv=none; d=google.com; s=arc-20160816; b=HQaW3vSaiuyXJLpzH9B48SCIhg0WUQHHXZXbfensL0Ax1xr8qQ34gGBOQQZN4Wc150 xGH0pITnzodudp9GRWHUmyZFFtgrRUdRTIiABoYN3H+JcLVsURT+NArekQmtTmMXIBPm BXqkCcCYD5de6BKECFbR91SUSHbQKpbYLWSd/w98BF7vkqPmQ2NhN8GT9waq5S+la6oy kWasAgMT+PPSVm31PJqRXUQWMz0dZ6JHOasu2UIh3KyhbafjMluFzKDpalA9L1t8SkZA mnE/v2UMMTfKr0yXUWfzKLUZ3ryYTWH4cgJA9V3NldzK+ZVr2n+ppH5Gj7KSEWDcpify v7EA== 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 :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=zVQf3itjUOUB22zOcMjuOXnhRpsEU/kH0zSYaIqDkiI=; b=WTIQf7KwCUumn78P0ypSqHAMHytKsLtYK83QTJsvDlXNB9sVnD7nYJTYMnv4IYSO7v U8ysM+IxhXUbwlH/3l83tJ+/IKnwbB6C+5TZUFaCDOKmFy6eZ0+DC6yXqD35SWEOtut6 vit1Nj7mAzodISCJkr+mEp0IlEOyZX/03PRE/DLs7nTnEBVOz4AFowfBB9BUK3gyQIRa GsBe3iE4K1lGzANhMWI42V8u8ajhJzhXa2v+R/qaR7IO2JgDz2PtAn8LG0W/O0jnL3T0 Gs9zFpFewmhHYCe3yVVa3h3l113FSIbEFaf8Dz0wfDVxX8tJEa+tMEr/E42uQQLjV+5I O2lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ND1Xmovp; 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 r125-v6si5885236qkf.244.2018.10.18.23.13.31 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 18 Oct 2018 23:13: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=ND1Xmovp; 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]:47247 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDO2N-0001T0-8n for patch@linaro.org; Fri, 19 Oct 2018 02:13:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39232) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDNwi-0004Tm-DR for qemu-devel@nongnu.org; Fri, 19 Oct 2018 02:07:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gDNwf-0002ly-Hx for qemu-devel@nongnu.org; Fri, 19 Oct 2018 02:07:40 -0400 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]:43025) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gDNwe-0002Dd-Uz for qemu-devel@nongnu.org; Fri, 19 Oct 2018 02:07:37 -0400 Received: by mail-pl1-x631.google.com with SMTP id 30-v6so15380724plb.10 for ; Thu, 18 Oct 2018 23:07:20 -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 :mime-version:content-transfer-encoding; bh=zVQf3itjUOUB22zOcMjuOXnhRpsEU/kH0zSYaIqDkiI=; b=ND1XmovpR7BnqJvMZ4sjIEVBI0wOJImrKaSmN5sGlEz9nG9ibgNWwzXfGnyRYKDzjO dL98ia6kqUtWJ5m5ZQppcq9uVjC7mv+vpDfp14pq0xvqAoP7S5cK5XGgWq2Wiro5efjj f+y4YTXKJA9fO1airpMWI+1DUGH5daB4gtZjU= 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:mime-version:content-transfer-encoding; bh=zVQf3itjUOUB22zOcMjuOXnhRpsEU/kH0zSYaIqDkiI=; b=CDuyI02s6Uj7Xpi+dj1HdQ8nU7CiaL2naqPqsA17GOusX4AXsXUFcSsF3Sp7baK8yE HZA47zpeIJuSyGVn6E3qniNUs/XmIKorPOMon5owHjH0hOyh7431IW+1QT1xX5vOKuED 80OGFvhHBqrcH3iBuXFLPT2nipa36CMbJjW+Hb099XxAkjZBkudLJLHkYhqQJ189Ndiz DikBUDHdtqaAyK9uW7hQQCLYmce++KLX93kFy26aOdyaesi+beBGERq5sC1GhwvA/P9f Cb2xjWAEp7Z0Ui4bj182RXnNO4bqScoQczy+DnAQhz9Gv37chsAldHvOYbM4Ye2QWM9/ DUFw== X-Gm-Message-State: ABuFfoi91iq3TDwzk3tj+EuVXalUo8z5d58eip/kPG77xYxkTFQzn6DH amvs2hsP/Lur6hqNWAGS10rXJCFJ+ZY= X-Received: by 2002:a17:902:8205:: with SMTP id x5-v6mr33158334pln.55.1539929239100; Thu, 18 Oct 2018 23:07:19 -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.17 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Oct 2018 23:07:18 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 18 Oct 2018 23:06:50 -0700 Message-Id: <20181019060656.7968-16-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> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::631 Subject: [Qemu-devel] [PULL v2 15/21] target/arm: Check HAVE_CMPXCHG128 at translate time 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 Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Reviewed-by: Emilio G. Cota Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- target/arm/helper-a64.c | 16 ++++------------ target/arm/translate-a64.c | 38 ++++++++++++++++++++++---------------- 2 files changed, 26 insertions(+), 28 deletions(-) -- 2.17.2 diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c index 6e4e1b8a19..61799d20e1 100644 --- a/target/arm/helper-a64.c +++ b/target/arm/helper-a64.c @@ -563,9 +563,7 @@ uint64_t HELPER(paired_cmpxchg64_le_parallel)(CPUARMState *env, uint64_t addr, int mem_idx; TCGMemOpIdx oi; - if (!HAVE_CMPXCHG128) { - cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); - } + assert(HAVE_CMPXCHG128); mem_idx = cpu_mmu_index(env, false); oi = make_memop_idx(MO_LEQ | MO_ALIGN_16, mem_idx); @@ -635,9 +633,7 @@ uint64_t HELPER(paired_cmpxchg64_be_parallel)(CPUARMState *env, uint64_t addr, int mem_idx; TCGMemOpIdx oi; - if (!HAVE_CMPXCHG128) { - cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); - } + assert(HAVE_CMPXCHG128); mem_idx = cpu_mmu_index(env, false); oi = make_memop_idx(MO_BEQ | MO_ALIGN_16, mem_idx); @@ -663,9 +659,7 @@ void HELPER(casp_le_parallel)(CPUARMState *env, uint32_t rs, uint64_t addr, int mem_idx; TCGMemOpIdx oi; - if (!HAVE_CMPXCHG128) { - cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); - } + assert(HAVE_CMPXCHG128); mem_idx = cpu_mmu_index(env, false); oi = make_memop_idx(MO_LEQ | MO_ALIGN_16, mem_idx); @@ -686,9 +680,7 @@ void HELPER(casp_be_parallel)(CPUARMState *env, uint32_t rs, uint64_t addr, int mem_idx; TCGMemOpIdx oi; - if (!HAVE_CMPXCHG128) { - cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); - } + assert(HAVE_CMPXCHG128); mem_idx = cpu_mmu_index(env, false); oi = make_memop_idx(MO_LEQ | MO_ALIGN_16, mem_idx); diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 8a24278d79..bb9c4d8ac7 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -37,6 +37,7 @@ #include "trace-tcg.h" #include "translate-a64.h" +#include "qemu/atomic128.h" static TCGv_i64 cpu_X[32]; static TCGv_i64 cpu_pc; @@ -2086,26 +2087,27 @@ static void gen_store_exclusive(DisasContext *s, int rd, int rt, int rt2, get_mem_index(s), MO_64 | MO_ALIGN | s->be_data); tcg_gen_setcond_i64(TCG_COND_NE, tmp, tmp, cpu_exclusive_val); - } else if (s->be_data == MO_LE) { - if (tb_cflags(s->base.tb) & CF_PARALLEL) { + } else if (tb_cflags(s->base.tb) & CF_PARALLEL) { + if (!HAVE_CMPXCHG128) { + gen_helper_exit_atomic(cpu_env); + s->base.is_jmp = DISAS_NORETURN; + } else if (s->be_data == MO_LE) { gen_helper_paired_cmpxchg64_le_parallel(tmp, cpu_env, cpu_exclusive_addr, cpu_reg(s, rt), cpu_reg(s, rt2)); } else { - gen_helper_paired_cmpxchg64_le(tmp, cpu_env, cpu_exclusive_addr, - cpu_reg(s, rt), cpu_reg(s, rt2)); - } - } else { - if (tb_cflags(s->base.tb) & CF_PARALLEL) { gen_helper_paired_cmpxchg64_be_parallel(tmp, cpu_env, cpu_exclusive_addr, cpu_reg(s, rt), cpu_reg(s, rt2)); - } else { - gen_helper_paired_cmpxchg64_be(tmp, cpu_env, cpu_exclusive_addr, - cpu_reg(s, rt), cpu_reg(s, rt2)); } + } else if (s->be_data == MO_LE) { + gen_helper_paired_cmpxchg64_le(tmp, cpu_env, cpu_exclusive_addr, + cpu_reg(s, rt), cpu_reg(s, rt2)); + } else { + gen_helper_paired_cmpxchg64_be(tmp, cpu_env, cpu_exclusive_addr, + cpu_reg(s, rt), cpu_reg(s, rt2)); } } else { tcg_gen_atomic_cmpxchg_i64(tmp, cpu_exclusive_addr, cpu_exclusive_val, @@ -2175,14 +2177,18 @@ static void gen_compare_and_swap_pair(DisasContext *s, int rs, int rt, } tcg_temp_free_i64(cmp); } else if (tb_cflags(s->base.tb) & CF_PARALLEL) { - TCGv_i32 tcg_rs = tcg_const_i32(rs); - - if (s->be_data == MO_LE) { - gen_helper_casp_le_parallel(cpu_env, tcg_rs, addr, t1, t2); + if (HAVE_CMPXCHG128) { + TCGv_i32 tcg_rs = tcg_const_i32(rs); + if (s->be_data == MO_LE) { + gen_helper_casp_le_parallel(cpu_env, tcg_rs, addr, t1, t2); + } else { + gen_helper_casp_be_parallel(cpu_env, tcg_rs, addr, t1, t2); + } + tcg_temp_free_i32(tcg_rs); } else { - gen_helper_casp_be_parallel(cpu_env, tcg_rs, addr, t1, t2); + gen_helper_exit_atomic(cpu_env); + s->base.is_jmp = DISAS_NORETURN; } - tcg_temp_free_i32(tcg_rs); } else { TCGv_i64 d1 = tcg_temp_new_i64(); TCGv_i64 d2 = tcg_temp_new_i64(); From patchwork Fri Oct 19 06:06:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 149238 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp2917336lji; Thu, 18 Oct 2018 23:25:39 -0700 (PDT) X-Google-Smtp-Source: ACcGV63EJKQaxO4jk6QqaqlcFB6Y6teHWylGcoz0epc2Sbpr5B8UaiyBxCuPtfd2bbLzK+sTiqZW X-Received: by 2002:aed:3b7b:: with SMTP id q56-v6mr31412340qte.51.1539930338975; Thu, 18 Oct 2018 23:25:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539930338; cv=none; d=google.com; s=arc-20160816; b=o0jXUpCPzb8GI2CcGTep/W0IOXLwv6SzKY6e2CLoePTzGF9QUQV59FJACF6TgwiBm9 hm+LQnjDdkAhik0FuEKqgOTl8jnevVTtTKsoJn58Jj5VOeVq8pbnAVJ/4bRxzhe7vs6Y CiSB8rvzqcmbu18fMbcialhfscNAETTLxs1RqUv6F3PlCr0qwYoanUpFXr4k43Grn9IU B7f/nEDnR24Ktp2xAU00ce9yrBvlWT7WM74F072kk5SIa2Q+ezZEkxo0L/OzIABcpy/v VwyNovwOK3/FzxfqmKO7PIHmetQCdyqJ62HU0xhYxz/CyN++ZBY3Cd9++w7putbYBXZi wQeQ== 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=tINqnC7t3qpYIlQwdR+JK2i1hWmQ6SSYgNbVSBX0E60=; b=sIgFFnHP7Dhb+MbhhKUF9i1+c5LN6MEKOqyAbgGTD8dGBwALgdxmHbMIoFvYZ2YsqB nOHI4PS/bTn6jpcWfjYBAuef5eWiEpDxn0qjMlVVHJ9MfKoyJNc+vy+uX51pCzcuUbSK PNFzGTfQWgCb5BN2bd0iiQeQDv+2zmyF1ncERT9zOqFGplh6HGz0ruiTDKmGYgU90epZ oJeF/c1bfZ8DBM0ALLBDNh8f200xcQ4B2tfq+0DU3DN9dZq5UHQpvY0Q0/Woqx0evMQ2 dUfFN/VWha0z3YvcbpslEzm4XoVNBMq6Zwn+VjTfKvFBcfpEpsGpf2gP9++kwwwFer1H HhEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=SNd51Rrz; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 208.118.235.17 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. [208.118.235.17]) by mx.google.com with ESMTPS id t9-v6si3672307qvb.135.2018.10.18.23.25.38 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 18 Oct 2018 23:25:38 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=SNd51Rrz; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 208.118.235.17 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]:47350 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDOE6-0003IE-DT for patch@linaro.org; Fri, 19 Oct 2018 02:25:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39248) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDNwi-0004Tp-PQ for qemu-devel@nongnu.org; Fri, 19 Oct 2018 02:07:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gDNwf-0002lp-HK for qemu-devel@nongnu.org; Fri, 19 Oct 2018 02:07:40 -0400 Received: from mail-pg1-x52f.google.com ([2607:f8b0:4864:20::52f]:40762) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gDNwe-0002FP-Rx for qemu-devel@nongnu.org; Fri, 19 Oct 2018 02:07:37 -0400 Received: by mail-pg1-x52f.google.com with SMTP id n31-v6so15308022pgm.7 for ; Thu, 18 Oct 2018 23:07:21 -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=tINqnC7t3qpYIlQwdR+JK2i1hWmQ6SSYgNbVSBX0E60=; b=SNd51RrzDs4x38n/1mLriNXMhC9MelS97o8N+9iDhvaqXlReVXcnYzRi4U73gs0s5e AhqxkNbkjrngndbYwCdIFEUJ2wQT5pVtmYIsT+G/DoqrzOnj+edxA7DflYInQF4M+1a3 vPvh32RvzLsU+2/oG0ztHJOBtJI1w5goFnStE= 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=tINqnC7t3qpYIlQwdR+JK2i1hWmQ6SSYgNbVSBX0E60=; b=U1mYlm64YhUAMKZYzJX23gtfjAraEvPLYGDp2/vKIhyPPzC7JVH8pNIp7awXFqgTfz Y/DLnOxYpfS/CrcmzL2lr7AD+vCjWl8ZWiFdH1TzQjAMT556AGfh8/9dbiKBEPJaKFa0 34uI5r0pnCsfXpqD7ywxtQzD4V01qKMTGw9fq23G766zFPBd/McVM/TP52fcXIxykQ6n 2i2N0aegIzoV6xshTbcsHNWOxua+rOaizAursiFatdvFUx2pDQAE2cTz7VSME7jM1Gd8 sG/B+e1QAGeybBaz0WhZS03Af7uznXTWux+/Nz4ucEmlDPuNQoTJf4WaVzgI6iPr7iyQ dVBA== X-Gm-Message-State: ABuFfojZ2ewtKmw+ZgVXCEildANyR1M/BBXLnAcf4qj6ARLgqKczYm9w 0x7BCZ2V83LyVYd2lqlnaTOeXUkzE2k= X-Received: by 2002:a62:1b45:: with SMTP id b66-v6mr33358443pfb.94.1539929240578; Thu, 18 Oct 2018 23:07:20 -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.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Oct 2018 23:07:19 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 18 Oct 2018 23:06:51 -0700 Message-Id: <20181019060656.7968-17-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::52f Subject: [Qemu-devel] [PULL v2 16/21] target/ppc: Convert to HAVE_CMPXCHG128 and HAVE_ATOMIC128 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 Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Reviewed-by: Emilio G. Cota Signed-off-by: Richard Henderson --- target/ppc/helper.h | 2 +- target/ppc/mem_helper.c | 33 ++++++++++-- target/ppc/translate.c | 115 +++++++++++++++++++++------------------- 3 files changed, 88 insertions(+), 62 deletions(-) -- 2.17.2 diff --git a/target/ppc/helper.h b/target/ppc/helper.h index ef64248bc4..7a1481fd0b 100644 --- a/target/ppc/helper.h +++ b/target/ppc/helper.h @@ -800,7 +800,7 @@ DEF_HELPER_4(dscliq, void, env, fprp, fprp, i32) DEF_HELPER_1(tbegin, void, env) DEF_HELPER_FLAGS_1(fixup_thrm, TCG_CALL_NO_RWG, void, env) -#if defined(TARGET_PPC64) && defined(CONFIG_ATOMIC128) +#ifdef TARGET_PPC64 DEF_HELPER_FLAGS_3(lq_le_parallel, TCG_CALL_NO_WG, i64, env, tl, i32) DEF_HELPER_FLAGS_3(lq_be_parallel, TCG_CALL_NO_WG, i64, env, tl, i32) DEF_HELPER_FLAGS_5(stq_le_parallel, TCG_CALL_NO_WG, diff --git a/target/ppc/mem_helper.c b/target/ppc/mem_helper.c index 8f0d86d104..a1485fad9b 100644 --- a/target/ppc/mem_helper.c +++ b/target/ppc/mem_helper.c @@ -25,6 +25,7 @@ #include "exec/cpu_ldst.h" #include "tcg.h" #include "internal.h" +#include "qemu/atomic128.h" //#define DEBUG_OP @@ -215,11 +216,15 @@ target_ulong helper_lscbx(CPUPPCState *env, target_ulong addr, uint32_t reg, return i; } -#if defined(TARGET_PPC64) && defined(CONFIG_ATOMIC128) +#ifdef TARGET_PPC64 uint64_t helper_lq_le_parallel(CPUPPCState *env, target_ulong addr, uint32_t opidx) { - Int128 ret = helper_atomic_ldo_le_mmu(env, addr, opidx, GETPC()); + Int128 ret; + + /* We will have raised EXCP_ATOMIC from the translator. */ + assert(HAVE_ATOMIC128); + ret = helper_atomic_ldo_le_mmu(env, addr, opidx, GETPC()); env->retxh = int128_gethi(ret); return int128_getlo(ret); } @@ -227,7 +232,11 @@ uint64_t helper_lq_le_parallel(CPUPPCState *env, target_ulong addr, uint64_t helper_lq_be_parallel(CPUPPCState *env, target_ulong addr, uint32_t opidx) { - Int128 ret = helper_atomic_ldo_be_mmu(env, addr, opidx, GETPC()); + Int128 ret; + + /* We will have raised EXCP_ATOMIC from the translator. */ + assert(HAVE_ATOMIC128); + ret = helper_atomic_ldo_be_mmu(env, addr, opidx, GETPC()); env->retxh = int128_gethi(ret); return int128_getlo(ret); } @@ -235,14 +244,22 @@ uint64_t helper_lq_be_parallel(CPUPPCState *env, target_ulong addr, void helper_stq_le_parallel(CPUPPCState *env, target_ulong addr, uint64_t lo, uint64_t hi, uint32_t opidx) { - Int128 val = int128_make128(lo, hi); + Int128 val; + + /* We will have raised EXCP_ATOMIC from the translator. */ + assert(HAVE_ATOMIC128); + val = int128_make128(lo, hi); helper_atomic_sto_le_mmu(env, addr, val, opidx, GETPC()); } void helper_stq_be_parallel(CPUPPCState *env, target_ulong addr, uint64_t lo, uint64_t hi, uint32_t opidx) { - Int128 val = int128_make128(lo, hi); + Int128 val; + + /* We will have raised EXCP_ATOMIC from the translator. */ + assert(HAVE_ATOMIC128); + val = int128_make128(lo, hi); helper_atomic_sto_be_mmu(env, addr, val, opidx, GETPC()); } @@ -252,6 +269,9 @@ uint32_t helper_stqcx_le_parallel(CPUPPCState *env, target_ulong addr, { bool success = false; + /* We will have raised EXCP_ATOMIC from the translator. */ + assert(HAVE_CMPXCHG128); + if (likely(addr == env->reserve_addr)) { Int128 oldv, cmpv, newv; @@ -271,6 +291,9 @@ uint32_t helper_stqcx_be_parallel(CPUPPCState *env, target_ulong addr, { bool success = false; + /* We will have raised EXCP_ATOMIC from the translator. */ + assert(HAVE_CMPXCHG128); + if (likely(addr == env->reserve_addr)) { Int128 oldv, cmpv, newv; diff --git a/target/ppc/translate.c b/target/ppc/translate.c index 881743571b..4e59dd5f42 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -33,6 +33,7 @@ #include "trace-tcg.h" #include "exec/translator.h" #include "exec/log.h" +#include "qemu/atomic128.h" #define CPU_SINGLE_STEP 0x1 @@ -2654,22 +2655,22 @@ static void gen_lq(DisasContext *ctx) hi = cpu_gpr[rd]; if (tb_cflags(ctx->base.tb) & CF_PARALLEL) { -#ifdef CONFIG_ATOMIC128 - TCGv_i32 oi = tcg_temp_new_i32(); - if (ctx->le_mode) { - tcg_gen_movi_i32(oi, make_memop_idx(MO_LEQ, ctx->mem_idx)); - gen_helper_lq_le_parallel(lo, cpu_env, EA, oi); + if (HAVE_ATOMIC128) { + TCGv_i32 oi = tcg_temp_new_i32(); + if (ctx->le_mode) { + tcg_gen_movi_i32(oi, make_memop_idx(MO_LEQ, ctx->mem_idx)); + gen_helper_lq_le_parallel(lo, cpu_env, EA, oi); + } else { + tcg_gen_movi_i32(oi, make_memop_idx(MO_BEQ, ctx->mem_idx)); + gen_helper_lq_be_parallel(lo, cpu_env, EA, oi); + } + tcg_temp_free_i32(oi); + tcg_gen_ld_i64(hi, cpu_env, offsetof(CPUPPCState, retxh)); } else { - tcg_gen_movi_i32(oi, make_memop_idx(MO_BEQ, ctx->mem_idx)); - gen_helper_lq_be_parallel(lo, cpu_env, EA, oi); + /* Restart with exclusive lock. */ + gen_helper_exit_atomic(cpu_env); + ctx->base.is_jmp = DISAS_NORETURN; } - tcg_temp_free_i32(oi); - tcg_gen_ld_i64(hi, cpu_env, offsetof(CPUPPCState, retxh)); -#else - /* Restart with exclusive lock. */ - gen_helper_exit_atomic(cpu_env); - ctx->base.is_jmp = DISAS_NORETURN; -#endif } else if (ctx->le_mode) { tcg_gen_qemu_ld_i64(lo, EA, ctx->mem_idx, MO_LEQ); gen_addr_add(ctx, EA, EA, 8); @@ -2805,21 +2806,21 @@ static void gen_std(DisasContext *ctx) hi = cpu_gpr[rs]; if (tb_cflags(ctx->base.tb) & CF_PARALLEL) { -#ifdef CONFIG_ATOMIC128 - TCGv_i32 oi = tcg_temp_new_i32(); - if (ctx->le_mode) { - tcg_gen_movi_i32(oi, make_memop_idx(MO_LEQ, ctx->mem_idx)); - gen_helper_stq_le_parallel(cpu_env, EA, lo, hi, oi); + if (HAVE_ATOMIC128) { + TCGv_i32 oi = tcg_temp_new_i32(); + if (ctx->le_mode) { + tcg_gen_movi_i32(oi, make_memop_idx(MO_LEQ, ctx->mem_idx)); + gen_helper_stq_le_parallel(cpu_env, EA, lo, hi, oi); + } else { + tcg_gen_movi_i32(oi, make_memop_idx(MO_BEQ, ctx->mem_idx)); + gen_helper_stq_be_parallel(cpu_env, EA, lo, hi, oi); + } + tcg_temp_free_i32(oi); } else { - tcg_gen_movi_i32(oi, make_memop_idx(MO_BEQ, ctx->mem_idx)); - gen_helper_stq_be_parallel(cpu_env, EA, lo, hi, oi); + /* Restart with exclusive lock. */ + gen_helper_exit_atomic(cpu_env); + ctx->base.is_jmp = DISAS_NORETURN; } - tcg_temp_free_i32(oi); -#else - /* Restart with exclusive lock. */ - gen_helper_exit_atomic(cpu_env); - ctx->base.is_jmp = DISAS_NORETURN; -#endif } else if (ctx->le_mode) { tcg_gen_qemu_st_i64(lo, EA, ctx->mem_idx, MO_LEQ); gen_addr_add(ctx, EA, EA, 8); @@ -3404,26 +3405,26 @@ static void gen_lqarx(DisasContext *ctx) hi = cpu_gpr[rd]; if (tb_cflags(ctx->base.tb) & CF_PARALLEL) { -#ifdef CONFIG_ATOMIC128 - TCGv_i32 oi = tcg_temp_new_i32(); - if (ctx->le_mode) { - tcg_gen_movi_i32(oi, make_memop_idx(MO_LEQ | MO_ALIGN_16, - ctx->mem_idx)); - gen_helper_lq_le_parallel(lo, cpu_env, EA, oi); + if (HAVE_ATOMIC128) { + TCGv_i32 oi = tcg_temp_new_i32(); + if (ctx->le_mode) { + tcg_gen_movi_i32(oi, make_memop_idx(MO_LEQ | MO_ALIGN_16, + ctx->mem_idx)); + gen_helper_lq_le_parallel(lo, cpu_env, EA, oi); + } else { + tcg_gen_movi_i32(oi, make_memop_idx(MO_BEQ | MO_ALIGN_16, + ctx->mem_idx)); + gen_helper_lq_be_parallel(lo, cpu_env, EA, oi); + } + tcg_temp_free_i32(oi); + tcg_gen_ld_i64(hi, cpu_env, offsetof(CPUPPCState, retxh)); } else { - tcg_gen_movi_i32(oi, make_memop_idx(MO_BEQ | MO_ALIGN_16, - ctx->mem_idx)); - gen_helper_lq_be_parallel(lo, cpu_env, EA, oi); + /* Restart with exclusive lock. */ + gen_helper_exit_atomic(cpu_env); + ctx->base.is_jmp = DISAS_NORETURN; + tcg_temp_free(EA); + return; } - tcg_temp_free_i32(oi); - tcg_gen_ld_i64(hi, cpu_env, offsetof(CPUPPCState, retxh)); -#else - /* Restart with exclusive lock. */ - gen_helper_exit_atomic(cpu_env); - ctx->base.is_jmp = DISAS_NORETURN; - tcg_temp_free(EA); - return; -#endif } else if (ctx->le_mode) { tcg_gen_qemu_ld_i64(lo, EA, ctx->mem_idx, MO_LEQ | MO_ALIGN_16); tcg_gen_mov_tl(cpu_reserve, EA); @@ -3461,20 +3462,22 @@ static void gen_stqcx_(DisasContext *ctx) hi = cpu_gpr[rs]; if (tb_cflags(ctx->base.tb) & CF_PARALLEL) { - TCGv_i32 oi = tcg_const_i32(DEF_MEMOP(MO_Q) | MO_ALIGN_16); -#ifdef CONFIG_ATOMIC128 - if (ctx->le_mode) { - gen_helper_stqcx_le_parallel(cpu_crf[0], cpu_env, EA, lo, hi, oi); + if (HAVE_CMPXCHG128) { + TCGv_i32 oi = tcg_const_i32(DEF_MEMOP(MO_Q) | MO_ALIGN_16); + if (ctx->le_mode) { + gen_helper_stqcx_le_parallel(cpu_crf[0], cpu_env, + EA, lo, hi, oi); + } else { + gen_helper_stqcx_be_parallel(cpu_crf[0], cpu_env, + EA, lo, hi, oi); + } + tcg_temp_free_i32(oi); } else { - gen_helper_stqcx_le_parallel(cpu_crf[0], cpu_env, EA, lo, hi, oi); + /* Restart with exclusive lock. */ + gen_helper_exit_atomic(cpu_env); + ctx->base.is_jmp = DISAS_NORETURN; } -#else - /* Restart with exclusive lock. */ - gen_helper_exit_atomic(cpu_env); - ctx->base.is_jmp = DISAS_NORETURN; -#endif tcg_temp_free(EA); - tcg_temp_free_i32(oi); } else { TCGLabel *lab_fail = gen_new_label(); TCGLabel *lab_over = gen_new_label(); From patchwork Fri Oct 19 06:06: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: 149226 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp2908216lji; Thu, 18 Oct 2018 23:13:35 -0700 (PDT) X-Google-Smtp-Source: ACcGV62E3Di4YYZinjDQ0VC+t0ECbTVC/aP9L5E/KTSkboyg03tnCLiIn20/cGHIg7aroMQBD9dj X-Received: by 2002:ac8:7c6:: with SMTP id m6-v6mr32712743qth.365.1539929615719; Thu, 18 Oct 2018 23:13:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539929615; cv=none; d=google.com; s=arc-20160816; b=pQcgmKt9baC2E0GjTliGiGEYFixE/pOJ5Dr/pXVYKNCdodmXey/oT2njb3zrjDs1xw 9Q/1QiXb8sYVK8T4JnOapKja/YPw5LVw2hLKJoBriNBwkrID5pfM32pJm61+xDSP1Ubu qT4BX99RxoL+lLQGXOJYqQyxXPBht119AQ1/I9kJUC34pJqIP3GaAJFoKvNRm8DroVlm gcnXO2AZ86ZkXNATomlWi+YC3f1N5F1Aln9Scyc4EZzVgntYvT10YAnORDd7B71jbdVU 0blHIAP1IfqLtiS+RvlrKeFkoAP0XHg0XKXQ+9DxXqoQDZNf2qvhu67LAS4kvvMBQB4b 2D7Q== 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=o+dgHPD7vn5MSQoXXXAwqx0gYM5oyfE8kduesNuHmck=; b=IN8MYEw6T/ZnBYibczgbTnlB1jsEiNc0XoQ2LMLPhFegAdY96Mm0dF3SB+OhqymHOQ EGxFsQADeG7dLx4ZqwXgcaWWyia/pk4uwvgrWz2ePT6jaxOTIymx0F0YaXt2ZGScgR2B dTCKqCpUnOQ+enBCcQkqJt1ufp9cYouky5nDMyAyePuY3458vXHEfHPjiDUloypgnDsd irVN8AwTK4/NPro4DTTwq7tLm1mvpzyHTSrtSwtPLcFzz04PBbOn13orkvrCCdp6VR1h Nc1VxNP+OgzFlYrx2EBoW62OdBe0XBjLUNaWkTjD+C+NfvEtzhkvnekvWrnCJOS2o6eT 5tAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=KzXpLAqa; 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 a20-v6si7213173qtj.202.2018.10.18.23.13.35 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 18 Oct 2018 23:13:35 -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=KzXpLAqa; 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]:47248 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDO2R-0001p0-3D for patch@linaro.org; Fri, 19 Oct 2018 02:13:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39287) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDNwk-0004Ts-3t for qemu-devel@nongnu.org; Fri, 19 Oct 2018 02:07:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gDNwg-0002o9-D1 for qemu-devel@nongnu.org; Fri, 19 Oct 2018 02:07:41 -0400 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]:44959) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gDNwf-0002JS-Sy for qemu-devel@nongnu.org; Fri, 19 Oct 2018 02:07:38 -0400 Received: by mail-pl1-x644.google.com with SMTP id d23-v6so1955305pls.11 for ; Thu, 18 Oct 2018 23:07:23 -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=o+dgHPD7vn5MSQoXXXAwqx0gYM5oyfE8kduesNuHmck=; b=KzXpLAqaEfJ5IzfTvJ+FuvgUI4xYmNy21w3kmpewuLIEd1SfG8JWe/P2HegGMVVqBr GXbRb62zR4OLwQE7UIfxURNPrtCJG8lO97lc+7Yw7FkXvwueHTtTw4JqE4bmRTzGNR0v K1coMDd6ehxjMf7SKevvtlpTam8O32PqUq1ys= 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=o+dgHPD7vn5MSQoXXXAwqx0gYM5oyfE8kduesNuHmck=; b=HvjPKv2LplxN0NlmlWGr6n99pvBnKNP2NmuzwdGVcb1Ts28NaVsCTGBtulc0d0k6Iz fe1kNPsXm1p4sJN0cBj7/KxgkD/FEQ5Lv4gGurGtMU5/E0NMMCeSiKtEb92ixqkIl/+f ir6mRw/CB4lBxOeOpBRho/+z6jLvcA48rtjSBMQwx5QIIu3UPQhmnDC3bYRC+UXB+cmW YkfWFm/DyrH42+W5gPDBYxCALq2YVT/G+cgadpkzgxoig5SmZN5uhg3dATN7pyb4GVbh u6GBZVRfQvQjC1DmgkHB87HaSEF9QfnVmA0etr4n8u3FoUR6UoFBQMppRWVdOoAc5r2N g39Q== X-Gm-Message-State: ABuFfohite31Mo4g4jnIqnI23uDRNiVDaxyHZ5of+qR9Mdn26qApDmCL 25x9Np/1ZivU12SBkVUtgZX+g4UTCbc= X-Received: by 2002:a17:902:24e7:: with SMTP id l36-v6mr32733648plg.234.1539929242097; Thu, 18 Oct 2018 23:07:22 -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.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Oct 2018 23:07:21 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 18 Oct 2018 23:06:52 -0700 Message-Id: <20181019060656.7968-18-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::644 Subject: [Qemu-devel] [PULL v2 17/21] target/s390x: Convert to HAVE_CMPXCHG128 and HAVE_ATOMIC128 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 Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Reviewed-by: David Hildenbrand Signed-off-by: Richard Henderson --- target/s390x/mem_helper.c | 92 +++++++++++++++++---------------------- 1 file changed, 41 insertions(+), 51 deletions(-) -- 2.17.2 diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index bacae4f503..e106f61b4e 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -25,6 +25,7 @@ #include "exec/exec-all.h" #include "exec/cpu_ldst.h" #include "qemu/int128.h" +#include "qemu/atomic128.h" #if !defined(CONFIG_USER_ONLY) #include "hw/s390x/storage-keys.h" @@ -1389,7 +1390,7 @@ static void do_cdsg(CPUS390XState *env, uint64_t addr, bool fail; if (parallel) { -#ifndef CONFIG_ATOMIC128 +#if !HAVE_CMPXCHG128 cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); #else int mem_idx = cpu_mmu_index(env, false); @@ -1435,9 +1436,7 @@ void HELPER(cdsg_parallel)(CPUS390XState *env, uint64_t addr, static uint32_t do_csst(CPUS390XState *env, uint32_t r3, uint64_t a1, uint64_t a2, bool parallel) { -#if !defined(CONFIG_USER_ONLY) || defined(CONFIG_ATOMIC128) uint32_t mem_idx = cpu_mmu_index(env, false); -#endif uintptr_t ra = GETPC(); uint32_t fc = extract32(env->regs[0], 0, 8); uint32_t sc = extract32(env->regs[0], 8, 8); @@ -1465,18 +1464,20 @@ static uint32_t do_csst(CPUS390XState *env, uint32_t r3, uint64_t a1, probe_write(env, a2, 0, mem_idx, ra); #endif - /* Note that the compare-and-swap is atomic, and the store is atomic, but - the complete operation is not. Therefore we do not need to assert serial - context in order to implement this. That said, restart early if we can't - support either operation that is supposed to be atomic. */ + /* + * Note that the compare-and-swap is atomic, and the store is atomic, + * but the complete operation is not. Therefore we do not need to + * assert serial context in order to implement this. That said, + * restart early if we can't support either operation that is supposed + * to be atomic. + */ if (parallel) { - int mask = 0; -#if !defined(CONFIG_ATOMIC64) - mask = -8; -#elif !defined(CONFIG_ATOMIC128) - mask = -16; + uint32_t max = 2; +#ifdef CONFIG_ATOMIC64 + max = 3; #endif - if (((4 << fc) | (1 << sc)) & mask) { + if ((HAVE_CMPXCHG128 ? 0 : fc + 2 > max) || + (HAVE_ATOMIC128 ? 0 : sc > max)) { cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); } } @@ -1546,16 +1547,7 @@ static uint32_t do_csst(CPUS390XState *env, uint32_t r3, uint64_t a1, Int128 cv = int128_make128(env->regs[r3 + 1], env->regs[r3]); Int128 ov; - if (parallel) { -#ifdef CONFIG_ATOMIC128 - TCGMemOpIdx oi = make_memop_idx(MO_TEQ | MO_ALIGN_16, mem_idx); - ov = helper_atomic_cmpxchgo_be_mmu(env, a1, cv, nv, oi, ra); - cc = !int128_eq(ov, cv); -#else - /* Note that we asserted !parallel above. */ - g_assert_not_reached(); -#endif - } else { + if (!parallel) { uint64_t oh = cpu_ldq_data_ra(env, a1 + 0, ra); uint64_t ol = cpu_ldq_data_ra(env, a1 + 8, ra); @@ -1567,6 +1559,13 @@ static uint32_t do_csst(CPUS390XState *env, uint32_t r3, uint64_t a1, cpu_stq_data_ra(env, a1 + 0, int128_gethi(nv), ra); cpu_stq_data_ra(env, a1 + 8, int128_getlo(nv), ra); + } else if (HAVE_CMPXCHG128) { + TCGMemOpIdx oi = make_memop_idx(MO_TEQ | MO_ALIGN_16, mem_idx); + ov = helper_atomic_cmpxchgo_be_mmu(env, a1, cv, nv, oi, ra); + cc = !int128_eq(ov, cv); + } else { + /* Note that we asserted !parallel above. */ + g_assert_not_reached(); } env->regs[r3 + 0] = int128_gethi(ov); @@ -1596,18 +1595,16 @@ static uint32_t do_csst(CPUS390XState *env, uint32_t r3, uint64_t a1, cpu_stq_data_ra(env, a2, svh, ra); break; case 4: - if (parallel) { -#ifdef CONFIG_ATOMIC128 + if (!parallel) { + cpu_stq_data_ra(env, a2 + 0, svh, ra); + cpu_stq_data_ra(env, a2 + 8, svl, ra); + } else if (HAVE_ATOMIC128) { TCGMemOpIdx oi = make_memop_idx(MO_TEQ | MO_ALIGN_16, mem_idx); Int128 sv = int128_make128(svl, svh); helper_atomic_sto_be_mmu(env, a2, sv, oi, ra); -#else + } else { /* Note that we asserted !parallel above. */ g_assert_not_reached(); -#endif - } else { - cpu_stq_data_ra(env, a2 + 0, svh, ra); - cpu_stq_data_ra(env, a2 + 8, svl, ra); } break; default: @@ -2105,21 +2102,18 @@ static uint64_t do_lpq(CPUS390XState *env, uint64_t addr, bool parallel) uintptr_t ra = GETPC(); uint64_t hi, lo; - if (parallel) { -#ifndef CONFIG_ATOMIC128 - cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); -#else + if (!parallel) { + check_alignment(env, addr, 16, ra); + hi = cpu_ldq_data_ra(env, addr + 0, ra); + lo = cpu_ldq_data_ra(env, addr + 8, ra); + } else if (HAVE_ATOMIC128) { int mem_idx = cpu_mmu_index(env, false); TCGMemOpIdx oi = make_memop_idx(MO_TEQ | MO_ALIGN_16, mem_idx); Int128 v = helper_atomic_ldo_be_mmu(env, addr, oi, ra); hi = int128_gethi(v); lo = int128_getlo(v); -#endif } else { - check_alignment(env, addr, 16, ra); - - hi = cpu_ldq_data_ra(env, addr + 0, ra); - lo = cpu_ldq_data_ra(env, addr + 8, ra); + cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); } env->retxl = lo; @@ -2142,21 +2136,17 @@ static void do_stpq(CPUS390XState *env, uint64_t addr, { uintptr_t ra = GETPC(); - if (parallel) { -#ifndef CONFIG_ATOMIC128 - cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); -#else - int mem_idx = cpu_mmu_index(env, false); - TCGMemOpIdx oi = make_memop_idx(MO_TEQ | MO_ALIGN_16, mem_idx); - - Int128 v = int128_make128(low, high); - helper_atomic_sto_be_mmu(env, addr, v, oi, ra); -#endif - } else { + if (!parallel) { check_alignment(env, addr, 16, ra); - cpu_stq_data_ra(env, addr + 0, high, ra); cpu_stq_data_ra(env, addr + 8, low, ra); + } else if (HAVE_ATOMIC128) { + int mem_idx = cpu_mmu_index(env, false); + TCGMemOpIdx oi = make_memop_idx(MO_TEQ | MO_ALIGN_16, mem_idx); + Int128 v = int128_make128(low, high); + helper_atomic_sto_be_mmu(env, addr, v, oi, ra); + } else { + cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); } } From patchwork Fri Oct 19 06:06:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 149234 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp2913722lji; Thu, 18 Oct 2018 23:20:51 -0700 (PDT) X-Google-Smtp-Source: AJdET5efmJKeP5Bv+IiMAXLaIabM1G3ppnuSx4FVwBH2FPH8vN+3ojPnKXm/ZE/EJ3nKUURl7WFO X-Received: by 2002:a37:15a5:: with SMTP id 37-v6mr4809914qkv.279.1539930051132; Thu, 18 Oct 2018 23:20:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539930051; cv=none; d=google.com; s=arc-20160816; b=MCirnBZYUc5bXbuHKDkmoftnFPpPz1c3bu3nXB9LqsPU7lbXEnoBq8CVYi3k7CBhyT 35m9B54nZ0uWzbBM5Wd7lIoIwC/ar4LeDMV1z5r/X0Act45QW0FYKF5E2JyFoF62+bz4 OC++cx38NSrprZw4MM3eylY1+Y+J1fx2KrOwTbQYDitPkWE18urKLZG0V+3Wxqu29cTF Mb6kMEhHJAgYLTJyOPThBpWeTTOSYpMUB26wCEP4w7jPEtKtVp/wBdwsCeMI0hXXN3d+ zoOgg4RCVJh/po+WM+aophcpj//DwYaeY4LPXr3XRSYK0cBh9wFtIwsiuGZuveCyxpky a7yg== 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=co7JbT0NTKhwEIVbXq3uW8PxRjMU/VzANbjq0dvGlrg=; b=YFQ0CLq/Nd2Etb5o7Mm9Qf7+F4jDR8urlEYBBDNUsetMUswTzt62jaSB5932rUyuvb vWpVEXREAzSQUbuCeI9ItAF3axkH+EyFFWFeLrP3+9deNRuX7y7yT3ZrARq0S3wcCc8n XnYkbEcDIohSUZONFvc5ZQyNX01KHff6xXFDmIXPefep88DVPknsXS2W61W0mev2tcCN RTxqzGlynGSxaLF0cAiL8iqjDXT+qu0Vsd9vxximNq4XkreT7kLLJhfa1nXjHMywR1FI a3OHt0u3rfQhKWNAuv+GGuGdf9nce4bAyBEhyz1wQMUclgAXlxIN2Od5p6jUuUxhY7ab hkgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=R1ufR1A0; 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 h50-v6si303215qtc.140.2018.10.18.23.20.50 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 18 Oct 2018 23:20:51 -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=R1ufR1A0; 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]:47286 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDO9S-0007vm-I8 for patch@linaro.org; Fri, 19 Oct 2018 02:20:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39195) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDNwh-0004Qw-3d for qemu-devel@nongnu.org; Fri, 19 Oct 2018 02:07:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gDNwf-0002l0-Au for qemu-devel@nongnu.org; Fri, 19 Oct 2018 02:07:38 -0400 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]:39361) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gDNwe-0002KU-Kh for qemu-devel@nongnu.org; Fri, 19 Oct 2018 02:07:37 -0400 Received: by mail-pf1-x42e.google.com with SMTP id c25-v6so16004699pfe.6 for ; Thu, 18 Oct 2018 23:07:24 -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=co7JbT0NTKhwEIVbXq3uW8PxRjMU/VzANbjq0dvGlrg=; b=R1ufR1A0t3RFw05U9PRDPa2BcODDRWIJuVjs9M0jJfTEJKJAdKgtJsQoAVaKy7FxKj MjqjSInkFiRY6dFFsJSY6YbWBLaOmQad6Z1kf48luFeOQUP3xYLFtYasBZK3xAkmhyrD HqmU0tyOxLRzuNDTB2HT1G/d9M+SjdXsyZi8I= 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=co7JbT0NTKhwEIVbXq3uW8PxRjMU/VzANbjq0dvGlrg=; b=HOa1+DPAwxlBqECRFeou60Ma5hJzO5G9RKnmoDbXndK/R5vwmWynaWMKgJuck825SP ijreAi13EflRQCfoka2mGRd9lZggk9Sprdx6MTT9LpYfKRXZCK0ArgGRLFFUDAdLSMJZ 12ZXvj7hGIVDL/G8gorQN660LF1d8FHlF1oQe+UH7GvoL92NIf3DkRHKbZP7lgQJkYZD ay3QCnzXv93Y4ay7B/e8jUz9Yn2jMAwx5jKhLWHvYlx+CEjLAyH92q1b/6x3biNTXFVS Akybm2MeK2SJFPwe6Mv8/BIkCLpE0GeJa0utkbJfiMFft2KwbcTbejo418NYtt+C0THn JdoQ== X-Gm-Message-State: ABuFfohBnb3J5s9VowhiKw1B08W1I2JBycqIu7jGoFGMWcGeWq2SI5E5 ssD7S7on71/aTUcu55+9Tg96NaPkt3I= X-Received: by 2002:a63:9809:: with SMTP id q9-v6mr12917171pgd.128.1539929243473; Thu, 18 Oct 2018 23:07:23 -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.22 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Oct 2018 23:07:22 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 18 Oct 2018 23:06:53 -0700 Message-Id: <20181019060656.7968-19-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::42e Subject: [Qemu-devel] [PULL v2 18/21] target/s390x: Split do_cdsg, do_lpq, do_stpq 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 Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Reviewed-by: David Hildenbrand Signed-off-by: Richard Henderson --- target/s390x/mem_helper.c | 128 ++++++++++++++++++-------------------- 1 file changed, 61 insertions(+), 67 deletions(-) -- 2.17.2 diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index e106f61b4e..b5858d2fa2 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -1380,57 +1380,58 @@ uint32_t HELPER(trXX)(CPUS390XState *env, uint32_t r1, uint32_t r2, return cc; } -static void do_cdsg(CPUS390XState *env, uint64_t addr, - uint32_t r1, uint32_t r3, bool parallel) +void HELPER(cdsg)(CPUS390XState *env, uint64_t addr, + uint32_t r1, uint32_t r3) { uintptr_t ra = GETPC(); Int128 cmpv = int128_make128(env->regs[r1 + 1], env->regs[r1]); Int128 newv = int128_make128(env->regs[r3 + 1], env->regs[r3]); Int128 oldv; + uint64_t oldh, oldl; bool fail; - if (parallel) { -#if !HAVE_CMPXCHG128 - cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); -#else - int mem_idx = cpu_mmu_index(env, false); - TCGMemOpIdx oi = make_memop_idx(MO_TEQ | MO_ALIGN_16, mem_idx); - oldv = helper_atomic_cmpxchgo_be_mmu(env, addr, cmpv, newv, oi, ra); - fail = !int128_eq(oldv, cmpv); -#endif - } else { - uint64_t oldh, oldl; + check_alignment(env, addr, 16, ra); - check_alignment(env, addr, 16, ra); + oldh = cpu_ldq_data_ra(env, addr + 0, ra); + oldl = cpu_ldq_data_ra(env, addr + 8, ra); - oldh = cpu_ldq_data_ra(env, addr + 0, ra); - oldl = cpu_ldq_data_ra(env, addr + 8, ra); - - oldv = int128_make128(oldl, oldh); - fail = !int128_eq(oldv, cmpv); - if (fail) { - newv = oldv; - } - - cpu_stq_data_ra(env, addr + 0, int128_gethi(newv), ra); - cpu_stq_data_ra(env, addr + 8, int128_getlo(newv), ra); + oldv = int128_make128(oldl, oldh); + fail = !int128_eq(oldv, cmpv); + if (fail) { + newv = oldv; } + cpu_stq_data_ra(env, addr + 0, int128_gethi(newv), ra); + cpu_stq_data_ra(env, addr + 8, int128_getlo(newv), ra); + env->cc_op = fail; env->regs[r1] = int128_gethi(oldv); env->regs[r1 + 1] = int128_getlo(oldv); } -void HELPER(cdsg)(CPUS390XState *env, uint64_t addr, - uint32_t r1, uint32_t r3) -{ - do_cdsg(env, addr, r1, r3, false); -} - void HELPER(cdsg_parallel)(CPUS390XState *env, uint64_t addr, uint32_t r1, uint32_t r3) { - do_cdsg(env, addr, r1, r3, true); + uintptr_t ra = GETPC(); + Int128 cmpv = int128_make128(env->regs[r1 + 1], env->regs[r1]); + Int128 newv = int128_make128(env->regs[r3 + 1], env->regs[r3]); + int mem_idx; + TCGMemOpIdx oi; + Int128 oldv; + bool fail; + + if (!HAVE_CMPXCHG128) { + cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); + } + + mem_idx = cpu_mmu_index(env, false); + oi = make_memop_idx(MO_TEQ | MO_ALIGN_16, mem_idx); + oldv = helper_atomic_cmpxchgo_be_mmu(env, addr, cmpv, newv, oi, ra); + fail = !int128_eq(oldv, cmpv); + + env->cc_op = fail; + env->regs[r1] = int128_gethi(oldv); + env->regs[r1 + 1] = int128_getlo(oldv); } static uint32_t do_csst(CPUS390XState *env, uint32_t r3, uint64_t a1, @@ -2097,16 +2098,25 @@ uint64_t HELPER(lra)(CPUS390XState *env, uint64_t addr) #endif /* load pair from quadword */ -static uint64_t do_lpq(CPUS390XState *env, uint64_t addr, bool parallel) +uint64_t HELPER(lpq)(CPUS390XState *env, uint64_t addr) { uintptr_t ra = GETPC(); uint64_t hi, lo; - if (!parallel) { - check_alignment(env, addr, 16, ra); - hi = cpu_ldq_data_ra(env, addr + 0, ra); - lo = cpu_ldq_data_ra(env, addr + 8, ra); - } else if (HAVE_ATOMIC128) { + check_alignment(env, addr, 16, ra); + hi = cpu_ldq_data_ra(env, addr + 0, ra); + lo = cpu_ldq_data_ra(env, addr + 8, ra); + + env->retxl = lo; + return hi; +} + +uint64_t HELPER(lpq_parallel)(CPUS390XState *env, uint64_t addr) +{ + uintptr_t ra = GETPC(); + uint64_t hi, lo; + + if (HAVE_ATOMIC128) { int mem_idx = cpu_mmu_index(env, false); TCGMemOpIdx oi = make_memop_idx(MO_TEQ | MO_ALIGN_16, mem_idx); Int128 v = helper_atomic_ldo_be_mmu(env, addr, oi, ra); @@ -2120,27 +2130,23 @@ static uint64_t do_lpq(CPUS390XState *env, uint64_t addr, bool parallel) return hi; } -uint64_t HELPER(lpq)(CPUS390XState *env, uint64_t addr) -{ - return do_lpq(env, addr, false); -} - -uint64_t HELPER(lpq_parallel)(CPUS390XState *env, uint64_t addr) -{ - return do_lpq(env, addr, true); -} - /* store pair to quadword */ -static void do_stpq(CPUS390XState *env, uint64_t addr, - uint64_t low, uint64_t high, bool parallel) +void HELPER(stpq)(CPUS390XState *env, uint64_t addr, + uint64_t low, uint64_t high) { uintptr_t ra = GETPC(); - if (!parallel) { - check_alignment(env, addr, 16, ra); - cpu_stq_data_ra(env, addr + 0, high, ra); - cpu_stq_data_ra(env, addr + 8, low, ra); - } else if (HAVE_ATOMIC128) { + check_alignment(env, addr, 16, ra); + cpu_stq_data_ra(env, addr + 0, high, ra); + cpu_stq_data_ra(env, addr + 8, low, ra); +} + +void HELPER(stpq_parallel)(CPUS390XState *env, uint64_t addr, + uint64_t low, uint64_t high) +{ + uintptr_t ra = GETPC(); + + if (HAVE_ATOMIC128) { int mem_idx = cpu_mmu_index(env, false); TCGMemOpIdx oi = make_memop_idx(MO_TEQ | MO_ALIGN_16, mem_idx); Int128 v = int128_make128(low, high); @@ -2150,18 +2156,6 @@ static void do_stpq(CPUS390XState *env, uint64_t addr, } } -void HELPER(stpq)(CPUS390XState *env, uint64_t addr, - uint64_t low, uint64_t high) -{ - do_stpq(env, addr, low, high, false); -} - -void HELPER(stpq_parallel)(CPUS390XState *env, uint64_t addr, - uint64_t low, uint64_t high) -{ - do_stpq(env, addr, low, high, true); -} - /* Execute instruction. This instruction executes an insn modified with the contents of r1. It does not change the executed instruction in memory; it does not change the program counter. From patchwork Fri Oct 19 06:06:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 149232 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp2911875lji; Thu, 18 Oct 2018 23:18:25 -0700 (PDT) X-Google-Smtp-Source: ACcGV62pIXHYjS9YW1VJWe+9ezZRZlHYKGg+UGc9zA59KX3qsUlLbjmoV2o24jq5CqFRNs14kfJt X-Received: by 2002:a37:8fc7:: with SMTP id r190-v6mr31614785qkd.36.1539929905824; Thu, 18 Oct 2018 23:18:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539929905; cv=none; d=google.com; s=arc-20160816; b=op1c8OubW6krShZqo3sTZMUGJksSAv3QoDTwg7Kru8UACGBAy+lGVkiNHEVW3mBXA+ 7dPqBnWcUXlY+HJme1/PT6Obfp84mUUOg4SG22Ot1FSODROiZN/jYiIfm/k3NG2yo1Hk UUEZ/BxdZOIX6Qdy7tgvnTNEllYWhzduKSfibnjhEUeIWFim9xGnnswVZw7YBD3iAOsA cRr/UzYaOjMWwamqibhvGOWCdiZtFWyv/ZiKv7Z+YrC1Y5JMFirAFc1xKQvbbr7I6psJ 4AP5w6VEfVc/RKD1cdJMUZUjOdPxcbykhmZmyTvypEX+2y+q7XG5iXHCkhnC4+IsU6X0 CuSQ== 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=d0dyaKvSPopezwzsfmkll4fXI/kC81rwwkatVdVGoD8=; b=RvMoxdRfPxhvflzY7mo+7zYQn3RD+NZll7oTFIYU8scFt7AupIDRGbXGMOgOpLehfB PCMO/aHhy4Sh9uoFIcmIwUbSaWnq8U3hsSdpn9ZkIdUbl9tyEufYd6VkQxaz3E687qZI eG+F7mUc+h/64a7KqAHMT+JQhPJerEZtVEyNY7xNiZoKCsenAxaqwcRBnK8MSFO2MVJU 6PXiPgsMeOEnHpKGJRZxqzftZcHONpmFHU3fiIzT7RRSg8aJ+ZEW4DGFj1TO3UoGoXUa v1qFQE1jGNbD+kKWy/Gmo4supAOz7wsRT2QcM28trMrcMFCiMewj8nn2oO9CepH6bSYK uaxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=j+4PHveC; 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 k189-v6si2579391qkf.123.2018.10.18.23.18.25 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 18 Oct 2018 23:18:25 -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=j+4PHveC; 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]:47273 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDO77-00068D-8t for patch@linaro.org; Fri, 19 Oct 2018 02:18:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39208) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDNwh-0004SC-EK for qemu-devel@nongnu.org; Fri, 19 Oct 2018 02:07:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gDNwf-0002m3-Ip for qemu-devel@nongnu.org; Fri, 19 Oct 2018 02:07:39 -0400 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:38379) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gDNwf-0002Lt-2N for qemu-devel@nongnu.org; Fri, 19 Oct 2018 02:07:37 -0400 Received: by mail-pg1-x542.google.com with SMTP id f8-v6so15301185pgq.5 for ; Thu, 18 Oct 2018 23:07:26 -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=d0dyaKvSPopezwzsfmkll4fXI/kC81rwwkatVdVGoD8=; b=j+4PHveCmgXcXlqpKcbiLkbgA7dpjxZcRqcsgLW32kuy9mS4/GjecwIIGKLtOVohpe F3jrzjv8/2iXcAClGu6BfuE4OqVfAGCN7Xkfoi9R1RmZ7yFbrN4wQ12rFD/CaRpYPvOh E69A4E3KfQUCoPzzWpWZz+CK3FMbYNFJzsmxg= 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=d0dyaKvSPopezwzsfmkll4fXI/kC81rwwkatVdVGoD8=; b=OvP5CptYhHrf5aU1g/SDvyEFEhfRYsbErW7DI6TqDCcmoX+mM5EajMOuKOzK6HaaoL HXbpmWU10+bzYBiGdtGcFK8HB3sztXrc5V/zYqHXqjB+QtJyKCaytaS7nsYEhhB2j2dV xBGra/dbhBAG2AqNwsVFvU4CrC8ASSRTE/xgpL3sFffApc8AcNZuzvRxyEcRpscace7D cD82142yUZVXkJ2ihTpwRzC6AuthE/OYOAR7UNttunkzX83x2csfDlKBzq5SeRr2CMzt dMGcJGKxcaxuggyoEZZbCUPRuqiFl06ekGvWrHncIipzJfoVeqN6TNQHeIUWSghNI73D w+9w== X-Gm-Message-State: ABuFfogSCynhjn/sjKWhzszE0Hg29oneinEoVFJK9mKanxI2t1kEQlwT iuZc5stxdqZ/m0/IdIypncs/6Uq1Y7g= X-Received: by 2002:a63:3203:: with SMTP id y3-v6mr31550905pgy.101.1539929244994; Thu, 18 Oct 2018 23:07:24 -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.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Oct 2018 23:07:23 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 18 Oct 2018 23:06:54 -0700 Message-Id: <20181019060656.7968-20-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::542 Subject: [Qemu-devel] [PULL v2 19/21] target/s390x: Skip wout, cout helpers if op helper does not return 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 Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" When op raises an exception, it may not have initialized the output temps that would be written back by wout or cout. Reviewed-by: David Hildenbrand Signed-off-by: Richard Henderson --- target/s390x/translate.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) -- 2.17.2 diff --git a/target/s390x/translate.c b/target/s390x/translate.c index 18861cd186..a7bd689337 100644 --- a/target/s390x/translate.c +++ b/target/s390x/translate.c @@ -1128,11 +1128,19 @@ struct DisasInsn { const char *name; + /* Pre-process arguments before HELP_OP. */ void (*help_in1)(DisasContext *, DisasFields *, DisasOps *); void (*help_in2)(DisasContext *, DisasFields *, DisasOps *); void (*help_prep)(DisasContext *, DisasFields *, DisasOps *); + + /* + * Post-process output after HELP_OP. + * Note that these are not called if HELP_OP returns DISAS_NORETURN. + */ void (*help_wout)(DisasContext *, DisasFields *, DisasOps *); void (*help_cout)(DisasContext *, DisasOps *); + + /* Implement the operation itself. */ DisasJumpType (*help_op)(DisasContext *, DisasOps *); uint64_t data; @@ -6125,11 +6133,13 @@ static DisasJumpType translate_one(CPUS390XState *env, DisasContext *s) if (insn->help_op) { ret = insn->help_op(s, &o); } - if (insn->help_wout) { - insn->help_wout(s, &f, &o); - } - if (insn->help_cout) { - insn->help_cout(s, &o); + if (ret != DISAS_NORETURN) { + if (insn->help_wout) { + insn->help_wout(s, &f, &o); + } + if (insn->help_cout) { + insn->help_cout(s, &o); + } } /* Free any temporaries created by the helpers. */ From patchwork Fri Oct 19 06:06:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 149235 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp2914075lji; Thu, 18 Oct 2018 23:21:16 -0700 (PDT) X-Google-Smtp-Source: ACcGV63l53VcLvoXKh/K8ycoLvukPpMH6H/DLsfitccF1dRCspLjLWvjHLjhwEGWh+yRfzGQvaqN X-Received: by 2002:ac8:6616:: with SMTP id c22-v6mr30779271qtp.199.1539930076296; Thu, 18 Oct 2018 23:21:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539930076; cv=none; d=google.com; s=arc-20160816; b=jz3f0UnBC2bZV6FTRvIqRGesbHleQxAY8+BDQO4GvODQ3it3KQvjs8tgf/Q/vrD9xv 6HBnTf4zhzqgJOw9Z07vUPlcF0g0fu6IT8tQKpSAEyOESWLmvnjxiAXjUzNtI1N0/5AO 0r81CbnPe/qgyfuYFNxebs8Mz/EhyomDwEkY0MRiXCqZ2jvaqkS3RHiyc6B1h8uSuAH/ 0iRokkT4Wp69eRUGWQNXvFWQRQsPI9qLtMN9LxNojSIidnh9QbKNbHY3vH6xWqFDQ4Rb y3sy5uFM0UBHhT0mTgDf00o3qRAfzJrmtN+BM/7rOZeQFl0lNPf4IWcwYZrGDcQNjX9q J0Tw== 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=xbiOv5TcJ4wgSOcnZ3lHtDhz8sB5I99xM4Z83wc2zVg=; b=tBH2zkU1uaSgxeENCTuWodBTL8WQQmWsiUxHZ7rIKTDETzUzTcjLY7ARItbNFUJN1u fHXIXXUmey1w+mb/i8/hAOZgtD0H7fNQ7MdlIoi3ZtpzazzVvulvgy4ietBPIoE/mJ+4 dSapjLGu8qoUGF6UoFLyS64nyrVEuimWzScO46anR5XgaVOfuVZ2LCtgsnHJv9uToxSP V4G00QrFAjp17wZZLK/hJCQeksFUU4i6JxESDoykviSvGUem0LMpFq9zZIIWjPjv0iP0 1GjxT8hBDzZlBmrVe+Xo4fSt1f9zZLTRpbf0NULeOvKivgOXVPdfl5uKmTkGUhp6jmOl PxaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ErxLqeww; 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 k27si4024358qvf.30.2018.10.18.23.21.16 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 18 Oct 2018 23:21:16 -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=ErxLqeww; 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]:47290 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDO9r-0007zK-Pg for patch@linaro.org; Fri, 19 Oct 2018 02:21:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39197) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDNwh-0004RQ-6Z for qemu-devel@nongnu.org; Fri, 19 Oct 2018 02:07:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gDNwf-0002lW-Dj for qemu-devel@nongnu.org; Fri, 19 Oct 2018 02:07:38 -0400 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]:32963) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gDNwe-0002Mm-Oa for qemu-devel@nongnu.org; Fri, 19 Oct 2018 02:07:37 -0400 Received: by mail-pg1-x536.google.com with SMTP id y18-v6so15320162pge.0 for ; Thu, 18 Oct 2018 23:07:27 -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=xbiOv5TcJ4wgSOcnZ3lHtDhz8sB5I99xM4Z83wc2zVg=; b=ErxLqeww6aXFNH4/HGr6Gdse2OBNyV46Bei7anqxeD+yDfThSFKsAk6hC+0h3FxCId Ye0ezDZpl1nkdYdohzMlAcqX+UlDPkSBeLh3mHMs1/iXanbjyHK8hCXdGUoLvxEe/o51 +uSzmz+WijdQf5UGv2bBkcyiW9c7U2s8jbT2g= 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=xbiOv5TcJ4wgSOcnZ3lHtDhz8sB5I99xM4Z83wc2zVg=; b=GufINeEw6rQfubo+JLEOqndDdgfidRlxbcFJWAhIXuuB4xFUuYtmVoLwf86q5dw+Uu o5I4gu45pii4zNFhednxULvgstVMVPW98D+6HyRQvErmtO556B6FE+A26Z+y9SK3Hx79 /P6Ye3bWaAte7s/HOQ60GijJLahx/nhnZVBRoKIHmbc7RosmOREvwwtG5RP5DFu4q287 nJ6hXR+c1v1Z/IHlgRuSWvOuZbVOipCHI73MT1rbF1UUIk0bvf9u5Hp4eqCWb2mAGOIk eb8AHN1FELG+xIiME5KCMoK+Zvcd5lxLcANEimU5fzfdFVvwOU8j/E270n5bTNVLJeNp 6idg== X-Gm-Message-State: ABuFfohd3Erm4ARpHsZ9LpEjmlK9sxFA3mO08OKzSUy7isBljvJqBKMg R84Hs+stTPr3u1IRL19jn6nzRzke8aM= X-Received: by 2002:a62:2bc2:: with SMTP id r185-v6mr33393418pfr.21.1539929246392; Thu, 18 Oct 2018 23:07:26 -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.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Oct 2018 23:07:25 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 18 Oct 2018 23:06:55 -0700 Message-Id: <20181019060656.7968-21-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::536 Subject: [Qemu-devel] [PULL v2 20/21] target/s390x: Check HAVE_ATOMIC128 and HAVE_CMPXCHG128 at translate 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 Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Reviewed-by: David Hildenbrand Signed-off-by: Richard Henderson --- target/s390x/mem_helper.c | 40 +++++++++++++++++++-------------------- target/s390x/translate.c | 25 +++++++++++++++++------- 2 files changed, 38 insertions(+), 27 deletions(-) -- 2.17.2 diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index b5858d2fa2..490c43e6e6 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -1420,9 +1420,7 @@ void HELPER(cdsg_parallel)(CPUS390XState *env, uint64_t addr, Int128 oldv; bool fail; - if (!HAVE_CMPXCHG128) { - cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); - } + assert(HAVE_CMPXCHG128); mem_idx = cpu_mmu_index(env, false); oi = make_memop_idx(MO_TEQ | MO_ALIGN_16, mem_idx); @@ -2115,16 +2113,17 @@ uint64_t HELPER(lpq_parallel)(CPUS390XState *env, uint64_t addr) { uintptr_t ra = GETPC(); uint64_t hi, lo; + int mem_idx; + TCGMemOpIdx oi; + Int128 v; - if (HAVE_ATOMIC128) { - int mem_idx = cpu_mmu_index(env, false); - TCGMemOpIdx oi = make_memop_idx(MO_TEQ | MO_ALIGN_16, mem_idx); - Int128 v = helper_atomic_ldo_be_mmu(env, addr, oi, ra); - hi = int128_gethi(v); - lo = int128_getlo(v); - } else { - cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); - } + assert(HAVE_ATOMIC128); + + mem_idx = cpu_mmu_index(env, false); + oi = make_memop_idx(MO_TEQ | MO_ALIGN_16, mem_idx); + v = helper_atomic_ldo_be_mmu(env, addr, oi, ra); + hi = int128_gethi(v); + lo = int128_getlo(v); env->retxl = lo; return hi; @@ -2145,15 +2144,16 @@ void HELPER(stpq_parallel)(CPUS390XState *env, uint64_t addr, uint64_t low, uint64_t high) { uintptr_t ra = GETPC(); + int mem_idx; + TCGMemOpIdx oi; + Int128 v; - if (HAVE_ATOMIC128) { - int mem_idx = cpu_mmu_index(env, false); - TCGMemOpIdx oi = make_memop_idx(MO_TEQ | MO_ALIGN_16, mem_idx); - Int128 v = int128_make128(low, high); - helper_atomic_sto_be_mmu(env, addr, v, oi, ra); - } else { - cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); - } + assert(HAVE_ATOMIC128); + + mem_idx = cpu_mmu_index(env, false); + oi = make_memop_idx(MO_TEQ | MO_ALIGN_16, mem_idx); + v = int128_make128(low, high); + helper_atomic_sto_be_mmu(env, addr, v, oi, ra); } /* Execute instruction. This instruction executes an insn modified with diff --git a/target/s390x/translate.c b/target/s390x/translate.c index a7bd689337..b5bd56b7ee 100644 --- a/target/s390x/translate.c +++ b/target/s390x/translate.c @@ -44,6 +44,7 @@ #include "trace-tcg.h" #include "exec/translator.h" #include "exec/log.h" +#include "qemu/atomic128.h" /* Information that (most) every instruction needs to manipulate. */ @@ -2040,6 +2041,7 @@ static DisasJumpType op_cdsg(DisasContext *s, DisasOps *o) int r3 = get_field(s->fields, r3); int d2 = get_field(s->fields, d2); int b2 = get_field(s->fields, b2); + DisasJumpType ret = DISAS_NEXT; TCGv_i64 addr; TCGv_i32 t_r1, t_r3; @@ -2047,17 +2049,20 @@ static DisasJumpType op_cdsg(DisasContext *s, DisasOps *o) addr = get_address(s, 0, b2, d2); t_r1 = tcg_const_i32(r1); t_r3 = tcg_const_i32(r3); - if (tb_cflags(s->base.tb) & CF_PARALLEL) { + if (!(tb_cflags(s->base.tb) & CF_PARALLEL)) { + gen_helper_cdsg(cpu_env, addr, t_r1, t_r3); + } else if (HAVE_CMPXCHG128) { gen_helper_cdsg_parallel(cpu_env, addr, t_r1, t_r3); } else { - gen_helper_cdsg(cpu_env, addr, t_r1, t_r3); + gen_helper_exit_atomic(cpu_env); + ret = DISAS_NORETURN; } tcg_temp_free_i64(addr); tcg_temp_free_i32(t_r1); tcg_temp_free_i32(t_r3); set_cc_static(s); - return DISAS_NEXT; + return ret; } static DisasJumpType op_csst(DisasContext *s, DisasOps *o) @@ -3034,10 +3039,13 @@ static DisasJumpType op_lpd(DisasContext *s, DisasOps *o) static DisasJumpType op_lpq(DisasContext *s, DisasOps *o) { - if (tb_cflags(s->base.tb) & CF_PARALLEL) { + if (!(tb_cflags(s->base.tb) & CF_PARALLEL)) { + gen_helper_lpq(o->out, cpu_env, o->in2); + } else if (HAVE_ATOMIC128) { gen_helper_lpq_parallel(o->out, cpu_env, o->in2); } else { - gen_helper_lpq(o->out, cpu_env, o->in2); + gen_helper_exit_atomic(cpu_env); + return DISAS_NORETURN; } return_low128(o->out2); return DISAS_NEXT; @@ -4414,10 +4422,13 @@ static DisasJumpType op_stmh(DisasContext *s, DisasOps *o) static DisasJumpType op_stpq(DisasContext *s, DisasOps *o) { - if (tb_cflags(s->base.tb) & CF_PARALLEL) { + if (!(tb_cflags(s->base.tb) & CF_PARALLEL)) { + gen_helper_stpq(cpu_env, o->in2, o->out2, o->out); + } else if (HAVE_ATOMIC128) { gen_helper_stpq_parallel(cpu_env, o->in2, o->out2, o->out); } else { - gen_helper_stpq(cpu_env, o->in2, o->out2, o->out); + gen_helper_exit_atomic(cpu_env); + return DISAS_NORETURN; } return DISAS_NEXT; } From patchwork Fri Oct 19 06:06:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 149229 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp2910937lji; Thu, 18 Oct 2018 23:17:17 -0700 (PDT) X-Google-Smtp-Source: ACcGV63gM4F0gD85KUOEXKfcBchn45wm7nP7sIenxbe5j4JOcSfjNKoy7cmJ/3oEqSYRzBjhCOEm X-Received: by 2002:ac8:3a82:: with SMTP id x2-v6mr32384584qte.342.1539929837378; Thu, 18 Oct 2018 23:17:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539929837; cv=none; d=google.com; s=arc-20160816; b=Ip6j/PvYkYM1sBYEUsRe/lB7/Adbsc7wSxY82Ry7jBFxl6qK1QEbI/L62KkOMpEUst vEhUI+AbAfFXRZz5cgkcA7MkGvDMYJTJz2q5ugkiv/tHM2wU+nhgGfwFBshuo3V4aA9A hojuy4+5kC0ArOEkswyow8j7MrceNHHr+rG8GBVob5IHDGWzLmTl1oRoOF1X96nSxKAr 8xlntTBma077jbIcOozYt8hGjj4FJGH+9ypdZK9oIrn2J4IoY0K/7nG7Hq2SIEKIlusc 0oVL9L8BGNtpK7a/Dph7U4Uglcdg+C6EzaGcx7N4bI7XFeiokJfbydpNEYcAbsHAL1/D Z1mQ== 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=UaQoW0X3h57lcIqJE5IM63G9fD5eqtJkNjrcpKzJ3Eo=; b=gsWv/O2FQbwG361NtzlZ+5/ii6ynqvqMOtcFrkur+5FU29Vgy71u3pMV060Tj8156D A/2tPiTvdMYnSgMuAaBLabNhVT1pPuCt6gRw/nozG/70ElaBKeS4Awyv24ZzDt9GezQQ 9I6YXwtVjMbzYCQZiznrU+4UkNUm/jqIzd2MK5GNbxDLknH0WN8oizTLkMuRmAT8rPxM 1eydrygLqCEkOtEiiRd356HMCb96aDkCvv5PnrRP/SHUv3Xy+Vld+7/6eHAsViDqULu8 T9s6wiGXRfXjutn0hQH2IutY8wsrMJwG5dRozFYJHlt7ak1XMZinazfL0I5l0DKY34+v aong== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=izYDI8yw; 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 l10-v6si68926qtq.334.2018.10.18.23.17.17 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 18 Oct 2018 23:17:17 -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=izYDI8yw; 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]:47270 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDO60-0004if-Qs for patch@linaro.org; Fri, 19 Oct 2018 02:17:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39349) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDNwl-0004Uo-LI for qemu-devel@nongnu.org; Fri, 19 Oct 2018 02:07:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gDNwg-0002nF-3K for qemu-devel@nongnu.org; Fri, 19 Oct 2018 02:07:43 -0400 Received: from mail-pg1-x533.google.com ([2607:f8b0:4864:20::533]:40766) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gDNwf-0002O4-FE for qemu-devel@nongnu.org; Fri, 19 Oct 2018 02:07:37 -0400 Received: by mail-pg1-x533.google.com with SMTP id n31-v6so15308166pgm.7 for ; Thu, 18 Oct 2018 23:07:29 -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=UaQoW0X3h57lcIqJE5IM63G9fD5eqtJkNjrcpKzJ3Eo=; b=izYDI8ywLvyeC8CCsKI+ck2N6pFKUT8pZlx429kf4ONlf7mXU5T4Z8otqzLIWXzgNv JY+WCfPgqhfEm2qNypToB5l8muHUhS7J2aog60C7uVgg1BDm9RLVENvQKDrZzLy/C1gB 6W/kKNr82zK6Dgp51DOSEl76/LoHknYp59T7g= 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=UaQoW0X3h57lcIqJE5IM63G9fD5eqtJkNjrcpKzJ3Eo=; b=tuzyWGwOD6G38n0BYMpO1NiUfkIHpeY1m9nr4QWxyReQkhg1jMTyHx4A0w20YVgltY YIkhjvg9gq1Im/Pg/6HXtINyx3a0ayCbtf1zwO7CCoMPx+ZAZMuK19tVilLy5LmsAf0l f5U8KlhKOI1nxTxEDhKDlyicMMjRrF3iE9T7Il495hB1G57FqiBfOHrEErCltM3SkjE5 9nXj9Ifuwx8yajHSIUskqowlfVpMsdc7MXXCKfLG7qP5VqNm/uAnOFXwE+dVAvhhwUJF oyXLv7ZB1D9uquRpzGNSfpJ6bGMoZSkQcnLXUfU1ZHv9Dalza5jKuFgCJanBHI0nQzXH MjQA== X-Gm-Message-State: ABuFfojuyR8o2y+w03BNkBPAKt9yzZkmglAsUjSmPsTMuQxqHFjV7A1r VPIridZUxvFdLxUehp2kT6qQvdrqXWM= X-Received: by 2002:a62:7e81:: with SMTP id z123-v6mr33275389pfc.139.1539929247853; Thu, 18 Oct 2018 23:07:27 -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.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Oct 2018 23:07:26 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 18 Oct 2018 23:06:56 -0700 Message-Id: <20181019060656.7968-22-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::533 Subject: [Qemu-devel] [PULL v2 21/21] cputlb: read CPUTLBEntry.addr_write atomically 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" Updates can come from other threads, so readers that do not take tlb_lock must use atomic_read to avoid undefined behaviour (UB). This completes the conversion to tlb_lock. This conversion results on average in no performance loss, as the following experiments (run on an Intel i7-6700K CPU @ 4.00GHz) show. 1. aarch64 bootup+shutdown test: - Before: Performance counter stats for 'taskset -c 0 ../img/aarch64/die.sh' (10 runs): 7487.087786 task-clock (msec) # 0.998 CPUs utilized ( +- 0.12% ) 31,574,905,303 cycles # 4.217 GHz ( +- 0.12% ) 57,097,908,812 instructions # 1.81 insns per cycle ( +- 0.08% ) 10,255,415,367 branches # 1369.747 M/sec ( +- 0.08% ) 173,278,962 branch-misses # 1.69% of all branches ( +- 0.18% ) 7.504481349 seconds time elapsed ( +- 0.14% ) - After: Performance counter stats for 'taskset -c 0 ../img/aarch64/die.sh' (10 runs): 7462.441328 task-clock (msec) # 0.998 CPUs utilized ( +- 0.07% ) 31,478,476,520 cycles # 4.218 GHz ( +- 0.07% ) 57,017,330,084 instructions # 1.81 insns per cycle ( +- 0.05% ) 10,251,929,667 branches # 1373.804 M/sec ( +- 0.05% ) 173,023,787 branch-misses # 1.69% of all branches ( +- 0.11% ) 7.474970463 seconds time elapsed ( +- 0.07% ) 2. SPEC06int: SPEC06int (test set) [Y axis: Speedup over master] 1.15 +-+----+------+------+------+------+------+-------+------+------+------+------+------+------+----+-+ | | 1.1 +-+.................................+++.............................+ tlb-lock-v2 (m+++x) +-+ | +++ | +++ tlb-lock-v3 (spinl|ck) | | +++ | | +++ +++ | | | 1.05 +-+....+++...........####.........|####.+++.|......|.....###....+++...........+++....###.........+-+ | ### ++#| # |# |# ***### +++### +++#+# | +++ | #|# ### | 1 +-+++***+#++++####+++#++#++++++++++#++#+*+*++#++++#+#+****+#++++###++++###++++###++++#+#++++#+#+++-+ | *+* # #++# *** # #### *** # * *++# ****+# *| * # ****|# |# # #|# #+# # # | 0.95 +-+..*.*.#....#..#.*|*..#...#..#.*|*..#.*.*..#.*|.*.#.*++*.#.*++*+#.****.#....#+#....#.#..++#.#..+-+ | * * # # # *|* # # # *|* # * * # *++* # * * # * * # * |* # ++# # # # *** # | | * * # ++# # *+* # # # *|* # * * # * * # * * # * * # *++* # **** # ++# # * * # | 0.9 +-+..*.*.#...|#..#.*.*..#.++#..#.*|*..#.*.*..#.*..*.#.*..*.#.*..*.#.*..*.#.*.|*.#...|#.#..*.*.#..+-+ | * * # *** # * * # |# # *+* # * * # * * # * * # * * # * * # *++* # |# # * * # | 0.85 +-+..*.*.#..*|*..#.*.*..#.***..#.*.*..#.*.*..#.*..*.#.*..*.#.*..*.#.*..*.#.*..*.#.****.#..*.*.#..+-+ | * * # *+* # * * # *|* # * * # * * # * * # * * # * * # * * # * * # * |* # * * # | | * * # * * # * * # *+* # * * # * * # * * # * * # * * # * * # * * # * |* # * * # | 0.8 +-+..*.*.#..*.*..#.*.*..#.*.*..#.*.*..#.*.*..#.*..*.#.*..*.#.*..*.#.*..*.#.*..*.#.*++*.#..*.*.#..+-+ | * * # * * # * * # * * # * * # * * # * * # * * # * * # * * # * * # * * # * * # | 0.75 +-+--***##--***###-***###-***###-***###-***###-****##-****##-****##-****##-****##-****##--***##--+-+ 400.perlben401.bzip2403.gcc429.m445.gob456.hmme45462.libqua464.h26471.omnet473483.xalancbmkgeomean png: https://imgur.com/a/BHzpPTW Notes: - tlb-lock-v2 corresponds to an implementation with a mutex. - tlb-lock-v3 corresponds to the current implementation, i.e. a spinlock and a single lock acquisition in tlb_set_page_with_attrs. Signed-off-by: Emilio G. Cota Message-Id: <20181016153840.25877-1-cota@braap.org> Signed-off-by: Richard Henderson --- accel/tcg/softmmu_template.h | 12 ++++++------ include/exec/cpu_ldst.h | 11 ++++++++++- include/exec/cpu_ldst_template.h | 2 +- accel/tcg/cputlb.c | 19 +++++++++++++------ 4 files changed, 30 insertions(+), 14 deletions(-) -- 2.17.2 diff --git a/accel/tcg/softmmu_template.h b/accel/tcg/softmmu_template.h index 09538b5349..b0adea045e 100644 --- a/accel/tcg/softmmu_template.h +++ b/accel/tcg/softmmu_template.h @@ -280,7 +280,7 @@ void helper_le_st_name(CPUArchState *env, target_ulong addr, DATA_TYPE val, uintptr_t mmu_idx = get_mmuidx(oi); uintptr_t index = tlb_index(env, mmu_idx, addr); CPUTLBEntry *entry = tlb_entry(env, mmu_idx, addr); - target_ulong tlb_addr = entry->addr_write; + target_ulong tlb_addr = tlb_addr_write(entry); unsigned a_bits = get_alignment_bits(get_memop(oi)); uintptr_t haddr; @@ -295,7 +295,7 @@ void helper_le_st_name(CPUArchState *env, target_ulong addr, DATA_TYPE val, tlb_fill(ENV_GET_CPU(env), addr, DATA_SIZE, MMU_DATA_STORE, mmu_idx, retaddr); } - tlb_addr = entry->addr_write & ~TLB_INVALID_MASK; + tlb_addr = tlb_addr_write(entry) & ~TLB_INVALID_MASK; } /* Handle an IO access. */ @@ -325,7 +325,7 @@ void helper_le_st_name(CPUArchState *env, target_ulong addr, DATA_TYPE val, cannot evict the first. */ page2 = (addr + DATA_SIZE) & TARGET_PAGE_MASK; entry2 = tlb_entry(env, mmu_idx, page2); - if (!tlb_hit_page(entry2->addr_write, page2) + if (!tlb_hit_page(tlb_addr_write(entry2), page2) && !VICTIM_TLB_HIT(addr_write, page2)) { tlb_fill(ENV_GET_CPU(env), page2, DATA_SIZE, MMU_DATA_STORE, mmu_idx, retaddr); @@ -358,7 +358,7 @@ void helper_be_st_name(CPUArchState *env, target_ulong addr, DATA_TYPE val, uintptr_t mmu_idx = get_mmuidx(oi); uintptr_t index = tlb_index(env, mmu_idx, addr); CPUTLBEntry *entry = tlb_entry(env, mmu_idx, addr); - target_ulong tlb_addr = entry->addr_write; + target_ulong tlb_addr = tlb_addr_write(entry); unsigned a_bits = get_alignment_bits(get_memop(oi)); uintptr_t haddr; @@ -373,7 +373,7 @@ void helper_be_st_name(CPUArchState *env, target_ulong addr, DATA_TYPE val, tlb_fill(ENV_GET_CPU(env), addr, DATA_SIZE, MMU_DATA_STORE, mmu_idx, retaddr); } - tlb_addr = entry->addr_write & ~TLB_INVALID_MASK; + tlb_addr = tlb_addr_write(entry) & ~TLB_INVALID_MASK; } /* Handle an IO access. */ @@ -403,7 +403,7 @@ void helper_be_st_name(CPUArchState *env, target_ulong addr, DATA_TYPE val, cannot evict the first. */ page2 = (addr + DATA_SIZE) & TARGET_PAGE_MASK; entry2 = tlb_entry(env, mmu_idx, page2); - if (!tlb_hit_page(entry2->addr_write, page2) + if (!tlb_hit_page(tlb_addr_write(entry2), page2) && !VICTIM_TLB_HIT(addr_write, page2)) { tlb_fill(ENV_GET_CPU(env), page2, DATA_SIZE, MMU_DATA_STORE, mmu_idx, retaddr); diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h index f54d91ff68..959068495a 100644 --- a/include/exec/cpu_ldst.h +++ b/include/exec/cpu_ldst.h @@ -126,6 +126,15 @@ extern __thread uintptr_t helper_retaddr; /* The memory helpers for tcg-generated code need tcg_target_long etc. */ #include "tcg.h" +static inline target_ulong tlb_addr_write(const CPUTLBEntry *entry) +{ +#if TCG_OVERSIZED_GUEST + return entry->addr_write; +#else + return atomic_read(&entry->addr_write); +#endif +} + /* Find the TLB index corresponding to the mmu_idx + address pair. */ static inline uintptr_t tlb_index(CPUArchState *env, uintptr_t mmu_idx, target_ulong addr) @@ -439,7 +448,7 @@ static inline void *tlb_vaddr_to_host(CPUArchState *env, abi_ptr addr, tlb_addr = tlbentry->addr_read; break; case 1: - tlb_addr = tlbentry->addr_write; + tlb_addr = tlb_addr_write(tlbentry); break; case 2: tlb_addr = tlbentry->addr_code; diff --git a/include/exec/cpu_ldst_template.h b/include/exec/cpu_ldst_template.h index d21a0b59bf..0f061d47ef 100644 --- a/include/exec/cpu_ldst_template.h +++ b/include/exec/cpu_ldst_template.h @@ -177,7 +177,7 @@ glue(glue(glue(cpu_st, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env, addr = ptr; mmu_idx = CPU_MMU_INDEX; entry = tlb_entry(env, mmu_idx, addr); - if (unlikely(entry->addr_write != + if (unlikely(tlb_addr_write(entry) != (addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))))) { oi = make_memop_idx(SHIFT, mmu_idx); glue(glue(helper_ret_st, SUFFIX), MMUSUFFIX)(env, addr, v, oi, diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index 28b770a404..af57aca5e4 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -258,7 +258,7 @@ static inline bool tlb_hit_page_anyprot(CPUTLBEntry *tlb_entry, target_ulong page) { return tlb_hit_page(tlb_entry->addr_read, page) || - tlb_hit_page(tlb_entry->addr_write, page) || + tlb_hit_page(tlb_addr_write(tlb_entry), page) || tlb_hit_page(tlb_entry->addr_code, page); } @@ -855,7 +855,7 @@ static void io_writex(CPUArchState *env, CPUIOTLBEntry *iotlbentry, tlb_fill(cpu, addr, size, MMU_DATA_STORE, mmu_idx, retaddr); entry = tlb_entry(env, mmu_idx, addr); - tlb_addr = entry->addr_write; + tlb_addr = tlb_addr_write(entry); if (!(tlb_addr & ~(TARGET_PAGE_MASK | TLB_RECHECK))) { /* RAM access */ uintptr_t haddr = addr + entry->addend; @@ -904,7 +904,14 @@ static bool victim_tlb_hit(CPUArchState *env, size_t mmu_idx, size_t index, assert_cpu_is_self(ENV_GET_CPU(env)); for (vidx = 0; vidx < CPU_VTLB_SIZE; ++vidx) { CPUTLBEntry *vtlb = &env->tlb_v_table[mmu_idx][vidx]; - target_ulong cmp = *(target_ulong *)((uintptr_t)vtlb + elt_ofs); + target_ulong cmp; + + /* elt_ofs might correspond to .addr_write, so use atomic_read */ +#if TCG_OVERSIZED_GUEST + cmp = *(target_ulong *)((uintptr_t)vtlb + elt_ofs); +#else + cmp = atomic_read((target_ulong *)((uintptr_t)vtlb + elt_ofs)); +#endif if (cmp == page) { /* Found entry in victim tlb, swap tlb and iotlb. */ @@ -977,7 +984,7 @@ void probe_write(CPUArchState *env, target_ulong addr, int size, int mmu_idx, uintptr_t index = tlb_index(env, mmu_idx, addr); CPUTLBEntry *entry = tlb_entry(env, mmu_idx, addr); - if (!tlb_hit(entry->addr_write, addr)) { + if (!tlb_hit(tlb_addr_write(entry), addr)) { /* TLB entry is for a different page */ if (!VICTIM_TLB_HIT(addr_write, addr)) { tlb_fill(ENV_GET_CPU(env), addr, size, MMU_DATA_STORE, @@ -995,7 +1002,7 @@ static void *atomic_mmu_lookup(CPUArchState *env, target_ulong addr, size_t mmu_idx = get_mmuidx(oi); uintptr_t index = tlb_index(env, mmu_idx, addr); CPUTLBEntry *tlbe = tlb_entry(env, mmu_idx, addr); - target_ulong tlb_addr = tlbe->addr_write; + target_ulong tlb_addr = tlb_addr_write(tlbe); TCGMemOp mop = get_memop(oi); int a_bits = get_alignment_bits(mop); int s_bits = mop & MO_SIZE; @@ -1026,7 +1033,7 @@ static void *atomic_mmu_lookup(CPUArchState *env, target_ulong addr, tlb_fill(ENV_GET_CPU(env), addr, 1 << s_bits, MMU_DATA_STORE, mmu_idx, retaddr); } - tlb_addr = tlbe->addr_write & ~TLB_INVALID_MASK; + tlb_addr = tlb_addr_write(tlbe) & ~TLB_INVALID_MASK; } /* Notice an IO access or a needs-MMU-lookup access */