From patchwork Fri May 24 02:18:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 13672608 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 83D9AC25B75 for ; Fri, 24 May 2024 02:18:51 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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 (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 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: uaq+5J7VJsp1R+HKQxmoUH+RO6C2TKR545pzmUQ5G22Xks5xPqG5QpmK7hDpDnE+47ejbwree+MPqGh2q7aFJpuyI6CAdwYxZiNqgZk6aw3CRW/IZKRa+Wy5zgTdwnvd07jTcV/CQJuNjnbtQScsfrk6L89m15vxJ3YO2NAMFOvoBeHrcBWFBmXmSqYEI4EIDx7PDQfpJ3bySZbhyd0nWpgiyD+ZXvRx3ucyLyzJDy7H11gdVUyLiLb5zmwwcnQyo4dSUH7nJ3OnU1b8iblErzSLg70bJbneMyJmLOFF0HCxLudUVN6P+z3w2cTYSBK3MzKoqdivGohF+UhhDeM3qL0LBUODHQ8ruWT68nz1n0klytLuHcM7NvWzbTklciVyQpA6XVAotPCzgMFLHOrCgIQU+kewjz11t/8WFpcgNKzElpvXGaUv9iQ9wWXHkMsQoJHuuGQKG/cG+03H48KNfdWRsE7h2kNNBtGV9noCK9DV8T64UplMKb3/skKxl9tWBB0amY9Nne+/kFnkhb2wJY2Bn4XDjoiyHDt8CElj59v0/61Ri83FTzVD6bVO0/rYTbDMGH2LaroFfji6SRv0TRpY/ShNzPnQPO6iIAyDCA4EccW3USmyePLTPPPGz4t7tLzIZZBExMXHysG8uL/3qgPgqb/tdSkJBrO06k6ZWJQfpBi/UjiZ+RgWbk2j6L5+daPWsx208ZpEX9lbMH7grKIDq9rQ0q/ag2ZYLVSFSlGCaInHfePx5GzSvfltWKCmCJfCmO1dcNLtCgAkryECoTpGYzszNNNJup4bqBKbIMABLHqvZPSKJIIO8cWKiUjDj1jIhCg+Y3c1swBDADy1xU5SAUKPn57nSIfT/YEaxHH2NlrhndEI3hrLEeqosJFGMTEXVP3maKkX+kYuff0Lpe/mWj2hECW//sVQ7DRwaqvxAc1CO97VhD1z93uKO+lZnSDzHgdkePhPGmPnMkpNYnPToLtydCp+jWY4HkHT8RuoJAq2IKnet8+yKC7FG7cDYuXrpZ6nEVU3J26Z02jyRZ9ZCNP9Z5RxtX29RMMyOb1cx3BDKW3/mCG9+JRINt/HJr87Apmu7wKiUkVxxxSezDyJ6XwoXbbVBVfXn4CCSbzZXy24oZ+U4rjuQfJ+UrJN9XkH5EHNa+phNgl/1lAUygTQZjOA/czT0tAz6t6ewHmr6TQ2n4einKpOsSvh9bvQyshJFSUbzx8Yh4iP/2o78DEFEicQsHosuTlHzAplgaMT7diX0j+KlDrA1VApnOPru+JxR2oINSGrEsx02GtM9GkXhUsxF9CieQQJDFNef9gvaXXqPXjKnRcKdalYijsLNQ43bDnPdEdLccK4BOk6L/br1yybMs6OOuwOEPIF7l0= 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 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[] = { { "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 = 2; if (argc < 2) { - help("dt_overlay"); + help("dt-overlay"); return EXIT_FAILURE; } @@ -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; } rc = libxl_dt_overlay(ctx, overlay_dtb, overlay_dtb_size, op); From patchwork Fri May 24 02:18:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 13672611 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2B026C25B7C for ; Fri, 24 May 2024 02:18:53 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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 (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 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: ZhWZs+o9k/4kk5rtRKSY62PMffnLmD5TNjCHCUppI8IrLmLkm0MQSao8twv3v/M8mREIxzJKLtxT+fd/R9xS/vDnzL5rxyPlYTpbEten4/YspKOHqhUPoNiZZYwB+AJIjgA02ixesTg+HSlgSX/XdrHqYfJf+3pImFS5j6FRu8QYPWJFdIHpPDwQn2iXrD+FaU0bGVzkomDuXhPdgEHjtuwY2EPDhC03MY74frnXwAY/J6pzWlrjgRqG16NDJWMDn2F0x3T4m3cOTVABJ/go4/Spdbi2gxD6bx0TY+R926oR2IrwbsV6JDO56Ggg2xRG3GJZ3joFAbcVx4YJNeYU76or6tLQiL5CbndFCKFLtqdDwtd/P+Gdxvb91SvNzuMb5Aqy82ccai38e8BwBzNW5x80UtvmLDWq+s3Q+8+7b7wNr3unv3tBxDXWzYLqhp+XPk+5mtIM3fh/fy1bn92UeN6d0VZEvPM/Y2GE3ZTzqAVyptCBe7OdPLOVbKp5EzPR1GcQ4ErOK5vHoAMl1SmKmor7A2KQZLQfqr/nva9Q3Y8fQCtyrbvQ9UlZUPFjfN6hV3FDPuFwd2B3RNxgrbIZajJaO5tZaJVIq1f3ZcbpBCc28olOOCY4+LSxGiBuuOi1RckddiVk961rR4lCLn1ixOtLTeQnrYuXVrpE3Ebu/isr0QQibxK0+Pdq3FRJHIe0tW9UufUEY/6Q2FEIX1Qvp9aRinAJUBm+CLO516Fv5jhJvgfAxIF9KtFOadu6z4XUfYJyiuhehQxfZRsnLmTSmjZStQYRbU44H9SIoNzrY8wt31RohdG/hm4kA+bp649lPo3Je6Ul/IUOGeIaCdboCdT6UHtv96EtDdY3WZiOZ6VrsprnAkYvrkhBcdOapZdnl8U+otR0KGob++MrgNOn8XDmwI3etKXNeVDJVy73b8GpjVwig3NbPXLY3hlgRgOUiXZC+eevJ4AbsKKA22xq9kM4P8KHC1rlaHng4QZcfMR03a0dIsYiMQQfJIK8cjBVWEmXU7Y3McZ7iLKtmnHcZg1YpZs3P6ckme0/F39+MvCUfL5PMF7lWH6zwVTof09EeBCRnw7oqFvY5GZyyLv1QE8ZiPFxhMQ1ftkoBS7IBdFbxwsFr1fv/wUkdNNsupJv2moe40FCWG+7XHob7LI3JdWxdj2solkxk2th/rdaQCxufZw4qPhVMSWYjnxkEQcFVfQ1nX2I+iMXt4wlOBAo8mgqPEvtYdblPOd2WxQntlL/a/2NvEoEl49qZGiZnR1a21SZnk5Snc0fFE0e99rhf9vsRT0rETwjKex0Mox0AvzgcU0eYtdYtjqC+RiLo3QI0IzErkIoGwAWa220Q3ZJDSg1IoHMQWIEiZRWu5Q7CZC78OW5yojAaPlJPNBnWPqH 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 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-tree/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_frames (or its default value if unspecified, i.e. 1024) is used. +- 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 domain. + Under the "xen,domain" compatible node, one or more sub-nodes are present for the DomU kernel and ramdisk. 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 = false; const struct dt_device_node *cpupool_node, *chosen = dt_find_node_by_path("/chosen"); @@ -895,8 +897,13 @@ void __init create_domUs(void) panic("Missing property 'cpus' for domain %s\n", dt_node_name(node)); - 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 = true; + + if ( iommu_enabled && + (iommu || dt_find_compatible_node(node, NULL, + "multiboot,device-tree")) ) d_cfg.flags |= XEN_DOMCTL_CDF_iommu; if ( !dt_property_read_u32(node, "nr_spis", &d_cfg.arch.nr_spis) ) From patchwork Fri May 24 02:18:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 13672609 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 91D4BC25B7D for ; Fri, 24 May 2024 02:18:52 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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 (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 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: xvzB2S8Mdd/V1lOkTCHoHsYjbP8BJ82IUoJz4SG44qqujlM/JeEmeg/o4hWKjOUEOXhgOOOt98smd6i/4mfeYcM7TWc+D5dG3t65waDdDu3icSO/y3UfnSVy1CVPp6Bo0ntXNfregaD8ZmjkvD1mY3bT5oi8ODXDQscq1UPST2AuOEjqanyISqhL8Q5fC7pKJSsZO4q04UEwOxB2Cmv/eS9BrQksOjKFzSM0hxBkyaisU2eE4t2pIEuXT/YRXERnaWznhEsGh5C8I3kvFO2E/zBi8OGOlCfNQSOr8egoYnTfDYuzGxz+u7l+HwkzOYDaQYoyIu5eTv7FS2ztk6EXGVXMc4LcnWC4MUrTMCpxuDDjo4Fo0lmXiprdWzOCOy7qQQDDtDMNQjyiNp1inkvv1FIOVrydzgu7ZrcTfR85vlT02Cfj6X/VKjDSOfgywu0Qk/+qltZhVGe7G+Nz7wAclhFBX7GN0o5zQ9zAw2khbYv5iqzz/sFEITNPFIs78rgLctOxM1MW59Tw7DkkF3mWMu37jjI2+9uaBoREG4xB8sND7RKhxgSwQAJOr6cu0Qqn/LLablqVNdi6QN57crfeA7fhJsPLdNLS1K6yiym8GXSr/xEUVBoxkYgH9Ye8hdTXTWMNHuZEXTVFG4PwMjTQ+nsP9Xo4cTM5BwsjyZFxbxNrCqZkrbNLHjDc5P7i1KpW+8r5ftcsyphDuPIbw35C6OxktiV6Qd0CqG39INMB49QoAYgUW1DUqylXbYt+nrIBk80XyMzz2WPIAdwhBmf6tUgLJeLr7MMu086V4CJJplYl4lPji7dojF+dQU9jjZsXGOnxPzOr+K92pAezFiDT9l4JGpjnqJMmr94wwgBGlVpX0sDeMfkgAQWYoqM7CzTCKUva6As87XSQVqnveykz2hItApdOCYZ00e54NvQoNe8B8A0NVmhHRpvd1go1EVWRPYmBravb0PFbmAEQD8APkAhnWR5/Eb+Qv5YtMLJM69PcGhOsQ0yNUPesrD/EhQusKKbHN4/0Vb2zGzDGS+Dxx/PDujFxifLrrbiJ7J4t8RueB7Er9Sh6L0RCStGMhrHQDI4LyUqmuZCKk3Q0IIt5L2EFkFECSWt5XY3pp19W6QAIDyj8N1sKbdOcvM58KN57KL2OWN6xqF+1WjV7nzpUgAB2v591BLCFRORrIC6q4zyIqLYeJib9lZ8VBrpWUMNFdNRiAnT9uhTYdSS03TvFVn/IquK726zV+t+CgYIfgKLSiJC3qkE4tifNkJUS0ZmQDGP9Rd0QVbdELO2uUOkEZo3/O82oFBV+ZlR/VqF76Bp/D6tUY63IcCIxo0oO/GjEpKmm0Oxsn9kNWYLPr7iYl3Y+Cu2RnMJeWQExD4+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 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. =back +=over 4 + +=item 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. + +=back + =head3 x86 =over 4 diff --git a/tools/golang/xenlight/helpers.gen.go b/tools/golang/xenlight/helpers.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 = GicVersion(xc.arch_arm.gic_version) x.ArchArm.Vuart = VuartType(xc.arch_arm.vuart) x.ArchArm.SveVl = SveType(xc.arch_arm.sve_vl) +x.ArchArm.NrSpis = uint32(xc.arch_arm.nr_spis) if err := x.ArchX86.MsrRelaxed.fromC(&xc.arch_x86.msr_relaxed);err != 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 = C.libxl_gic_version(x.ArchArm.GicVersion) xc.arch_arm.vuart = C.libxl_vuart_type(x.ArchArm.Vuart) xc.arch_arm.sve_vl = C.libxl_sve_type(x.ArchArm.SveVl) +xc.arch_arm.nr_spis = C.uint32_t(x.ArchArm.NrSpis) if err := x.ArchX86.MsrRelaxed.toC(&xc.arch_x86.msr_relaxed); err != nil { return fmt.Errorf("converting field ArchX86.MsrRelaxed: %v", err) } diff --git a/tools/golang/xenlight/types.gen.go b/tools/golang/xenlight/types.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 +/* + * 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, LOG(DEBUG, "Configure the domain"); - config->arch.nr_spis = nr_spis; - LOG(DEBUG, " - Allocate %u SPIs", nr_spis); + config->arch.nr_spis = max(nr_spis, d_config->b_info.arch_arm.nr_spis); + LOG(DEBUG, " - Allocate %u SPIs", config->arch.nr_spis); 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_types.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 = 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: } } + if (!xlu_cfg_get_long (config, "nr_spis", &l, 0)) + b_info->arch_arm.nr_spis = l; + parse_vkb_list(config, d_config); d_config->virtios = NULL; From patchwork Fri May 24 02:18:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 13672610 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6C6D5C25B7E for ; Fri, 24 May 2024 02:18:53 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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 (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 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: 5Kfs9OGs6EUji5agDbShs9dUhfuVFkFUkPASr4/FE9kDWmBylwHxf2AnAG2QEHxqTwSng8cZMvmoqbpdhMdSgX4httlMo9Kh8P0xU5Hhh1kM1LudrjUyjKrjCZyT72h8XUyLPFbQQeDGK5D6iQAuXd70FOtthS+r815pbM+e19tRslRO0b9ASThM2jNAbjPN0diH4p4JWInRcC2uEWTupT87amcXdDeCF6qefNBoDtJCQpuK6M8H7ms4/Ib/CGtKYBd9CwdHNrMTIzDIq9hun0z4KMSi5NHce2ry61KxRGVVJRWHwNgQmLasYHI1mgm2Rb5rUhz10dfzWFeGZ3iFWpvdJtaO+WxYzIPX89NUBMGIaZfxfSQRsSl9OD8PCYJZIlKBHrhvViYwJWbFjWZNeFDQHgbkt8O8UbINwEOxx/HK7r2Pl/s50965EgK8OMoq6k4DnDGCLNsmoLv/NrDAIi81qVdHtZBeFc86+jzSygvLXxSqzzI2nPdm63vxgrHmCO/ZZH55LD84CWPDo1BK0MfaeQgas7QurGFQpSE+ca9k43licMmDctNuOPTXgEN+NVWOtLPthvVh389vucFdGHla6XtIMSLhUf9fquyJYIhBr1IhnI9Ufv0u+ftV1T4SXLcy8DwSw1qSQuazzPblKLBUDE/I8SDYHG/qMk+YXLFV7PP2/nySjI55hhnMdGfx97JQAQ+CftYsy3bALeb96KISCwmue/xSswO0D9t8XDZYcddOFOqYrHxR5FhfLgWir8IaMoPHL78fNysTlhpIpNed1yBf+F49z86vJjm3xqCXAAWIssdu9chmEJccGwfSzGKkK+Z1x+Y7Gpm5JFAgDZdFStcKZvpfhwfDRFa6S19LRGYhX5BB+efqQsnljHzgyavDBmqHNoQVCb2cFFKc3/XNvozVaeT+poQwmur8S/vnPCsrX2wPNTuluUd/irx6Xzc1xb4+JZ5qBZZPykLN7SIG1oXBFTZalE2eNelPkxQxMtYPsdl/7UbT1k8i51dVd2RGamVfWXIBKicmbQAHrzGqLj8pHYTKeZ6sqckQ6Mj9i4wj2ivmcgHVhOMY5t4YKvwdNuTY/0EyLH1tZidxZ9fHH6cxVhmW+p0ujDk7DVfKAgtZhrstLCp/9St9xoIRnCcp6JhRsyYpoR71scN1qVj5DJMKB7/2KOmiKu1iYdRiMXqqxifCS2geNMDxRAA9Od7C+ljLWb+pAp6sxk5orf0A1/Z3N2pFRcMOIwSL7pAMYxO3pXjEnQKHudUsO/qpfwxH5G8BO6M+oRXYFOoFzycDMIM3CjBVJpgd0LBowGOtMMTSZaPrsZIUS+6V1ZfWaza8vFKCSkqoOcWUg3TfYjLxJwhXL3fr3WJUZqCO7vAGaPXMMwDcZSg+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 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, 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 = desc; else ret = -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)); - /* - * 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 = 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, 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_latch ) { irq->hw = true; irq->hwintid = desc->irq; From patchwork Fri May 24 02:18:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 13672612 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B7647C27C42 for ; Fri, 24 May 2024 02:18:53 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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 (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 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: jf2NIh+QHSzWhLOFWQJGnQ9Z+seGPhGnO1JTOS03Z3WEPNElMpQYSDmxVudX1c3rumi27SXYS81SPkzfuR0V7L0MuLtVmEdV8SRtTMqnzeChFQqbweHgAh9r8+Xsg3TsG7FUAvwppaRP8ZulIkPpKjrJ/KC1eF2aC0zqiURfmYMFtqLX09SCvJ54+XKwBaDGOuXVNdy3y8QFo5/eFInZl1Xc0IniX3etGCkU+s20oueH6UsS+f2TUN2kDExJzF+Oz4sIn4HJa1DK2yL/aCJK7atDcdUaKcSL97jx47gCKWBAhSL38997nUGG2IzhKvnvnW0Datej0sYbLmCDNby/O6wRYnIv51S14fK4rGGFQOkL0PUXDcn72zgpybkQ6bI5L4aB1Tev7vbr1sktbcYTNsBlEV8OcochhDveAv3/iLq1u2IBrGj4rRaelEkVOlKowOxbJi+gQ05ev7CwF0d6XIMlNElBEOrMaRtkIq8POGhGwymlL7S9zDFmR4B+VuF+mp71Y41+rjlmJhFh50U1WFG/XerIbafgSa6IhUG+unWS53iWCDUbyjRT8Ztalh6Y/hYpMbTl22F+RiaT9aecj35TBDhlzTEFbr/tuOADL55K1qbQC1zcyCFFVbjQRoFXhNIahnXFJVJ+cjWBRzrHP81QBATf1Dzeem+0FMaCm/2tgXgQCL5LMY7bojFa2wnQd7GHaBYFlT/yn7wmr70Cb/ZbIXLiVvAxVRF0QHxsKh1UrQobR0RyFsykouArtPFXP0ZfQujS5Li7CVgUKJal87hmbSVxHGhUFFc65vewmgafibHWNitQgZKLe9rms2MUP0NwB7AqF96HeNhnpW/L9UyuLodTTIdCb89N2YMeI2QGIegupVdIuxW0CNL8J0T5ONJp5PdkaNib/qUT2XqdzZOHysCFu4n2iYHDF2nmGgrszIDlDFT9fglsbxu/yb6dZQsJveGA/95mQlHZBahohToDk3pKLOlbGuPYBEtLxSREvJtWpwctz52Wq2G0yAAJOljCS5xuwoTJMR7EfnBuYeLL9wgLNIC9I5mxmZvNbkCUjDI0HM40T77b06eJjiobD9P/h3o8i/aJmw0HNsfFRcmiQoUJPOksHHkT+G3iVR2AC0mewfAs1H2QXKcs4V8NEvIUQczmJ6fSEjNhQaF5gJ+XZ5S4Rwh8Y/FCL0ySHXhWWI39/Lb5ze7q9ppN9bMRxlgIZ4zJyFkyvFq641ljmfQ/vkeY6QdErqt5HaunC77UacD4KcsLcBWMGWO2rGmGplOoBX5RJ+juXB+n/ZNXUlDbCgMmYadbjvmhBNZmaf/DnyGgClAIhc6eqyc9RGPLK6VafrCU+jRbohoa2VkGrBDrtjt23ItkGzbs9EHA7qs= 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 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 */ +#include #include #include #include @@ -176,6 +177,8 @@ long arch_do_domctl(struct xen_domctl *domctl, struct domain *d, 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, char **nodes_full_path) return 0; } +/* 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 = 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 not + * 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) == 0 ) + { + found_entry = true; + break; + } + } + + if ( !found_entry ) + { + printk(XENLOG_ERR "Cannot find any matching tracker with input dtbo." + " 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 *overlay_fdt, uint32_t overlay_fdt_size) { int rc; - struct overlay_track *entry, *temp, *track; - bool found_entry = false; + struct overlay_track *entry; rc = check_overlay_fdt(overlay_fdt, overlay_fdt_size); if ( rc ) @@ -494,29 +529,10 @@ static long handle_remove_overlay_nodes(const void *overlay_fdt, spin_lock(&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 not - * 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) == 0 ) - { - track = entry; - found_entry = true; - break; - } - } - - if ( !found_entry ) + entry = find_track_entry_from_tracker(overlay_fdt, overlay_fdt_size); + if ( entry == NULL ) { rc = -EINVAL; - - printk(XENLOG_ERR "Cannot find any matching tracker with input dtbo." - " Removing nodes is supported only for prior added dtbo.\n"); goto out; } @@ -620,15 +636,7 @@ static long add_nodes(struct overlay_track *tr, char **nodes_full_path) return -EFAULT; } - rc = handle_device(hardware_domain, overlay_node, p2m_mmio_direct_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; - } /* Keep overlay_node address in tracker. */ tr->nodes_address[j] = (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 mapping - * 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; } - tr->irq_ranges = rangeset_new(hardware_domain, "Overlays: Interrupts", 0); - if (tr->irq_ranges == NULL) - { - printk(XENLOG_ERR "Creating IRQ rangeset failed"); - goto err; - } - - tr->iomem_ranges = rangeset_new(hardware_domain, "Overlay: I/O Memory", 0); - if (tr->iomem_ranges == NULL) - { - printk(XENLOG_ERR "Creating IOMMU rangeset failed"); - goto err; - } - rc = add_nodes(tr, nodes_full_path); if ( rc ) { @@ -843,14 +835,89 @@ static long handle_add_overlay_nodes(void *overlay_fdt, xfree(tr->nodes_address); xfree(tr->fdt); - rangeset_destroy(tr->irq_ranges); - rangeset_destroy(tr->iomem_ranges); - xfree(tr); return rc; } +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 = check_overlay_fdt(overlay_fdt, overlay_fdt_size); + if ( rc ) + return rc; + + spin_lock(&overlay_lock); + + entry = find_track_entry_from_tracker(overlay_fdt, overlay_fdt_size); + if ( entry == NULL ) + { + rc = -EINVAL; + goto out; + } + + entry->irq_ranges = rangeset_new(d, "Overlays: Interrupts", 0); + if (entry->irq_ranges == NULL) + { + rc = -ENOMEM; + printk(XENLOG_ERR "Creating IRQ rangeset failed"); + goto out; + } + + entry->iomem_ranges = rangeset_new(d, "Overlay: I/O Memory", 0); + if (entry->iomem_ranges == NULL) + { + rc = -ENOMEM; + printk(XENLOG_ERR "Creating IOMMU rangeset failed"); + goto out; + } + + for ( j = 0; j < entry->num_nodes; j++ ) + { + struct dt_device_node *overlay_node; + + overlay_node = (struct dt_device_node *)entry->nodes_address[j]; + if ( overlay_node == NULL ) + { + rc = -EINVAL; + goto out; + } + + if ( dt_get_property(overlay_node, "xen,reg", &len) ) + { + printk(XENLOG_ERR "xen,reg not supported yet in overlay\n"); + rc = -EOPNOTSUPP; + goto out; + } + write_lock(&dt_host_lock); + rc = 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 *op) return ret; } +long dt_overlay_domctl(struct domain *d, struct xen_domctl_dt_overlay *op) +{ + long ret; + void *overlay_fdt; + + if ( op->overlay_op != XEN_DOMCTL_DT_OVERLAY_ATTACH ) + return -EOPNOTSUPP; + + if ( op->overlay_fdt_size == 0 || op->overlay_fdt_size > KB(500) ) + return -EINVAL; + + if ( op->pad[0] || op->pad[1] || op->pad[2] ) + return -EINVAL; + + overlay_fdt = xmalloc_bytes(op->overlay_fdt_size); + + if ( overlay_fdt == NULL ) + return -ENOMEM; + + ret = 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 == XEN_DOMCTL_DT_OVERLAY_ATTACH ) + ret = handle_attach_overlay_nodes(d, overlay_fdt, op->overlay_fdt_size); + else + ret = -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" -#define XEN_DOMCTL_INTERFACE_VERSION 0x00000016 +#define XEN_DOMCTL_INTERFACE_VERSION 0x00000017 /* * 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); +#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 -#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 -#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 { }; struct xen_sysctl_dt_overlay; +struct xen_domctl_dt_overlay; #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 #endif /* __XEN_DT_OVERLAY_H__ */ From patchwork Fri May 24 02:18:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 13672614 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 127ECC25B7C for ; Fri, 24 May 2024 02:18:58 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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 (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 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: A4L37uh5lyCQVNYh7YmEKmcKs+6lWcOekLbFMJmHJGZLCPY8VQoy1DpeXhYSVfcCFGwC9f2FJNhJBnPyqiR5t3r8kFjT+dj5ZWiWx94pHPcSt+WCcpGL3oQeIM9FG9O8+kFfyQoW5QRljeieWDJyHEoRVWLFJ9xtSJ1jw/V8N0sq08II9IStKxzppd2vVXTq+Qx/wabjFb1kotBKwT8osrG9DgaO8Z97L9IidVj5OZqTqoE9PLOodMTVAYwil2D+u2M8M0K0HyZVoFHXgKBLfB0ykilwJjTY+UDL92UTZmwHpp0B2zt738Tb4cY+8CM1xGpw0blWyUc5uxku8ZOHJe1OWK3bLPZqurivCga0+iKB9/b2zyygw3rAu78K8CDTTay9hvbfj/MHhtqqS3dJCGDW05eSFrmXuiMfDQMgPsBqo5Hfzati6I2yFFSAYPH4HFswIfZWutWda6T7PNBLDQ3zWg1e6wU3CMedWUjpbdTRnUoVckynMjnBPOWI+vhFtVjvTIt09F8ZLFlCOCaTzCSNamfBkAqu/H4ACooVZ6kIAz3Ng2w1DalwJNmRKuuRzN4AP/ueLVs2Exv+qFN8X5Oz4clyBphgKC/Nkn/90iwjhSt687HXlQ9deliZxAQa2q105eYgW1SPoNg8uvER5CI2Wbw94lK3wI41n7cqgj2vaVfuTpxV5jUl+a9MZpIvc5QkXHs5UHqii8OVL3Em1rbBUbaIzdxgc8nWyin7wC3R61033js9VUZG/Gl+gK1UsV2P4IpTihsidS26AoOFo5SvovKzqZTnEthTWmbEWI1N4EG1RIg8rENHt9qSTfqh3wy8uNbGxDjngG955lpz5gt2gA1h5ZGLD/xxeAvt9Eo6YEFbETnE87n+2aJdQ86jAEUM95FZ/ZdXKEdp/VzAqMmrYXi2hnq5expsP79qxmOF36IWIQpele5QcWBJyOOpdquOFdpv7zmGM7ecjw4RSD+nsEXyjcz3WXFFgJh4ra/q1MXlXUfe/OiKBg5F6zRdShIVcRdjjui2gNqodxUAc+4rNjry8PTuhCvAa7rKTh8vA5HERZl2AWwggDpHEXRkHdGk4BswE2kO54OSbUB+UzAtL++Pqe8Uldzb2NPcPRwe1TFbgTpwYaN2+Sy4y0M4nvl5+5lsBGGbxKfQj1xR8Msj5WTQhsWrXVH/LjLy/fWs3gJFGf/rx2KXfP3mYaMD+wSEOy6Jsp6WVJH6ahp3c29OPdua8RxporAPst0lm2YlXYP1wxM+UfgZWrnUIoaKi9BeQu3bAQtYT7s6qRooiuo6de7Hez1e7GW91fw4YyFRIR8jVWdPAyYxuib2Q3ZmSq9dEsiDEVG+aOlxkqTE+Ot0yx1PLWv48qRO1RdMF/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 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 +/* + * 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 *ctx, uint32_t domid, void libxl_device_pci_list_free(libxl_device_pci* list, int num); #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 /* 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 /* Compat shims */ diff --git a/tools/libs/ctrl/xc_dt_overlay.c b/tools/libs/ctrl/xc_dt_overlay.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: 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 = { + .cmd = XEN_DOMCTL_dt_overlay, + .domain = domain_id, + .u.dt_overlay = { + .overlay_op = overlay_op, + .overlay_fdt_size = overlay_fdt_size, + } + }; + + DECLARE_HYPERCALL_BOUNCE(overlay_fdt, overlay_fdt_size, + XC_HYPERCALL_BUFFER_BOUNCE_IN); + + if ( (err = xc_hypercall_bounce_pre(xch, overlay_fdt)) ) + goto err; + + set_xen_guest_handle(domctl.u.dt_overlay.overlay_fdt, overlay_fdt); + + if ( (err = do_domctl(xch, &domctl)) != 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_dt_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; } +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 = ERROR_FAIL; + goto out; + } else { + LOG(DEBUG, "Overlay DTB check passed"); + rc = 0; + } + + r = xc_dt_overlay_domain(ctx->xch, overlay_dt, overlay_dt_size, overlay_op, + domain_id); + if (r) { + LOG(ERROR, "%s: Attaching/Detaching overlay dtb failed.", __func__); + rc = 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[] = { #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 = NULL; const char *overlay_config_file = NULL; void *overlay_dtb = NULL; int rc; uint8_t op; int overlay_dtb_size = 0; - const int overlay_add_op = 1; - const int overlay_remove_op = 2; + uint32_t domain_id = 0; + bool domain_op = false; if (argc < 2) { help("dt-overlay"); return EXIT_FAILURE; } - overlay_ops = argv[1]; - overlay_config_file = argv[2]; - - if (strcmp(overlay_ops, "add") == 0) - op = overlay_add_op; - else if (strcmp(overlay_ops, "remove") == 0) - op = overlay_remove_op; - else { + if (strcmp(argv[optind], "add") == 0) + op = LIBXL_DT_OVERLAY_ADD; + else if (strcmp(argv[optind], "remove") == 0) + op = LIBXL_DT_OVERLAY_REMOVE; + else if (strcmp(argv[optind], "attach") == 0) { + op = LIBXL_DT_OVERLAY_DOMAIN_ATTACH; + domain_op = true; + } else { fprintf(stderr, "Invalid dt overlay operation\n"); return EXIT_FAILURE; } + overlay_config_file = argv[optind+1]; + + if (domain_op) { + if (argc <= optind + 2) { + fprintf(stderr, "Missing domain ID\n"); + help("dt-overlay"); + return EXIT_FAILURE; + } else { + domain_id = find_domain(argv[optind+2]); + } + } + if (overlay_config_file) { rc = 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; } - rc = libxl_dt_overlay(ctx, overlay_dtb, overlay_dtb_size, op); + if (!domain_op) + rc = libxl_dt_overlay(ctx, overlay_dtb, overlay_dtb_size, op); + else + rc = libxl_dt_overlay_domain(ctx, domain_id, overlay_dtb, + overlay_dtb_size, op); free(overlay_dtb); From patchwork Fri May 24 02:18:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 13672613 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 884C9C25B75 for ; Fri, 24 May 2024 02:18:56 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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 (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 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: WLmn1WgWEulHuBgsdlmgC06rLAkeRjI7lKTDnoUxl9HAFHN6vGddY044lrNluLTx+mWFd+cxpC2lMCdMqcPqX8XmAOx+QPgxxokOHrQPtAGO5UWVj/FtmhinXXFoiUZXPkojMntMhhGWWuQRpAMInUIksgXx2o35I9b/2CJEiE1BindYw3m2QN4YUSfjO90iqzbjNqBLMcmu1F77Mdi7ftUZ47nMR7tVs31EoETftWHXfAKgXfIsNGjsrgNzmilFbAJ5cr7UX7OHWBtyDmjtjZtYZRq8bkoSyN6nXjdekVAK9Xp9Z5u6XXhj5rWDF6Oe5W1u3ZqmjUQo5Td7An5Zta/k++Xh7Yp8t5po8ZG+TzJLJdtcXTvrmjZwvBDI5JbanPxdEkDoPmTbusKAejzWSJwVue4aK9vD7n208/F6Thu3Ingk7lr3tCo0eJXIOY1PJrIctaCt9wSvt97uKicW4c+8pobrbitEGIDH5LI29ZiedKIrwkfFp4yy4Mh6r1DNQfL09Ejsq6MliuEy33iCWrevANohAPLojt9fz4NNo2uMFvU6Gyxk5Xz2q3tdwDawlqlcD6+h5dFU2q1UaC3SPzWx9xmeHiGV9q8SwTzrdCBO4bmtZ6KSbkweDXNQdd+ujTp2PSI7703HDiQqtWMIUQnPybyZVtNbmU5cNJrSzJLPAPwA0XsfB/LimTDpIUT3q9Z6P86+ctVPez/6Z79GrF9rPMgqRrzN+GErd2/pGDNb8KPEh166gRZ3g4GiHMcJfsHYXP/PKsphHRcEtAtJ5iQnsP3fyHBd2UGvzyfi+DuHSy1ofHc1dJnjRH4NpMReCtv0qVVYXP6GOq6l5apBfPM19R8Rr5yUdz7+lKvf76t75hKWVk/Drt6iOaFtbyowigQc2vgrgq6LGSYTaCQQxsAdIz2bL9kHwq0eEnq4x/Ev6OAUOhfA3+6KtlAXQxVlLoQcSmDHRLfVvCvr8ST2Po9fyGsVue+QmGanaYulI6e2tEzEGKQKJLP0z9mdGL7iVTtHfzzLjbmx33rp73aotZ/VCL6rPi1D94RrF/lkV0971IlqWDluIrG5DegjslMF/Iy/kI/odgdngVL8sQEqdK1MPepPA90+z8qMvGjBV1A1k08iy/XrAh+KhGzkyYRCsfGp8oZgM+HG8Y0RMVwDpAccnr/wcAcnJ11xnMSdeojJG4hDFfXEEIGHEGEKK8JLb5o0VzBS8pkTJW26v3v3h8PswvJsuC8S6QTY11mVAWrL1EGmoLEp7AS1CEeVl6e/wU9Zwh6OahGOXC88L5aRv9NwMi6wxsGl03jT6JxKLEZY/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 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 arguments +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 arguments +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 tree. + +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 before + (dom0) xl dt-overlay attach overlay.dtbo $domid + (dom0) xl console $domid # To access $domid console + +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