From nobody Tue May 7 18:39:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1493270482160811.6130928704932; Wed, 26 Apr 2017 22:21:22 -0700 (PDT) Received: from localhost ([::1]:58770 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3brk-0001zm-QB for importer@patchew.org; Thu, 27 Apr 2017 01:21:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56503) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3bq1-0000lC-4p for qemu-devel@nongnu.org; Thu, 27 Apr 2017 01:19:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d3bpx-0002Vu-WC for qemu-devel@nongnu.org; Thu, 27 Apr 2017 01:19:33 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:48440 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d3bpx-0002VS-QN for qemu-devel@nongnu.org; Thu, 27 Apr 2017 01:19:29 -0400 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v3R5Icp2093470 for ; Thu, 27 Apr 2017 01:19:28 -0400 Received: from e23smtp03.au.ibm.com (e23smtp03.au.ibm.com [202.81.31.145]) by mx0b-001b2d01.pphosted.com with ESMTP id 2a32a0r25w-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 27 Apr 2017 01:19:27 -0400 Received: from localhost by e23smtp03.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 27 Apr 2017 15:19:25 +1000 Received: from d23relay10.au.ibm.com (202.81.31.229) by e23smtp03.au.ibm.com (202.81.31.209) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 27 Apr 2017 15:19:24 +1000 Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay10.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v3R5JFeD66125904; Thu, 27 Apr 2017 15:19:23 +1000 Received: from d23av03.au.ibm.com (localhost [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v3R5IkIH003528; Thu, 27 Apr 2017 15:18:46 +1000 Received: from abhimanyu.ibmmodules.com ([9.85.81.18]) by d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v3R5Ifn8002984; Thu, 27 Apr 2017 15:18:44 +1000 From: Nikunj A Dadhania To: qemu-ppc@nongnu.org, david@gibson.dropbear.id.au Date: Thu, 27 Apr 2017 10:48:19 +0530 X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170427051824.30194-1-nikunj@linux.vnet.ibm.com> References: <20170427051824.30194-1-nikunj@linux.vnet.ibm.com> X-TM-AS-MML: disable x-cbid: 17042705-0008-0000-0000-00000125EA10 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17042705-0009-0000-0000-00000953B512 Message-Id: <20170427051824.30194-2-nikunj@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-04-27_04:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=2 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1704270085 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH v3 1/6] target/ppc: Emulate LL/SC using cmpxchg 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: bharata@linux.vnet.ibm.com, alex.bennee@linaro.org, qemu-devel@nongnu.org, nikunj@linux.vnet.ibm.com, rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Emulating LL/SC with cmpxchg is not correct, since it can suffer from the ABA problem. However, portable parallel code is written assuming only cmpxchg which means that in practice this is a viable alternative. Signed-off-by: Nikunj A Dadhania Reviewed-by: Richard Henderson --- target/ppc/translate.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/target/ppc/translate.c b/target/ppc/translate.c index f40b5a1..50b6d4d 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -73,6 +73,7 @@ static TCGv cpu_cfar; #endif static TCGv cpu_xer, cpu_so, cpu_ov, cpu_ca, cpu_ov32, cpu_ca32; static TCGv cpu_reserve; +static TCGv cpu_reserve_val; static TCGv cpu_fpscr; static TCGv_i32 cpu_access_type; =20 @@ -181,6 +182,9 @@ void ppc_translate_init(void) cpu_reserve =3D tcg_global_mem_new(cpu_env, offsetof(CPUPPCState, reserve_addr), "reserve_addr"); + cpu_reserve_val =3D tcg_global_mem_new(cpu_env, + offsetof(CPUPPCState, reserve_val), + "reserve_val"); =20 cpu_fpscr =3D tcg_global_mem_new(cpu_env, offsetof(CPUPPCState, fpscr), "fpscr"); @@ -3023,7 +3027,7 @@ static void gen_##name(DisasContext *ctx) = \ } \ tcg_gen_qemu_ld_tl(gpr, t0, ctx->mem_idx, memop); \ tcg_gen_mov_tl(cpu_reserve, t0); \ - tcg_gen_st_tl(gpr, cpu_env, offsetof(CPUPPCState, reserve_val)); \ + tcg_gen_mov_tl(cpu_reserve_val, gpr); \ tcg_temp_free(t0); \ } =20 @@ -3155,14 +3159,27 @@ static void gen_conditional_store(DisasContext *ctx= , TCGv EA, static void gen_conditional_store(DisasContext *ctx, TCGv EA, int reg, int memop) { - TCGLabel *l1; + TCGLabel *l1 =3D gen_new_label(); + TCGLabel *l2 =3D gen_new_label(); + TCGv t0; =20 - tcg_gen_trunc_tl_i32(cpu_crf[0], cpu_so); - l1 =3D gen_new_label(); tcg_gen_brcond_tl(TCG_COND_NE, EA, cpu_reserve, l1); - tcg_gen_ori_i32(cpu_crf[0], cpu_crf[0], CRF_EQ); - tcg_gen_qemu_st_tl(cpu_gpr[reg], EA, ctx->mem_idx, memop); + + t0 =3D tcg_temp_new(); + tcg_gen_atomic_cmpxchg_tl(t0, cpu_reserve, cpu_reserve_val, + cpu_gpr[reg], ctx->mem_idx, + DEF_MEMOP(memop) | MO_ALIGN); + tcg_gen_setcond_tl(TCG_COND_EQ, t0, t0, cpu_reserve_val); + tcg_gen_shli_tl(t0, t0, CRF_EQ_BIT); + tcg_gen_or_tl(t0, t0, cpu_so); + tcg_gen_trunc_tl_i32(cpu_crf[0], t0); + tcg_temp_free(t0); + tcg_gen_br(l2); + gen_set_label(l1); + tcg_gen_trunc_tl_i32(cpu_crf[0], cpu_so); + + gen_set_label(l2); tcg_gen_movi_tl(cpu_reserve, -1); } #endif --=20 2.9.3 From nobody Tue May 7 18:39:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 149327050253378.67100920908808; Wed, 26 Apr 2017 22:21:42 -0700 (PDT) Received: from localhost ([::1]:58773 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3bs4-0002F9-Qj for importer@patchew.org; Thu, 27 Apr 2017 01:21:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56517) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3bq3-0000mN-Cq for qemu-devel@nongnu.org; Thu, 27 Apr 2017 01:19:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d3bq0-0002Xb-Dw for qemu-devel@nongnu.org; Thu, 27 Apr 2017 01:19:35 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:52932) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d3bq0-0002X0-4h for qemu-devel@nongnu.org; Thu, 27 Apr 2017 01:19:32 -0400 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v3R5Ick9003722 for ; Thu, 27 Apr 2017 01:19:31 -0400 Received: from e23smtp08.au.ibm.com (e23smtp08.au.ibm.com [202.81.31.141]) by mx0a-001b2d01.pphosted.com with ESMTP id 2a2wj3xmgt-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 27 Apr 2017 01:19:30 -0400 Received: from localhost by e23smtp08.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 27 Apr 2017 15:19:28 +1000 Received: from d23relay08.au.ibm.com (202.81.31.227) by e23smtp08.au.ibm.com (202.81.31.205) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 27 Apr 2017 15:19:26 +1000 Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay08.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v3R5JHSE5112152; Thu, 27 Apr 2017 15:19:25 +1000 Received: from d23av03.au.ibm.com (localhost [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v3R5ImB5003593; Thu, 27 Apr 2017 15:18:48 +1000 Received: from abhimanyu.ibmmodules.com ([9.85.81.18]) by d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v3R5Ifn9002984; Thu, 27 Apr 2017 15:18:46 +1000 From: Nikunj A Dadhania To: qemu-ppc@nongnu.org, david@gibson.dropbear.id.au Date: Thu, 27 Apr 2017 10:48:20 +0530 X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170427051824.30194-1-nikunj@linux.vnet.ibm.com> References: <20170427051824.30194-1-nikunj@linux.vnet.ibm.com> X-TM-AS-MML: disable x-cbid: 17042705-0048-0000-0000-000002252330 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17042705-0049-0000-0000-000047D2FFD1 Message-Id: <20170427051824.30194-3-nikunj@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-04-27_04:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1704270085 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH v3 2/6] cputlb: handle first atomic write to the page 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: bharata@linux.vnet.ibm.com, alex.bennee@linaro.org, qemu-devel@nongnu.org, nikunj@linux.vnet.ibm.com, rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" In case where the conditional write is the first write to the page, TLB_NOTDIRTY will be set and stop_the_world is triggered. Handle this as a special case and set the dirty bit. After that fall through to the actual atomic instruction below. Signed-off-by: Nikunj A Dadhania Reviewed-by: Richard Henderson --- cputlb.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cputlb.c b/cputlb.c index f5d056c..743776a 100644 --- a/cputlb.c +++ b/cputlb.c @@ -930,7 +930,13 @@ static void *atomic_mmu_lookup(CPUArchState *env, targ= et_ulong addr, tlb_addr =3D tlbe->addr_write; } =20 - /* Notice an IO access, or a notdirty page. */ + /* Check notdirty */ + if (unlikely(tlb_addr & TLB_NOTDIRTY)) { + tlb_set_dirty(ENV_GET_CPU(env), addr); + tlb_addr =3D tlb_addr & ~TLB_NOTDIRTY; + } + + /* Notice an IO access */ if (unlikely(tlb_addr & ~TARGET_PAGE_MASK)) { /* There's really nothing that can be done to support this apart from stop-the-world. */ --=20 2.9.3 From nobody Tue May 7 18:39:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1493270645435447.49992792864566; Wed, 26 Apr 2017 22:24:05 -0700 (PDT) Received: from localhost ([::1]:58784 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3buO-0004Wl-74 for importer@patchew.org; Thu, 27 Apr 2017 01:24:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56557) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3bq8-0000oF-DK for qemu-devel@nongnu.org; Thu, 27 Apr 2017 01:19:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d3bq5-0002YG-7e for qemu-devel@nongnu.org; Thu, 27 Apr 2017 01:19:40 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:50664) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d3bq4-0002Y3-VR for qemu-devel@nongnu.org; Thu, 27 Apr 2017 01:19:37 -0400 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v3R5IeaX092443 for ; Thu, 27 Apr 2017 01:19:35 -0400 Received: from e23smtp07.au.ibm.com (e23smtp07.au.ibm.com [202.81.31.140]) by mx0a-001b2d01.pphosted.com with ESMTP id 2a2vajtwwc-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 27 Apr 2017 01:19:35 -0400 Received: from localhost by e23smtp07.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 27 Apr 2017 15:19:30 +1000 Received: from d23relay09.au.ibm.com (202.81.31.228) by e23smtp07.au.ibm.com (202.81.31.204) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 27 Apr 2017 15:19:28 +1000 Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay09.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v3R5JK7E37814348; Thu, 27 Apr 2017 15:19:28 +1000 Received: from d23av03.au.ibm.com (localhost [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v3R5Iop1003648; Thu, 27 Apr 2017 15:18:50 +1000 Received: from abhimanyu.ibmmodules.com ([9.85.81.18]) by d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v3R5IfnA002984; Thu, 27 Apr 2017 15:18:48 +1000 From: Nikunj A Dadhania To: qemu-ppc@nongnu.org, david@gibson.dropbear.id.au Date: Thu, 27 Apr 2017 10:48:21 +0530 X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170427051824.30194-1-nikunj@linux.vnet.ibm.com> References: <20170427051824.30194-1-nikunj@linux.vnet.ibm.com> X-TM-AS-MML: disable x-cbid: 17042705-0044-0000-0000-0000024A2124 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17042705-0045-0000-0000-000006D22193 Message-Id: <20170427051824.30194-4-nikunj@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-04-27_04:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=2 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1704270085 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH v3 3/6] target/ppc: Generate fence operations 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: bharata@linux.vnet.ibm.com, alex.bennee@linaro.org, qemu-devel@nongnu.org, nikunj@linux.vnet.ibm.com, rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Nikunj A Dadhania Reviewed-by: Richard Henderson --- target/ppc/translate.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/target/ppc/translate.c b/target/ppc/translate.c index 50b6d4d..4a1f24a 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -2971,6 +2971,7 @@ static void gen_stswx(DisasContext *ctx) /* eieio */ static void gen_eieio(DisasContext *ctx) { + tcg_gen_mb(TCG_MO_LD_ST | TCG_BAR_SC); } =20 #if !defined(CONFIG_USER_ONLY) @@ -3008,6 +3009,7 @@ static void gen_isync(DisasContext *ctx) if (!ctx->pr) { gen_check_tlb_flush(ctx, false); } + tcg_gen_mb(TCG_MO_ALL | TCG_BAR_SC); gen_stop_exception(ctx); } =20 @@ -3028,6 +3030,7 @@ static void gen_##name(DisasContext *ctx) = \ tcg_gen_qemu_ld_tl(gpr, t0, ctx->mem_idx, memop); \ tcg_gen_mov_tl(cpu_reserve, t0); \ tcg_gen_mov_tl(cpu_reserve_val, gpr); \ + tcg_gen_mb(TCG_MO_ALL | TCG_BAR_LDAQ); \ tcg_temp_free(t0); \ } =20 @@ -3177,6 +3180,10 @@ static void gen_conditional_store(DisasContext *ctx,= TCGv EA, tcg_gen_br(l2); =20 gen_set_label(l1); + + /* Address mismatch implies failure. But we still need to provide the + memory barrier semantics of the instruction. */ + tcg_gen_mb(TCG_MO_ALL | TCG_BAR_STRL); tcg_gen_trunc_tl_i32(cpu_crf[0], cpu_so); =20 gen_set_label(l2); @@ -3308,6 +3315,7 @@ static void gen_sync(DisasContext *ctx) if (((l =3D=3D 2) || !(ctx->insns_flags & PPC_64B)) && !ctx->pr) { gen_check_tlb_flush(ctx, true); } + tcg_gen_mb(TCG_MO_ALL | TCG_BAR_SC); } =20 /* wait */ --=20 2.9.3 From nobody Tue May 7 18:39:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1493270633258917.6449559058822; Wed, 26 Apr 2017 22:23:53 -0700 (PDT) Received: from localhost ([::1]:58782 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3buB-0004Oi-Ti for importer@patchew.org; Thu, 27 Apr 2017 01:23:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56598) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3bqB-0000rJ-IK for qemu-devel@nongnu.org; Thu, 27 Apr 2017 01:19:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d3bq9-0002ZG-UR for qemu-devel@nongnu.org; Thu, 27 Apr 2017 01:19:43 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:38742 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d3bq9-0002Z9-O8 for qemu-devel@nongnu.org; Thu, 27 Apr 2017 01:19:41 -0400 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v3R5IbcW139678 for ; Thu, 27 Apr 2017 01:19:36 -0400 Received: from e23smtp03.au.ibm.com (e23smtp03.au.ibm.com [202.81.31.145]) by mx0b-001b2d01.pphosted.com with ESMTP id 2a3a4e0g6s-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 27 Apr 2017 01:19:36 -0400 Received: from localhost by e23smtp03.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 27 Apr 2017 15:19:33 +1000 Received: from d23relay10.au.ibm.com (202.81.31.229) by e23smtp03.au.ibm.com (202.81.31.209) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 27 Apr 2017 15:19:30 +1000 Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay10.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v3R5JMM61048840; Thu, 27 Apr 2017 15:19:30 +1000 Received: from d23av03.au.ibm.com (localhost [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v3R5IqrZ003709; Thu, 27 Apr 2017 15:18:53 +1000 Received: from abhimanyu.ibmmodules.com ([9.85.81.18]) by d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v3R5IfnB002984; Thu, 27 Apr 2017 15:18:50 +1000 From: Nikunj A Dadhania To: qemu-ppc@nongnu.org, david@gibson.dropbear.id.au Date: Thu, 27 Apr 2017 10:48:22 +0530 X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170427051824.30194-1-nikunj@linux.vnet.ibm.com> References: <20170427051824.30194-1-nikunj@linux.vnet.ibm.com> X-TM-AS-MML: disable x-cbid: 17042705-0008-0000-0000-00000125EA15 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17042705-0009-0000-0000-00000953B516 Message-Id: <20170427051824.30194-5-nikunj@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-04-27_04:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1704270085 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH v3 4/6] cpus: Fix CPU unplug for MTTCG 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: bharata@linux.vnet.ibm.com, alex.bennee@linaro.org, qemu-devel@nongnu.org, nikunj@linux.vnet.ibm.com, rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Bharata B Rao Ensure that the unplugged CPU thread is destroyed and the waiting thread is notified about it. This is needed for CPU unplug to work correctly in MTTCG mode. Signed-off-by: Bharata B Rao Signed-off-by: Nikunj A Dadhania --- cpus.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cpus.c b/cpus.c index 740b8dc..79f780b 100644 --- a/cpus.c +++ b/cpus.c @@ -1483,6 +1483,12 @@ static void *qemu_tcg_cpu_thread_fn(void *arg) /* Ignore everything else? */ break; } + } else if (cpu->unplug) { + qemu_tcg_destroy_vcpu(cpu); + cpu->created =3D false; + qemu_cond_signal(&qemu_cpu_cond); + qemu_mutex_unlock_iothread(); + return NULL; } =20 atomic_mb_set(&cpu->exit_request, 0); --=20 2.9.3 From nobody Tue May 7 18:39:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1493270493524914.4397643241012; Wed, 26 Apr 2017 22:21:33 -0700 (PDT) Received: from localhost ([::1]:58772 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3brw-00026b-7W for importer@patchew.org; Thu, 27 Apr 2017 01:21:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56579) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3bqA-0000q7-Hv for qemu-devel@nongnu.org; Thu, 27 Apr 2017 01:19:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d3bq7-0002Yf-Du for qemu-devel@nongnu.org; Thu, 27 Apr 2017 01:19:42 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:38891 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d3bq7-0002YX-7p for qemu-devel@nongnu.org; Thu, 27 Apr 2017 01:19:39 -0400 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v3R5IdZP132643 for ; Thu, 27 Apr 2017 01:19:38 -0400 Received: from e23smtp04.au.ibm.com (e23smtp04.au.ibm.com [202.81.31.146]) by mx0b-001b2d01.pphosted.com with ESMTP id 2a333he0tq-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 27 Apr 2017 01:19:38 -0400 Received: from localhost by e23smtp04.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 27 Apr 2017 15:19:35 +1000 Received: from d23relay09.au.ibm.com (202.81.31.228) by e23smtp04.au.ibm.com (202.81.31.210) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 27 Apr 2017 15:19:33 +1000 Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay09.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v3R5JOjs4784484; Thu, 27 Apr 2017 15:19:32 +1000 Received: from d23av03.au.ibm.com (localhost [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v3R5IsqM003809; Thu, 27 Apr 2017 15:18:55 +1000 Received: from abhimanyu.ibmmodules.com ([9.85.81.18]) by d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v3R5IfnC002984; Thu, 27 Apr 2017 15:18:53 +1000 From: Nikunj A Dadhania To: qemu-ppc@nongnu.org, david@gibson.dropbear.id.au Date: Thu, 27 Apr 2017 10:48:23 +0530 X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170427051824.30194-1-nikunj@linux.vnet.ibm.com> References: <20170427051824.30194-1-nikunj@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-MML: disable x-cbid: 17042705-0012-0000-0000-0000022CE613 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17042705-0013-0000-0000-000007438505 Message-Id: <20170427051824.30194-6-nikunj@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-04-27_04:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1704270085 Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by mx0b-001b2d01.pphosted.com id v3R5IdZP132643 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH v3 5/6] tcg: enable MTTCG by default for PPC64 on x86 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: bharata@linux.vnet.ibm.com, alex.bennee@linaro.org, qemu-devel@nongnu.org, nikunj@linux.vnet.ibm.com, rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This enables the multi-threaded system emulation by default for PPC64 guests using the x86_64 TCG back-end. Signed-off-by: Nikunj A Dadhania Reviewed-by: Alex Benn=C3=A9e --- configure | 2 ++ target/ppc/cpu.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/configure b/configure index c35acf1..3814617 100755 --- a/configure +++ b/configure @@ -6090,12 +6090,14 @@ case "$target_name" in ppc64) TARGET_BASE_ARCH=3Dppc TARGET_ABI_DIR=3Dppc + mttcg=3Dyes gdb_xml_files=3D"power64-core.xml power-fpu.xml power-altivec.xml powe= r-spe.xml power-vsx.xml" ;; ppc64le) TARGET_ARCH=3Dppc64 TARGET_BASE_ARCH=3Dppc TARGET_ABI_DIR=3Dppc + mttcg=3Dyes gdb_xml_files=3D"power64-core.xml power-fpu.xml power-altivec.xml powe= r-spe.xml power-vsx.xml" ;; ppc64abi32) diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index e0ff041..ece535d 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -30,6 +30,8 @@ #define TARGET_LONG_BITS 64 #define TARGET_PAGE_BITS 12 =20 +#define TCG_GUEST_DEFAULT_MO 0 + /* Note that the official physical address space bits is 62-M where M is implementation dependent. I've not looked up M for the set of cpus we emulate at the system level. */ --=20 2.9.3 From nobody Tue May 7 18:39:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1493270728042359.15339005754254; Wed, 26 Apr 2017 22:25:28 -0700 (PDT) Received: from localhost ([::1]:58796 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3bvi-0005g0-PK for importer@patchew.org; Thu, 27 Apr 2017 01:25:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56619) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3bqD-0000tj-Ok for qemu-devel@nongnu.org; Thu, 27 Apr 2017 01:19:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d3bqA-0002ZV-IF for qemu-devel@nongnu.org; Thu, 27 Apr 2017 01:19:45 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:48668 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d3bqA-0002ZL-BU for qemu-devel@nongnu.org; Thu, 27 Apr 2017 01:19:42 -0400 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v3R5IdwK093532 for ; Thu, 27 Apr 2017 01:19:41 -0400 Received: from e23smtp02.au.ibm.com (e23smtp02.au.ibm.com [202.81.31.144]) by mx0b-001b2d01.pphosted.com with ESMTP id 2a32a0r2c2-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 27 Apr 2017 01:19:41 -0400 Received: from localhost by e23smtp02.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 27 Apr 2017 15:19:38 +1000 Received: from d23relay06.au.ibm.com (202.81.31.225) by e23smtp02.au.ibm.com (202.81.31.208) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 27 Apr 2017 15:19:35 +1000 Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay06.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v3R5JQ0J65994812; Thu, 27 Apr 2017 15:19:34 +1000 Received: from d23av03.au.ibm.com (localhost [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v3R5Ivh0003873; Thu, 27 Apr 2017 15:18:57 +1000 Received: from abhimanyu.ibmmodules.com ([9.85.81.18]) by d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v3R5IfnD002984; Thu, 27 Apr 2017 15:18:55 +1000 From: Nikunj A Dadhania To: qemu-ppc@nongnu.org, david@gibson.dropbear.id.au Date: Thu, 27 Apr 2017 10:48:24 +0530 X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170427051824.30194-1-nikunj@linux.vnet.ibm.com> References: <20170427051824.30194-1-nikunj@linux.vnet.ibm.com> X-TM-AS-MML: disable x-cbid: 17042705-0004-0000-0000-000001FBE5F0 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17042705-0005-0000-0000-000009F0ABB7 Message-Id: <20170427051824.30194-7-nikunj@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-04-27_04:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1704270085 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH v3 6/6] target/ppc: do not reset reserve_addr in exec_enter 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: bharata@linux.vnet.ibm.com, alex.bennee@linaro.org, qemu-devel@nongnu.org, nikunj@linux.vnet.ibm.com, rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" In case when atomic operation is not supported, exit_atomic is called and we stop the world and execute the atomic operation. This results in a following call chain: tcg_gen_atomic_cmpxchg_tl() -> gen_helper_exit_atomic() -> HELPER(exit_atomic) -> cpu_loop_exit_atomic() -> EXCP_ATOMIC -> qemu_tcg_cpu_thread_fn() =3D> case EXCP_ATOMIC -> cpu_exec_step_atomic() -> cpu_step_atomic() -> cc->cpu_exec_enter() =3D ppc_cpu_exec_enter() Sets env->reserve_addr =3D -1; But by the time it return back, the reservation is erased and the code fails, this continues forever and the lock is never taken. Instead set this in powerpc_excp() Now that ppc_cpu_exec_enter() doesn't have anything meaningful to do, let us get rid of the function. Signed-off-by: Nikunj A Dadhania --- target/ppc/excp_helper.c | 3 +++ target/ppc/translate_init.c | 9 --------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c index f4ee7aa..a6bcb47 100644 --- a/target/ppc/excp_helper.c +++ b/target/ppc/excp_helper.c @@ -728,6 +728,9 @@ static inline void powerpc_excp(PowerPCCPU *cpu, int ex= cp_model, int excp) cs->exception_index =3D POWERPC_EXCP_NONE; env->error_code =3D 0; =20 + /* Reset the reservation */ + env->reserve_addr =3D -1; + /* Any interrupt is context synchronizing, check if TCG TLB * needs a delayed flush on ppc64 */ diff --git a/target/ppc/translate_init.c b/target/ppc/translate_init.c index e82e3e6..9b048cd 100644 --- a/target/ppc/translate_init.c +++ b/target/ppc/translate_init.c @@ -10436,14 +10436,6 @@ static bool ppc_cpu_has_work(CPUState *cs) return msr_ee && (cs->interrupt_request & CPU_INTERRUPT_HARD); } =20 -static void ppc_cpu_exec_enter(CPUState *cs) -{ - PowerPCCPU *cpu =3D POWERPC_CPU(cs); - CPUPPCState *env =3D &cpu->env; - - env->reserve_addr =3D -1; -} - /* CPUClass::reset() */ static void ppc_cpu_reset(CPUState *s) { @@ -10660,7 +10652,6 @@ static void ppc_cpu_class_init(ObjectClass *oc, voi= d *data) cc->get_phys_page_debug =3D ppc_cpu_get_phys_page_debug; cc->vmsd =3D &vmstate_ppc_cpu; #endif - cc->cpu_exec_enter =3D ppc_cpu_exec_enter; #if defined(CONFIG_SOFTMMU) cc->write_elf64_note =3D ppc64_cpu_write_elf64_note; cc->write_elf32_note =3D ppc32_cpu_write_elf32_note; --=20 2.9.3