From nobody Fri Nov 22 13:37:36 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=1716517136; cv=pass; d=zohomail.com; s=zohoarc; b=kXXI3CjyvfftTs5gpETejylVskiF/fqqHsoVOLSSRz31sC0vr8yUsMpzoTI8YVXCBezhDZlG9LvhHlCayo92ZAhv6kH6bYUlYiPmQJFnJbx0MDAZ31U5SlXI3zG95bkalYBEir+0cOM+fyZF12w0nSVVo17ML/jtGj5MvraWv40= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716517136; 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=DJzU+Lo23+pblv8U5ELG1eHDNPAMdYWdjjMuN9k4W2I=; b=OiE1CdnxedTObQQdT/zQ8Oyv4ETAYyW5LjPe1qLaSEohsLMN9S5NKyGYs7qgpz8e0xdRC8McJlbJxhUBQVv0HI7jKtzsCKNtMx2ZcCnGhDgT1Mhmfa3V93Lv4JiDgP0VjpCmRB0B+3MeJrBP/wv8YivbDt97v8p9gVUlwX14/Z0= 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 1716517136381359.14344421077783; Thu, 23 May 2024 19:18:56 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.728983.1134075 (Exim 4.92) (envelope-from ) id 1sAKW2-0003tx-5x; Fri, 24 May 2024 02:18:42 +0000 Received: by outflank-mailman (output) from mailman id 728983.1134075; Fri, 24 May 2024 02:18:42 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sAKW2-0003tq-3G; Fri, 24 May 2024 02:18:42 +0000 Received: by outflank-mailman (input) for mailman id 728983; Fri, 24 May 2024 02:18:40 +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 1sAKW0-0003tc-Gm for xen-devel@lists.xenproject.org; Fri, 24 May 2024 02:18:40 +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 ee6c294a-1973-11ef-90a1-e314d9c70b13; Fri, 24 May 2024 04:18:38 +0200 (CEST) Received: from MW4PR04CA0066.namprd04.prod.outlook.com (2603:10b6:303:6b::11) by CH3PR12MB7617.namprd12.prod.outlook.com (2603:10b6:610:140::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.22; Fri, 24 May 2024 02:18:33 +0000 Received: from CO1PEPF000075EF.namprd03.prod.outlook.com (2603:10b6:303:6b:cafe::f8) by MW4PR04CA0066.outlook.office365.com (2603:10b6:303:6b::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.22 via Frontend Transport; Fri, 24 May 2024 02:18:32 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by CO1PEPF000075EF.mail.protection.outlook.com (10.167.249.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7611.14 via Frontend Transport; Fri, 24 May 2024 02:18:32 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 23 May 2024 21:18:29 -0500 Received: from smtp.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Thu, 23 May 2024 21:18:28 -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: ee6c294a-1973-11ef-90a1-e314d9c70b13 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QfnTtZrjHcOZuTG1RV24o7aioszq+2i1wi9SL+VzVENbB1OeNZ0AVReOMnsIPL7G+l6OfoesjLxad6etSxq7qDsXuBPKYeL37r/s7b3WlnRAWgsUc9ZYMsNRV9ugD+vJL1YHwp8B594Lzxs58kumF2vDBpKJLOKAFaN1/w5y7kf2qTShZE7hf61jeU26aAw7xixiowl4mVovg3yoZbt2jazISTBv+Uu63VupuXgc7KdpmE5B38AcbSFIWAGRklt+H6KV1iKK9Vka4zXWgTYxdq/CzlQ9rGhx3z3lsKH7Ov1902M5cj2WhS3mbXSCY2/JsSCM4S9Vqs6n1AqnGzxbgA== 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=DJzU+Lo23+pblv8U5ELG1eHDNPAMdYWdjjMuN9k4W2I=; b=f9skBc+HMDg/vp2x+inOpaYSEwC5VF/9qu6pJBpF3dqnX9lLjmrSh761TqNmy7Plq8EuqiKnewY3lekPO/AqRnTarALX+2iwObvFLuT0pQcOBHDvlHhl2RfnIJU4FEnT8DnRKmdCOU9/341mVsPkkNNP5Vx3D9iMPCUYABOTqxgN8l6ha+UrKVqyPA5JVd0UG2EsHNN4Fhtw7ljOT4BL76P4/JNXOFE43jAh0wBSfNO2bttEHX9Bq257dJor6T8NIUwc/eaReYW9h88ZFpnA3nOrSSQze2jjOsqYNxDtqWCv5Z840kP/DLUEWIEpm4DKSkt0M1Kkz9Q+i1sYdXx7Eg== 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=DJzU+Lo23+pblv8U5ELG1eHDNPAMdYWdjjMuN9k4W2I=; b=OW9r2Ob3j4jAh6VUZ6GJ4nhym9xZtlIgNbhUhys/8sFSnl7nffFfL0dfXKWHYaNkz8csVIkjuxPxHC8GSOqqEQpPjpVNvvHMEoYWhX1PaYln64q29HhZJGUi0Z8EJnK76nwmzVuKFms9Jiz0W2gqXoDF8QeXFWceKscPNAG1ghA= 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: Stefano Stabellini To: CC: , , , , , , Henry Wang , Jason Andryuk Subject: [PATCH v5 1/7] tools/xl: Correct the help information and exit code of the dt-overlay command Date: Thu, 23 May 2024 19:18:08 -0700 Message-ID: <20240524021814.2666257-1-stefano.stabellini@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: None (SATLEXMB03.amd.com: stefano.stabellini@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000075EF:EE_|CH3PR12MB7617:EE_ X-MS-Office365-Filtering-Correlation-Id: bc86422b-143b-4581-7f6c-08dc7b97ceed X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|36860700004|82310400017|376005|1800799015; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?uaq+5J7VJsp1R+HKQxmoUH+RO6C2TKR545pzmUQ5G22Xks5xPqG5QpmK7hDp?= =?us-ascii?Q?DnE+47ejbwree+MPqGh2q7aFJpuyI6CAdwYxZiNqgZk6aw3CRW/IZKRa+Wy5?= =?us-ascii?Q?zgTdwnvd07jTcV/CQJuNjnbtQScsfrk6L89m15vxJ3YO2NAMFOvoBeHrcBWF?= =?us-ascii?Q?BmXmSqYEI4EIDx7PDQfpJ3bySZbhyd0nWpgiyD+ZXvRx3ucyLyzJDy7H11gd?= =?us-ascii?Q?VUyLiLb5zmwwcnQyo4dSUH7nJ3OnU1b8iblErzSLg70bJbneMyJmLOFF0HCx?= =?us-ascii?Q?LudUVN6P+z3w2cTYSBK3MzKoqdivGohF+UhhDeM3qL0LBUODHQ8ruWT68nz1?= =?us-ascii?Q?n0klytLuHcM7NvWzbTklciVyQpA6XVAotPCzgMFLHOrCgIQU+kewjz11t/8W?= =?us-ascii?Q?FpcgNKzElpvXGaUv9iQ9wWXHkMsQoJHuuGQKG/cG+03H48KNfdWRsE7h2kNN?= =?us-ascii?Q?BtGV9noCK9DV8T64UplMKb3/skKxl9tWBB0amY9Nne+/kFnkhb2wJY2Bn4XD?= =?us-ascii?Q?joiyHDt8CElj59v0/61Ri83FTzVD6bVO0/rYTbDMGH2LaroFfji6SRv0TRpY?= =?us-ascii?Q?/ShNzPnQPO6iIAyDCA4EccW3USmyePLTPPPGz4t7tLzIZZBExMXHysG8uL/3?= =?us-ascii?Q?qgPgqb/tdSkJBrO06k6ZWJQfpBi/UjiZ+RgWbk2j6L5+daPWsx208ZpEX9lb?= =?us-ascii?Q?MH7grKIDq9rQ0q/ag2ZYLVSFSlGCaInHfePx5GzSvfltWKCmCJfCmO1dcNLt?= =?us-ascii?Q?CgAkryECoTpGYzszNNNJup4bqBKbIMABLHqvZPSKJIIO8cWKiUjDj1jIhCg+?= =?us-ascii?Q?Y3c1swBDADy1xU5SAUKPn57nSIfT/YEaxHH2NlrhndEI3hrLEeqosJFGMTEX?= =?us-ascii?Q?VP3maKkX+kYuff0Lpe/mWj2hECW//sVQ7DRwaqvxAc1CO97VhD1z93uKO+lZ?= =?us-ascii?Q?nSDzHgdkePhPGmPnMkpNYnPToLtydCp+jWY4HkHT8RuoJAq2IKnet8+yKC7F?= =?us-ascii?Q?G7cDYuXrpZ6nEVU3J26Z02jyRZ9ZCNP9Z5RxtX29RMMyOb1cx3BDKW3/mCG9?= =?us-ascii?Q?+JRINt/HJr87Apmu7wKiUkVxxxSezDyJ6XwoXbbVBVfXn4CCSbzZXy24oZ+U?= =?us-ascii?Q?4rjuQfJ+UrJN9XkH5EHNa+phNgl/1lAUygTQZjOA/czT0tAz6t6ewHmr6TQ2?= =?us-ascii?Q?n4einKpOsSvh9bvQyshJFSUbzx8Yh4iP/2o78DEFEicQsHosuTlHzAplgaMT?= =?us-ascii?Q?7diX0j+KlDrA1VApnOPru+JxR2oINSGrEsx02GtM9GkXhUsxF9CieQQJDFNe?= =?us-ascii?Q?f9gvaXXqPXjKnRcKdalYijsLNQ43bDnPdEdLccK4BOk6L/br1yybMs6OOuwO?= =?us-ascii?Q?EPIF7l0=3D?= 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)(36860700004)(82310400017)(376005)(1800799015);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 May 2024 02:18:32.0310 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bc86422b-143b-4581-7f6c-08dc7b97ceed 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: CO1PEPF000075EF.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB7617 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1716517137986100001 Content-Type: text/plain; charset="utf-8" From: Henry Wang 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 --- 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.25.1 From nobody Fri Nov 22 13:37:36 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=1716517139; cv=pass; d=zohomail.com; s=zohoarc; b=WU1UozJiQFOv+J8Nux7Pd55F1Y8jk+mKPT9Ey3dd8zYsS06RzZ8D7vaRYYTs5ntrcUkIDZa+J28MkyKvb69js3uNS74uaqEWe6dhHgV0LF4izidMVJ3QKBqv9P5qHTVo9V+XTrH3XYk9VBMQK7QkQFbyf9OUuDdCnUYIOOHeMEc= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716517139; 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=xRJXSt/i9q6c1C8Y7abmDgKw7TBf2B9wiQ/rWE+b2Go=; b=Xa6xAJ8zIsE/WTtxY8XdJ9wldv3SR2SZi7LTyn8dXJyh9QRTR1n6BgbcED7AhpGsb3bF4aGRWcoH7bGyMue0QoqjfUbXUs4E0N8hDWccErNbRuJGJx7RXzIyHbvJhoscLLjYkHRRgtNMltPbcqeBoxA8DbdSYvHWEV4Ah6p4TbQ= 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 1716517139530417.71298983042175; Thu, 23 May 2024 19:18:59 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.728984.1134080 (Exim 4.92) (envelope-from ) id 1sAKW2-0003wS-E0; Fri, 24 May 2024 02:18:42 +0000 Received: by outflank-mailman (output) from mailman id 728984.1134080; Fri, 24 May 2024 02:18:42 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sAKW2-0003vW-9M; Fri, 24 May 2024 02:18:42 +0000 Received: by outflank-mailman (input) for mailman id 728984; Fri, 24 May 2024 02:18:40 +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 1sAKW0-0003tc-Nt for xen-devel@lists.xenproject.org; Fri, 24 May 2024 02:18:40 +0000 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on20600.outbound.protection.outlook.com [2a01:111:f403:2418::600]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id ee563b6e-1973-11ef-90a1-e314d9c70b13; Fri, 24 May 2024 04:18:39 +0200 (CEST) Received: from MW4PR04CA0088.namprd04.prod.outlook.com (2603:10b6:303:6b::33) by DS0PR12MB6629.namprd12.prod.outlook.com (2603:10b6:8:d3::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.22; Fri, 24 May 2024 02:18:35 +0000 Received: from CO1PEPF000075EF.namprd03.prod.outlook.com (2603:10b6:303:6b:cafe::57) by MW4PR04CA0088.outlook.office365.com (2603:10b6:303:6b::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.22 via Frontend Transport; Fri, 24 May 2024 02:18:33 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by CO1PEPF000075EF.mail.protection.outlook.com (10.167.249.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7611.14 via Frontend Transport; Fri, 24 May 2024 02:18:33 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 23 May 2024 21:18:30 -0500 Received: from smtp.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Thu, 23 May 2024 21:18:29 -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: ee563b6e-1973-11ef-90a1-e314d9c70b13 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j3WIzEpIHCPlXtoXUXhyn/HedDkRCrCvBT/QC58XOqfNHcZ03lmY6cm+XorMsd9+SVcQ6Ar4IBTc5D1nUIETuu88KwH7rqpxbspJXNqqHEBn9n7hrOLu170rfMy5dgsbZrUXPYF3VuSofJsgPKpjhsFr6API/kr8E3uXxyX8ai2BYhZinzGYFMETz4jHYkbbr07EbqBi1+mFfDZ/8akekNhCN2tOYE5nuS3plGJ1cg22t5XZbnO5agCHeBRKKa/VtAyH08jAQ2Fuy0Qm9GUkKGqPBax3wM33K3ReECjYTBV8rlizs5RWEdVxsvFGvZw+fD63WfDf4xshF0XUgHVO/g== 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=xRJXSt/i9q6c1C8Y7abmDgKw7TBf2B9wiQ/rWE+b2Go=; b=CG63nlEYG1l25gWL8g6nobKFBpKDm4Sd8VuOGcj/t2NKQvTRrkcAy5E4Whj+1FxnfblkZWhoyStb/3Xvx8HQKTihkwJLdvhttNr53VbANBZoY5c81bFdXCXdGEiMaktQ7Zbesyk8wg8RvJOe8cNApdCLqNIn/xpcQBVzyGsBsinF+qDPuyszjMH2x17i1whbtV44F7/FYC70Gb4rbKObBWBH2NNSZVovEneBGbDCyAHbG8nlIONaVAVK4m49nP31cyJXiqr5XE2IY4TiKeabIy+zYaMSvGySaCTX91udGXpa6PzUkRTJBSteUMgf3e+hNpxyIrIu1PXymPb2odJukA== 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=xRJXSt/i9q6c1C8Y7abmDgKw7TBf2B9wiQ/rWE+b2Go=; b=zjhRv5QNzmd6ikViC6Ww2u9xJ9EPI9RXq1n8ziDkhHxZLw5bz99FBgkkRJ4kXPTz+33n3Z+4hlBxl1fifi9E7rptnZUqtuvUpvi0J6EL4PE5i8ougj+X0PdIOu/QOJ6wMY3ND4SzM6uRU5bBzDo4fW/7ihfaF1v0Pt2QKQb1MkA= 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: Stefano Stabellini To: CC: , , , , , , Henry Wang , Julien Grall Subject: [PATCH v5 2/7] xen/arm, doc: Add a DT property to specify IOMMU for Dom0less domUs Date: Thu, 23 May 2024 19:18:09 -0700 Message-ID: <20240524021814.2666257-2-stefano.stabellini@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: None (SATLEXMB03.amd.com: stefano.stabellini@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000075EF:EE_|DS0PR12MB6629:EE_ X-MS-Office365-Filtering-Correlation-Id: d30934c1-8e23-4436-4e62-08dc7b97cfbf 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?ZhWZs+o9k/4kk5rtRKSY62PMffnLmD5TNjCHCUppI8IrLmLkm0MQSao8twv3?= =?us-ascii?Q?v/M8mREIxzJKLtxT+fd/R9xS/vDnzL5rxyPlYTpbEten4/YspKOHqhUPoNiZ?= =?us-ascii?Q?ZYwB+AJIjgA02ixesTg+HSlgSX/XdrHqYfJf+3pImFS5j6FRu8QYPWJFdIHp?= =?us-ascii?Q?PDwQn2iXrD+FaU0bGVzkomDuXhPdgEHjtuwY2EPDhC03MY74frnXwAY/J6pz?= =?us-ascii?Q?WlrjgRqG16NDJWMDn2F0x3T4m3cOTVABJ/go4/Spdbi2gxD6bx0TY+R926oR?= =?us-ascii?Q?2IrwbsV6JDO56Ggg2xRG3GJZ3joFAbcVx4YJNeYU76or6tLQiL5CbndFCKFL?= =?us-ascii?Q?tqdDwtd/P+Gdxvb91SvNzuMb5Aqy82ccai38e8BwBzNW5x80UtvmLDWq+s3Q?= =?us-ascii?Q?+8+7b7wNr3unv3tBxDXWzYLqhp+XPk+5mtIM3fh/fy1bn92UeN6d0VZEvPM/?= =?us-ascii?Q?Y2GE3ZTzqAVyptCBe7OdPLOVbKp5EzPR1GcQ4ErOK5vHoAMl1SmKmor7A2KQ?= =?us-ascii?Q?ZLQfqr/nva9Q3Y8fQCtyrbvQ9UlZUPFjfN6hV3FDPuFwd2B3RNxgrbIZajJa?= =?us-ascii?Q?O5tZaJVIq1f3ZcbpBCc28olOOCY4+LSxGiBuuOi1RckddiVk961rR4lCLn1i?= =?us-ascii?Q?xOtLTeQnrYuXVrpE3Ebu/isr0QQibxK0+Pdq3FRJHIe0tW9UufUEY/6Q2FEI?= =?us-ascii?Q?X1Qvp9aRinAJUBm+CLO516Fv5jhJvgfAxIF9KtFOadu6z4XUfYJyiuhehQxf?= =?us-ascii?Q?ZRsnLmTSmjZStQYRbU44H9SIoNzrY8wt31RohdG/hm4kA+bp649lPo3Je6Ul?= =?us-ascii?Q?/IUOGeIaCdboCdT6UHtv96EtDdY3WZiOZ6VrsprnAkYvrkhBcdOapZdnl8U+?= =?us-ascii?Q?otR0KGob++MrgNOn8XDmwI3etKXNeVDJVy73b8GpjVwig3NbPXLY3hlgRgOU?= =?us-ascii?Q?iXZC+eevJ4AbsKKA22xq9kM4P8KHC1rlaHng4QZcfMR03a0dIsYiMQQfJIK8?= =?us-ascii?Q?cjBVWEmXU7Y3McZ7iLKtmnHcZg1YpZs3P6ckme0/F39+MvCUfL5PMF7lWH6z?= =?us-ascii?Q?wVTof09EeBCRnw7oqFvY5GZyyLv1QE8ZiPFxhMQ1ftkoBS7IBdFbxwsFr1fv?= =?us-ascii?Q?/wUkdNNsupJv2moe40FCWG+7XHob7LI3JdWxdj2solkxk2th/rdaQCxufZw4?= =?us-ascii?Q?qPhVMSWYjnxkEQcFVfQ1nX2I+iMXt4wlOBAo8mgqPEvtYdblPOd2WxQntlL/?= =?us-ascii?Q?a/2NvEoEl49qZGiZnR1a21SZnk5Snc0fFE0e99rhf9vsRT0rETwjKex0Mox0?= =?us-ascii?Q?AvzgcU0eYtdYtjqC+RiLo3QI0IzErkIoGwAWa220Q3ZJDSg1IoHMQWIEiZRW?= =?us-ascii?Q?u5Q7CZC78OW5yojAaPlJPNBnWPqH?= 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: 24 May 2024 02:18:33.4060 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d30934c1-8e23-4436-4e62-08dc7b97cfbf 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: CO1PEPF000075EF.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB6629 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1716517139944100003 Content-Type: text/plain; charset="utf-8" From: Henry Wang 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 --- 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.25.1 From nobody Fri Nov 22 13:37:36 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=1716517141; cv=pass; d=zohomail.com; s=zohoarc; b=GNu/xtsUmDBTxDpAJ840RCGNZnc8QWH2TzYjdS5OCFp4NfrzvQrTYfAnbpu56cex7g6dSFCBd1I6S/Ms8pq6eL3A1nBtMr/Vnb+B8LqsDCkXW7g2l9NN7dByJAruwwiH/ctpB3PwcuxBs+oUZ5/oSt3LeQ6fLP6H30Sk/2FuKT4= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716517141; 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=0mNtauRAgY1rxPk1todAfJ8ZkfStKgBmhTiRwKw4AV4=; b=X3Yfse8WbmSq7UcHcRjn2YFh7J1l45BHyUDH6AzZq4PEQtOdSeo723cvybvhv5ziBip9tAVIPaAJgfD5HUHPO7jyWX6r55hVrOfW0ctsHWZSVpOLPfpaxq3DMHsHzKb2z1HBtCCwQFttw+hZttG0uuWhxpoAF/zMLECNp84tLEY= 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 1716517141828289.0585670371423; Thu, 23 May 2024 19:19:01 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.728986.1134103 (Exim 4.92) (envelope-from ) id 1sAKW5-0004Rs-7U; Fri, 24 May 2024 02:18:45 +0000 Received: by outflank-mailman (output) from mailman id 728986.1134103; Fri, 24 May 2024 02:18:45 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sAKW5-0004Qj-02; Fri, 24 May 2024 02:18:45 +0000 Received: by outflank-mailman (input) for mailman id 728986; Fri, 24 May 2024 02:18:43 +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 1sAKW3-0004I4-I9 for xen-devel@lists.xenproject.org; Fri, 24 May 2024 02:18:43 +0000 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on20600.outbound.protection.outlook.com [2a01:111:f403:2417::600]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id ef6d3d0c-1973-11ef-b4bb-af5377834399; Fri, 24 May 2024 04:18:41 +0200 (CEST) Received: from MW4PR04CA0087.namprd04.prod.outlook.com (2603:10b6:303:6b::32) by CH3PR12MB9341.namprd12.prod.outlook.com (2603:10b6:610:1cd::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.22; Fri, 24 May 2024 02:18:36 +0000 Received: from CO1PEPF000075EF.namprd03.prod.outlook.com (2603:10b6:303:6b:cafe::58) by MW4PR04CA0087.outlook.office365.com (2603:10b6:303:6b::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.20 via Frontend Transport; Fri, 24 May 2024 02:18:36 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by CO1PEPF000075EF.mail.protection.outlook.com (10.167.249.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7611.14 via Frontend Transport; Fri, 24 May 2024 02:18:36 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 23 May 2024 21:18:31 -0500 Received: from smtp.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Thu, 23 May 2024 21:18:30 -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: ef6d3d0c-1973-11ef-b4bb-af5377834399 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jZ1cVyFSk45uNtO4JrLahA3+fbml3QYQGvxMfv7PlKKRMWX9MGtHcvRMPr7jnd4qchyQpGkg2y9vYpWBF/qwMZxYNptbD3dbsjtqpcTZdaDdEBN3tQXhyPKzSmEooGARLivQ+y4hKBJhbvA4oYp9AmUqaEtDVvhMUrakTgXDLArP3sji41u6X3l67JofKRzyot5QmWPXH5XjluWfeT88rzRcJ1Mcvm65yKoH1O5NPLoUd2NgZY1YkwraduWypRhPzAh7lSorZY39Wm/n20HYE2gmLvaGqBuWuvrbOArFtMy56FtxvQitrLekh20M1dddzPFz9VkoqCwCBkDVPFwH7A== 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=0mNtauRAgY1rxPk1todAfJ8ZkfStKgBmhTiRwKw4AV4=; b=BWZrqlIqrIxiKqV6e+GcVw2sR19dpRDtWWzNGbK/4h09inHRlIf0lWYL4z2/yt2qnvXbCNp+tW2pP/hdeEDq/EPVYBwQ3QXdaYtsS+0gJQA3/+9T7ZgxSzUk5grnJIwThfwA+wdTAyguTsjq9XYS24Kl9zhzhyCo+iooMmmmZy0OeH8u2yxW5IbZmYyn19+ijU6/gS+/9ZMBrFriKYDCm4SVxEDjvOL2ttkSbWimuqbcjc1jlk2mdoqrsZSBx7e4Ssxw9RQ1cB9UJelfa0RXxvnmeRwbXs66PTQGuXY6uH7PRz50eWgZGemfw9NkMOzr7Z08fTcjVPI8SRsvJWM7cw== 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=0mNtauRAgY1rxPk1todAfJ8ZkfStKgBmhTiRwKw4AV4=; b=WjLVyQOMxWRcT3Z7Uoh7cQgmq6ZMIfqxqguqpuJ+QivQuyx2+P/zI7B/Am596KkRSES/Vyt5f0WvWXc8mBIXdFNSe77iCAcxsOtejttJ0hsl3La/6anEcokRfYOfJNb/nXalpBR7hZN8OH4dKcZylYrVS6pmSyrfrnTFsae2wuw= 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: Stefano Stabellini To: CC: , , , , , , Henry Wang , "Stefano Stabellini" , Jason Andryuk Subject: [PATCH v5 3/7] tools/arm: Introduce the "nr_spis" xl config entry Date: Thu, 23 May 2024 19:18:10 -0700 Message-ID: <20240524021814.2666257-3-stefano.stabellini@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: None (SATLEXMB03.amd.com: stefano.stabellini@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000075EF:EE_|CH3PR12MB9341:EE_ X-MS-Office365-Filtering-Correlation-Id: 0533cb20-300c-4f3c-9cf6-08dc7b97d173 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|82310400017|1800799015|36860700004|376005; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?xvzB2S8Mdd/V1lOkTCHoHsYjbP8BJ82IUoJz4SG44qqujlM/JeEmeg/o4hWK?= =?us-ascii?Q?jOUEOXhgOOOt98smd6i/4mfeYcM7TWc+D5dG3t65waDdDu3icSO/y3UfnSVy?= =?us-ascii?Q?1CVPp6Bo0ntXNfregaD8ZmjkvD1mY3bT5oi8ODXDQscq1UPST2AuOEjqanyI?= =?us-ascii?Q?SqhL8Q5fC7pKJSsZO4q04UEwOxB2Cmv/eS9BrQksOjKFzSM0hxBkyaisU2eE?= =?us-ascii?Q?4t2pIEuXT/YRXERnaWznhEsGh5C8I3kvFO2E/zBi8OGOlCfNQSOr8egoYnTf?= =?us-ascii?Q?DYuzGxz+u7l+HwkzOYDaQYoyIu5eTv7FS2ztk6EXGVXMc4LcnWC4MUrTMCpx?= =?us-ascii?Q?uDDjo4Fo0lmXiprdWzOCOy7qQQDDtDMNQjyiNp1inkvv1FIOVrydzgu7ZrcT?= =?us-ascii?Q?fR85vlT02Cfj6X/VKjDSOfgywu0Qk/+qltZhVGe7G+Nz7wAclhFBX7GN0o5z?= =?us-ascii?Q?Q9zAw2khbYv5iqzz/sFEITNPFIs78rgLctOxM1MW59Tw7DkkF3mWMu37jjI2?= =?us-ascii?Q?+9uaBoREG4xB8sND7RKhxgSwQAJOr6cu0Qqn/LLablqVNdi6QN57crfeA7fh?= =?us-ascii?Q?JsPLdNLS1K6yiym8GXSr/xEUVBoxkYgH9Ye8hdTXTWMNHuZEXTVFG4PwMjTQ?= =?us-ascii?Q?+nsP9Xo4cTM5BwsjyZFxbxNrCqZkrbNLHjDc5P7i1KpW+8r5ftcsyphDuPIb?= =?us-ascii?Q?w35C6OxktiV6Qd0CqG39INMB49QoAYgUW1DUqylXbYt+nrIBk80XyMzz2WPI?= =?us-ascii?Q?AdwhBmf6tUgLJeLr7MMu086V4CJJplYl4lPji7dojF+dQU9jjZsXGOnxPzOr?= =?us-ascii?Q?+K92pAezFiDT9l4JGpjnqJMmr94wwgBGlVpX0sDeMfkgAQWYoqM7CzTCKUva?= =?us-ascii?Q?6As87XSQVqnveykz2hItApdOCYZ00e54NvQoNe8B8A0NVmhHRpvd1go1EVWR?= =?us-ascii?Q?PYmBravb0PFbmAEQD8APkAhnWR5/Eb+Qv5YtMLJM69PcGhOsQ0yNUPesrD/E?= =?us-ascii?Q?hQusKKbHN4/0Vb2zGzDGS+Dxx/PDujFxifLrrbiJ7J4t8RueB7Er9Sh6L0RC?= =?us-ascii?Q?StGMhrHQDI4LyUqmuZCKk3Q0IIt5L2EFkFECSWt5XY3pp19W6QAIDyj8N1sK?= =?us-ascii?Q?bdOcvM58KN57KL2OWN6xqF+1WjV7nzpUgAB2v591BLCFRORrIC6q4zyIqLYe?= =?us-ascii?Q?Jib9lZ8VBrpWUMNFdNRiAnT9uhTYdSS03TvFVn/IquK726zV+t+CgYIfgKLS?= =?us-ascii?Q?iJC3qkE4tifNkJUS0ZmQDGP9Rd0QVbdELO2uUOkEZo3/O82oFBV+ZlR/VqF7?= =?us-ascii?Q?6Bp/D6tUY63IcCIxo0oO/GjEpKmm0Oxsn9kNWYLPr7iYl3Y+Cu2RnMJeWQEx?= =?us-ascii?Q?D4+l13/EOahBPH0nDw/+lLeMnWYH?= 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)(36860700004)(376005);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 May 2024 02:18:36.2498 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0533cb20-300c-4f3c-9cf6-08dc7b97d173 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: CO1PEPF000075EF.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB9341 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1716517141964100005 Content-Type: text/plain; charset="utf-8" From: Henry Wang 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 Signed-off-by: Stefano Stabellini Reviewed-by: Jason Andryuk --- docs/man/xl.cfg.5.pod.in | 16 ++++++++++++++++ tools/golang/xenlight/helpers.gen.go | 2 ++ tools/golang/xenlight/types.gen.go | 1 + tools/include/libxl.h | 7 +++++++ tools/libs/light/libxl_arm.c | 4 ++-- tools/libs/light/libxl_types.idl | 1 + tools/xl/xl_parse.c | 3 +++ 7 files changed, 32 insertions(+), 2 deletions(-) diff --git a/docs/man/xl.cfg.5.pod.in b/docs/man/xl.cfg.5.pod.in index 8f2b375ce9..ac3f88fd57 100644 --- a/docs/man/xl.cfg.5.pod.in +++ b/docs/man/xl.cfg.5.pod.in @@ -3072,6 +3072,22 @@ raised. =20 =3Dback =20 +=3Dover 4 + +=3Ditem B + +An optional integer parameter specifying the number of SPIs (Shared +Peripheral Interrupts) to allocate for the domain. Max is 991 SPIs. If +the value specified by the `nr_spis` parameter is smaller than the +number of SPIs calculated by the 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. +The number of SPIs should match the highest interrupt ID that will be +assigned to the domain. + +=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/include/libxl.h b/tools/include/libxl.h index 62cb07dea6..3b5c18b48b 100644 --- a/tools/include/libxl.h +++ b/tools/include/libxl.h @@ -636,6 +636,13 @@ */ #define LIBXL_HAVE_XEN_9PFS 1 =20 +/* + * LIBXL_HAVE_NR_SPIS indicates the presence of the nr_spis field in + * libxl_domain_build_info that specifies the number of SPIs interrupts + * for the guest. + */ +#define LIBXL_HAVE_NR_SPIS 1 + /* * libxl memory management * 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.25.1 From nobody Fri Nov 22 13:37:36 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=1716517143; cv=pass; d=zohomail.com; s=zohoarc; b=Fl87FwZVL5vPGXwlMZb5CcKv/dNg84gBLNEsRNWqd+wBiMG3bE53q6zn8rC14cxVTclC69Gdkd9OetUz2OJCRN/S0EqfQiHhjsv2Lec+rhw61PlmtowDefTwRl3+HMd61FjQUc81l6P0EToWp/M/ENODEbVGcxsswWzh+Wcsta0= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716517143; 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=dUxLvykGPrn0TdFclj7NWwLQlt3XRena1NmCNYfl8WY=; b=HdRcA1p32Tkns8h7muRu/llCjurZG/QU2S7paQ9e7BmyrvSzwZV0p00GWl4hgJMnPMlKxwJnvt4K2UnSABsQXwCxJSnkBU1WTrH1/o9JrdNws0kctrj3Wqaa5Aq9SUV2SpNLCHhXZvPE/ZkJccPxMVnWs6qX6eyQazl2qTpR5wU= 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 1716517143181446.56268914519467; Thu, 23 May 2024 19:19:03 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.728985.1134095 (Exim 4.92) (envelope-from ) id 1sAKW4-0004Oh-Qz; Fri, 24 May 2024 02:18:44 +0000 Received: by outflank-mailman (output) from mailman id 728985.1134095; Fri, 24 May 2024 02:18:44 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sAKW4-0004OY-O3; Fri, 24 May 2024 02:18:44 +0000 Received: by outflank-mailman (input) for mailman id 728985; Fri, 24 May 2024 02:18:43 +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 1sAKW3-0003tc-Aw for xen-devel@lists.xenproject.org; Fri, 24 May 2024 02:18:43 +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 f02977bf-1973-11ef-90a1-e314d9c70b13; Fri, 24 May 2024 04:18:42 +0200 (CEST) Received: from MW4PR04CA0078.namprd04.prod.outlook.com (2603:10b6:303:6b::23) by PH7PR12MB9202.namprd12.prod.outlook.com (2603:10b6:510:2ef::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.19; Fri, 24 May 2024 02:18:37 +0000 Received: from CO1PEPF000075EF.namprd03.prod.outlook.com (2603:10b6:303:6b:cafe::5e) by MW4PR04CA0078.outlook.office365.com (2603:10b6:303:6b::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.22 via Frontend Transport; Fri, 24 May 2024 02:18:36 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by CO1PEPF000075EF.mail.protection.outlook.com (10.167.249.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7611.14 via Frontend Transport; Fri, 24 May 2024 02:18:36 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 23 May 2024 21:18:32 -0500 Received: from smtp.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Thu, 23 May 2024 21:18:31 -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: f02977bf-1973-11ef-90a1-e314d9c70b13 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=K+oOt94oKv7T9anVoojoQ2aQupFhYcyms6MN4ZJUxkgGKyV7SOeL1eoG1czNxiDCT3Wv41uE/WssM3QHtG1HYsJmBvxeXnRav7esw0ITS8cExVKmPsGyNGTAABMOEGv9JsOczd17BLY24gqdG8zlype73oh12aWAHfIX/mf79DrtEWoy37H+Gk+QFw2Gdqx9f9O7V2uYEtXw7chSTLSNcjcopqKJ2bvHUApbpFOpYFTCGm/WYJkorgHAiuYrTSNF+i9OcCyoPZ2PV29wAcfzjAY6tQogjuyDvT4+b6phGoyuPJPgOkr8C/A1q5bZeZ9vDFgEg1w0b2Vvj1PRuoOiTQ== 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=dUxLvykGPrn0TdFclj7NWwLQlt3XRena1NmCNYfl8WY=; b=kOHAkf8zFzgffGuktIgxoefAhdk7IO3sZwPyYyrQEZtfy6CphD985vHT2HIVG1Rve4b4cRcKdxQMJvbPDGDbiP7ZeGOUxItXDkulg1tjRDuVF8YMVBWczd55daSr5mzzWqtvr7P3ubKdyPIkHowD7B2HUx8esZSNRdgYvOCgcBr3eibBgnXPzYI53ow5wknpvp/rGAZnYJSNYs9G3bEpEq6qRVh+Dm5Iy+gG9hHrQWYhanWatm19yP6eKEpaSaiAYmuw4DN4F1V+C8oHyqpEbq/UbKDNArXv+0J0biTVT5Fjykh2ZnIoltmuNxmk6JGjsrCvvn4H5i7ed0vyc5BtQw== 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=dUxLvykGPrn0TdFclj7NWwLQlt3XRena1NmCNYfl8WY=; b=xNoUp4SBKWr0BOsbJwkmTaOnbTNp6wYpQjmn3AdCAvG08lon9xk40uOTwGl8f4DjnMzH4k/6jdLl10EiRXcIoGvscVRT4BJKLEVC82K4mD+oPk4Z91zjqsUSXH0y3u7pmZi7YSRl6oNs/oljEIkqxxrkAoIc0E/2Z2u6Ge8W3JM= 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: Stefano Stabellini To: CC: , , , , , , Henry Wang , "Stefano Stabellini" , Julien Grall Subject: [PATCH v5 4/7] xen/arm/gic: Allow adding interrupt to running VMs Date: Thu, 23 May 2024 19:18:11 -0700 Message-ID: <20240524021814.2666257-4-stefano.stabellini@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: None (SATLEXMB03.amd.com: stefano.stabellini@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000075EF:EE_|PH7PR12MB9202:EE_ X-MS-Office365-Filtering-Correlation-Id: 6ea84ffd-f719-4948-71b9-08dc7b97d1c9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|36860700004|1800799015|376005|82310400017; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?5Kfs9OGs6EUji5agDbShs9dUhfuVFkFUkPASr4/FE9kDWmBylwHxf2AnAG2Q?= =?us-ascii?Q?EHxqTwSng8cZMvmoqbpdhMdSgX4httlMo9Kh8P0xU5Hhh1kM1LudrjUyjKrj?= =?us-ascii?Q?CZyT72h8XUyLPFbQQeDGK5D6iQAuXd70FOtthS+r815pbM+e19tRslRO0b9A?= =?us-ascii?Q?SThM2jNAbjPN0diH4p4JWInRcC2uEWTupT87amcXdDeCF6qefNBoDtJCQpuK?= =?us-ascii?Q?6M8H7ms4/Ib/CGtKYBd9CwdHNrMTIzDIq9hun0z4KMSi5NHce2ry61KxRGVV?= =?us-ascii?Q?JRWHwNgQmLasYHI1mgm2Rb5rUhz10dfzWFeGZ3iFWpvdJtaO+WxYzIPX89NU?= =?us-ascii?Q?BMGIaZfxfSQRsSl9OD8PCYJZIlKBHrhvViYwJWbFjWZNeFDQHgbkt8O8UbIN?= =?us-ascii?Q?wEOxx/HK7r2Pl/s50965EgK8OMoq6k4DnDGCLNsmoLv/NrDAIi81qVdHtZBe?= =?us-ascii?Q?Fc86+jzSygvLXxSqzzI2nPdm63vxgrHmCO/ZZH55LD84CWPDo1BK0MfaeQga?= =?us-ascii?Q?s7QurGFQpSE+ca9k43licMmDctNuOPTXgEN+NVWOtLPthvVh389vucFdGHla?= =?us-ascii?Q?6XtIMSLhUf9fquyJYIhBr1IhnI9Ufv0u+ftV1T4SXLcy8DwSw1qSQuazzPbl?= =?us-ascii?Q?KLBUDE/I8SDYHG/qMk+YXLFV7PP2/nySjI55hhnMdGfx97JQAQ+CftYsy3bA?= =?us-ascii?Q?Leb96KISCwmue/xSswO0D9t8XDZYcddOFOqYrHxR5FhfLgWir8IaMoPHL78f?= =?us-ascii?Q?NysTlhpIpNed1yBf+F49z86vJjm3xqCXAAWIssdu9chmEJccGwfSzGKkK+Z1?= =?us-ascii?Q?x+Y7Gpm5JFAgDZdFStcKZvpfhwfDRFa6S19LRGYhX5BB+efqQsnljHzgyavD?= =?us-ascii?Q?BmqHNoQVCb2cFFKc3/XNvozVaeT+poQwmur8S/vnPCsrX2wPNTuluUd/irx6?= =?us-ascii?Q?Xzc1xb4+JZ5qBZZPykLN7SIG1oXBFTZalE2eNelPkxQxMtYPsdl/7UbT1k8i?= =?us-ascii?Q?51dVd2RGamVfWXIBKicmbQAHrzGqLj8pHYTKeZ6sqckQ6Mj9i4wj2ivmcgHV?= =?us-ascii?Q?hOMY5t4YKvwdNuTY/0EyLH1tZidxZ9fHH6cxVhmW+p0ujDk7DVfKAgtZhrst?= =?us-ascii?Q?LCp/9St9xoIRnCcp6JhRsyYpoR71scN1qVj5DJMKB7/2KOmiKu1iYdRiMXqq?= =?us-ascii?Q?xifCS2geNMDxRAA9Od7C+ljLWb+pAp6sxk5orf0A1/Z3N2pFRcMOIwSL7pAM?= =?us-ascii?Q?YxO3pXjEnQKHudUsO/qpfwxH5G8BO6M+oRXYFOoFzycDMIM3CjBVJpgd0LBo?= =?us-ascii?Q?wGOtMMTSZaPrsZIUS+6V1ZfWaza8vFKCSkqoOcWUg3TfYjLxJwhXL3fr3WJU?= =?us-ascii?Q?ZqCO7vAGaPXMMwDcZSg+gfDim3Xv?= 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)(36860700004)(1800799015)(376005)(82310400017);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 May 2024 02:18:36.8123 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6ea84ffd-f719-4948-71b9-08dc7b97d1c9 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: CO1PEPF000075EF.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB9202 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1716517143996100001 Content-Type: text/plain; charset="utf-8" From: Henry Wang 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 Signed-off-by: Stefano Stabellini Reviewed-by: Julien Grall --- 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..6cabd0496d 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.25.1 From nobody Fri Nov 22 13:37:36 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=1716517145; cv=pass; d=zohomail.com; s=zohoarc; b=SP3+u4TC/rOSNiyKE5PFAGJ6uhL8d0Il/U8ZdjNLDZbflr9dZ2AWrDw6L1ASGvVpPmAuxmjhvp85Ty30/EupV5XN2FX6Bq4dK5i1JUqxZLZQf+uETHwZCqaSl5rdadmT4tnU+RRW8/TpfEYvUaJlNcilhdNuSmGXYNSOdbCY0Ng= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716517145; 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=6RAlekm6oSAtsD1z/+65lehwcriofxvGBLLV+0kmPzI=; b=forQsBUr50p9SWRAJ+cPb9Y6YzqngYEISN9MPX+XHQMA9P1vGf0tHWrtu7ErCr0A5PboQID+l5pqC4cLFYshDqRppSSljFXSvWSx1SVNlEDZi4MpXQ7COJKCI2hQbvTeXyl75NpDMsNH+tdgEE1Z/jmWvhP8+9GQCRVhomDv6cs= 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 1716517145385221.63471130706534; Thu, 23 May 2024 19:19:05 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.728987.1134108 (Exim 4.92) (envelope-from ) id 1sAKW5-0004ZQ-Ix; Fri, 24 May 2024 02:18:45 +0000 Received: by outflank-mailman (output) from mailman id 728987.1134108; Fri, 24 May 2024 02:18:45 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sAKW5-0004Wz-CA; Fri, 24 May 2024 02:18:45 +0000 Received: by outflank-mailman (input) for mailman id 728987; Fri, 24 May 2024 02:18:44 +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 1sAKW4-0004I4-8L for xen-devel@lists.xenproject.org; Fri, 24 May 2024 02:18:44 +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 ef9c251e-1973-11ef-b4bb-af5377834399; Fri, 24 May 2024 04:18:41 +0200 (CEST) Received: from MW4PR04CA0086.namprd04.prod.outlook.com (2603:10b6:303:6b::31) by CH3PR12MB8234.namprd12.prod.outlook.com (2603:10b6:610:125::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.22; Fri, 24 May 2024 02:18:38 +0000 Received: from CO1PEPF000075EF.namprd03.prod.outlook.com (2603:10b6:303:6b:cafe::b4) by MW4PR04CA0086.outlook.office365.com (2603:10b6:303:6b::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.20 via Frontend Transport; Fri, 24 May 2024 02:18:37 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by CO1PEPF000075EF.mail.protection.outlook.com (10.167.249.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7611.14 via Frontend Transport; Fri, 24 May 2024 02:18:37 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 23 May 2024 21:18:33 -0500 Received: from smtp.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Thu, 23 May 2024 21:18:32 -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: ef9c251e-1973-11ef-b4bb-af5377834399 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SiHs1HzmOyszYoEjU5xOTYRtzcqcrgOvQv3lyrAS2kF2ddF+EBMyhi4SGPld5fX9NBqynMypFD+FoqqnerlmE6pY2Urr2sYXe++KBH5A7dyscbS+8QEQHonzZcvnWOQ40tjLRE+q+MR8fUxllHvMWxEwiBnltuQLxia746T5LTNhaqAknGmVgXTr3YmsoZ/XIU3//CunJ+MGAXJs2cuKhpVCwjn2g1cA5VWKXLX3bJDpqqQKkFjKBUyp5YJHN3Z1AWcvUuwCoLyaDSxdziodumkJ2TlijLezdKIdx4B0WXT+DMI57ZD53sdnTMrkyhqI833Dz5L0iR9mJ1yH3oqOww== 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=6RAlekm6oSAtsD1z/+65lehwcriofxvGBLLV+0kmPzI=; b=Q1YqmJMlKiPu4Tr2tfKYtCac+6uWrH1bKBGMK6nCNKbNSiDq4wKVXp+scGj8DAmdGqykntLmtWH6yOx7rYytGUDT8jhQJR3+hM3SgjLTLBrqzXNA71I+VMWAvTB62N5zm+r/5v6oDAjAQErcq8uEZUuvic7e/23oEyh7fQie/4F+fjf/hh7Yr3x1KVqccZG1+xxKVal2VC3ilhyF1M4nH7464bZuVHfitR9aY1MyofoX1ZagX+Up+ZVC3zzTjEPzXsQt55tID7mtZWewW+BJ7Ga6UeclYYIwHdK5yPlaIeEB/89LFm4ra3anF93BCD9BVxnKaEwybYzQjt+O3ZlZqA== 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=6RAlekm6oSAtsD1z/+65lehwcriofxvGBLLV+0kmPzI=; b=AdOkzR2v7KN7omCEqZMBSj8Z0o66l7aJaYZBThUqIRVe8oZWy1L1Q4UT6zDhnSZppCyZf9lmh22d+tvqmmGKERkrPk5RD25eMgm6A/E9B32Qx1sRyGUBxMjx7NSn0cdO0pdtU/LIhLfdb/I9/sh4Ie/dy041kp2gEYKIdnWMRLI= 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: Stefano Stabellini To: CC: , , , , , , Henry Wang , Vikram Garhwal , Stefano Stabellini Subject: [PATCH v5 5/7] xen/arm: Add XEN_DOMCTL_dt_overlay and device attachment to domains Date: Thu, 23 May 2024 19:18:12 -0700 Message-ID: <20240524021814.2666257-5-stefano.stabellini@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: None (SATLEXMB03.amd.com: stefano.stabellini@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000075EF:EE_|CH3PR12MB8234:EE_ X-MS-Office365-Filtering-Correlation-Id: 243daead-779b-4673-ba46-08dc7b97d253 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?jf2NIh+QHSzWhLOFWQJGnQ9Z+seGPhGnO1JTOS03Z3WEPNElMpQYSDmxVudX?= =?us-ascii?Q?1c3rumi27SXYS81SPkzfuR0V7L0MuLtVmEdV8SRtTMqnzeChFQqbweHgAh9r?= =?us-ascii?Q?8+Xsg3TsG7FUAvwppaRP8ZulIkPpKjrJ/KC1eF2aC0zqiURfmYMFtqLX09SC?= =?us-ascii?Q?vJ54+XKwBaDGOuXVNdy3y8QFo5/eFInZl1Xc0IniX3etGCkU+s20oueH6UsS?= =?us-ascii?Q?+f2TUN2kDExJzF+Oz4sIn4HJa1DK2yL/aCJK7atDcdUaKcSL97jx47gCKWBA?= =?us-ascii?Q?hSL38997nUGG2IzhKvnvnW0Datej0sYbLmCDNby/O6wRYnIv51S14fK4rGGF?= =?us-ascii?Q?QOkL0PUXDcn72zgpybkQ6bI5L4aB1Tev7vbr1sktbcYTNsBlEV8OcochhDve?= =?us-ascii?Q?Av3/iLq1u2IBrGj4rRaelEkVOlKowOxbJi+gQ05ev7CwF0d6XIMlNElBEOrM?= =?us-ascii?Q?aRtkIq8POGhGwymlL7S9zDFmR4B+VuF+mp71Y41+rjlmJhFh50U1WFG/XerI?= =?us-ascii?Q?bafgSa6IhUG+unWS53iWCDUbyjRT8Ztalh6Y/hYpMbTl22F+RiaT9aecj35T?= =?us-ascii?Q?BDhlzTEFbr/tuOADL55K1qbQC1zcyCFFVbjQRoFXhNIahnXFJVJ+cjWBRzrH?= =?us-ascii?Q?P81QBATf1Dzeem+0FMaCm/2tgXgQCL5LMY7bojFa2wnQd7GHaBYFlT/yn7wm?= =?us-ascii?Q?r70Cb/ZbIXLiVvAxVRF0QHxsKh1UrQobR0RyFsykouArtPFXP0ZfQujS5Li7?= =?us-ascii?Q?CVgUKJal87hmbSVxHGhUFFc65vewmgafibHWNitQgZKLe9rms2MUP0NwB7Aq?= =?us-ascii?Q?F96HeNhnpW/L9UyuLodTTIdCb89N2YMeI2QGIegupVdIuxW0CNL8J0T5ONJp?= =?us-ascii?Q?5PdkaNib/qUT2XqdzZOHysCFu4n2iYHDF2nmGgrszIDlDFT9fglsbxu/yb6d?= =?us-ascii?Q?ZQsJveGA/95mQlHZBahohToDk3pKLOlbGuPYBEtLxSREvJtWpwctz52Wq2G0?= =?us-ascii?Q?yAAJOljCS5xuwoTJMR7EfnBuYeLL9wgLNIC9I5mxmZvNbkCUjDI0HM40T77b?= =?us-ascii?Q?06eJjiobD9P/h3o8i/aJmw0HNsfFRcmiQoUJPOksHHkT+G3iVR2AC0mewfAs?= =?us-ascii?Q?1H2QXKcs4V8NEvIUQczmJ6fSEjNhQaF5gJ+XZ5S4Rwh8Y/FCL0ySHXhWWI39?= =?us-ascii?Q?/Lb5ze7q9ppN9bMRxlgIZ4zJyFkyvFq641ljmfQ/vkeY6QdErqt5HaunC77U?= =?us-ascii?Q?acD4KcsLcBWMGWO2rGmGplOoBX5RJ+juXB+n/ZNXUlDbCgMmYadbjvmhBNZm?= =?us-ascii?Q?af/DnyGgClAIhc6eqyc9RGPLK6VafrCU+jRbohoa2VkGrBDrtjt23ItkGzbs?= =?us-ascii?Q?9EHA7qs=3D?= 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)(1800799015)(36860700004)(376005)(82310400017);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 May 2024 02:18:37.7342 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 243daead-779b-4673-ba46-08dc7b97d253 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: CO1PEPF000075EF.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8234 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1716517146009100003 Content-Type: text/plain; charset="utf-8" From: Henry Wang 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. It is OK to change the sysctl behavior as this feature is experimental so changing sysctl behavior and breaking compatibility is OK. 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. All devices in the overlay are assigned to a single domain. Also take the opportunity to make one coding style fix in sysctl.h. xen,reg is to be used to handle non-1:1 mappings but it is currently unsupported. Signed-off-by: Henry Wang Signed-off-by: Vikram Garhwal Signed-off-by: Stefano Stabellini --- xen/arch/arm/domctl.c | 3 + xen/common/dt-overlay.c | 207 ++++++++++++++++++++++++++--------- xen/include/public/domctl.h | 16 ++- xen/include/public/sysctl.h | 11 +- xen/include/xen/dt-overlay.h | 8 ++ 5 files changed, 186 insertions(+), 59 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..c2b03865a7 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,89 @@ 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, len; + 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; + } + + if ( dt_get_property(overlay_node, "xen,reg", &len) ) + { + printk(XENLOG_ERR "xen,reg not supported yet in overlay\n"); + rc =3D -EOPNOTSUPP; + 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 +957,44 @@ 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); + else + ret =3D -EOPNOTSUPP; + + 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..6cd39ea46d 100644 --- a/xen/include/public/domctl.h +++ b/xen/include/public/domctl.h @@ -21,7 +21,7 @@ #include "hvm/save.h" #include "memory.h" =20 -#define XEN_DOMCTL_INTERFACE_VERSION 0x00000016 +#define XEN_DOMCTL_INTERFACE_VERSION 0x00000017 =20 /* * NB. xen_domctl.domain is an IN/OUT parameter for this operation. @@ -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..b2cedf3f2a 100644 --- a/xen/include/xen/dt-overlay.h +++ b/xen/include/xen/dt-overlay.h @@ -39,15 +39,23 @@ 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.25.1 From nobody Fri Nov 22 13:37:36 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=1716517148; cv=pass; d=zohomail.com; s=zohoarc; b=CJj1TV7xUOy4nWq7zisqKzP38Zl8rF22sn1hq/JDkhM8XKYxLKxm+ToeFDQF6tx3zsfXAhrvPtY0hkZozQxEbLbb/5wmd+ZdYdHoVFev4D6/GhcN7VykaPeYCUIznNeF9iR2AAQvQUbnfxwFnGau2GdydQnKhN8xd4gw2D5mQsE= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716517148; 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=NSERoOa3ZYR0kdpGTWAKdhvJ11sFwvda7ns+AIDXeNI=; b=KZCkwU0NwrUgWUtw7n3fYYa5UMUoJaY2a3JlquAC92Uk5XiK0ogg0zmi5A5QoJ4ymVAy23Qk0KFki4e5sr0aVqCCrKVqUAwp9QxFU1ttzxkJ7tEP/VLpbfTkJ5ZrtwcGAjibj7/ZTuxXNKDeRJ441vMV2PkmttfgsfcxctTUncA= 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 1716517148139674.9891874303178; Thu, 23 May 2024 19:19:08 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.728988.1134126 (Exim 4.92) (envelope-from ) id 1sAKW8-0005D2-50; Fri, 24 May 2024 02:18:48 +0000 Received: by outflank-mailman (output) from mailman id 728988.1134126; Fri, 24 May 2024 02:18:48 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sAKW7-0005Cn-W3; Fri, 24 May 2024 02:18:48 +0000 Received: by outflank-mailman (input) for mailman id 728988; Fri, 24 May 2024 02:18:46 +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 1sAKW6-0003tc-NW for xen-devel@lists.xenproject.org; Fri, 24 May 2024 02:18:46 +0000 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on20600.outbound.protection.outlook.com [2a01:111:f403:2405::600]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id f23483f6-1973-11ef-90a1-e314d9c70b13; Fri, 24 May 2024 04:18:45 +0200 (CEST) Received: from MW4PR04CA0064.namprd04.prod.outlook.com (2603:10b6:303:6b::9) by DS0PR12MB6416.namprd12.prod.outlook.com (2603:10b6:8:cb::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.22; Fri, 24 May 2024 02:18:39 +0000 Received: from CO1PEPF000075EF.namprd03.prod.outlook.com (2603:10b6:303:6b:cafe::46) by MW4PR04CA0064.outlook.office365.com (2603:10b6:303:6b::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.22 via Frontend Transport; Fri, 24 May 2024 02:18:38 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by CO1PEPF000075EF.mail.protection.outlook.com (10.167.249.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7611.14 via Frontend Transport; Fri, 24 May 2024 02:18:38 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 23 May 2024 21:18:34 -0500 Received: from smtp.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Thu, 23 May 2024 21:18:33 -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: f23483f6-1973-11ef-90a1-e314d9c70b13 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PLhI1eeIczr16i9d20o6T+a6XaXi7/1BvgoIwx9TlY7RjjQ63/qVEKaZ4c6RPO7NttTdlrygJM+MzoSxi5e5L+w0uwUXm379IvVVfrbck6PbxG9pqTHfUn2ayR7uhWT94BMtdTvFvs83AHHa6YJiPIj2Pxf2OyZNmUZYRNShTvXy26/IogGrMuoyuZFQ2fE8W13lgzM7A9bYiCCfjBY7IOxYUnWg7doXQ5mYKs78yYwsUcCc5KPmZfAcwRc7rQYGTjqnugNkk0cX76+gBlk7rzvabLsjB8vX0eOJgkkGPGZrk6U0tHI+GUIRnjRTVAvDcV7cNi6G1AAfdFD6bd09/A== 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=NSERoOa3ZYR0kdpGTWAKdhvJ11sFwvda7ns+AIDXeNI=; b=KFj9jB2Qs2LWNHaInMWOjQQLSCZVJJjfbm4qjSOzI7n/isvjAeVe0RzfDZ7nzkoV3POy0A+KCE9CVFRlROUeH5aS4D4uuknHY45DFl/sncd14Nc7W5uJFQvjvMpCiXREltn1PBt0tjrI+ygY2hviqQZO7yVKB/61fHWKo6/kIxqnANPci1sN/NYp7xFy3auszkfj+IKZdxxrmYc2HTcs/AXIYiDWtXxJNyGDA8HjErYfeMy5wdhpqX09VVGvLm+UfOYJ0pRXH1Zj1O1HI7eCLrAoz/k15VLtQ+epN9rPXck0pSdnWLB58K9/JKqjMU1KABXDOMqPiLsuRmfkG/FeSw== 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=NSERoOa3ZYR0kdpGTWAKdhvJ11sFwvda7ns+AIDXeNI=; b=PxV+7V2MZooKFL0Z6fO1O0fZHCxBywvWQslCIL6Bvca9qw01BcFQrnkuio2tOd5InENv6ITPh3jvpMG6EeFk30gLs5TMzT6KwHsX5A13JxSjzCfGyqllOoJShU+jhbz58F6gv/3lcmMF4LwnYEpRX9kFYZedwBm5nWXFOMtPaNo= 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: Stefano Stabellini To: CC: , , , , , , Henry Wang , "Stefano Stabellini" , Jason Andryuk Subject: [PATCH v5 6/7] tools: Introduce the "xl dt-overlay attach" command Date: Thu, 23 May 2024 19:18:13 -0700 Message-ID: <20240524021814.2666257-6-stefano.stabellini@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: None (SATLEXMB03.amd.com: stefano.stabellini@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000075EF:EE_|DS0PR12MB6416:EE_ X-MS-Office365-Filtering-Correlation-Id: 1539460b-d240-48f7-9f12-08dc7b97d2fa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|82310400017|1800799015|36860700004|376005; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?A4L37uh5lyCQVNYh7YmEKmcKs+6lWcOekLbFMJmHJGZLCPY8VQoy1DpeXhYS?= =?us-ascii?Q?VfcCFGwC9f2FJNhJBnPyqiR5t3r8kFjT+dj5ZWiWx94pHPcSt+WCcpGL3oQe?= =?us-ascii?Q?IM9FG9O8+kFfyQoW5QRljeieWDJyHEoRVWLFJ9xtSJ1jw/V8N0sq08II9ISt?= =?us-ascii?Q?Kxzppd2vVXTq+Qx/wabjFb1kotBKwT8osrG9DgaO8Z97L9IidVj5OZqTqoE9?= =?us-ascii?Q?PLOodMTVAYwil2D+u2M8M0K0HyZVoFHXgKBLfB0ykilwJjTY+UDL92UTZmwH?= =?us-ascii?Q?pp0B2zt738Tb4cY+8CM1xGpw0blWyUc5uxku8ZOHJe1OWK3bLPZqurivCga0?= =?us-ascii?Q?+iKB9/b2zyygw3rAu78K8CDTTay9hvbfj/MHhtqqS3dJCGDW05eSFrmXuiMf?= =?us-ascii?Q?DQMgPsBqo5Hfzati6I2yFFSAYPH4HFswIfZWutWda6T7PNBLDQ3zWg1e6wU3?= =?us-ascii?Q?CMedWUjpbdTRnUoVckynMjnBPOWI+vhFtVjvTIt09F8ZLFlCOCaTzCSNamfB?= =?us-ascii?Q?kAqu/H4ACooVZ6kIAz3Ng2w1DalwJNmRKuuRzN4AP/ueLVs2Exv+qFN8X5Oz?= =?us-ascii?Q?4clyBphgKC/Nkn/90iwjhSt687HXlQ9deliZxAQa2q105eYgW1SPoNg8uvER?= =?us-ascii?Q?5CI2Wbw94lK3wI41n7cqgj2vaVfuTpxV5jUl+a9MZpIvc5QkXHs5UHqii8OV?= =?us-ascii?Q?L3Em1rbBUbaIzdxgc8nWyin7wC3R61033js9VUZG/Gl+gK1UsV2P4IpTihsi?= =?us-ascii?Q?dS26AoOFo5SvovKzqZTnEthTWmbEWI1N4EG1RIg8rENHt9qSTfqh3wy8uNbG?= =?us-ascii?Q?xDjngG955lpz5gt2gA1h5ZGLD/xxeAvt9Eo6YEFbETnE87n+2aJdQ86jAEUM?= =?us-ascii?Q?95FZ/ZdXKEdp/VzAqMmrYXi2hnq5expsP79qxmOF36IWIQpele5QcWBJyOOp?= =?us-ascii?Q?dquOFdpv7zmGM7ecjw4RSD+nsEXyjcz3WXFFgJh4ra/q1MXlXUfe/OiKBg5F?= =?us-ascii?Q?6zRdShIVcRdjjui2gNqodxUAc+4rNjry8PTuhCvAa7rKTh8vA5HERZl2AWwg?= =?us-ascii?Q?gDpHEXRkHdGk4BswE2kO54OSbUB+UzAtL++Pqe8Uldzb2NPcPRwe1TFbgTpw?= =?us-ascii?Q?YaN2+Sy4y0M4nvl5+5lsBGGbxKfQj1xR8Msj5WTQhsWrXVH/LjLy/fWs3gJF?= =?us-ascii?Q?Gf/rx2KXfP3mYaMD+wSEOy6Jsp6WVJH6ahp3c29OPdua8RxporAPst0lm2Yl?= =?us-ascii?Q?XYP1wxM+UfgZWrnUIoaKi9BeQu3bAQtYT7s6qRooiuo6de7Hez1e7GW91fw4?= =?us-ascii?Q?YyFRIR8jVWdPAyYxuib2Q3ZmSq9dEsiDEVG+aOlxkqTE+Ot0yx1PLWv48qRO?= =?us-ascii?Q?1RdMF/CaobzpIIUbbPiw3jLFyBTK?= 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)(36860700004)(376005);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 May 2024 02:18:38.8123 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1539460b-d240-48f7-9f12-08dc7b97d2fa 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: CO1PEPF000075EF.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB6416 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1716517150155100001 Content-Type: text/plain; charset="utf-8" From: Henry Wang With the XEN_DOMCTL_dt_overlay DOMCTL added, users should be able to attach (in the future also detach) devices from the provided DT overlay to domains. Support this by introducing a new "xl dt-overlay" command and related documentation, i.e. "xl dt-overlay attach. Slightly rework the command option parsing logic. Signed-off-by: Henry Wang Signed-off-by: Stefano Stabellini Reviewed-by: Jason Andryuk Reviewed-by: Stefano Stabellini --- tools/include/libxl.h | 15 +++++++++++ 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 | 39 ++++++++++++++++++++--------- 6 files changed, 106 insertions(+), 14 deletions(-) diff --git a/tools/include/libxl.h b/tools/include/libxl.h index 3b5c18b48b..f2e19ec592 100644 --- a/tools/include/libxl.h +++ b/tools/include/libxl.h @@ -643,6 +643,12 @@ */ #define LIBXL_HAVE_NR_SPIS 1 =20 +/* + * LIBXL_HAVE_OVERLAY_DOMAIN indicates the presence of + * libxl_dt_overlay_domain. + */ +#define LIBXL_HAVE_OVERLAY_DOMAIN 1 + /* * libxl memory management * @@ -2556,8 +2562,17 @@ 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 +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..42751228c1 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 <.dtbo> ", "-h print this help\n" }, #endif diff --git a/tools/xl/xl_vmcontrol.c b/tools/xl/xl_vmcontrol.c index 02575d5d36..fa1a4420e3 100644 --- a/tools/xl/xl_vmcontrol.c +++ b/tools/xl/xl_vmcontrol.c @@ -1268,32 +1268,43 @@ 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 { 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 +1320,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.25.1 From nobody Fri Nov 22 13:37:36 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=1716517146; cv=pass; d=zohomail.com; s=zohoarc; b=Ef1sNCPj6bMGeijv8uwvuA6xaWPpqUlQ6RWnSTLGAt8fEzE+STtJZydRotwe5LQu6FEtBQJP/sU9FWWsoSJnvXMStmZ3zWZDrt2GXMGIkAd7fltEe5lek7hzoTTU/laJyiYxoxzgCpE3WgITGY1fSGYRETHF56Z86rbEKQbFg14= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716517146; 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=spfuWcKUhy4IpKgxdQbUBhNNhHU158grwSfyfQ+eUYo=; b=JK04+vqfVE5mayaCiFr4ALGn+gfN1VlVvml/xo7UJC5TV+GmhyR5Qx6KmKprsrh4cyAFOy5yDlCD9/gcXnwYmzvPQG1hhcxrTCSwoOMUsE7/umsJD4Jh5yRIdiG8e4NQ0vPfJGuw6hiHdwyvTT1zbn4Lmi7y03slbYGuQWShhWs= 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 1716517146583191.12413583824912; Thu, 23 May 2024 19:19:06 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.728989.1134129 (Exim 4.92) (envelope-from ) id 1sAKW8-0005GH-F9; Fri, 24 May 2024 02:18:48 +0000 Received: by outflank-mailman (output) from mailman id 728989.1134129; Fri, 24 May 2024 02:18:48 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sAKW8-0005Ew-9O; Fri, 24 May 2024 02:18:48 +0000 Received: by outflank-mailman (input) for mailman id 728989; Fri, 24 May 2024 02:18:47 +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 1sAKW7-0004I4-DO for xen-devel@lists.xenproject.org; Fri, 24 May 2024 02:18:47 +0000 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on20600.outbound.protection.outlook.com [2a01:111:f403:240a::600]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id f19a7382-1973-11ef-b4bb-af5377834399; Fri, 24 May 2024 04:18:45 +0200 (CEST) Received: from BN1PR13CA0028.namprd13.prod.outlook.com (2603:10b6:408:e2::33) by SA3PR12MB7808.namprd12.prod.outlook.com (2603:10b6:806:31b::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.22; Fri, 24 May 2024 02:18:40 +0000 Received: from BN3PEPF0000B374.namprd21.prod.outlook.com (2603:10b6:408:e2:cafe::71) by BN1PR13CA0028.outlook.office365.com (2603:10b6:408:e2::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.5 via Frontend Transport; Fri, 24 May 2024 02:18:40 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by BN3PEPF0000B374.mail.protection.outlook.com (10.167.243.171) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7633.0 via Frontend Transport; Fri, 24 May 2024 02:18:38 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) 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 21:18:35 -0500 Received: from smtp.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Thu, 23 May 2024 21:18:34 -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: f19a7382-1973-11ef-b4bb-af5377834399 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Fs3ERBiqLH43cXK4d92rJTJk5XKoqn/N9iAZyMIGSBTo5kAMwcidPAxPDhubgzub6ENMkj+OhIYrwIi0ReCD258Dp2yEagpUf8fn1iEXO84D01rJimDzpNZ5/3b0tx7K05rd+TiaO2izJq1ovDCDZ5vDb1pPM5TCnWhkTWftQp7gT/O3IPrdm9f86mkd31ZXF2aCJZVCLFKfvIPLXtWQbAA861nOnCagd9EG1gs2hhC1SvjM9zW7XCr+VROOTjcVrMsNyzBxxbqasfIuhy+FoyvOT3HPYTLpH/VQ5nxICfUyruFvcpWdFNyxJyPNglhwtOC/8P7t6M58ZqPzRn7opQ== 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=spfuWcKUhy4IpKgxdQbUBhNNhHU158grwSfyfQ+eUYo=; b=HYKmb8aI6KtNvlloVTSrsMxCRN8LKkj0H3Gjb3IhMghKn/0ldjNg9siSvVAUbyDcBZQgTjXiVRwBym+u0X7EzkXUlJ8MrYsgwhBlIgJPlHs7YnnN9ZasgyoTX2DQxcuNteUzKSj5avlVla+C1YgVEtajPqftWoTkqqfhVJA00lh20l9p5tMgU5B9VtrvTeBydgcBoEA+S91O4DLhk2FReLf3ZYYU7iJeXvf8NoTB7GPQIJ4NEcc83zOVHgOHfQ+T5f/K3P8nhLMpvOzJ2vSF9FZ7xOC+9J5NeiaO8ZmEzZbfdB9hZdl7r6yoTKDNMrVT8qHKolD973086XctB1v0NA== 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=spfuWcKUhy4IpKgxdQbUBhNNhHU158grwSfyfQ+eUYo=; b=qgUa3GAcc0X79CF2OsHLFWP/KK341C23/WpjuZEUvrTlsGHnln3bYg5KILYth5xNqjQ1bSuZgdLU9nhxR43hXbJBFiIj3eK5nQuwBQmuL3Inxf2+JI2jKGbDvpg4UZf+ZfDxS8c2lA+IsuslAMk/N+rQ5AKzqdD3Y+pF8PU86JY= 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: Stefano Stabellini To: CC: , , , , , , Vikram Garhwal , "Stefano Stabellini" , Henry Wang Subject: [PATCH v5 7/7] docs: Add device tree overlay documentation Date: Thu, 23 May 2024 19:18:14 -0700 Message-ID: <20240524021814.2666257-7-stefano.stabellini@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: None (SATLEXMB04.amd.com: stefano.stabellini@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN3PEPF0000B374:EE_|SA3PR12MB7808:EE_ X-MS-Office365-Filtering-Correlation-Id: e4961a22-ac01-47d0-80d5-08dc7b97d2f3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|376005|82310400017|36860700004; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?WLmn1WgWEulHuBgsdlmgC06rLAkeRjI7lKTDnoUxl9HAFHN6vGddY044lrNl?= =?us-ascii?Q?uLTx+mWFd+cxpC2lMCdMqcPqX8XmAOx+QPgxxokOHrQPtAGO5UWVj/Ftmhin?= =?us-ascii?Q?XXFoiUZXPkojMntMhhGWWuQRpAMInUIksgXx2o35I9b/2CJEiE1BindYw3m2?= =?us-ascii?Q?QN4YUSfjO90iqzbjNqBLMcmu1F77Mdi7ftUZ47nMR7tVs31EoETftWHXfAKg?= =?us-ascii?Q?XfIsNGjsrgNzmilFbAJ5cr7UX7OHWBtyDmjtjZtYZRq8bkoSyN6nXjdekVAK?= =?us-ascii?Q?9Xp9Z5u6XXhj5rWDF6Oe5W1u3ZqmjUQo5Td7An5Zta/k++Xh7Yp8t5po8ZG+?= =?us-ascii?Q?TzJLJdtcXTvrmjZwvBDI5JbanPxdEkDoPmTbusKAejzWSJwVue4aK9vD7n20?= =?us-ascii?Q?8/F6Thu3Ingk7lr3tCo0eJXIOY1PJrIctaCt9wSvt97uKicW4c+8pobrbitE?= =?us-ascii?Q?GIDH5LI29ZiedKIrwkfFp4yy4Mh6r1DNQfL09Ejsq6MliuEy33iCWrevANoh?= =?us-ascii?Q?APLojt9fz4NNo2uMFvU6Gyxk5Xz2q3tdwDawlqlcD6+h5dFU2q1UaC3SPzWx?= =?us-ascii?Q?9xmeHiGV9q8SwTzrdCBO4bmtZ6KSbkweDXNQdd+ujTp2PSI7703HDiQqtWMI?= =?us-ascii?Q?UQnPybyZVtNbmU5cNJrSzJLPAPwA0XsfB/LimTDpIUT3q9Z6P86+ctVPez/6?= =?us-ascii?Q?Z79GrF9rPMgqRrzN+GErd2/pGDNb8KPEh166gRZ3g4GiHMcJfsHYXP/PKsph?= =?us-ascii?Q?HRcEtAtJ5iQnsP3fyHBd2UGvzyfi+DuHSy1ofHc1dJnjRH4NpMReCtv0qVVY?= =?us-ascii?Q?XP6GOq6l5apBfPM19R8Rr5yUdz7+lKvf76t75hKWVk/Drt6iOaFtbyowigQc?= =?us-ascii?Q?2vgrgq6LGSYTaCQQxsAdIz2bL9kHwq0eEnq4x/Ev6OAUOhfA3+6KtlAXQxVl?= =?us-ascii?Q?LoQcSmDHRLfVvCvr8ST2Po9fyGsVue+QmGanaYulI6e2tEzEGKQKJLP0z9md?= =?us-ascii?Q?GL7iVTtHfzzLjbmx33rp73aotZ/VCL6rPi1D94RrF/lkV0971IlqWDluIrG5?= =?us-ascii?Q?DegjslMF/Iy/kI/odgdngVL8sQEqdK1MPepPA90+z8qMvGjBV1A1k08iy/Xr?= =?us-ascii?Q?Ah+KhGzkyYRCsfGp8oZgM+HG8Y0RMVwDpAccnr/wcAcnJ11xnMSdeojJG4hD?= =?us-ascii?Q?FfXEEIGHEGEKK8JLb5o0VzBS8pkTJW26v3v3h8PswvJsuC8S6QTY11mVAWrL?= =?us-ascii?Q?1EGmoLEp7AS1CEeVl6e/wU9Zwh6OahGOXC88L5aRv9NwMi6wxsGl03jT6JxK?= =?us-ascii?Q?LEZY/ZxGkBn4ESo4sUIhUWUH?= 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)(82310400017)(36860700004);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 May 2024 02:18:38.8750 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e4961a22-ac01-47d0-80d5-08dc7b97d2f3 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: BN3PEPF0000B374.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR12MB7808 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1716517147993100005 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 --- docs/misc/arm/overlay.txt | 82 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 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..0a2dee951a --- /dev/null +++ b/docs/misc/arm/overlay.txt @@ -0,0 +1,82 @@ +# Device Tree Overlays support in Xen + +Xen experimentally supports dynamic device assignment to running +domains, i.e. adding/removing nodes (using .dtbo) to/from Xen device +tree, and attaching them to 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 device from the DT overlay to 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 the device to the user-provided $domid by + mapping 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 + +## 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` +property of the DomU overlay should be changed to the Xen hardcoded +value `0xfde8`, and the xen,reg property should be added to specify the +address mappings. If xen,reg is not present, it is assumed 1:1 mapping. +Below assumes the properly written DomU dtbo is `overlay_domu.dtbo`. + +For new domains to be created, the 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. For already +running domains, the user can use the xl dt-overlay attach command, +example: + + (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 + +[1] https://www.kernel.org/doc/Documentation/devicetree/overlay-notes.txt --=20 2.25.1