From nobody Fri May 3 03:14:52 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1675212424; cv=none; d=zohomail.com; s=zohoarc; b=iDeqOyuVK4J3WSNVaCeYvyWU4QMW+txEPZZ4tDr2zYbbAAr2NYn/jnPF/qFrHw1SDmc8lIlv65QNqvVLbIT6KNGe4hOYqQCp1r/nAroeMKhn8CN1vtcMNxK1T9xkwRYvyJmrnaxoA+Dg6lULt9u7ttRVDK7Rr8EIrh4iGqiH3/o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675212424; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=lNG1C7/g61qucbNXvHa8aMus9ERooUklPM9og2hfzyY=; b=cC2AuiAa3j3jx5Lz5lA8TQmAp0D/ApXzk1wnItBVf172SfTjlrnqFBM7dQu9GyhKzFv/C2lTYU4E/+B9vKi4B4GbZsdHCnO4UI1a6Jc9FK9Dq9Ztgwua1rANAh/7zul8hnZ6GU/GC73aUhxWXGberb5SlHQ2RfS94LAoNL6kNWA= 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+importer2=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 1675212424734698.3584605668115; Tue, 31 Jan 2023 16:47:04 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pN1Ge-0006MY-6m; Tue, 31 Jan 2023 19:46:28 -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 1pN1Gc-0006Lp-PM for qemu-devel@nongnu.org; Tue, 31 Jan 2023 19:46:26 -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 1pN1Ga-0004JX-VW for qemu-devel@nongnu.org; Tue, 31 Jan 2023 19:46:26 -0500 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3110CjJf001241; Wed, 1 Feb 2023 00:46:22 GMT Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3nf9tedg8p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 01 Feb 2023 00:46:22 +0000 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 30VJea66025960; Wed, 1 Feb 2023 00:46:19 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma06ams.nl.ibm.com (PPS) with ESMTPS id 3ncvttv43j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 01 Feb 2023 00:46:19 +0000 Received: from smtpav07.fra02v.mail.ibm.com (smtpav07.fra02v.mail.ibm.com [10.20.54.106]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3110kG0p46858740 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 1 Feb 2023 00:46:16 GMT Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E917020040; Wed, 1 Feb 2023 00:46:15 +0000 (GMT) Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 82DD120043; Wed, 1 Feb 2023 00:46:15 +0000 (GMT) Received: from heavy.ibmuc.com (unknown [9.171.18.228]) by smtpav07.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 1 Feb 2023 00:46: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=lNG1C7/g61qucbNXvHa8aMus9ERooUklPM9og2hfzyY=; b=e4MLWluMaUwn3+rol/9YwRMjvTsl0x5B3dANRxg8XPfdqHbxE7LRqU4DX2jmJo/3vgSq 0tiGvoW8BqK8trS9LYWLRmP0EU+y8qAnpsiAFne3tpPA86nw9t2eDASFcZ0oaQP7xyV1 Gm1ffROy7KRS105tH2cuLstxv6iZbgytZ0vSdEXxHsziHLWImFWCiE7F6FKKm+eu8+69 sCPDvx3iaudgcA7aBTKQOzFi0MXXSu2ngivtwKWKX1ZsueGfPPxD5r8vEZNn3rUjUKzO kfRAU22EqKZ4Rg7DxOXczcTSW8fwItE2dmGYI8t4R5skxJG0f3UC53BJXq9LPIJMrK+P Tw== From: Ilya Leoshkevich To: Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= Cc: Christian Borntraeger , qemu-devel@nongnu.org, Ilya Leoshkevich Subject: [PATCH 1/4] cpus: Make {start,end}_exclusive() recursive Date: Wed, 1 Feb 2023 01:46:06 +0100 Message-Id: <20230201004609.3005029-2-iii@linux.ibm.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230201004609.3005029-1-iii@linux.ibm.com> References: <20230201004609.3005029-1-iii@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 9GN5OCJZAEIIbgwPxiLJG3KT1kiEKBdS X-Proofpoint-ORIG-GUID: 9GN5OCJZAEIIbgwPxiLJG3KT1kiEKBdS X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-31_08,2023-01-31_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 adultscore=0 spamscore=0 bulkscore=0 impostorscore=0 phishscore=0 mlxlogscore=736 clxscore=1015 mlxscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302010003 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+importer2=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, 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1675212426165100006 Content-Type: text/plain; charset="utf-8" Currently dying to one of the core_dump_signal()s deadlocks, because dump_core_and_abort() calls start_exclusive() two times: first via stop_all_tasks(), and then via preexit_cleanup() -> qemu_plugin_user_exit(). There are a number of ways to solve this: resume after dumping core; check cpu_in_exclusive_context() in qemu_plugin_user_exit(); or make {start,end}_exclusive() recursive. Pick the last option, since it's the most straightforward one. Fixes: da91c1920242 ("linux-user: Clean up when exiting due to a signal") Signed-off-by: Ilya Leoshkevich --- cpus-common.c | 12 ++++++++++-- include/hw/core/cpu.h | 4 ++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/cpus-common.c b/cpus-common.c index 793364dc0ed..a0c52cd187f 100644 --- a/cpus-common.c +++ b/cpus-common.c @@ -192,6 +192,11 @@ void start_exclusive(void) CPUState *other_cpu; int running_cpus; =20 + if (current_cpu->exclusive_context_count) { + current_cpu->exclusive_context_count++; + return; + } + qemu_mutex_lock(&qemu_cpu_list_lock); exclusive_idle(); =20 @@ -219,13 +224,16 @@ void start_exclusive(void) */ qemu_mutex_unlock(&qemu_cpu_list_lock); =20 - current_cpu->in_exclusive_context =3D true; + current_cpu->exclusive_context_count++; } =20 /* Finish an exclusive operation. */ void end_exclusive(void) { - current_cpu->in_exclusive_context =3D false; + current_cpu->exclusive_context_count--; + if (current_cpu->exclusive_context_count) { + return; + } =20 qemu_mutex_lock(&qemu_cpu_list_lock); qatomic_set(&pending_cpus, 0); diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 2417597236b..671f041bec6 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -349,7 +349,7 @@ struct CPUState { bool unplug; bool crash_occurred; bool exit_request; - bool in_exclusive_context; + int exclusive_context_count; uint32_t cflags_next_tb; /* updates protected by BQL */ uint32_t interrupt_request; @@ -758,7 +758,7 @@ void async_safe_run_on_cpu(CPUState *cpu, run_on_cpu_fu= nc func, run_on_cpu_data */ static inline bool cpu_in_exclusive_context(const CPUState *cpu) { - return cpu->in_exclusive_context; + return cpu->exclusive_context_count; } =20 /** --=20 2.39.1 From nobody Fri May 3 03:14:52 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1675212428; cv=none; d=zohomail.com; s=zohoarc; b=CnWFuDfGFepu5EgrqkOWVpGdltw2unFcYCi55bM9WxaiiH3wolJDZZn7dh7tniY9emJ+SnRZEc57jpMGgk4WpQFJxYvjNOO+U6dK6CJ3vJUyqKNj4UpuToNeAk5JZ7GUP/RhcLXXq2O/jZkhuxQ6fHjzINvETHdCGiHAd/pIIBk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675212428; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=mMRQaC3kK+XIczQaWtm8aSJsy1D7GyS5ob78buNrJVU=; b=lTOk94D5rmYMpHlYzrJHaFx6EJ06VPDpWtg9HsLQCxEQUQhdfb8s2ZWuTovP5G/cGJvfXgUMqMiYDFvMa8k3wqWpCB6oialb+R8aGrM9JOLLlg4g6GjTjykNboclF8VgXNyBIBYsjp7N7IatnV5Jq8siDV3ld3A1NL2GfU2DLHs= 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+importer2=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 1675212428948234.8164899241002; Tue, 31 Jan 2023 16:47:08 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pN1Gg-0006OU-EV; Tue, 31 Jan 2023 19:46:30 -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 1pN1Ge-0006MZ-6Q for qemu-devel@nongnu.org; Tue, 31 Jan 2023 19:46:28 -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 1pN1Gb-0004Jc-5Y for qemu-devel@nongnu.org; Tue, 31 Jan 2023 19:46:27 -0500 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3110EjeF018504; Wed, 1 Feb 2023 00:46:23 GMT Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3nfag0cda6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 01 Feb 2023 00:46:22 +0000 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 30VDArlQ013356; Wed, 1 Feb 2023 00:46:20 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma03ams.nl.ibm.com (PPS) with ESMTPS id 3ncvtyc3xn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 01 Feb 2023 00:46:20 +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 3110kH7k48300320 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 1 Feb 2023 00:46:17 GMT Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 02AB520043; Wed, 1 Feb 2023 00:46:17 +0000 (GMT) Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8D60D20040; Wed, 1 Feb 2023 00:46:16 +0000 (GMT) Received: from heavy.ibmuc.com (unknown [9.171.18.228]) by smtpav07.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 1 Feb 2023 00:46: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=mMRQaC3kK+XIczQaWtm8aSJsy1D7GyS5ob78buNrJVU=; b=UbvyofDP1NXXJSvfe93eTFhR0WsOgkmhAAQQexRP9YGFz0ukS6mFxcJ6HSLVxk2tjnKv XTRJmrHnF1B2eYtaxLabUHgSH+PtubqXdlV2zADMCF9FQExmxhOa22oBXNn3JXAN9M62 ILxay1c8SN5SqZ/yZK/YZS9ANsrAsCRCRMaYId8JT6TN7PtSgyfRi2ZVrzNMKxgWVUC0 bUw1qriveRsfJAVWzmJc5vwvSlapVLQENbbg2OOuhGEr9k1pSneYnT12n52kjSrGas9g o0ftO0QJbcWAiyNCyD1pCnivR11tA8zrqzt8nV/Uj9tWdvj/Vlf5mxAYEux1j+vP5p+8 9Q== From: Ilya Leoshkevich To: Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= Cc: Christian Borntraeger , qemu-devel@nongnu.org, Ilya Leoshkevich Subject: [PATCH 2/4] linux-user/microblaze: Handle privileged exception Date: Wed, 1 Feb 2023 01:46:07 +0100 Message-Id: <20230201004609.3005029-3-iii@linux.ibm.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230201004609.3005029-1-iii@linux.ibm.com> References: <20230201004609.3005029-1-iii@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: EN5Je7g7tjvmBNdWJmnHZlgXTWzVCqny X-Proofpoint-ORIG-GUID: EN5Je7g7tjvmBNdWJmnHZlgXTWzVCqny X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-31_08,2023-01-31_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 impostorscore=0 phishscore=0 suspectscore=0 spamscore=0 adultscore=0 lowpriorityscore=0 priorityscore=1501 mlxscore=0 mlxlogscore=999 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302010003 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+importer2=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, 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1675212429618100001 Content-Type: text/plain; charset="utf-8" Follow what kernel's full_exception() is doing. Signed-off-by: Ilya Leoshkevich Reviewed-by: Richard Henderson --- linux-user/microblaze/cpu_loop.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/linux-user/microblaze/cpu_loop.c b/linux-user/microblaze/cpu_l= oop.c index 5ccf9e942ea..212e62d0a62 100644 --- a/linux-user/microblaze/cpu_loop.c +++ b/linux-user/microblaze/cpu_loop.c @@ -25,8 +25,8 @@ =20 void cpu_loop(CPUMBState *env) { + int trapnr, ret, si_code, sig; CPUState *cs =3D env_cpu(env); - int trapnr, ret, si_code; =20 while (1) { cpu_exec_start(cs); @@ -76,6 +76,7 @@ void cpu_loop(CPUMBState *env) env->iflags &=3D ~(IMM_FLAG | D_FLAG); switch (env->esr & 31) { case ESR_EC_DIVZERO: + sig =3D TARGET_SIGFPE; si_code =3D TARGET_FPE_INTDIV; break; case ESR_EC_FPU: @@ -84,6 +85,7 @@ void cpu_loop(CPUMBState *env) * if there's no recognized bit set. Possibly this * implies that si_code is 0, but follow the structure. */ + sig =3D TARGET_SIGFPE; si_code =3D env->fsr; if (si_code & FSR_IO) { si_code =3D TARGET_FPE_FLTINV; @@ -97,13 +99,17 @@ void cpu_loop(CPUMBState *env) si_code =3D TARGET_FPE_FLTRES; } break; + case ESR_EC_PRIVINSN: + sig =3D SIGILL; + si_code =3D ILL_PRVOPC; + break; default: fprintf(stderr, "Unhandled hw-exception: 0x%x\n", env->esr & ESR_EC_MASK); cpu_dump_state(cs, stderr, 0); exit(EXIT_FAILURE); } - force_sig_fault(TARGET_SIGFPE, si_code, env->pc); + force_sig_fault(sig, si_code, env->pc); break; =20 case EXCP_DEBUG: --=20 2.39.1 From nobody Fri May 3 03:14:52 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1675212425; cv=none; d=zohomail.com; s=zohoarc; b=m8z3ITzWx63tWFt13bB7B8dwBOKfZVAVegycDEEQS+HIRJdW3BbP9IOfJFM71srlWqeWeI9Jkn9aCSQIQrRBpVk1z7ZLqLzlSMh9eBw9oDvQp4oOMKkQ82l8TwZvnUIlEqYNrN0PLN74kf/xxJXShWWfgn3aKpl71kfKf4LwxDE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675212425; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=iw1NFwLXsdwgRifB88ZluK+/1nDhlnNR7B2fM6GreBQ=; b=muT9dz3sI9O/sSLvVbByRqqgH91+9iw4GhkWWn9caLN7Fq/A3ISuKS7ZOf/kX7kF/rffxBLvnrk+wBD910ZsxcHepRyptMNlde71/k4NPquT0Hui5eJXzec+A4B+K0DSR7ce+ewfuKuN3m8fBGeIgGeIJaGyVAJ13Umml8aSAzM= 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+importer2=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 1675212425057292.39298553514334; Tue, 31 Jan 2023 16:47:05 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pN1Gd-0006ML-Lg; Tue, 31 Jan 2023 19:46:27 -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 1pN1Gc-0006Lo-Lc for qemu-devel@nongnu.org; Tue, 31 Jan 2023 19:46:26 -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 1pN1Ga-0004Ja-Up for qemu-devel@nongnu.org; Tue, 31 Jan 2023 19:46:26 -0500 Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3110gI48029852; Wed, 1 Feb 2023 00:46:23 GMT Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3nfd460vku-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 01 Feb 2023 00:46:23 +0000 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 30VDpqNa012859; Wed, 1 Feb 2023 00:46:21 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma03ams.nl.ibm.com (PPS) with ESMTPS id 3ncvtyc3xq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 01 Feb 2023 00:46:21 +0000 Received: from smtpav07.fra02v.mail.ibm.com (smtpav07.fra02v.mail.ibm.com [10.20.54.106]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3110kIah44237186 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 1 Feb 2023 00:46:18 GMT Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EEFC920043; Wed, 1 Feb 2023 00:46:17 +0000 (GMT) Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 803B420040; Wed, 1 Feb 2023 00:46:17 +0000 (GMT) Received: from heavy.ibmuc.com (unknown [9.171.18.228]) by smtpav07.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 1 Feb 2023 00:46: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-transfer-encoding; s=pp1; bh=iw1NFwLXsdwgRifB88ZluK+/1nDhlnNR7B2fM6GreBQ=; b=fdzMnIA4EZEkH0IhMdyo0zmgzctUlNk6zPqLj//qP4p+Mrx6XnfqkwAR2lQNCG58txTa OlpEPoq3QPyImtn/uNDdx/Zn5kzyp9pXTir/VWvuYUS4ji5G+5t54+4b7GlIIYWlS556 4Gx6Ov5CPy0U+0TTmw1VdE1TiWzaNmU4JLPHh5j8uyxXMx1pGz4Z5elIGSYIqh4DlQ/C dKL9rcIT4OFhK1nuQk73X1DmIsaaRFETikyi3qPM97UW492godTWonXACq1AKslBaqmU nVIC7yvU7HCvltN9OI1dV4cEgWBhywwOWJO/o3o1HmCDsO3qu1ixdbS4KwZIXSdTBjbK UQ== From: Ilya Leoshkevich To: Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= Cc: Christian Borntraeger , qemu-devel@nongnu.org, Ilya Leoshkevich Subject: [PATCH 3/4] linux-user/sparc: Handle "ta 5" Date: Wed, 1 Feb 2023 01:46:08 +0100 Message-Id: <20230201004609.3005029-4-iii@linux.ibm.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230201004609.3005029-1-iii@linux.ibm.com> References: <20230201004609.3005029-1-iii@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: OIKzlPvKJGGAFKMs6Wuq8jJUgWJTBQQ4 X-Proofpoint-GUID: OIKzlPvKJGGAFKMs6Wuq8jJUgWJTBQQ4 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-31_08,2023-01-31_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 malwarescore=0 bulkscore=0 mlxscore=0 suspectscore=0 phishscore=0 spamscore=0 priorityscore=1501 impostorscore=0 clxscore=1015 adultscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302010003 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.158.5; envelope-from=iii@linux.ibm.com; helo=mx0b-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1675212426162100005 Content-Type: text/plain; charset="utf-8" GCC lowers __builtin_trap() to "ta 5", which in turn generates trap 0x105. Follow what kernel's bad_trap() is doing there. Signed-off-by: Ilya Leoshkevich --- linux-user/sparc/cpu_loop.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/linux-user/sparc/cpu_loop.c b/linux-user/sparc/cpu_loop.c index 434c90a55f8..fa36d452a51 100644 --- a/linux-user/sparc/cpu_loop.c +++ b/linux-user/sparc/cpu_loop.c @@ -225,6 +225,9 @@ void cpu_loop (CPUSPARCState *env) restore_window(env); break; #ifndef TARGET_ABI32 + case 0x105: + force_sig_fault(TARGET_SIGILL, ILL_ILLTRP, env->pc); + break; case 0x16e: flush_windows(env); sparc64_get_context(env); --=20 2.39.1 From nobody Fri May 3 03:14:52 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1675212428; cv=none; d=zohomail.com; s=zohoarc; b=jWw2cZlExdw7WztUtcezFECY+/7ayt1TJCHXoffukBpIwz2rVANa5m7EVRGpdN1D3989JJqFF1EPT9WiGfL9gRulovL6gc8TPy4hqHcw1pnTR72d6KEeJPBXkqRhVqkO4+vTabR2Gh8nFsSoiP4Sm4ZfGVuL+BH+2Bacz94ui0M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675212428; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=5Dncu3fDp4KaNdR+nzKKjfpEqYCUNuYvmiIc/96SuoI=; b=QBTWC4P5lwCt9/HeIffSNIxmokEczidpCTS5tT5e2C5tqFYBjBMlBNJlNqqgzKE57UUFteMSPRXPnw/xkfLTY3bsf2p3rWA8kBrtLt4BQl2TZLqQ7Nsn1RHBKjGCJN624KBiDpyZNlckNmIHuXNu3um690sOYhFbEEOqUtnRu30= 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+importer2=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 1675212428719449.5173254776256; Tue, 31 Jan 2023 16:47:08 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pN1Gf-0006NK-9u; Tue, 31 Jan 2023 19:46:29 -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 1pN1Ge-0006MT-1E for qemu-devel@nongnu.org; Tue, 31 Jan 2023 19:46:28 -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 1pN1Gb-0004Jz-IX for qemu-devel@nongnu.org; Tue, 31 Jan 2023 19:46:27 -0500 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30VM0ikJ003264; Wed, 1 Feb 2023 00:46:24 GMT Received: from ppma03fra.de.ibm.com (6b.4a.5195.ip4.static.sl-reverse.com [149.81.74.107]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3nf83d967p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 01 Feb 2023 00:46:24 +0000 Received: from pps.filterd (ppma03fra.de.ibm.com [127.0.0.1]) by ppma03fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 30VJfGHc030067; Wed, 1 Feb 2023 00:46:22 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma03fra.de.ibm.com (PPS) with ESMTPS id 3ncvshaxqs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 01 Feb 2023 00:46:22 +0000 Received: from smtpav07.fra02v.mail.ibm.com (smtpav07.fra02v.mail.ibm.com [10.20.54.106]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3110kI3739453008 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 1 Feb 2023 00:46:19 GMT Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DBB802004B; Wed, 1 Feb 2023 00:46:18 +0000 (GMT) Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7829320040; Wed, 1 Feb 2023 00:46:18 +0000 (GMT) Received: from heavy.ibmuc.com (unknown [9.171.18.228]) by smtpav07.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 1 Feb 2023 00:46:18 +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=5Dncu3fDp4KaNdR+nzKKjfpEqYCUNuYvmiIc/96SuoI=; b=M0iujoMRS1NOCI2Qtl54loKjaynfxH45dSzqTdLxIiCTf9hem2R4WFvkzcBXhWra6g3c n6rKpeAS3Yek6i9jftmAsTKsvS21hUYA0jHmC9UB9IGY6k+9FBvqmOWJk2Lv57RVkvlA S9+0spyNOSB6MKUBldrzo7nFN8b9aJMvN2tMPxpDjOj5/C74g/r7CTpAac8FeA3BLTCf 318K4nWXeh6zQoozfaxYh3vivRmBtQBv6QvEIXWDJl2usuIiGqB+yqRZYygKgoK2piJG WpnXv0yGRb9TLbKf/EYXK6x5N0roa2yeXoG7svRJz/pEdHTpxqY5lHLTd35fVFixWboV tw== From: Ilya Leoshkevich To: Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= Cc: Christian Borntraeger , qemu-devel@nongnu.org, Ilya Leoshkevich Subject: [PATCH 4/4] tests/tcg/linux-test: Add linux-fork-trap test Date: Wed, 1 Feb 2023 01:46:09 +0100 Message-Id: <20230201004609.3005029-5-iii@linux.ibm.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230201004609.3005029-1-iii@linux.ibm.com> References: <20230201004609.3005029-1-iii@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 4ytAdfIl2-Jo4-ZftggRvuQE8vLXOq2h X-Proofpoint-GUID: 4ytAdfIl2-Jo4-ZftggRvuQE8vLXOq2h X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-31_08,2023-01-31_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 clxscore=1015 impostorscore=0 lowpriorityscore=0 spamscore=0 mlxlogscore=642 suspectscore=0 malwarescore=0 priorityscore=1501 adultscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302010003 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.158.5; envelope-from=iii@linux.ibm.com; helo=mx0b-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1675212429621100002 Content-Type: text/plain; charset="utf-8" Check that dying due to a signal does not deadlock. Signed-off-by: Ilya Leoshkevich Reviewed-by: Richard Henderson --- tests/tcg/multiarch/linux/linux-fork-trap.c | 48 +++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 tests/tcg/multiarch/linux/linux-fork-trap.c diff --git a/tests/tcg/multiarch/linux/linux-fork-trap.c b/tests/tcg/multia= rch/linux/linux-fork-trap.c new file mode 100644 index 00000000000..a921f875380 --- /dev/null +++ b/tests/tcg/multiarch/linux/linux-fork-trap.c @@ -0,0 +1,48 @@ +/* + * Test that a fork()ed process terminates after __builtin_trap(). + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ +#include +#include +#include +#include +#include + +int main(void) +{ + struct rlimit nodump; + pid_t err, pid; + int wstatus; + + pid =3D fork(); + assert(pid !=3D -1); + if (pid =3D=3D 0) { + /* We are about to crash on purpose; disable core dumps. */ + if (getrlimit(RLIMIT_CORE, &nodump)) { + return EXIT_FAILURE; + } + nodump.rlim_cur =3D 0; + if (setrlimit(RLIMIT_CORE, &nodump)) { + return EXIT_FAILURE; + } + /* + * An alternative would be to dereference a NULL pointer, but that + * would be an UB in C. + */ +#if defined(__MICROBLAZE__) + /* + * gcc emits "bri 0", which is an endless loop. + * Take glibc's ABORT_INSTRUCTION. + */ + asm volatile("brki r0,-1"); +#else + __builtin_trap(); +#endif + } + err =3D waitpid(pid, &wstatus, 0); + assert(err =3D=3D pid); + assert(WIFSIGNALED(wstatus)); + + return EXIT_SUCCESS; +} --=20 2.39.1