From nobody Wed May 15 11:48:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1682973122; cv=pass; d=zohomail.com; s=zohoarc; b=VYzGt/72Eoyyl3TGZGWEvDWFgTxRJZbKFb4qcOeDnhuplhw6aYOoU8md7KO/+7twiLCMMJYwUZ6Bu/JZmg3087j/MxCe2TfNJiZetFTPPGdeDxj0+7YhEQ/9LIgMb7v0FeDG/8bqVWleJrJjGmPjDZPMZD0VjWahjGB0AYDKA28= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682973122; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=CSFUIv+vA4xvYLSDbnANA0FJUUKynik5M6lLpry0LHk=; b=l8Y77i+Oii/rz9RnPMvB/G1BU0cbUpX6NVn7XRl7jpNlChPRzgRZH5E6YEIwbHUhUDl8xAVa9M3keYj+StzeDvPoem2G9J+Jw7l1aH0w7h10I+H2WJ3utHUlb8S6FteJuVNR6ZJFXGox/pD6kUs/aFLwtcDluuyQ6LEyZWmlH3g= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1682973122250690.2585497555568; Mon, 1 May 2023 13:32:02 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.528289.821247 (Exim 4.92) (envelope-from ) id 1ptaAi-0004GW-KM; Mon, 01 May 2023 20:30:56 +0000 Received: by outflank-mailman (output) from mailman id 528289.821247; Mon, 01 May 2023 20:30:56 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ptaAi-0004GP-Hb; Mon, 01 May 2023 20:30:56 +0000 Received: by outflank-mailman (input) for mailman id 528289; Mon, 01 May 2023 20:30:55 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ptaAh-0004GJ-DN for xen-devel@lists.xenproject.org; Mon, 01 May 2023 20:30:55 +0000 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on20600.outbound.protection.outlook.com [2a01:111:f400:fe5b::600]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 10c6ba00-e85f-11ed-b225-6b7b168915f2; Mon, 01 May 2023 22:30:53 +0200 (CEST) Received: from DS7PR05CA0077.namprd05.prod.outlook.com (2603:10b6:8:57::17) by SA3PR12MB7784.namprd12.prod.outlook.com (2603:10b6:806:317::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.30; Mon, 1 May 2023 20:30:50 +0000 Received: from DS1PEPF0000E649.namprd02.prod.outlook.com (2603:10b6:8:57:cafe::8f) by DS7PR05CA0077.outlook.office365.com (2603:10b6:8:57::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.20 via Frontend Transport; Mon, 1 May 2023 20:30:49 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by DS1PEPF0000E649.mail.protection.outlook.com (10.167.18.39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6340.16 via Frontend Transport; Mon, 1 May 2023 20:30:49 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Mon, 1 May 2023 15:30:48 -0500 Received: from ubuntu.mshome.net (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Mon, 1 May 2023 15:30:48 -0500 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 10c6ba00-e85f-11ed-b225-6b7b168915f2 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mdMwMeBAzJ0YwgoD90WE9JrbR91We36xi7QeZHVwiTKiWY7A5Khhoc6nxeuWihek56vzUcJ4DYkKLLzo+5NjJzHfrKOBzkwl/OZCzsEo69HEpT7pOMq8zsGZq7G/QMStnhSt0IIZsYOqxvyH93aiZ9uYxH+vTry9AV0SzEpYpnOM4Sw5YN7vFcPeATrl5XHbglJP6134JQJB1/Un9urouybQ+u4i/59HhF3U0GKL0Ladsck8qt4oS8/nSIt/DsxwGICZPvkIevoZntQskET84Yi/uMHDRpnwZZoY3KKmYKunJ0H6Lt35aAwg15DNw4I65z2vW/zLWO1x7pzihh+AbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=CSFUIv+vA4xvYLSDbnANA0FJUUKynik5M6lLpry0LHk=; b=Wtg8XHCEFG0n5SqdcJqZqvWykMifHxVRV8SzZ2zrQnrZ1rgOMJLeyOZmVxhk98oWI7HSmsAkaRpNjogWAwshBJgiDQRS6n2o8YyxljzVzLJaVuw7h1LqgnQ2nfctTxMcuJOHLVDdP8UpPs0881sIvUZpd5q6nGa3BoDyLxFy4yDo/rBWjqlWsEE/gS0Z93Iu7ftVBVYh4SttaJFB19LJpuhjZOUcUbGpexwqGJJ1qUGvSruhSXxcZpj+AQrUZtFXjDzcx/oMhxP3hR87Tp1aYeraWnlO+5igDc2o/mvS/GWPZhf3diisk7jSYmnK+Jn/til7tVSYhCpwhipAau+bEw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=CSFUIv+vA4xvYLSDbnANA0FJUUKynik5M6lLpry0LHk=; b=BUhgGeyjVq9n2YOjlMMUkiY94U8LkxXF2vt1Gl8le2Gmj5XQ8qU8R4ahXKwGNO39SHPC+QkcoLIdeHdwczECLuXGUS4yjwu05hY+7qUk1qnaAIlXNPqsBU+R8KH2OrGKegyHY3kTrHjt8KB3Mmirdk940T/Xjr2gThhp63wq+K8= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C From: Stewart Hildebrand To: CC: Stewart Hildebrand , George Dunlap , Dario Faggioli , "Juergen Gross" Subject: [PATCH v1] xen/sched/null: avoid crash after failed domU creation Date: Mon, 1 May 2023 16:30:46 -0400 Message-ID: <20230501203046.168856-1-stewart.hildebrand@amd.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0000E649:EE_|SA3PR12MB7784:EE_ X-MS-Office365-Filtering-Correlation-Id: d80ca6cd-7382-4db1-4971-08db4a82f387 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9rasoY0u2wUFDqhcqLDQc8UUGjWTGuBZITehAW1/NmIt5BgArjh6Rk829Z5ywuuBV8Tg+1Uo2iKcV+B74EwPql8Vj/x1HlIv5ZpSMr9wxcBIRhvOc/JQUr4NJkP9BOphqSrsTQOVI8/p5g2VfDS/N76QwVxeKAnKsalWpfzlS+XZJmGvBfwpT+ZRgyBt4nv3GGujpNxPL1kNJkiIw6CHdTFtEcFOb0JwME6srJSjm4GsJEB9HmnwA8v0gpzilKBMAnmD8Wm3tbvAiqaf+IBUNxYBVd77bBtAk9Di7NW2UdhSbFI9u3hFPg6At1I2SVdGHbsi8oWCSfaGxWQF57ukrFJL0D9XemCGTXTsHLjXohBcw2tbtKU91hbR93u/Sm8S5jeaZ2WWT7TU8brRNDi3LLIay+0xA3zU/0dgpVUaKcqxr2SfA2B4f8iWYeAiJsnUZdOJi5QrCBxYRNUP57rUBtEmG2jZwIGgU0UEQvGnTXsAEHp5FFlLaC2jBiGxqTEE0uTW97Jplj+kk0LMRojLRCpj7KZXYmK7OrZ9c0temJPa17BAXu9DP/bmY2GeJxJVlaqkb2a/NCVzXbxwhdPBvHY/+uQfkoJAIdLuJ5UQdDjTQyXdCpWvh9zRcq4o01EeLUvD4OpzNpMsE2fd94tL26hJPIo2ZRulJSSyy0ta82bMYvmHMeR6GtH7JJ7aBn92psuvWlNFaMuVnbjVievHU0/fZq8gFkfv9YxJ+x6dDDc= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(396003)(39860400002)(136003)(346002)(376002)(451199021)(36840700001)(46966006)(40470700004)(40480700001)(40460700003)(316002)(1076003)(82310400005)(26005)(426003)(336012)(41300700001)(2616005)(47076005)(83380400001)(186003)(478600001)(70206006)(36860700001)(54906003)(70586007)(4326008)(966005)(6916009)(356005)(82740400003)(81166007)(36756003)(2906002)(5660300002)(86362001)(8936002)(8676002)(44832011)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 May 2023 20:30:49.4209 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d80ca6cd-7382-4db1-4971-08db4a82f387 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS1PEPF0000E649.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR12MB7784 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1682973124372100001 Content-Type: text/plain; charset="utf-8" When creating a domU, but the creation fails, there is a corner case that m= ay lead to a crash in the null scheduler when running a debug build of Xen. (XEN) **************************************** (XEN) Panic on CPU 0: (XEN) Assertion 'npc->unit =3D=3D unit' failed at common/sched/null.c:379 (XEN) **************************************** The events leading to the crash are: * null_unit_insert() was invoked with the unit offline. Since the unit was offline, unit_assign() was not called, and null_unit_insert() returned. * Later during domain creation, the unit was onlined * Eventually, domain creation failed due to bad configuration * null_unit_remove() was invoked with the unit still online. Since the unit= was online, it called unit_deassign() and triggered an ASSERT. To fix this, only call unit_deassign() when npc->unit is non-NULL in null_unit_remove. Signed-off-by: Stewart Hildebrand Acked-by: Dario Faggioli Reviewed-by: Juergen Gross --- RFC->v1 * Follow Juergen's suggested fix Link to RFC [1] [1] https://lists.xenproject.org/archives/html/xen-devel/2023-04/msg01387.h= tml --- xen/common/sched/null.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/xen/common/sched/null.c b/xen/common/sched/null.c index 65a0a6c5312d..2091337fcd06 100644 --- a/xen/common/sched/null.c +++ b/xen/common/sched/null.c @@ -522,6 +522,8 @@ static void cf_check null_unit_remove( { struct null_private *prv =3D null_priv(ops); struct null_unit *nvc =3D null_unit(unit); + struct null_pcpu *npc; + unsigned int cpu; spinlock_t *lock; =20 ASSERT(!is_idle_unit(unit)); @@ -531,8 +533,6 @@ static void cf_check null_unit_remove( /* If offline, the unit shouldn't be assigned, nor in the waitqueue */ if ( unlikely(!is_unit_online(unit)) ) { - struct null_pcpu *npc; - npc =3D unit->res->sched_priv; ASSERT(npc->unit !=3D unit); ASSERT(list_empty(&nvc->waitq_elem)); @@ -549,7 +549,10 @@ static void cf_check null_unit_remove( goto out; } =20 - unit_deassign(prv, unit); + cpu =3D sched_unit_master(unit); + npc =3D get_sched_res(cpu)->sched_priv; + if ( npc->unit ) + unit_deassign(prv, unit); =20 out: unit_schedule_unlock_irq(lock, unit); --=20 2.40.1