From patchwork Mon Jan 13 13:36:27 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Leoshkevich X-Patchwork-Id: 13937382 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EBACBC02180 for ; Mon, 13 Jan 2025 13:48:36 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tXKmr-0000xK-0j; Mon, 13 Jan 2025 08:47:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tXKmp-0000wT-Dl for qemu-devel@nongnu.org; Mon, 13 Jan 2025 08:47:23 -0500 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 1tXKmm-0006UP-FK for qemu-devel@nongnu.org; Mon, 13 Jan 2025 08:47:23 -0500 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 50DCmMbj020832; Mon, 13 Jan 2025 13:47:17 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=GwXKR2zRXtYZzYY4t CErncAcg57/dUdGdnm15qEjL34=; b=cxuAFpglpg75fVcGytKiGqPJ2XDbAjnKz WuzmYqj7KNSaJAAk+ioRJsTTs5ojG+BIOaA0aYfN/pyV+unpKEFNXr/ZeoQMkeGl weri99ZnQS1WuOk9NUiLHWZkDTAIj8SCoKxs5GWM/NAk2WnQrVl37YZ3O2UIbq3K 3N7L4/USvw4K/kdNc8J2xBVJUakTfZTxRwUieW8irIyo6m5ae1mcrnGXH7sft88B dBxZKd15+K5UBY7RTcE2ulG0ek5oIQyGj7mppevp6SoHSjMyIPZDiAEf4MvgVG0U kGbwPVEUho4F9KgwJNvrLr8CTxjYy3KoC+6afsrRonKRqPV0L/g3A== 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 444qvhjtpk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 13 Jan 2025 13:47:16 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 50DCKdtd007462; Mon, 13 Jan 2025 13:47:15 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4443ymxd0d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 13 Jan 2025 13:47:15 +0000 Received: from smtpav04.fra02v.mail.ibm.com (smtpav04.fra02v.mail.ibm.com [10.20.54.103]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 50DDlDMO34210072 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Jan 2025 13:47:13 GMT Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C4BBF2004B; Mon, 13 Jan 2025 13:47:13 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7148220040; Mon, 13 Jan 2025 13:47:13 +0000 (GMT) Received: from heavy.ibm.com (unknown [9.179.24.22]) by smtpav04.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 13 Jan 2025 13:47:13 +0000 (GMT) From: Ilya Leoshkevich To: =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Cc: qemu-devel@nongnu.org, Ilya Leoshkevich Subject: [PATCH 1/3] cpu: Set current_cpu early in qemu-user Date: Mon, 13 Jan 2025 14:36:27 +0100 Message-ID: <20250113134658.68376-2-iii@linux.ibm.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250113134658.68376-1-iii@linux.ibm.com> References: <20250113134658.68376-1-iii@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: W5G2pGOwh689tLFeV1UuCKLYCqs_ETw- X-Proofpoint-ORIG-GUID: W5G2pGOwh689tLFeV1UuCKLYCqs_ETw- X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_01,2024-10-11_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 clxscore=1015 priorityscore=1501 bulkscore=0 adultscore=0 mlxscore=0 spamscore=0 phishscore=0 impostorscore=0 mlxlogscore=848 lowpriorityscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2411120000 definitions=main-2501130114 Received-SPF: pass client-ip=148.163.156.1; envelope-from=iii@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -44 X-Spam_score: -4.5 X-Spam_bar: ---- X-Spam_report: (-4.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-1.787, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org gdb_handlesig() uses current_cpu. Signed-off-by: Ilya Leoshkevich --- bsd-user/main.c | 2 ++ linux-user/main.c | 2 ++ linux-user/syscall.c | 1 + 3 files changed, 5 insertions(+) diff --git a/bsd-user/main.c b/bsd-user/main.c index 0a5bc578365..aa052e515c9 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -627,6 +627,8 @@ int main(int argc, char **argv) target_cpu_init(env, regs); + current_cpu = cpu; + if (gdbstub) { gdbserver_start(gdbstub); gdb_handlesig(cpu, 0, NULL, NULL, 0); diff --git a/linux-user/main.c b/linux-user/main.c index b97634a32dd..b2bf0688617 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -1022,6 +1022,8 @@ int main(int argc, char **argv, char **envp) target_cpu_copy_regs(env, regs); + current_cpu = cpu; + if (gdbstub) { if (gdbserver_start(gdbstub) < 0) { fprintf(stderr, "qemu: could not open gdbserver on %s\n", diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 78c7c0b34ef..a101f177632 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -6542,6 +6542,7 @@ static void *clone_func(void *arg) env = info->env; cpu = env_cpu(env); thread_cpu = cpu; + current_cpu = cpu; ts = get_task_state(cpu); info->tid = sys_gettid(); task_settid(ts); From patchwork Mon Jan 13 13:36:28 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Leoshkevich X-Patchwork-Id: 13937381 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CCF5DE7719F for ; Mon, 13 Jan 2025 13:48:27 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tXKmr-0000xg-VJ; Mon, 13 Jan 2025 08:47:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tXKmp-0000wS-Df for qemu-devel@nongnu.org; Mon, 13 Jan 2025 08:47:23 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tXKmm-0006Um-Ff for qemu-devel@nongnu.org; Mon, 13 Jan 2025 08:47:23 -0500 Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 50D85lA1000697; Mon, 13 Jan 2025 13:47:19 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=PnbXZSJVDES7xEtrk 4v9vi0z8GoxCrh+mXsg6uDc/gs=; b=a2icxRWjjd1VRhG1FpZLmkAuNYbsgAMMC /ezVd1yKn2EH91iIWzpIb3DgPpkX40zWaJWJXfXdvSIvzrK/8CPTy5HfonwVMCKq gJfUuEzUD5mMCQFxJL+vCuU8gH7YI4QyfSMpBgGM4oOJrCNOSsI9LPF6xyLNyKZ+ OQpqePgzsBghIYsan89Bip8wCiSYMxDHR1J3F3nrCgGV82lT1qlbz9vxIh3MMQJC RwNK2EgZrOGxb77Q50PWanmNFkOyYIq1OXVsD96ZQrwrvE/uCBg20CxfkMXkgyYO TYWm6/3UM8edh2mMPwQ3zkOdTX1vqZ03vF2ehyUE5yYeU/gdGOTyg== 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 444y12hchm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 13 Jan 2025 13:47:18 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 50DCSIg4007371; Mon, 13 Jan 2025 13:47:18 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4443ymxd0e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 13 Jan 2025 13:47:18 +0000 Received: from smtpav04.fra02v.mail.ibm.com (smtpav04.fra02v.mail.ibm.com [10.20.54.103]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 50DDlEWb56820064 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Jan 2025 13:47:14 GMT Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 458902004D; Mon, 13 Jan 2025 13:47:14 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DA10820040; Mon, 13 Jan 2025 13:47:13 +0000 (GMT) Received: from heavy.ibm.com (unknown [9.179.24.22]) by smtpav04.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 13 Jan 2025 13:47:13 +0000 (GMT) From: Ilya Leoshkevich To: =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Cc: qemu-devel@nongnu.org, Ilya Leoshkevich Subject: [PATCH 2/3] cpu: Introduce EXCLUSIVE_GUARD() Date: Mon, 13 Jan 2025 14:36:28 +0100 Message-ID: <20250113134658.68376-3-iii@linux.ibm.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250113134658.68376-1-iii@linux.ibm.com> References: <20250113134658.68376-1-iii@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: saEeJyIzuOaagVJDjQOM0sqf_pi2xa7a X-Proofpoint-GUID: saEeJyIzuOaagVJDjQOM0sqf_pi2xa7a X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_01,2024-10-11_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 impostorscore=0 clxscore=1015 malwarescore=0 suspectscore=0 adultscore=0 lowpriorityscore=0 bulkscore=0 priorityscore=1501 spamscore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2411120000 definitions=main-2501130114 Received-SPF: pass client-ip=148.163.158.5; envelope-from=iii@linux.ibm.com; helo=mx0b-001b2d01.pphosted.com X-Spam_score_int: -44 X-Spam_score: -4.5 X-Spam_bar: ---- X-Spam_report: (-4.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-1.787, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Add a macro that produces a start_exclusive() / end_exclusive() pair. Useful to guarantee an exit from an exclusive section in large functions. Signed-off-by: Ilya Leoshkevich --- include/hw/core/cpu.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index c3ca0babcb3..a7d9d6e2b8c 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -1063,6 +1063,17 @@ void start_exclusive(void); */ void end_exclusive(void); +static inline void exclusive_unlock_guard(int *exclusive_guard G_GNUC_UNUSED) +{ + end_exclusive(); +} + +#define EXCLUSIVE_GUARD() \ + int glue(exclusive_guard, __COUNTER__) \ + G_GNUC_UNUSED \ + __attribute__((cleanup(exclusive_unlock_guard))) = \ + (start_exclusive(), 0); + /** * qemu_init_vcpu: * @cpu: The vCPU to initialize. From patchwork Mon Jan 13 13:36:29 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Leoshkevich X-Patchwork-Id: 13937384 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6BF17C02180 for ; Mon, 13 Jan 2025 13:49:20 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tXKmq-0000wg-9G; Mon, 13 Jan 2025 08:47:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tXKmo-0000w9-3y for qemu-devel@nongnu.org; Mon, 13 Jan 2025 08:47:22 -0500 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 1tXKmm-0006UX-7j for qemu-devel@nongnu.org; Mon, 13 Jan 2025 08:47:21 -0500 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 50D3tBlo003313; Mon, 13 Jan 2025 13:47:17 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=j/GUulKt0szX9mh0W jefez6yA6KxsZWKXDGO1Z2rohI=; b=RyztO0pAjLP/ybAqsPbx6IkPnnkAclfdc O16SMDcUI40AA1RB6utcPCQ63+QIV/h9Qyxmmbh+HMNl3hpSlncdKCJ/TaUoyBKA wDdBoocDHPNtaVqfDw+998gDVmY2xHoKm+0VtXM4Vqiqbkp3VQpz+770FPfecjfa Q3rVQBeuY7LDGI6xJHuImUsPXWE/zKf/PllERdDhBHydXOR8V4AhcYkTAPdgi49G 3SwyngRRxh8iGsrthddBgj3E5+I99lCoTx1cyVIlCuOpE8ZLl+DSAV+gZmjNdkIe UW30UvZR03MeiB7AvTGjxJaux1xIb6p/LvWuvkaHOF4VoQwONthVQ== Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 444qvhjtpn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 13 Jan 2025 13:47:17 +0000 (GMT) Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 50D9hJ3e001108; Mon, 13 Jan 2025 13:47:16 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 44456jp51m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 13 Jan 2025 13:47:16 +0000 Received: from smtpav04.fra02v.mail.ibm.com (smtpav04.fra02v.mail.ibm.com [10.20.54.103]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 50DDlEY848497006 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Jan 2025 13:47:14 GMT Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BDAB52004D; Mon, 13 Jan 2025 13:47:14 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5C74220040; Mon, 13 Jan 2025 13:47:14 +0000 (GMT) Received: from heavy.ibm.com (unknown [9.179.24.22]) by smtpav04.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 13 Jan 2025 13:47:14 +0000 (GMT) From: Ilya Leoshkevich To: =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Cc: qemu-devel@nongnu.org, Ilya Leoshkevich Subject: [PATCH 3/3] gdbstub: Protect gdb_handlesig() with EXCLUSIVE_GUARD() Date: Mon, 13 Jan 2025 14:36:29 +0100 Message-ID: <20250113134658.68376-4-iii@linux.ibm.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250113134658.68376-1-iii@linux.ibm.com> References: <20250113134658.68376-1-iii@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: Fz2NXy9bshC7JeifGvIFtPjd6i9U3PJ6 X-Proofpoint-ORIG-GUID: Fz2NXy9bshC7JeifGvIFtPjd6i9U3PJ6 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_01,2024-10-11_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 clxscore=1015 priorityscore=1501 bulkscore=0 adultscore=0 mlxscore=0 spamscore=0 phishscore=0 impostorscore=0 mlxlogscore=999 lowpriorityscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2411120000 definitions=main-2501130114 Received-SPF: pass client-ip=148.163.156.1; envelope-from=iii@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -44 X-Spam_score: -4.5 X-Spam_bar: ---- X-Spam_report: (-4.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-1.787, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org If multiple threads hit a breakpoint at the same time, GDB gets confused [1]. Prevent this situation by stopping the other threads once a thread hits a breakpoint. [1] https://sourceware.org/bugzilla/show_bug.cgi?id=32023 Signed-off-by: Ilya Leoshkevich --- gdbstub/user.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gdbstub/user.c b/gdbstub/user.c index 0b4bfa9c488..d72f8ca6106 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -200,6 +200,8 @@ int gdb_handlesig(CPUState *cpu, int sig, const char *reason, void *siginfo, char buf[256]; int n; + EXCLUSIVE_GUARD(); + if (!gdbserver_state.init || gdbserver_user_state.fd < 0) { return sig; }