From nobody Fri Nov 22 13:30:37 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=1716450083; cv=pass; d=zohomail.com; s=zohoarc; b=UGjH+mfXE9h18dapqxo/QvSX6AF5BpV4sWCtnbrXAvmeMeHNpNUBZizU5Sfyf+3EAJzGSjaQtaGyNs9Us0uq8bXQlW6wbx3YcLIyNS7C6Sru0pOfSKoxcmTmopsU3S3x7ZTaix9byppEU7CJQ5A+B/VVYuOygPdXomrGkHHw/Tw= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716450083; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=r/W168QEvQVYTC09iGsQQFU2oTMKOq6gSMJXAiUxem4=; b=lBPw3nTgGpVFiGtil8pBE9FAjYOGiTS6oJubUhshdP9GAuB7rpcVZaJtXR+dfM5uHB4yYR3fE72Ywj6zxIp+Yj120KKYL523O0CbR66kCVAwQFLHWlEltyzzUWStYcguLMmBp9+FPuUHJJk9MLF8Fg2oE/hpAoMYfd/WjbrbDcE= 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 1716450083342211.19948017446507; Thu, 23 May 2024 00:41:23 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.728094.1132869 (Exim 4.92) (envelope-from ) id 1sA34H-0001lE-NG; Thu, 23 May 2024 07:40:53 +0000 Received: by outflank-mailman (output) from mailman id 728094.1132869; Thu, 23 May 2024 07:40:53 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sA34H-0001l7-KE; Thu, 23 May 2024 07:40:53 +0000 Received: by outflank-mailman (input) for mailman id 728094; Thu, 23 May 2024 07:40:52 +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 1sA34G-0001WY-PD for xen-devel@lists.xenproject.org; Thu, 23 May 2024 07:40:52 +0000 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on20601.outbound.protection.outlook.com [2a01:111:f403:2405::601]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id c73155d3-18d7-11ef-90a1-e314d9c70b13; Thu, 23 May 2024 09:40:52 +0200 (CEST) Received: from SJ0PR03CA0272.namprd03.prod.outlook.com (2603:10b6:a03:39e::7) by DS0PR12MB7509.namprd12.prod.outlook.com (2603:10b6:8:137::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.19; Thu, 23 May 2024 07:40:47 +0000 Received: from CO1PEPF000066E7.namprd05.prod.outlook.com (2603:10b6:a03:39e:cafe::d0) by SJ0PR03CA0272.outlook.office365.com (2603:10b6:a03:39e::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.22 via Frontend Transport; Thu, 23 May 2024 07:40:47 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1PEPF000066E7.mail.protection.outlook.com (10.167.249.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7611.14 via Frontend Transport; Thu, 23 May 2024 07:40:46 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 23 May 2024 02:40:45 -0500 Received: from henry-MS-7D54.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Thu, 23 May 2024 02:40:44 -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: c73155d3-18d7-11ef-90a1-e314d9c70b13 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TXdzLE+kKH46u9Sng84dpWlCTRQJI357cr0AvkengcQnhlsrf5Iwemeh7WjtNCl+oVmvyaOl+qRo056poVrfNWXIYqMuDkUyZNhExvVXeiGUK0NlJ+szO1eTUux0rxa1nrSuFTBhixg8+ls7qMOtkMPs0fkXS2Uny0J19MlrVILVjVAPMI3vp+to+wGDURkbvXSbl3BScWM3vpuOCr7azFdDV7Xg2OBIBeh9x4/93YjS6OKYXFWLAGMMSW8cDIBLF9m7y4KdPa/op6HPrPd+2ni4N4dh2OUfsgNYJHgO179kwWPMfBZR4BtlniN1+bT1AyOFT6Q+UFu6CID2JuMPvA== 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=r/W168QEvQVYTC09iGsQQFU2oTMKOq6gSMJXAiUxem4=; b=NMaeuc0ruls78XaqMFJNAgAvtcN6bNBfxoJjmuiCbICes0/+QLC2obkCdpPQoVBhQL0ENQfje4cRmfZFR9KgqniUMpebFrkOOz3cFsZrqlmcF31v1qWJ5Rs0Ll3JbQypn8xlwTwasDpzPBUxDLNiwvc5y5Yej4wNOlhb9oYIcEuUVTSIlWLDMICcgpBs8uGxpfN2cYo335BptrilvzGoDOBd0yMxzEbWl0MlhPL1GU/fM7VMJviBrWDKUtfm9AtIS01DhceT3L80FxcC2t133Lz6riFYjAbvLyc6LS1EqgJ4WRhMDqh1CvGnwLuuxNo0t5LUrztUNWrKLCEPqUA/mQ== 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 (0) 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=r/W168QEvQVYTC09iGsQQFU2oTMKOq6gSMJXAiUxem4=; b=TXD8tE0v34Mn88tGEFcaqrfSKdZLPHpYn6pij5jvSEULaSUd5NfphWjyhYC4Wk8RFLc6Cjdgs0+Z9W0yFOh1XcOvIvj/168jlMKJmYT9dfPb/Fa6rEtzuSsdLyE+tntQWY84HDSRhDRTpYEVhelkQq3AVSwuDUbD/3tXMgFEHXA= 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=SATLEXMB04.amd.com; pr=C From: Henry Wang To: CC: Anthony PERARD , Henry Wang , Jason Andryuk Subject: [PATCH v4 1/9] tools/xl: Correct the help information and exit code of the dt-overlay command Date: Thu, 23 May 2024 15:40:32 +0800 Message-ID: <20240523074040.1611264-2-xin.wang2@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240523074040.1611264-1-xin.wang2@amd.com> References: <20240523074040.1611264-1-xin.wang2@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: None (SATLEXMB04.amd.com: xin.wang2@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000066E7:EE_|DS0PR12MB7509:EE_ X-MS-Office365-Filtering-Correlation-Id: d377181f-5b2f-445f-d9d5-08dc7afba8e7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|376005|36860700004|82310400017; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?aBxdqU1m92P565gZjrLCwUTUZ7iEh2pilmYFgRhCAGqcNpKQ2StZPIxzzdVd?= =?us-ascii?Q?96H/MB6e+5lA6zQaY1Ygk0zcz0wvfAuc4PudQL6b7spKqWEZZ84fHVWih+/f?= =?us-ascii?Q?76YGFzs14idDEeONJXl8x/+TFsqcViwcVpUoEHIQz4n8qwccKhdCxNPLhmKh?= =?us-ascii?Q?qvVaLAC4GEHySL3+qKLA7uAara81nnO+rPGhzJa4kKrTBlWfz6/g8Nz2JsMl?= =?us-ascii?Q?lz2HLILzJlxEHYGtZyfvoZLF9Z1sb6c91J4jUCy7SmpCRcKF42HkxmISBx0u?= =?us-ascii?Q?XDoUkJd3LaHZm3mpQRnQsQVKpb6zNez9gKi2HSLipryEgnyr4sEh802JgkBV?= =?us-ascii?Q?wYWnCrGZNF1jozBkvdFXGsZAFPM2duvy8tdWzQluoIfdQw7P7Tr9+njnFoXM?= =?us-ascii?Q?aLdlY45m51BjgXsjZAtPBixECkcedvnTfQxuuFgXmRAz+lgnefSYOJ84Se1h?= =?us-ascii?Q?477hGdGmXXoocAS4FQTeuoUJ9RxRI3xIbeVPf6oC+weWCzOqfnrH9zjiBqB8?= =?us-ascii?Q?9rv3I5PkWUJVOuk0jX7c3JyJ2KRvra0s09OGoi6YnTQ/OzWJ0OcHSn31kL9K?= =?us-ascii?Q?q2mzNIM65dbeMa2D2BDvBasOLyjFoKH1bIVFPoYmyK5bCpUaHlALXct3Ck9+?= =?us-ascii?Q?8UMfhnixOiX/EpU45+P/NwvqQXjg4/VET6KCcPTpvKtWFOHqVnKiN8E9r3Lo?= =?us-ascii?Q?prWwb6iuuXQkww4Y2mPmpve4yndQyXNp3IvN6JtFADjGskdtnZraZqmuEAbU?= =?us-ascii?Q?w7y6Gwo3QFTpvGVirVQa4ba13obncpsabH/5DEugocn4eyjegc8YB9rk9xRk?= =?us-ascii?Q?IhOnIyeOiSI5X1eWxN7mYThjkanxeUadYfqpKSu+99l8tlw+UW+Eci97Yr/L?= =?us-ascii?Q?+S+LrCEEdfbAD/a+MW9f4Q9Xe0qYo3LOn8WEG48DbsW3623Bk8y7yVawC5Nf?= =?us-ascii?Q?VCFGnTlnsC5eNIhqPbCAXxXlqiwVXgDfh9kcJFJWEYijHjJUS8sWG1pZbhiN?= =?us-ascii?Q?OH/5e/Sim4eQkCHRWCdmRSRhE89HnvPlnBXVtAbnkr2DAqcyWvjIiZc8WC84?= =?us-ascii?Q?gHjbM/ud/tf9RPk5RN8RJ5tOR7mWC+b+DM0O75iYebIuysx6GMv2nSIgQdpA?= =?us-ascii?Q?RYzFoFkm94etGITtytCUNlhjcU4g1bMqcqRKeYqUnOgtrhhpmfHEP523D9P4?= =?us-ascii?Q?nniGe3UZDHH/Pj4tyhKOAnJIl1FSgSZoe/TsnIww0SRQ+WHVwfdwz44P+zvm?= =?us-ascii?Q?jaGNIDUiA6+D0923XI/AlDwjBNneGhUhl6XUIUUgR7hvfpci/YNRdvG96VDr?= =?us-ascii?Q?ma2RNU9wq+unOYC9luT8f9w05OpSDAxXMp0gcpcCywDKtRaLhZ3tAeckhHTc?= =?us-ascii?Q?Dm5ZfbE=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(1800799015)(376005)(36860700004)(82310400017);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 May 2024 07:40:46.6883 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d377181f-5b2f-445f-d9d5-08dc7afba8e7 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000066E7.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7509 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1716450085231100007 Content-Type: text/plain; charset="utf-8" Fix the name mismatch in the xl dt-overlay command, the command name should be "dt-overlay" instead of "dt_overlay". Add the missing "," in the cmdtable. Fix the exit code of the dt-overlay command, use EXIT_FAILURE instead of ERROR_FAIL. Fixes: 61765a07e3d8 ("tools/xl: Add new xl command overlay for device tree = overlay support") Suggested-by: Anthony PERARD Signed-off-by: Henry Wang Reviewed-by: Jason Andryuk Reviewed-by: Stefano Stabellini --- v4: - No change. v3: - Add Jason's Reviewed-by tag. v2: - New patch --- tools/xl/xl_cmdtable.c | 2 +- tools/xl/xl_vmcontrol.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/xl/xl_cmdtable.c b/tools/xl/xl_cmdtable.c index 62bdb2aeaa..1f3c6b5897 100644 --- a/tools/xl/xl_cmdtable.c +++ b/tools/xl/xl_cmdtable.c @@ -635,7 +635,7 @@ const struct cmd_spec cmd_table[] =3D { { "dt-overlay", &main_dt_overlay, 0, 1, "Add/Remove a device tree overlay", - "add/remove <.dtbo>" + "add/remove <.dtbo>", "-h print this help\n" }, #endif diff --git a/tools/xl/xl_vmcontrol.c b/tools/xl/xl_vmcontrol.c index 98f6bd2e76..02575d5d36 100644 --- a/tools/xl/xl_vmcontrol.c +++ b/tools/xl/xl_vmcontrol.c @@ -1278,7 +1278,7 @@ int main_dt_overlay(int argc, char **argv) const int overlay_remove_op =3D 2; =20 if (argc < 2) { - help("dt_overlay"); + help("dt-overlay"); return EXIT_FAILURE; } =20 @@ -1302,11 +1302,11 @@ int main_dt_overlay(int argc, char **argv) fprintf(stderr, "failed to read the overlay device tree file %= s\n", overlay_config_file); free(overlay_dtb); - return ERROR_FAIL; + return EXIT_FAILURE; } } else { fprintf(stderr, "overlay dtbo file not provided\n"); - return ERROR_FAIL; + return EXIT_FAILURE; } =20 rc =3D libxl_dt_overlay(ctx, overlay_dtb, overlay_dtb_size, op); --=20 2.34.1 From nobody Fri Nov 22 13:30:37 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=1716450081; cv=pass; d=zohomail.com; s=zohoarc; b=nyRo99R8wvPiXiZjSogQqeSKq0TTCSlQThRQvQCT9ss3Jzsi4SaRrkh2ywfQ1b/Bw8IQZDrzeQCU9knSTdemMeVAPXmxtpYfIZvNVahrqVECOxojCLaIS73qyYU0Nh9AkZdNvhYIltA/TaNijL7QD8DIe6OuVBRTGIZ+sT5ceVo= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716450081; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=1PvDoXhNpQSv0AS8DYv80AMDNw8eCiT+reRuwP+9FhI=; b=Xe3vRiln+41ky8D9fPvNHIhfsqYjYub2zLPXxPYbNTn4a9Sqw6+3CzgpRyU9126V3X5zWCcrxyAej3yw9AEZTN3eOYBu6tGTZ0CR6UL41/oP7bRLmsFy2PQRdq7cnX0+jYCOocdERav6lnPmlJQAcBr7A6mbkQI5Wg5RIceHlLM= 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 1716450081048957.7040682790843; Thu, 23 May 2024 00:41:21 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.728095.1132880 (Exim 4.92) (envelope-from ) id 1sA34J-00020W-VF; Thu, 23 May 2024 07:40:55 +0000 Received: by outflank-mailman (output) from mailman id 728095.1132880; Thu, 23 May 2024 07:40:55 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sA34J-00020L-S1; Thu, 23 May 2024 07:40:55 +0000 Received: by outflank-mailman (input) for mailman id 728095; Thu, 23 May 2024 07:40: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 1sA34J-0001WY-5o for xen-devel@lists.xenproject.org; Thu, 23 May 2024 07:40:55 +0000 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on20600.outbound.protection.outlook.com [2a01:111:f403:2415::600]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id c8a1b593-18d7-11ef-90a1-e314d9c70b13; Thu, 23 May 2024 09:40:54 +0200 (CEST) Received: from CH0PR03CA0317.namprd03.prod.outlook.com (2603:10b6:610:118::12) by DS7PR12MB5718.namprd12.prod.outlook.com (2603:10b6:8:71::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.22; Thu, 23 May 2024 07:40:49 +0000 Received: from CH1PEPF0000AD74.namprd04.prod.outlook.com (2603:10b6:610:118:cafe::9b) by CH0PR03CA0317.outlook.office365.com (2603:10b6:610:118::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.20 via Frontend Transport; Thu, 23 May 2024 07:40:49 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by CH1PEPF0000AD74.mail.protection.outlook.com (10.167.244.52) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7611.14 via Frontend Transport; Thu, 23 May 2024 07:40:49 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) 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.2507.35; Thu, 23 May 2024 02:40:47 -0500 Received: from henry-MS-7D54.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Thu, 23 May 2024 02:40:46 -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: c8a1b593-18d7-11ef-90a1-e314d9c70b13 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BENyBqWYcm6Pq/xf854269+YaTfuU2GK/+p0Jnp2PKwUYsar2Nz83urLx3jCEj/L5ueXm1O5bTu0EAnIfASZBaRWjtE2RQowQqBMaV2rTC+MxlF38pTt5w9B4FEhhcSuovXgYdg+28i2a5rOLDeYWk3+FlBuQl3MTcGTxEROSFKSp8+ZXMPp42m75LnB4QLA6D1HthnMAWk9sU04CNsrAQgdOJgATTDE0n+D4ARNBfzzLSywBYE7HJp2N6f3jxGEN1+vwteRxZNjy1wxsKuH5k8YyRfIMUVvNXF5Qr6LUFE2ggRGlUQOXEj/6lfKoVBXDNdWFZyOa4GXjnzoTEio9A== 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=1PvDoXhNpQSv0AS8DYv80AMDNw8eCiT+reRuwP+9FhI=; b=hbyVjSNL2HvF+bDJjnSDNSm4BtfimDM57P7OMhiL/VzPvDsYffq1kUjLm0+YOrCnTuEqelgJRq/3sdx8zxpyxxL9irtgAHRD1V6rdRYLNMKQGqwM9pb4dlwTjIlKlUixLKN7fjGa7KfGNKfzZzoR4XYq4Rq1nx/bWwDiLckRgtWmhVNAI1l68rm3ZaxbDVLrN+yTQFKVMByiRgIL0f9Lc8yHsDM7JXVooR71Kxgkf7nz/X03jNeiol6FjpEIOObsQjv9dOQIUbdklfawbNJ/qS/KCqpxx2o+KNOMtuk5GDx7CB6DZcWXpfUDmMJw4DhsDBQoCSnnne6kN8Lc/fqu2g== 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 (0) 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=1PvDoXhNpQSv0AS8DYv80AMDNw8eCiT+reRuwP+9FhI=; b=qC4v2zWovjYwQYxqAG6rfZZkoNEEk79LhoDTTOaW1l/azRRqFDmG2QZ3ISdtF4lKmiQNG5Z6ZKnfq0U0oR/YQjOjCTeIskaCWLoOcabEhsCRE4qOSs2gL7C1YdrhVsdA8PccVZfbR5h+WYKsRq4xcxhKiEwr+/XHJ1fb+HEt4xY= 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: Henry Wang To: CC: Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk , "Henry Wang" Subject: [PATCH v4 2/9] xen/arm, doc: Add a DT property to specify IOMMU for Dom0less domUs Date: Thu, 23 May 2024 15:40:33 +0800 Message-ID: <20240523074040.1611264-3-xin.wang2@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240523074040.1611264-1-xin.wang2@amd.com> References: <20240523074040.1611264-1-xin.wang2@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: None (SATLEXMB03.amd.com: xin.wang2@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000AD74:EE_|DS7PR12MB5718:EE_ X-MS-Office365-Filtering-Correlation-Id: 857a9ee6-1009-4bda-0eb6-08dc7afbaa47 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|376005|36860700004|1800799015|82310400017; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?fFIyXY5nh2IaKIY5JtE4otIB+TL2D7QyIMTc6XQhKjU1adF76KFbQXL7Bd4o?= =?us-ascii?Q?jsFp1ThFKMlFIh6R2v0cnjhwFNXcfg3UDwgrZdCOwyzyQZszt7HrZpKZ/HKl?= =?us-ascii?Q?gTAKwcadTSjEjhRSOzUn7kWQXonrqLdONgNpBoA1SB42vU+uaERhIj41qdMl?= =?us-ascii?Q?wc7JCnaXe+Dl65CNAHQQ4EvQAcQxFsaCXenh+AAY3xjDiAgP422tD9te0kdS?= =?us-ascii?Q?oCnmhuI5E+vgJlqu3Pqx9ri4waOpeUZW5yi8ymU01Tk8FWTmfv8TrTYOvE9L?= =?us-ascii?Q?vmPj2IBZe9y0K+jQfl1e7GNzjt2Pb+iEOFMgIc10hnq1cdHWk/MQoNojL4vf?= =?us-ascii?Q?iQlqn7xUwUZ3Gw7964X55sAkGxZvrK+auGL7rjY4F7RJ0AssayHr4v6yH1Fy?= =?us-ascii?Q?sqvNrPSLN2kFm9VB4rVIeSHA4cVlhNBHC8gysgkDAmzkncjEzUzOd+NkOrO3?= =?us-ascii?Q?YIVowO/vDEx0qk9ToCA6HRMm5BJOFze/1N63TU8C9qeXwwgdq4sFzhmBFkXN?= =?us-ascii?Q?kQIKyu2w/y0nuU/XmiYKXpWi9eLSpCVtFSWr9pphQDfuNRWQbPIZQjexSWYT?= =?us-ascii?Q?mYHKOfRPsPKwiRBXxUoYtIeF8QvyOACNuOk9SZ2YLQ5+Fcr1A7Pl9W1FYHeA?= =?us-ascii?Q?yP1AfIXKu7fcssmdQQ64QejV7+dicu3iSsgDYwDCaER4oGSNJqBalqix2U7I?= =?us-ascii?Q?Sn2Wbiqs4KB7xe4X6N1PhyiLNGlZfPGiz6SfPVw85BgHbpb3A88yLoIMAGXN?= =?us-ascii?Q?IVY66NYfrh4wUyspjBLCF6cwPVRYPFLwAxGuBc7xIseDZv8yWd2LJTqp0lZK?= =?us-ascii?Q?4b8or9EmSQSTAXOAb5EGsZO6bqe1LJ1DT1B/TA0N66jZkXn1i5AMe7+ptH+i?= =?us-ascii?Q?wkymHX9jnsp75uKbx9+XAkbLmif3VfjOPeeo70ssCZqgwHGyxtAqEA1BDS66?= =?us-ascii?Q?5zr0dYiKqhxkiCfmTBsMZTu/CZqVvAVq/nxz0PWNrel1SA61cMvfB+vCtH9Z?= =?us-ascii?Q?UgishP6mhlzVUY4qVRIeH9fLag3ZGLld8Ct+gsyHOy4eIOnN6ltKkpmtEiSn?= =?us-ascii?Q?m4fs6pxbApFin2gZRF/IJxbFF0dnN5dmd6lQXl2u3dDjU+zk478H36pdXO04?= =?us-ascii?Q?b6jBiJJ1GjBClWuJsuUdIbSFOscGXk4NPJHj90xniQ45r1hi2ucuIt7kBYrW?= =?us-ascii?Q?M7sBNZ7Je3oFFNGsQuvqOS43+nCe5mKInfdyZ7xLO1o9dZzFPIxC27dZEKZs?= =?us-ascii?Q?9OJFydYElttwLsO/MOtwT0RI426znyPFwFWlXlpNHJNTlIw9xSsxeTchdXdL?= =?us-ascii?Q?7bsQPQQyeb4Q7q50WHI0s3SZb501MLa3qCmTeTz+Pr0HK2pNXUKPm0JwJzVg?= =?us-ascii?Q?r7yISToomKmTX2UNRiuX47stH1FS?= 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:(13230031)(376005)(36860700004)(1800799015)(82310400017);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 May 2024 07:40:49.1150 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 857a9ee6-1009-4bda-0eb6-08dc7afbaa47 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: CH1PEPF0000AD74.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB5718 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1716450083321100003 Content-Type: text/plain; charset="utf-8" There are some use cases in which the dom0less domUs need to have the XEN_DOMCTL_CDF_iommu set at the domain construction time. For example, the dynamic dtbo feature allows the domain to be assigned a device that is behind the IOMMU at runtime. For these use cases, we need to have a way to specify the domain will need the IOMMU mapping at domain construction time. Introduce a "passthrough" DT property for Dom0less DomUs following the same entry as the xl.cfg. Currently only provide two options, i.e. "enable" and "disable". Set the XEN_DOMCTL_CDF_iommu at domain construction time based on the property. Signed-off-by: Henry Wang Reviewed-by: Julien Grall --- v4: - No change. v3: - Use a separate variable to cache the condition from the "passthrough" flag separately to improve readability. - Update the doc to explain the default condition more clearly. v2: - New patch to replace the original patch in v1: "[PATCH 03/15] xen/arm: Always enable IOMMU" --- docs/misc/arm/device-tree/booting.txt | 16 ++++++++++++++++ xen/arch/arm/dom0less-build.c | 11 +++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/docs/misc/arm/device-tree/booting.txt b/docs/misc/arm/device-t= ree/booting.txt index bbd955e9c2..f1fd069c87 100644 --- a/docs/misc/arm/device-tree/booting.txt +++ b/docs/misc/arm/device-tree/booting.txt @@ -260,6 +260,22 @@ with the following properties: value specified by Xen command line parameter gnttab_max_maptrack_fram= es (or its default value if unspecified, i.e. 1024) is used. =20 +- passthrough + + A string property specifying whether IOMMU mappings are enabled for the + domain and hence whether it will be enabled for passthrough hardware. + Possible property values are: + + - "enabled" + IOMMU mappings are enabled for the domain. Note that this option is the + default if the user provides the device partial passthrough device tree + for the domain. + + - "disabled" + IOMMU mappings are disabled for the domain and so hardware may not be + passed through. This option is the default if this property is missing + and the user does not provide the device partial device tree for the d= omain. + Under the "xen,domain" compatible node, one or more sub-nodes are present for the DomU kernel and ramdisk. =20 diff --git a/xen/arch/arm/dom0less-build.c b/xen/arch/arm/dom0less-build.c index 74f053c242..5830a7051d 100644 --- a/xen/arch/arm/dom0less-build.c +++ b/xen/arch/arm/dom0less-build.c @@ -848,6 +848,8 @@ static int __init construct_domU(struct domain *d, void __init create_domUs(void) { struct dt_device_node *node; + const char *dom0less_iommu; + bool iommu =3D false; const struct dt_device_node *cpupool_node, *chosen =3D dt_find_node_by_path("/chosen"= ); =20 @@ -895,8 +897,13 @@ void __init create_domUs(void) panic("Missing property 'cpus' for domain %s\n", dt_node_name(node)); =20 - if ( dt_find_compatible_node(node, NULL, "multiboot,device-tree") = && - iommu_enabled ) + if ( !dt_property_read_string(node, "passthrough", &dom0less_iommu= ) && + !strcmp(dom0less_iommu, "enabled") ) + iommu =3D true; + + if ( iommu_enabled && + (iommu || dt_find_compatible_node(node, NULL, + "multiboot,device-tree")) ) d_cfg.flags |=3D XEN_DOMCTL_CDF_iommu; =20 if ( !dt_property_read_u32(node, "nr_spis", &d_cfg.arch.nr_spis) ) --=20 2.34.1 From nobody Fri Nov 22 13:30:37 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=1716450079; cv=pass; d=zohomail.com; s=zohoarc; b=AF92ARH2HVO4K3LKrDS3GTprxd2nlOY53z4nkR06iBGgC6zobcVf5sUMicIbfAtdZ4D/QIF6teJ8xxYmpu80tyZx0NlWE6TGXrzmSRApZ5d4+Xr5FOuZTsRLnvpwVgDYIdi1NQT+KIQNNp4hcpiDMWhP91KlygvRNb1WSpYteU0= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716450079; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=KLxhi2kA+DFIhfmJBOruoj4kiXc2RPsQrpkdr7sIoWE=; b=X0LQ32Q/28LiccXoQsbzt6+xdBiX+bjk77LmnyPmeS0ibOZy0v6AZYa5mWd9CwpZXdp1e+dhmFzVjd2MXCRw8JLX5ZNc7zJm5V2YE2l0e20J0Gt2az9CTW/9U95uEUe6LfGhJeDagVXYC6C9bN5uAxmJPas6n31OHu3etidPUJA= 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 1716450079352319.3687727437365; Thu, 23 May 2024 00:41:19 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.728096.1132889 (Exim 4.92) (envelope-from ) id 1sA34L-0002Fy-6t; Thu, 23 May 2024 07:40:57 +0000 Received: by outflank-mailman (output) from mailman id 728096.1132889; Thu, 23 May 2024 07:40:57 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sA34L-0002Fn-3n; Thu, 23 May 2024 07:40:57 +0000 Received: by outflank-mailman (input) for mailman id 728096; Thu, 23 May 2024 07:40:56 +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 1sA34K-0001WY-60 for xen-devel@lists.xenproject.org; Thu, 23 May 2024 07:40:56 +0000 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on20600.outbound.protection.outlook.com [2a01:111:f403:2415::600]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id c93c26aa-18d7-11ef-90a1-e314d9c70b13; Thu, 23 May 2024 09:40:54 +0200 (CEST) Received: from CH0PR03CA0328.namprd03.prod.outlook.com (2603:10b6:610:118::14) by PH7PR12MB6882.namprd12.prod.outlook.com (2603:10b6:510:1b8::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.22; Thu, 23 May 2024 07:40:51 +0000 Received: from CH1PEPF0000AD74.namprd04.prod.outlook.com (2603:10b6:610:118:cafe::c8) by CH0PR03CA0328.outlook.office365.com (2603:10b6:610:118::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.20 via Frontend Transport; Thu, 23 May 2024 07:40:50 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by CH1PEPF0000AD74.mail.protection.outlook.com (10.167.244.52) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7611.14 via Frontend Transport; Thu, 23 May 2024 07:40:50 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) 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.2507.35; Thu, 23 May 2024 02:40:50 -0500 Received: from henry-MS-7D54.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Thu, 23 May 2024 02:40: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: c93c26aa-18d7-11ef-90a1-e314d9c70b13 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GASANB7wRfDiBw1ZYy5MobrfNCEfRYjgsrg/RI9Os1jl+FYX8BtBBlsH2i6cm0Zx5rhfpcNYvoon0qGoYlky02pMMaAG7C7BlMh8+c2uOkoZh+fogGwJxBT18uvpXXqhqLRL/p70C75TwqHAKykez7Zzefbun15eQntzJm98y8yoT64NwCb+Am8oBuTqczJTcXXWq6T9vqHcxU1d3r/YNySJprxtD/pSXPrvfehaE7LxaZcacR/KCFCPMjiwxQabclPXi0DsOlMOrsVvmdiQ4wXVzEjAK5LZzyFiwf5RqNkIUQQMcnIWmJ/NuDA7dwWDPhR5WEtrcYh0pQkYOCg45A== 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=KLxhi2kA+DFIhfmJBOruoj4kiXc2RPsQrpkdr7sIoWE=; b=GVmSctfn71A0m1gonkGAMKOeFxZbt20ohEYTYxQCIPp1oP3L7lW8xv3S3Rm9dqRJrb6E8W/IImqt/oAlmrKTjJUShz7PAmfQcBPK2a4uz58cPPo1ifLksBODz1hmwbZ68L9l7VTGCoaYTekavu3/QGmy5cr4Ck4WxQN8Bj5R2GGDmqKh4TroRksRb3kVj78kRL+opHIleJ0Gl5uybTBZfud/tPYgkZytNeAI0BOKqM+84dSNp5h3Rh0HGEKplaRXnlJie6ZzOhKFDl5q+fv3waqRC2SAffuy9cYUPfxR9NaXIecEvL8rzQCI0sPsEbb7UOREOxv0euKyolsoSnMlPA== 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 (0) 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=KLxhi2kA+DFIhfmJBOruoj4kiXc2RPsQrpkdr7sIoWE=; b=aRguojq0DNlj0lcnHRcOhH6ezOWHKdVvcV/CDw4KPrD1YP5uaohbpDqT26/qwbSr5Jmn3St02CrnbPhrwAKjDTRO6fdGNk4DMET2i+xzmpr+Vei14dfgb4M0B+1ZVnWd2UCIQ2otTCapcJaaSRpKmRUcExijgJ0lLrwVB0oPymg= 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: Henry Wang To: CC: Anthony PERARD , George Dunlap , Nick Rosbrook , "Juergen Gross" , Henry Wang , Jason Andryuk Subject: [PATCH v4 3/9] tools/arm: Introduce the "nr_spis" xl config entry Date: Thu, 23 May 2024 15:40:34 +0800 Message-ID: <20240523074040.1611264-4-xin.wang2@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240523074040.1611264-1-xin.wang2@amd.com> References: <20240523074040.1611264-1-xin.wang2@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: None (SATLEXMB03.amd.com: xin.wang2@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000AD74:EE_|PH7PR12MB6882:EE_ X-MS-Office365-Filtering-Correlation-Id: ef06980a-a40e-4bda-512a-08dc7afbab4d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|82310400017|1800799015|376005|36860700004; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?DQVn/2bkLGWMeex8Bl0oFAwDENUj5lUQVM7JhtUDpuqti28h65sxsB0XEmcW?= =?us-ascii?Q?vu9Ll/jnDvQt2y8gPiOSDM+kqrLse/yY9l4shPu3u0tavdDdN0ny0Fovzz3P?= =?us-ascii?Q?XO4vYyEFHd4COKWGtGJIY/vXuiFIlvdNwY+etuJYDnbshwKdKr/FwHz+d79E?= =?us-ascii?Q?k0XQstTzeJhaAtOANh72wnufn7Y55/SpfRPtOIZjj8El4mAreYGQRUR2/Vuf?= =?us-ascii?Q?N9ZMG/wcoNsXu9f9Wk6JQ72EG6dy3oExY0XYaDy/U7DEZu9n0ohqtSo2+fNo?= =?us-ascii?Q?St/QUCzYNbvTWwM/xThDEUpxi5+HTv8cX0a8EvVj0XaH3MrC3qmsXfhdDo8y?= =?us-ascii?Q?JE1q48EyV6jJYwFGqEcRomaccr1wLMWOW7rycs/ZuTc5Ee22l+GOerac/fUx?= =?us-ascii?Q?rq0gm1t6eEr1ESi0x2xWji5qBG+FOqlt+cBbmaX51/QKi0TtvoMdE31nBm3/?= =?us-ascii?Q?hmHZ5xcSC4jnE+z7HRiHpgQ1wc4Dy+J7DLh+/hKpuNYGJK/hBL4ew8LcNS2Y?= =?us-ascii?Q?J16lCobsWuMKWuhorTcL8hCQiAGiKG2xp90g4ArdCTPIuB36vLrDLF8FFB3b?= =?us-ascii?Q?BLAFjECIsS8qPv7RJw9STMKErZ3tjSQGZb5t9r4KweC4dd0GNBm2vn5qNK6z?= =?us-ascii?Q?rV+hzCMqvkgDepTCbjrLzVMShw8k37hSM34lMNV2CEEadENZfUIp7OHXGsZD?= =?us-ascii?Q?l/pbGiYaj9jPOi6RGX8O8MNgIaD9/mOJyHO6okRNPAnQqEdM2qTT8Bx6Uz6O?= =?us-ascii?Q?m8Y4f9/1zpTq9BpNAqb8FZ9EGUHzNRJkKzX/B4vneUSKUkHggvr99QXjIzjS?= =?us-ascii?Q?nrYoFBiBXdf/6cdl9uFLiI5mzqNzQhzeP9RR8v7DF99eOQFHOM8j94M1JFr/?= =?us-ascii?Q?VKHscBBu1HrkYTNc0unvXPzsI7QQWu2etFHUSx7A65q1AFt395qgd2Emgo+X?= =?us-ascii?Q?Ld9cGnRBeCt2HK5dFTfI5uv+PCygWP4OPLsYH/qf5515ANqP9FTmVZVAR7N0?= =?us-ascii?Q?UVgwlScJskf9F6cavBKbnGSznmxfN1OKEiq0lg4/BuAVnKQPu7yaIEC4ycxq?= =?us-ascii?Q?8mXrXtLm2Ctrgxu01DFziwjXHpQldO7b4y3pOjSd5rVEnFd/mu5wIfG/GdIV?= =?us-ascii?Q?w7ydpqv6YMonOKAiHtMQIW/OYz8fyJm3RU8DsswCWOYUGX7sXfa74orrLJlJ?= =?us-ascii?Q?FG7yn8CcHYj32AFNJY4W59+aXgH+NSPacbLBggyQCuf59WT7a5HSP1tFH34o?= =?us-ascii?Q?D8j+W52GJqVgG0gLPR8sG14DWplVOnvaJ9oXxzknj1EM+9d+gSfsp6SpmJnW?= =?us-ascii?Q?IpRVXokmg06Iq3R09mQ+Xx8DPHYKdCe5zm26dM2Tlpvtc6S7i7dMyuhuLyhs?= =?us-ascii?Q?DqcrNmBSJiGCwkGht0ZC078NUjjs?= 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:(13230031)(82310400017)(1800799015)(376005)(36860700004);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 May 2024 07:40:50.8337 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ef06980a-a40e-4bda-512a-08dc7afbab4d 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: CH1PEPF0000AD74.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6882 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1716450081305100001 Content-Type: text/plain; charset="utf-8" Currently, the number of SPIs allocated to the domain is only configurable for Dom0less DomUs. Xen domains are supposed to be platform agnostics and therefore the numbers of SPIs for libxl guests should not be based on the hardware. Introduce a new xl config entry for Arm to provide a method for user to decide the number of SPIs. This would help to avoid bumping the `config->arch.nr_spis` in libxl everytime there is a new platform with increased SPI numbers. Update the doc and the golang bindings accordingly. Signed-off-by: Henry Wang Reviewed-by: Jason Andryuk --- v4: - Add Jason's Reviewed-by tag. v3: - Reword documentation to avoid ambiguity. v2: - New patch to replace the original patch in v1: "[PATCH 05/15] tools/libs/light: Increase nr_spi to 160" --- docs/man/xl.cfg.5.pod.in | 14 ++++++++++++++ tools/golang/xenlight/helpers.gen.go | 2 ++ tools/golang/xenlight/types.gen.go | 1 + tools/libs/light/libxl_arm.c | 4 ++-- tools/libs/light/libxl_types.idl | 1 + tools/xl/xl_parse.c | 3 +++ 6 files changed, 23 insertions(+), 2 deletions(-) diff --git a/docs/man/xl.cfg.5.pod.in b/docs/man/xl.cfg.5.pod.in index 8f2b375ce9..416d582844 100644 --- a/docs/man/xl.cfg.5.pod.in +++ b/docs/man/xl.cfg.5.pod.in @@ -3072,6 +3072,20 @@ raised. =20 =3Dback =20 +=3Dover 4 + +=3Ditem B + +An optional 32-bit integer parameter specifying the number of SPIs (Shared +Peripheral Interrupts) to allocate for the domain. If the value specified = by +the `nr_spis` parameter is smaller than the number of SPIs calculated by t= he +toolstack based on the devices allocated for the domain, or the `nr_spis` +parameter is not specified, the value calculated by the toolstack will be = used +for the domain. Otherwise, the value specified by the `nr_spis` parameter = will +be used. + +=3Dback + =3Dhead3 x86 =20 =3Dover 4 diff --git a/tools/golang/xenlight/helpers.gen.go b/tools/golang/xenlight/h= elpers.gen.go index b9cb5b33c7..fe5110474d 100644 --- a/tools/golang/xenlight/helpers.gen.go +++ b/tools/golang/xenlight/helpers.gen.go @@ -1154,6 +1154,7 @@ return fmt.Errorf("invalid union key '%v'", x.Type)} x.ArchArm.GicVersion =3D GicVersion(xc.arch_arm.gic_version) x.ArchArm.Vuart =3D VuartType(xc.arch_arm.vuart) x.ArchArm.SveVl =3D SveType(xc.arch_arm.sve_vl) +x.ArchArm.NrSpis =3D uint32(xc.arch_arm.nr_spis) if err :=3D x.ArchX86.MsrRelaxed.fromC(&xc.arch_x86.msr_relaxed);err !=3D = nil { return fmt.Errorf("converting field ArchX86.MsrRelaxed: %v", err) } @@ -1670,6 +1671,7 @@ return fmt.Errorf("invalid union key '%v'", x.Type)} xc.arch_arm.gic_version =3D C.libxl_gic_version(x.ArchArm.GicVersion) xc.arch_arm.vuart =3D C.libxl_vuart_type(x.ArchArm.Vuart) xc.arch_arm.sve_vl =3D C.libxl_sve_type(x.ArchArm.SveVl) +xc.arch_arm.nr_spis =3D C.uint32_t(x.ArchArm.NrSpis) if err :=3D x.ArchX86.MsrRelaxed.toC(&xc.arch_x86.msr_relaxed); err !=3D n= il { return fmt.Errorf("converting field ArchX86.MsrRelaxed: %v", err) } diff --git a/tools/golang/xenlight/types.gen.go b/tools/golang/xenlight/typ= es.gen.go index 5b293755d7..c9e45b306f 100644 --- a/tools/golang/xenlight/types.gen.go +++ b/tools/golang/xenlight/types.gen.go @@ -597,6 +597,7 @@ ArchArm struct { GicVersion GicVersion Vuart VuartType SveVl SveType +NrSpis uint32 } ArchX86 struct { MsrRelaxed Defbool diff --git a/tools/libs/light/libxl_arm.c b/tools/libs/light/libxl_arm.c index 1cb89fa584..a4029e3ac8 100644 --- a/tools/libs/light/libxl_arm.c +++ b/tools/libs/light/libxl_arm.c @@ -181,8 +181,8 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc, =20 LOG(DEBUG, "Configure the domain"); =20 - config->arch.nr_spis =3D nr_spis; - LOG(DEBUG, " - Allocate %u SPIs", nr_spis); + config->arch.nr_spis =3D max(nr_spis, d_config->b_info.arch_arm.nr_spi= s); + LOG(DEBUG, " - Allocate %u SPIs", config->arch.nr_spis); =20 switch (d_config->b_info.arch_arm.gic_version) { case LIBXL_GIC_VERSION_DEFAULT: diff --git a/tools/libs/light/libxl_types.idl b/tools/libs/light/libxl_type= s.idl index 79e9c656cc..4e65e6fda5 100644 --- a/tools/libs/light/libxl_types.idl +++ b/tools/libs/light/libxl_types.idl @@ -722,6 +722,7 @@ libxl_domain_build_info =3D Struct("domain_build_info",[ ("arch_arm", Struct(None, [("gic_version", libxl_gic_version), ("vuart", libxl_vuart_type), ("sve_vl", libxl_sve_type), + ("nr_spis", uint32), ])), ("arch_x86", Struct(None, [("msr_relaxed", libxl_defbool), ])), diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c index c504ab3711..e3a4800f6e 100644 --- a/tools/xl/xl_parse.c +++ b/tools/xl/xl_parse.c @@ -2935,6 +2935,9 @@ skip_usbdev: } } =20 + if (!xlu_cfg_get_long (config, "nr_spis", &l, 0)) + b_info->arch_arm.nr_spis =3D l; + parse_vkb_list(config, d_config); =20 d_config->virtios =3D NULL; --=20 2.34.1 From nobody Fri Nov 22 13:30:37 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=1716450087; cv=pass; d=zohomail.com; s=zohoarc; b=Uo5Ex8O0kMCGltVBgSz5nGMOxkvPaDNuljj3r38mtrPXF6nL1QaAPaHliliedQG0ukvUSqlSlWI0ZU087v973rOult2unJO80OM5mO2kC60I9qzFmwAPYvGv/ZqwMhHV001S5N7u7iGZW50D1zy48cHcIHAr2Ph9EUVnr2X8DBw= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716450087; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=bJ4rFJutdXy/qfPZPTvRAO+qEyMuCy4lZffUC1ijz5Y=; b=Qcz2LAVR/RBtv8DgketTKuAaiecvufrQOcg00hZqzXkTykv7UN+t9Wy6MYs9Qpitt9ND2b+N6S7SmsTGxWFZWlvX9/7hZ6eqmZQNBlxJI6zLzFPAVcuLTLE/ueoBpnQWnmIqLkXClAQYwGH/s0Y6E8Ruovzf2ZIUv0UgQiEFF2I= 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 1716450087453774.451357196505; Thu, 23 May 2024 00:41:27 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.728097.1132900 (Exim 4.92) (envelope-from ) id 1sA34P-0002aR-Ht; Thu, 23 May 2024 07:41:01 +0000 Received: by outflank-mailman (output) from mailman id 728097.1132900; Thu, 23 May 2024 07:41:01 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sA34P-0002a2-EB; Thu, 23 May 2024 07:41:01 +0000 Received: by outflank-mailman (input) for mailman id 728097; Thu, 23 May 2024 07:40:59 +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 1sA34N-0001WY-GQ for xen-devel@lists.xenproject.org; Thu, 23 May 2024 07:40:59 +0000 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on20600.outbound.protection.outlook.com [2a01:111:f403:2415::600]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id cb2aae42-18d7-11ef-90a1-e314d9c70b13; Thu, 23 May 2024 09:40:58 +0200 (CEST) Received: from MW4PR03CA0214.namprd03.prod.outlook.com (2603:10b6:303:b9::9) by BL3PR12MB6643.namprd12.prod.outlook.com (2603:10b6:208:38f::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.22; Thu, 23 May 2024 07:40:54 +0000 Received: from CO1PEPF000066ED.namprd05.prod.outlook.com (2603:10b6:303:b9:cafe::2f) by MW4PR03CA0214.outlook.office365.com (2603:10b6:303:b9::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.36 via Frontend Transport; Thu, 23 May 2024 07:40:54 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1PEPF000066ED.mail.protection.outlook.com (10.167.249.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7611.14 via Frontend Transport; Thu, 23 May 2024 07:40:53 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 23 May 2024 02:40:52 -0500 Received: from henry-MS-7D54.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Thu, 23 May 2024 02:40:50 -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: cb2aae42-18d7-11ef-90a1-e314d9c70b13 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BAjQNZm/ATs7jCaRlEhbS7Nw5C78kdhdWkKY+KmIhV0cX4NtiF4QPSxtc/Xt1IlVT1SuyzkvX7TGHzG53LrMNaaViHLRUpU0mlKeP7YbF6oj22yNuCYk3lVoSdcdbB1AapQAuNQTXK179rfvCPqaErhQEprirOG/RWw6HohNeA1MK0p9q2wTIh13kGu5rRM05QlhqM+jIULWq/lfgO+lQJKhdiGClRpc95ExraEtCE28rf60mUBprBpGB0/ib1wEF6Qu/onkct1rtdSHwbf5ZAlEAzB4ukVqTs5VLUYvFQmfTVcV7Mw/UEx4SHxtfFFztdAnxPfyStUCdWvz0Q3eyA== 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=bJ4rFJutdXy/qfPZPTvRAO+qEyMuCy4lZffUC1ijz5Y=; b=TXoLpKg7Xbd+z/nzO7Ngb4nWAkG/qN4DWA0a215/cp+RLLFtwSTWOMnYRjjIx4GuM+azFIJGNW5IEXZiCmDyClIZpHUgyxn4mkfOcTZhV+DksfkBZujGbr+t4QBogaGdN8QNUFKoBUlHd51bIpQY0ZbDDqWuPovPzSkC1jff6RVAJvD4zyeCbo9nm+Rb4SSWA+V/Cch8/6tz8Fo7xYjH09ytMKx3Iq2+9gVEHj5I93gEwvMJLoYBYFRcAS4in+toRkm2x8DkypnNCEheX8qvdNJ9u7Q0+5SYuOACBBDtgQYPQXjZvxl5y4lpI7AniOGneFgaE9NiFpwtVJGydDuyBw== 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 (0) 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=bJ4rFJutdXy/qfPZPTvRAO+qEyMuCy4lZffUC1ijz5Y=; b=uiXBZP2Tg6MRcvKJnEBlCwVRNe4gcODnm8nXD4nDZveMFnwiD38u0jS3p83CTVGJABLAbe0NGgAe5N8JAGF3SQ/JduAOVXvoxK2GIWQLsqhE3LF0IxATU7Hr0DNE4Bc7kozfff1biJeCyYebL5xv28ReFbBjK+8QdJL24u7lCXw= 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=SATLEXMB04.amd.com; pr=C From: Henry Wang To: CC: Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk , "Henry Wang" Subject: [PATCH v4 4/9] xen/arm/gic: Allow adding interrupt to running VMs Date: Thu, 23 May 2024 15:40:35 +0800 Message-ID: <20240523074040.1611264-5-xin.wang2@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240523074040.1611264-1-xin.wang2@amd.com> References: <20240523074040.1611264-1-xin.wang2@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: None (SATLEXMB04.amd.com: xin.wang2@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000066ED:EE_|BL3PR12MB6643:EE_ X-MS-Office365-Filtering-Correlation-Id: 7161e61b-6859-4b92-08d0-08dc7afbace7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|82310400017|36860700004|376005; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?LYeGWke6n4bX49lwvxP85Ozwipg4qx2/aH0d7Un85TTkALAGeAp4Uj5QfGTD?= =?us-ascii?Q?BfXAIfeb2c8gHu8XC7YPqQ9qZG8KX/EawG9bDJQMLgqZ4KPkKPappLluKt5C?= =?us-ascii?Q?AgerW39/7TUGf8t5Y+fXeV4VXQQO5/JZSIFm25T/Y/ucrZF38YVNdMNkuLZe?= =?us-ascii?Q?gOov3WIXNDTblsPBoPfD6d/2eO6jgSjacGhALoZF3TX9v9xc5AFInBXp4Zj8?= =?us-ascii?Q?GJDwdGBm+uqYi6CcZU9KhKWpTo6hevZ9GTpBe4Tuge42MuyNTlyueZ9TEmYO?= =?us-ascii?Q?iYkGzRLajFg6Bh8G/Yszul9MU7U8Bi0H0tdnCZEsGg9oxpWHlsJK4DzKzOPq?= =?us-ascii?Q?7vm/S1HchCdNgZRrZMsCUHtdU5AicYbqGSLNia8F+xpd3VWvXMlAQijetkmv?= =?us-ascii?Q?YunXb5pXNH6uGgnNEU7T7jcc65xyIg0m3YyKiDHwgAbLTNDkEkEG9PHjRHjR?= =?us-ascii?Q?9wazh9bVULpB5nhlKkZEk5WZ51hHO/QkLrpLAGzXavYS/SbxjcT1mrpydE/1?= =?us-ascii?Q?EDM5Xx1fkOj1qPbF69+KqWGGShYaPH8s8BdNydApGnL5ntdnAPA4fH1Npe7K?= =?us-ascii?Q?LXGQvAlgTMZuOWzvpcIZn5GW1OzR0NP71FOYZgzp21ZDUDM9JODeHjofqkhm?= =?us-ascii?Q?UnHit6AYprwRXKvVz25deIdjPh1gMWndRMPwY77O5P4BdiHg1dpfXxWJ55O4?= =?us-ascii?Q?npal4ZNXr6odCKF9ZMzLtSGOMaha28QZ0eQgeQzldViIUypkwGffNrMbYmka?= =?us-ascii?Q?zvHqjnjgLclZna94RcdqD6UUOp+utj6igelleEyeynOz6qwVy0uoJeWd9Txc?= =?us-ascii?Q?KDAzY0onyLS4eOF3M9qpYHTFBCYaeBe2Y7FIOlOeSyEk/trjOJ78tNjJbkbZ?= =?us-ascii?Q?tpJ85VDvnk+QV6Zl1gJgtpjnpHRg8XzjW9rcmy6YD4DEZuXRQZ8CfEl5JbRb?= =?us-ascii?Q?nCiRH9ri3kjhcfmzXyBj6blllFFKlBe5Hh0lumyVJMFZ/+RFb87FNs0r2qcD?= =?us-ascii?Q?oV5r6FFjPKfI4mt6ZZGFUVw5oh3SWKahKKc0pRbyk1YIsgTWuJ6R6nbrNGb/?= =?us-ascii?Q?Oz3RC7GeMjRjewoHrCqzbgi7JhFI/vFVszGqgEfZ+64BymI2ET0nnui8bLKo?= =?us-ascii?Q?hML2YMb7Vq1mvqvUa4X0+AGeR70eZqM7pi0ANYWxF8DJ4Zmjg93W2/RsLlwW?= =?us-ascii?Q?xG5qNhAqTiCstsqIiIkrMjDFc5BvuSDfZ9i6cgMTPg4Mj7ClG/wPJHGRJISK?= =?us-ascii?Q?OVylkfwkqk1hud1MsyWXnAYvYqhn6eoIbds+e75u4aW4VWwIylncgJpH9sii?= =?us-ascii?Q?L4qerWCg1U2NjuMY2nkFg3UaWqate6R1U90Idcib8KwhocfbFjzFzCCs2LcM?= =?us-ascii?Q?zxpfzHbbPSX1KkPmpZYCjuDtb0Kl?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(1800799015)(82310400017)(36860700004)(376005);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 May 2024 07:40:53.4407 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7161e61b-6859-4b92-08d0-08dc7afbace7 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000066ED.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR12MB6643 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1716450089264100001 Content-Type: text/plain; charset="utf-8" Currently, adding physical interrupts are only allowed at the domain creation time. For use cases such as dynamic device tree overlay addition, the adding of physical IRQ to running domains should be allowed. Drop the above-mentioned domain creation check. Since this will introduce interrupt state unsync issues for cases when the interrupt is active or pending in the guest, therefore for these cases we simply reject the operation. Do it for both new and old vGIC implementations. Signed-off-by: Henry Wang Reviewed-by: Julien Grall --- v4: - Split the original patch, only do the adding IRQ stuff in this patch. v3: - Update in-code comments. - Correct the if conditions. - Add taking/releasing the vgic lock of the vcpu. v2: - Reject the case where the IRQ is active or pending in guest. --- xen/arch/arm/gic-vgic.c | 9 +++++++-- xen/arch/arm/gic.c | 8 -------- xen/arch/arm/vgic/vgic.c | 7 +++++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/xen/arch/arm/gic-vgic.c b/xen/arch/arm/gic-vgic.c index 56490dbc43..b99e287224 100644 --- a/xen/arch/arm/gic-vgic.c +++ b/xen/arch/arm/gic-vgic.c @@ -442,9 +442,14 @@ int vgic_connect_hw_irq(struct domain *d, struct vcpu = *v, unsigned int virq, =20 if ( connect ) { - /* The VIRQ should not be already enabled by the guest */ + /* + * The VIRQ should not be already enabled by the guest nor + * active/pending in the guest. + */ if ( !p->desc && - !test_bit(GIC_IRQ_GUEST_ENABLED, &p->status) ) + !test_bit(GIC_IRQ_GUEST_ENABLED, &p->status) && + !test_bit(GIC_IRQ_GUEST_VISIBLE, &p->status) && + !test_bit(GIC_IRQ_GUEST_ACTIVE, &p->status) ) p->desc =3D desc; else ret =3D -EBUSY; diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c index 44c40e86de..b3467a76ae 100644 --- a/xen/arch/arm/gic.c +++ b/xen/arch/arm/gic.c @@ -135,14 +135,6 @@ int gic_route_irq_to_guest(struct domain *d, unsigned = int virq, ASSERT(virq < vgic_num_irqs(d)); ASSERT(!is_lpi(virq)); =20 - /* - * When routing an IRQ to guest, the virtual state is not synced - * back to the physical IRQ. To prevent get unsync, restrict the - * routing to when the Domain is been created. - */ - if ( d->creation_finished ) - return -EBUSY; - ret =3D vgic_connect_hw_irq(d, NULL, virq, desc, true); if ( ret ) return ret; diff --git a/xen/arch/arm/vgic/vgic.c b/xen/arch/arm/vgic/vgic.c index b9463a5f27..048e12c562 100644 --- a/xen/arch/arm/vgic/vgic.c +++ b/xen/arch/arm/vgic/vgic.c @@ -876,8 +876,11 @@ int vgic_connect_hw_irq(struct domain *d, struct vcpu = *vcpu, =20 if ( connect ) /* assign a mapped IRQ */ { - /* The VIRQ should not be already enabled by the guest */ - if ( !irq->hw && !irq->enabled ) + /* + * The VIRQ should not be already enabled by the guest nor + * active/pending in the guest + */ + if ( !irq->hw && !irq->enabled && !irq->active && !irq->pending_la= tch ) { irq->hw =3D true; irq->hwintid =3D desc->irq; --=20 2.34.1 From nobody Fri Nov 22 13:30:37 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=1716450085; cv=pass; d=zohomail.com; s=zohoarc; b=lTbzsT5wgXs3xeuI5ltiTYYgIiUBbZpihRFQncbCtIGSFRj5EKm8TaGhdkQs0P1TcFArcZuFWpnq1U94+R8Km5Oat1p6n2eg67E/mp90kBZAhpG8ne73JywaZ34C/+2fnv6qdFDAswixMn+qO356+i2ukGn87r8KZrz8wuzNIgg= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716450085; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=6cGqHcXBoZTzyZBk/4TEkkSbTo+NOg9YMZd/62zSuww=; b=lI0bP/a87/cS2IhEAsN5l9ZnnnUhagSEVrfcPzBflPZSwBiPLQZT/X2fDU4r5t5O27eScA+dWu5wVTg2ZY/2RohoWDVZIOD0WMzqHtwsV4YtCSp4WWfFnaPJeWAmQYKuYpkkoqTISRjHogXFO7EycbFCiqK4Xo3yCx5+ygZvrCY= 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 1716450085175166.5959741863926; Thu, 23 May 2024 00:41:25 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.728098.1132910 (Exim 4.92) (envelope-from ) id 1sA34R-0002tB-Ro; Thu, 23 May 2024 07:41:03 +0000 Received: by outflank-mailman (output) from mailman id 728098.1132910; Thu, 23 May 2024 07:41:03 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sA34R-0002sv-Mm; Thu, 23 May 2024 07:41:03 +0000 Received: by outflank-mailman (input) for mailman id 728098; Thu, 23 May 2024 07:41:01 +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 1sA34P-0001WY-GT for xen-devel@lists.xenproject.org; Thu, 23 May 2024 07:41:01 +0000 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on20601.outbound.protection.outlook.com [2a01:111:f403:2412::601]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id cbe9361c-18d7-11ef-90a1-e314d9c70b13; Thu, 23 May 2024 09:41:00 +0200 (CEST) Received: from SJ0PR03CA0271.namprd03.prod.outlook.com (2603:10b6:a03:39e::6) by CY5PR12MB6059.namprd12.prod.outlook.com (2603:10b6:930:2c::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.19; Thu, 23 May 2024 07:40:57 +0000 Received: from CO1PEPF000066E7.namprd05.prod.outlook.com (2603:10b6:a03:39e:cafe::7) by SJ0PR03CA0271.outlook.office365.com (2603:10b6:a03:39e::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.55 via Frontend Transport; Thu, 23 May 2024 07:40:56 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1PEPF000066E7.mail.protection.outlook.com (10.167.249.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7611.14 via Frontend Transport; Thu, 23 May 2024 07:40:56 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 23 May 2024 02:40:55 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 23 May 2024 02:40:55 -0500 Received: from henry-MS-7D54.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Thu, 23 May 2024 02:40:52 -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: cbe9361c-18d7-11ef-90a1-e314d9c70b13 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YgKPuDp7h7POl4wtY17dpSFPp8a6+4Lys+iwRMefruh2Udblq2blnNdDZi2gOiLTJUITY4Pt30iHICpvdu/IY45SLJxaonu2k56Nvtlcc2zkyH4fR7+F2SV2lm4pu1iQ0bAGDkbYbLp4KQCBL2pBRKC1MQ5j/hbMnaJX9OZivvlyyD4QIwrRKYg6VdSW624ucIJCCvaQ/E3Nfq2O/sIBjAebwwvhlXO/YjW+3HO4zenxkD3pN7vnBlXlyGeHyhY4jntT/HSyH9K2I1VT6bF4Dja1tXBj2pVOYYqvghCUZFXvc6doUtbVK3InJ7Xi7NdyaJ8M+146exxfVDx/GcgcJg== 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=6cGqHcXBoZTzyZBk/4TEkkSbTo+NOg9YMZd/62zSuww=; b=RBlHBzNTiHNVbAyJR/b4bLst0YADu4Ycino6UouZKWc+a32S6KnktaRy+HkL+wBuyLkQU44MdC0YXbpn7Jw0hhz5RBhs2zuzrZI2cG1blozJcZr0Te6yqw/3NUIk8vEP6mfpJDQUyjbmzrQVrYCjFWyG8HtgyVYH6hhhwJd5in2zvU+1ZwGbtZQy5DH0nrQFOYrLhPWJzzaVIoY+hTyn4DPYtcC+q3/WJdymv1+D9XHU9yos9RfxvUXiXUJ9EnRYOt+jPBCgqv5LA92mAWzhfLDk4+IPAGy8m8iJCZl1sdw7xKVUdCcSZ+hdT3DiK7To42ANjoRCkoDkvuYN1jiujA== 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 (0) 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=6cGqHcXBoZTzyZBk/4TEkkSbTo+NOg9YMZd/62zSuww=; b=xJskQFAZddZKAwcQxfx5spyajeQxOAUZ5CLC36EHTuG3H+tvT9g5A8R8BMNF7673A55ScT+DapVPdqY95hX84GlS1FcxFOdX3tbmIETcnb91ATT50UnPRkfKbGn9joKxDy/hbTtNDfXEw8PRM3KHl+ZS/DKxxHpZ1QwpgcJyPo4= 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=SATLEXMB04.amd.com; pr=C From: Henry Wang To: CC: Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk , Andrew Cooper , George Dunlap , Jan Beulich , Henry Wang Subject: [PATCH v4 5/9] xen/arm: Add XEN_DOMCTL_dt_overlay and device attachment to domains Date: Thu, 23 May 2024 15:40:36 +0800 Message-ID: <20240523074040.1611264-6-xin.wang2@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240523074040.1611264-1-xin.wang2@amd.com> References: <20240523074040.1611264-1-xin.wang2@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: None (SATLEXMB05.amd.com: xin.wang2@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000066E7:EE_|CY5PR12MB6059:EE_ X-MS-Office365-Filtering-Correlation-Id: 45c5f866-43a4-4ba9-97dc-08dc7afbaeb7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|36860700004|376005|82310400017|1800799015; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?lecmbsste4sgjSXM7CrLlaewWO9a0Gm4oDdXUun5hp1CNdD9qi9oXY/NcOhP?= =?us-ascii?Q?b5Aoly6URh3mwihLbtCIQmfwlpGGROZiV8qVCm01V9KDF/+8IjJGjGuDuecS?= =?us-ascii?Q?7+hLjf+xuKlOO7yj3eP4wMqgb3LxaR6j0JVSUO9bPa33vfjWa8zmS9E7pcrB?= =?us-ascii?Q?U0NY0a+0yXVsvVRR996oR0rCUp6Pky9x7oc7S6JkZfplifNdNbxdEz6zMt+D?= =?us-ascii?Q?/7gJg2cNkFXmGsHsp4NYq4Ji3Oa37H5Bb7Y3dfBh/dWjPt2Yl393SUZSoIyW?= =?us-ascii?Q?4MHU3Wz3lgvseYlLVizKeNWGdM2nUTgsBcxrGVlEuiywpIXShYZdoG+6qZxv?= =?us-ascii?Q?4FJwADCHHz7ofWzVDnbxcVg7iFcoabqASPITLiWwvkIWCARk9yk3VEJVNPjY?= =?us-ascii?Q?6Ne3w2KWdHvXswNje9US0aKIVjGcqigM0vM+mZyydpKzKBgRyMKyvmgl+zID?= =?us-ascii?Q?OpuarVZ8GHxTPn1nGtZwG5qDsWjVPbRoLy6wZQkrbwq+z1zOSzDWink23W28?= =?us-ascii?Q?Nu2Uy3Vzgw9FCxDMDwkazl9GbGzrdD+5WP0VslJB4osAP7/n99Y5m3EzIkqY?= =?us-ascii?Q?DAmCADFh1Qmzus9qwR7fwU5zDpYtC3s7MsEESyArq7eRLxQ5OKd7pq4jYq0I?= =?us-ascii?Q?/ZLKCz/y0FQMqiLxhDEqDqWzt1YDp/v0CHQp45NTDPBHLxCATlpKeki+QaId?= =?us-ascii?Q?ppgMBCQjKFeD2Rgel67RJyB6XRUALiud4f9ZrBIEkA6Zb1OdeSPcyomr03X1?= =?us-ascii?Q?9fD+Q3PuoIfi4W3GBVVIy14CYL+F1a1CCMjXVlTLLH4O0mQ3hR2FWerjAW+c?= =?us-ascii?Q?UkfFGyNQ0gNwPR6H/wIU9FBuLJ8p9C0wk6n8OXiPb5HpAXBUBEAdKcD4EmM6?= =?us-ascii?Q?lAAEpiiUTsIApv3jwBYeqtRT+04Yxj1ahBd3LJERH7yrzNs8rRYOG4hSzSZl?= =?us-ascii?Q?TwousILBfu/w9gmMuKmpQTPgvB3Lj6pEJI0USgDcDNs6j2ce2oFZ9/GcYotp?= =?us-ascii?Q?o3HG9ZIdMkL7zBnuFj1O8YwSw3LL7ok9Baq7HfOMcKCth25XCp/AaKMStMpj?= =?us-ascii?Q?HWKLF66fPgmw2alA+ng3GbgHuqpfIu3w/SKoJmk6QkNPaR1FWYGxNqBJHyIZ?= =?us-ascii?Q?Q7yH/2KFiG9RxgzvWa0NU2gZY27kgBzjjcHxv6sj9rFcJmro2GuyZ5I4cjtL?= =?us-ascii?Q?vOmqcZOam3DKCPRPD6cDMy3DBHqh7BeVLu5NkbdS+xy3q0Ogc5jJqnkBdpi4?= =?us-ascii?Q?y3ZsqzuQBa1P1JQVxoLWdwsNBqmhk027kiIZ+Iife+WUP2fOe3jGp+/QzM00?= =?us-ascii?Q?zk1pr49lswhj/DBugS9kIiAglfKOthZRkcgQoLCQ9ik3NLZht1itzJ7XNvbQ?= =?us-ascii?Q?Delnns7ksV2btW6C7aA4UHlTjAUd?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(36860700004)(376005)(82310400017)(1800799015);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 May 2024 07:40:56.4696 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 45c5f866-43a4-4ba9-97dc-08dc7afbaeb7 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000066E7.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6059 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1716450099243100004 Content-Type: text/plain; charset="utf-8" In order to support the dynamic dtbo device assignment to a running VM, the add/remove of the DT overlay and the attach/detach of the device from the DT overlay should happen separately. Therefore, repurpose the existing XEN_SYSCTL_dt_overlay to only add the DT overlay to Xen device tree, instead of assigning the device to the hardware domain at the same time. Add the XEN_DOMCTL_dt_overlay with operations XEN_DOMCTL_DT_OVERLAY_ATTACH to do the device assignment to the domain. The hypervisor firstly checks the DT overlay passed from the toolstack is valid. Then the device nodes are retrieved from the overlay tracker based on the DT overlay. The attach of the device is implemented by mapping the IRQ and IOMMU resources. Signed-off-by: Henry Wang Signed-off-by: Vikram Garhwal --- v4: - Split the original patch, only do the device attachment. v3: - Style fixes for arch-selection #ifdefs. - Do not include public/domctl.h, only add a forward declaration of struct xen_domctl_dt_overlay. - Extract the overlay track entry finding logic to a function, drop the unused variables. - Use op code 1&2 for XEN_DOMCTL_DT_OVERLAY_{ATTACH,DETACH}. v2: - New patch. --- xen/arch/arm/domctl.c | 3 + xen/common/dt-overlay.c | 199 ++++++++++++++++++++++++++--------- xen/include/public/domctl.h | 14 +++ xen/include/public/sysctl.h | 11 +- xen/include/xen/dt-overlay.h | 7 ++ 5 files changed, 176 insertions(+), 58 deletions(-) diff --git a/xen/arch/arm/domctl.c b/xen/arch/arm/domctl.c index ad56efb0f5..12a12ee781 100644 --- a/xen/arch/arm/domctl.c +++ b/xen/arch/arm/domctl.c @@ -5,6 +5,7 @@ * Copyright (c) 2012, Citrix Systems */ =20 +#include #include #include #include @@ -176,6 +177,8 @@ long arch_do_domctl(struct xen_domctl *domctl, struct d= omain *d, =20 return rc; } + case XEN_DOMCTL_dt_overlay: + return dt_overlay_domctl(d, &domctl->u.dt_overlay); default: return subarch_do_domctl(domctl, d, u_domctl); } diff --git a/xen/common/dt-overlay.c b/xen/common/dt-overlay.c index 9cece79067..1087f9b502 100644 --- a/xen/common/dt-overlay.c +++ b/xen/common/dt-overlay.c @@ -356,6 +356,42 @@ static int overlay_get_nodes_info(const void *fdto, ch= ar **nodes_full_path) return 0; } =20 +/* This function should be called with the overlay_lock taken */ +static struct overlay_track * +find_track_entry_from_tracker(const void *overlay_fdt, + uint32_t overlay_fdt_size) +{ + struct overlay_track *entry, *temp; + bool found_entry =3D false; + + ASSERT(spin_is_locked(&overlay_lock)); + + /* + * First check if dtbo is correct i.e. it should one of the dtbo which= was + * used when dynamically adding the node. + * Limitation: Cases with same node names but different property are n= ot + * supported currently. We are relying on user to provide the same dtbo + * as it was used when adding the nodes. + */ + list_for_each_entry_safe( entry, temp, &overlay_tracker, entry ) + { + if ( memcmp(entry->overlay_fdt, overlay_fdt, overlay_fdt_size) =3D= =3D 0 ) + { + found_entry =3D true; + break; + } + } + + if ( !found_entry ) + { + printk(XENLOG_ERR "Cannot find any matching tracker with input dtb= o." + " Operation is supported only for prior added dtbo.\n"); + return NULL; + } + + return entry; +} + /* Check if node itself can be removed and remove node from IOMMU. */ static int remove_node_resources(struct dt_device_node *device_node) { @@ -485,8 +521,7 @@ static long handle_remove_overlay_nodes(const void *ove= rlay_fdt, uint32_t overlay_fdt_size) { int rc; - struct overlay_track *entry, *temp, *track; - bool found_entry =3D false; + struct overlay_track *entry; =20 rc =3D check_overlay_fdt(overlay_fdt, overlay_fdt_size); if ( rc ) @@ -494,29 +529,10 @@ static long handle_remove_overlay_nodes(const void *o= verlay_fdt, =20 spin_lock(&overlay_lock); =20 - /* - * First check if dtbo is correct i.e. it should one of the dtbo which= was - * used when dynamically adding the node. - * Limitation: Cases with same node names but different property are n= ot - * supported currently. We are relying on user to provide the same dtbo - * as it was used when adding the nodes. - */ - list_for_each_entry_safe( entry, temp, &overlay_tracker, entry ) - { - if ( memcmp(entry->overlay_fdt, overlay_fdt, overlay_fdt_size) =3D= =3D 0 ) - { - track =3D entry; - found_entry =3D true; - break; - } - } - - if ( !found_entry ) + entry =3D find_track_entry_from_tracker(overlay_fdt, overlay_fdt_size); + if ( entry =3D=3D NULL ) { rc =3D -EINVAL; - - printk(XENLOG_ERR "Cannot find any matching tracker with input dtb= o." - " Removing nodes is supported only for prior added dtbo.\n"= ); goto out; =20 } @@ -620,15 +636,7 @@ static long add_nodes(struct overlay_track *tr, char *= *nodes_full_path) return -EFAULT; } =20 - rc =3D handle_device(hardware_domain, overlay_node, p2m_mmio_direc= t_c, - tr->iomem_ranges, - tr->irq_ranges); write_unlock(&dt_host_lock); - if ( rc ) - { - printk(XENLOG_ERR "Adding IRQ and IOMMU failed\n"); - return rc; - } =20 /* Keep overlay_node address in tracker. */ tr->nodes_address[j] =3D (unsigned long)overlay_node; @@ -638,9 +646,7 @@ static long add_nodes(struct overlay_track *tr, char **= nodes_full_path) } /* * Adds device tree nodes under target node. - * We use tr->dt_host_new to unflatten the updated device_tree_flattened. = This - * is done to avoid the removal of device_tree generation, iomem regions m= apping - * to hardware domain done by handle_node(). + * We use tr->dt_host_new to unflatten the updated device_tree_flattened. */ static long handle_add_overlay_nodes(void *overlay_fdt, uint32_t overlay_fdt_size) @@ -774,20 +780,6 @@ static long handle_add_overlay_nodes(void *overlay_fdt, goto err; } =20 - tr->irq_ranges =3D rangeset_new(hardware_domain, "Overlays: Interrupts= ", 0); - if (tr->irq_ranges =3D=3D NULL) - { - printk(XENLOG_ERR "Creating IRQ rangeset failed"); - goto err; - } - - tr->iomem_ranges =3D rangeset_new(hardware_domain, "Overlay: I/O Memor= y", 0); - if (tr->iomem_ranges =3D=3D NULL) - { - printk(XENLOG_ERR "Creating IOMMU rangeset failed"); - goto err; - } - rc =3D add_nodes(tr, nodes_full_path); if ( rc ) { @@ -843,14 +835,83 @@ static long handle_add_overlay_nodes(void *overlay_fd= t, xfree(tr->nodes_address); xfree(tr->fdt); =20 - rangeset_destroy(tr->irq_ranges); - rangeset_destroy(tr->iomem_ranges); - xfree(tr); =20 return rc; } =20 +static long handle_attach_overlay_nodes(struct domain *d, + const void *overlay_fdt, + uint32_t overlay_fdt_size) +{ + int rc; + unsigned int j; + struct overlay_track *entry; + + rc =3D check_overlay_fdt(overlay_fdt, overlay_fdt_size); + if ( rc ) + return rc; + + spin_lock(&overlay_lock); + + entry =3D find_track_entry_from_tracker(overlay_fdt, overlay_fdt_size); + if ( entry =3D=3D NULL ) + { + rc =3D -EINVAL; + goto out; + } + + entry->irq_ranges =3D rangeset_new(d, "Overlays: Interrupts", 0); + if (entry->irq_ranges =3D=3D NULL) + { + rc =3D -ENOMEM; + printk(XENLOG_ERR "Creating IRQ rangeset failed"); + goto out; + } + + entry->iomem_ranges =3D rangeset_new(d, "Overlay: I/O Memory", 0); + if (entry->iomem_ranges =3D=3D NULL) + { + rc =3D -ENOMEM; + printk(XENLOG_ERR "Creating IOMMU rangeset failed"); + goto out; + } + + for ( j =3D 0; j < entry->num_nodes; j++ ) + { + struct dt_device_node *overlay_node; + + overlay_node =3D (struct dt_device_node *)entry->nodes_address[j]; + if ( overlay_node =3D=3D NULL ) + { + rc =3D -EINVAL; + goto out; + } + + write_lock(&dt_host_lock); + rc =3D handle_device(d, overlay_node, p2m_mmio_direct_c, + entry->iomem_ranges, entry->irq_ranges); + write_unlock(&dt_host_lock); + if ( rc ) + { + printk(XENLOG_ERR "Adding IRQ and IOMMU failed\n"); + goto out; + } + } + + spin_unlock(&overlay_lock); + + return 0; + + out: + spin_unlock(&overlay_lock); + + rangeset_destroy(entry->irq_ranges); + rangeset_destroy(entry->iomem_ranges); + + return rc; +} + long dt_overlay_sysctl(struct xen_sysctl_dt_overlay *op) { long ret; @@ -890,6 +951,42 @@ long dt_overlay_sysctl(struct xen_sysctl_dt_overlay *o= p) return ret; } =20 +long dt_overlay_domctl(struct domain *d, struct xen_domctl_dt_overlay *op) +{ + long ret; + void *overlay_fdt; + + if ( op->overlay_op !=3D XEN_DOMCTL_DT_OVERLAY_ATTACH ) + return -EOPNOTSUPP; + + if ( op->overlay_fdt_size =3D=3D 0 || op->overlay_fdt_size > KB(500) ) + return -EINVAL; + + if ( op->pad[0] || op->pad[1] || op->pad[2] ) + return -EINVAL; + + overlay_fdt =3D xmalloc_bytes(op->overlay_fdt_size); + + if ( overlay_fdt =3D=3D NULL ) + return -ENOMEM; + + ret =3D copy_from_guest(overlay_fdt, op->overlay_fdt, op->overlay_fdt_= size); + if ( ret ) + { + gprintk(XENLOG_ERR, "copy from guest failed\n"); + xfree(overlay_fdt); + + return -EFAULT; + } + + if ( op->overlay_op =3D=3D XEN_DOMCTL_DT_OVERLAY_ATTACH ) + ret =3D handle_attach_overlay_nodes(d, overlay_fdt, op->overlay_fd= t_size); + + xfree(overlay_fdt); + + return ret; +} + /* * Local variables: * mode: C diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h index a33f9ec32b..ac3c2a7c4c 100644 --- a/xen/include/public/domctl.h +++ b/xen/include/public/domctl.h @@ -1190,6 +1190,16 @@ struct xen_domctl_vmtrace_op { typedef struct xen_domctl_vmtrace_op xen_domctl_vmtrace_op_t; DEFINE_XEN_GUEST_HANDLE(xen_domctl_vmtrace_op_t); =20 +#if defined(__arm__) || defined(__aarch64__) +struct xen_domctl_dt_overlay { + XEN_GUEST_HANDLE_64(const_void) overlay_fdt; /* IN: overlay fdt. */ + uint32_t overlay_fdt_size; /* IN: Overlay dtb size. */ +#define XEN_DOMCTL_DT_OVERLAY_ATTACH 1 + uint8_t overlay_op; /* IN: Attach. */ + uint8_t pad[3]; /* IN: Must be zero. */ +}; +#endif + struct xen_domctl { uint32_t cmd; #define XEN_DOMCTL_createdomain 1 @@ -1277,6 +1287,7 @@ struct xen_domctl { #define XEN_DOMCTL_vmtrace_op 84 #define XEN_DOMCTL_get_paging_mempool_size 85 #define XEN_DOMCTL_set_paging_mempool_size 86 +#define XEN_DOMCTL_dt_overlay 87 #define XEN_DOMCTL_gdbsx_guestmemio 1000 #define XEN_DOMCTL_gdbsx_pausevcpu 1001 #define XEN_DOMCTL_gdbsx_unpausevcpu 1002 @@ -1339,6 +1350,9 @@ struct xen_domctl { struct xen_domctl_vuart_op vuart_op; struct xen_domctl_vmtrace_op vmtrace_op; struct xen_domctl_paging_mempool paging_mempool; +#if defined(__arm__) || defined(__aarch64__) + struct xen_domctl_dt_overlay dt_overlay; +#endif uint8_t pad[128]; } u; }; diff --git a/xen/include/public/sysctl.h b/xen/include/public/sysctl.h index febaa4b16a..3a6e7d48f0 100644 --- a/xen/include/public/sysctl.h +++ b/xen/include/public/sysctl.h @@ -1184,14 +1184,11 @@ typedef struct xen_sysctl_cpu_policy xen_sysctl_cpu= _policy_t; DEFINE_XEN_GUEST_HANDLE(xen_sysctl_cpu_policy_t); #endif =20 -#if defined(__arm__) || defined (__aarch64__) +#if defined(__arm__) || defined(__aarch64__) /* * XEN_SYSCTL_dt_overlay - * Performs addition/removal of device tree nodes under parent node using = dtbo. - * This does in three steps: - * - Adds/Removes the nodes from dt_host. - * - Adds/Removes IRQ permission for the nodes. - * - Adds/Removes MMIO accesses. + * Performs addition/removal of device tree nodes under parent node using = dtbo + * from dt_host. */ struct xen_sysctl_dt_overlay { XEN_GUEST_HANDLE_64(const_void) overlay_fdt; /* IN: overlay fdt. */ @@ -1265,7 +1262,7 @@ struct xen_sysctl { struct xen_sysctl_cpu_policy cpu_policy; #endif =20 -#if defined(__arm__) || defined (__aarch64__) +#if defined(__arm__) || defined(__aarch64__) struct xen_sysctl_dt_overlay dt_overlay; #endif uint8_t pad[128]; diff --git a/xen/include/xen/dt-overlay.h b/xen/include/xen/dt-overlay.h index c0567741ee..7f0f3741b5 100644 --- a/xen/include/xen/dt-overlay.h +++ b/xen/include/xen/dt-overlay.h @@ -39,15 +39,22 @@ struct overlay_track { }; =20 struct xen_sysctl_dt_overlay; +struct xen_domctl_dt_overlay; =20 #ifdef CONFIG_OVERLAY_DTB long dt_overlay_sysctl(struct xen_sysctl_dt_overlay *op); +long dt_overlay_domctl(struct domain *d, struct xen_domctl_dt_overlay *op); #else #include static inline long dt_overlay_sysctl(struct xen_sysctl_dt_overlay *op) { return -EOPNOTSUPP; } +static inline long dt_overlay_domctl(struct domain *d, + struct xen_domctl_dt_overlay *op) +{ + return -EOPNOTSUPP; +} #endif =20 #endif /* __XEN_DT_OVERLAY_H__ */ --=20 2.34.1 From nobody Fri Nov 22 13:30:37 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=1716450090; cv=pass; d=zohomail.com; s=zohoarc; b=QPHHXtDHYFK9BY0b6SNhPDtQiH0M4NQ9LqNR3MvycpAVPWRsPw+/bt/Zj08MM7GQshqT+wAAyBTY+N3Kw2mc7pZyHa4lriO1IQWHO65d6t/i2GEQuYs9ylJ4ERA/0lpYLwYxGmzT8ctb9ZhQZ1/SSaTJ2ousvsgwNC+Alt1ZX2E= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716450090; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=L8dKwKh5Agkr6/Sz2gAOhHiky/a7zfL5mmaZ+kO5RLw=; b=ES0P3xH8YBoEL1bCgcexjuoU0I3xEaBESv1v41LAT5iNXgLVSu3e6e9JbB3kIMSLS7UyHyNifehujce9vHG6FI3DjpjF5iHWkvnqMW1NBnPTrGyhJawzIg/HR3xY9g8PDVhxQ8yXjKvgy/rCDcrE1kIdSRGyugb6X+OuIlI8Ef8= 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 1716450090833822.4436803766164; Thu, 23 May 2024 00:41:30 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.728101.1132930 (Exim 4.92) (envelope-from ) id 1sA34Y-0003hP-N9; Thu, 23 May 2024 07:41:10 +0000 Received: by outflank-mailman (output) from mailman id 728101.1132930; Thu, 23 May 2024 07:41:10 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sA34Y-0003gE-Gq; Thu, 23 May 2024 07:41:10 +0000 Received: by outflank-mailman (input) for mailman id 728101; Thu, 23 May 2024 07:41:09 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sA34W-0003CF-VT for xen-devel@lists.xenproject.org; Thu, 23 May 2024 07:41:08 +0000 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on20600.outbound.protection.outlook.com [2a01:111:f403:2415::600]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id cdf34002-18d7-11ef-b4bb-af5377834399; Thu, 23 May 2024 09:41:03 +0200 (CEST) Received: from CH0PR03CA0441.namprd03.prod.outlook.com (2603:10b6:610:10e::34) by LV3PR12MB9215.namprd12.prod.outlook.com (2603:10b6:408:1a0::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.18; Thu, 23 May 2024 07:40:59 +0000 Received: from CH1PEPF0000AD77.namprd04.prod.outlook.com (2603:10b6:610:10e:cafe::99) by CH0PR03CA0441.outlook.office365.com (2603:10b6:610:10e::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.18 via Frontend Transport; Thu, 23 May 2024 07:40:59 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by CH1PEPF0000AD77.mail.protection.outlook.com (10.167.244.55) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7611.14 via Frontend Transport; Thu, 23 May 2024 07:40:58 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) 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.2507.35; Thu, 23 May 2024 02:40:57 -0500 Received: from henry-MS-7D54.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Thu, 23 May 2024 02:40:55 -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: cdf34002-18d7-11ef-b4bb-af5377834399 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RBUWCnqg9UeHYedJVl/R9pfYRSQPbqjaNn7+kPZ1VzeYDdGsRAp6XO47j2WTc9R8hM4UNNlWKMNw9MswuMqsmKEnjdMfgGqrE4wyf3xQ5L0TofVKYiwN/gtb9hkGr8TqbdvBzej0OAR6vc5DxmMLvGN0qg4FskHGYTkKxlhZ63v0cofGYvrswBoEhfCeZ8RopH0nWDa1LGDZsA/ec4cxH9Zj+CN4JI0T4+i/Q7sIZD1vJQ/3sudVXdI5ooolnAkTZcHZi2yu8B501MN90jnYqJ6+zAOnPs4lfH8osgQlkR2uMslfZYvy/hi8DC71mal6htn6GKUl6Sy27xa20e76Yw== 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=L8dKwKh5Agkr6/Sz2gAOhHiky/a7zfL5mmaZ+kO5RLw=; b=n1oH2n8ilKylm7HfqTfqeCDmNiQtZwqTCQcKFooiKb/aHe0ze2d4w91fG5jwTa5/Ewa6XB40tDtz+8hCSkuEIqIfOyufbswZ7vWKRIkSI+OmcaI2TH+9GepKfewK2djNlRVg1uBg0F0Q6uftP6/mJQ0cSDpICce7ZkXgFJziWxsChmFYBhpk8vTg2lrUJvskgp9invOzTcyybXEf4uopUDYYm4Gdm6N4BJYZEd+i9WI4mv89/JiCoCu5VuOfrZ8amP9G3upRy8TnMQmepNchdZiJcpL0wxXcbc8DHoa6v6l9VmJouTLy1ba52svo04rMRpS5NXJUTMhsSXsX5u8oXw== 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 (0) 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=L8dKwKh5Agkr6/Sz2gAOhHiky/a7zfL5mmaZ+kO5RLw=; b=qu60VsrHqx7x0QzeoqjN1uswiuS4Q1T48lpY2u313+IUphvS2ILN1y95o22X8mXIlwIIRO/lLjU03QmQ+WB7xdH93inSSXHU55FDY6au3ea7lxuRv1I7M4lnt34nX9KtrG1WnBE3q4ESb9ADol4AxaplKS1KRoggPbLZzYm8kmQ= 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: Henry Wang To: CC: Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk , "Henry Wang" Subject: [PATCH v4 6/9] xen/arm/gic: Allow removing interrupt to running VMs Date: Thu, 23 May 2024 15:40:37 +0800 Message-ID: <20240523074040.1611264-7-xin.wang2@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240523074040.1611264-1-xin.wang2@amd.com> References: <20240523074040.1611264-1-xin.wang2@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: None (SATLEXMB03.amd.com: xin.wang2@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000AD77:EE_|LV3PR12MB9215:EE_ X-MS-Office365-Filtering-Correlation-Id: 26087eb1-bd6e-4dcb-36f2-08dc7afbb00a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|376005|1800799015|36860700004|82310400017; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?589QVo1rUR6jtYI+hepZXhQS/2JuFhESRrE1KFczuIeIYQSskO+IhDLWCaOl?= =?us-ascii?Q?UHGvySCx19xxCsbhFfvDxlEYvOmKeT8tUgDhd6i6eGKqvGTlfBDq5zP+wCyV?= =?us-ascii?Q?gsGJbAP+G9sH6anfv2ucG5DNXxVZbqvkomx/ClEJHK1XMj+6s9BZxydxLttU?= =?us-ascii?Q?5ejamBYAhW8iDb8Pdgvn3NtIK6YaSY/B0HxvWftP7f0CDPeUeJf7uMX5cnE+?= =?us-ascii?Q?MABpDff/pLQDcKV6kRJaTp3vw8/07bZ+uEZgO3NbCyj/MH8peeG6167VzW9v?= =?us-ascii?Q?cdPeiM2QdG/3PU2qY2pk2b8PGd7yQvWp9/qHwlvNKYvIYaiIHFRvHzGwuM3v?= =?us-ascii?Q?+ECDZH2KsqqJ2WIQwqDdANA40bK7jsRe3Ajw1/clkgMXzbDOTEGaCfKJPT9e?= =?us-ascii?Q?EVgS3XXjolOepU2d3oOJojTuh0jK+NVYIJUB0gb7Yh41QTKxMXrKZWwIF3Dh?= =?us-ascii?Q?Ngf0qdpiqncx0la5AOMtFF/QOc1qlbWTnDn8hBiigpfhzqKGceSqJ8/gyWKU?= =?us-ascii?Q?KzXMBYpXwQzcG+j4A/fGi8WZwnjrxo4cmeCjEfUf5BefQLSwlwoCvelkAPDR?= =?us-ascii?Q?mp+Rrep0s8YKMOiOJneQK+7daTpCmFHKLxk1xPJ7HbGc1uZOHVAtnK0wEvYq?= =?us-ascii?Q?5r6pQdd1qV7F6zsGcR8Os60w2KG4PRc9s+LcT7yjki5S/uzSpUplqRiCMCI/?= =?us-ascii?Q?3AUFpoR5ZOz0c8S1j9BSGXigW6P6z5dcKzVWlH/8GfJbHybE2TKuzZep87Bk?= =?us-ascii?Q?PtsQcQUa9RG2aEPAHWZaGa0Wb5HBGoA9BE/vNzVLUtxeHFEirjvHV8fBKerQ?= =?us-ascii?Q?b9m1UKd/0BSeBMEvvtMMSUOdBi+UVu2qVaW9EDpHvxvN0XMK35Jm/mgo2DR9?= =?us-ascii?Q?hvUqWEoI0EqVGCxWZUy4H/6xtm54Lh8BR9ZLbAuX1Fmp0asdNgpXH2RwbaTx?= =?us-ascii?Q?TSLD/VXpJsPdxdfG5i62/EHK77LaRZnhmxtMZ++FcodvkTeUOdn6Sii9kTjx?= =?us-ascii?Q?Cw8CcwlL4L7dEIDmOT1TNgMIT1K6T0Kp1nY+CdbmS89ieHB8eFqu03mfGLoA?= =?us-ascii?Q?Hyg77CFxjbjs/pI/bG+0hN+jl54Fbsnm7stFkUUoiwnYcI+nyhL4L/VfLTIo?= =?us-ascii?Q?Ugy8oA/sCeZZOY6nDb4dIlipa+MqEUY6+j9RKnI+/ZZhiNV+PtC5ou5FZuvu?= =?us-ascii?Q?qMVYsFcWFnThJiHQMdu/yQjOFY/o1a5xYH5H3R8SphjTcPMGA0yh7jnB4ry9?= =?us-ascii?Q?W8P3JRGRfTY06Ca5swh4EeACv1QLdXY+G4llyZN2iBzyQV+jLZDmRkSqjkP+?= =?us-ascii?Q?3FQHLoxRyEecKZET/bsAAEXtd746LkaBI2a7eyW9Y71YsTtKrJPV8SPbQzI+?= =?us-ascii?Q?8P978YdRzxirDX2UX1v+FcpyI7C5?= 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:(13230031)(376005)(1800799015)(36860700004)(82310400017);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 May 2024 07:40:58.7826 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 26087eb1-bd6e-4dcb-36f2-08dc7afbb00a 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: CH1PEPF0000AD77.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR12MB9215 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1716450091217100003 Content-Type: text/plain; charset="utf-8" From: Vikram Garhwal Currently, removing physical interrupts are only allowed at the domain destroy time. For use cases such as dynamic device tree overlay removing, the removing of physical IRQ to running domains should be allowed. Move the above-mentioned domain dying check to vgic_connect_hw_irq(). Similarly as the routing interrupt to running domains, reject the operation if the IRQ is active or pending in the guest. Do it for both new and old vGIC implementations. Since now vgic_connect_hw_irq() may reject the invalid operation case, move the clear of _IRQ_INPROGRESS flag in gic_remove_irq_from_guest() to after the successful execution of vgic_connect_hw_irq(). Signed-off-by: Vikram Garhwal Signed-off-by: Stefano Stabellini Signed-off-by: Henry Wang --- v4: - Split the original patch, only do the removing IRQ stuff in this patch. - Move the clear of _IRQ_INPROGRESS flag in gic_remove_irq_from_guest() to after the successful execution of vgic_connect_hw_irq(). - Special case the d->is_dying check. --- xen/arch/arm/gic-vgic.c | 27 ++++++++++++++++++++++++--- xen/arch/arm/gic.c | 9 +-------- xen/arch/arm/vgic/vgic.c | 24 ++++++++++++++++++++---- 3 files changed, 45 insertions(+), 15 deletions(-) diff --git a/xen/arch/arm/gic-vgic.c b/xen/arch/arm/gic-vgic.c index b99e287224..56b6a3d5b0 100644 --- a/xen/arch/arm/gic-vgic.c +++ b/xen/arch/arm/gic-vgic.c @@ -439,6 +439,14 @@ int vgic_connect_hw_irq(struct domain *d, struct vcpu = *v, unsigned int virq, =20 /* We are taking to rank lock to prevent parallel connections. */ vgic_lock_rank(v_target, rank, flags); + /* Return with error if the IRQ is being migrated. */ + if( test_bit(GIC_IRQ_GUEST_MIGRATING, &p->status) ) + { + vgic_unlock_rank(v_target, rank, flags); + return -EBUSY; + } + + spin_lock(&v_target->arch.vgic.lock); =20 if ( connect ) { @@ -456,12 +464,25 @@ int vgic_connect_hw_irq(struct domain *d, struct vcpu= *v, unsigned int virq, } else { - if ( desc && p->desc !=3D desc ) - ret =3D -EINVAL; + if ( d->is_dying ) + { + if ( desc && p->desc !=3D desc ) + ret =3D -EINVAL; + else + p->desc =3D NULL; + } else - p->desc =3D NULL; + { + if ( (desc && p->desc !=3D desc) || + test_bit(GIC_IRQ_GUEST_VISIBLE, &p->status) || + test_bit(GIC_IRQ_GUEST_ACTIVE, &p->status) ) + ret =3D -EINVAL; + else + p->desc =3D NULL; + } } =20 + spin_unlock(&v_target->arch.vgic.lock); vgic_unlock_rank(v_target, rank, flags); =20 return ret; diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c index b3467a76ae..8633f14bdd 100644 --- a/xen/arch/arm/gic.c +++ b/xen/arch/arm/gic.c @@ -159,24 +159,17 @@ int gic_remove_irq_from_guest(struct domain *d, unsig= ned int virq, ASSERT(test_bit(_IRQ_GUEST, &desc->status)); ASSERT(!is_lpi(virq)); =20 - /* - * Removing an interrupt while the domain is running may have - * undesirable effect on the vGIC emulation. - */ - if ( !d->is_dying ) - return -EBUSY; - desc->handler->shutdown(desc); =20 /* EOI the IRQ if it has not been done by the guest */ if ( test_bit(_IRQ_INPROGRESS, &desc->status) ) gic_hw_ops->deactivate_irq(desc); - clear_bit(_IRQ_INPROGRESS, &desc->status); =20 ret =3D vgic_connect_hw_irq(d, NULL, virq, desc, false); if ( ret ) return ret; =20 + clear_bit(_IRQ_INPROGRESS, &desc->status); clear_bit(_IRQ_GUEST, &desc->status); desc->handler =3D &no_irq_type; =20 diff --git a/xen/arch/arm/vgic/vgic.c b/xen/arch/arm/vgic/vgic.c index 048e12c562..0c324b58f7 100644 --- a/xen/arch/arm/vgic/vgic.c +++ b/xen/arch/arm/vgic/vgic.c @@ -890,14 +890,30 @@ int vgic_connect_hw_irq(struct domain *d, struct vcpu= *vcpu, } else /* remove a mapped IRQ */ { - if ( desc && irq->hwintid !=3D desc->irq ) + if ( d->is_dying ) { - ret =3D -EINVAL; + if ( desc && irq->hwintid !=3D desc->irq ) + { + ret =3D -EINVAL; + } + else + { + irq->hw =3D false; + irq->hwintid =3D 0; + } } else { - irq->hw =3D false; - irq->hwintid =3D 0; + if ( (desc && irq->hwintid !=3D desc->irq) || + irq->active || irq->pending_latch ) + { + ret =3D -EINVAL; + } + else + { + irq->hw =3D false; + irq->hwintid =3D 0; + } } } =20 --=20 2.34.1 From nobody Fri Nov 22 13:30:37 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=1716450096; cv=pass; d=zohomail.com; s=zohoarc; b=k4OewRQxwrbVhupiK4O5tnUTXJ2WMT1WyGE6EoOEEgUs7yHb1TjlGPC/dwBXKXa+LSaDis0KGwZPDHY8BOXa7jeaGRat1bzCH1cMT7NFlw8nnEsJfqDzNLeEeIinswm+5vGC/LS5n3jgC+N6WIOew0DBF2aUIgp4rGbRsIcpLcU= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716450096; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=2WjCV+UJTAIwa98i99pj6e9RnE3+oYy74bW5zI2VriQ=; b=JjfQUzG+51ww2Af2WS1W6iX/JsByyh58AYTggcWB2DyyGHsMlW9UGzm4FuvRt8FJJUzE7R2bJUHM+lnEVUuQRCxcmKEGKQaHY95OA9EIPmzPWQYU1C0DiOlLOnbqf0I1jo9PUDIT4bDN7eMmfF1aE41k2uLfQihbDqUEpGPmdtw= 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 1716450096720186.34152485361096; Thu, 23 May 2024 00:41:36 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.728100.1132919 (Exim 4.92) (envelope-from ) id 1sA34X-0003M5-A0; Thu, 23 May 2024 07:41:09 +0000 Received: by outflank-mailman (output) from mailman id 728100.1132919; Thu, 23 May 2024 07:41:09 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sA34X-0003Lu-6R; Thu, 23 May 2024 07:41:09 +0000 Received: by outflank-mailman (input) for mailman id 728100; Thu, 23 May 2024 07:41:08 +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 1sA34W-0001WY-Bw for xen-devel@lists.xenproject.org; Thu, 23 May 2024 07:41:08 +0000 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on20600.outbound.protection.outlook.com [2a01:111:f403:2408::600]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id d0c5d2ec-18d7-11ef-90a1-e314d9c70b13; Thu, 23 May 2024 09:41:07 +0200 (CEST) Received: from BY5PR20CA0024.namprd20.prod.outlook.com (2603:10b6:a03:1f4::37) by PH7PR12MB6738.namprd12.prod.outlook.com (2603:10b6:510:1a9::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.36; Thu, 23 May 2024 07:41:03 +0000 Received: from CO1PEPF000066EC.namprd05.prod.outlook.com (2603:10b6:a03:1f4:cafe::ef) by BY5PR20CA0024.outlook.office365.com (2603:10b6:a03:1f4::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.22 via Frontend Transport; Thu, 23 May 2024 07:41:03 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1PEPF000066EC.mail.protection.outlook.com (10.167.249.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7611.14 via Frontend Transport; Thu, 23 May 2024 07:41:02 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 23 May 2024 02:40:59 -0500 Received: from henry-MS-7D54.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Thu, 23 May 2024 02:40:58 -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: d0c5d2ec-18d7-11ef-90a1-e314d9c70b13 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZawFVej4XbPQ44lzG6OFWPH5F7gp/ntM/F0lJ6b4W2SDVG6DjqzJ0SNvVOIxD3r53kSxc5L6fD+Kr52Cnmtm6LaZbg0w8iAfiPChYlbhglrjpL/lPR2l0Fi4yTMANNn48FdBez2h92eTfP2Nq7kr2MUfBA/5RrcNpmUjgQbb4Vx9T3sQOxOglATWbMnQNNAuO+rzsKk4po+8/k7zrBCMpeyNU2qXQ3dbnuFF2gy0Om5o1Mv9Zd3ufqUnGHiZWxd/NCH8E6q+mi/y9t7dzxHyhEerFhI7NhijOyi8EEhqYQFTYuOL8SlU03Hfz25vIBXG62z6TYJkQGwZxfANnE6vwA== 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=2WjCV+UJTAIwa98i99pj6e9RnE3+oYy74bW5zI2VriQ=; b=n0nw5r70dTN9/IUIRZjlqTnDYsguiiKMq2UY84uPM9Krskv+CqFHFH0MWX77PGRKWu70gPA1O2RTg73EJCvn0kfeu0WfRybXdqTk53Xdic15frL7i72kusIMEI4lJSI2Pap4xaEuZgBlR7FG46PP2jj/4AM8Uh2T5OCXYrGgIBHEZjrQylsDS5wLBSX4hzC4/N2LEBJDpglYTRRt8pN3PGTo/1hawzq65eY8FD4Y430XRTYH7+2+v/970VwUzVZ1P2Lorxs/3ijI95QW4TD3q+oVw4FnwoeoYfkgsLV05B15JQCIf+qk+gs31soVDzagNE54iRJ/r7TsZMLEbt71qw== 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 (0) 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=2WjCV+UJTAIwa98i99pj6e9RnE3+oYy74bW5zI2VriQ=; b=05HiC3DdPgRXfDroX4eQlYRO5tbdoPbfu8wuUuR+jEopWi0wsgN2dwBI49/WQp8ffYVDGw/wvlcer1w7ymZNXR/tu6qsUQ4NXfrmVSa+xzYIc+Uf98VdNmdNW2Fds0lMh9ULejxDsVlNd8cHjPdds8syvPQajJlm1d8kyH2/OpQ= 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=SATLEXMB04.amd.com; pr=C From: Henry Wang To: CC: Stefano Stabellini , Julien Grall , Andrew Cooper , George Dunlap , Jan Beulich , Henry Wang Subject: [PATCH v4 7/9] xen/arm: Support device detachment from domains Date: Thu, 23 May 2024 15:40:38 +0800 Message-ID: <20240523074040.1611264-8-xin.wang2@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240523074040.1611264-1-xin.wang2@amd.com> References: <20240523074040.1611264-1-xin.wang2@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: None (SATLEXMB04.amd.com: xin.wang2@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000066EC:EE_|PH7PR12MB6738:EE_ X-MS-Office365-Filtering-Correlation-Id: 4004e741-a608-4b1d-3e75-08dc7afbb262 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|36860700004|376005|82310400017; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?HEj4UA5zBGDBgQ72s0ZLScb306lbL6WBiFpXCeolHkM2EqPOR/yIraiT8MBx?= =?us-ascii?Q?qJVupoEd3MiBwopBNCVv61Kxnm9FkwhMdvnrIO3V4FEDxtp0uSUFUjgiIeG2?= =?us-ascii?Q?rQNKK9MWcy3Twjvp0ojYy2XfnZia2Qeqlf0wcWA/vJK2T2Y4H2bGWWdUk6XC?= =?us-ascii?Q?18mWzpeBaG5mZh8VG0Wmk0YVB42emsoK/FEW8Fa4dfWFHPBPDg9rvyRY4TtR?= =?us-ascii?Q?q2HZpkc3Um44+VDwkKpet5svQLFOJSVZPE8qy3DS5v6Blq96W4+eLpSyhhdt?= =?us-ascii?Q?lIKRW0l+jr68AACveMoXFMuTgJbZm3WM8B8vmjPfKv4sIlR9KMEsb0/0Ul7m?= =?us-ascii?Q?nkAHL6XVU6ObtXBkzkEuTY0oe6jbdxrgT/xkLrDauvLiThgQTK6DrSYZCX1h?= =?us-ascii?Q?1RMExcCl52WXoIjvmr4gVVzAx3mbAHG2VRKjDXktiuGQxEjOC2e3gq8rTpB0?= =?us-ascii?Q?fhLQ+vfRFzm8xXIcY78nYzSTwKgfapaqeqcrl51894dIgowz+0Tm9tJl1YDl?= =?us-ascii?Q?HHFkd8pBIrvPD/nL1h92a0ZRSJam6lYADZaN1DmgbYM3Ejc71up7BGVylEWJ?= =?us-ascii?Q?GlRmss5qzNux5Ezo+BMez0jrLiP8IRKyBB0GPB5eCmiT5GjtkxNvxLreDRUo?= =?us-ascii?Q?IzOW5AceSnB1fMkgz/QdFR1WYnwqf4BFAzLGe86kl00neq9Fl1TqiH8ybmTc?= =?us-ascii?Q?LLXq1euz1E71zoSaqvfwPjztlcZeW0QF+dXLCAw+NMYeYnzbFRi7sJHZrC/8?= =?us-ascii?Q?e1CG8gFXf1ZBzDVbrMbQalRZzPUNpiTWJk/GWdN4TExm7dTGWecgLjFy1282?= =?us-ascii?Q?bUrPGAURmHhA2Z/sxf0nOWrSV8VHcXOU6TdYf2Drwn8r/Sh9nKuvEfSEOC5H?= =?us-ascii?Q?7QMuyqwahKvmk1eojH/J05VCMurl5YjCXu2Yb6PyLGfrieUuWHZaZg/8h349?= =?us-ascii?Q?YpAeJQp7LGp1XyF2Oztx4jMGtvZeto3Xu2EokhY46dqw+q3KjC4C9nek97ck?= =?us-ascii?Q?DiwZkNuPHfo6qIuzum79astagPxeGW3IN6XmkiKN0kEOrf+4jqhmbzlK2/yR?= =?us-ascii?Q?JsU3ffDkSnTkHO5Sp0lvHJcoUD9ROJSOldq2u6l0iGLd5jEu+34WDH7NnKzc?= =?us-ascii?Q?5k1TvFl2ncGLEtPgOEBiekDTqqTlrsa8eRfO3c4e9YPD5aZnhlU7oghHaDdM?= =?us-ascii?Q?MNM4nMUcAVos/F3M4/yErrqej72ZyTOJNkgs/wq+wtp6pVqrkWSjxX7eC4B4?= =?us-ascii?Q?GF7KJh2ks6gr5etccn4liRphAW/wHwtZPLEcpidz3tht6Y7/vUdGWvwftKIG?= =?us-ascii?Q?Vko78hCn72zq0JEwqE5zMqNofBodj5k0AwcgqJMGzv09w67qtWr42bhrjp/x?= =?us-ascii?Q?KvqCkdk39/qRB1TfODGYZv5VH/xi?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(1800799015)(36860700004)(376005)(82310400017);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 May 2024 07:41:02.6368 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4004e741-a608-4b1d-3e75-08dc7afbb262 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000066EC.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6738 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1716450097235100001 Content-Type: text/plain; charset="utf-8" Similarly as the device attachment from DT overlay to domain, this commit implements the device detachment from domain. The DOMCTL XEN_DOMCTL_dt_overlay op is extended to have the operation XEN_DOMCTL_DT_OVERLAY_DETACH. The detachment of the device is implemented by unmapping the IRQ and IOMMU resources. Note that with these changes, the device de-registration from the IOMMU driver should only happen at the time when the DT overlay is removed from the Xen device tree. Signed-off-by: Henry Wang Signed-off-by: Vikram Garhwal --- v4: - Split the original patch, only do device detachment from domain. --- xen/common/dt-overlay.c | 243 ++++++++++++++++++++++++++++-------- xen/include/public/domctl.h | 3 +- 2 files changed, 194 insertions(+), 52 deletions(-) diff --git a/xen/common/dt-overlay.c b/xen/common/dt-overlay.c index 1087f9b502..693b6e4777 100644 --- a/xen/common/dt-overlay.c +++ b/xen/common/dt-overlay.c @@ -392,24 +392,100 @@ find_track_entry_from_tracker(const void *overlay_fd= t, return entry; } =20 +static int remove_irq(unsigned long s, unsigned long e, void *data) +{ + struct domain *d =3D data; + int rc =3D 0; + + /* + * IRQ should always have access unless there are duplication of + * of irqs in device tree. There are few cases of xen device tree + * where there are duplicate interrupts for the same node. + */ + if (!irq_access_permitted(d, s)) + return 0; + /* + * TODO: We don't handle shared IRQs for now. So, it is assumed that + * the IRQs was not shared with another domain. + */ + rc =3D irq_deny_access(d, s); + if ( rc ) + { + printk(XENLOG_ERR "unable to revoke access for irq %ld\n", s); + return rc; + } + + rc =3D release_guest_irq(d, s); + if ( rc ) + { + printk(XENLOG_ERR "unable to release irq %ld\n", s); + return rc; + } + + return rc; +} + +static int remove_all_irqs(struct rangeset *irq_ranges, struct domain *d) +{ + return rangeset_report_ranges(irq_ranges, 0, ~0UL, remove_irq, d); +} + +static int remove_iomem(unsigned long s, unsigned long e, void *data) +{ + struct domain *d =3D data; + int rc =3D 0; + p2m_type_t t; + mfn_t mfn; + + mfn =3D p2m_lookup(d, _gfn(s), &t); + if ( mfn_x(mfn) =3D=3D 0 || mfn_x(mfn) =3D=3D ~0UL ) + return -EINVAL; + + rc =3D iomem_deny_access(d, s, e); + if ( rc ) + { + printk(XENLOG_ERR "Unable to remove %pd access to %#lx - %#lx\n", + d, s, e); + return rc; + } + + rc =3D unmap_mmio_regions(d, _gfn(s), e - s, _mfn(s)); + if ( rc ) + return rc; + + return rc; +} + +static int remove_all_iomems(struct rangeset *iomem_ranges, struct domain = *d) +{ + return rangeset_report_ranges(iomem_ranges, 0, ~0UL, remove_iomem, d); +} + /* Check if node itself can be removed and remove node from IOMMU. */ -static int remove_node_resources(struct dt_device_node *device_node) +static int remove_node_resources(struct dt_device_node *device_node, + struct domain *d) { int rc =3D 0; unsigned int len; domid_t domid; =20 - domid =3D dt_device_used_by(device_node); + if ( !d ) + { + domid =3D dt_device_used_by(device_node); =20 - dt_dprintk("Checking if node %s is used by any domain\n", - device_node->full_name); + dt_dprintk("Checking if node %s is used by any domain\n", + device_node->full_name); =20 - /* Remove the node if only it's assigned to hardware domain or domain = io. */ - if ( domid !=3D hardware_domain->domain_id && domid !=3D DOMID_IO ) - { - printk(XENLOG_ERR "Device %s is being used by domain %u. Removing = nodes failed\n", - device_node->full_name, domid); - return -EINVAL; + /* + * We also check if device is assigned to DOMID_IO as when a domain + * is destroyed device is assigned to DOMID_IO. + */ + if ( domid !=3D DOMID_IO ) + { + printk(XENLOG_ERR "Device %s is being assigned to %u. Device i= s assigned to %d\n", + device_node->full_name, DOMID_IO, domid); + return -EINVAL; + } } =20 /* Check if iommu property exists. */ @@ -417,9 +493,12 @@ static int remove_node_resources(struct dt_device_node= *device_node) { if ( dt_device_is_protected(device_node) ) { - rc =3D iommu_remove_dt_device(device_node); - if ( rc < 0 ) - return rc; + if ( !list_empty(&device_node->domain_list) ) + { + rc =3D iommu_deassign_dt_device(d, device_node); + if ( rc < 0 ) + return rc; + } } } =20 @@ -428,7 +507,8 @@ static int remove_node_resources(struct dt_device_node = *device_node) =20 /* Remove all descendants from IOMMU. */ static int -remove_descendant_nodes_resources(const struct dt_device_node *device_node) +remove_descendant_nodes_resources(const struct dt_device_node *device_node, + struct domain *d) { int rc =3D 0; struct dt_device_node *child_node; @@ -438,12 +518,12 @@ remove_descendant_nodes_resources(const struct dt_dev= ice_node *device_node) { if ( child_node->child ) { - rc =3D remove_descendant_nodes_resources(child_node); + rc =3D remove_descendant_nodes_resources(child_node, d); if ( rc ) return rc; } =20 - rc =3D remove_node_resources(child_node); + rc =3D remove_node_resources(child_node, d); if ( rc ) return rc; } @@ -456,8 +536,7 @@ static int remove_nodes(const struct overlay_track *tra= cker) { int rc =3D 0; struct dt_device_node *overlay_node; - unsigned int j; - struct domain *d =3D hardware_domain; + unsigned int j, len; =20 for ( j =3D 0; j < tracker->num_nodes; j++ ) { @@ -467,18 +546,15 @@ static int remove_nodes(const struct overlay_track *t= racker) =20 write_lock(&dt_host_lock); =20 - rc =3D remove_descendant_nodes_resources(overlay_node); - if ( rc ) + /* Check if iommu property exists. */ + if ( dt_get_property(overlay_node, "iommus", &len) ) { - write_unlock(&dt_host_lock); - return rc; - } - - rc =3D remove_node_resources(overlay_node); - if ( rc ) - { - write_unlock(&dt_host_lock); - return rc; + if ( dt_device_is_protected(overlay_node) ) + { + rc =3D iommu_remove_dt_device(overlay_node); + if ( rc < 0 ) + return rc; + } } =20 dt_dprintk("Removing node: %s\n", overlay_node->full_name); @@ -493,22 +569,6 @@ static int remove_nodes(const struct overlay_track *tr= acker) write_unlock(&dt_host_lock); } =20 - /* Remove IRQ access. */ - if ( tracker->irq_ranges ) - { - rc =3D rangeset_consume_ranges(tracker->irq_ranges, irq_remove_cb,= d); - if ( rc ) - return rc; - } - - /* Remove mmio access. */ - if ( tracker->iomem_ranges ) - { - rc =3D rangeset_consume_ranges(tracker->iomem_ranges, iomem_remove= _cb, d); - if ( rc ) - return rc; - } - return rc; } =20 @@ -534,7 +594,6 @@ static long handle_remove_overlay_nodes(const void *ove= rlay_fdt, { rc =3D -EINVAL; goto out; - } =20 rc =3D remove_nodes(entry); @@ -552,9 +611,6 @@ static long handle_remove_overlay_nodes(const void *ove= rlay_fdt, =20 xfree(entry->nodes_address); =20 - rangeset_destroy(entry->irq_ranges); - rangeset_destroy(entry->iomem_ranges); - xfree(entry); =20 out: @@ -840,6 +896,88 @@ static long handle_add_overlay_nodes(void *overlay_fdt, return rc; } =20 +static long handle_detach_overlay_nodes(struct domain *d, + const void *overlay_fdt, + uint32_t overlay_fdt_size) +{ + int rc; + unsigned int j; + struct overlay_track *entry; + + rc =3D check_overlay_fdt(overlay_fdt, overlay_fdt_size); + if ( rc ) + return rc; + + spin_lock(&overlay_lock); + + entry =3D find_track_entry_from_tracker(overlay_fdt, overlay_fdt_size); + if ( entry =3D=3D NULL ) + { + rc =3D -EINVAL; + goto out; + } + + for ( j =3D 0; j < entry->num_nodes; j++ ) + { + struct dt_device_node *overlay_node; + + overlay_node =3D (struct dt_device_node *)entry->nodes_address[j]; + if ( overlay_node =3D=3D NULL ) + { + rc =3D -EINVAL; + goto out; + } + + write_lock(&dt_host_lock); + rc =3D remove_descendant_nodes_resources(overlay_node, d); + if ( rc ) + { + write_unlock(&dt_host_lock); + goto out; + } + + rc =3D remove_node_resources(overlay_node, d); + if ( rc ) + { + write_unlock(&dt_host_lock); + goto out; + } + write_unlock(&dt_host_lock); + + rc =3D remove_all_irqs(entry->irq_ranges, d); + if ( rc ) + goto out; + + rc =3D remove_all_iomems(entry->iomem_ranges, d); + if ( rc ) + goto out; + } + + /* Remove IRQ access. */ + if ( entry->irq_ranges ) + { + rc =3D rangeset_consume_ranges(entry->irq_ranges, irq_remove_cb, d= ); + if ( rc ) + goto out; + } + + /* Remove mmio access. */ + if ( entry->iomem_ranges ) + { + rc =3D rangeset_consume_ranges(entry->iomem_ranges, iomem_remove_c= b, d); + if ( rc ) + goto out; + } + + rangeset_destroy(entry->irq_ranges); + rangeset_destroy(entry->iomem_ranges); + + out: + spin_unlock(&overlay_lock); + + return rc; +} + static long handle_attach_overlay_nodes(struct domain *d, const void *overlay_fdt, uint32_t overlay_fdt_size) @@ -956,7 +1094,8 @@ long dt_overlay_domctl(struct domain *d, struct xen_do= mctl_dt_overlay *op) long ret; void *overlay_fdt; =20 - if ( op->overlay_op !=3D XEN_DOMCTL_DT_OVERLAY_ATTACH ) + if ( op->overlay_op !=3D XEN_DOMCTL_DT_OVERLAY_ATTACH && + op->overlay_op !=3D XEN_DOMCTL_DT_OVERLAY_DETACH ) return -EOPNOTSUPP; =20 if ( op->overlay_fdt_size =3D=3D 0 || op->overlay_fdt_size > KB(500) ) @@ -979,7 +1118,9 @@ long dt_overlay_domctl(struct domain *d, struct xen_do= mctl_dt_overlay *op) return -EFAULT; } =20 - if ( op->overlay_op =3D=3D XEN_DOMCTL_DT_OVERLAY_ATTACH ) + if ( op->overlay_op =3D=3D XEN_DOMCTL_DT_OVERLAY_DETACH ) + ret =3D handle_detach_overlay_nodes(d, overlay_fdt, op->overlay_fd= t_size); + else ret =3D handle_attach_overlay_nodes(d, overlay_fdt, op->overlay_fd= t_size); =20 xfree(overlay_fdt); diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h index ac3c2a7c4c..e91f743fa4 100644 --- a/xen/include/public/domctl.h +++ b/xen/include/public/domctl.h @@ -1195,7 +1195,8 @@ struct xen_domctl_dt_overlay { XEN_GUEST_HANDLE_64(const_void) overlay_fdt; /* IN: overlay fdt. */ uint32_t overlay_fdt_size; /* IN: Overlay dtb size. */ #define XEN_DOMCTL_DT_OVERLAY_ATTACH 1 - uint8_t overlay_op; /* IN: Attach. */ +#define XEN_DOMCTL_DT_OVERLAY_DETACH 2 + uint8_t overlay_op; /* IN: Attach/Detach. */ uint8_t pad[3]; /* IN: Must be zero. */ }; #endif --=20 2.34.1 From nobody Fri Nov 22 13:30:37 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=1716450097; cv=pass; d=zohomail.com; s=zohoarc; b=VyG92SoXHiVLyoktk+SCgj5T1RTNUf3VoFqy/XaE3BsTxKfL5OVr0J9Smy0RNKNC0sX3ABOV/88ck3NiFqGJzMsK5SAoKbYf6ZpVvWvPU81MjMUvW3ggHino8tehFSmsyjmfp5lVXe7UXJZIuS/isQMHoYwImkduxBtVZWTLjvU= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716450097; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=da2DEjMTTPOqHs5JEHft5f2zNU/TKUOCNbSUhm9LjB0=; b=jr/SyqDPyBegNUXk3uzvWaJRAL83jmyWgFCh4C+nvCvKJTs+d38Kk7GPv/8AsD3kJPi+9NsSoEAaPAHfwnoR4/VcWd2+2WN7V63KJwNecQatj7gyLcGX5TDB+ZyhQYZpMfL2/2hyTXJDMWiKeoRXmbrroPjBQSdcNc4hRH5kisU= 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 171645009724545.649790940003186; Thu, 23 May 2024 00:41:37 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.728109.1132950 (Exim 4.92) (envelope-from ) id 1sA34c-0004YO-OQ; Thu, 23 May 2024 07:41:14 +0000 Received: by outflank-mailman (output) from mailman id 728109.1132950; Thu, 23 May 2024 07:41:14 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sA34c-0004Y0-JH; Thu, 23 May 2024 07:41:14 +0000 Received: by outflank-mailman (input) for mailman id 728109; Thu, 23 May 2024 07:41:13 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sA34b-0003CF-Hg for xen-devel@lists.xenproject.org; Thu, 23 May 2024 07:41:13 +0000 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on20600.outbound.protection.outlook.com [2a01:111:f403:2009::600]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id d34da501-18d7-11ef-b4bb-af5377834399; Thu, 23 May 2024 09:41:11 +0200 (CEST) Received: from BY5PR20CA0013.namprd20.prod.outlook.com (2603:10b6:a03:1f4::26) by BL1PR12MB5804.namprd12.prod.outlook.com (2603:10b6:208:394::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.36; Thu, 23 May 2024 07:41:08 +0000 Received: from CO1PEPF000066EC.namprd05.prod.outlook.com (2603:10b6:a03:1f4:cafe::2e) by BY5PR20CA0013.outlook.office365.com (2603:10b6:a03:1f4::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.20 via Frontend Transport; Thu, 23 May 2024 07:41:07 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1PEPF000066EC.mail.protection.outlook.com (10.167.249.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7611.14 via Frontend Transport; Thu, 23 May 2024 07:41:07 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 23 May 2024 02:41:01 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 23 May 2024 02:41:01 -0500 Received: from henry-MS-7D54.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Thu, 23 May 2024 02:41:00 -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: d34da501-18d7-11ef-b4bb-af5377834399 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=X8xx40pf5Keh1b42FvaLrBPfygRwS+VlBg+4pTsdKe3/5zk4nHES1+k9oi3u2mVTJPO2rld5GoqAAHfBPBCZqCihVjTf8Ec3MQZuWIxrxlUfD/IrXGfrp2f3as9Q6SBfOB58run/nINP7IvutIjKp4NwkAdoSHWQj+q4pWFqBBU5gigCfobNgeWjdJ6oFvsNHi1jImBZAwgPrx6L+ELYrHnrDuOgH4ZxJPDjFH5dkrSpZnAYXcb5C4s6DNjutiejZSAcAfKr5oLmLQbz6gbYPblppVavrKc1ZakViO+w0BcJX6icO1nYeNZBIAPo4fuovImMA8RqWBkr8bRu3SSfNg== 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=da2DEjMTTPOqHs5JEHft5f2zNU/TKUOCNbSUhm9LjB0=; b=mJe/hsJJNhF9SfQulWbnW8YkZ51UUl+LS+LW9zlfazjX7EEK13nvmIsnqlw3dLjR+xF1bCUe9tO0BzNDt8svJckLgY9qdecfsN7B0Zot6c3I5HchUj5XsnaDybLHtb5hxBYLubL4r6wDCnMv4LXXZPYGEFZBIMtNVoi+R9szpFc1PbV1PulgxkT6u7hPEguLMKnkWpcemo8EU7pA6qE47jdIZDcfU7oXDPf3oQqXYVsIHmPimbtL/dkGsPnD7K/4qSBkBbCz/CJ5TLty9fTlctAGArW2gE0cl0MVXDeMjuR+LoXt62aKLrkiMozVxkEt/O+TI9ObnJN9/3jbCGOEJQ== 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 (0) 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=da2DEjMTTPOqHs5JEHft5f2zNU/TKUOCNbSUhm9LjB0=; b=Xdq9w1W82Bn0vuY6eT/+m7Ixhu5PytVvwZhlxWBg2SLQHyxj/d3M+f+I6XTMUXj7U6TXbb/iQy0tWCcx0EkK5NKziYi26jqNG/hWnJPqxc52tbxyMvEZHgL+iLb97Ne1e+v4NZvE8GNSsfBw82n61ZI8sVOl33bdhZAemF44NjM= 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=SATLEXMB04.amd.com; pr=C From: Henry Wang To: CC: Anthony PERARD , Juergen Gross , Henry Wang , Jason Andryuk Subject: [PATCH v4 8/9] tools: Introduce the "xl dt-overlay {attach,detach}" commands Date: Thu, 23 May 2024 15:40:39 +0800 Message-ID: <20240523074040.1611264-9-xin.wang2@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240523074040.1611264-1-xin.wang2@amd.com> References: <20240523074040.1611264-1-xin.wang2@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: None (SATLEXMB05.amd.com: xin.wang2@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000066EC:EE_|BL1PR12MB5804:EE_ X-MS-Office365-Filtering-Correlation-Id: 543ba5a1-7b6f-43ed-6a07-08dc7afbb558 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|36860700004|376005|82310400017|1800799015; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?thVannc2U8Dx/QzE1TkJBopXvcqv5OJO1x6Qv+15CEuSHxn6lj+eFTZmWNhz?= =?us-ascii?Q?kI3HTlMG/cd2WkdjXcht9nqn2OuqxzADHOpbEP2ajzRD9F2iyeVAvir42gb3?= =?us-ascii?Q?AIuo7mxkIBIRUOy4sXFqiecwP6OKOmGA18bbPgIJPseM2h/+r5KCNTpTCrwF?= =?us-ascii?Q?R0UYPrGVHd5EvPe21LPzv7gegeIgqDDf1PUDzGk+sqzEgb91KVzifAqG962m?= =?us-ascii?Q?H/R1fZnCaY1IC1fhxyU2wilKCjc7lGG3IPKgv7tNXgUb9iMcRkHDFCKYSD9M?= =?us-ascii?Q?RasR7Z7A8A5AVvIIB64YeaTwxX/RXgImQ//RiV4yzA7gPOFBywzl3y7CMRcw?= =?us-ascii?Q?QXWMEnWhI/LY4PacYosUfohypuvWYmOG1dW8OBPuBOsJz1i1KANjeMcfgp01?= =?us-ascii?Q?wdt0tCSQFfBpARNRbHghaN8DCpum8/bA3H1QsWlK3KnVz9GZDZJ8Bx8Vh/6Q?= =?us-ascii?Q?OGdtjJLXvyRwTCT6QVFYD+rIHn2PjPAkqewG1i4E19ybdX/jkUGTe2PlVXjW?= =?us-ascii?Q?7v73FajVGMOlgUf0d//LUoY/XCuYuGBezRKIJfMjq1gBSUUA4OS4M3av8cyY?= =?us-ascii?Q?zoqH8QU8CPNj7WHmitm+oibjs98hor4MrtVMtJEoVGL2i65eniSZDFlfbKem?= =?us-ascii?Q?dGuVce9BT+O9Ff8O5rovFCictvdzHNPToQlQ0snKJet8SHZNNIdaDNmn+0dR?= =?us-ascii?Q?YcytvDIp0pBlxabx003sb/5y7LzvTkutaH7BYcOMDRy+7ZoJKYPb8mOoc+hK?= =?us-ascii?Q?aEJC9gdUQr0X+fufjswffBO084hTxI8x1q/XykxT4ole9P5CxoS1sQCnQ8+R?= =?us-ascii?Q?MeFq4/UxErk/maNgJhUGxmP7Tw/RQWabOh7mRr3U7Y7FCvEADDv2ntUGPrKG?= =?us-ascii?Q?iFanZejcICUQPO7ma1KMy16F+YY92cZpx4ixLBUsTfveebLDgL9OmGxdqdP2?= =?us-ascii?Q?tYaQn3AuICSuZKyWTli1b3uQwvy+9Bpu5XM9CQODlOTz4XA/cEdz5uEO/c8N?= =?us-ascii?Q?+prTFj7MieelZIXNx36DU7l6F440XeVVOjrn4PhnvwNxj9iWsiWCfvI+3Z5Y?= =?us-ascii?Q?oHK/y+WK3x3AdArXQEydsUurLql9HWJq2gmCAPM9mlvMhV5ZMADX1M/aZaAy?= =?us-ascii?Q?2wbJnrg28UHI/WdVEL0Ib48QqrSSLKNClpCCuoIYXzBD9/dqmYm7y8aBXXJT?= =?us-ascii?Q?xuaYY+IH9m7ipSjCVpjji/G30Del/ThGG8HUOxj82i+5JE8TMivTO1vCR9mr?= =?us-ascii?Q?k5sOjfCJWqftfp4bWoQQpowEcYmciPhjXzvc8zi/u8mvfyiDB6xHcY0sncY7?= =?us-ascii?Q?LQU8nFNJ1g0a2NWaioe1Ej952p+sb/XW3c0syXKtMC9GOV9EYHCPXrg2wWKE?= =?us-ascii?Q?8k1J6rmIX3z/i3cmPMAF1GeSw/pn?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(36860700004)(376005)(82310400017)(1800799015);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 May 2024 07:41:07.6055 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 543ba5a1-7b6f-43ed-6a07-08dc7afbb558 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000066EC.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5804 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1716450099206100003 Content-Type: text/plain; charset="utf-8" With the XEN_DOMCTL_dt_overlay DOMCTL added, users should be able to attach/detach devices from the provided DT overlay to domains. Support this by introducing a new set of "xl dt-overlay" commands and related documentation, i.e. "xl dt-overlay {attach,detach}". Slightly rework the command option parsing logic. Signed-off-by: Henry Wang Reviewed-by: Jason Andryuk Reviewed-by: Stefano Stabellini --- v4: - Add Jason's Reviewed-by tag. v3: - Introduce new API libxl_dt_overlay_domain() and co., instead of reusing existing API libxl_dt_overlay(). - Add in-code comments for the LIBXL_DT_OVERLAY_* macros. - Use find_domain() to avoid getting domain_id from strtol(). v2: - New patch. --- tools/include/libxl.h | 10 +++++++ tools/include/xenctrl.h | 3 +++ tools/libs/ctrl/xc_dt_overlay.c | 31 +++++++++++++++++++++ tools/libs/light/libxl_dt_overlay.c | 28 +++++++++++++++++++ tools/xl/xl_cmdtable.c | 4 +-- tools/xl/xl_vmcontrol.c | 42 ++++++++++++++++++++--------- 6 files changed, 104 insertions(+), 14 deletions(-) diff --git a/tools/include/libxl.h b/tools/include/libxl.h index 62cb07dea6..6cc6d6bf6a 100644 --- a/tools/include/libxl.h +++ b/tools/include/libxl.h @@ -2549,8 +2549,18 @@ libxl_device_pci *libxl_device_pci_list(libxl_ctx *c= tx, uint32_t domid, void libxl_device_pci_list_free(libxl_device_pci* list, int num); =20 #if defined(__arm__) || defined(__aarch64__) +/* Values should keep consistent with the op from XEN_SYSCTL_dt_overlay */ +#define LIBXL_DT_OVERLAY_ADD 1 +#define LIBXL_DT_OVERLAY_REMOVE 2 int libxl_dt_overlay(libxl_ctx *ctx, void *overlay, uint32_t overlay_size, uint8_t overlay_op); + +/* Values should keep consistent with the op from XEN_DOMCTL_dt_overlay */ +#define LIBXL_DT_OVERLAY_DOMAIN_ATTACH 1 +#define LIBXL_DT_OVERLAY_DOMAIN_DETACH 2 +int libxl_dt_overlay_domain(libxl_ctx *ctx, uint32_t domain_id, + void *overlay_dt, uint32_t overlay_dt_size, + uint8_t overlay_op); #endif =20 /* diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h index 4996855944..9ceca0cffc 100644 --- a/tools/include/xenctrl.h +++ b/tools/include/xenctrl.h @@ -2657,6 +2657,9 @@ int xc_domain_cacheflush(xc_interface *xch, uint32_t = domid, #if defined(__arm__) || defined(__aarch64__) int xc_dt_overlay(xc_interface *xch, void *overlay_fdt, uint32_t overlay_fdt_size, uint8_t overlay_op); +int xc_dt_overlay_domain(xc_interface *xch, void *overlay_fdt, + uint32_t overlay_fdt_size, uint8_t overlay_op, + uint32_t domain_id); #endif =20 /* Compat shims */ diff --git a/tools/libs/ctrl/xc_dt_overlay.c b/tools/libs/ctrl/xc_dt_overla= y.c index c2224c4d15..ea1da522d1 100644 --- a/tools/libs/ctrl/xc_dt_overlay.c +++ b/tools/libs/ctrl/xc_dt_overlay.c @@ -48,3 +48,34 @@ err: =20 return err; } + +int xc_dt_overlay_domain(xc_interface *xch, void *overlay_fdt, + uint32_t overlay_fdt_size, uint8_t overlay_op, + uint32_t domain_id) +{ + int err; + struct xen_domctl domctl =3D { + .cmd =3D XEN_DOMCTL_dt_overlay, + .domain =3D domain_id, + .u.dt_overlay =3D { + .overlay_op =3D overlay_op, + .overlay_fdt_size =3D overlay_fdt_size, + } + }; + + DECLARE_HYPERCALL_BOUNCE(overlay_fdt, overlay_fdt_size, + XC_HYPERCALL_BUFFER_BOUNCE_IN); + + if ( (err =3D xc_hypercall_bounce_pre(xch, overlay_fdt)) ) + goto err; + + set_xen_guest_handle(domctl.u.dt_overlay.overlay_fdt, overlay_fdt); + + if ( (err =3D do_domctl(xch, &domctl)) !=3D 0 ) + PERROR("%s failed", __func__); + +err: + xc_hypercall_bounce_post(xch, overlay_fdt); + + return err; +} diff --git a/tools/libs/light/libxl_dt_overlay.c b/tools/libs/light/libxl_d= t_overlay.c index a6c709a6dc..00503b76bd 100644 --- a/tools/libs/light/libxl_dt_overlay.c +++ b/tools/libs/light/libxl_dt_overlay.c @@ -69,3 +69,31 @@ out: return rc; } =20 +int libxl_dt_overlay_domain(libxl_ctx *ctx, uint32_t domain_id, + void *overlay_dt, uint32_t overlay_dt_size, + uint8_t overlay_op) +{ + int rc; + int r; + GC_INIT(ctx); + + if (check_overlay_fdt(gc, overlay_dt, overlay_dt_size)) { + LOG(ERROR, "Overlay DTB check failed"); + rc =3D ERROR_FAIL; + goto out; + } else { + LOG(DEBUG, "Overlay DTB check passed"); + rc =3D 0; + } + + r =3D xc_dt_overlay_domain(ctx->xch, overlay_dt, overlay_dt_size, over= lay_op, + domain_id); + if (r) { + LOG(ERROR, "%s: Attaching/Detaching overlay dtb failed.", __func__= ); + rc =3D ERROR_FAIL; + } + +out: + GC_FREE; + return rc; +} diff --git a/tools/xl/xl_cmdtable.c b/tools/xl/xl_cmdtable.c index 1f3c6b5897..37770b20e3 100644 --- a/tools/xl/xl_cmdtable.c +++ b/tools/xl/xl_cmdtable.c @@ -634,8 +634,8 @@ const struct cmd_spec cmd_table[] =3D { #ifdef LIBXL_HAVE_DT_OVERLAY { "dt-overlay", &main_dt_overlay, 0, 1, - "Add/Remove a device tree overlay", - "add/remove <.dtbo>", + "Add/Remove a device tree overlay to Xen device tree, attach/detach = the device to a domain", + " <.dtbo> OR <.d= tbo> ", "-h print this help\n" }, #endif diff --git a/tools/xl/xl_vmcontrol.c b/tools/xl/xl_vmcontrol.c index 02575d5d36..ccfeec39f1 100644 --- a/tools/xl/xl_vmcontrol.c +++ b/tools/xl/xl_vmcontrol.c @@ -1268,32 +1268,46 @@ int main_create(int argc, char **argv) #ifdef LIBXL_HAVE_DT_OVERLAY int main_dt_overlay(int argc, char **argv) { - const char *overlay_ops =3D NULL; const char *overlay_config_file =3D NULL; void *overlay_dtb =3D NULL; int rc; uint8_t op; int overlay_dtb_size =3D 0; - const int overlay_add_op =3D 1; - const int overlay_remove_op =3D 2; + uint32_t domain_id =3D 0; + bool domain_op =3D false; =20 if (argc < 2) { help("dt-overlay"); return EXIT_FAILURE; } =20 - overlay_ops =3D argv[1]; - overlay_config_file =3D argv[2]; - - if (strcmp(overlay_ops, "add") =3D=3D 0) - op =3D overlay_add_op; - else if (strcmp(overlay_ops, "remove") =3D=3D 0) - op =3D overlay_remove_op; - else { + if (strcmp(argv[optind], "add") =3D=3D 0) + op =3D LIBXL_DT_OVERLAY_ADD; + else if (strcmp(argv[optind], "remove") =3D=3D 0) + op =3D LIBXL_DT_OVERLAY_REMOVE; + else if (strcmp(argv[optind], "attach") =3D=3D 0) { + op =3D LIBXL_DT_OVERLAY_DOMAIN_ATTACH; + domain_op =3D true; + } else if (strcmp(argv[optind], "detach") =3D=3D 0) { + op =3D LIBXL_DT_OVERLAY_DOMAIN_DETACH; + domain_op =3D true; + } else { fprintf(stderr, "Invalid dt overlay operation\n"); return EXIT_FAILURE; } =20 + overlay_config_file =3D argv[optind+1]; + + if (domain_op) { + if (argc <=3D optind + 2) { + fprintf(stderr, "Missing domain ID\n"); + help("dt-overlay"); + return EXIT_FAILURE; + } else { + domain_id =3D find_domain(argv[optind+2]); + } + } + if (overlay_config_file) { rc =3D libxl_read_file_contents(ctx, overlay_config_file, &overlay_dtb, &overlay_dtb_size); @@ -1309,7 +1323,11 @@ int main_dt_overlay(int argc, char **argv) return EXIT_FAILURE; } =20 - rc =3D libxl_dt_overlay(ctx, overlay_dtb, overlay_dtb_size, op); + if (!domain_op) + rc =3D libxl_dt_overlay(ctx, overlay_dtb, overlay_dtb_size, op); + else + rc =3D libxl_dt_overlay_domain(ctx, domain_id, overlay_dtb, + overlay_dtb_size, op); =20 free(overlay_dtb); =20 --=20 2.34.1 From nobody Fri Nov 22 13:30:37 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=1716450100; cv=pass; d=zohomail.com; s=zohoarc; b=mwhgbUHyeNHU+SX2uTuOdRWjhF4SER79zDwTH1Y9xfeIjobngVUWQRRd63joU6Z+24AcQAlc6PnDiZYklw0bJJ2aqk2ReRWofRiy7bFDG5RuKT6iYDaeENXwSdZSv7MzEno/p9jo9TfcZ9sUoi72spwtLuJJOAgKomkXASBX7a8= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716450100; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=j/FY1olHM2o9Q7bHo9+Dh+AEIc21S3KHBajG96rQ8uk=; b=irwZ0otQMh81wE/OZN/rrAbxRJf4Z7zGM8QsNb6ugI0KtdQLErLKvMkZzmTAewoPGUqrDqTBgr+B7wZ4ZW/N/78tIzxjW1tQVdindhkHUKXi+8qkzdbtZ3O/Ld9sDOZABOCCWy3O1HNO+QDhA4h1JpbnxxLsMzxLiWb0DgczJaE= 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 17164501002141005.8749197010685; Thu, 23 May 2024 00:41:40 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.728103.1132935 (Exim 4.92) (envelope-from ) id 1sA34Z-0003tQ-Bb; Thu, 23 May 2024 07:41:11 +0000 Received: by outflank-mailman (output) from mailman id 728103.1132935; Thu, 23 May 2024 07:41:11 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sA34Z-0003qF-6V; Thu, 23 May 2024 07:41:11 +0000 Received: by outflank-mailman (input) for mailman id 728103; Thu, 23 May 2024 07:41:10 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sA34Y-0003CF-A9 for xen-devel@lists.xenproject.org; Thu, 23 May 2024 07:41:10 +0000 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on20600.outbound.protection.outlook.com [2a01:111:f403:2409::600]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id d0c96977-18d7-11ef-b4bb-af5377834399; Thu, 23 May 2024 09:41:08 +0200 (CEST) Received: from CH3P220CA0028.NAMP220.PROD.OUTLOOK.COM (2603:10b6:610:1e8::6) by SN7PR12MB6839.namprd12.prod.outlook.com (2603:10b6:806:265::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.20; Thu, 23 May 2024 07:41:05 +0000 Received: from CH1PEPF0000AD78.namprd04.prod.outlook.com (2603:10b6:610:1e8:cafe::18) by CH3P220CA0028.outlook.office365.com (2603:10b6:610:1e8::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.34 via Frontend Transport; Thu, 23 May 2024 07:41:05 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by CH1PEPF0000AD78.mail.protection.outlook.com (10.167.244.56) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7611.14 via Frontend Transport; Thu, 23 May 2024 07:41:04 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) 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.2507.35; Thu, 23 May 2024 02:41:04 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 23 May 2024 02:41:03 -0500 Received: from henry-MS-7D54.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Thu, 23 May 2024 02:41:02 -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: d0c96977-18d7-11ef-b4bb-af5377834399 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UmbpJ0HsSwwe+NJUpclGR6c3RxCh0P/ps3q7wVmhSEmnerM6SjhVj4T8DmBqzUIOxdZCaFGy/JxMm5TMJKuD8mfFc8vuFqdG1gBPTvsRhuXntrSxXCQDmoZt93I9QZP3U9eDC+5IRtYS54gjXlucnPt7US4lj8wAp2EkvZZqwHcxxN529JgwfRGDUW+jgt7KhmQKO2UwcSMPDdDG0wFRO7eyK//VSWBBEAW4Lar472c3dCDy99V4Z8brmIjKtrteYzTke1PYNrpRwSu8Hpkk6NLgatfk+7GisFvpbh0PX1OGKCQowsyUzHVgEGvPd3XW0hyThy3ncy1sTCqzMxGXDA== 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=j/FY1olHM2o9Q7bHo9+Dh+AEIc21S3KHBajG96rQ8uk=; b=GPy/cb2Ftw3Aaur26qyqNTFgeN/2u3/9MbDFiK8zqiTGDu8z/U3UXiy+xE156kpxoww6NtAXwGjSYzHpaGnVFih5/AM3N5qAmQxri2sp/sMawJ70kQlZZOITfeJjcsgfL9x+17ZmbCqDUe+bRNNfG+Bxlg0f5SMM5ycOrF2dXi5Z+lcYgqKYdgoaIX1nqNLhep5icI569r9zgJtfy8QIiN97v9p9ny6swpaNc5plh/Vyt88HZTzjYLR8pTTYfRmK6bSFcE/mNVw38ZZsBN2pO+MAC1Rlc8tluB1uHB3U9ifaSRas4mr1oVNtwXgeBI0sioKpR8uoXcl8VJyhaBct0Q== 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 (0) 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=j/FY1olHM2o9Q7bHo9+Dh+AEIc21S3KHBajG96rQ8uk=; b=x0HF11Ut5J5qvqv8o8lEU9slHgbH7ylvjLio4m13+rUqwcw5DQOaMpbwJuuD2ekcKieCMX1FFGUIGm3rGm2GehLf1h+a8gbdtTbQPA07GGgH+NeozFcnEizPLZbROMy1obq8hJaxfGk39w5UH0RZGM9MiMBgCfSOaeuPceWy6RQ= 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: Henry Wang To: CC: Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk , Henry Wang Subject: [PATCH v4 9/9] docs: Add device tree overlay documentation Date: Thu, 23 May 2024 15:40:40 +0800 Message-ID: <20240523074040.1611264-10-xin.wang2@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240523074040.1611264-1-xin.wang2@amd.com> References: <20240523074040.1611264-1-xin.wang2@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: None (SATLEXMB05.amd.com: xin.wang2@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000AD78:EE_|SN7PR12MB6839:EE_ X-MS-Office365-Filtering-Correlation-Id: c8cfb63d-fa69-4f2c-610d-08dc7afbb381 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|82310400017|1800799015|376005|36860700004; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?x8MX7l7cJJXwKSNdmYB957qHQ8qn5KZnsPnXe83e9gpHl7382t3HE5Mc6QG/?= =?us-ascii?Q?gjk0ygz8Htq/J6xGJ6xR25aawR97fF04ipzWqCGogE9XKPLtcW9R65DOgcNS?= =?us-ascii?Q?Ng6kZiLd0NBfWPE1nOgNhYv4Acn+LQ30X/BZDdpDxR1N43GW2UJ/V4VM2WBr?= =?us-ascii?Q?7pexlZu1VnJ7Nwt8RRF4ebpSaiyBQ/sBJSaMXP98iChBsTADivoRHBqewBd0?= =?us-ascii?Q?f8IGq3JStb/bmhjKvvW1Byh1j1paIm/gNSQPXkrLYd8VuhoFjFzQ8U3vUBuX?= =?us-ascii?Q?wotU1G4DCHYK8i9VOcAGQbKPibC5keQHs4e/vI1Jk2t7NSHw22bIqf3yBrns?= =?us-ascii?Q?brdnnlbZONunHGV2WXw1FJ2gdymVnGNhg0i2S2S8MlgF3ybw0imC70Jp4AU9?= =?us-ascii?Q?fZ4PMvgGFYpHSg8HlgdOrN00L1LFOIRPm81XpzhOvI5hB9HJkomb2G+KrpSO?= =?us-ascii?Q?vaqQ4nHMBwsHhVSNxS+XJqwjOVFfWvbgiGGmXI0DlMUoyntQ084HHmOgyzPj?= =?us-ascii?Q?XeGHRYKakXMO1it4xLJQ/JAAQd8CgkH4/UDmVXKJlWoR+vNE3ZoCkDIXGQcU?= =?us-ascii?Q?u/XGefwmO9r7JWtkGuoVF1J+lvvi7/8JlwuHW7YCmigvhzUSIvBr/hauNDe4?= =?us-ascii?Q?fl8IA8uGlYCOI4q23OuyXOmmbG9Jfp8eUNKqk6+0w5XnONGKIIjZcKU5CZIJ?= =?us-ascii?Q?sobwK6OHVmq0K5GWPVnSqvpC5MD+CSHwDVsTH25Ygy73NTTELS1By8xmkdly?= =?us-ascii?Q?PqkopfgGLT4QXrPqkfEwySxJLEaouqCnQHN4rdrxfgwbmK7IcTm01xRtveWN?= =?us-ascii?Q?JlT2+e7MvtyU/IA34TM/OjLoLjD3dgnLmmgq77jlEOd8oaLBQ+DI7CjIMHIj?= =?us-ascii?Q?B7lq+sezpMfkttFNnJ2fF3zrbaR1Ny8JVV41ybcBYEy0nHXcgE1hhDSyHrIc?= =?us-ascii?Q?mclND3WqtrSbLE/teyjU2GvJ6h8rBgvQDki9pYQ9sIq/0x+0lTmBp28M3UVT?= =?us-ascii?Q?XP5QIfTvtnTC+VKGRpz0t582Z8+JZPmkvjoYbUvC3x9VRHlATxYhC6sCXZFA?= =?us-ascii?Q?JUWLdg6/sE/gqrku53hmK+WQrZTh85M1B5SRbjHdG02Kb7OM4Z0XRkgkxHnE?= =?us-ascii?Q?oEkyajwl3I3dQFyT681KgFK0zR1y1VwVKjmvQeArUqE2SAH56ibvfT/kO6tr?= =?us-ascii?Q?qSObuDRJwNQutbmhGWTEMBEbLt9EChCZo+nxBPISv//bX4VXANDhF1j3CVvg?= =?us-ascii?Q?F2Wi8jvPQQVXI68iLl395GobR9qF4F9n7E1FHDqw+mZ/8llJtmVwz/f0XDnn?= =?us-ascii?Q?qUNwoTfnCTotvjD0bxCuUg5i?= 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:(13230031)(82310400017)(1800799015)(376005)(36860700004);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 May 2024 07:41:04.5967 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c8cfb63d-fa69-4f2c-610d-08dc7afbb381 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: CH1PEPF0000AD78.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB6839 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1716450103249100001 Content-Type: text/plain; charset="utf-8" From: Vikram Garhwal Signed-off-by: Vikram Garhwal Signed-off-by: Stefano Stabellini Signed-off-by: Henry Wang --- v4: - No change. v3: - No change. v2: - Update the content based on the changes in this version. --- docs/misc/arm/overlay.txt | 99 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 docs/misc/arm/overlay.txt diff --git a/docs/misc/arm/overlay.txt b/docs/misc/arm/overlay.txt new file mode 100644 index 0000000000..811a6de369 --- /dev/null +++ b/docs/misc/arm/overlay.txt @@ -0,0 +1,99 @@ +# Device Tree Overlays support in Xen + +Xen now supports dynamic device assignment to running domains, +i.e. adding/removing nodes (using .dtbo) to/from Xen device tree, and +attaching/detaching them to/from a running domain with given $domid. + +Dynamic node assignment works in two steps: + +## Add/Remove device tree overlay to/from Xen device tree + +1. Xen tools check the dtbo given and parse all other user provided argume= nts +2. Xen tools pass the dtbo to Xen hypervisor via hypercall. +3. Xen hypervisor applies/removes the dtbo to/from Xen device tree. + +## Attach/Detach device from the DT overlay to/from domain + +1. Xen tools check the dtbo given and parse all other user provided argume= nts +2. Xen tools pass the dtbo to Xen hypervisor via hypercall. +3. Xen hypervisor attach/detach the device to/from the user-provided $domi= d by + mapping/unmapping node resources in the DT overlay. + +# Examples + +Here are a few examples on how to use it. + +## Dom0 device add + +For assigning a device tree overlay to Dom0, user should firstly properly +prepare the DT overlay. More information about device tree overlays can be +found in [1]. Then, in Dom0, enter the following: + + (dom0) xl dt-overlay add overlay.dtbo + +This will allocate the devices mentioned in overlay.dtbo to Xen device tre= e. + +To assign the newly added device from the dtbo to Dom0: + + (dom0) xl dt-overlay attach overlay.dtbo 0 + +Next, if the user wants to add the same device tree overlay to dom0 +Linux, execute the following: + + (dom0) mkdir -p /sys/kernel/config/device-tree/overlays/new_overlay + (dom0) cat overlay.dtbo > /sys/kernel/config/device-tree/overlays/new_= overlay/dtbo + +Finally if needed, the relevant Linux kernel drive can be loaded using: + + (dom0) modprobe module_name.ko + +## Dom0 device remove + +For removing the device from Dom0, first detach the device from Dom0: + + (dom0) xl dt-overlay detach overlay.dtbo 0 + +NOTE: The user is expected to unload any Linux kernel modules which +might be accessing the devices in overlay.dtbo before detach the device. +Detaching devices without unloading the modules might result in a crash. + +Then remove the overlay from Xen device tree: + + (dom0) xl dt-overlay remove overlay.dtbo + +## DomU device add/remove + +All the nodes in dtbo will be assigned to a domain; the user will need +to prepare the dtb for the domU. For example, the `interrupt-parent` prope= rty +of the DomU overlay should be changed to the Xen hardcoded value `0xfde8`. +Below assumes the properly written DomU dtbo is `overlay_domu.dtbo`. + +User will need to create the DomU with below properties properly configured +in the xl config file: +- `iomem` +- `passthrough` (if IOMMU is needed) + +User will also need to modprobe the relevant drivers. + +Example for domU device add: + + (dom0) xl dt-overlay add overlay.dtbo # If not executed bef= ore + (dom0) xl dt-overlay attach overlay.dtbo $domid + (dom0) xl console $domid # To access $domid co= nsole + +Next, if the user needs to modify/prepare the overlay.dtbo suitable for +the domU: + + (domU) mkdir -p /sys/kernel/config/device-tree/overlays/new_overlay + (domU) cat overlay_domu.dtbo > /sys/kernel/config/device-tree/overlays= /new_overlay/dtbo + +Finally, if needed, the relevant Linux kernel drive can be probed: + + (domU) modprobe module_name.ko + +Example for domU overlay remove: + + (dom0) xl dt-overlay detach overlay.dtbo $domid + (dom0) xl dt-overlay remove overlay.dtbo + +[1] https://www.kernel.org/doc/Documentation/devicetree/overlay-notes.txt --=20 2.34.1