From nobody Sun May 19 04:05:29 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1618491870; cv=none; d=zohomail.com; s=zohoarc; b=ZR0OVBaMG/kUv4vdTyD+xZJIqg2/n8tP5o5pgkE4VUyf3Kk7s/34grAmPo6wpOS57NlmCQ/3O1mWtzzEmTqDYi25mbRoA95RkTRK98v0iPxNs7JU15RHS+jT4UmOTjpE7YfHOPCD2kcb9aW+Q8hwlHFCu+Ov0VsaM4ZZ6ohYeWg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618491870; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=s+xocQN6xiHTQK3frx/YTOYIPSoAczd3F8sE78d4gjE=; b=n7IYfQvzC+zpkZvwNrifIRUOfAd9kwOvtoc5nX4+t2tYedtMOKGZKYCcRGlEAUAQbMHoLC15dx356MLSreUyIkAmDoIWbe7wHj3q2a1HfM1STIKwzDH4uEojdMstWAjVXPuEVhaE/GgsrM0nEdsbDY7tqNS3HlK0TjlxZoHaozc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1618491870016261.91380839112617; Thu, 15 Apr 2021 06:04:30 -0700 (PDT) Received: from localhost ([::1]:36014 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lX1fW-00074j-MB for importer@patchew.org; Thu, 15 Apr 2021 09:04:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55702) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lX1eS-0005q4-MU; Thu, 15 Apr 2021 09:03:20 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:13172) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lX1eQ-0001C0-Bv; Thu, 15 Apr 2021 09:03:20 -0400 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 13FCXsJF082325; Thu, 15 Apr 2021 09:03:14 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 37xfrnu22k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 Apr 2021 09:03:14 -0400 Received: from m0098409.ppops.net (m0098409.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 13FCXsGL082274; Thu, 15 Apr 2021 09:03:13 -0400 Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com with ESMTP id 37xfrnu20t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 Apr 2021 09:03:13 -0400 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.0.43/8.16.0.43) with SMTP id 13FCqRnu018468; Thu, 15 Apr 2021 13:03:11 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma04ams.nl.ibm.com with ESMTP id 37u3n8uw43-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 Apr 2021 13:03:11 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 13FD37j534406800 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 15 Apr 2021 13:03:08 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CB25EA4062; Thu, 15 Apr 2021 13:03:07 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 49051A4054; Thu, 15 Apr 2021 13:03:07 +0000 (GMT) Received: from vm.lan (unknown [9.145.157.105]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 15 Apr 2021 13:03:07 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=s+xocQN6xiHTQK3frx/YTOYIPSoAczd3F8sE78d4gjE=; b=RloEoa0jVPbwHiPN1+AI+TQrwRCmkrfg8nWcAu6Ojb4iQd+cNHlcpPulEQ/auCqzmmiF oGLQDYF24Cb7N3DxceX54hiplQPeljLi14zuCiQ21anxDnsC1169HwFrndZV1qOez+qU G8FXu98WcKy97bdgxvpC35OZ+4lCt4GGlsOgQmfSeXICzgukt8QR0U4LBzQ8czgrK3kl rLga9WT7JlXe0noiO//fbd4BMJJX/uElUdrwCZT7KPSJGzdTQ7fyV04HHd6rBK4eQcIc 7v/k1fqREVexueEVOFu+sxHpWtrFY05FPGtEa6AMqtDLMmC+BLRtKORTcoZzAdL/YLfC Lg== From: Ilya Leoshkevich To: Cornelia Huck , Thomas Huth , Richard Henderson , David Hildenbrand , Paolo Bonzini , Peter Maydell , Max Filippov Subject: [PATCH v4 1/4] target/s390x: Fix translation exception on illegal instruction Date: Thu, 15 Apr 2021 15:03:02 +0200 Message-Id: <20210415130305.28640-2-iii@linux.ibm.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210415130305.28640-1-iii@linux.ibm.com> References: <20210415130305.28640-1-iii@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: NNc63C3lGSnDuTRvXtPqbq_X8IAcDhXr X-Proofpoint-GUID: zzJD48B3gQBzIzYZe7ZYhAlmGS62KD7_ X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.761 definitions=2021-04-15_04:2021-04-15, 2021-04-15 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 impostorscore=0 clxscore=1015 mlxlogscore=999 priorityscore=1501 malwarescore=0 spamscore=0 adultscore=0 bulkscore=0 phishscore=0 suspectscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104150084 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.156.1; envelope-from=iii@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christian Borntraeger , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, qemu-devel@nongnu.org, Ilya Leoshkevich Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Hitting an uretprobe in a s390x TCG guest causes a SIGSEGV. What happens is: * uretprobe maps a userspace page containing an invalid instruction. * uretprobe replaces the target function's return address with the address of that page. * When tb_gen_code() is called on that page, tb->size ends up being 0 (because the page starts with the invalid instruction), which causes virt_page2 to point to the previous page. * The previous page is not mapped, so this causes a spurious translation exception. tb->size must never be 0: even if there is an illegal instruction, the instruction bytes that have been looked at must count towards tb->size. So adjust s390x's translate_one() to act this way for both illegal instructions and instructions that are known to generate exceptions. Signed-off-by: Ilya Leoshkevich Reviewed-by: David Hildenbrand --- target/s390x/translate.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/target/s390x/translate.c b/target/s390x/translate.c index 4f953ddfba..e243624d2a 100644 --- a/target/s390x/translate.c +++ b/target/s390x/translate.c @@ -6412,7 +6412,8 @@ static DisasJumpType translate_one(CPUS390XState *env= , DisasContext *s) qemu_log_mask(LOG_UNIMP, "unimplemented opcode 0x%02x%02x\n", s->fields.op, s->fields.op2); gen_illegal_opcode(s); - return DISAS_NORETURN; + ret =3D DISAS_NORETURN; + goto out; } =20 #ifndef CONFIG_USER_ONLY @@ -6428,7 +6429,8 @@ static DisasJumpType translate_one(CPUS390XState *env= , DisasContext *s) /* privileged instruction */ if ((s->base.tb->flags & FLAG_MASK_PSTATE) && (insn->flags & IF_PR= IV)) { gen_program_exception(s, PGM_PRIVILEGED); - return DISAS_NORETURN; + ret =3D DISAS_NORETURN; + goto out; } =20 /* if AFP is not enabled, instructions and registers are forbidden= */ @@ -6455,7 +6457,8 @@ static DisasJumpType translate_one(CPUS390XState *env= , DisasContext *s) } if (dxc) { gen_data_exception(dxc); - return DISAS_NORETURN; + ret =3D DISAS_NORETURN; + goto out; } } =20 @@ -6463,7 +6466,8 @@ static DisasJumpType translate_one(CPUS390XState *env= , DisasContext *s) if (insn->flags & IF_VEC) { if (!((s->base.tb->flags & FLAG_MASK_VECTOR))) { gen_data_exception(0xfe); - return DISAS_NORETURN; + ret =3D DISAS_NORETURN; + goto out; } } =20 @@ -6484,7 +6488,8 @@ static DisasJumpType translate_one(CPUS390XState *env= , DisasContext *s) (insn->spec & SPEC_r1_f128 && !is_fp_pair(get_field(s, r1))) || (insn->spec & SPEC_r2_f128 && !is_fp_pair(get_field(s, r2)))) { gen_program_exception(s, PGM_SPECIFICATION); - return DISAS_NORETURN; + ret =3D DISAS_NORETURN; + goto out; } } =20 @@ -6544,6 +6549,7 @@ static DisasJumpType translate_one(CPUS390XState *env= , DisasContext *s) } #endif =20 +out: /* Advance to the next instruction. */ s->base.pc_next =3D s->pc_tmp; return ret; --=20 2.29.2 From nobody Sun May 19 04:05:29 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1618492271; cv=none; d=zohomail.com; s=zohoarc; b=AkmezIvfNQjOm/hsLAewO3JECt+rud17/oADUjbExb6pW+huB6U0+/+cCgWO+He8UQ8Clr+YvEjHGztlkXVHwGdVoRakRNgYa/n+8wdId7NI5u1fvPGS5tL44u9pMzJhaWP6ZzK8WvIc4rFfES0UMAV3JObWENYUkc+B33DOvac= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618492271; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=HN6gi2waTXJ3xm3yRDbOv4zXp826T0uvvOsNIUyUuHA=; b=kVJ3EWCqIxatlz4vssrSgOTW+LtoVR1MOn2O2FGWYJI6sr8TnZHD6WOCAhE/tQMsTdRod+C6IaT7kvutjDflq3GJDpTLoktF46yln6aHvRwzaVVCoSwJp3VWpn3q3XArZwIhsnGI6GEG6gD+PZ4mtAwY8ljcpBDg0iAmdTRcvUg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1618492271461116.80114887672926; Thu, 15 Apr 2021 06:11:11 -0700 (PDT) Received: from localhost ([::1]:51686 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lX1m2-0005KX-Pe for importer@patchew.org; Thu, 15 Apr 2021 09:11:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55832) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lX1eZ-00064E-UD; Thu, 15 Apr 2021 09:03:27 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:41394) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lX1eX-0001IW-Qf; Thu, 15 Apr 2021 09:03:27 -0400 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 13FCYMKG141710; Thu, 15 Apr 2021 09:03:23 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 37x0ffjbmv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 Apr 2021 09:03:22 -0400 Received: from m0098410.ppops.net (m0098410.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 13FCZco1002024; Thu, 15 Apr 2021 09:03:19 -0400 Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com with ESMTP id 37x0ffjbfs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 Apr 2021 09:03:19 -0400 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.16.0.43/8.16.0.43) with SMTP id 13FCsfvX015584; Thu, 15 Apr 2021 13:03:12 GMT Received: from b06avi18626390.portsmouth.uk.ibm.com (b06avi18626390.portsmouth.uk.ibm.com [9.149.26.192]) by ppma06ams.nl.ibm.com with ESMTP id 37u39hkwdv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 Apr 2021 13:03:11 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 13FD2k1331588652 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 15 Apr 2021 13:02:46 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id ED069A4069; Thu, 15 Apr 2021 13:03:08 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5F0DEA4054; Thu, 15 Apr 2021 13:03:08 +0000 (GMT) Received: from vm.lan (unknown [9.145.157.105]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 15 Apr 2021 13:03:08 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=HN6gi2waTXJ3xm3yRDbOv4zXp826T0uvvOsNIUyUuHA=; b=BkVeh67l2JIuTfRFll55SylGhLtwrF4RLUC1Gmy4LUWLpClVvBlZYWMIYJZCkvTTcWuS Tn8WlIU7UkSRo1/bBCQOYl7j7zBZxvqNYQ4zpYN7o9Ifhj0H5FwPN0194KsNhE5xMK4u UBhd9LsJrFR4n3HKPxv+cavRIJsKvD3EEO7e+X6a6hPMkuAtXCAR7Uo3RhG9+X+oY6rZ /9K9kKacobwqHYtHVrtSbC7RtGW4RP2RMRoEIzkwP3VB/eLTPLYBOFnvabcFT/QjRkSd U7yq43kqDbb35wCww7a7sqx/Op2BmJLaQIJzaaVBjkaTKSTBvv8HqttKpXqG7u2kCl3n xg== From: Ilya Leoshkevich To: Cornelia Huck , Thomas Huth , Richard Henderson , David Hildenbrand , Paolo Bonzini , Peter Maydell , Max Filippov Subject: [PATCH v4 2/4] target/arm: Make sure that commpage's tb->size != 0 Date: Thu, 15 Apr 2021 15:03:03 +0200 Message-Id: <20210415130305.28640-3-iii@linux.ibm.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210415130305.28640-1-iii@linux.ibm.com> References: <20210415130305.28640-1-iii@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: E3pmUiU8JJxDr4rB9X68LwuB_96icghf X-Proofpoint-ORIG-GUID: AHLd3UN9jFJpn17D9uBpFDhR__nzoR-Q X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.761 definitions=2021-04-15_04:2021-04-15, 2021-04-15 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 clxscore=1015 malwarescore=0 adultscore=0 bulkscore=0 impostorscore=0 lowpriorityscore=0 mlxlogscore=999 priorityscore=1501 phishscore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104150084 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.156.1; envelope-from=iii@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christian Borntraeger , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, qemu-devel@nongnu.org, Ilya Leoshkevich Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" tb_gen_code() assumes that tb->size must never be zero, otherwise it may produce spurious exceptions. For ARM this may happen when creating a translation block for the commpage. Fix by pretending that commpage translation blocks have at least one instruction. Signed-off-by: Ilya Leoshkevich --- target/arm/translate.c | 1 + 1 file changed, 1 insertion(+) diff --git a/target/arm/translate.c b/target/arm/translate.c index 62b1c2081b..885f69b044 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -9060,6 +9060,7 @@ static void arm_tr_translate_insn(DisasContextBase *d= cbase, CPUState *cpu) unsigned int insn; =20 if (arm_pre_translate_insn(dc)) { + dc->base.pc_next +=3D 4; return; } =20 --=20 2.29.2 From nobody Sun May 19 04:05:29 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1618492132; cv=none; d=zohomail.com; s=zohoarc; b=c7qAbrfAP23VJasB6vgxqNSHTrzq1FXI36lX2vJRDlAFSoa5MyEuisX2nbeHMav3Nj4Xj2CyHGs85N3HANOHjXnqjhpyk9+oQf9E/UxkCUUozuQMLTIc2ei1vzB7wjEWWZbHB33QJUy7WjVLeVdrm0xECXm8eqyeFvr+QAX0X8I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618492132; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=I2ptigVFr+IWzhexi7m+OP+G3j7MSbAsWNkSxqjZc5E=; b=VccMkhaklAUjtrVzn5Bz3yFFyxg74f9FTFylNzOwwf8gsk3LPcYwYTYxpHoE6RvbL4a+QMbluOcU2JoSyrOh1tckkYV86sexCMcqxYp4XmiD6S4iUJ+daKMC64asaL0EKBCg0RGwI62DlCfZESOrrIdUk/+AWrbs1xSxji7KwSE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1618492132841109.37234487374553; Thu, 15 Apr 2021 06:08:52 -0700 (PDT) Received: from localhost ([::1]:46352 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lX1jo-000323-4x for importer@patchew.org; Thu, 15 Apr 2021 09:08:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55748) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lX1eV-0005tO-0c; Thu, 15 Apr 2021 09:03:23 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:51192) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lX1eS-0001F9-AX; Thu, 15 Apr 2021 09:03:22 -0400 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 13FCYM0N141738; Thu, 15 Apr 2021 09:03:17 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 37x0ffjbju-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 Apr 2021 09:03:17 -0400 Received: from m0098410.ppops.net (m0098410.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 13FCYgLH143019; Thu, 15 Apr 2021 09:03:16 -0400 Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 37x0ffjbgm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 Apr 2021 09:03:16 -0400 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.0.43/8.16.0.43) with SMTP id 13FCsASw012947; Thu, 15 Apr 2021 13:03:13 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma03ams.nl.ibm.com with ESMTP id 37u3n8bw2s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 Apr 2021 13:03:12 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 13FD3Ai931326466 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 15 Apr 2021 13:03:10 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 028DBA405F; Thu, 15 Apr 2021 13:03:10 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 64AC3A4054; Thu, 15 Apr 2021 13:03:09 +0000 (GMT) Received: from vm.lan (unknown [9.145.157.105]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 15 Apr 2021 13:03:09 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=I2ptigVFr+IWzhexi7m+OP+G3j7MSbAsWNkSxqjZc5E=; b=FGe4P3lRlBnsCjLJKsj9yE2eLjKCuW7JaEir/HJQVQEuJZDOgJ3tjy/0frcDS50byWGL pXlgnsYklGz6TxNI3Pd4ecq8FAk0BMmaMwRIxWGI2KcWGV3qKWg45LO5XeYa8CyDRK6A CbOwBuWC60D43/lc9E9ZIQENXGoIrRW74SdYgTYLj7u1YhU5OS4dTabzn2oKCgu3FY5z mIFNc3dApBUaXmOh36QAF39FK99xgjYjLB+H8hdszXn6ctqkwLic1B2JJ0KChUd/MONg TKF1JohKQgczwnxOmdlQKyBoUgizyGSbLsHOhPQLiKsMt+r5ZaBFG8RhpUF7DPGwKe9j pA== From: Ilya Leoshkevich To: Cornelia Huck , Thomas Huth , Richard Henderson , David Hildenbrand , Paolo Bonzini , Peter Maydell , Max Filippov Subject: [PATCH v4 3/4] target/xtensa: Make sure that tb->size != 0 Date: Thu, 15 Apr 2021 15:03:04 +0200 Message-Id: <20210415130305.28640-4-iii@linux.ibm.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210415130305.28640-1-iii@linux.ibm.com> References: <20210415130305.28640-1-iii@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: SdWFHsSpxg4TxxgJPVStprwrcswFMNKx X-Proofpoint-ORIG-GUID: CsXDPbAJYN7gs75LARAlahn7qRgb1i0S X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.761 definitions=2021-04-15_04:2021-04-15, 2021-04-15 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 clxscore=1015 malwarescore=0 adultscore=0 bulkscore=0 impostorscore=0 lowpriorityscore=0 mlxlogscore=999 priorityscore=1501 phishscore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104150084 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.156.1; envelope-from=iii@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christian Borntraeger , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, qemu-devel@nongnu.org, Ilya Leoshkevich Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" tb_gen_code() assumes that tb->size must never be zero, otherwise it may produce spurious exceptions. For xtensa this may happen when decoding an unknown instruction, when handling a write into the CCOUNT or CCOMPARE special register and when single-stepping the first instruction of an exception handler. Fix by pretending that the size of the respective translation block is 1 in all these cases. Signed-off-by: Ilya Leoshkevich Acked-by: Max Filippov Tested-by: Max Filippov --- target/xtensa/translate.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/target/xtensa/translate.c b/target/xtensa/translate.c index 0ae4efc48a..73584d9d60 100644 --- a/target/xtensa/translate.c +++ b/target/xtensa/translate.c @@ -917,6 +917,7 @@ static void disas_xtensa_insn(CPUXtensaState *env, Disa= sContext *dc) "unknown instruction length (pc =3D %08x)\n", dc->pc); gen_exception_cause(dc, ILLEGAL_INSTRUCTION_CAUSE); + dc->base.pc_next =3D dc->pc + 1; return; } =20 @@ -1274,11 +1275,13 @@ static void xtensa_tr_translate_insn(DisasContextBa= se *dcbase, CPUState *cpu) if ((tb_cflags(dc->base.tb) & CF_USE_ICOUNT) && (dc->base.tb->flags & XTENSA_TBFLAG_YIELD)) { gen_exception(dc, EXCP_YIELD); + dc->base.pc_next =3D dc->pc + 1; dc->base.is_jmp =3D DISAS_NORETURN; return; } if (dc->base.tb->flags & XTENSA_TBFLAG_EXCEPTION) { gen_exception(dc, EXCP_DEBUG); + dc->base.pc_next =3D dc->pc + 1; dc->base.is_jmp =3D DISAS_NORETURN; return; } --=20 2.29.2 From nobody Sun May 19 04:05:29 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1618492086; cv=none; d=zohomail.com; s=zohoarc; b=ISFR5jcTlRJeOIRYZJt0NUW9z/lhmFRfAZcL9G+vHAPAV7tkvPRk+otk8A49MEQX0YmsBi/ld2HzYjH3MJO/Y32tNDzUZ3eLj9OJqZwLwdE6UEQ2d96+N4ZBTPC+nHtWNeCwTOUt7RKScQBREYur2QisbtzwaNsc0ybp5XL9uNc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618492086; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=BW7u4WcPkobkkMRidYkYfR+F2b4Woa8iJkWP89Rsaw0=; b=FTMMlomN5azdeMZpUiFrA+WhKKaEP6+RGomY+3dHkvOzIyWerekw0DIK9jE6Aqycc4UuFcnH5zw6f7O+4OrahqMKsz/fnYHwYAuTX64ulQCChKqNc772FxGmL151cayI70jea2o9Aogg8IE7r6k0zsv0t7+xzWPgmLPQo1iVZWY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1618492086986817.0539652638164; Thu, 15 Apr 2021 06:08:06 -0700 (PDT) Received: from localhost ([::1]:44114 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lX1j3-00024S-Hf for importer@patchew.org; Thu, 15 Apr 2021 09:08:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55758) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lX1eV-0005uA-Fa; Thu, 15 Apr 2021 09:03:23 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:39242) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lX1eS-0001FB-KS; Thu, 15 Apr 2021 09:03:23 -0400 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 13FCY29e022938; Thu, 15 Apr 2021 09:03:18 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 37x13vh433-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 Apr 2021 09:03:17 -0400 Received: from m0098396.ppops.net (m0098396.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 13FClgGT074323; Thu, 15 Apr 2021 09:03:17 -0400 Received: from ppma05fra.de.ibm.com (6c.4a.5195.ip4.static.sl-reverse.com [149.81.74.108]) by mx0a-001b2d01.pphosted.com with ESMTP id 37x13vh415-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 Apr 2021 09:03:16 -0400 Received: from pps.filterd (ppma05fra.de.ibm.com [127.0.0.1]) by ppma05fra.de.ibm.com (8.16.0.43/8.16.0.43) with SMTP id 13FCradI011692; Thu, 15 Apr 2021 13:03:14 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma05fra.de.ibm.com with ESMTP id 37u3n8a3h7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 Apr 2021 13:03:14 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 13FD3BhL25100564 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 15 Apr 2021 13:03:11 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F10F5A4069; Thu, 15 Apr 2021 13:03:10 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 65BEBA4054; Thu, 15 Apr 2021 13:03:10 +0000 (GMT) Received: from vm.lan (unknown [9.145.157.105]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 15 Apr 2021 13:03:10 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=BW7u4WcPkobkkMRidYkYfR+F2b4Woa8iJkWP89Rsaw0=; b=YRKahCUiwqBkNHMSvkKUR2WQHFcqYVADPxGHoTd9pZRO9zMwiV+HrA/Z5Ljrk0/XotIk J24BHDF0aqND5lDhag+v0c8YuD82MkUpF6A4R9DgCpaFbjoCR8UcayWgBxvYM5J9OyE5 BPfmkTJ85B46Sy82j3HXXdH74gElig7ZO4VL8tN/M1AQZgUe5A1HhJ99rlYJbjDnGTut YBxVjgNgnyVEw/cmXCO9w8680Nh2kNMdK2Ui8i/ANgSf0y+ypf2b/YBo+m9bDQvdndNd 6dne9rTET8ftKFSutiOnGijpw77do8bIpgNZg3U8ZfvmWXidkq531KcnrZXJJ0r+pCBJ EA== From: Ilya Leoshkevich To: Cornelia Huck , Thomas Huth , Richard Henderson , David Hildenbrand , Paolo Bonzini , Peter Maydell , Max Filippov Subject: [PATCH v4 4/4] accel/tcg: Assert that tb->size != 0 after translation Date: Thu, 15 Apr 2021 15:03:05 +0200 Message-Id: <20210415130305.28640-5-iii@linux.ibm.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210415130305.28640-1-iii@linux.ibm.com> References: <20210415130305.28640-1-iii@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 8blabmXFe8Uzu6MIvoAenvTKtjnIVgBM X-Proofpoint-ORIG-GUID: dbX4gnH0M7z7_gCRIu83RneRgbu--vFn X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.761 definitions=2021-04-15_04:2021-04-15, 2021-04-15 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 impostorscore=0 suspectscore=0 phishscore=0 malwarescore=0 lowpriorityscore=0 adultscore=0 mlxscore=0 spamscore=0 priorityscore=1501 clxscore=1015 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104150084 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.156.1; envelope-from=iii@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christian Borntraeger , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, qemu-devel@nongnu.org, Ilya Leoshkevich Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" If arch-specific code generates a translation block of size 0, tb_gen_code() may generate a spurious exception. Add an assertion in order to catch such situations early. Signed-off-by: Ilya Leoshkevich Reviewed-by: David Hildenbrand --- accel/tcg/translate-all.c | 1 + 1 file changed, 1 insertion(+) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index ba6ab09790..93b2dae112 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -1913,6 +1913,7 @@ TranslationBlock *tb_gen_code(CPUState *cpu, =20 tcg_ctx->cpu =3D env_cpu(env); gen_intermediate_code(cpu, tb, max_insns); + assert(tb->size !=3D 0); tcg_ctx->cpu =3D NULL; max_insns =3D tb->icount; =20 --=20 2.29.2