From patchwork Fri May 24 22:16:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 13673762 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 16C1FC25B79 for ; Fri, 24 May 2024 22:17:07 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.729887.1135196 (Exim 4.92) (envelope-from ) id 1sAdDe-0007X1-L6; Fri, 24 May 2024 22:16:58 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 729887.1135196; Fri, 24 May 2024 22:16:58 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sAdDe-0007Vi-Bg; Fri, 24 May 2024 22:16:58 +0000 Received: by outflank-mailman (input) for mailman id 729887; Fri, 24 May 2024 22:16:56 +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 1sAdDc-0006xe-Gp for xen-devel@lists.xenproject.org; Fri, 24 May 2024 22:16:56 +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 534f98c6-1a1b-11ef-b4bb-af5377834399; Sat, 25 May 2024 00:16:54 +0200 (CEST) Received: from DM5PR08CA0041.namprd08.prod.outlook.com (2603:10b6:4:60::30) by SN7PR12MB7811.namprd12.prod.outlook.com (2603:10b6:806:34f::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 22:16:50 +0000 Received: from CY4PEPF0000FCC4.namprd03.prod.outlook.com (2603:10b6:4:60:cafe::a9) by DM5PR08CA0041.outlook.office365.com (2603:10b6:4:60::30) 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 22:16:49 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000FCC4.mail.protection.outlook.com (10.167.242.106) 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 22:16:48 +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; Fri, 24 May 2024 17:16:48 -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; Fri, 24 May 2024 17:16:47 -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: 534f98c6-1a1b-11ef-b4bb-af5377834399 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ns9JCnCAXGoAjQfpP9wTbqYGU7n90JKF+cuIZPfDk/R14fZpmhkxc7Lfyc1c+Zj0gU4kMbg3DVQ5uNluhrqy0QC1uIfO7sukvVSTgSWaHizcFf7YfcE+CYWevdrPUscDIeVLCSc2GR2ZlmMUnZesH1aZPi1jx59TDIn7r2saF2jpC2bU1OCJROwplSWO+nx/WLm/Cf84NWGd7LcfmYZ5OdoK8Af2w23DDIuygvc+flp+aDvQWa1/plWMuvY6kG3bIfx2KiGeHg96iedhe1gl//+3Cliw8cNuod7jGDkQ8LOqyvUo1judm1qLbl9/6wLyM3jSpbGaRJ5dYc5kNByhOQ== 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=bp5c6uxrCNfQZZipQ4TC9ZG/hqYGc0hO4mq7bqpZqgrL5JcW8seJhm2L2aaHGPkGeVwlsGUQfKz04vTgF9xuQ3C2h+gEkw2AArIELGI6kwrSB/vKevmRYIDM107anhmob+PWDx/ocBBcs90GxXkAGzwM11qgdKmiuv03jF+S60APTK+uOQVSp7723ytAif/rTlqdUTfkw4wEbrvQ2/pYvGnUseGpIaWYrpoviKuST1h7j0qZCEF3vbwu9GY8OCWiQM3Q+AN9bIiYUexKF+FLUn95HcoWX0qm2gtbpcalv7xkS23h7+Nwm8DcgV/3FSQsF7WD/c5WbsVcE61lTHer5w== 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=GiNFzdCzMXUm73p1jFdMZbwrVPzY6M1lm2agrxUnPzjtm3vbUi6PwInsDTbhyk1SCsoGEIUfoqMS4J/xL9LV5yHhchshune1moFCe6xaWW/fn+jFhdbKyO+Fl9d4bz13cVLOkOqkinNBSB0KlduiVl3BeABiKhhmcY2GnKzxrDk= 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: , , , , , , Henry Wang , Jason Andryuk Subject: [PATCH v6 1/7] tools/xl: Correct the help information and exit code of the dt-overlay command Date: Fri, 24 May 2024 15:16:41 -0700 Message-ID: <20240524221647.2860711-1-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: CY4PEPF0000FCC4:EE_|SN7PR12MB7811:EE_ X-MS-Office365-Filtering-Correlation-Id: 3b1469f8-0f67-42e1-a46d-08dc7c3f34b9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|82310400017|376005|36860700004; X-Microsoft-Antispam-Message-Info: We6+HSNrH5PCtFIOkHpGgt47i80SS+XBiQvm/anNS7mrXE0NZIsDs+wIJdcw5+ZLaSs55myOP+JkzbHmu4KL7rCMkWewFqo2Fyk6rAX12ecPnGpHjZ/26YfgC8Ote7p//1M8iWpYtW4jYlety5h20Ru+oP0S1MsKOMHH4dfI1XM0EStbdbfFTlv4/Kmfs1jr9eW53iOVjW8MJAVifHma0rVtl4FI9RHlavMaiDhXTL8nCd8emYOqnQxRKPTTitxMvSU8yTUfgdAR5Z6zFr2ZfZg94CEnZxkaHR79Vq+1UmS3E5BCXVuri1RnWJT5hyRCI/2SsZY1GWQy3DJgAbUrx0suLVNnFCC4HhEV+jUizHNsC/pVU+5DYGMA6FV8UVzpBIOF1Vsfu5ul1YX8lz55ZbjHhoWJra+5ybG0mEwtGdZgdLGPkjvO6U9KQEUEEkrIW4KPqqqEVepjpfDobc6nVAtH3+bxw5T5Evx/1K3WZ1cb44GBS1ZDJcq5KZ9DsgvCEscSbzoAkuhlEIhjjIO2Ufvj1mJegnqKwBunPzRMYJ9mr0Qx2ZYOLOcYEDau061FdvbJWEG41Bggq/bCmqQtl2ItBWiD2K5a2SarXocGPtG8wUx/eiTL1vEwBRts84MPG1kKyhJR6KibCLVaSHpUu/nO1dZu8LDwNDM00k/RGTve8SKJF/CcvRaYF1Nt+FwfFT23jx6h6vpQtNRnZRkQD4/VTalHvLRBpOmiKYW9uKEiP9qea4KdR4ylkBFa2MVbPzuf0Yt9oQSNGNSecdAAEXFM7bljdq5IxyP6piPIvKnUkA7UZWfA/x9qym+lD0f0DuZA+oxntwDW7w6KNka/W3X3Ig7z4A3hdYvOkwDTHR+G6pLLXc1H/44okZl2sE07jJ7k6ObFOYJ+Ytdy5JDnEkLeG8gmS59h+bTE6wcMcyV2DTLc+Fl1jRZfe4gLoa3o1PzAdTuyq89J/fjWWPwvJ+8swkunyrp/Q5SwGcXK+uHg+g65uybFXdMlc0xymj60imeCLGUAefkehRGk9M/njRhBmu/sDZDsKbFI6sSK4k9W7iDI/lVoz65h0x0B1PDRhyBr3+q/VcHMomXjoMDFKUtY4UFAsv7VPuOKzgrnlTjDkY7KUtGQ5l2J+vKSDZ6QbK/gqiwwtcj00sTSaMdCRantg1xOaI5ZGDgvP1h6jbOXk4i5+/WjC/opFE1G6nVyzcMrziUIpXFUfRp+wfU1dgK8KchFQFVzchwIwVPAkf452zdyH9tBOoeMqxz5TZJEyVczFvIZvFNuVG+/Mw2IljLEdEKxbxbzQAIA310XVZH3bu3AJUbYs59v3Qugofqlo5nmq20g3nofn0XUIL3pBZifQsZ7hosrb1WyZ7rcljk= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(1800799015)(82310400017)(376005)(36860700004);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 May 2024 22:16:48.8195 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3b1469f8-0f67-42e1-a46d-08dc7c3f34b9 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: CY4PEPF0000FCC4.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7811 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 22:16:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 13673766 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 C48F6C25B7E for ; Fri, 24 May 2024 22:17:13 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.729890.1135230 (Exim 4.92) (envelope-from ) id 1sAdDj-00006b-JR; Fri, 24 May 2024 22:17:03 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 729890.1135230; Fri, 24 May 2024 22:17:03 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sAdDj-00006Q-Bq; Fri, 24 May 2024 22:17:03 +0000 Received: by outflank-mailman (input) for mailman id 729890; Fri, 24 May 2024 22:17:01 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sAdDh-0007Iy-SJ for xen-devel@lists.xenproject.org; Fri, 24 May 2024 22:17:01 +0000 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2060c.outbound.protection.outlook.com [2a01:111:f400:7ea9::60c]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 5761ee32-1a1b-11ef-90a1-e314d9c70b13; Sat, 25 May 2024 00:17:00 +0200 (CEST) Received: from DM5PR08CA0042.namprd08.prod.outlook.com (2603:10b6:4:60::31) by PH0PR12MB7888.namprd12.prod.outlook.com (2603:10b6:510:28b::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 22:16:51 +0000 Received: from CY4PEPF0000FCC4.namprd03.prod.outlook.com (2603:10b6:4:60:cafe::a8) by DM5PR08CA0042.outlook.office365.com (2603:10b6:4:60::31) 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 22:16:50 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000FCC4.mail.protection.outlook.com (10.167.242.106) 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 22:16:50 +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; Fri, 24 May 2024 17:16:49 -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; Fri, 24 May 2024 17:16:48 -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: 5761ee32-1a1b-11ef-90a1-e314d9c70b13 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HglzBUSu0Q3uLWrJxDq4dyGWmR3pEAjys9pbN6rERGCSdO8hH/HEyQ1/N0Ni3LIeYLlkglg981luM1UuEDf+b6fIlgkRvFNTcD9MA47iYzppFucr2Qlx5kC/e819XcBXvW9rPmFkxwjKHAsurg21PEGevJfH+dGhFa0wfBL/Ew8A944cI5DRopBnbc13FIh4Na3Qsnhv2jXynWcKDezjNDR6U34EWAvfAf4Mvx9lbouLHuhxuOtY7M3XLi9EDjZsPE5rVLv1DV2Wf/7EQOnuuUGOsI4WqYoqvKb6sYjlu0bCCzUOYUferjo/z2KujU2Y5tS0bYaOFR83xoOs9uXktg== 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=D/JdGi+CtOOBbF8Anrxl7pSdmvnLsoE+IhUc9SJ9OXzBF+hO3lw6Haf6oVnzRzLCa4nfnNngS7Hu43T0lxLQqHfSL0URPwLQ1OybuI+KVYc/ZPGEMHbuWMVUv46M4uaYMiULFyoNk3wctF9yv3bl8+rAorB1wlBzF0T0wUs3nJ2jx7dT+hD45+5Tm/3OZDPU/cNHOMHrBpgk6/dpj/KYR9YZ6DOqCSbuASM0uPDIy5Fm0BU7i6YrAjLfDG7hGqG+6k5YzbR/TeKkb1oi3nEIR4se4/Ua63Hb4OTQV++50eS/ExcjjBb3dBLe/bBf0z/86Gol1+8Ujfl1uyOsYEg2aw== 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=kyEbJu5MxFV3zc8+DDSkzY2Gt4n/wMqXF4TCPw+k6xPNtV9FdJAKdUFOjmNdC191AgLFovxVICh/8BWZtLVLXSkYy/F4qu2IjMBIwZhnED4PFn3C3QZmlrd+rrqRbjY5/yqErTrY0VMJKJAEsq5j4rgombQNFg6+rQ46Y6TG9nA= 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: , , , , , , Henry Wang , Julien Grall Subject: [PATCH v6 2/7] xen/arm, doc: Add a DT property to specify IOMMU for Dom0less domUs Date: Fri, 24 May 2024 15:16:42 -0700 Message-ID: <20240524221647.2860711-2-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: CY4PEPF0000FCC4:EE_|PH0PR12MB7888:EE_ X-MS-Office365-Filtering-Correlation-Id: c2982c3e-5f43-45cf-85fd-08dc7c3f359e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|36860700004|376005|1800799015|82310400017; X-Microsoft-Antispam-Message-Info: VnEuSgH1Nm9hpjmMVJ2Ssfx+PXLQKIGbFygjMcZWfXmTX6CZwojlSidlxN8eEKmu7MIaZFZd1EgPWGpaJItUmEz/oTpI+vCib6LJLfpVkhucRFFLdRM22cT2lvFhaNWgMvKr/d0LinGaY2RmTOJB+XzlJDdBe1FJ99mo3/xbAbjLq6tFKJNh54AkGtA0c1AgDZoToClT9VtYrl949DVZxt8YfZjKio8QDHtcPXGiKs2kXBDiqbsM83ju+J522cZpG8kmJuz18/4XmSKeRulnlY4XIto4lsfTeKNuDF1NWU74LgDq2FXA+j88/uXig5QGpZRuVRBM6q6KXoFf/BfXxj4KxdfAS6QwYF0mW1XXfAi9vyf2pPs03ZyjMearB/kuRZeh1qo64Bc8qWyg6d/Wen7ohzO8AyAA1egEEBoukhdxuvPztyLuVpb4urhPSTmkTmiSpzPd8JOVKXinojs3Bo8dwicFs61bsWFpzsFmtPp6GjXrkBHiDiRDrrfTxBP3/MqVGa0i5CkIyN+vT9A3usprz96zxKrPpS921mOyeWomn8VuegPyipqvGUZPp8VvyF+XDjhCd4cG1vPqUOfWU7Bz2tUL97e8ubOSS/yss7syRmtrf5utsVO51Vp63RzZdS7taEcqg61QmH0G7/4cZR5u0dlZZmm6IkyeLsi/OayOY0kgxHbKPCgBL2dcAIinJlk56zctwgPcD6YTT27bS82XfdiHk1AZ5+Po+f00bfpEfNbroqxjgKfdzJpNeZd4CT4E59KPHwzNTialEmqMXu+ZUpP3pX1yaKtoGftqY8LP0rfZDWv5V/Nx6kwbMR3C/laqFaScll0162PheXCZjSjOKkTXoWvlHnjD97HTcORnQZ0LtDPyk66g1J+UXC8/dE7bZj2U4xu+KdsaGViGw3pA7PuXW3V2M9hpOHP+0wORWfmvQ290oXJFkf/MvIrW3dGQfbxlcAtD4iwgswkLMdsv04ZAHaArU1d6a7zCG7aO2gIX7oEiJIMmnsyjhAJYdvjPyVEviZmVqxkolrKo4U8jkXar/oXXMq/DY4/GyE/U3LtaOLn8QQ+Jdq/OfG4Zx+5KoUBEC+/Ik/YKe11c8pwi2vgpmtwukpVTPw9Rbftu63Zxz0zqDwTKIsmyIlpqvdOJ8np03B2bv+SzNPyCBU0q9mxkq/GbgDYhhrBXV+PEEmqyUwS1pXk+FppK9hLLu+1MbMOP1QBaa6Eh/nbcforwtQbGwsEQxiLAEJ4xHDHywGsyKWSbTZf+gmN9WDMqavy7dcK3CEfqcvGHw0dwZ2UxlUrhloj+Yld9h2xhwXhSOUjdMEH0hslYOF7fu3aJnM/49ZcCOhKf3TVtjvFeJVEHam5dzp0K62DcfE/pDOwDhJiFBIt08duxCU2T2NTZ X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(36860700004)(376005)(1800799015)(82310400017);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 May 2024 22:16:50.3039 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c2982c3e-5f43-45cf-85fd-08dc7c3f359e 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: CY4PEPF0000FCC4.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB7888 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 22:16:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 13673761 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 E6E26C25B74 for ; Fri, 24 May 2024 22:17:05 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.729886.1135190 (Exim 4.92) (envelope-from ) id 1sAdDe-0007U9-8f; Fri, 24 May 2024 22:16:58 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 729886.1135190; Fri, 24 May 2024 22:16:58 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sAdDe-0007TX-4w; Fri, 24 May 2024 22:16:58 +0000 Received: by outflank-mailman (input) for mailman id 729886; Fri, 24 May 2024 22:16:56 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sAdDc-0007Iy-Fr for xen-devel@lists.xenproject.org; Fri, 24 May 2024 22:16:56 +0000 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on20600.outbound.protection.outlook.com [2a01:111:f403:2417::600]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 53c72a6f-1a1b-11ef-90a1-e314d9c70b13; Sat, 25 May 2024 00:16:55 +0200 (CEST) Received: from DM5PR08CA0054.namprd08.prod.outlook.com (2603:10b6:4:60::43) by PH8PR12MB7205.namprd12.prod.outlook.com (2603:10b6:510:227::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.26; Fri, 24 May 2024 22:16:52 +0000 Received: from CY4PEPF0000FCC4.namprd03.prod.outlook.com (2603:10b6:4:60:cafe::19) by DM5PR08CA0054.outlook.office365.com (2603:10b6:4:60::43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.26 via Frontend Transport; Fri, 24 May 2024 22:16:51 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000FCC4.mail.protection.outlook.com (10.167.242.106) 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 22:16:51 +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; Fri, 24 May 2024 17:16:50 -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; Fri, 24 May 2024 17:16:49 -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: 53c72a6f-1a1b-11ef-90a1-e314d9c70b13 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CTzZuTGnG5+05W5Uf1a//3vm5/5e2izw06KDCV27HWIBe8C0mueHPbJEf61VdJYE2h/EQDbk5cHJmxBuWViFhsbLc1TRVxjqlhVQ3O+JscEXBzvsjcMHxBe8zUteq/eVg3zEVfn7yO8+h25hUX6mX9+Fl5aLT0yusC88UQbnbEvhDdWTtjwLB1O8Eepmr1btqpKQsv4N8Gtx2zMJpuwaoSUWdzDUd+ywW87OXCarIwUghPUBynQukRbNrRaNnyOorhxwyOAnJsy2ByQrBA08uIlWUAE/JOqwp7GALbmOcuBYrWEDPMyHEyI08WJInsb55N2qeN8AJpEYXawVaD2PLg== 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=NlizJg2iClGMdik+Fxv6BQH90USOSUhLLxid+7iVuz0=; b=Ej/sc3hrLkuTD/ZOdBItZcOTZgCvZkgb14atfgI2HWOGx2Hlr9dTAJBAQoHiimYxLdpzkKy7cHEMpFf6EkT7slTVllV/crg4av+54S19jgWryPTrzhb0rj4fo8i3C3mRIbTDPnHjIuim6NDdjhpg0wGTe+slmOLob0t920A5JL8eAT1JGzx36RcY2JbD2P7OUft3I6SrrtGN3UtAa7nhqg+XKIbNEGokDox64xcT7Z83lu55pMPnoW21yHPOHIN02vCdEkrIHVXRr66QbrQ7kMfJOWWtEllMMrozwjh1WTYC44C1QgbyN7Wjbd0EKhosghoQIbQe0NoYtpnzWpBtPw== 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=NlizJg2iClGMdik+Fxv6BQH90USOSUhLLxid+7iVuz0=; b=2dQAv7rvWO8m5WNGBKOKSy9yTmkfMUtvBuJYnKqkD8u4hGBbRVxAkt9Ww7puLpDeAHHdXohRQfLe541nZPmSGoQqjkCk++kuG5b2ratM2PZY8VdygRyOqI6DOBq2MRCfHR7IP+hgcfyx4tiUVjpkFCo9/AHXbnK7RcF+XxX85UA= 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: , , , , , , Henry Wang , "Stefano Stabellini" , Jason Andryuk Subject: [PATCH v6 3/7] tools/arm: Introduce the "nr_spis" xl config entry Date: Fri, 24 May 2024 15:16:43 -0700 Message-ID: <20240524221647.2860711-3-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: CY4PEPF0000FCC4:EE_|PH8PR12MB7205:EE_ X-MS-Office365-Filtering-Correlation-Id: e9ca015d-c878-4a30-07cd-08dc7c3f3643 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|36860700004|376005|1800799015|82310400017; X-Microsoft-Antispam-Message-Info: OMGWerVL3CvW7SrQ9+jFQR7rc6NW++MjeBSJIczUJ3cIrT1WuiLL/mLyUJj/Wpu1awTo/LxQNe41fHOQxNhj8fbJmAhLTWtqv8CacRwVFJhFUM1cdlkLEhgIB1hYz5Gl8/sfKAyv6/rcdSM01BhHLhklG6uh/1k7Aq+AVO8KQ9Ewkv4eLselM9Fu8df3AxaOlkFutEz5n7tGWgVv5uzZM+xWJ+yXSf3enZX/FwCZi7hztWge+HibR6azoD0BviPVMw8j5/WZZPaBrMm8SeeF33AFsj5RrGWIadiGlt3HBAERFYjbCoNZLdE8hz/JL77erBLq012qpjY3wNlgpGgoMo0s0y/FyAqF5igvUSan1Y3JknGpqBUhxtAyQ8cLSj2W1qXVDIoHSHXAWYa7pjF7ADBuLfZ3HNgCu/xpaevzch5SB+nuBaQh222JSdzARflDwd+QEfdq49wZhxV8TrJStP1WZ7NbMG+So/wVnjibjfSL9m7HEc82zo/bvxOX8v3WIaOhHpif6eidgJeDTHRhP00Akku8dTZrqBMH1D3Sn86qmiQxKMFXExSAoSaoKOgsSExsRQ0Ih+CNNr35JzskaCNuxG1GOLudtHQAgAKjE5NC9TmnNwjiPNos+xUbAMCR4kjvlo0oDgQjmi0G8wo/evWBeSMbgj7tcZj0h/+av2cAWxtA3Gvf4XCEwi8VC72o7l2Zf/7obynimB+GRl4YDu1Khg7BVpHWFd5rfX6jSfM/niN6KCf0i79Ms5rqVBRk5YTSiPf8JS8K9+Ub0pTympVGJ/qmB64UM91Knb/wMESmDpAf3MfORrGm+D0GRq1xwC7X8nvAKmqff43AfePIptfJe6IDawd0BdrKqPneZPaa5JIboHRDqda1C3bl0xIJHvCU+yeX+MTd/0T+CMzXURCmmunvRQjsK1p5N65cOJ/G3FvIwG1AE5ai+8HP+SOmSPwuCnf0SKcCmScrUefZrAlYesZZ4jAKbk6hMeikPlYf51OPD3ZG3W2bGIiSB2cTd4F97ScwGiREx+inlG+zG2Ze0SfEcTt+JSTvMzOvCsa1EzZbVtNtx29L4As2Itcs75kcrmf5gN1OApJNbrfCUWlK/BEZzwEffrtraJUNyWFpDLI6OLdONYY/NUTAiQ/PJhymBRyLTFmx83oA2gw1AMwTBJgU1eXB613qFTzjIg+FklPmD/n2064WZZEdmKhq6Ax4AK3rh8C+YqlhwhLNiGUkb9PJEKgoI1CeIx4W1qdGwRGLGLFHivsM1bAEz82uUTaGVZVhWeuUuo1fOzifnjqMggU9bwdOOAWTnpsWjREUPY54aHGRnKxEQQTXKXYyqAfBv7voQxpGDACVD43w/t/EbSsmcl/aSgLF6eXMS5A+wKukOrM0l8ltG2APEy1+ X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(36860700004)(376005)(1800799015)(82310400017);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 May 2024 22:16:51.3820 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e9ca015d-c878-4a30-07cd-08dc7c3f3643 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: CY4PEPF0000FCC4.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB7205 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 | 5 +++++ tools/libs/light/libxl_arm.c | 4 ++-- tools/libs/light/libxl_types.idl | 1 + tools/xl/xl_parse.c | 3 +++ 7 files changed, 30 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..a3d05c840b 100644 --- a/tools/include/libxl.h +++ b/tools/include/libxl.h @@ -308,6 +308,11 @@ */ #define LIBXL_HAVE_BUILDINFO_ARCH_ARM_SVE_VL 1 +/* + * libxl_domain_build_info has the arch_arm.nr_spis field + */ +#define LIBXL_HAVE_BUILDINFO_ARCH_NR_SPIS 1 + /* * LIBXL_HAVE_SOFT_RESET indicates that libxl supports performing * 'soft reset' for domains and there is 'soft_reset' shutdown reason 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 22:16:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 13673763 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 5C0ECC25B7E for ; Fri, 24 May 2024 22:17:07 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.729888.1135209 (Exim 4.92) (envelope-from ) id 1sAdDf-0007z0-Oq; Fri, 24 May 2024 22:16:59 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 729888.1135209; Fri, 24 May 2024 22:16:59 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sAdDf-0007yQ-LT; Fri, 24 May 2024 22:16:59 +0000 Received: by outflank-mailman (input) for mailman id 729888; Fri, 24 May 2024 22:16:58 +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 1sAdDe-0007Iy-Ni for xen-devel@lists.xenproject.org; Fri, 24 May 2024 22:16:58 +0000 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on20601.outbound.protection.outlook.com [2a01:111:f403:2418::601]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 5588d913-1a1b-11ef-90a1-e314d9c70b13; Sat, 25 May 2024 00:16:58 +0200 (CEST) Received: from DM5PR08CA0025.namprd08.prod.outlook.com (2603:10b6:4:60::14) by IA1PR12MB6329.namprd12.prod.outlook.com (2603:10b6:208:3e5::19) 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 22:16:52 +0000 Received: from CY4PEPF0000FCC4.namprd03.prod.outlook.com (2603:10b6:4:60:cafe::fb) by DM5PR08CA0025.outlook.office365.com (2603:10b6:4:60::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.26 via Frontend Transport; Fri, 24 May 2024 22:16:52 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000FCC4.mail.protection.outlook.com (10.167.242.106) 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 22:16:52 +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; Fri, 24 May 2024 17:16:50 -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; Fri, 24 May 2024 17:16:50 -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: 5588d913-1a1b-11ef-90a1-e314d9c70b13 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HzIcS/jnelNSjX5wmxlhAnjjAVdohjceaUs9ETjTs5Y+YhOn5igMhInyZZ/EJ1Z5OoyDnhq2SMISzSjRBTq/+cUPxEH3lZbK5XEjt/JwccDSRf9rmelHCz4ggiuWYMtc2nVFk1njrZXcsdZI5MSihSFhnP14iqlYo9BJRlaGYluzA9VivtjA+/3Asn+yb9ZT8nu0N3ZZGo5Hov8q+TD581ijD8qVrZfMXPKZvn3Tp2Lw0pWzgBtNvQJFyOnSddHp6X/XfQJLKRFgdSAGpHzgeCb0UBuIhYUz5ESy+YIXxPAkfx50U7P/thQgPDB1uGfdGIzBODRKXUEoZUkS7V633g== 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=kaBZAr3pU4zrWLveeJm1a1tA0bhHgywJpIeS2nRlAMsHHPnTJeKbx+u3YG2Pqyzn+HE5DXvXqltQn5BiYZSWcspoUKcW/eoS1Rz9lruKIWqN6pqS19KZPQOOfHaYjyE/3LH4lVsTubjnrv1dQXT7y+EraAfPBMhJhPGeSM4Btp1YjMZU4q80fv4SSJC8GoWBHHv7IUhUTFabCTVk/06YJO0+CPf92nxT9/m/gse05/uOd9X0S1Vez58Ejez0OYdCuO91mmCaHo3AakoNWO+IvjGJS5D/dNfQClZnNP1/f2LR1fJSJBMNnts345dJBeNcf8Xnmz0vJcFh9/d/K0QhMg== 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=44iYRey/bQX/UqeeEG1oty/E0pXIS2Fa5yCEm5zFSJpI1TQ3ebtVDkmsiqfC6Lc7UokVtlM7RN6rsBvknALGs40MWSpr3MX7bbXf5Vk59Cxdt3q2PYsyZeym4Zg3vJUjxwIqkVhi5uz+oM3P2rWH9t94E3sxwFly/JsKwx3a/sw= 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: , , , , , , Henry Wang , "Stefano Stabellini" , Julien Grall Subject: [PATCH v6 4/7] xen/arm/gic: Allow adding interrupt to running VMs Date: Fri, 24 May 2024 15:16:44 -0700 Message-ID: <20240524221647.2860711-4-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: CY4PEPF0000FCC4:EE_|IA1PR12MB6329:EE_ X-MS-Office365-Filtering-Correlation-Id: e3ffe385-56df-4e60-27c3-08dc7c3f36e5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|82310400017|376005|36860700004; X-Microsoft-Antispam-Message-Info: x7bV7ZqjgUF7VWv5tEb0t7r9/1QAF3128hqXshja0lxs7s/Tn52FXT3oFHsSZT2zhsIwWX9WmVCIbeyGtfYr8jPZjh1JEYvQdtmOoATSEVTGHSBJMLJ2UoVGj6dUkA4J0WItM5O/5BecsfapkAmTqG9XKMGWl/VOXpSRhSUTcP3FOtyHlxKFdpJBx2XkgtsfaDeptG0jvlTVzj7kfIPkaFQJKX/TUy27EvTt0143HRTQExXmBhRH/YDC4bD1Cw/Zs0MRzkxOwVPOzQUmprIMGNWY8+O/76vMs6x03QS/X5iftlL27RkOWIALa9YBK3rFGVxyXZsgLEbndrDAntOMgxAWxfpiGtXHygvUybX6EjchwqpbJVmQ+t62P5McG3mK+lFyL6awNcJJSTaYfewSJSFd3Z1jQwOSyRdccQvnaOuXa3snhaMz2R7c0K2OsU/loLa2i3BkiYYa00oTrrA/AamDNVtvk4xVtA7x1TC+kuBQVRboW/EdhySZxNBZCeZ/d/QmGSpbKfuKtzY/SetOSN0fOWLUqRLe9jvHdH02rYu17zOatsvltddMKd7TpUX7vwp1H+fzWF29NRtylfYKI2P5A8z5zNFVnE1KC1YPtVCDuYAV0IpxPeeJmUlCQJGpUtL6JoVwVSqul8DnBo9wXXoDUeCq2KHVGDGfajg59FAGsK2PPUB+yoUVbnUu8jzx6YbICMJJrOl+flCMnUwXkUeRQLgiS+9aubFdVsFAJZcSVsA/EaZLt2TPQdxEPG3JI6Lu55MG8+ASy/I3ST/A9pbVxZem8uNBcgNRJQcYCgz+qP4UcqAsExXn5rw/Dvdy2XlD3B93+fJ2yu7bOaT8JHNpNGbYseCEAigDJekk9IDr3d+UT1AZnSSUjy5FMTuy2jMF8HZbr71te46vq01pgwrvo/6WrYLkQOjaNbuEqSniqbYdbqdF45cxq1JRqNG+r5jbCzBWQo6lmNogYCUk4LIQFJkazvrl5T/Qzc1GOsCz3wpj4rxN5ZDWzMsI5aPUQlrM5ZvqkBsvoDNQRR791iDpT7C/T5+Lq0t12xZx+wPgFjQegNFI5wlk3a7laNehWr2PjvNShs/LIG8VQNzFlRrB/jZ1CB2vCZxZy1rWHtsvwqTMGa5ueK+POV4b4FBwTdtAiZQQm6jnuEDu+BrK4ipwsZYFpyQAn1TsWTAJWB+1y7GKfZwqxTtc+MqneLz/2aNx4tdUuHp9MtexrJV/Ocrv0V4YbwPD5vans9K4JpQwwjvMBa3vq3gaEESRQDESTPL/eGk4hpcZ6F7qXcXGwg11p3aP/E04qgUNGb6JzrRnnZk9EEW/qVxAOdiMjmIbeMzAEO1oWAnL4u1hUkjYlo+DRZlhuSt336uGQBeB9YOLN2h+QucIJMfIDN+Yl49R X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(1800799015)(82310400017)(376005)(36860700004);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 May 2024 22:16:52.4601 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e3ffe385-56df-4e60-27c3-08dc7c3f36e5 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: CY4PEPF0000FCC4.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6329 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 22:16:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 13673764 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 7639EC25B79 for ; Fri, 24 May 2024 22:17:11 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.729889.1135220 (Exim 4.92) (envelope-from ) id 1sAdDi-0008Gq-5g; Fri, 24 May 2024 22:17:02 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 729889.1135220; Fri, 24 May 2024 22:17:02 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sAdDi-0008Gh-2D; Fri, 24 May 2024 22:17:02 +0000 Received: by outflank-mailman (input) for mailman id 729889; Fri, 24 May 2024 22:17:01 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sAdDg-0007Iy-S2 for xen-devel@lists.xenproject.org; Fri, 24 May 2024 22:17:00 +0000 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2060d.outbound.protection.outlook.com [2a01:111:f400:7ea9::60d]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 55fd81fe-1a1b-11ef-90a1-e314d9c70b13; Sat, 25 May 2024 00:16:59 +0200 (CEST) Received: from DM5PR08CA0054.namprd08.prod.outlook.com (2603:10b6:4:60::43) by DM4PR12MB8497.namprd12.prod.outlook.com (2603:10b6:8:180::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 22:16:53 +0000 Received: from CY4PEPF0000FCC4.namprd03.prod.outlook.com (2603:10b6:4:60:cafe::38) by DM5PR08CA0054.outlook.office365.com (2603:10b6:4:60::43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.26 via Frontend Transport; Fri, 24 May 2024 22:16:53 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000FCC4.mail.protection.outlook.com (10.167.242.106) 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 22:16:53 +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; Fri, 24 May 2024 17:16:51 -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; Fri, 24 May 2024 17:16:51 -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: 55fd81fe-1a1b-11ef-90a1-e314d9c70b13 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QeXeaYcAhNT879ugktFaQEjg1g4Ny4UwtfkPJYFyGHHUPBiIoVj/1eGGjO4K9msD5Ugabtoku1MuSVCWyuAJnpP4BdUgZ3KkcN7opchHjnxMfDpEYEXga7XaZqckEDOvLSyWunA3+bWtSouL0psh5VXLX477W+Rfku61Ik7T7ip3SwcOv+8i70QXAV9C1YmKWqRmuiBVDABmSDy0BmgN5U4koNOfibBJ4FDMOvY5qWd5hC7Y2rBQIHONOLJaQvlPF7+qwsp+/+Bbl830bzFNfu2cQpeCEHXhklQzlnlkCxaM3nVGHZrJP06G8zfY26c760ry+mT/p6N+hjFXi8RyDA== 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=iRI1HqDlL5ZdxdN/WlhV5sNzuCLmoN3HyEJY9Ux8c04=; b=lDe0INtBJnnPmVzEUEdO//GSBkgnnZlKn/fMvZzbAqqQ/jA77GeWGMf310HhcgB02GpF+1oK/VtiaFNqQjMEccYPa2/b9ljEa8hcaBKh1A8N/4qy5Kw3IE82P4GEkcRplOha8SlgWwuqSaT185IUYLOXTIVTPT4LjgsspWfxtiVgNpNVbQXBqNtXmYtPbBsGkCjJo/BCN1I/1LUN8cCgx+AgV0OPSWPkhBaPe3h4ahQT0zidzlLy2MueiXfupGhfKGJpRBalM5eTWDn2dsTynVBkCLS8VptHBwg8PXmrdTQrLEgL2UJgNVF3fe74QYLQCVEu/13apVunV7yUNWDQGg== 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=iRI1HqDlL5ZdxdN/WlhV5sNzuCLmoN3HyEJY9Ux8c04=; b=Yio6nUeEFewAbh3RSiJLaD1gd/5ZV3efbRgmIDUtM1NtzbpzwIW6BVtx6EDlKmWa644AG9G+E3iGJe1qD+9+ENtnMhYG3mse316E6QvSlqDrM3BbnYFcsynxyS9TGUswiQdKM486EkZemrWjDezDCl0p15D4sTF4zO5XYzsQvKY= 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: , , , , , , Henry Wang , Vikram Garhwal , Stefano Stabellini Subject: [PATCH v6 5/7] xen/arm: Add XEN_DOMCTL_dt_overlay and device attachment to domains Date: Fri, 24 May 2024 15:16:45 -0700 Message-ID: <20240524221647.2860711-5-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: CY4PEPF0000FCC4:EE_|DM4PR12MB8497:EE_ X-MS-Office365-Filtering-Correlation-Id: 1afe2021-d29c-4367-48ca-08dc7c3f3768 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|376005|36860700004|82310400017; X-Microsoft-Antispam-Message-Info: 0zS8WKN9gYe0mffDjmraAbod5ztY2uhf1w7dACwXABVzCSN+hAdwAfH0lO49oafYStPymArANWC76Ti9PkC+xxSWfzLBi+2PnLzU7KPXgv0v5vTYo4pUL6RO/r2QttNSQa4wWd2uTc9rs5ufEEsEx5Ttut/ZKs1w707tUtlj4A9LrKO65xqZpZYGuMwAL+EQ4fMGdb2xBBaKKeuwpYvYLengJd175roUoJevBykCbfI6TX1sIg2MPrk7lfRguGfLHEf/ijU/4MdPl4jHcAPG5gcf9HTnImdAyrHQbiHyLgsErgbkJ4xNgTN8EhYLhVqHGSn/RUGYfxR9BoZFfdwrl9pGtcKesAjpIHvEiN9B8DHzsNEi+dll2UDJ7TOOZUvP0+sGtdC9bKDripMYSMag7OIjm3DSc1Ap7KUAr6KuMgqcOS1RklRsbZxG9HtehIPhZDQUdpVrvJatvF1eCOTpdfysu1d4MP4Tb1lnk392S9GIVqIoLnmW31kqlNwIP8bK4XM3jRH31wLdwYwCgwHRZpWFpn/GAkF4aBdMXs/QU7RUUEHnnCCNwA/ebl1EB2u4X0jI7PfYuTbWSki0/+kXv/l5Ka1+PKazuapvLg8dMjDA+PtA/IgTpmzggro3KDHbjsJixbENgqzAzFXtn7feRSHfSLN39W62GgKONDDPApFKFPpGIb3BtzPkeIBHSHBgyj3g6ouYEK2S5Qja9iD+ueIeR8hr/fZRwhG8EIZKJ6tcNDU5i49/KhV+CKPFhOp51DZHJ7PArzW3B9lcner3rE9fuu4h7HDXFsfmPVgYhdTdwP4IGfMj6+F7mPzz0C7R6EdwYvcVXn7Fj0hEXFQoIYRpo0xUPLixH8Iiajgi5KxAtwzJldjZM9r6UFuCml5MopgiJiVlG0Yog0LBHnco5MqNhrUZ59iqKZ/j60gkRR8Rrf7O5S8OYSF2V36t3X3iO76+ykXJQbXJKZaZHi1kAUut91rzv5xiEjoLh8NQeCA3r03RaNjO8AMzC1hDlUNTZJ/WT+I2vE3w6Wf0gBrDqnc3JLGGWW5gsIal1T+D6dGS1H6XR8Fjsan4HmMY00zRNjNMvcFw8w7P4CKAf3m9nw1VowL47YxCbEbxL7oq/U4rVeO1yQlftnsZYL6HxrKUe3c2TicAKNC8EqZXy8AtuhtjARxsyxI2++fP2YnJLee45bdivp20hcCZ7BUib4D1d+ZkWNMFm6IgV4N/i83ytL+ItaV+QHarLGwe4mn/rP/b8wvlvfN5jIfukUJuhFGdVD6e7bBqFo5Cxn8q042xzEZXi68gIvEhyycUe6U+ciBP/RamkTKvj7S8CCSo9r8z3W84fNsfkUMmXIhWMi79OjPXtwkicdZCyLYd+Gg2xf4= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(1800799015)(376005)(36860700004)(82310400017);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 May 2024 22:16:53.3039 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1afe2021-d29c-4367-48ca-08dc7c3f3768 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: CY4PEPF0000FCC4.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB8497 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. Introduce DT_OVERLAY_MAX_SIZE and use it to avoid repetitions of KB(500). xen,reg is to be used to handle non-1:1 mappings but it is currently unsupported. For now return errors for not-1:1 mapped domains. Signed-off-by: Henry Wang Signed-off-by: Vikram Garhwal Signed-off-by: Stefano Stabellini Acked-by: Julien Grall --- xen/arch/arm/domctl.c | 3 + xen/common/dt-overlay.c | 211 ++++++++++++++++++++++++++--------- xen/include/public/domctl.h | 16 ++- xen/include/public/sysctl.h | 11 +- xen/include/xen/dt-overlay.h | 8 ++ 5 files changed, 189 insertions(+), 60 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..d53b4706cd 100644 --- a/xen/common/dt-overlay.c +++ b/xen/common/dt-overlay.c @@ -15,6 +15,8 @@ #include #include +#define DT_OVERLAY_MAX_SIZE KB(500) + static LIST_HEAD(overlay_tracker); static DEFINE_SPINLOCK(overlay_lock); @@ -356,6 +358,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 +523,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 +531,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 +638,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 +648,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 +782,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 +837,83 @@ 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; + 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; + } + + 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; @@ -860,7 +923,8 @@ long dt_overlay_sysctl(struct xen_sysctl_dt_overlay *op) op->overlay_op != XEN_SYSCTL_DT_OVERLAY_REMOVE ) return -EOPNOTSUPP; - if ( op->overlay_fdt_size == 0 || op->overlay_fdt_size > KB(500) ) + if ( op->overlay_fdt_size == 0 || + op->overlay_fdt_size > DT_OVERLAY_MAX_SIZE ) return -EINVAL; if ( op->pad[0] || op->pad[1] || op->pad[2] ) @@ -890,6 +954,49 @@ 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 > DT_OVERLAY_MAX_SIZE ) + return -EINVAL; + + if ( op->pad[0] || op->pad[1] || op->pad[2] ) + return -EINVAL; + + /* TODO: add support for non-1:1 domains using xen,reg */ + if ( !is_domain_direct_mapped(d) ) + return -EOPNOTSUPP; + + 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 22:16:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 13673767 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 BAF8EC25B7D for ; Fri, 24 May 2024 22:17:13 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.729892.1135246 (Exim 4.92) (envelope-from ) id 1sAdDl-0000Z3-Bo; Fri, 24 May 2024 22:17:05 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 729892.1135246; Fri, 24 May 2024 22:17:05 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sAdDl-0000Y2-7c; Fri, 24 May 2024 22:17:05 +0000 Received: by outflank-mailman (input) for mailman id 729892; Fri, 24 May 2024 22:17:04 +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 1sAdDj-0007Iy-SR for xen-devel@lists.xenproject.org; Fri, 24 May 2024 22:17:03 +0000 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on20601.outbound.protection.outlook.com [2a01:111:f403:2416::601]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 56bec488-1a1b-11ef-90a1-e314d9c70b13; Sat, 25 May 2024 00:17:00 +0200 (CEST) Received: from DM5PR08CA0053.namprd08.prod.outlook.com (2603:10b6:4:60::42) by PH7PR12MB7186.namprd12.prod.outlook.com (2603:10b6:510:202::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.36; Fri, 24 May 2024 22:16:54 +0000 Received: from CY4PEPF0000FCC4.namprd03.prod.outlook.com (2603:10b6:4:60:cafe::eb) by DM5PR08CA0053.outlook.office365.com (2603:10b6:4:60::42) 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 22:16:53 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000FCC4.mail.protection.outlook.com (10.167.242.106) 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 22:16:53 +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; Fri, 24 May 2024 17:16:52 -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; Fri, 24 May 2024 17:16:52 -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: 56bec488-1a1b-11ef-90a1-e314d9c70b13 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=n1WIa5hyBbCCmlFsWsiq13AwcNfDf/prH6dSxgm6oIo3UjuP/GqZTPKrsRepQOPZlyuzfn5lhTrHU2E/kYnz12viCULvm1LYNwq4P5tSZriOz47NU6p0EgNlGTEqIOtfyo08zWXQ8yg0NtIESkV65YY7K4unrZiAzaqrZUBj2w/MCZqha3W5MoQ5QnpEJjcDYJ8YwdtoWahmNunPJqXAe5Wg2N7KXY+61l64dYoDTWwLwduInYTCbFw/h9GlvuiKBJIMCUH02mRLY+ImMMolcrFsImwG15zbIFWWT97Xd8P0aRf69Quepyeq5l4Qa+zCzc2sFzAX6gUwyhhHfb2ArQ== 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=8840+SwwfsZRigVHTRSue5zpJzKftzBoXAWMQbq7J+M=; b=Qrk8E90Rgt6OOmUIFY0qT0O8Z83C04195iMCs2ce652csFpzX5gnnbQc1gQQ5GABIEC3LM9Tt59zURQ7XNUCbv9UFML6sC0ZzcOBuMag/TwfTXb0sYsxny66B5ER5+bqjoOD1nETJ11vqrUOS+MiwiAV/6pbADZAYQwh+UBqDu9bSQ6sYdR/FL1MVYCHUgyQY6IaGiscYziPOMGxiZtYLTVUPwsbbu+kgjguffDNj0qTp4KHYQJqZDy4b6UKjAFm0EaQdb+T/qTdwUE4dy+OtEtUHdH84ciaOtcpSJk1awiuoWreYWqNj6V2ZtGSIUxlf09MV/29PZpMLkOlSxSMUw== 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=8840+SwwfsZRigVHTRSue5zpJzKftzBoXAWMQbq7J+M=; b=Fq9Fg5caWy1L9wZTOdDnjbfjD7lAO/71QqmWN29AMXvkT6W2gt2puCYt+6zEkevBLQezaHP3geXk9Ep94o4lztrZ+lyZFXq88zUkREbCTZ5A9o/e5E0uBpZ+5K+fHXKWWLb1GUaL5Pm4g/mUxJAxiljI4qAGi1vXXuv3vFj6iEo= 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: , , , , , , Henry Wang , "Stefano Stabellini" , Jason Andryuk Subject: [PATCH v6 6/7] tools: Introduce the "xl dt-overlay attach" command Date: Fri, 24 May 2024 15:16:46 -0700 Message-ID: <20240524221647.2860711-6-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: CY4PEPF0000FCC4:EE_|PH7PR12MB7186:EE_ X-MS-Office365-Filtering-Correlation-Id: 31ee4b0c-592c-4e4e-93e8-08dc7c3f37b4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|376005|82310400017|1800799015|36860700004; X-Microsoft-Antispam-Message-Info: U4fvEoe62dzmheReT3IX5YSBS6THqI7f9eCy8/PXK3G2ySg6+fuUd3nDyGK8tG91lPI7TuDG4N3+enj7jOGF/PS8vKIk/NUhumPlOkCfNmA9xGttOoWv+8goiSO4Pgn6ZE8pCskl1obbxJHSgHK8TUejGKJfyk2UUZb7GBMhUYjNnnso1ngsi6rNYkCs67hMA2ZJOsktatvcMO195MonofhLr3vngg32r8HhlolMVXULhwUzSS7bnr4/VL4LDnbFV0E56OsaMFMFyKzk+APf/s5Pe85yty4SgcTYe5KcPiBrHBS3FGNVAKhuh4Q3sN87MaPQtqyKnb3ouvRwoTxozA/ddP+R+1NTEw9Yewt1woYmszs0kDIYaHc8c21RC8nisZEFBbHFfUxrlItAiqCtVT9T6J109+WVAiWFr9k6GVRqdSDayzPcdV1eAAJuISNDHVK3XBqCB3VoCY6nzG7FgRdyV4Yk2aZKu7vX6nYUAhxmtBEoYBhZknadZ26P5lWyaLPXfG3JQGkwp3IUzSbykpXjEbSJ3x/wPyy/7aIOmBGbpAFpoIG9NasLMp8rXUd+teYwZKFrgbeglyyajaSOyvQSOEk0dgF9pwT9Ye6sVI0nd6WVAZxH20aqSoSME5zXQfmrB1sDf1FoOsawCaG5bczEW55Z9mV9fcZAQAVL8FS74EFaeR/22UFNcFIrWvSoHiDLhjcK+7WEB+ECPgGN7AVw/diyymphRb/DsVyvyrZrm/nh80RfzZI1wVB0tRnwUFVyll72LsHgwVLcWcDLZ7FbMUVjfJxYC0XmtyGcVF214Mu2abQXWYOl8u4aWRrcjbEbzobfOD1xH8gQFgLBaZ4e+IpoOeqW9hNeLCqp2Pt59kiLVRrQv2g61n024xxwqDV7Dg4j50cp3TKDqe1klIkKn+Q67JKRrGDOEcZ3ly78yFsYmsyHFbZJt5x2zcBPWKcP/vVLZHG+f/UFQiWkJ9Eu/KzBPaKCBlKZOJX2n1fNjXExzlBdiCJtMw/nPruPBfolRqYCAu686/c5qYthZTGD3t/XrZVVemULFPRzdDowogcz62GPi7nes5TKw4tgqBeenvioCzTgvyySJQozI6OSp4HTjxBIjS/kf4PeoLruOB9CiTBleUwvwmmBShi0vdBhbWjfq4iRzqL49qxVc50u0PUp91loQ2NSJUiUrQFIC6ogoAojShaBmycYaPTa2u4abnd98Dti94R09cb7ehUG1NStysdnZRmUJycW/xG/F+ydTDXqnak4eGY0h7svTjZKF/S8HW2obWdgv+VjVQb90hnvhD6kQYqDL9khjEa6wmKNjI6IY3rgrKBrYicxpxK73OoErtb6O7x/h0O6q+fBawH7SeQduZJ0LTd9aTLasnDpEi80051JEwHcKWjx 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)(376005)(82310400017)(1800799015)(36860700004);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 May 2024 22:16:53.8195 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 31ee4b0c-592c-4e4e-93e8-08dc7c3f37b4 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: CY4PEPF0000FCC4.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7186 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 a3d05c840b..f5c7167742 100644 --- a/tools/include/libxl.h +++ b/tools/include/libxl.h @@ -641,6 +641,12 @@ */ #define LIBXL_HAVE_XEN_9PFS 1 +/* + * LIBXL_HAVE_DT_OVERLAY_DOMAIN indicates the presence of + * libxl_dt_overlay_domain. + */ +#define LIBXL_HAVE_DT_OVERLAY_DOMAIN 1 + /* * libxl memory management * @@ -2554,8 +2560,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 22:16:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 13673765 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 EF9B3C25B74 for ; Fri, 24 May 2024 22:17:11 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.729891.1135235 (Exim 4.92) (envelope-from ) id 1sAdDk-0000Br-2q; Fri, 24 May 2024 22:17:04 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 729891.1135235; Fri, 24 May 2024 22:17:04 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sAdDj-0000AD-RT; Fri, 24 May 2024 22:17:03 +0000 Received: by outflank-mailman (input) for mailman id 729891; Fri, 24 May 2024 22:17:02 +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 1sAdDi-0007Iy-SM for xen-devel@lists.xenproject.org; Fri, 24 May 2024 22:17:02 +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 56dc309d-1a1b-11ef-90a1-e314d9c70b13; Sat, 25 May 2024 00:17:00 +0200 (CEST) Received: from DM5PR08CA0034.namprd08.prod.outlook.com (2603:10b6:4:60::23) by CY5PR12MB6179.namprd12.prod.outlook.com (2603:10b6:930:24::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.26; Fri, 24 May 2024 22:16:55 +0000 Received: from CY4PEPF0000FCC4.namprd03.prod.outlook.com (2603:10b6:4:60:cafe::75) by DM5PR08CA0034.outlook.office365.com (2603:10b6:4:60::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.25 via Frontend Transport; Fri, 24 May 2024 22:16:54 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000FCC4.mail.protection.outlook.com (10.167.242.106) 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 22:16:54 +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; Fri, 24 May 2024 17:16:53 -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; Fri, 24 May 2024 17:16:53 -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: 56dc309d-1a1b-11ef-90a1-e314d9c70b13 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=g1WOooZrS4FH+fyJ4SSehSaqtVvNVnbUijGatl/DGrn68l53YfnP8aBy6pCVotcgP0MzVC5O5aCfGywTSoEGYgvSGDDyM2WFbIpsj9s4+ib1Rd1agRBHvfvoWzcu6tOAgYH58Dp8Z+KTDoKA4cYZ8xXOTP4v2gRhiKuCeYoDQCf9RCDf8OC6xzuJHRoTMLwbeFL9JuL2DWXoFrWccFuCAaJKrU+obhl88HaGrK7oXDqarXx5ysV4SIq3wUgJ2bsDh935baZGdhgDYnZZy7xEtAYhAQZlJz6PgckpIb7lwwXaBtiiBYnslEfv04elBYo9rhM+H794tfh+DVAP53PbOA== 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=B3jJMlOrEINeOqECOvhj7YrjOfi6yjCyyFlom/2lhcc=; b=AHLzFVxfdmPKSLY1YtAaJiQufbIrNc+5WpangG7AxgdIT1xQptvcjPMsifLBQzvZk46sJHhsUZltDuNJ3g/PxePAd+KfbP3H7tBlO91bOLIAtdXjIksoxZ0jX8kEU9jP5fH9Y8KqgTjodQ27a2/sFcojoYtoJXq1Vr/cFfj2UmNwsTe9ggceC3CvDmm+1ShCmqW4LKoByT4CHhntNcFFqr85367OSRg/FGObT3zsBq1NmjQ+urdPL/5hS6AGd9kmeohveRRwhW/DiwTa28szsngWFZ46MMHwT0ssiIMNiCs2ue/AyMQT0zjcXIG4yNgb9tqzjBJK2Nvd2cRo5Jm+/A== 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=B3jJMlOrEINeOqECOvhj7YrjOfi6yjCyyFlom/2lhcc=; b=FDgOXMKihEKrR3R36cgnYUEr4THgczch2FnwFnc1Zi3ZExA01ySutsrcWZB01iybLOrd2MkfqlYi6cdxRj6ivpmRJPEVz/XoVCvS1sYyMlFPa8eyhX06LlOXGcNzfnMKDOQ+EVnYr5pVw1oF71zLAHZ/IhB2k8GdCnLIT8yghNs= 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 v6 7/7] docs: Add device tree overlay documentation Date: Fri, 24 May 2024 15:16:47 -0700 Message-ID: <20240524221647.2860711-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: CY4PEPF0000FCC4:EE_|CY5PR12MB6179:EE_ X-MS-Office365-Filtering-Correlation-Id: cc71ca9e-005e-4f8d-eef1-08dc7c3f3851 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|376005|36860700004|82310400017; X-Microsoft-Antispam-Message-Info: deCGLzX/V1y8E1Tqx8Fh3fF2X4SFWVIXBAZZTwvkHrIvwzSx9AcJYK+dzWOX+QriQOY6UE4ri6HE0WpZWblf64Skvx23+4xd0KlJHy63+jfTGXoRBz0L94CMvU/pXAX5kHCjV0QEl8+b5BKr8iJLY1+Wk924OcjWwo6Q4OnCyf6e8eeljC7A43WlawRJQwIzzEBQxSFU0/WohKSfq1dk5og8URauTXAeiCkGBsqDAXavhWcsiB5lRm62iQ7CB7ZEMwS3x4PIrVGsL0EcaE0ts4vwZENa7BYIA2D7zQpQwEaLmQ3DjfrujikEg/ajUmzBNbdAoi+kWc2ndWKFl0EQAiB8DVo6RIhYC8GH7qXtFw4n/iuyAX+3TacF1tiA0s9Ro6xqns3PmDqWBXZXz0wyb8gn1oWmwIjnD/CIbnOgzZ/p3M/eNgm5hvWvn/0CI198tBUMAmwMrA/qYTGtFWWLebWagMq+jreLm+6xIQKdgwDePDicDePYGXm+L4Aio8qagKHInO9S8IpQ1P/grvLT5BtaOgo407H9nKOPiqC3PhLFG/OvxT9ggf2hUT5fbIg7QdYnU4hnkf1Tig0Hi1gI6D1Zf1WzSfpsS1qGXreJvhXQjbwKPKd1nFCxJCugqozB9fiGtFlaxtluS+VxQCDaf6zKFyygE1Ajtt5nhhX0WYAFBTyj1XSONKqstknPmpIMHAeBimJH+FY9ZPQ97MELPM9j9EPB391ByY91WelFad13kl9UopNCfLqxxLnjGHy+W02gaaUyKVAfOhVcfYjlLaIgEhoQtPPZs3coeW8vOsaSrdeoVOm7nVrd49afc/9z86h6BJ4EtCjYTNp2N6i45czoGbFc7CudCpNhyb9TZbgKKuFuH1t1mAWh0UV/6Oa9I0Z04PgqgplJmOHYOBQDQrNMHKVaNoH1XVqd8wDXo6QUbjohM8d5KnWEEvMRaDNCUhT4FvuesX5j44SFxHIk3I6diVlpOFkbY4C3UYlkMyf5MACHphLtd6/ZhodE6d9t1F8n2eRZbFcPhgecu6qZ5VPeNnVuhxCEfNNgkhtgYmT1adIYYaOmGmKrHvFuheVTbHYFwuP1htWGVS4IasF2F6XChpS5rhIfRVi4mXpD9tHAiCp2i8Ny41ynCKbmhCxv1WuVMtgcN6WWRZB81PmlVkA3pILVy/no/QjAQMZokTAvpuxvFG0qCsVbPb1sjj14KYFtG0BIWzbUz9hPn2BsePcm7ieitz81SpoWXcjiX0ns+/yw7UaWyZn6eiAd9HufssvZURQ8vG51dNVWfYivAxq/juPb8noNfTfC76NVPCbcHvffcem74FQ/46HeJidN X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(1800799015)(376005)(36860700004)(82310400017);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 May 2024 22:16:54.8195 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cc71ca9e-005e-4f8d-eef1-08dc7c3f3851 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: CY4PEPF0000FCC4.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6179 From: Vikram Garhwal Signed-off-by: Vikram Garhwal Signed-off-by: Stefano Stabellini Signed-off-by: Henry Wang Reviewed-by: Julien Grall --- 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..ef3ef792f7 --- /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 one domain. The user will need +to prepare a different dtbo 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 the domain is not 1:1 mapped, xen,reg +must be present. See the xen,reg format description in +docs/misc/arm/passthrough.txt. Below assumes the properly written DomU +dtbo is `overlay_domu.dtbo`. + +You need to set the `passthrough` property in the xl config file if you +plan to use DT overlay and devices requiring an IOMMU. + +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_domu.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