From nobody Tue Nov 26 22:23:37 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=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1704757188; cv=none; d=zohomail.com; s=zohoarc; b=hs3zPmHnUOj3DwyU6UcKRm5nfh6GM/6dJIMZLh8D9aYiBcsknnUmnrbN8Z6D774uDuB4P/wXdhCdLsZ7vPze5tS8Pq5VbEkUIB2uUnX/hF+zdgZM9YzTY6gXDn+sUdrrTnzotGEZejxTktTjwdsk1UQGELqGC0mnVL/fk7buEOg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704757188; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=BnOVy1brSmNwOJlli/9cw4CpTyAc6Y9wcRr8LqAG3Kk=; b=C2iheEA0Ex419X9HyJo+jw2pEAjO63ILw64vCeaNK/p+6P5EBihA3vNHp7FMEeEGejiICXsL6UUwK9+MzdjiysFiHRfBJ++OGqEOPFoI5ohPRZNl0c898TCpix399gYywmWQg8GcRU6zeNR5jrgIZunBd6gRd54kqt8INDemNq4= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1704757188441275.7095970695385; Mon, 8 Jan 2024 15:39:48 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rMzCh-00022H-Gx; Mon, 08 Jan 2024 18:38:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rMzCd-0001zO-Qp; Mon, 08 Jan 2024 18:38:43 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rMzCa-0005e8-4I; Mon, 08 Jan 2024 18:38:43 -0500 Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 408NBegH021919; Mon, 8 Jan 2024 23:38:38 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3vgsf9a04g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 08 Jan 2024 23:38:37 +0000 Received: from m0356516.ppops.net (m0356516.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 408NUuX0017289; Mon, 8 Jan 2024 23:38:37 GMT Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3vgsf9a049-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 08 Jan 2024 23:38:37 +0000 Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 408M0Ism000906; Mon, 8 Jan 2024 23:38:36 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 3vfkdk2xau-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 08 Jan 2024 23:38:36 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 408NcYSC11862738 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 8 Jan 2024 23:38:34 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9CAF420043; Mon, 8 Jan 2024 23:38:34 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F36EC20040; Mon, 8 Jan 2024 23:38:33 +0000 (GMT) Received: from heavy.boeblingen.de.ibm.com (unknown [9.171.15.162]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 8 Jan 2024 23:38:33 +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=BnOVy1brSmNwOJlli/9cw4CpTyAc6Y9wcRr8LqAG3Kk=; b=qKWtiLhS3x7+1MwxCTYf9T6YIMJUCiHv7P0xcZRGE2Cm7j7bMlGMCG2BkGxSJr2x8aIi VQRs/vSph4NRJEEefqygQ12Q+cY/VrAoBuMTer3xHKAo2gqak4tLvKl76n+UH1kzB8Rx JXWHHpJud/NYfWGoA8oVUnVs9TH+8+WCB9zjn953/cio6w2cVtUVb+Rk97h2GmbiHeyX SHGs+xd37FWkDWvfpLu3g0ZxqQZuvDPD6C8LP3Rh1KJQGT4JErIb23wd6m5Kovr8Ccyo jIKf7M38KkZGVheWA2H3cG5BzY/9aMO7/AaaJt4qfd8BT8SlaOidhGOPFxiSFVlm2H3S rA== From: Ilya Leoshkevich To: Richard Henderson , Peter Maydell , =?UTF-8?q?Alex=20Benn=C3=A9e?= , David Hildenbrand Cc: Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org, qemu-arm@nongnu.org, qemu-s390x@nongnu.org, Ilya Leoshkevich Subject: [PATCH 3/3] tests/tcg: Add the PROT_NONE gdbstub test Date: Tue, 9 Jan 2024 00:34:08 +0100 Message-ID: <20240108233821.201325-4-iii@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240108233821.201325-1-iii@linux.ibm.com> References: <20240108233821.201325-1-iii@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 0jjNaVQ6eF2q4Zx9cBbQqlgWLdhqjMuw X-Proofpoint-GUID: OupBdXrGsL_EUL7o2M5iNZkCHmrijP5I X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-08_10,2024-01-08_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 spamscore=0 adultscore=0 mlxlogscore=862 suspectscore=0 clxscore=1015 impostorscore=0 phishscore=0 bulkscore=0 lowpriorityscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2401080192 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_H4=0.001, RCVD_IN_MSPIKE_WL=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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1704757190053100003 Content-Type: text/plain; charset="utf-8" Make sure that qemu gdbstub, like gdbserver, allows reading from and writing to PROT_NONE pages. Signed-off-by: Ilya Leoshkevich --- tests/tcg/multiarch/Makefile.target | 9 +++++- tests/tcg/multiarch/gdbstub/prot-none.py | 22 ++++++++++++++ tests/tcg/multiarch/prot-none.c | 38 ++++++++++++++++++++++++ 3 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 tests/tcg/multiarch/gdbstub/prot-none.py create mode 100644 tests/tcg/multiarch/prot-none.c diff --git a/tests/tcg/multiarch/Makefile.target b/tests/tcg/multiarch/Make= file.target index d31ba8d6ae4..315a2e13588 100644 --- a/tests/tcg/multiarch/Makefile.target +++ b/tests/tcg/multiarch/Makefile.target @@ -101,13 +101,20 @@ run-gdbstub-registers: sha512 --bin $< --test $(MULTIARCH_SRC)/gdbstub/registers.py, \ checking register enumeration) =20 +run-gdbstub-prot-none: prot-none + $(call run-test, $@, env PROT_NONE_PY=3D1 $(GDB_SCRIPT) \ + --gdb $(GDB) \ + --qemu $(QEMU) --qargs "$(QEMU_OPTS)" \ + --bin $< --test $(MULTIARCH_SRC)/gdbstub/prot-none.py, \ + accessing PROT_NONE memory) + else run-gdbstub-%: $(call skip-test, "gdbstub test $*", "need working gdb with $(patsubst -%= ,,$(TARGET_NAME)) support") endif EXTRA_RUNS +=3D run-gdbstub-sha1 run-gdbstub-qxfer-auxv-read \ run-gdbstub-proc-mappings run-gdbstub-thread-breakpoint \ - run-gdbstub-registers + run-gdbstub-registers run-gdbstub-prot-none =20 # ARM Compatible Semi Hosting Tests # diff --git a/tests/tcg/multiarch/gdbstub/prot-none.py b/tests/tcg/multiarch= /gdbstub/prot-none.py new file mode 100644 index 00000000000..751e44d5b93 --- /dev/null +++ b/tests/tcg/multiarch/gdbstub/prot-none.py @@ -0,0 +1,22 @@ +"""Test that GDB can access PROT_NONE pages. + +This runs as a sourced script (via -x, via run-test.py). + +SPDX-License-Identifier: GPL-2.0-or-later +""" +from test_gdbstub import main, report + + +def run_test(): + """Run through the tests one by one""" + gdb.Breakpoint("break_here") + gdb.execute("continue") + val =3D int(gdb.parse_and_eval("*p")) + report(val =3D=3D 42, "{} !=3D 42".format(val)) + gdb.execute("set *p =3D 24") + gdb.execute("continue") + exitcode =3D int(gdb.parse_and_eval("$_exitcode")) + report(exitcode =3D=3D 0, "{} !=3D 0".format(exitcode)) + + +main(run_test) diff --git a/tests/tcg/multiarch/prot-none.c b/tests/tcg/multiarch/prot-non= e.c new file mode 100644 index 00000000000..66e38065cf0 --- /dev/null +++ b/tests/tcg/multiarch/prot-none.c @@ -0,0 +1,38 @@ +/* + * Test that GDB can access PROT_NONE pages. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ +#include +#include +#include +#include + +void break_here(long *p) +{ +} + +int main(void) +{ + long pagesize =3D sysconf(_SC_PAGESIZE); + int err; + long *p; + + p =3D mmap(NULL, pagesize, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + assert(p !=3D MAP_FAILED); + *p =3D 42; + + err =3D mprotect(p, pagesize, PROT_NONE); + assert(err =3D=3D 0); + + break_here(p); + + err =3D mprotect(p, pagesize, PROT_READ); + assert(err =3D=3D 0); + if (getenv("PROT_NONE_PY")) { + assert(*p =3D=3D 24); + } + + return EXIT_SUCCESS; +} --=20 2.43.0