From nobody Sun Nov 24 15:02:12 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=1722592990; cv=none; d=zohomail.com; s=zohoarc; b=Hibz3BoEq2ViFz5TON4/MF50/CSewWhei2y7NvOHZ++WaBrBRYE6aqpKj++G5l9kdQpdIOQ8inihP0LTwrQfneosNRbPRdfpXRjKzy0eV/mqSfJXo6R5rP3CHXxalZYP5j1PExkfeIWiO2vMOk6FZ/1NcbNRoqucLV73BPgOo3o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722592990; 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=TiVy1OLCQMJp3DBn71dMrmHoNkskSZfSpCctCu53ONs=; b=FYgodM0B9sIz4fHWXvsv2gQC6Uu5CB3RUzm0rjsNUNOfjopEWG2tZOTmKlqslXRs9eUK7Z8ItBSHdVkAcf5sb1p4ligNx4LxaXL4Hh8EC8gf7tZgU4SAEPSqXppQmKlK0/5eN1gwr/ObOK79kfpG1iomtWz9gD0+llPvkSP4lTM= 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 1722592990627895.5968606693151; Fri, 2 Aug 2024 03:03:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sZp7C-0007H9-Kq; Fri, 02 Aug 2024 06:02:26 -0400 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 1sZp79-00079i-Vq for qemu-devel@nongnu.org; Fri, 02 Aug 2024 06:02:23 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sZp77-0004eA-G8 for qemu-devel@nongnu.org; Fri, 02 Aug 2024 06:02:23 -0400 Received: from pps.filterd (m0353728.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4729TxKa015214; Fri, 2 Aug 2024 10:02:17 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 40rvuw02c3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 02 Aug 2024 10:02:17 +0000 (GMT) Received: from m0353728.ppops.net (m0353728.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 472A2G8d012643; Fri, 2 Aug 2024 10:02:16 GMT Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 40rvuw02c1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 02 Aug 2024 10:02:16 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 47277Emn011133; Fri, 2 Aug 2024 10:02:15 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 40ncqn6jp3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 02 Aug 2024 10:02:15 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 472A2B6p27001170 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 2 Aug 2024 10:02:13 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3BB7620063; Fri, 2 Aug 2024 10:02:11 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D83FF2004F; Fri, 2 Aug 2024 10:02:10 +0000 (GMT) Received: from heavy.ibm.com (unknown [9.171.14.120]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 2 Aug 2024 10:02: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=TiVy1OLCQMJp3 DBn71dMrmHoNkskSZfSpCctCu53ONs=; b=KB/5s42ZxQhlTHju3PWIFhuN9orov jBRgqq2huTf/e3oVNRIVegte51qnzVGKxIXqlSOs/K5wQGwkawWIa/KiXKwRGWoz 8eoe6bAQK2eHFWvQN0lca4mT3O81zpjI2B/dvCeIJcn3ZWu8l6m7TbkgjzTGx/RV +dFsgmvmcZOBCS8z74j0MK7lsBKiMexGeJKQrKv0dOg4ubi/R1gbrIrpLdlhs9cW gUwiTd/ho8HvckObCyg+wmkDFZobrjC6UW6aWVqVyS9YElxg1qNSPluWcm8cwn8p HoBKRxVJUh20mQewx7kIpFjcJqlXcZ2IAUNwINEZBw0Ad6gxoFTJYcHdQ== From: Ilya Leoshkevich To: Laurent Vivier , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paolo Bonzini , Richard Henderson Cc: qemu-devel@nongnu.org, Ilya Leoshkevich Subject: [PATCH 1/5] include/exec: Introduce env_cpu_const() Date: Fri, 2 Aug 2024 11:59:14 +0200 Message-ID: <20240802095942.34565-2-iii@linux.ibm.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240802095942.34565-1-iii@linux.ibm.com> References: <20240802095942.34565-1-iii@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: dL9y2OkZsCFBjiYz7btTwe83G-xVaf1H X-Proofpoint-ORIG-GUID: dFF2uZve5S9hH6_yXsiEFvS3oWcWvz2B X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-02_06,2024-08-01_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 phishscore=0 adultscore=0 suspectscore=0 malwarescore=0 lowpriorityscore=0 mlxscore=0 spamscore=0 priorityscore=1501 impostorscore=0 mlxlogscore=999 clxscore=1011 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2407110000 definitions=main-2408020066 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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.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: 1722592992017116600 Content-Type: text/plain; charset="utf-8" It's the same as env_cpu(), but for const objects. Signed-off-by: Ilya Leoshkevich Reviewed-by: Richard Henderson --- include/exec/cpu-common.h | 13 ++++++++++++- linux-user/elfload.c | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h index 2e1b499cb71..638dc806a5f 100644 --- a/include/exec/cpu-common.h +++ b/include/exec/cpu-common.h @@ -238,6 +238,17 @@ static inline ArchCPU *env_archcpu(CPUArchState *env) return (void *)env - sizeof(CPUState); } =20 +/** + * env_cpu_const(env) + * @env: The architecture environment + * + * Return the CPUState associated with the environment. + */ +static inline const CPUState *env_cpu_const(const CPUArchState *env) +{ + return (void *)env - sizeof(CPUState); +} + /** * env_cpu(env) * @env: The architecture environment @@ -246,7 +257,7 @@ static inline ArchCPU *env_archcpu(CPUArchState *env) */ static inline CPUState *env_cpu(CPUArchState *env) { - return (void *)env - sizeof(CPUState); + return (CPUState *)env_cpu_const(env); } =20 #ifndef CONFIG_USER_ONLY diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 0861f115fc4..05292c27776 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -4329,7 +4329,7 @@ static int wmr_write_region(void *opaque, target_ulon= g start, */ static int elf_core_dump(int signr, const CPUArchState *env) { - const CPUState *cpu =3D env_cpu((CPUArchState *)env); + const CPUState *cpu =3D env_cpu_const(env); const TaskState *ts =3D (const TaskState *)get_task_state((CPUState *)= cpu); struct rlimit dumpsize; CountAndSizeRegions css; --=20 2.45.2 From nobody Sun Nov 24 15:02:12 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=1722592987; cv=none; d=zohomail.com; s=zohoarc; b=L/xC+Xq8U2ephIn/+hUbuS4iQKiM4RnXv0adUWd5vhJALB5p5c5CGUy4W8O++5qdJr8pbPAWfaysxxBXEqnL8rs3i+eVXh6LQCigxckCpDdhf1mafAagvw14t3JE7ISsjVfM3Qm9RyGLmk33wrBCCgsUQjIUPfDIqVoTS0IB+BY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722592987; 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=xgiNEOZec+cTa1XyCOikEGB8SlWebH4QPlQyjtj1wUE=; b=Rfk37E9DlFhegxa4wN9fmMG/x2GtvJgis6pOV2Oj6h1TA1fMElx2dA+YFWy4/2Fb0apcN/GJPQBLUH1PKHumcmcsFKc0crieB+/WmZbRcUZFELS/4vcGUTKdyUdbuUOOqokeRLZQTY9cjN0OLgK5Tu0uFSkT+sEckncHRUr0ffA= 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 1722592987704410.3254109845325; Fri, 2 Aug 2024 03:03:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sZp7B-0007ES-Tn; Fri, 02 Aug 2024 06:02:25 -0400 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 1sZp78-00078y-Py for qemu-devel@nongnu.org; Fri, 02 Aug 2024 06:02:22 -0400 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 1sZp76-0004dU-R5 for qemu-devel@nongnu.org; Fri, 02 Aug 2024 06:02:22 -0400 Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4729HIZM018789; Fri, 2 Aug 2024 10:02:18 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 40ruypg6mq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 02 Aug 2024 10:02:17 +0000 (GMT) Received: from m0356516.ppops.net (m0356516.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 472A2HFQ006523; Fri, 2 Aug 2024 10:02:17 GMT Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 40ruypg6mk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 02 Aug 2024 10:02:17 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 4728orcN009205; Fri, 2 Aug 2024 10:02:16 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 40ndx3eatf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 02 Aug 2024 10:02:16 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 472A2CS851446106 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 2 Aug 2024 10:02:14 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A4B4920067; Fri, 2 Aug 2024 10:02:11 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4C91D2004F; Fri, 2 Aug 2024 10:02:11 +0000 (GMT) Received: from heavy.ibm.com (unknown [9.171.14.120]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 2 Aug 2024 10:02:11 +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=xgiNEOZec+cTa 1XyCOikEGB8SlWebH4QPlQyjtj1wUE=; b=oh/SvruPCSevgRBiLtsM1Q8v/phPD pHG8NitNA1x5TQd4vV6f3svYfUiDeJwamegV4osgspxfbLMsCfxkb7HCPImPaHnh Z+bHQ7bOlnofW7CfOsTux9+rMwJwhBLysTt8l9KIf4kcBk3JTuqevs2N6Vv1ydF+ A+5BkCV+xFUsACHUMyy0p4FD7e2weOqVfNg3aw7l9ACyTC/wVAJ3SnnUeqtsZmmO uLSM/u2PGeLRpo9A+bvyaapQdr0+uuhXFMtqKjk6rqVzROt+1J4pWIFByork6j9l IYHZNEegEjcm7zRseOHcJ+ds6S3mck53xhMmCGxPU31h2tndMmL8fctbA== From: Ilya Leoshkevich To: Laurent Vivier , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paolo Bonzini , Richard Henderson Cc: qemu-devel@nongnu.org, Ilya Leoshkevich Subject: [PATCH 2/5] linux-user/i386: Emulate orig_ax Date: Fri, 2 Aug 2024 11:59:15 +0200 Message-ID: <20240802095942.34565-3-iii@linux.ibm.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240802095942.34565-1-iii@linux.ibm.com> References: <20240802095942.34565-1-iii@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: rwiB53lT8I59F_9Rj7dfo6_S53MLMD9b X-Proofpoint-ORIG-GUID: xQoDlqG88Gie9iMIojC94aZjD5as5CaC X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-02_06,2024-08-01_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 suspectscore=0 mlxlogscore=913 phishscore=0 priorityscore=1501 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2407110000 definitions=main-2408020066 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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.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: 1722592988215116600 Content-Type: text/plain; charset="utf-8" The kernel uses orig_rax/orig_eax to store the syscall number before a syscall. One can see this value in core dumps and ptrace. Signed-off-by: Ilya Leoshkevich Reviewed-by: Richard Henderson --- linux-user/elfload.c | 4 ++-- linux-user/i386/cpu_loop.c | 3 +++ linux-user/qemu.h | 5 +++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 05292c27776..2d73382ae6b 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -203,7 +203,7 @@ static void elf_core_copy_regs(target_elf_gregset_t *re= gs, const CPUX86State *en (*regs)[12] =3D tswapreg(env->regs[R_EDX]); (*regs)[13] =3D tswapreg(env->regs[R_ESI]); (*regs)[14] =3D tswapreg(env->regs[R_EDI]); - (*regs)[15] =3D tswapreg(env->regs[R_EAX]); /* XXX */ + (*regs)[15] =3D tswapreg(get_task_state(env_cpu_const(env))->orig_ax); (*regs)[16] =3D tswapreg(env->eip); (*regs)[17] =3D tswapreg(env->segs[R_CS].selector & 0xffff); (*regs)[18] =3D tswapreg(env->eflags); @@ -306,7 +306,7 @@ static void elf_core_copy_regs(target_elf_gregset_t *re= gs, const CPUX86State *en (*regs)[8] =3D tswapreg(env->segs[R_ES].selector & 0xffff); (*regs)[9] =3D tswapreg(env->segs[R_FS].selector & 0xffff); (*regs)[10] =3D tswapreg(env->segs[R_GS].selector & 0xffff); - (*regs)[11] =3D tswapreg(env->regs[R_EAX]); /* XXX */ + (*regs)[11] =3D tswapreg(get_task_state(env_cpu_const(env))->orig_ax); (*regs)[12] =3D tswapreg(env->eip); (*regs)[13] =3D tswapreg(env->segs[R_CS].selector & 0xffff); (*regs)[14] =3D tswapreg(env->eflags); diff --git a/linux-user/i386/cpu_loop.c b/linux-user/i386/cpu_loop.c index 92beb6830cc..7a35215278a 100644 --- a/linux-user/i386/cpu_loop.c +++ b/linux-user/i386/cpu_loop.c @@ -172,6 +172,7 @@ static void emulate_vsyscall(CPUX86State *env) /* * Perform the syscall. None of the vsyscalls should need restarting. */ + get_task_state(env_cpu(env))->orig_ax =3D syscall; ret =3D do_syscall(env, syscall, env->regs[R_EDI], env->regs[R_ESI], env->regs[R_EDX], env->regs[10], env->regs[8], env->regs[9], 0, 0); @@ -221,6 +222,7 @@ void cpu_loop(CPUX86State *env) case EXCP_SYSCALL: #endif /* linux syscall from int $0x80 */ + get_task_state(cs)->orig_ax =3D env->regs[R_EAX]; ret =3D do_syscall(env, env->regs[R_EAX], env->regs[R_EBX], @@ -239,6 +241,7 @@ void cpu_loop(CPUX86State *env) #ifdef TARGET_X86_64 case EXCP_SYSCALL: /* linux syscall from syscall instruction. */ + get_task_state(cs)->orig_ax =3D env->regs[R_EAX]; ret =3D do_syscall(env, env->regs[R_EAX], env->regs[R_EDI], diff --git a/linux-user/qemu.h b/linux-user/qemu.h index a2961f503f4..85ba5a53869 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -159,6 +159,11 @@ struct TaskState { =20 /* Start time of task after system boot in clock ticks */ uint64_t start_boottime; + +#if defined(TARGET_I386) + /* Last syscall number. */ + target_ulong orig_ax; +#endif }; =20 abi_long do_brk(abi_ulong new_brk); --=20 2.45.2 From nobody Sun Nov 24 15:02:12 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=1722593014; cv=none; d=zohomail.com; s=zohoarc; b=lvKM4R5Qyfj4aMXMMOkRozG2BdIfH0drwlabQnkZlqMX3pehK8/A9BppkDWcplTQ/yFf28ARmGSc0pQkJTASd4aZ+xt/+rLipKgz+adupMFt8/faeVdb89x9TI/QYDEox+yhpykGel04/38PDjfUIg73cbwFiPO0p5T1qC4+uYI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722593014; 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=jaf4NZqXAJUq7YRAbcqCdpqjW48Fp+pO5ITMV63+9UA=; b=YLruhYq2oWnMCPSr79VN0M/zbfQIiA8DiBhlgMfqM8WFQ5DLmHfR28aCNcwDXMuxGvVvgrH1pWy+fda4klgUbi9whyD3dlCoKb3XWtdOYAP52Wsy+wuMrFyAIzJvv1shJn8SYmuOHn1tW+RM0AVvfTGLGEEZGINvJrmW9AW6nxg= 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 172259301418769.92389850398706; Fri, 2 Aug 2024 03:03:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sZp7E-0007MY-8K; Fri, 02 Aug 2024 06:02:28 -0400 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 1sZp7A-00079y-5E for qemu-devel@nongnu.org; Fri, 02 Aug 2024 06:02:24 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sZp77-0004iq-0G for qemu-devel@nongnu.org; Fri, 02 Aug 2024 06:02:23 -0400 Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4729xmhq026998; Fri, 2 Aug 2024 10:02:18 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 40rw9tr091-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 02 Aug 2024 10:02:17 +0000 (GMT) Received: from m0360083.ppops.net (m0360083.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 472A2H4T030683; Fri, 2 Aug 2024 10:02:17 GMT Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 40rw9tr08x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 02 Aug 2024 10:02:17 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 4726SNAf029118; Fri, 2 Aug 2024 10:02:16 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 40nbm16std-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 02 Aug 2024 10:02:16 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 472A2CYN57803262 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 2 Aug 2024 10:02:14 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 19FA12006B; Fri, 2 Aug 2024 10:02:12 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B51892006A; Fri, 2 Aug 2024 10:02:11 +0000 (GMT) Received: from heavy.ibm.com (unknown [9.171.14.120]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 2 Aug 2024 10:02:11 +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=jaf4NZqXAJUq7 YRAbcqCdpqjW48Fp+pO5ITMV63+9UA=; b=L9TsIKHieWGF5+WQNKzWsiIDF98+e fr/MhoLD8IjiCI0TqVXk26EGTMxsTWLFQQ0VYkuoyOELR97qipYl/jqq0hOi3MyQ vzw79xc0riCAaQBZM5xU85HG64ZU/O+0scO16WJtlqlQcyS75M2+gr7rW6u97bCN kLBHT9n0m0/06Mwj1rfpoWZn+IhGMmyU44MlwOpTAU3uZWyJ2KP3it80ZpXxPKBp oslHhpFgnSCrrykCH/W0xp/4nM+ooGEQbUcMpDazRH8z2X9pqtKDuIgqWaYEJVET ZxU8B19VzHAw5SxGD3oNboAaJOV/DHikktPkYANAyLGtbVKiyQOctbhzw== From: Ilya Leoshkevich To: Laurent Vivier , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paolo Bonzini , Richard Henderson Cc: qemu-devel@nongnu.org, Ilya Leoshkevich Subject: [PATCH 3/5] target/i386/gdbstub: Factor out gdb_get_reg() and gdb_write_reg() Date: Fri, 2 Aug 2024 11:59:16 +0200 Message-ID: <20240802095942.34565-4-iii@linux.ibm.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240802095942.34565-1-iii@linux.ibm.com> References: <20240802095942.34565-1-iii@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: fNl_JTk-73h5PktGgvIjHAg2oSFRyTRI X-Proofpoint-GUID: vKIzMZyDF7uCfsfcRfQFkEdYhYg2pjpM X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-02_06,2024-08-01_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 mlxscore=0 bulkscore=0 spamscore=0 clxscore=1015 priorityscore=1501 mlxlogscore=673 lowpriorityscore=0 malwarescore=0 impostorscore=0 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2407110000 definitions=main-2408020066 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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.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: 1722593016106116600 Content-Type: text/plain; charset="utf-8" i386 gdbstub handles both i386 and x86_64. Factor out two functions for reading and writing registers without knowing their bitness. Signed-off-by: Ilya Leoshkevich Reviewed-by: Richard Henderson --- target/i386/gdbstub.c | 52 ++++++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 21 deletions(-) diff --git a/target/i386/gdbstub.c b/target/i386/gdbstub.c index 4acf485879e..ec64ab6c53f 100644 --- a/target/i386/gdbstub.c +++ b/target/i386/gdbstub.c @@ -96,6 +96,19 @@ static int gdb_write_reg_cs64(uint32_t hflags, uint8_t *= buf, target_ulong *val) return 4; } =20 +static int gdb_get_reg(CPUX86State *env, GByteArray *mem_buf, target_ulong= val) +{ + if (TARGET_LONG_BITS =3D=3D 64) { + if (env->hflags & HF_CS64_MASK) { + return gdb_get_reg64(mem_buf, val); + } else { + return gdb_get_reg64(mem_buf, val & 0xffffffffUL); + } + } else { + return gdb_get_reg32(mem_buf, val); + } +} + int x86_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { X86CPU *cpu =3D X86_CPU(cs); @@ -137,15 +150,7 @@ int x86_cpu_gdb_read_register(CPUState *cs, GByteArray= *mem_buf, int n) } else { switch (n) { case IDX_IP_REG: - if (TARGET_LONG_BITS =3D=3D 64) { - if (env->hflags & HF_CS64_MASK) { - return gdb_get_reg64(mem_buf, env->eip); - } else { - return gdb_get_reg64(mem_buf, env->eip & 0xffffffffUL); - } - } else { - return gdb_get_reg32(mem_buf, env->eip); - } + return gdb_get_reg(env, mem_buf, env->eip); case IDX_FLAGS_REG: return gdb_get_reg32(mem_buf, env->eflags); =20 @@ -248,6 +253,22 @@ static int x86_cpu_gdb_load_seg(X86CPU *cpu, X86Seg sr= eg, uint8_t *mem_buf) return 4; } =20 +static int gdb_write_reg(CPUX86State *env, uint8_t *mem_buf, target_ulong = *val) +{ + if (TARGET_LONG_BITS =3D=3D 64) { + if (env->hflags & HF_CS64_MASK) { + *val =3D ldq_p(mem_buf); + } else { + *val =3D ldq_p(mem_buf) & 0xffffffffUL; + } + return 8; + } else { + *val &=3D ~0xffffffffUL; + *val |=3D (uint32_t)ldl_p(mem_buf); + return 4; + } +} + int x86_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) { X86CPU *cpu =3D X86_CPU(cs); @@ -288,18 +309,7 @@ int x86_cpu_gdb_write_register(CPUState *cs, uint8_t *= mem_buf, int n) } else { switch (n) { case IDX_IP_REG: - if (TARGET_LONG_BITS =3D=3D 64) { - if (env->hflags & HF_CS64_MASK) { - env->eip =3D ldq_p(mem_buf); - } else { - env->eip =3D ldq_p(mem_buf) & 0xffffffffUL; - } - return 8; - } else { - env->eip &=3D ~0xffffffffUL; - env->eip |=3D (uint32_t)ldl_p(mem_buf); - return 4; - } + return gdb_write_reg(env, mem_buf, &env->eip); case IDX_FLAGS_REG: env->eflags =3D ldl_p(mem_buf); return 4; --=20 2.45.2 From nobody Sun Nov 24 15:02:12 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=1722592998; cv=none; d=zohomail.com; s=zohoarc; b=AgNrp2Z1cH8elaiD2O69vwun3CuylzFMIQEp9c7HmZlHJ341FyJt0T2U8uR1rHG0vcZPHDHE5U6pYhtq4Z3X8DjNGmLmX4mUnoDRP6OsCoqQbTvR2cAGR7kQ/Ym/VVfPAAJWrj/rwXVkQbr3JCMR4HbVzm4SACrT9DQK5kB0TY4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722592998; 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=6cyJwVwQiB19W8amtncYiVUFzK3zjHt38qcWFDXwo2w=; b=ltWFNl6Mx5bRdgTT/S9LubVCzlDaB7as4IvEqCPr+7UyLVXO1mrrgMYcWGc7rXK+fjKx2JmHYUUZhkHtwY2LnbIxSXQu55ZGUqpc6g/AXY1mXCSWX6LHPO1aD56L0m76dMf6GjB4tJSdepz2UX53LXtaSuVIZbz8R5vMrL5VWQ8= 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 1722592998131818.1245244355192; Fri, 2 Aug 2024 03:03:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sZp7E-0007M8-5p; Fri, 02 Aug 2024 06:02:28 -0400 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 1sZp7A-0007AU-Dc for qemu-devel@nongnu.org; Fri, 02 Aug 2024 06:02:24 -0400 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 1sZp76-0004et-He for qemu-devel@nongnu.org; Fri, 02 Aug 2024 06:02:24 -0400 Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4729uS1N013971; Fri, 2 Aug 2024 10:02:18 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 40rq508qqj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 02 Aug 2024 10:02:17 +0000 (GMT) Received: from m0353725.ppops.net (m0353725.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 472A2Hsp025352; Fri, 2 Aug 2024 10:02:17 GMT Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 40rq508qqe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 02 Aug 2024 10:02:17 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 4727fQWO011170; Fri, 2 Aug 2024 10:02:16 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 40ncqn6jp4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 02 Aug 2024 10:02:16 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 472A2CXS56885606 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 2 Aug 2024 10:02:14 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 817FF2004F; Fri, 2 Aug 2024 10:02:12 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2A7A72006C; Fri, 2 Aug 2024 10:02:12 +0000 (GMT) Received: from heavy.ibm.com (unknown [9.171.14.120]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 2 Aug 2024 10:02:12 +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 :content-transfer-encoding:mime-version; s=pp1; bh=6cyJwVwQiB19W 8amtncYiVUFzK3zjHt38qcWFDXwo2w=; b=BtXvZ/O+UC+6v3pvtBPHW8+ZLrB5u auFI6cEq+0Tn6/Ax+xvUEqO/kongrFpfUhymBlcyLy/PSNueKn4ddG4ZIChbulPk eRIOYRM3XqTIJe86vgFckMVOnruRevCFMBBPwfREeQ/0D7u+mqjx4Sm8z3IbKoDu El1JNdEFM7SD2c+CAeTj86pZZg+D2OMNsqS/y46tg7GDgnS27dr+U0npTfMRp3CS qPbe2WYwkcummIQhD3Xi1T3ln0rBISbK9GYhWti1yi5loa1im20yxm0mwv8hchy5 x1RLSI0WcSWQcPJGL9RIdX6ptqTiKIbzaklfzl74909Ks+5vxbMnh44Lw== From: Ilya Leoshkevich To: Laurent Vivier , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paolo Bonzini , Richard Henderson Cc: qemu-devel@nongnu.org, Ilya Leoshkevich Subject: [PATCH 4/5] target/i386/gdbstub: Expose orig_ax Date: Fri, 2 Aug 2024 11:59:17 +0200 Message-ID: <20240802095942.34565-5-iii@linux.ibm.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240802095942.34565-1-iii@linux.ibm.com> References: <20240802095942.34565-1-iii@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: PFSZ990M2gV_1YJo7qm3hd59EuTbrzfk X-Proofpoint-ORIG-GUID: QUXnaIjrIg2Hvk0ozlYVDBKGCAgTNxbK Content-Transfer-Encoding: quoted-printable X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-02_06,2024-08-01_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 clxscore=1015 malwarescore=0 impostorscore=0 suspectscore=0 mlxlogscore=934 adultscore=0 mlxscore=0 lowpriorityscore=0 spamscore=0 phishscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2407110000 definitions=main-2408020066 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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.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: 1722593000011116600 Content-Type: text/plain; charset="utf-8" Copy XML files describing orig_ax from GDB and glue them with CPUX86State.orig_ax. Signed-off-by: Ilya Leoshkevich Reviewed-by: Richard Henderson --- configs/targets/i386-linux-user.mak | 2 +- configs/targets/x86_64-linux-user.mak | 2 +- gdb-xml/i386-32bit-linux.xml | 11 ++++++ gdb-xml/i386-64bit-linux.xml | 11 ++++++ target/i386/cpu.c | 1 + target/i386/cpu.h | 1 + target/i386/gdbstub.c | 51 +++++++++++++++++++++++++++ 7 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 gdb-xml/i386-32bit-linux.xml create mode 100644 gdb-xml/i386-64bit-linux.xml diff --git a/configs/targets/i386-linux-user.mak b/configs/targets/i386-lin= ux-user.mak index 5b2546a4309..b72a156473a 100644 --- a/configs/targets/i386-linux-user.mak +++ b/configs/targets/i386-linux-user.mak @@ -1,4 +1,4 @@ TARGET_ARCH=3Di386 TARGET_SYSTBL_ABI=3Di386 TARGET_SYSTBL=3Dsyscall_32.tbl -TARGET_XML_FILES=3D gdb-xml/i386-32bit.xml +TARGET_XML_FILES=3D gdb-xml/i386-32bit.xml gdb-xml/i386-32bit-linux.xml diff --git a/configs/targets/x86_64-linux-user.mak b/configs/targets/x86_64= -linux-user.mak index 9ceefbb615a..86042814d39 100644 --- a/configs/targets/x86_64-linux-user.mak +++ b/configs/targets/x86_64-linux-user.mak @@ -2,4 +2,4 @@ TARGET_ARCH=3Dx86_64 TARGET_BASE_ARCH=3Di386 TARGET_SYSTBL_ABI=3Dcommon,64 TARGET_SYSTBL=3Dsyscall_64.tbl -TARGET_XML_FILES=3D gdb-xml/i386-64bit.xml +TARGET_XML_FILES=3D gdb-xml/i386-64bit.xml gdb-xml/i386-64bit-linux.xml diff --git a/gdb-xml/i386-32bit-linux.xml b/gdb-xml/i386-32bit-linux.xml new file mode 100644 index 00000000000..5ffe5616e63 --- /dev/null +++ b/gdb-xml/i386-32bit-linux.xml @@ -0,0 +1,11 @@ + + + + + + + diff --git a/gdb-xml/i386-64bit-linux.xml b/gdb-xml/i386-64bit-linux.xml new file mode 100644 index 00000000000..0f26990d2f7 --- /dev/null +++ b/gdb-xml/i386-64bit-linux.xml @@ -0,0 +1,11 @@ + + + + + + + diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 85ef7452c04..52788e6170d 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -7831,6 +7831,7 @@ static void x86_cpu_realizefn(DeviceState *dev, Error= **errp) =20 mce_init(cpu); =20 + x86_cpu_gdb_init(cs); qemu_init_vcpu(cs); =20 /* diff --git a/target/i386/cpu.h b/target/i386/cpu.h index c6cc035df3d..f2819e91007 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -2226,6 +2226,7 @@ void x86_cpu_dump_state(CPUState *cs, FILE *f, int fl= ags); =20 int x86_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); int x86_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); +void x86_cpu_gdb_init(CPUState *cs); =20 void x86_cpu_list(void); int cpu_x86_support_mca_broadcast(CPUX86State *env); diff --git a/target/i386/gdbstub.c b/target/i386/gdbstub.c index ec64ab6c53f..ff688bd26ed 100644 --- a/target/i386/gdbstub.c +++ b/target/i386/gdbstub.c @@ -18,8 +18,13 @@ * License along with this library; if not, see . */ #include "qemu/osdep.h" +#include "accel/tcg/vcpu-state.h" #include "cpu.h" +#include "exec/gdbstub.h" #include "gdbstub/helpers.h" +#ifdef CONFIG_LINUX_USER +#include "linux-user/qemu.h" +#endif =20 #ifdef TARGET_X86_64 static const int gpr_map[16] =3D { @@ -407,3 +412,49 @@ int x86_cpu_gdb_write_register(CPUState *cs, uint8_t *= mem_buf, int n) /* Unrecognised register. */ return 0; } + +#ifdef CONFIG_LINUX_USER + +#define IDX_ORIG_AX 0 + +static int x86_cpu_gdb_read_linux_register(CPUState *cs, GByteArray *mem_b= uf, + int n) +{ + X86CPU *cpu =3D X86_CPU(cs); + CPUX86State *env =3D &cpu->env; + + switch (n) { + case IDX_ORIG_AX: + return gdb_get_reg(env, mem_buf, get_task_state(cs)->orig_ax); + } + return 0; +} + +static int x86_cpu_gdb_write_linux_register(CPUState *cs, uint8_t *mem_buf, + int n) +{ + X86CPU *cpu =3D X86_CPU(cs); + CPUX86State *env =3D &cpu->env; + + switch (n) { + case IDX_ORIG_AX: + return gdb_write_reg(env, mem_buf, &get_task_state(cs)->orig_ax); + } + return 0; +} + +#endif + +void x86_cpu_gdb_init(CPUState *cs) +{ +#ifdef CONFIG_LINUX_USER + gdb_register_coprocessor(cs, x86_cpu_gdb_read_linux_register, + x86_cpu_gdb_write_linux_register, +#ifdef TARGET_X86_64 + gdb_find_static_feature("i386-64bit-linux.xml= "), +#else + gdb_find_static_feature("i386-32bit-linux.xml= "), +#endif + 0); +#endif +} --=20 2.45.2 From nobody Sun Nov 24 15:02:12 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=1722592996; cv=none; d=zohomail.com; s=zohoarc; b=Q+IcUsEP3S0w/4WBqr3XapOga7gc957UVG+bla6Z0+Dzpcaj1D51qaSm2uqxLaNgtwTLuLSBoCqkxVccWYkczqd3OVIkbPSOKXClxYcA7D57usbaiBXTfK1tEAHIRFEB3xQe+l/OpXSPG6IFEEBm2kll2iQo/aNlJLyTXT0tOWE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722592996; 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=iIVjvu85D9K1qhEziIv0wA1/t1l4O02FOAAC99avhnI=; b=DaGgf9F/lzZKSFKrPlC5k9hnzY1sEHgIaRW/g0tNqAk6pxan062MRZieJz3D1w6BT1OeKDw5eq87tdB6eiKR4EugsgTw1IRFvNf7y+gZVoYGeQ+AZzym0AzFq1yI9ekbnsb4iyxcUzNrhEHbEHhS4Eja1nQ86p8UP0rZNwRN+LA= 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 1722592996520289.6851336870691; Fri, 2 Aug 2024 03:03:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sZp7D-0007JC-8q; Fri, 02 Aug 2024 06:02:27 -0400 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 1sZp7B-0007Cl-Ca for qemu-devel@nongnu.org; Fri, 02 Aug 2024 06:02:25 -0400 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 1sZp78-0004gT-Lk for qemu-devel@nongnu.org; Fri, 02 Aug 2024 06:02:25 -0400 Received: from pps.filterd (m0353723.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4729Iqd9021203; Fri, 2 Aug 2024 10:02:18 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 40ru3j89c1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 02 Aug 2024 10:02:18 +0000 (GMT) Received: from m0353723.ppops.net (m0353723.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 472A2HOU000924; Fri, 2 Aug 2024 10:02:17 GMT Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 40ru3j89bv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 02 Aug 2024 10:02:17 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 4727dOEr018863; Fri, 2 Aug 2024 10:02:17 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 40nc7q6n2x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 02 Aug 2024 10:02:16 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 472A2DQD57868674 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 2 Aug 2024 10:02:15 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E8F9A2005A; Fri, 2 Aug 2024 10:02:12 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9268B2006E; Fri, 2 Aug 2024 10:02:12 +0000 (GMT) Received: from heavy.ibm.com (unknown [9.171.14.120]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 2 Aug 2024 10:02:12 +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=iIVjvu85D9K1q hEziIv0wA1/t1l4O02FOAAC99avhnI=; b=kGXhBYRZhVgpnS6IEm4WOSCjUUkt2 PV2Q0i4Q159oq7JQeMUQtzQmi/S04T3pH3ts8TQlwQItKR7nPwsWM1F73+2sg5nt L7EhcvaNS2Bx2IcFesInEmgMRvJhjZZmCTW4SDqQIYxqtvLXsEPR7IwcFockNXQs n8ebj2tc4PJcDjFUncX1/t8zpzmEyOjPIHyxQcPbOiKDeqyApmiHiZ1SkdotnmvT Vf/v7WMkyOFXfJLl/9UAyFGReGsVVd1mYF3JzoGiNl4k2I4TYd4XhDDPHWnPk+sG Oh0Q692XqVVe5aFk6swHFgchu3thQG0Wbq9hilNLk6e2xqww1wgVuvkNQ== From: Ilya Leoshkevich To: Laurent Vivier , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paolo Bonzini , Richard Henderson Cc: qemu-devel@nongnu.org, Ilya Leoshkevich Subject: [PATCH 5/5] tests/tcg: Run test-proc-mappings.py on i386 Date: Fri, 2 Aug 2024 11:59:18 +0200 Message-ID: <20240802095942.34565-6-iii@linux.ibm.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240802095942.34565-1-iii@linux.ibm.com> References: <20240802095942.34565-1-iii@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: RBWOLJJzSaSMZfGJ5dRc78Qk-HuEJr-K X-Proofpoint-ORIG-GUID: Ihzb_VpYyTY_hOeEi1ds0RAZP0Iz8hq1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-02_06,2024-08-01_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 mlxlogscore=983 phishscore=0 clxscore=1015 priorityscore=1501 malwarescore=0 adultscore=0 mlxscore=0 bulkscore=0 spamscore=0 suspectscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2407110000 definitions=main-2408020066 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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.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: 1722592998222116600 Content-Type: text/plain; charset="utf-8" Now that orig_ax is exposed and GDB is happy, don't skip test-proc-mappings.py on i386. In fact, it's broken only on m68k now, so skip only this architecture. Signed-off-by: Ilya Leoshkevich Acked-by: Alex Benn=C3=A9e --- .../tcg/multiarch/gdbstub/test-proc-mappings.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/tests/tcg/multiarch/gdbstub/test-proc-mappings.py b/tests/tcg/= multiarch/gdbstub/test-proc-mappings.py index 564613fabf0..0f687f3284a 100644 --- a/tests/tcg/multiarch/gdbstub/test-proc-mappings.py +++ b/tests/tcg/multiarch/gdbstub/test-proc-mappings.py @@ -8,17 +8,12 @@ =20 def run_test(): """Run through the tests one by one""" - try: - mappings =3D gdb.execute("info proc mappings", False, True) - except gdb.error as exc: - exc_str =3D str(exc) - if "Not supported on this target." in exc_str: - # Detect failures due to an outstanding issue with how GDB han= dles - # the x86_64 QEMU's target.xml, which does not contain the - # definition of orig_rax. Skip the test in this case. - print("SKIP: {}".format(exc_str)) - return - raise + if gdb.selected_inferior().architecture().name() =3D=3D "m68k": + # m68k GDB supports only GDB_OSABI_SVR4, but GDB_OSABI_LINUX is + # required for the info proc support (see set_gdbarch_info_proc()). + print("SKIP: m68k GDB does not support GDB_OSABI_LINUX") + exit(0) + mappings =3D gdb.execute("info proc mappings", False, True) report(isinstance(mappings, str), "Fetched the mappings from the infer= ior") # Broken with host page size > guest page size # report("/sha1" in mappings, "Found the test binary name in the mappi= ngs") --=20 2.45.2