From nobody Sun Nov 24 06:29:22 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=1726133493; cv=none; d=zohomail.com; s=zohoarc; b=eiNhrhA2brk23awvQyejB8quKMKQOEU5Al4Q58P5MsN21qygpEK/iv1MWP7zjaiXwUBjg9a8fsRu+QWPcJNXg92CohUdeM3i31JJB37uau6Cu8E80jkjrU93BZmoc8Vaj/6U50GdlpKKCHa2RNW3Sy651o5qBBiEdP1VGMwHCx4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1726133493; 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=BciYKAAcVl6ew/+esm6yGIWokh3KtE4RrIk6UxbGtY0=; b=F6jy9edGfv03+k2XBT0DFbssFUwaK3zDRCjumLgNoSfgYDgtBfTyCl2vKJlnsWi85PIMb/AiifldMdzjNqd8QtPQutceGyPIO7ItR+X/4DCGuxpFo2R0At91MvfR4uKwgjFcFLHmOrwJ3S2RBXXthjzTvJtdXfceHFw3DECrbO4= 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 1726133493456453.2946209759083; Thu, 12 Sep 2024 02:31:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sog9w-00075U-4D; Thu, 12 Sep 2024 05:30:40 -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 1sog9h-0006vR-1K for qemu-devel@nongnu.org; Thu, 12 Sep 2024 05:30:37 -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 1sog9e-0004L6-BT for qemu-devel@nongnu.org; Thu, 12 Sep 2024 05:30:24 -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 48BLcvX9004900; Thu, 12 Sep 2024 09:30:19 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 41gc8qjwsp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 12 Sep 2024 09:30:18 +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 48C9UI6X015105; Thu, 12 Sep 2024 09:30:18 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 41gc8qjwsj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 12 Sep 2024 09:30:18 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 48C7SbOl027315; Thu, 12 Sep 2024 09:30:17 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 41h3v3eq3b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 12 Sep 2024 09:30:17 +0000 Received: from smtpav07.fra02v.mail.ibm.com (smtpav07.fra02v.mail.ibm.com [10.20.54.106]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 48C9UGb152036058 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 12 Sep 2024 09:30:16 GMT Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id ECDC320043; Thu, 12 Sep 2024 09:30:15 +0000 (GMT) Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8EE3020063; Thu, 12 Sep 2024 09:30:15 +0000 (GMT) Received: from heavy.ibm.com (unknown [9.171.24.155]) by smtpav07.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 12 Sep 2024 09:30:15 +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=BciYKAAcVl6ew /+esm6yGIWokh3KtE4RrIk6UxbGtY0=; b=L34JnH1ZIpeT5C4k/HSRaNHNKgGpw TpdsUzYKuvJF7MIPksEcJ5Oda8b/lvJEq/8xHdiGD0xZA3HXOsgMbL6LcHMU9/wx 80jQH7wounYVKHB7qUd/QUUpxvAm2HCnOK5Gaqg5Osy7Le51j1kI4SRh8931HCzf Hh8XOrU1QEDW1TsT/ObaDeFW8wloZrb5n89A5NWj8F42NUVhWhgfKPK6PW8Hyq9b nPqwwU+3QmDpBE5C7iIYeOkvK8Qnd/F1UmfqZSIEzx9z9yTht1COS1O+w8HRaiqw KNBk4bRky/aeUvFfnozb5G4LTIfvSMtG0/aefHbHCS+chxlA6glC1wX5g== 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 v2 1/5] include/exec: Introduce env_cpu_const() Date: Thu, 12 Sep 2024 11:28:20 +0200 Message-ID: <20240912093012.402366-2-iii@linux.ibm.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240912093012.402366-1-iii@linux.ibm.com> References: <20240912093012.402366-1-iii@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 8e34rjlLK89IFtaoWerltAVKI_xLS606 X-Proofpoint-ORIG-GUID: 7eb0YrslVHJHS8S5-ccZKlcheYJMoSju X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-12_01,2024-09-09_02,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 spamscore=0 mlxscore=0 lowpriorityscore=0 impostorscore=0 priorityscore=1501 malwarescore=0 adultscore=0 clxscore=1015 mlxlogscore=999 suspectscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2408220000 definitions=main-2409120063 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_DNSWL_NONE=-0.0001, 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: 1726133494367116600 Content-Type: text/plain; charset="utf-8" It's the same as env_cpu(), but for const objects. Reviewed-by: Richard Henderson Signed-off-by: Ilya Leoshkevich --- 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 2998c95da4a..dc5cffadf29 100644 --- a/include/exec/cpu-common.h +++ b/include/exec/cpu-common.h @@ -242,6 +242,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 @@ -250,7 +261,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.46.0 From nobody Sun Nov 24 06:29:22 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=1726133471; cv=none; d=zohomail.com; s=zohoarc; b=e44PrVp2UnKofpbjvq0mZ1nTH/2sR5bCLxPtuPZUk8g2Io6eoeho4OactdgO7tR/LYz040K0f3ZEzv0XHbZb/vrjugKgGsGT26zY5cZQdpIqeNhD+UWiBIyTeWJfFLVuLbzH0ET4AfWP+DlNQlVoet6ehwpxVhUdXt+5f0yaPf8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1726133471; 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=sLzg4gVgou+L8/YeEQBK1DBF4DR+LjSB0I8+lMA45jM=; b=I5s290p+bQ0x2wSfHVFhUhMpWTeBOt+BIU5eht6FWUO3XILbCyztgGnUs8DBFF+iAW1hZxNjlsPLikEp/HNYQ2SBBbzNxpK+n2xe1S5a66lfI3bluNktN7WHuN4fP0z1+PL8NSIyg8EJydJZoBW/T/s/c9oY/LlL/RTa3qceulY= 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 1726133471244703.5031796669385; Thu, 12 Sep 2024 02:31:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sog9u-00070M-Lu; Thu, 12 Sep 2024 05:30:38 -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 1sog9k-0006vg-6o for qemu-devel@nongnu.org; Thu, 12 Sep 2024 05:30:37 -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 1sog9g-0004LT-7g for qemu-devel@nongnu.org; Thu, 12 Sep 2024 05:30:25 -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 48C6Q1Cf023704; Thu, 12 Sep 2024 09:30:20 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 41gebajqa6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 12 Sep 2024 09:30:20 +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 48C9UJDW012239; Thu, 12 Sep 2024 09:30:19 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 41gebajqa0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 12 Sep 2024 09:30:19 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 48C6rOu5032103; Thu, 12 Sep 2024 09:30:18 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 41h2nmxx3v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 12 Sep 2024 09:30:18 +0000 Received: from smtpav07.fra02v.mail.ibm.com (smtpav07.fra02v.mail.ibm.com [10.20.54.106]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 48C9UGQh57803136 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 12 Sep 2024 09:30:16 GMT Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6C4292004D; Thu, 12 Sep 2024 09:30:16 +0000 (GMT) Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0BE2C20040; Thu, 12 Sep 2024 09:30:16 +0000 (GMT) Received: from heavy.ibm.com (unknown [9.171.24.155]) by smtpav07.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 12 Sep 2024 09:30:15 +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=sLzg4gVgou+L8 /YeEQBK1DBF4DR+LjSB0I8+lMA45jM=; b=LUltwvGKOA9UsWIJQzJrwaH9X1tUC WW+rqQmiqa20q1pf8bEGqJUtKEFDVn6T9bJmyFmMHQy4C2gLQnLE1hnhwOLyLfYQ ASbWsnj2aR9Io/OzGfPpFk3yCmUh5HHH9YT/EZD9/xd9hF8BIunzJXCr1Xdpz0ur /FDsM6LPgOA2r9uuEADKNOBQgbuawquIqZN9qYW8UHReom6OMHQwsRILtOvON4+v GHeKYeoBf/vYFWMz31FuJgSQk8gO0dTMhboYx8yL/uRj39Tv601KwcY/3OPCfOik irIkD+mZ6pmI9M9rNr2XmEHV0p8gARyQWzaIWxJmhYuMLgDLB+FJqo+wQ== 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 v2 2/5] linux-user/i386: Emulate orig_ax Date: Thu, 12 Sep 2024 11:28:21 +0200 Message-ID: <20240912093012.402366-3-iii@linux.ibm.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240912093012.402366-1-iii@linux.ibm.com> References: <20240912093012.402366-1-iii@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 4Lzhc4wAQwIAPKHNCIrftTvwKgh_lY0H X-Proofpoint-GUID: 1HCZYHqAxXAoJvASlPMJgI9pbb8EZ3Ga X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-12_01,2024-09-09_02,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 suspectscore=0 priorityscore=1501 bulkscore=0 spamscore=0 phishscore=0 lowpriorityscore=0 mlxscore=0 mlxlogscore=842 impostorscore=0 clxscore=1015 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2408220000 definitions=main-2409120063 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_DNSWL_NONE=-0.0001, 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: 1726133472542116600 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. Reviewed-by: Richard Henderson Signed-off-by: Ilya Leoshkevich --- linux-user/elfload.c | 4 ++-- linux-user/i386/cpu_loop.c | 3 +++ linux-user/qemu.h | 4 ++++ 3 files changed, 9 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 8707a3eaf25..43ad4e2f39e 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); @@ -218,6 +219,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], @@ -236,6 +238,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..92b2bee87b1 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -113,6 +113,10 @@ struct TaskState { struct target_vm86plus_struct vm86plus; uint32_t v86flags; uint32_t v86mask; +#endif +#if defined(TARGET_I386) + /* Last syscall number. */ + target_ulong orig_ax; #endif abi_ulong child_tidptr; #ifdef TARGET_M68K --=20 2.46.0 From nobody Sun Nov 24 06:29:22 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=1726133540; cv=none; d=zohomail.com; s=zohoarc; b=lUasVEHG3BjdoZrZ0E/A1VfpNSEz8+3QTA2W5JxuM82zEv5w1GFEQhXzRQHEx2O11PjvJx4+ao+GLvzxsKT9ufC7yOTCF04nt1U5ZTubUgFPBHC+Oe6rq/eiLPDz/MHq0U4NTJH+uf/yeX4t81hpio+e2x/3DiJ8AWrLSV7MYRc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1726133540; 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=nZ5ZfuY8DqKcZUIZERfUXcnqAcq5EHxmfo32LBk7SZo=; b=A3yWdmWD1V1Y+3ekqdF61/EcL6h440bGTycZqWxEg9otbEVOGdQ4hPDhYjpTDoug8JwZEG7oghwD21Z59p9HQKK81MBVT9jII7FBbJT8euW19y1s5d9ylmLoD5zKN6n4lk8F6FeWtAbAUXnFbYMMJjTZE6bXyvX3W83bDVo96mY= 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 1726133540348697.771535106104; Thu, 12 Sep 2024 02:32:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sog9x-0007Af-CV; Thu, 12 Sep 2024 05:30:41 -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 1sog9k-0006vf-6q for qemu-devel@nongnu.org; Thu, 12 Sep 2024 05:30:37 -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 1sog9g-0004LJ-7T for qemu-devel@nongnu.org; Thu, 12 Sep 2024 05:30:25 -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 48C41oF0022813; Thu, 12 Sep 2024 09:30:20 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 41gc8qjwst-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 12 Sep 2024 09:30:20 +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 48C9UI6Z015105; Thu, 12 Sep 2024 09:30:19 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 41gc8qjwsq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 12 Sep 2024 09:30:19 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 48C7QDeQ027333; Thu, 12 Sep 2024 09:30:18 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 41h3v3eq3h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 12 Sep 2024 09:30:18 +0000 Received: from smtpav07.fra02v.mail.ibm.com (smtpav07.fra02v.mail.ibm.com [10.20.54.106]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 48C9UGMW52167152 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 12 Sep 2024 09:30:17 GMT Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DF4B120043; Thu, 12 Sep 2024 09:30:16 +0000 (GMT) Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7F20020040; Thu, 12 Sep 2024 09:30:16 +0000 (GMT) Received: from heavy.ibm.com (unknown [9.171.24.155]) by smtpav07.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 12 Sep 2024 09:30:16 +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=nZ5ZfuY8DqKcZ UIZERfUXcnqAcq5EHxmfo32LBk7SZo=; b=FEGqt8QpmeQxwXB/ajTOeOBN4hEZY 3PjuCSfwUxlyKH9gaHyG4DDdJqT3CpmLTNk9gjIqcU4j5skqq2lETv8XV0dfceAf dGu+MaAcc5A4PC7grHib13bRgECVc2dYZeAUkwcUctwMSQ6m2+7U+2yNYcJiiYp+ HAdOF+l2nezr/rJaiuWnTh4BJ6vunfqk1vT837maqvR7ETiyO1Q0qNeBCWarYaPN SWBy3FfpwnXchtqbnBX5MnXegqW5iEgbGspuHvac85t866o0xC9Zft+yPzFz62Pz C3T930AOIe/i07Ti3eQb8Gpr67C6aKplOPTFUksMuhKUh/sg31/D8+nxQ== 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 v2 3/5] target/i386/gdbstub: Factor out gdb_get_reg() and gdb_write_reg() Date: Thu, 12 Sep 2024 11:28:22 +0200 Message-ID: <20240912093012.402366-4-iii@linux.ibm.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240912093012.402366-1-iii@linux.ibm.com> References: <20240912093012.402366-1-iii@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: x9vuZVoIRF2VVZ2gzin6UvFCOP4ltjJS X-Proofpoint-ORIG-GUID: 8xR7GoCXNw5aLXBQ_Sqom08AL850ksF0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-12_01,2024-09-09_02,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 spamscore=0 mlxscore=0 lowpriorityscore=0 impostorscore=0 priorityscore=1501 malwarescore=0 adultscore=0 clxscore=1015 mlxlogscore=704 suspectscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2408220000 definitions=main-2409120063 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_DNSWL_NONE=-0.0001, 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: 1726133542640116600 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. While at it, simplify the TARGET_LONG_BITS =3D=3D 32 case. Reviewed-by: Richard Henderson Signed-off-by: Ilya Leoshkevich --- target/i386/gdbstub.c | 51 +++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/target/i386/gdbstub.c b/target/i386/gdbstub.c index 4acf485879e..cc5eceeb7eb 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,21 @@ 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 (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 +308,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.46.0 From nobody Sun Nov 24 06:29:22 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=1726133472; cv=none; d=zohomail.com; s=zohoarc; b=gkbUFAAx1QfF4btLWZYpFikeq7Fv7VTlII/asKaSJH6ubAYLwYWLaGRfbU1b3KtTi2cr0YLLLS/ZG3XgjNS3bmsKqVNPFrY8dU0JFIrmYYM5+dAT80B0bUQ6oyenyyHfIqfWBmUfZHBADlQtXjbDb2FAZr7mFf9STe6J2ZguL/8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1726133472; 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=z15MGlbE7xNbfKEJzQJx28SesNJPf3ivaIA6ZPPyPdw=; b=UQ/12ULOXn0dWxYbpe6Fu+I6hv/Bpxi763MqkHgwHWOZruLB3uUdYB7on50JcSY32BqYDsGnVhklNITw1dWMGPX9cvQ9rLc3A0LDNxxQXTrNVeS/7l974pyuD72Wovow0odnUSREyecIT/hnzQZj1RKH4jGZiCmxduAwE5B7k7I= 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 1726133472114964.0735645830525; Thu, 12 Sep 2024 02:31:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sog9v-00074Q-Iw; Thu, 12 Sep 2024 05:30:39 -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 1sog9k-0006vh-6x for qemu-devel@nongnu.org; Thu, 12 Sep 2024 05:30:37 -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 1sog9g-0004LX-8p for qemu-devel@nongnu.org; Thu, 12 Sep 2024 05:30:26 -0400 Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 48BIpASP013414; Thu, 12 Sep 2024 09:30:21 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 41gegx2qrp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 12 Sep 2024 09:30:21 +0000 (GMT) Received: from m0353729.ppops.net (m0353729.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 48C9T1Ul018821; Thu, 12 Sep 2024 09:30:20 GMT Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 41gegx2qrh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 12 Sep 2024 09:30:20 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 48C8Q44X003141; Thu, 12 Sep 2024 09:30:19 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 41h15u767k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 12 Sep 2024 09:30:19 +0000 Received: from smtpav07.fra02v.mail.ibm.com (smtpav07.fra02v.mail.ibm.com [10.20.54.106]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 48C9UHlr53150096 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 12 Sep 2024 09:30:17 GMT Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5DED42004B; Thu, 12 Sep 2024 09:30:17 +0000 (GMT) Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F1DF320040; Thu, 12 Sep 2024 09:30:16 +0000 (GMT) Received: from heavy.ibm.com (unknown [9.171.24.155]) by smtpav07.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 12 Sep 2024 09:30:16 +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=z15MGlbE7xNbf KEJzQJx28SesNJPf3ivaIA6ZPPyPdw=; b=TSCQ58hNNHNzzzANuOzOipKNUj7pF +MfnLD2JwlAOGGpQ4UbXWOQsjrkzwYkUuGVm+RhsejZbHQ93aERBCSwWfSSYt/wB YQvuKPpHDy0Q/et1K4xgdn4hzD9OtmRwGSEKjCcNRq+Y6wni9WkhNTZrXTW7yYZd Hc3KMR2SAk/7aiBZtX8P1PxqifojxqhkIpZTlbD4u/MjQ3cEN9eJrTg8W1EkU6Kb Yqr3zUNN7lqm2uT0yMhJZbpaErnJyUsYwjMKtLF/49Fpb/x+Fv0O5kTdhr7orxna RuL3zd3k4gxQd8zCLUKqOISB9fZazECSrX+e5kG9+KuEedzzeuVs67Frg== 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 v2 4/5] target/i386/gdbstub: Expose orig_ax Date: Thu, 12 Sep 2024 11:28:23 +0200 Message-ID: <20240912093012.402366-5-iii@linux.ibm.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240912093012.402366-1-iii@linux.ibm.com> References: <20240912093012.402366-1-iii@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: i9WFuKSwO2qVuHAKfe3yZx0DNjwJHqfs X-Proofpoint-ORIG-GUID: LhQmdMKb_lvCQ0KQ4vUU49ONfr_DbMmn 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.60.29 definitions=2024-09-12_01,2024-09-09_02,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 mlxlogscore=969 lowpriorityscore=0 suspectscore=0 priorityscore=1501 bulkscore=0 adultscore=0 impostorscore=0 clxscore=1015 malwarescore=0 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2408220000 definitions=main-2409120063 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_DNSWL_NONE=-0.0001, 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: 1726133474389116600 Content-Type: text/plain; charset="utf-8" Copy XML files describing orig_ax from GDB and glue them with CPUX86State.orig_ax. Reviewed-by: Richard Henderson Signed-off-by: Ilya Leoshkevich --- 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 14edd57a37b..dc2e074e227 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -2231,6 +2231,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 cc5eceeb7eb..04c49e802d7 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 { @@ -406,3 +411,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.46.0 From nobody Sun Nov 24 06:29:22 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=1726133488; cv=none; d=zohomail.com; s=zohoarc; b=PM4SyronTWe9bJ5fT88OUFp5IyPswDHGAZmTJTJczhUMdU7NeRKNovzoRvS6cJowx5Zp8B3TtYMTDyz0iuI0aSzXaFB6jwIbtF7joBpFFFOTXZhm9aRVnbP8JOr7aDYKTg9YkI0AOxD9HEhbaqmj29++q1r3J1HayEbj5Gil5RU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1726133488; h=Content-Type: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=ZBw8sjq6PQLHkvAQ60B4YsQnBd3LLJBvBMXzOt5br1k=; b=lqDA1a6Gu5zHsPWodBDkVjnaYFdHmEbk6BWXTheChfSzOuxF8/R+EwdsqgrvAAIaFONEgoRNGClQUwkobjV4epxHdJW99O8HL8DvPafgZjDcX/AzO+y7bJsNyG8lyAqNjCHOemNvevvB+8W3HHpgyxGPZV95S+iU1KQUvabkDEA= 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 1726133488983198.72367111497636; Thu, 12 Sep 2024 02:31:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sog9y-0007H4-Mm; Thu, 12 Sep 2024 05:30:42 -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 1sog9k-0006vi-7V for qemu-devel@nongnu.org; Thu, 12 Sep 2024 05:30:37 -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 1sog9g-0004LV-7T for qemu-devel@nongnu.org; Thu, 12 Sep 2024 05:30:25 -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 48C9Fj1m003520; Thu, 12 Sep 2024 09:30:21 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 41gc8qjwt1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 12 Sep 2024 09:30:21 +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 48C9UKdq015191; Thu, 12 Sep 2024 09:30:20 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 41gc8qjwsv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 12 Sep 2024 09:30:20 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 48C6rOu9032103; Thu, 12 Sep 2024 09:30:20 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 41h2nmxx48-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 12 Sep 2024 09:30:19 +0000 Received: from smtpav07.fra02v.mail.ibm.com (smtpav07.fra02v.mail.ibm.com [10.20.54.106]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 48C9UHFU51708392 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 12 Sep 2024 09:30:17 GMT Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D1A0D2004B; Thu, 12 Sep 2024 09:30:17 +0000 (GMT) Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 71B6320040; Thu, 12 Sep 2024 09:30:17 +0000 (GMT) Received: from heavy.ibm.com (unknown [9.171.24.155]) by smtpav07.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 12 Sep 2024 09:30:17 +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-type:content-transfer-encoding; s=pp1; bh= ZBw8sjq6PQLHkvAQ60B4YsQnBd3LLJBvBMXzOt5br1k=; b=A4dgkhfu3LiiGLLg 98zhAyxEmsnzvYBUK7g+CMuXUHaA1m1uf0BrfGspUMUbdJbnpTIuf1/nGHyOKim0 bmMq+2xJbPsqWtK/dK6igDa+FzL7vag9fz5mnbZlJ6DpVjRx9sYdOVbugNW0umRr kw2zSH4CM0pFTuzFVsWB67fhR8aWJRuoyEMtiMqBgfOW2UTcgorl0jbBEnfQLL6b UBKEHXiYAShnJxCV3LoQ55blGd3zQk9W6lAkeLAR9z+88n/7gtIzR3sjLc0WH9gt UBS872E6zL9UU5rFlE85iLH5Id0N3XtAWBUF3/7XqMF67KkQ4kjKhYD/4ZHjZj3a 9vqS2A== 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 v2 5/5] tests/tcg: Run test-proc-mappings.py on i386 Date: Thu, 12 Sep 2024 11:28:24 +0200 Message-ID: <20240912093012.402366-6-iii@linux.ibm.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240912093012.402366-1-iii@linux.ibm.com> References: <20240912093012.402366-1-iii@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: pAtDUcozYHkNs4-F1YtkOaoiN0hO44h_ X-Proofpoint-ORIG-GUID: lXpdHqJWcschkpFKnjVIuQeOSh5g_xBY X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-12_01,2024-09-09_02,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 spamscore=0 mlxscore=0 lowpriorityscore=0 impostorscore=0 priorityscore=1501 malwarescore=0 adultscore=0 clxscore=1015 mlxlogscore=999 suspectscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2408220000 definitions=main-2409120063 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_DNSWL_NONE=-0.0001, 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: 1726133490375116600 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. Acked-by: Alex Benn=C3=A9e Signed-off-by: Ilya Leoshkevich --- .../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.46.0