From nobody Mon Apr 29 03:03:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1660212268; cv=none; d=zohomail.com; s=zohoarc; b=DzfxvsVFf219788cm6rV3OWG4vTlwqid/zhjYXMyMkmquxu8zA8aJ88AMA63LKZvLNM3OE7TpopfJKfpoIKzz6FswgVP7GlteJRlsoFT10dH0mccXsj6w+TYanwKQiJF/isCIE1v1tq0IS5FPjDbj7TdOfPqoS15EYqPj2QBw8Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660212268; 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=LNJWTjXEDDLzto9iALwGRYwubqmvc7lVDMXP25KOpVY=; b=DFJWOmMBnuKOGNxbXI6R3T79sB4TNhdNEwvc5P1RVI1I/ug+cavHgvq5nWR2V2Jbfo8WY8Dt5EqWJAIQzcjbHSvWBMDyzAGl9XflD4UxmTaNTDXkN0HsWJbtpiZ8OPAMVia0zIT2w0bWGN/AimQgsytZ6xD9kVtBocO+BmBsQNo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1660212268283426.4095819366389; Thu, 11 Aug 2022 03:04:28 -0700 (PDT) Received: from localhost ([::1]:58586 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oM53D-0003Yi-BE for importer@patchew.org; Thu, 11 Aug 2022 06:04:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34594) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oM4v2-0002Cb-4j; Thu, 11 Aug 2022 05:56:00 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:3238) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oM4v0-0002gL-JL; Thu, 11 Aug 2022 05:55:59 -0400 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 27B9hGfV021457; Thu, 11 Aug 2022 09:55:42 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hvycs0a9t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 11 Aug 2022 09:55:42 +0000 Received: from m0098417.ppops.net (m0098417.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 27B9jwFY027592; Thu, 11 Aug 2022 09:55:41 GMT Received: from ppma04fra.de.ibm.com (6a.4a.5195.ip4.static.sl-reverse.com [149.81.74.106]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hvycs0a8y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 11 Aug 2022 09:55:41 +0000 Received: from pps.filterd (ppma04fra.de.ibm.com [127.0.0.1]) by ppma04fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 27B9oPBp030888; Thu, 11 Aug 2022 09:55:39 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma04fra.de.ibm.com with ESMTP id 3huww19d7v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 11 Aug 2022 09:55:39 +0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 27B9taPX29950446 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Aug 2022 09:55:36 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4281FA404D; Thu, 11 Aug 2022 09:55:36 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A303FA4040; Thu, 11 Aug 2022 09:55:35 +0000 (GMT) Received: from heavy.ibmuc.com (unknown [9.171.43.253]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 11 Aug 2022 09:55:35 +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=LNJWTjXEDDLzto9iALwGRYwubqmvc7lVDMXP25KOpVY=; b=cbGo04X5rt7GXHWoCqokjInmpqNS/Jcc/T4CjVVdz1EXuaYWol1MCKuCUVvt1agRJBbx tmxKChcLilGlnVM/x2faAE18MB3MF5gjul6sq7EjoQBKWiKY+nC3ha2VzND6Tds3/k4f A9smdl9Fwgvythtp7US6x91mGj4zfRovxcqYe2bgephO/E335GvX7jJjAvEo/ezFtkRI 0k4CX4UEt5cYebTBgnAN5Sjl8hTThL5lOhPizHjnR4vTcN+ttw01LvV4Mm/OyKzGcA6r 5wHC79rSWIW/EQdQZnLjG6u7TNrBfoCYQ6OUE7eEQPp1M0JtFqexBlnftPwJ9f7FEoqc yQ== From: Ilya Leoshkevich To: Laurent Vivier , Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , Richard Henderson , Paolo Bonzini , David Hildenbrand , Peter Maydell Cc: qemu-devel@nongnu.org, qemu-s390x@nongnu.org, Christian Borntraeger , Ilya Leoshkevich Subject: [PATCH v4 1/5] accel/tcg: Invalidate translations when clearing PAGE_EXEC Date: Thu, 11 Aug 2022 11:55:30 +0200 Message-Id: <20220811095534.241224-2-iii@linux.ibm.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220811095534.241224-1-iii@linux.ibm.com> References: <20220811095534.241224-1-iii@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: EY0s4g3Kw_LFEugvoroab1mYUZOYDGTU X-Proofpoint-GUID: 6u784K7NpgCYsnuuHMQWwS5ypBNsjB2u X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-08-11_05,2022-08-10_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 spamscore=0 adultscore=0 mlxscore=0 clxscore=1015 priorityscore=1501 lowpriorityscore=0 mlxlogscore=999 impostorscore=0 phishscore=0 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2207270000 definitions=main-2208110027 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.158.5; envelope-from=iii@linux.ibm.com; helo=mx0b-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1660212269522100001 Content-Type: text/plain; charset="utf-8" In the following sequence: addr(); mprotect(addr, 0x1000, PROT_NONE); addr(); the second call must cause a SEGV, but it doesn't, because there is a cached translation. Drop it. Signed-off-by: Ilya Leoshkevich --- accel/tcg/translate-all.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index ef62a199c7..32ea5f0adf 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -2295,12 +2295,19 @@ void page_set_flags(target_ulong start, target_ulon= g end, int flags) len !=3D 0; len -=3D TARGET_PAGE_SIZE, addr +=3D TARGET_PAGE_SIZE) { PageDesc *p =3D page_find_alloc(addr >> TARGET_PAGE_BITS, 1); + bool write_set, exec_cleared; =20 - /* If the write protection bit is set, then we invalidate - the code inside. */ - if (!(p->flags & PAGE_WRITE) && - (flags & PAGE_WRITE) && - p->first_tb) { + /* + * If the write protection bit is set, then we invalidate the code + * inside. + */ + write_set =3D !(p->flags & PAGE_WRITE) && (flags & PAGE_WRITE); + /* + * If PAGE_EXEC is cleared, we also need to invalidate the code in + * order to force a fault when trying to run it. + */ + exec_cleared =3D (p->flags & PAGE_EXEC) && !(flags & PAGE_EXEC); + if ((write_set || exec_cleared) && p->first_tb) { tb_invalidate_phys_page(addr, 0); } if (reset_target_data) { --=20 2.37.1 From nobody Mon Apr 29 03:03:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1660211871; cv=none; d=zohomail.com; s=zohoarc; b=KJRQc3REJq0vOzdOxL9OICJVKqRDjL19RqLo3qbTpa7nmKY1OxUHaKuxjgfOaDkuTWdNGCcTYOizKoPr9sjJQFXfHifFPbYKjGKHe723R6hEiXP0HTmCXKFFgKmjJIYGBA0gwqstW3ICIhhTaEgfFLMXb/R8YzwBGrVfAaYq4V4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660211871; 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=+JAO3hReEkzoOoRBeJnKndQpD4pR/meFfm3qaYPkoH8=; b=mR5yPfe+Ytjc3o5uL3ubS/6vgRhzVekWblQV5LYB+7UoI4c9VbDd7N69K2Hw9ciI8PO82lW7rnv45FcV4ENVXbXWbZk0XjDfTQJcLaYBF/8yvVtuzRL5/7d/oxiAcgnUqvvX/AOMkZKNv9nNOR6yQk9OgwvlG29d9MztpmQ6OnY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16602118712281008.017581827226; Thu, 11 Aug 2022 02:57:51 -0700 (PDT) Received: from localhost ([::1]:48592 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oM4wn-0004Kx-M4 for importer@patchew.org; Thu, 11 Aug 2022 05:57:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34542) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oM4uy-0002Ak-HB; Thu, 11 Aug 2022 05:55:56 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:35776) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oM4uw-0002fo-GD; Thu, 11 Aug 2022 05:55:56 -0400 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 27B82H70003823; Thu, 11 Aug 2022 09:55:44 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hvuggq9ec-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 11 Aug 2022 09:55:44 +0000 Received: from m0098404.ppops.net (m0098404.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 27B9jH8c023063; Thu, 11 Aug 2022 09:55:43 GMT Received: from ppma03fra.de.ibm.com (6b.4a.5195.ip4.static.sl-reverse.com [149.81.74.107]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hvuggq9d5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 11 Aug 2022 09:55:43 +0000 Received: from pps.filterd (ppma03fra.de.ibm.com [127.0.0.1]) by ppma03fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 27B9pARm022084; Thu, 11 Aug 2022 09:55:40 GMT Received: from b06avi18878370.portsmouth.uk.ibm.com (b06avi18878370.portsmouth.uk.ibm.com [9.149.26.194]) by ppma03fra.de.ibm.com with ESMTP id 3huwvfsda5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 11 Aug 2022 09:55:40 +0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 27B9tsAN31850996 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Aug 2022 09:55:54 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F18BAA404D; Thu, 11 Aug 2022 09:55:36 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 559FEA4040; Thu, 11 Aug 2022 09:55:36 +0000 (GMT) Received: from heavy.ibmuc.com (unknown [9.171.43.253]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 11 Aug 2022 09:55:36 +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=+JAO3hReEkzoOoRBeJnKndQpD4pR/meFfm3qaYPkoH8=; b=a4oMepT9iwaGEzc2FrX5kVyi2qCF7XOUQlKnGSRpc7mqGjdLyMClJf+kaHNHlmAIczSg Prn7XOcLv77CP485+aWuSps7cg26tdE7h9+VkYrZccLLCtRNc4pCC0QJW3uWMtuRiC03 /NWNUBrXqwHJ5LoAtW16+r830P21X1ESOZMFBZj/++elMTmqKQsZP+7uZuMx77F09Mbf oxvIVQtCKSj7/lWsYr2onjBXlfnePyFql4TFRQQuiDsXklDSx1zAJ5iixvomRdfh3rf8 9HqYwZrlWh+4IaLyfF9BqR9HiNVundgL8mTTFYlDGnuQfyixDP0uXSskAgO+/kin9d0N 7A== From: Ilya Leoshkevich To: Laurent Vivier , Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , Richard Henderson , Paolo Bonzini , David Hildenbrand , Peter Maydell Cc: qemu-devel@nongnu.org, qemu-s390x@nongnu.org, Christian Borntraeger , Ilya Leoshkevich Subject: [PATCH v4 2/5] accel/tcg: Introduce is_same_page() Date: Thu, 11 Aug 2022 11:55:31 +0200 Message-Id: <20220811095534.241224-3-iii@linux.ibm.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220811095534.241224-1-iii@linux.ibm.com> References: <20220811095534.241224-1-iii@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 376dmWGanya0-5Ihw8W2cqLUElyKrjxm X-Proofpoint-GUID: 39QD_ek-qN3_LlWe0J0y1Ohi3A4pd3__ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-08-11_05,2022-08-10_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 malwarescore=0 adultscore=0 phishscore=0 spamscore=0 lowpriorityscore=0 suspectscore=0 clxscore=1015 priorityscore=1501 bulkscore=0 mlxscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2207270000 definitions=main-2208110027 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: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1660211873448100001 Content-Type: text/plain; charset="utf-8" Introduce a function that checks whether a given address is on the same page as where disassembly started. Having it improves readability of the following patches. Signed-off-by: Ilya Leoshkevich Reviewed-by: Richard Henderson --- include/exec/translator.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/exec/translator.h b/include/exec/translator.h index 7db6845535..d27f8c33b6 100644 --- a/include/exec/translator.h +++ b/include/exec/translator.h @@ -187,4 +187,14 @@ FOR_EACH_TRANSLATOR_LD(GEN_TRANSLATOR_LD) =20 #undef GEN_TRANSLATOR_LD =20 +/* + * Return whether addr is on the same page as where disassembly started. + * Translators can use this to enforce the rule that only single-insn + * translation blocks are allowed to cross page boundaries. + */ +static inline bool is_same_page(DisasContextBase *db, target_ulong addr) +{ + return ((addr ^ db->pc_first) & TARGET_PAGE_MASK) =3D=3D 0; +} + #endif /* EXEC__TRANSLATOR_H */ --=20 2.37.1 From nobody Mon Apr 29 03:03:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1660211884; cv=none; d=zohomail.com; s=zohoarc; b=X9oU4Ip9nJqfIlpa+xLezRQsoc4n60xwBT/tA7bfJSSOI30nTeJA3cPHLm3rOJyW09IGHm43n7EJ5qXGS8mCQj+VXlns0d/pmfdQH5fe5G0Tp4kCrdqL8f/7P9fODGSwQ8lmMqf/V2YMfA7h1id9BryrFzm7LJz5Up/Ek63GG7A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660211884; 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=g7kIo5Xtkc/K15l0qE10cE/d0JfELTGvxEDQdM76Yo4=; b=WJeUgD/esWCSI4z1Vv8SSCEZAn86P6un2wHVxk2+QzAYl+IKndmHYMbe9CbF5eHSmXq5JA2ZM6cIG4hrCY6Vfr463TS+Uz7akluDDWFOHS5Lo0r8c8hdV3akDfiNPo169FoSVduuXCuoaEEIf1133L95j4HHzogAW4PVjPAu0tM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1660211884966655.3239651941001; Thu, 11 Aug 2022 02:58:04 -0700 (PDT) Received: from localhost ([::1]:49348 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oM4x1-0004pD-WA for importer@patchew.org; Thu, 11 Aug 2022 05:58:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34596) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oM4v2-0002DP-MO; Thu, 11 Aug 2022 05:56:00 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:17930 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oM4v1-0002gS-3v; Thu, 11 Aug 2022 05:56:00 -0400 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 27B9HhEA001137; Thu, 11 Aug 2022 09:55:43 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3hvy0qs578-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 11 Aug 2022 09:55:43 +0000 Received: from m0098420.ppops.net (m0098420.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 27B9rMmK007460; Thu, 11 Aug 2022 09:55:43 GMT Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3hvy0qs56h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 11 Aug 2022 09:55:42 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 27B9oQgS027371; Thu, 11 Aug 2022 09:55:40 GMT Received: from b06avi18878370.portsmouth.uk.ibm.com (b06avi18878370.portsmouth.uk.ibm.com [9.149.26.194]) by ppma04ams.nl.ibm.com with ESMTP id 3huww2hv2v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 11 Aug 2022 09:55:40 +0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 27B9ttMQ27853222 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Aug 2022 09:55:55 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A69D6A404D; Thu, 11 Aug 2022 09:55:37 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1073CA4040; Thu, 11 Aug 2022 09:55:37 +0000 (GMT) Received: from heavy.ibmuc.com (unknown [9.171.43.253]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 11 Aug 2022 09:55:36 +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=g7kIo5Xtkc/K15l0qE10cE/d0JfELTGvxEDQdM76Yo4=; b=FJV8/X53NjpJjcu5kngwLat5pMZl1wfTEdqbVsS3sBHZ1a+GcTxhk1yPmRciZUMpEcup 0bOHPEeyJyBxiRNP8t7XR/onabaQG2tTZ/JrfjqBXU56Y6UVT6YdfYPoi4HiycmZjf+5 mV32ymcb7xypCwpBRoLcazTi3KK+pF0aSaZ937vOz3nP6inJuLle+49ZayaNLw2AziTs UDAK3w3r596RvMyBo4y+jY7XRiGiqJYsckRf0exWOGjUWagQ9YuTQVtb7KS7J5JIzGeo /sEZsA8rT9eNe5brgGcKIR1oByKAIzXHdPll6l464zcNKSizB3U/4/L33B4Obb3WBYUX Eg== From: Ilya Leoshkevich To: Laurent Vivier , Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , Richard Henderson , Paolo Bonzini , David Hildenbrand , Peter Maydell Cc: qemu-devel@nongnu.org, qemu-s390x@nongnu.org, Christian Borntraeger , Ilya Leoshkevich Subject: [PATCH v4 3/5] target/s390x: Make translator stop before the end of a page Date: Thu, 11 Aug 2022 11:55:32 +0200 Message-Id: <20220811095534.241224-4-iii@linux.ibm.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220811095534.241224-1-iii@linux.ibm.com> References: <20220811095534.241224-1-iii@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 23aqnJ8D_aphR08iyGH7a-8Ib3uN07Lp X-Proofpoint-GUID: UU2GTHDLLrBay0-xIyH5j-QAMfyTaGuX X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-08-11_05,2022-08-10_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 suspectscore=0 lowpriorityscore=0 mlxscore=0 bulkscore=0 impostorscore=0 malwarescore=0 clxscore=1015 phishscore=0 mlxlogscore=966 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2207270000 definitions=main-2208110027 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.158.5; envelope-from=iii@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1660211887134100001 Content-Type: text/plain; charset="utf-8" Right now translator stops right *after* the end of a page, which breaks reporting of fault locations when the last instruction of a multi-insn translation block crosses a page boundary. Signed-off-by: Ilya Leoshkevich Reviewed-by: Richard Henderson --- target/s390x/tcg/translate.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/target/s390x/tcg/translate.c b/target/s390x/tcg/translate.c index e2ee005671..8e45a0e0d3 100644 --- a/target/s390x/tcg/translate.c +++ b/target/s390x/tcg/translate.c @@ -6609,6 +6609,14 @@ static void s390x_tr_insn_start(DisasContextBase *dc= base, CPUState *cs) dc->insn_start =3D tcg_last_op(); } =20 +static target_ulong get_next_pc(CPUS390XState *env, DisasContext *s, + uint64_t pc) +{ + uint64_t insn =3D ld_code2(env, s, pc); + + return pc + get_ilen((insn >> 8) & 0xff); +} + static void s390x_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs) { CPUS390XState *env =3D cs->env_ptr; @@ -6616,10 +6624,9 @@ static void s390x_tr_translate_insn(DisasContextBase= *dcbase, CPUState *cs) =20 dc->base.is_jmp =3D translate_one(env, dc); if (dc->base.is_jmp =3D=3D DISAS_NEXT) { - uint64_t page_start; - - page_start =3D dc->base.pc_first & TARGET_PAGE_MASK; - if (dc->base.pc_next - page_start >=3D TARGET_PAGE_SIZE || dc->ex_= value) { + if (!is_same_page(dcbase, dc->base.pc_next) || + !is_same_page(dcbase, get_next_pc(env, dc, dc->base.pc_next)) = || + dc->ex_value) { dc->base.is_jmp =3D DISAS_TOO_MANY; } } --=20 2.37.1 From nobody Mon Apr 29 03:03:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1660212169; cv=none; d=zohomail.com; s=zohoarc; b=fqPnn0ZWhV4jCxfkUHv4ADzurwtOHkBhwuDxKkAZM13LqyxjN8ZXZNjBcdVeKJHwR1IOsy4UxkWEgonDRGkb19rDPTM1G+6JxGdOBFQHWW/X7Q55Jy0gWBQFoSG6z9myHYNndGlEsNeBzIOM3WZcUB1tLWhyxiJaBC51j3ZoTNc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660212169; 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=QC1HeWv+kGURyy5JaCVSxFdBov00nztQQa4gp0jMqcw=; b=dwHhZdgsxt4rveAlplkcnmz6p2SfmJtRq4XIKEPLOl1xiB6YxSljZgt5uwKvkdYMGav/A46bAWfOkoxYgFZsYsfoZdpHiOU5Qq5IErY6KPIesUukO/0IZedxw6OurKxOU70jZm9tV4VXhbVRy6SeTlvuRskGVZrGgEv5kH9TPlQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1660212169273249.93438896227212; Thu, 11 Aug 2022 03:02:49 -0700 (PDT) Received: from localhost ([::1]:55088 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oM51b-0000fV-VU for importer@patchew.org; Thu, 11 Aug 2022 06:02:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34558) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oM4v0-0002BP-GQ; Thu, 11 Aug 2022 05:55:58 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:35760) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oM4uw-0002fm-Fp; Thu, 11 Aug 2022 05:55:58 -0400 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 27B8nBqf004614; Thu, 11 Aug 2022 09:55:45 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hvxkf1tmd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 11 Aug 2022 09:55:44 +0000 Received: from m0098410.ppops.net (m0098410.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 27B8sVK1022932; Thu, 11 Aug 2022 09:55:44 GMT Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hvxkf1tka-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 11 Aug 2022 09:55:43 +0000 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 27B9p7mP031835; Thu, 11 Aug 2022 09:55:41 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 3huwvf1uhx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 11 Aug 2022 09:55:41 +0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 27B9r5A433227088 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Aug 2022 09:53:05 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 59B52A404D; Thu, 11 Aug 2022 09:55:38 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B8DE5A4040; Thu, 11 Aug 2022 09:55:37 +0000 (GMT) Received: from heavy.ibmuc.com (unknown [9.171.43.253]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 11 Aug 2022 09:55:37 +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=QC1HeWv+kGURyy5JaCVSxFdBov00nztQQa4gp0jMqcw=; b=cN3eINl/h3ywQjtriXuswF9LWAqXoL1Qb5B27VkNyS4GP+pueh9Q29wMiY/0/MfyNrc0 i/QjqDRBgKIMb4uU3bnHbx7w10xzIuUsRGDopLnhiyptelcunHVA8rKKahQQgf493BRp xTPyk8AellN81MYKiUEV0CmP1whWJwFCAobP/7DDuWnJL6ao+qk1/g6ebEwhkmjktNVX 47j344nJikRyT8AG4NbffPPQPmboQzYL/Lt27Z4i+I1C3PXlrrlPNOp88ghE+Nb/dY9z ouqAqW7xZRKITUtuZNQpMD+s7J9iXzK9/5QCiJOzC0GQ+dtUsF5sqvVvBf9u8JhcBvuK gw== From: Ilya Leoshkevich To: Laurent Vivier , Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , Richard Henderson , Paolo Bonzini , David Hildenbrand , Peter Maydell Cc: qemu-devel@nongnu.org, qemu-s390x@nongnu.org, Christian Borntraeger , Ilya Leoshkevich Subject: [PATCH v4 4/5] target/i386: Make translator stop before the end of a page Date: Thu, 11 Aug 2022 11:55:33 +0200 Message-Id: <20220811095534.241224-5-iii@linux.ibm.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220811095534.241224-1-iii@linux.ibm.com> References: <20220811095534.241224-1-iii@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: m2a3Gv9-Z7xzaNBSEENCg39wfue-7p2c X-Proofpoint-ORIG-GUID: rTn38ERfLL9ovMkNTWV-iqjR9Tvq6fVH X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-08-11_05,2022-08-10_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 impostorscore=0 bulkscore=0 mlxlogscore=999 spamscore=0 malwarescore=0 priorityscore=1501 phishscore=0 mlxscore=0 lowpriorityscore=0 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2207270000 definitions=main-2208110027 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: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1660212170482100001 Content-Type: text/plain; charset="utf-8" Right now translator stops right *after* the end of a page, which breaks reporting of fault locations when the last instruction of a multi-insn translation block crosses a page boundary. An implementation, like the one arm and s390x have, would require an i386 length disassembler, which is burdensome to maintain. Another alternative would be to single-step at the end of a guest page, but this may come with a performance impact. Fix by snapshotting disassembly state and restoring it after we figured out we crossed a page boundary. This includes rolling back cc_op updates and emitted ops. Signed-off-by: Ilya Leoshkevich Reviewed-by: Richard Henderson --- target/i386/tcg/translate.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index b7972f0ff5..2287d22c3a 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -130,6 +130,7 @@ typedef struct DisasContext { TCGv_i64 tmp1_i64; =20 sigjmp_buf jmpbuf; + TCGOp *prev_insn_end; } DisasContext; =20 /* The environment in which user-only runs is constrained. */ @@ -2008,6 +2009,12 @@ static uint64_t advance_pc(CPUX86State *env, DisasCo= ntext *s, int num_bytes) { uint64_t pc =3D s->pc; =20 + /* This is a subsequent insn that crosses a page boundary. */ + if (s->base.num_insns > 1 && + !is_same_page(&s->base, s->pc + num_bytes - 1)) { + siglongjmp(s->jmpbuf, 2); + } + s->pc +=3D num_bytes; if (unlikely(s->pc - s->pc_start > X86_MAX_INSN_LENGTH)) { /* If the instruction's 16th byte is on a different page than the = 1st, a @@ -4556,6 +4563,8 @@ static target_ulong disas_insn(DisasContext *s, CPUSt= ate *cpu) int modrm, reg, rm, mod, op, opreg, val; target_ulong next_eip, tval; target_ulong pc_start =3D s->base.pc_next; + bool orig_cc_op_dirty =3D s->cc_op_dirty; + CCOp orig_cc_op =3D s->cc_op; =20 s->pc_start =3D s->pc =3D pc_start; s->override =3D -1; @@ -4568,9 +4577,22 @@ static target_ulong disas_insn(DisasContext *s, CPUS= tate *cpu) s->rip_offset =3D 0; /* for relative ip address */ s->vex_l =3D 0; s->vex_v =3D 0; - if (sigsetjmp(s->jmpbuf, 0) !=3D 0) { + switch (sigsetjmp(s->jmpbuf, 0)) { + case 0: + break; + case 1: gen_exception_gpf(s); return s->pc; + case 2: + /* Restore state that may affect the next instruction. */ + s->cc_op_dirty =3D orig_cc_op_dirty; + s->cc_op =3D orig_cc_op; + s->base.num_insns--; + tcg_remove_ops_after(s->prev_insn_end); + s->base.is_jmp =3D DISAS_TOO_MANY; + return pc_start; + default: + g_assert_not_reached(); } =20 prefixes =3D 0; @@ -8632,6 +8654,7 @@ static void i386_tr_insn_start(DisasContextBase *dcba= se, CPUState *cpu) { DisasContext *dc =3D container_of(dcbase, DisasContext, base); =20 + dc->prev_insn_end =3D tcg_last_op(); tcg_gen_insn_start(dc->base.pc_next, dc->cc_op); } =20 --=20 2.37.1 From nobody Mon Apr 29 03:03:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1660212161; cv=none; d=zohomail.com; s=zohoarc; b=SB7wDEHP0GOLdOO9EDAJykHITJYcaiVz5toiFTKjkwZu/p2GTXTOPpVv0Sv7YrBggSp7gyghfmcw4xiilD94H6GonrQRTzLLjW8Ek0T8Ll02z5bZVstz2lEITfuxMIi6fwZJG5Aufh9dTECMnpKo4oQj3PI5iLknuOWTBSmQ82s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660212161; 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=rtgOdwlKL84LDuedjqddt8Q60nUJ68iFlIH3jXbWdN4=; b=nR16BwUYOMXERwvS4aFjeXZs/TbB0HMJDbzQDQpABXMTkOpOQnvU4h0CD1tn17KlUFVeF51/XTS8+Dpn4fvcSamBPcVob8GTm5Qitj7wNzJ7++fSiQ9V0oLjIDchDtkM3iuqhSR3+Y9fxB+Nb5DrmK+2FQsBITAsyQnZ1HwZrRs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1660212161760992.6608417779825; Thu, 11 Aug 2022 03:02:41 -0700 (PDT) Received: from localhost ([::1]:54942 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oM51U-0000a7-8t for importer@patchew.org; Thu, 11 Aug 2022 06:02:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34588) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oM4v1-0002CF-On; Thu, 11 Aug 2022 05:55:59 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:61306) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oM4uz-0002gB-FN; Thu, 11 Aug 2022 05:55:59 -0400 Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 27B9d0sv009954; Thu, 11 Aug 2022 09:55:46 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hvvtqwfju-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 11 Aug 2022 09:55:45 +0000 Received: from m0127361.ppops.net (m0127361.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 27B9e6iJ019558; Thu, 11 Aug 2022 09:55:44 GMT Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hvvtqwfj5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 11 Aug 2022 09:55:44 +0000 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 27B9p5YX031818; Thu, 11 Aug 2022 09:55:42 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma06ams.nl.ibm.com with ESMTP id 3huwvf1uhy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 11 Aug 2022 09:55:42 +0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 27B9tduH29425982 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Aug 2022 09:55:39 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0FA20A404D; Thu, 11 Aug 2022 09:55:39 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 70B74A4040; Thu, 11 Aug 2022 09:55:38 +0000 (GMT) Received: from heavy.ibmuc.com (unknown [9.171.43.253]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 11 Aug 2022 09:55:38 +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=rtgOdwlKL84LDuedjqddt8Q60nUJ68iFlIH3jXbWdN4=; b=dznBF8okbBQt8wP9Big/kpi8bcdRFCaa1fYAwS2YBzJYfc3C74ry4FmGqpHoGna1Dy+5 LVljXhMFiWhM+xPNwoEDL9BG4nQ1bcV/+JTIcHTebalh2iSWIKZ6tS3F+MKiALY57YWa vZeYlj7260ZXDugKIWS8ZDWS2PYlN0KW0zZ9JVIbG7tsPjc95SnPiK6gsPtEaTPtKrPo kOGZeIdI1DpLpQRJ6bIiYHYrHZghruYojVOJFljJoF5uOa3QRHPoIQOH9hi1hbCTO0iw 17qvwwcHtZnVM9xjGvM/WKJKOsZiaVbmV1gbc8f0djQiJDqcrlg8h4hk5ugrXF5WhpbD TA== From: Ilya Leoshkevich To: Laurent Vivier , Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , Richard Henderson , Paolo Bonzini , David Hildenbrand , Peter Maydell Cc: qemu-devel@nongnu.org, qemu-s390x@nongnu.org, Christian Borntraeger , Ilya Leoshkevich Subject: [PATCH v4 5/5] tests/tcg: Test siginfo_t contents when jumping to non-readable pages Date: Thu, 11 Aug 2022 11:55:34 +0200 Message-Id: <20220811095534.241224-6-iii@linux.ibm.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220811095534.241224-1-iii@linux.ibm.com> References: <20220811095534.241224-1-iii@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: c0vTB7Qxn3mQt0jY0WYxfo4_vQZXuTTh X-Proofpoint-GUID: e3kt17i47tNexmBsnumuZhdggnHtZh_q X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-08-11_05,2022-08-10_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 spamscore=0 impostorscore=0 mlxscore=0 suspectscore=0 lowpriorityscore=0 bulkscore=0 priorityscore=1501 phishscore=0 adultscore=0 malwarescore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2207270000 definitions=main-2208110027 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.158.5; envelope-from=iii@linux.ibm.com; helo=mx0b-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1660212162416100001 Content-Type: text/plain; charset="utf-8" Add x86_64 and s390x tests to prevent regressions. Signed-off-by: Ilya Leoshkevich --- tests/tcg/multiarch/noexec.h | 114 ++++++++++++++++++++++++ tests/tcg/s390x/Makefile.target | 1 + tests/tcg/s390x/noexec.c | 145 +++++++++++++++++++++++++++++++ tests/tcg/x86_64/Makefile.target | 3 +- tests/tcg/x86_64/noexec.c | 116 +++++++++++++++++++++++++ 5 files changed, 378 insertions(+), 1 deletion(-) create mode 100644 tests/tcg/multiarch/noexec.h create mode 100644 tests/tcg/s390x/noexec.c create mode 100644 tests/tcg/x86_64/noexec.c diff --git a/tests/tcg/multiarch/noexec.h b/tests/tcg/multiarch/noexec.h new file mode 100644 index 0000000000..a76e0aa9ea --- /dev/null +++ b/tests/tcg/multiarch/noexec.h @@ -0,0 +1,114 @@ +/* + * Common code for arch-specific MMU_INST_FETCH fault testing. + * + * Declare struct arch_noexec_test before including this file and define + * arch_check_mcontext() after that. + */ + +#include +#include +#include +#include +#include +#include +#include + +/* Forward declarations. */ + +static void arch_check_mcontext(const struct arch_noexec_test *test, + const mcontext_t *ctx); + +/* Utility functions. */ + +static void safe_print(const char *s) +{ + write(0, s, strlen(s)); +} + +static void safe_puts(const char *s) +{ + safe_print(s); + safe_print("\n"); +} + +#define PAGE_ALIGN(p) (void *)((unsigned long)(p) & ~0xfffUL) + +/* Testing infrastructure. */ + +struct noexec_test { + const char *name; + void (*func)(int); + void *page; + void *expected_si_addr; + struct arch_noexec_test arch; +}; + +static const struct noexec_test *current_noexec_test; + +static void handle_segv(int sig, siginfo_t *info, void *ucontext) +{ + int err; + + if (current_noexec_test =3D=3D NULL) { + safe_puts("[ FAILED ] unexpected SEGV"); + _exit(1); + } + + if (info->si_addr !=3D current_noexec_test->expected_si_addr) { + safe_puts("[ FAILED ] wrong si_addr"); + _exit(1); + } + + arch_check_mcontext(¤t_noexec_test->arch, + &((ucontext_t *)ucontext)->uc_mcontext); + + err =3D mprotect(current_noexec_test->page, 0x1000, PROT_READ | PROT_E= XEC); + if (err !=3D 0) { + safe_puts("[ FAILED ] mprotect() failed"); + _exit(1); + } + + current_noexec_test =3D NULL; +} + +static void test_noexec_1(const struct noexec_test *test) +{ + int ret; + + /* Trigger TB creation in order to test invalidation. */ + test->func(0); + + ret =3D mprotect(test->page, 0x1000, PROT_NONE); + assert(ret =3D=3D 0); + + /* Trigger SEGV and check that handle_segv() ran. */ + current_noexec_test =3D test; + test->func(0); + assert(current_noexec_test =3D=3D NULL); +} + +static int test_noexec(struct noexec_test *tests, size_t n_tests) +{ + struct sigaction act; + size_t i; + int err; + + memset(&act, 0, sizeof(act)); + act.sa_sigaction =3D handle_segv; + act.sa_flags =3D SA_SIGINFO; + err =3D sigaction(SIGSEGV, &act, NULL); + assert(err =3D=3D 0); + + for (i =3D 0; i < n_tests; i++) { + struct noexec_test *test =3D &tests[i]; + + safe_print("[ RUN ] "); + safe_puts(test->name); + test_noexec_1(test); + safe_puts("[ OK ]"); + } + + safe_puts("[ PASSED ]"); + + return EXIT_SUCCESS; +} diff --git a/tests/tcg/s390x/Makefile.target b/tests/tcg/s390x/Makefile.tar= get index 1a7a4a2f59..5e13a41c3f 100644 --- a/tests/tcg/s390x/Makefile.target +++ b/tests/tcg/s390x/Makefile.target @@ -16,6 +16,7 @@ TESTS+=3Dshift TESTS+=3Dtrap TESTS+=3Dsignals-s390x TESTS+=3Dbranch-relative-long +TESTS+=3Dnoexec =20 Z14_TESTS=3Dvfminmax vfminmax: LDFLAGS+=3D-lm diff --git a/tests/tcg/s390x/noexec.c b/tests/tcg/s390x/noexec.c new file mode 100644 index 0000000000..2dfc9ee817 --- /dev/null +++ b/tests/tcg/s390x/noexec.c @@ -0,0 +1,145 @@ +#define _GNU_SOURCE + +struct arch_noexec_test { + void *expected_pswa; + unsigned long expected_r2; +}; + +#include "../multiarch/noexec.h" + +static void arch_check_mcontext(const struct arch_noexec_test *test, + const mcontext_t *ctx) { + if (ctx->psw.addr !=3D (unsigned long)test->expected_pswa) { + safe_puts("[ FAILED ] wrong psw.addr"); + _exit(1); + } + + if (ctx->gregs[2] !=3D test->expected_r2) { + safe_puts("[ FAILED ] wrong r2"); + _exit(1); + } +} + +#define DEFINE_NX(name, offset) \ + void name ## _1(int); \ + void name ## _2(int); \ + void name ## _exrl(int); \ + extern const short name ## _end[]; \ + asm(/* Go to the specified page offset. */ \ + ".align 0x1000\n" \ + ".org .+" #offset "\n" \ + /* %r2 is 0 on entry, overwrite it with 1. */ \ + ".globl " #name "_1\n" \ + #name "_1:\n" \ + ".cfi_startproc\n" \ + "lgfi %r2,1\n" \ + /* Overwrite %2 with 2. */ \ + ".globl " #name "_2\n" \ + #name "_2:\n" \ + "lgfi %r2,2\n" \ + "br %r14\n" \ + /* End of code. */ \ + ".globl " #name "_end\n" \ + #name "_end:\n" \ + ".cfi_endproc\n" \ + /* Go to the next page. */ \ + ".align 0x1000\n" \ + /* Break alignment. */ \ + "nopr %r7\n" \ + ".globl " #name "_exrl\n" \ + #name "_exrl:\n" \ + ".cfi_startproc\n" \ + "exrl %r0," #name "_2\n" \ + "br %r14\n" \ + ".cfi_endproc"); + +/* noexec_1 is executable, noexec_2 is non-executable. */ +DEFINE_NX(noexec, 0xffa); + +/* + * noexec_cross_1 is executable, noexec_cross_2 crosses non-executable page + * boundary. + */ +DEFINE_NX(noexec_cross, 0xff8); + +/* noexec_full_1 and noexec_full_2 are non-executable. */ +DEFINE_NX(noexec_full, 0x322); + +int main(void) +{ + struct noexec_test noexec_tests[] =3D { + { + .name =3D "Fallthrough", + .func =3D noexec_1, + .page =3D noexec_2, + .expected_si_addr =3D noexec_2, + .arch =3D { + .expected_pswa =3D noexec_2, + .expected_r2 =3D 1, + }, + }, + { + .name =3D "Jump", + .func =3D noexec_2, + .page =3D noexec_2, + .expected_si_addr =3D noexec_2, + .arch =3D { + .expected_pswa =3D noexec_2, + .expected_r2 =3D 0, + }, + }, + { + .name =3D "EXRL", + .func =3D noexec_exrl, + .page =3D noexec_2, + .expected_si_addr =3D PAGE_ALIGN(noexec_end), + .arch =3D { + .expected_pswa =3D noexec_exrl, + .expected_r2 =3D 0, + }, + }, + { + .name =3D "Fallthrough [cross]", + .func =3D noexec_cross_1, + .page =3D PAGE_ALIGN(noexec_cross_end), + .expected_si_addr =3D PAGE_ALIGN(noexec_cross_end), + .arch =3D { + .expected_pswa =3D noexec_cross_2, + .expected_r2 =3D 1, + }, + }, + { + .name =3D "Jump [cross]", + .func =3D noexec_cross_2, + .page =3D PAGE_ALIGN(noexec_cross_end), + .expected_si_addr =3D PAGE_ALIGN(noexec_cross_end), + .arch =3D { + .expected_pswa =3D noexec_cross_2, + .expected_r2 =3D 0, + }, + }, + { + .name =3D "EXRL [cross]", + .func =3D noexec_cross_exrl, + .page =3D PAGE_ALIGN(noexec_cross_end), + .expected_si_addr =3D PAGE_ALIGN(noexec_cross_end), + .arch =3D { + .expected_pswa =3D noexec_cross_exrl, + .expected_r2 =3D 0, + }, + }, + { + .name =3D "Jump [full]", + .func =3D noexec_full_1, + .page =3D PAGE_ALIGN(noexec_full_1), + .expected_si_addr =3D PAGE_ALIGN(noexec_full_1), + .arch =3D { + .expected_pswa =3D noexec_full_1, + .expected_r2 =3D 0, + }, + }, + }; + + return test_noexec(noexec_tests, + sizeof(noexec_tests) / sizeof(noexec_tests[0])); +} diff --git a/tests/tcg/x86_64/Makefile.target b/tests/tcg/x86_64/Makefile.t= arget index b71a6bcd5e..c0e7e5b005 100644 --- a/tests/tcg/x86_64/Makefile.target +++ b/tests/tcg/x86_64/Makefile.target @@ -10,6 +10,7 @@ include $(SRC_PATH)/tests/tcg/i386/Makefile.target =20 ifeq ($(filter %-linux-user, $(TARGET)),$(TARGET)) X86_64_TESTS +=3D vsyscall +X86_64_TESTS +=3D noexec TESTS=3D$(MULTIARCH_TESTS) $(X86_64_TESTS) test-x86_64 else TESTS=3D$(MULTIARCH_TESTS) @@ -20,5 +21,5 @@ test-x86_64: LDFLAGS+=3D-lm -lc test-x86_64: test-i386.c test-i386.h test-i386-shift.h test-i386-muldiv.h $(CC) $(CFLAGS) $< -o $@ $(LDFLAGS) =20 -vsyscall: $(SRC_PATH)/tests/tcg/x86_64/vsyscall.c +%: $(SRC_PATH)/tests/tcg/x86_64/%.c $(CC) $(CFLAGS) $< -o $@ $(LDFLAGS) diff --git a/tests/tcg/x86_64/noexec.c b/tests/tcg/x86_64/noexec.c new file mode 100644 index 0000000000..ec07c9f0ba --- /dev/null +++ b/tests/tcg/x86_64/noexec.c @@ -0,0 +1,116 @@ +#define _GNU_SOURCE + +struct arch_noexec_test { + void *expected_rip; + unsigned long expected_rdi; +}; + +#include "../multiarch/noexec.h" + +static void arch_check_mcontext(const struct arch_noexec_test *test, + const mcontext_t *ctx) { + if (ctx->gregs[REG_RIP] !=3D (unsigned long)test->expected_rip) { + safe_puts("[ FAILED ] wrong rip"); + _exit(1); + } + + if (ctx->gregs[REG_RDI] !=3D test->expected_rdi) { + safe_puts("[ FAILED ] wrong rdi"); + _exit(1); + } +} + +#define DEFINE_NX(name, offset) \ + void name ## _1(int); \ + void name ## _2(int); \ + extern const short name ## _end[]; \ + asm(/* Go to the specified page offset. */ \ + ".align 0x1000\n" \ + ".org .+" #offset "\n" \ + /* %rdi is 0 on entry, overwrite it with 1. */ \ + ".globl " #name "_1\n" \ + #name "_1:\n" \ + ".cfi_startproc\n" \ + "movq $1,%rdi\n" \ + /* Overwrite %rdi with 2. */ \ + ".globl " #name "_2\n" \ + #name "_2:\n" \ + "movq $2,%rdi\n" \ + "ret\n" \ + /* End of code. */ \ + ".globl " #name "_end\n" \ + #name "_end:\n" \ + ".cfi_endproc\n" \ + /* Go to the next page. */ \ + ".align 0x1000"); + +/* noexec_1 is executable, noexec_2 is non-executable. */ +DEFINE_NX(noexec, 0xff9); + +/* + * noexec_cross_1 is executable, noexec_cross_2 crosses non-executable page + * boundary. + */ +DEFINE_NX(noexec_cross, 0xff8); + +/* noexec_full_1 and noexec_full_2 are non-executable. */ +DEFINE_NX(noexec_full, 0x321); + +int main(void) +{ + struct noexec_test noexec_tests[] =3D { + { + .name =3D "Fallthrough", + .func =3D noexec_1, + .page =3D noexec_2, + .expected_si_addr =3D noexec_2, + .arch =3D { + .expected_rip =3D noexec_2, + .expected_rdi =3D 1, + }, + }, + { + .name =3D "Jump", + .func =3D noexec_2, + .page =3D noexec_2, + .expected_si_addr =3D noexec_2, + .arch =3D { + .expected_rip =3D noexec_2, + .expected_rdi =3D 0, + }, + }, + { + .name =3D "Fallthrough [cross]", + .func =3D noexec_cross_1, + .page =3D PAGE_ALIGN(noexec_cross_end), + .expected_si_addr =3D PAGE_ALIGN(noexec_cross_end), + .arch =3D { + .expected_rip =3D noexec_cross_2, + .expected_rdi =3D 1, + }, + }, + { + .name =3D "Jump [cross]", + .func =3D noexec_cross_2, + .page =3D PAGE_ALIGN(noexec_cross_end), + .expected_si_addr =3D PAGE_ALIGN(noexec_cross_end), + .arch =3D { + .expected_rip =3D noexec_cross_2, + .expected_rdi =3D 0, + }, + }, + { + .name =3D "Jump [full]", + .func =3D noexec_full_1, + .page =3D PAGE_ALIGN(noexec_full_1), + .expected_si_addr =3D noexec_full_1, + .arch =3D { + .expected_rip =3D noexec_full_1, + .expected_rdi =3D 0, + }, + }, + }; + + return test_noexec(noexec_tests, + sizeof(noexec_tests) / sizeof(noexec_tests[0])); +} --=20 2.37.1