From patchwork Wed Apr 24 03:34:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Henry Wang X-Patchwork-Id: 13641119 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 996C5C10F1A for ; Wed, 24 Apr 2024 03:35:22 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.711015.1110630 (Exim 4.92) (envelope-from ) id 1rzTPZ-0002ML-9q; Wed, 24 Apr 2024 03:35:09 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 711015.1110630; Wed, 24 Apr 2024 03:35:09 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rzTPZ-0002ME-5y; Wed, 24 Apr 2024 03:35:09 +0000 Received: by outflank-mailman (input) for mailman id 711015; Wed, 24 Apr 2024 03:35:08 +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 1rzTPY-0002In-KE for xen-devel@lists.xenproject.org; Wed, 24 Apr 2024 03:35:08 +0000 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on20600.outbound.protection.outlook.com [2a01:111:f403:2415::600]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id a506c8fc-01eb-11ef-b4bb-af5377834399; Wed, 24 Apr 2024 05:35:07 +0200 (CEST) Received: from MN2PR08CA0027.namprd08.prod.outlook.com (2603:10b6:208:239::32) by PH7PR12MB6883.namprd12.prod.outlook.com (2603:10b6:510:1b9::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.44; Wed, 24 Apr 2024 03:35:02 +0000 Received: from BL6PEPF0001AB76.namprd02.prod.outlook.com (2603:10b6:208:239:cafe::23) by MN2PR08CA0027.outlook.office365.com (2603:10b6:208:239::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7495.34 via Frontend Transport; Wed, 24 Apr 2024 03:35:02 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by BL6PEPF0001AB76.mail.protection.outlook.com (10.167.242.169) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7519.19 via Frontend Transport; Wed, 24 Apr 2024 03:35:02 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Tue, 23 Apr 2024 22:35:01 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Tue, 23 Apr 2024 20:35:01 -0700 Received: from henry-MS-7D54.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Tue, 23 Apr 2024 22:35:00 -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: a506c8fc-01eb-11ef-b4bb-af5377834399 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TKcmzpVfrV0OOl/Xn5jD86M501YCBgGcvdy/QkucbZP0WwkqcA8JZeft7D+m7hF85uDPpS9RG0ckJX+I+3MqzjfdIPljPCwKBbcMBFEUh3bMySFY+Q3F9Z3K6lmxk3KnLJSALP8ZmRL1y8qMHW5uZ09HIXviT3j+fp6mi+AH1gGQmMJdLS4vIAXc+GUZijgGhvkFfxGTRnF0jIG3Nblk911f4J/lqDTyiaURFEyEc5z2Td/kpkV2R1xgu68Nwc56Z6UA/Uj1Xky6of7uXGGY2s7XoiriADo+8J9rIGFePf9excNzq93AbqmBG7y4mzvOUlA19cxz4bqxdOzHPE+Klw== 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=mKgf7DQIPcUhTaQ2T+Lk3ZgLl1QF9wZZ5t5/Zbs5z1s=; b=ZL4lOzx9nTXHP6vtm48w89FS4esaZDN0RNUSVmxOzRSV9yFk/ioJvhQFz97l8SMwb7yAQ2YNbu8qM/ZC7Fi8jUNRmdVCy+ZIzxpzgbQ6yRFlbXE08sMQRoHreCE8SKDn3IIrLiV9aeDWYxbMxS0TbHiUdxWN9LHeL0x3NggwY+waJ6j5en87sjJ35eDgCaDGQEABFm9gz3M3jlvk5/1V7SHEFcc/OHv3sVZIGGrg8yQMBRR64cj+jp4Av4RmZB52dVTX7WN0BNIeky2kbk1246qlQ+hv3O3E6A9yIR7EGx2q4Q6hNInAWSZAWmo7L68h045shtF365IutRt9eP/pQA== 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=mKgf7DQIPcUhTaQ2T+Lk3ZgLl1QF9wZZ5t5/Zbs5z1s=; b=JzIOuo2GWZrZvbIr8LC3wec425bA6pdUsqYx3m6GIBKRrY25729GkWhMDge39hTGP+OsH1ONRFlvFw7kxFANhAfHwTU+zfT4n5fT83MMQ8nzRm2wK5uh5/+gPIRoTR8T+xSOSGf25B8OUfnC7cX51A/2YrkWFqTkfv7GqOVgxs4= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C From: Henry Wang To: CC: Henry Wang , Stefano Stabellini , Julien Grall Subject: [PATCH 01/15] xen/commom/dt-overlay: Fix missing lock when remove the device Date: Wed, 24 Apr 2024 11:34:35 +0800 Message-ID: <20240424033449.168398-2-xin.wang2@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240424033449.168398-1-xin.wang2@amd.com> References: <20240424033449.168398-1-xin.wang2@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB76:EE_|PH7PR12MB6883:EE_ X-MS-Office365-Filtering-Correlation-Id: e1e1d811-7580-4ca9-142e-08dc640f8672 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: =?utf-8?q?iPKHDF+DzVtLmyEXFSESSnBWR2ROIi0?= =?utf-8?q?a6b2PzSGaywmdP+Ms8mMYzS3k1+v6o3MdodJCHnnHw29dalfhsSG66R4k/A7Nng6I?= =?utf-8?q?DKxjp0fZe3PSVd9qSsDVusPYdfvsr4XUiy8/ywZl0bqa2iBgj/RMStIeGFGHTFEq5?= =?utf-8?q?m71AGurNgNUbl7xge5XIzauSEtsiufJgONUQHqdZWJWLO1BXhiGj84WTDSY3IV7wn?= =?utf-8?q?tPXMHL6LedQau8lQUH43xOGW4Hxb8T6I05eEFECxu9sQVD4edmGcWjWWYBwF550ji?= =?utf-8?q?894mobWmTjOMtWz2KhmrcNwwN9A8cDTh7vv3e4sY6zaCsZoI66JvoSYlOjhjpxKGe?= =?utf-8?q?CRaCCb3Oxule4l5mxMa50qEltNJHz54G+pjPdd55JGOpuPScLZcV4+r+3a7v05Zmr?= =?utf-8?q?vUUH6H4h0CA1+/CpOW8ybs7sd5nHQGMPyQYMBATZnqOvjVbTUinIqgGgtd7K4crbQ?= =?utf-8?q?0J4scTYzSzOCyJLgCo4yL4REjYbuy6tmrHB0zudO5vVh7ihdRau7cxDF4NFGSXfhK?= =?utf-8?q?/2KECWfhXWo+AWmxnemgjraiA9dPG8dBUC6aGJmS6KcDvbJA+qSBHfzyuCdOWcU7M?= =?utf-8?q?ZB8Vm7s3x96haEnJVy/Y3N+8WRAxdAimXmtxBMWpDu52N35y1uaxPu9El4uyPop5y?= =?utf-8?q?Wl32Z5a6nUj54Lv5b7BqTscOS3qfXAghUfE74mfzeEgxWZdeqeKWoWuAz8dHnpuMl?= =?utf-8?q?elLf6b0Ra98uX9T8lBg9q9igpatLJFunhhy7muFwp2jYRAPgQ/bYka4zmKSsXM0OM?= =?utf-8?q?/HnJWZ7IHrYdT6zRM+RAlLoJGAolgZr0AnSR42fScXoADy5xIkcD7koNY3peoCU63?= =?utf-8?q?mqZOkJbMu5HqRt53zbi8agQqKJWfre5TPhajf9xqcwzzf/twtcLNx3BXD2SmHkbnR?= =?utf-8?q?QxQuy2u9ZMl0EGrWXNbvuFibyinjyWipBUyGQhtV0Y2Gtvx5DqA9OvjaaUtF/jBI+?= =?utf-8?q?SInnzsOUKiQ+W2KVJ/8nxW05H1eUmQfMbSqUoc1t/ADQB4rA0MyNIOqCYqHJb9f3P?= =?utf-8?q?iGEo9TjxRYPdZqoD2RzbjdzRLZCdfrOmYjdt9mDnY8qOfMmw9GPNgNYNFa2vAQgXL?= =?utf-8?q?4lwVRdcTFxFgGH9cKpR5IHM7sVyyZfi20T3/yHYTugMvi2oTQyZn6PElNgIV98/pg?= =?utf-8?q?do98itQQ0j8zcKIP10veL8hO3zN3BLFFQcQTG1U5p7uLFrKGircJ8NfSSRgJvf1kW?= =?utf-8?q?3LuYZykZi8DKg6ZnJyXem4mAKXzaj20SUEtsIzCM1BdHptm3XzMu4E5ygPFTKZSQ7?= =?utf-8?q?/Y81FH4CdLCP7lxaVkwn17Rksh4KhMI85cR/hzZKR6PuZ9PN0z5sUsLMhaKNMJ2IK?= =?utf-8?q?wuzDDC65p66t?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(1800799015)(376005)(82310400014)(36860700004);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2024 03:35:02.2209 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e1e1d811-7580-4ca9-142e-08dc640f8672 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB76.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6883 If CONFIG_DEBUG=y, below assertion will be triggered: (XEN) Assertion 'rw_is_locked(&dt_host_lock)' failed at drivers/passthrough/device_tree.c:146 (XEN) ----[ Xen-4.19-unstable  arm64  debug=y  Not tainted ]---- (XEN) CPU:    0 (XEN) PC:     00000a0000257418 iommu_remove_dt_device+0x8c/0xd4 (XEN) LR:     00000a00002573a0 (XEN) SP:     00008000fff7fb30 (XEN) CPSR:   0000000000000249 MODE:64-bit EL2h (Hypervisor, handler) [...] (XEN) Xen call trace: (XEN)    [<00000a0000257418>] iommu_remove_dt_device+0x8c/0xd4 (PC) (XEN)    [<00000a00002573a0>] iommu_remove_dt_device+0x14/0xd4 (LR) (XEN)    [<00000a000020797c>] dt-overlay.c#remove_node_resources+0x8c/0x90 (XEN)    [<00000a0000207f14>] dt-overlay.c#remove_nodes+0x524/0x648 (XEN)    [<00000a0000208460>] dt_overlay_sysctl+0x428/0xc68 (XEN)    [<00000a00002707f8>] arch_do_sysctl+0x1c/0x2c (XEN)    [<00000a0000230b40>] do_sysctl+0x96c/0x9ec (XEN)    [<00000a0000271e08>] traps.c#do_trap_hypercall+0x1e8/0x288 (XEN)    [<00000a0000273490>] do_trap_guest_sync+0x448/0x63c (XEN)    [<00000a000025c480>] entry.o#guest_sync_slowpath+0xa8/0xd8 (XEN) (XEN) (XEN) **************************************** (XEN) Panic on CPU 0: (XEN) Assertion 'rw_is_locked(&dt_host_lock)' failed at drivers/passthrough/device_tree.c:146 (XEN) **************************************** This is because iommu_remove_dt_device() is called without taking the dt_host_lock. Fix the issue by taking and releasing the lock properly. Fixes: 7e5c4a8b86f1 ("xen/arm: Implement device tree node removal functionalities") Signed-off-by: Henry Wang --- xen/common/dt-overlay.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/xen/common/dt-overlay.c b/xen/common/dt-overlay.c index 1b197381f6..39e4ba59dd 100644 --- a/xen/common/dt-overlay.c +++ b/xen/common/dt-overlay.c @@ -381,9 +381,14 @@ static int remove_node_resources(struct dt_device_node *device_node) { if ( dt_device_is_protected(device_node) ) { + write_lock(&dt_host_lock); rc = iommu_remove_dt_device(device_node); if ( rc < 0 ) + { + write_unlock(&dt_host_lock); return rc; + } + write_unlock(&dt_host_lock); } } From patchwork Wed Apr 24 03:34:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Henry Wang X-Patchwork-Id: 13641118 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 12DA7C4345F for ; Wed, 24 Apr 2024 03:35:20 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.711016.1110645 (Exim 4.92) (envelope-from ) id 1rzTPb-0002nY-I5; Wed, 24 Apr 2024 03:35:11 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 711016.1110645; Wed, 24 Apr 2024 03:35:11 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rzTPb-0002nN-F3; Wed, 24 Apr 2024 03:35:11 +0000 Received: by outflank-mailman (input) for mailman id 711016; Wed, 24 Apr 2024 03:35:10 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rzTPa-0002In-EE for xen-devel@lists.xenproject.org; Wed, 24 Apr 2024 03:35:10 +0000 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on20601.outbound.protection.outlook.com [2a01:111:f403:200a::601]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id a525c537-01eb-11ef-b4bb-af5377834399; Wed, 24 Apr 2024 05:35:08 +0200 (CEST) Received: from MN2PR20CA0021.namprd20.prod.outlook.com (2603:10b6:208:e8::34) by DS0PR12MB7680.namprd12.prod.outlook.com (2603:10b6:8:11c::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.44; Wed, 24 Apr 2024 03:35:04 +0000 Received: from MN1PEPF0000ECDB.namprd02.prod.outlook.com (2603:10b6:208:e8:cafe::87) by MN2PR20CA0021.outlook.office365.com (2603:10b6:208:e8::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7495.33 via Frontend Transport; Wed, 24 Apr 2024 03:35:04 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by MN1PEPF0000ECDB.mail.protection.outlook.com (10.167.242.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7519.19 via Frontend Transport; Wed, 24 Apr 2024 03:35:04 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Tue, 23 Apr 2024 22:35:04 -0500 Received: from henry-MS-7D54.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Tue, 23 Apr 2024 22:35:02 -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: a525c537-01eb-11ef-b4bb-af5377834399 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JoPK4Jtfc5aTxJoZP3cA2KnDZXMZ16X2SN3dByJU4IAZJ3gu1npJCvlcgX9LFBfK335WhG/nSdR/xdSdcm5tESkD4i0Wqx7nqmmQBiIwA5dkoJzr6Ro5OmGoWNWcfNAHYK7AtuW6eGzg/XBWSDkdh6CRgK719ff1LbW9TXBzthSKHS5UXT3k56WEF7xnbDnOaMqmo8JEmCrYvm4LZ6oxQpqhekh24uHXsfnxgmG47cjQxttBu+yG7lRjoh6oFPJPGYoopKVzboHY24RBE3oYd7KQELiPqYWddga2Yr2o38iDSVS6Ce8rF8P+cw61PLehWjO7nqw1DrmC1wiJiPUzOQ== 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=mRz8rsYNOg7W8p6WCOVFtK/rtd0GqejAmZ7U+c2Atjk=; b=VwBwgNovkKBfqeElHufhdZxuS3xablGa4lsGyQHKMOh3n9T6rjlChgX23rXQqOu1GOzyHakJ2uJZYmxCYr6tGe+jo/Yfw6exJjQI7x0kXOsJqnUF3xPFnjFV4u3SGwBdu0svzFqpc5sHG3qllg1mkjorbdrA5VS4hHP5AwTBiupS1nBJf1Mjqe35MNf9+hDkdg9J9Efc3Ue4ECU4CbUuXUUHuXI9Li8Wf5uw5B2XlJJ4EdQEV3QDvbmSZSX5TLC7t/51vbxWeex1QG70WSUY9f4hOGFArmtWlvQnMLobrqt109OLpbF2yFinFWaNRl6z9coGfpr9DyFgaG1TUvfjcQ== 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=mRz8rsYNOg7W8p6WCOVFtK/rtd0GqejAmZ7U+c2Atjk=; b=dEWKSDVl/TkuQjzuchM1mDVKmCH/b7/qtN8Qg1hUvOEP9DjxAeTe7cKDVCJgS1SNHASRIv/mbEHB4wmW2+E5ET1uZBmzIncY+fojKFprU0ipxp9xvgtbwTzTPmUuKiDn1wKGLHDrG/xyC9d47F/nmkere+Tqe5OKDxSi+0To7hk= 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: Henry Wang To: CC: Vikram Garhwal , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , "Volodymyr Babchuk" , Stefano Stabellini , Henry Wang Subject: [PATCH 02/15] xen/arm/gic: Enable interrupt assignment to running VM Date: Wed, 24 Apr 2024 11:34:36 +0800 Message-ID: <20240424033449.168398-3-xin.wang2@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240424033449.168398-1-xin.wang2@amd.com> References: <20240424033449.168398-1-xin.wang2@amd.com> MIME-Version: 1.0 Received-SPF: None (SATLEXMB04.amd.com: xin.wang2@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000ECDB:EE_|DS0PR12MB7680:EE_ X-MS-Office365-Filtering-Correlation-Id: 59ed944a-8879-47d4-4eb9-08dc640f8801 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gy/DhkHsf1PBtujLtrnvaDMkm/tllfcv5PM+8bT1T3vXe7n9QB5UvmIY7Ajli2MdspljOIRjh/IJasxK9TVuuvkK+d7uV9f99ZgxPEcGI/qcmAX7Az+jGASm+//7T50QL/arMV8d0PZ7vqqIeMrcul2gRtXxoQGJFM3LNha8FzfwlPri/bKKfmd85Tv8P9VhtAZhZrgudvMv+BGa0gG+ZWsbVsbiXTVcFbx+3xQzjo6Tajpjhi17PuVMWdJEcszp6e9gs5Ky66XkhATqDXOilJs0658vO/dhQu1QFMtScuMCfYptWyquaBPytBjxH/lpNYFmNkM6jBX0SkZjQRctqgowz0XfhCW52bnQ3kV3SEJV8AGD+j3qfjZQ97G432oR95jyvYB+Dl14Qc2qakEeVTguNXK0zDmVloxPAJ+dSa0Ag97ABYG6Pu6Wm0CIw29hqNn2A0Y8ZoWdq679bYHLPnPiPbh0uiILckLiM9KKNzkWdPGaU7NTyojXSdquGELKuOwlVfmTLNEDQHpZF7f5VpI9DK4ypUYXKpQiCSCUZtuQOa4qydsuVZDQG/0jGlIxaEfXorwPSvSyOuX2ecNgNiQCGgTdu9w0jPg5cN9MS4rLi3ivKuTa1zxZvWT/P0O/TkkaDxw3Kkksx34akkvpA4rc7Mu5+aUQ9j4rXNdibGEAJBktEVMuZ4rb9/3+/ibLS00aT/uGQoW594vVgvQeRPIFjK5XGZst5nVgWzIut83FCzJ2J+0S1uR4wKVepHuTEopMaAV44bmBjuyXktoIVide9U14JRk//LUPfIwcRBHp1lc4mfMxLRoC110F7ZsV6V7dmBdkDjWtzMNd6UQHZucKeBvxGlseALc7p89ggPVHjFfGUJ5TJz0T4myCFl3sc3eifh/z6yOrU5ND8xYRlxXoQKMKm1W22qa4M54iqjWanx8jL+M5FFBfFPLl+tmVyYJN8idjsvZJBAYJ7H6UUfzDXfWchFrvRgKqIaC32USk9HrVxrszhxz8aTogX7rpgGvYDoJ1KMWmI4J1I46uY7txSN7oBf5tvZI5eJEWvYPwVIHTi4zb29iWPnRlqssz7TgCteO5LGMDCOAi1kIphE8C7gmpbFPP3JZBm231DfFpc2LETFmXATBWnRWNiOM4o3ZJ/GWQfKDil5HqG4eKveesW4dmSe4eLmT0iDBoc6y4sVrlHKcC67helCPZZXpm82BUdYDbv8MwClTxUxPdqpcnv47P9gOFu3QsQgt7WOLUiGYTi8k++qILUnSC1c6y3cavAu6bN8BJucxluO5Q1BrGNoUF9fTd4DA24GjGimqN7Zd4fCSGq7bHTY2X8ArU4yIlrAQ1o0ZV0J3losRT+CgOQSILmj28n2hd0E8EGKC2ByGOhQnSUJu1opJSfwjj 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)(1800799015)(36860700004)(82310400014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2024 03:35:04.8373 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 59ed944a-8879-47d4-4eb9-08dc640f8801 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: MN1PEPF0000ECDB.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7680 From: Vikram Garhwal Enable interrupt assign/remove for running VMs in CONFIG_OVERLAY_DTB. Currently, irq_route and mapping is only allowed at the domain creation. Adding exception for CONFIG_OVERLAY_DTB. Signed-off-by: Vikram Garhwal Signed-off-by: Stefano Stabellini Signed-off-by: Henry Wang --- xen/arch/arm/gic.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c index 44c40e86de..a775f886ed 100644 --- a/xen/arch/arm/gic.c +++ b/xen/arch/arm/gic.c @@ -140,8 +140,10 @@ int gic_route_irq_to_guest(struct domain *d, unsigned int virq, * back to the physical IRQ. To prevent get unsync, restrict the * routing to when the Domain is been created. */ +#ifndef CONFIG_OVERLAY_DTB if ( d->creation_finished ) return -EBUSY; +#endif ret = vgic_connect_hw_irq(d, NULL, virq, desc, true); if ( ret ) @@ -171,8 +173,10 @@ int gic_remove_irq_from_guest(struct domain *d, unsigned int virq, * Removing an interrupt while the domain is running may have * undesirable effect on the vGIC emulation. */ +#ifndef CONFIG_OVERLAY_DTB if ( !d->is_dying ) return -EBUSY; +#endif desc->handler->shutdown(desc); From patchwork Wed Apr 24 03:34:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Henry Wang X-Patchwork-Id: 13641120 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 A0A49C04FFE for ; Wed, 24 Apr 2024 03:35:23 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.711017.1110654 (Exim 4.92) (envelope-from ) id 1rzTPe-00036K-W8; Wed, 24 Apr 2024 03:35:14 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 711017.1110654; Wed, 24 Apr 2024 03:35:14 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rzTPe-00036D-SP; Wed, 24 Apr 2024 03:35:14 +0000 Received: by outflank-mailman (input) for mailman id 711017; Wed, 24 Apr 2024 03:35:13 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rzTPd-0002In-SH for xen-devel@lists.xenproject.org; Wed, 24 Apr 2024 03:35:13 +0000 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on20601.outbound.protection.outlook.com [2a01:111:f403:2417::601]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id a828a1fe-01eb-11ef-b4bb-af5377834399; Wed, 24 Apr 2024 05:35:12 +0200 (CEST) Received: from BLAPR03CA0041.namprd03.prod.outlook.com (2603:10b6:208:32d::16) by MN0PR12MB6245.namprd12.prod.outlook.com (2603:10b6:208:3c3::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.22; Wed, 24 Apr 2024 03:35:08 +0000 Received: from MN1PEPF0000ECD6.namprd02.prod.outlook.com (2603:10b6:208:32d:cafe::24) by BLAPR03CA0041.outlook.office365.com (2603:10b6:208:32d::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.23 via Frontend Transport; Wed, 24 Apr 2024 03:35:08 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by MN1PEPF0000ECD6.mail.protection.outlook.com (10.167.242.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7519.19 via Frontend Transport; Wed, 24 Apr 2024 03:35:07 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) 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; Tue, 23 Apr 2024 22:35:07 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Tue, 23 Apr 2024 20:35:06 -0700 Received: from henry-MS-7D54.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Tue, 23 Apr 2024 22:35:04 -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: a828a1fe-01eb-11ef-b4bb-af5377834399 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GyKfnslBHUGSFb+U1g7rUkgwdiou/ZcNHLpd2EtH6LMQwIfu6mAyhdxNIMaz9q20IoSPZSJSuuhak5CKkC0Oxl/OPKS1r2srfnoyKV0EwkRBYqkRQ3eNm5rMI8tI5hecKM0TXRNhFkPvMjnzP+B5ST2Ncdy9IMxwMXavQHH1AkLQ5k55ZkT0/V3aOjzzc8T+yFFRRIfXGVOuRoEXKQ24qm1N4sb7GApTPdPWUJpWpyRts+MawUB1qOTqbJqcG2M2UjcTE4tUTvY07rbsi3UFunRgBlilD/HxcB7tCi4xLQb2IhefcU/JXr+5SCMw2RYr9YPYrmrQPGfjKh+JZK9wWg== 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=71+mKXETSrKvqqiB26Vzc3zFez3NgUks8pMM+W1JiUo=; b=QXPq3AJwNthBY1mqJIf7+j5udijF3rcURmfDt5slmyIMkeDyW+f8jrw4ylwze/WXeOU2mG7YUnJWkIBtQdh17RCV4ImzhNUVEnf7fkST3Z9VnRqdkGdmezUA7QoCs5m9mnVJSdn9fdAC62fFJTgRAiVrg/QaK/pXhuOgswxisZKV7j2elliIkgfukno1jEvFWjqC5OTXQGXmwKT1QwKICILFHpjIboeJy6uc/Lqj8PwjF7M8ivTMPcKpzoatoKX39Cmy8p3HR3gVjg4l3tY2A58mSCNhW/2OKSd2x6AgALT16yWVVxzXF2OhfII9vhyT1WQ0fXK/eEuCLKyc+Z0+bw== 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=71+mKXETSrKvqqiB26Vzc3zFez3NgUks8pMM+W1JiUo=; b=tDJldnezdawTsLP7hJqnQjfwme/BKg/ApBCTczBMh5bpdhdRJNwQ9Cd59aFmihxtZSFcohumCLbD9BJ56wrLkPp/HPrx95KojSXLiW/PtCbEUt2lnlsZUwzDL3Yr4sEr+sAd1we+f0RGGAVIiit10dr6vE+rsWUfJc3Rawn5cDw= 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: Henry Wang To: CC: Vikram Garhwal , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , "Volodymyr Babchuk" , Stefano Stabellini , Henry Wang Subject: [PATCH 03/15] xen/arm: Always enable IOMMU Date: Wed, 24 Apr 2024 11:34:37 +0800 Message-ID: <20240424033449.168398-4-xin.wang2@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240424033449.168398-1-xin.wang2@amd.com> References: <20240424033449.168398-1-xin.wang2@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000ECD6:EE_|MN0PR12MB6245:EE_ X-MS-Office365-Filtering-Correlation-Id: ebbf373b-8405-468b-5ba0-08dc640f89be X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|82310400014|376005|36860700004; X-Microsoft-Antispam-Message-Info: 3HMUgQPmwsD+InmnusLeZYmqBWwE8K7hNQMnrxLWCLcqPUpMJ1+cZUW6YfWMgemu7NaQtarL2uuhg0WJVkjowH6Sga3WCBipcYKQ/F0VEXYe+wrQXdZBH+WU7KA8zakcpuoYi78BiItXXlcVFqPpgav0DM6pZH+F2MfmrHvagWw0qac/+rtxMjWkqBIWK3dO5XK49zBuNCP971HZvngBrN2XWNoKEho7NJTsesTsv5N+r6YApLhkCSTG7/pogEhV81gZGvBU2+j9P3EnyxZ6S7CVE1eyxRxcMo/9s+Kvos1GouMLqNHosIhI+L2Cr8or2AH18zBJpn6AgdM+UMrdQhj1rWBpydfCSZosA8Eo0/qXWiI0XWxV33s2mE0giM0qrJIycciv1BtdRBaF6JpMy2sPC4UtyGwa0A6j1rACipoAVeE+uSkLu+O9/afDIlZk0FXxYKXtd8/u1qQR/o8Eq0AfjS5ggVwB3qs0zFzJa1ZeZbNyqkGvr4I+F64Wo+dgXPu2Lx+QXONIQXe39rJUPPFpwS+ziUd90OK/h6FKHo1gr7mOknBUo/RPhfieKDIP5a4n3CeCZ7gDhD4uSZpZgKWDApN6cizUKKySsnhYhkMdwb9HsllxnAifeHFjwubiiJhf804jkt/N7O2RXeSLWKuQ2iS9hWBB2oQXhWbjxCuFf6h/CXsC4FHMPxDPLoYTeEz4TFbqBL5cn4S9D4l8lz4lUMbgfa1R+tgt8hfWXXIXFzti6pggg3zNGA9m1bWVCCuNUziHJ9kPjV11wql+DtbXI4+whwKz0YfashCxmeOa42WlE8VrGnHdYvLmDuzYd1Sw7ZDjkVisFyopSz5qwYFmcSKPOkP3z2aD1lQpB2aQ/rZ3r8gxtgAylnjBZNDAZKz18r3Q0uGncGFLI+UyJg5KxOho1K01HPVHAf0hXVtlT+5VDdz4hoz4+5JkF6tcnrY2sU5U3w5QQyJU3L5wrYoldoeqkvUFkRwzzPvGBfB+TVIKuJYkTNcLlsSNyCVnp6YEg8ixYQcQ69jAxkdQTmezO+gLW1UPq5zhg0Z5SKQDCO7Lnc6bcpinXjCwkC6OLlBPTQaH5hYTmcYSL0alYIFZO76tlo9D7A+Yf91qVI5sta84A1w03vKaLMoxuO3Wz0Gx4IweBynVdn0BOSA3L011hJHxQ8dOVNbdIwq5U1f+CkQ4ucnJK34Yhus7H/pj6DLIo9DMSxhFHeODMzEw/rA9pRD2syWTiISMyzv/nlUfeDWwYadsn7grZtgBnSWE+PqgRUuot9lT42EOJyvRqH6ZOmoJioPhgXt2buJoPBRmmoAgexqxbGPxgey+wEiJ+hmn2LKn1pzGQ2Bh1fEa6WF2+BFsx7J30jv73H+Mi3w= 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)(82310400014)(376005)(36860700004);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2024 03:35:07.7539 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ebbf373b-8405-468b-5ba0-08dc640f89be 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: MN1PEPF0000ECD6.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB6245 From: Vikram Garhwal For overlay with iommu functionality to work with running VMs, we need to enable IOMMU by default for the domains. Signed-off-by: Vikram Garhwal Signed-off-by: Stefano Stabellini Signed-off-by: Henry Wang --- xen/arch/arm/dom0less-build.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/dom0less-build.c b/xen/arch/arm/dom0less-build.c index fb63ec6fd1..2d1fd1e214 100644 --- a/xen/arch/arm/dom0less-build.c +++ b/xen/arch/arm/dom0less-build.c @@ -894,7 +894,8 @@ 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") && + if ( (IS_ENABLED(CONFIG_OVERLAY_DTB) || + dt_find_compatible_node(node, NULL, "multiboot,device-tree")) && iommu_enabled ) d_cfg.flags |= XEN_DOMCTL_CDF_iommu; From patchwork Wed Apr 24 03:34:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Henry Wang X-Patchwork-Id: 13641122 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 92AFEC4345F for ; Wed, 24 Apr 2024 03:35:55 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.711026.1110665 (Exim 4.92) (envelope-from ) id 1rzTQD-0004M4-8U; Wed, 24 Apr 2024 03:35:49 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 711026.1110665; Wed, 24 Apr 2024 03:35:49 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rzTQD-0004Lu-5N; Wed, 24 Apr 2024 03:35:49 +0000 Received: by outflank-mailman (input) for mailman id 711026; Wed, 24 Apr 2024 03:35:48 +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 1rzTQC-0003iy-19 for xen-devel@lists.xenproject.org; Wed, 24 Apr 2024 03:35:48 +0000 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on20601.outbound.protection.outlook.com [2a01:111:f403:2405::601]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id bce454dc-01eb-11ef-909a-e314d9c70b13; Wed, 24 Apr 2024 05:35:47 +0200 (CEST) Received: from MN2PR20CA0014.namprd20.prod.outlook.com (2603:10b6:208:e8::27) by MW4PR12MB6780.namprd12.prod.outlook.com (2603:10b6:303:20e::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.44; Wed, 24 Apr 2024 03:35:44 +0000 Received: from MN1PEPF0000ECD8.namprd02.prod.outlook.com (2603:10b6:208:e8:cafe::34) by MN2PR20CA0014.outlook.office365.com (2603:10b6:208:e8::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.22 via Frontend Transport; Wed, 24 Apr 2024 03:35:43 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by MN1PEPF0000ECD8.mail.protection.outlook.com (10.167.242.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7519.19 via Frontend Transport; Wed, 24 Apr 2024 03:35:43 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Tue, 23 Apr 2024 22:35:42 -0500 Received: from henry-MS-7D54.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Tue, 23 Apr 2024 22:35:07 -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: bce454dc-01eb-11ef-909a-e314d9c70b13 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dnJNKrP5ZUBD6jx8Qxxh4v8Hw6TdkyXdxAKHvCK1sKALL5L/wsfuuLR9wc/86LYc/imdJwtVqjcEqzu+GpkvevXfz7XkfyjPM+CaiO7X2Pirnycd00NypQ7qWHSO15bCENg2Rq/GsgXaveXqlVja5Y/YIIhFPgxAPbEguylTL03mQ0AoFd/NbRFKHfd5BpTb9c+JyuWYsmMNjtPXyCmAif5hlL5u9sTGnPIMfV8v6EIdIq+FMmH2CIspekwA5W4S/vvwj9GuWC1KDqlIaIXhmLm/EaG3k8SuXB9kLRC2wztJnQcmGsqWHidzALruMkOQs5hDyR90raKkidBuzsugdg== 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=h0iAu2KLuWONYe8oojEyCYpFwDMZMJe4duy+fEUGegc=; b=ajOlT1d5RiqGy5SNcLlFmedWUXYoedWwb6m5K7ajTeJ3UA6zSA2yJR1MroDIqCKXGOx00Gryem5ekYnaHqU4/GGDZ2q1TbZR/BZNlMcvfNg2HZ07xROfAEANZok6O4b9ZHMDknLot75gFuCqMQBdWTACMLwgTwNwAGYzetV4sB60o4BB3eYRsHsed92x3YP1F9cYVrcWmf9Pg9EaqZRlr1l4DDv/F8lwmVEsMkNVrshe/D2O+dgzkgqoxgU5O1ebvmTwh6zxsgINN3tMhEAr6wPqCG5G/RSeVkWpEANNVSglC7TKBJTcg22dtFAjXVLerBtuTmxebyhUNTTjM4YMCA== 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=h0iAu2KLuWONYe8oojEyCYpFwDMZMJe4duy+fEUGegc=; b=sPJE5A5QXx8bLUDbBLFG/J0Nj9QvE3wi1XbuZLd2JvUfdy6JKbarABBoSgdHonEUIp/a6IU5ZNkb9lctsqD/n6Ou4Rpkhy9uxxQsGGi1F+IF0oJo4G1IvBkMwgNcdm7ngnaOuUs0iwbKcs4NFtsQ68JpN0Ys2jJ9hwQb3HReyNM= 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: Henry Wang To: CC: Vikram Garhwal , Anthony PERARD , Juergen Gross , Henry Wang Subject: [PATCH 04/15] tools/libs/light: Always enable IOMMU Date: Wed, 24 Apr 2024 11:34:38 +0800 Message-ID: <20240424033449.168398-5-xin.wang2@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240424033449.168398-1-xin.wang2@amd.com> References: <20240424033449.168398-1-xin.wang2@amd.com> MIME-Version: 1.0 Received-SPF: None (SATLEXMB04.amd.com: xin.wang2@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000ECD8:EE_|MW4PR12MB6780:EE_ X-MS-Office365-Filtering-Correlation-Id: 15fca0d2-4893-443b-e846-08dc640f9eec X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: f5BKQ8vMDfA2eVgbv3A6UtLPJmTiKI7B+OQ9n6LakatVv8nLopf/Zfzt4K9oriV6dL72Mi4fL/zvfwmib0vjagqotIWExXm8YHVvda4p/GcRNSZ8+/SmTcdh31E6SdcuoqoReJyzB8Ap6Af64r3vfO90EMa6T8DdkQlLt5il/WnShTDSjZLxDtZD3i2IJWDZSc4h4RCNyIqGXK7VIKk0Xovdkyx5poH8D14L14LojalEQmzyDG+neG2LwPZOW8qviyziwEihMJBNZbXiDYauLQZ5gKGU1YzB/Nt9e3WXAHPxFoaSeAjVXkXp7Tzl8wOFalOu1mtgtIzyrruLeGKuVS1MqipQ2jn9arPo7KLKesQC9LJPYmeRAJcn3oiy0eW32RsQS/uuqd78rGAcyLBii67MexS7O7T22JfdAJFF+93onNRUBOBHIg2OnqHiGkoIyuC8OmWR1czWXjmsmO1qFdKWI5ffhra8ig913Jy0wVKd2NgeX+cHOnIvZad5Ahxx106G/VWsxITj3+3Ap7DJMYsP+IFg0GnJda8b3XOiiCUxCj444MQJaS8QQEz+BjlYYXAgs5eu3q4SbQD1tPFPpA/c3jjQzUBoKsDji05KTIiqMjqyRDA10jB5nXQlZOGq4ApUdM2nFPkGXqIIDt2IdiCVmtVhFvJeApCqkj+OhdcTAQDa97tzqKdQyH8wEmquTe2j/o3vBbCBUfW9XB8XPXxCanu9e5bnk/zv2z60XcWRSA+/WvxUYzd6HZCVlaeI3kB1SH6uiawvtXQdEYJOYcWbXiakMAKyr763IeoxZti3ZDRJifxa4pxuRMgQjKm+aQaZGILvoHlyooA2rGwj2ZfS4ZR0C8UuUiA0z3spSoGNAgTdbq3o7UnCGmyl6Z+z5TwKCO8VzJ/KbZrkkVS0yzQhLyh2hdn0QUJpJgFEkIbJqDuWCCHibIy8418iuzbqcFajG41F9BnabEGbG7Ojkxx9EMafywYgybTWEV2Cwfw0cpM8LsAyPbO2Yqd/Z/+mtZGFNHjZPkVnrm9ICb+ZXrqAAHE+2rc4IUOW7rcCwl8xv359FwGTOBomnj/PghvVwqRHca8i5DiqumOPnPC+yMchggW3xSyU8jYVVW74JToWlevl8SbYkkEfW9vq5m6jxE+77YzVP4WszuFDrcNfmClgzklZB6aX6DKzuLCDKJ1Ek1S8GK/Ca6ach8HA+ft45iNBKNh8Tgy5ZBcEp8zy+Q+zQ546ejjbuGz2hUKJC/yJuDWX3WHp6yTVXmYj9YWEOEXdDKwZdGb+d3S+kXf478ONyOPYY1Nz6jaFr+rNYwENT8mAmcO8zgQKovGMbpaUm3N4VcvwnDmMLO3Jz0whML+PPpe/RMsqBFWnjLq2e8bZhVddCg4vEi5UUTjaYI8j 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)(82310400014)(36860700004);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2024 03:35:43.2912 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 15fca0d2-4893-443b-e846-08dc640f9eec 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: MN1PEPF0000ECD8.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB6780 From: Vikram Garhwal For overlay with iommu functionality to work with running VMs, we need to enable IOMMU when iomem presents for the domains. Signed-off-by: Vikram Garhwal Signed-off-by: Henry Wang --- tools/libs/light/libxl_arm.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/libs/light/libxl_arm.c b/tools/libs/light/libxl_arm.c index 1cb89fa584..dd5c9f4917 100644 --- a/tools/libs/light/libxl_arm.c +++ b/tools/libs/light/libxl_arm.c @@ -222,6 +222,12 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc, config->arch.sve_vl = d_config->b_info.arch_arm.sve_vl / 128U; } +#ifdef LIBXL_HAVE_DT_OVERLAY + if (d_config->b_info.num_iomem) { + config->flags |= XEN_DOMCTL_CDF_iommu; + } +#endif + return 0; } From patchwork Wed Apr 24 03:34:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Henry Wang X-Patchwork-Id: 13641138 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 8A37CC4345F for ; Wed, 24 Apr 2024 03:35:59 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.711027.1110675 (Exim 4.92) (envelope-from ) id 1rzTQF-0004ba-H7; Wed, 24 Apr 2024 03:35:51 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 711027.1110675; Wed, 24 Apr 2024 03:35:51 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rzTQF-0004bT-DG; Wed, 24 Apr 2024 03:35:51 +0000 Received: by outflank-mailman (input) for mailman id 711027; Wed, 24 Apr 2024 03:35:50 +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 1rzTQE-0002In-MM for xen-devel@lists.xenproject.org; Wed, 24 Apr 2024 03:35:50 +0000 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on20600.outbound.protection.outlook.com [2a01:111:f403:2412::600]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id bd439ab8-01eb-11ef-b4bb-af5377834399; Wed, 24 Apr 2024 05:35:49 +0200 (CEST) Received: from MN2PR20CA0023.namprd20.prod.outlook.com (2603:10b6:208:e8::36) by DM4PR12MB6445.namprd12.prod.outlook.com (2603:10b6:8:bd::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.44; Wed, 24 Apr 2024 03:35:45 +0000 Received: from MN1PEPF0000ECD8.namprd02.prod.outlook.com (2603:10b6:208:e8:cafe::6f) by MN2PR20CA0023.outlook.office365.com (2603:10b6:208:e8::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7495.34 via Frontend Transport; Wed, 24 Apr 2024 03:35:45 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by MN1PEPF0000ECD8.mail.protection.outlook.com (10.167.242.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7519.19 via Frontend Transport; Wed, 24 Apr 2024 03:35:45 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Tue, 23 Apr 2024 22:35:44 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Tue, 23 Apr 2024 22:35:44 -0500 Received: from henry-MS-7D54.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Tue, 23 Apr 2024 22:35:42 -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: bd439ab8-01eb-11ef-b4bb-af5377834399 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=l7SEcH28VM54chhn+ZsVd9lyXDhMZSP3I32oAj+wbJyf2DTLyNT6Xg8xqd5J0N61cNaXYB5apZXmEW1RRzmMy7psGNJCHrFZ1NrGfSigFFJ0S7EkRQnaCvRZ7z57m9bM6hZAaIzk6bTp7pPlc0Pk4OzreyD5OzDwgIrLpIZT5nlJ+IS9rsdZLc/wA1hY6BGvL92OovlCDubUSpKEX/LRUMHYavPJTE1/aEL67pQwQ/5w5//VfTRWWCafwRC1UEh8LgV7MBeL7VVZEMblglNdXLjOw+9dsGzmeDK9CS5g4GpNMv03Fu1Rx1WZwrPw8WEovEMO7HaAZLDVBdM6HwboiQ== 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=2CXTiKjl6H23aWyq/JRcR1V9QG6E4fZMm3DFM6arH00=; b=lvTuWc7Lc86Uy4n6iQRWf/WUrROcZpwFxoGDQshC0lRv14nvYfCybpmEhMEygu1QsuLeviBV9rHQRvI29TwYwrpxuSZT2vezgqEfRZnpqkS4m/Y7rCBBEWsIYby1wdO4TkzpQUF2gDcUDnrvArSU+dpdIY5NqCJmImoMRmMg2JfoxCZDrUf6vOI33dZrHxrlDp2BiscP5Hiux1sEnNTlJ1rgC+WA8+ouCVKL+B4Zknj27iruBuM/obzpjgm+rlLBkqYezURtZ2jaBgMjnUYsXxHblbJ8LF5YLE41epEUkxMv/q49m7ha3YdvGWqAYI6i2+BiEeE1/lxnxg3C2uXkxg== 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=2CXTiKjl6H23aWyq/JRcR1V9QG6E4fZMm3DFM6arH00=; b=hsGHfvenorc/ZHnHvZ4b1z/NaDr1Kj4qYqxy2dZuhD9rBSBWgRT4vhbjz8CGXgGrBIDmBMUOkZm87PnZpfM8YrdgxQpXk90iJoYACWTydbDF8swcaYec7rUq19fmfEHnDOHU9UrZ73HfuSOO1e2vL6J6hLbClEace2/9Zu27KlY= 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: Henry Wang To: CC: Vikram Garhwal , Anthony PERARD , Juergen Gross , "Stefano Stabellini" , Henry Wang Subject: [PATCH 05/15] tools/libs/light: Increase nr_spi to 160 Date: Wed, 24 Apr 2024 11:34:39 +0800 Message-ID: <20240424033449.168398-6-xin.wang2@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240424033449.168398-1-xin.wang2@amd.com> References: <20240424033449.168398-1-xin.wang2@amd.com> MIME-Version: 1.0 Received-SPF: None (SATLEXMB05.amd.com: xin.wang2@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000ECD8:EE_|DM4PR12MB6445:EE_ X-MS-Office365-Filtering-Correlation-Id: c8c0de3f-1c74-4541-3c8d-08dc640fa025 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yFrNObRJOo0hw8J6RTQB8PnSnEsGOZf/E81yg9ertyGfByCuesthuFZUUzIxxpkP74rYUdD+KcqtzVPKgbrYo6c1N7/qGgSMsCPLiNK88DBX00wqO0xX5BJ4b4PWvIrnxls8z5mB/fhixSS83CTmCvEwgFugdeZhe709mhiFmV5Lyl3zwxTXM5Rzrn8RFT2bShySZixcKpeRcXOAIn+j1QrOClXlEV1zQHwNioEZMxOTN1ZT3vj5rVb7j/tVhCE3J2crTgxezqwCBtDbpWPnK8QVkho6C6saNMEDbj4yO8kpwq7pZP8640d+kpmy964MTZsQKUn5SlpukNwDK4CiuEN19fVfq5fbNQEN7a20EiniXv3dhRkeMz+mpyU9Gr1cHYFqPlgmDA1asZR6kpgdgQfRFNXMpHCZlAAe7ujNY8sLIN1vpuWCxvtwb8lCPv+WHCVN9bDEnJRPIcJm32lG5G71xFoYQrB9LAQP/YsyGzKa9lDzkZQzk01kJMlyA2GP5+TbcJd2oe457OmcPOpihfKiWwZ/ufM0rEnBStrdAyb2V4kQ7GcgIMIAjFN4x5xkMpixN6/osHxuX7SnfM8bT11l4S3gqeen/D6tkYaJdEjMD3Lg0exEUdCNJKSelUN4LgOF/8gax520kD09AOkOXuD9jVSYxHxM45oR7KTsk1NUwtqpWK4aT78KOpjyEq/Fobg9jgewuNtpSDEPgf8fT8CBcuPDoUhv3JEXohPZSqjnvE0WQ8Mp0CxJRNZgItCrpJjCiMTpcO71of4LACvofRnvmd8metVBP8C7ab42Xk70SOHwMKmWjCq85bZXDUlW/Oa9DJFEcgxaAZwQI131QsplAmesfZTWo5JWH+pTce8C+9gwWrDexT329axIiYp6S63KonsnLZvovu+Sni+Oe5cB4Vw0r4wCTpZ+YCUzNO5TFZDKHFZr4Tyv92JTF0L3V5i/t/Pw14Q+GGV7ZXpEWGHrzcSVlScHPC6gSEb4JJfRlrzzp8Y3mP3kStkbIWCTo+Z/WfP76tqw24AJvEbmKgrLIyC62MY3j4f8O7vrBAdJFcm22fqcq6Rj0BlUWv8czf+p1GYCVcTxmfPZYHHFVC5d1F5kr4oidgAj10zZCnlIyp6n/puyOogxjaqocn0eokZKHvNgHHdOyu1HyeqWRJaGGxKIRgMIUv2jSHz9Ix3v+Uvn7d0dy+INRIzoc+ckOwJhfdRQgaR3TbzTCNXVFpw+EIFgf2zjaDEmquBxOZigVSL6l8g6ZdtboRRRWozNGqSQg3wey6e6WClX7pzlACKctc+2HKffpX9zTtDVDgpgE5xwHO/haexQ+mZuSc2c3QbTRiaUoQ6f5AzZ8brUxShccC9gyKYfYGXXIENTlKZmOg384JCaD2Qn+t7nipBt 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)(82310400014)(1800799015)(376005)(36860700004);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2024 03:35:45.3380 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c8c0de3f-1c74-4541-3c8d-08dc640fa025 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: MN1PEPF0000ECD8.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6445 From: Vikram Garhwal Increase number of spi to 160 i.e. gic_number_lines() for Xilinx ZynqMP - 32. This was done to allocate and assign IRQs to a running domain. Signed-off-by: Vikram Garhwal Signed-off-by: Stefano Stabellini Signed-off-by: Henry Wang --- tools/libs/light/libxl_arm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/libs/light/libxl_arm.c b/tools/libs/light/libxl_arm.c index dd5c9f4917..50dbd0f2a9 100644 --- a/tools/libs/light/libxl_arm.c +++ b/tools/libs/light/libxl_arm.c @@ -181,7 +181,8 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc, LOG(DEBUG, "Configure the domain"); - config->arch.nr_spis = nr_spis; + /* gic_number_lines() is 192 for Xilinx ZynqMP. min nr_spis = 192 - 32. */ + config->arch.nr_spis = MAX(nr_spis, 160); LOG(DEBUG, " - Allocate %u SPIs", nr_spis); switch (d_config->b_info.arch_arm.gic_version) { From patchwork Wed Apr 24 03:34:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Henry Wang X-Patchwork-Id: 13641141 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 2D1A3C4345F for ; Wed, 24 Apr 2024 03:36:23 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.711033.1110710 (Exim 4.92) (envelope-from ) id 1rzTQc-0005xC-Np; Wed, 24 Apr 2024 03:36:14 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 711033.1110710; Wed, 24 Apr 2024 03:36:14 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rzTQc-0005wj-JP; Wed, 24 Apr 2024 03:36:14 +0000 Received: by outflank-mailman (input) for mailman id 711033; Wed, 24 Apr 2024 03:36:12 +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 1rzTQa-0003iy-T2 for xen-devel@lists.xenproject.org; Wed, 24 Apr 2024 03:36:12 +0000 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on20600.outbound.protection.outlook.com [2a01:111:f403:2414::600]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id cb35a9e6-01eb-11ef-909a-e314d9c70b13; Wed, 24 Apr 2024 05:36:12 +0200 (CEST) Received: from MN2PR07CA0004.namprd07.prod.outlook.com (2603:10b6:208:1a0::14) by SJ2PR12MB8807.namprd12.prod.outlook.com (2603:10b6:a03:4d0::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.44; Wed, 24 Apr 2024 03:36:08 +0000 Received: from BL6PEPF0001AB78.namprd02.prod.outlook.com (2603:10b6:208:1a0:cafe::79) by MN2PR07CA0004.outlook.office365.com (2603:10b6:208:1a0::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7495.34 via Frontend Transport; Wed, 24 Apr 2024 03:36:08 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by BL6PEPF0001AB78.mail.protection.outlook.com (10.167.242.171) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7519.19 via Frontend Transport; Wed, 24 Apr 2024 03:36:08 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Tue, 23 Apr 2024 22:36:02 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Tue, 23 Apr 2024 20:35:47 -0700 Received: from henry-MS-7D54.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Tue, 23 Apr 2024 22:35:45 -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: cb35a9e6-01eb-11ef-909a-e314d9c70b13 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VKjPkG16JDzf28E8cqXwwG9S2AS1BHqoMnmCc5N+2h5q//y8QgPKPJfRhbbaSgg8Rcmh8O6Ks3PorLXhHOYk5e3a0HoXzsbjHgvvF4/JNfEyxz2FStCWjo9/twXuhb5uzNIBbevi7FTHq/1oA1TXVRPLB3jH0Oh57NaPxY78lsTLUY5/pLNt3amysvHsNaK8IipXu10cUumvw46rVB/FDr07w8TWvac010KBBWSBLg4MQ2DLxOqoymVoFj07OtDKIFK0uDxrkk9/UItq9gj6GYo0gvwi0IfbUKqqFQa1IWMIZubkuHiUn1KkrnH9BGxD+nrXADJnMnq+QsDGx7dxKw== 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=6RfZgheYZN0zbH6UoyVjyXZAc0SA9g0gkM7LgGJzRro=; b=TOJf1ZVmePm2dQqUewh1WtxQy5iMttMiDZjLME1dT/F93wFwj2aJE2Mc6iu/PQmUpfXaOfH0dMdO6mEq7RLxJ1I2nd7jQjjY37+f52+ZbPQe4qGFWoSFp/9TVZTKp9IMvJc1HkpEn1iv33QL0Frr4RSIb6nEhO7VfXnBRwGuwGA0TsnfTgd9UCPJKDPWrVRaYEsdDMPxwKNPV1ROjrnI07VLANXrSTZY6Y5Z8eJNd1WgnLsdtxlN0TK8gmhYAIV33EBo/M3FYlhWbFdpOrttPyh6fevOquYUUSYvoa91MRfH2Et54T7LQ1N1OHOVp6WSHGZon2WzXJbu+QnK/ERWmg== 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=6RfZgheYZN0zbH6UoyVjyXZAc0SA9g0gkM7LgGJzRro=; b=eOlaPU3LA3MDHeFN6N31GGmxaf5OeCIS5+fUz15LcznbWS+zLBk0c7dHZbm5TR2jG3SjXc49RehCa9tYOT2c0Z4u1rOoccRZ0VEPcH6L49UyhHZDZhBFOBEsg4VoY2CDnZA18csW+Inz+QJluJNYBVprvATll+0Jl0uMCeUm59Y= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C From: Henry Wang To: CC: Vikram Garhwal , Andrew Cooper , George Dunlap , "Jan Beulich" , Julien Grall , "Stefano Stabellini" , Henry Wang Subject: [PATCH 06/15] rangeset: Move struct range and struct rangeset to headerfile Date: Wed, 24 Apr 2024 11:34:40 +0800 Message-ID: <20240424033449.168398-7-xin.wang2@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240424033449.168398-1-xin.wang2@amd.com> References: <20240424033449.168398-1-xin.wang2@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB78:EE_|SJ2PR12MB8807:EE_ X-MS-Office365-Filtering-Correlation-Id: a87d3345-30c1-4fc3-be94-08dc640fadc3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TTenfAeORr62R9ETBpCqotM4RBldnGR5wgtZctDhmqyjE4GdEyWJmfZwSN0x4p4sGTGC0peXWBwvnsZpVhcBCovsdl47RxBvp9wcJ6uLhOm81fTG9OWpWdWW7EcQQNUtbVgBZfnD6AyOUzSpQYIgdRLSP/m/+0dJ2O5/twuvaVFA7eyoSDGZrqJM/HvLwYvqzGUTT2c4EwDeAJvR28xZ7Z9kdmxV8MGaPI4fSkNkGVDS6Z3lmjV5+Oe52FIMsiEbQ5W3g4MRYRDe6tOeus72LX/8O4MUn9FQqYYPN3WGprpsHxEBr9O4PZdysiXLTBS1hPOxKKa9M+AlNv6D3yTlrwhgaIJJpHcfR8MGGuBuBKh9dhUiMBkAqZ3KTykGlBzYgW6GNlV9c5mHgcKLo/qUtZfDPWfnzWpzRU6ippP2ftGYx/N5lO0FtXDRLjwiJx9va/7irm0Jrf2Awqx07CWbMCbsnHwqHgDJISsDUP0+pzh+RRzv/NGQ7KJ+4OuxCD+vU0HLb4FHSGPozNrX5ObRD/cXxMLZpIIOKhulcH3Fc64QOBa1/ZkZA86bnI0ZmacEuGpTBTWTNS2CTkK7cHCgzzL4tQAfKYbS8pOR4MDqOrVV04Vwun7vzfvRRZnA9Tp9TeaxL5zS6C5ubQvSLYO1bvN4DVzycjFhYB/gQtkZAxLtF3L+ihx8IJBAV/MyIoUxWHx/5WoYnodit0k4bj/nlVwlVmrl9mhz6LwJOAe6rpcp+kgJBNgdzaxJB0Pwm59RGnVo/PA8bNfcGvZaSONSPKhPBRq6zIV3q95coQaa8u8DC5sER9zmH4eKzHBY4zC/dwpTEBFd2Q8fJ8mgoXEPjsGjeL6dVUwQCkY/EjU1JMYpR//eg2Spn5sqvmfR45qyDLDfHNQqWhCKejz1wTigWXDxIo1a6swHfLFRw/yAzXQx+YbkcyHpM9kwv3RJ/7rRSVvzoSonhNqoG9y1R9UopaxltjldqjFqombBBvMO0ao29wMFCE1BPzSAN1RhA3WJs1GkskHvvlDDkkxNw0zko+Eamei5WgjXsfabALMRxJW1L15qL39189HHucHuvXyME5NaXtBVdGX75JfCY5Gd1g/a3YNinQriw5P3VgwY+0OjoUHdNClUyXk6Dpyf2im365JeQStU04geXQMA+CRb5qL0ALq0vHPJalJEuyMC1WUWk2ng8kcglfYtOMOFeIn5JWEI+720iECUHxxHCW3gAgT6nqWl5SrNKNSnnF5C3gKXSvp5yq1tjLKg/CiqwizctQgy/kz/D3XzCQUWG9J713ShQ2q66sNBEZoHj2FyfKmnH9D7duBORVA6300ZuavsbxbAp42fWnq8VudqK7ZONS+8de05MwJ8njMIC3AckRQyZOzFnWNrpAauwizaUffL X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(376005)(1800799015)(36860700004)(82310400014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2024 03:36:08.1872 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a87d3345-30c1-4fc3-be94-08dc640fadc3 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB78.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB8807 From: Vikram Garhwal Move struct range, rangeset and removed static from first_range and next_range(). IRQs and IOMEMs for nodes are stored as rangeset in the dynamic node addition part. While removing the nodes we need to access every IRQ and IOMEM ranges to unmap IRQ and IOMEM from the domain. Signed-off-by: Vikram Garhwal Signed-off-by: Henry Wang --- xen/common/rangeset.c | 31 ++----------------------------- xen/include/xen/rangeset.h | 32 +++++++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 30 deletions(-) diff --git a/xen/common/rangeset.c b/xen/common/rangeset.c index b75590f907..d3f4297e41 100644 --- a/xen/common/rangeset.c +++ b/xen/common/rangeset.c @@ -12,31 +12,6 @@ #include #include -/* An inclusive range [s,e] and pointer to next range in ascending order. */ -struct range { - struct list_head list; - unsigned long s, e; -}; - -struct rangeset { - /* Owning domain and threaded list of rangesets. */ - struct list_head rangeset_list; - struct domain *domain; - - /* Ordered list of ranges contained in this set, and protecting lock. */ - struct list_head range_list; - - /* Number of ranges that can be allocated */ - long nr_ranges; - rwlock_t lock; - - /* Pretty-printing name. */ - char name[32]; - - /* RANGESETF flags. */ - unsigned int flags; -}; - /***************************** * Private range functions hide the underlying linked-list implemnetation. */ @@ -57,8 +32,7 @@ static struct range *find_range( return x; } -/* Return the lowest range in the set r, or NULL if r is empty. */ -static struct range *first_range( +struct range *first_range( struct rangeset *r) { if ( list_empty(&r->range_list) ) @@ -66,8 +40,7 @@ static struct range *first_range( return list_entry(r->range_list.next, struct range, list); } -/* Return range following x in ascending order, or NULL if x is the highest. */ -static struct range *next_range( +struct range *next_range( struct rangeset *r, struct range *x) { if ( x->list.next == &r->range_list ) diff --git a/xen/include/xen/rangeset.h b/xen/include/xen/rangeset.h index 96c9180825..cd80fd9179 100644 --- a/xen/include/xen/rangeset.h +++ b/xen/include/xen/rangeset.h @@ -13,7 +13,37 @@ #include struct domain; -struct rangeset; + +struct rangeset { + /* Owning domain and threaded list of rangesets. */ + struct list_head rangeset_list; + struct domain *domain; + + /* Ordered list of ranges contained in this set, and protecting lock. */ + struct list_head range_list; + + /* Number of ranges that can be allocated */ + long nr_ranges; + rwlock_t lock; + + /* Pretty-printing name. */ + char name[32]; + + /* RANGESETF flags. */ + unsigned int flags; +}; + +/* An inclusive range [s,e] and pointer to next range in ascending order. */ +struct range { + struct list_head list; + unsigned long s, e; +}; + +/* Return the lowest range in the set r, or NULL if r is empty. */ +struct range *first_range(struct rangeset *r); + +/* Return range following x in ascending order, or NULL if x is the highest. */ +struct range *next_range(struct rangeset *r, struct range *x); /* * Initialise/destroy per-domain rangeset information. From patchwork Wed Apr 24 03:34:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Henry Wang X-Patchwork-Id: 13641151 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 69B57C4345F for ; Wed, 24 Apr 2024 03:44:06 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.711058.1110745 (Exim 4.92) (envelope-from ) id 1rzTY5-0001RL-Ao; Wed, 24 Apr 2024 03:43:57 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 711058.1110745; Wed, 24 Apr 2024 03:43:57 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rzTY5-0001RB-7i; Wed, 24 Apr 2024 03:43:57 +0000 Received: by outflank-mailman (input) for mailman id 711058; Wed, 24 Apr 2024 03:43:55 +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 1rzTQd-0002In-Kd for xen-devel@lists.xenproject.org; Wed, 24 Apr 2024 03:36:15 +0000 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on20600.outbound.protection.outlook.com [2a01:111:f403:2414::600]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id cc34aefa-01eb-11ef-b4bb-af5377834399; Wed, 24 Apr 2024 05:36:13 +0200 (CEST) Received: from MN2PR07CA0006.namprd07.prod.outlook.com (2603:10b6:208:1a0::16) by DS7PR12MB6357.namprd12.prod.outlook.com (2603:10b6:8:96::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.44; Wed, 24 Apr 2024 03:36:09 +0000 Received: from BL6PEPF0001AB78.namprd02.prod.outlook.com (2603:10b6:208:1a0:cafe::32) by MN2PR07CA0006.outlook.office365.com (2603:10b6:208:1a0::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7495.34 via Frontend Transport; Wed, 24 Apr 2024 03:36:09 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by BL6PEPF0001AB78.mail.protection.outlook.com (10.167.242.171) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7519.19 via Frontend Transport; Wed, 24 Apr 2024 03:36:09 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Tue, 23 Apr 2024 22:36:02 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Tue, 23 Apr 2024 20:35:50 -0700 Received: from henry-MS-7D54.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Tue, 23 Apr 2024 22:35: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: cc34aefa-01eb-11ef-b4bb-af5377834399 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MQ6JSNrzJpeerxjmsbGM+jY1aBs+y+YCk4oE7pRxuTHbAX3LTsdlx4v8TgkZP3SbeNRh2M8WG8aL827wzo2R2n5aFaIDD3c2UDB4B9ElW2EDJ89HAihAiRTHBKtpvcSYgBTNS2m68RGyqY8zBR3mRZ3goc+4UkEUg+/A/LtRvH3o9ix1ELlMZTNkSiDL4VEiOlO+6x1kgmdVwFjqLpoQ3LhiVAmZXOoqOPhw2PycSBgcNPlCFqRc2vZoAPUKd77wigfZ2uM9U2dM7NLsJv6SMgYWAqkSBH0a70uCqq/vLvPvFV8QVYaCIEGS59NwHOTPwLXgzEY2vFUi9DN2wVMyww== 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=DTkFoRXnpKJLc0+QsW9+qktSbxTVG+nGYUGcq/+U60w=; b=PJFYV6JxgxLJIcKT3wDdeshkOvzFUTSdtbWqmiBYNmvORLnI+8vKrVmWgUECoiYygBD3BDeKyGOrIDH5P5XK6Yg+uLVXzRl2ZaAQRMqCI6+ZzoQilILVfsUOoGKREpvYlUMJjWbqDLV1N4EwkZWQCbc3KyyroHE/XwTCk8U3b8zVDlq1OieDi4ekDxOV3VPLI/PVinRw7tf3Ch540rPyz6asBXDOviX75DCJWdgMScJkjqn7r1nuHv4NIAhLDcldfbHh6PqrG81U5e2cV8PquMdYd+Vs4s9G9h0MTXb5IkMlllq+Z1okRC2DwbGTRdHF62pqw5WXWfx7zpoANcYg/Q== 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=DTkFoRXnpKJLc0+QsW9+qktSbxTVG+nGYUGcq/+U60w=; b=mncG7NdhNOZyjEsA5n7OWngNYcGNWtJSNyv7YxuELcahr579douhrAxDB0aFvH5Z+sjeWacBiBAudd/nok8eyRkD6xdudlhS4gJNDYBiIw5ZhuTpYO+hZl4JPKbuJr+4rVfFljm//L5o5g75r65ctnoJFMaGcC7bxsRl3iLzvAw= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C From: Henry Wang To: CC: Vikram Garhwal , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , "Volodymyr Babchuk" , Andrew Cooper , George Dunlap , "Jan Beulich" , Vikram Garhwal , "Henry Wang" Subject: [PATCH 07/15] xen/overlay: Enable device tree overlay assignment to running domains Date: Wed, 24 Apr 2024 11:34:41 +0800 Message-ID: <20240424033449.168398-8-xin.wang2@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240424033449.168398-1-xin.wang2@amd.com> References: <20240424033449.168398-1-xin.wang2@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB78:EE_|DS7PR12MB6357:EE_ X-MS-Office365-Filtering-Correlation-Id: f4fcf970-eedd-4aa1-dfc8-08dc640fae65 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: K85sB8ClB6nQkWsQeYTh18OXfZkGhagob1W4qn1IX09NmR5trNEud9WRU2BaClrOIBwJqcIbdL7q+NYAdaI1Jf1vmdxludqH/fjiPEpkUXsu+24LwbvbMKtzCYoSbjAML/1B818XPwqd5dwj0fLUCzO3c3MUT7tX2ny4Gmb9toEEZDP6wrzFAjBICUI6V435+Yq0E8FkX7+q16io4OCkVjHN2Zs0vCz2t52X1fi4bCgST/u0YWeVAq7GIOzLV9IU9nLaVZqmcI0pXmJshqCh6NRrYu+H2IzJ/X3EEiJ3yWll4waYggJnmVQRvdZhOAVoTZjXO8+bsCUVTULVEIhbPWfNXXPhNx2szHCVbZo1Eg5b3p0MDbugWPx97FI+NqUqaGafOwOmSSOWqeR1ke6NatXBbXXTqg4ZzrAiBOixxaKI82W5ZVKis0zBIz6ojN/Cri6hhJG4sEpynTEKQlhp+eo4gB3Ukd1JrkfXU1domeQtIAweSWEMhvDQqMOZWphK3CVsG4+7Sni+1mtwH1qpXJG1rrIPITXS/EBOXbV32JO7jQTuilGiFOmQ7CgO/CK9PNeP1EJOK938gVSYu2jojkuncf9BjpUukviHP+kTvfZZRrar/N8v8BaJ6dgGI8T3cuWAlmkU+GCHthKd3x4GyX7Wpbbsc0JI47slwOWTMXV5L276y+UurbbLCRX4yVoRf18ScNmUvjPEgj9xm8YyEkUMs9inkK1p9AcFjRK/MzQqqwnHBL/7V29nsctj2lnLv04P3uyxgqMtVDJXegg0byvcmmXj3bQy/6QcQPzNy99AGams/HqHsYXXQx5CMW+0w9s0/qYaZmlLDLjcFI/wKG2twGLAhWe7wihEfsVlg7LS8Bn7ry159YEjvRO2EmiFhfQCvwTGRybSPuxkWbxHaeVPbXG8g6SnIJP+RW7iUYSeFeD+PAO/JUhYtpvoCTZzmc0rrMAgHe5HfmGeJCQ7nRue2ShP4XtlYq0gjeMx4Or5mNiXSFL7Wln3hzUaySV5c4RwAFvk1HT8KVSNXz8Uz903+e/VQsc6fbCXR9+PjrIPt6JuB7TyBV8DyrCwRI1UgKoP9xI14w6dHOpWda3wao7dD+wDwdJVLPiD9JN1mqcATUVXy9pmrwkjYLQ/Q5NcyLv7iFfrlvih85FEEay3qycQJID/h3Ev4mOQvVPR5aHDKNp52QBgUuBvlJuhrImJTRfci2j1SKCqeuurTqz2uW0GAq3JhZ/dwB0t2S/EZ9w83kRejUrKqsaGhRqK1jW5J7XkDjC+EL9wPJK8HbzXf+VIHm1r9ikk1TIkQ2zjvls2jXr3YlVo0Z05YVIt70S3gbpSap0VUHW/PEgD2qKo3VbfWRjbaoDpZkiz9rQaldw= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(1800799015)(376005)(36860700004)(82310400014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2024 03:36:09.2498 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f4fcf970-eedd-4aa1-dfc8-08dc640fae65 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB78.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6357 From: Vikram Garhwal Following changes are done to enable dtbo assignment to a running vm with given domain_id: 1. Support for irq map and unmap for running domain. We store the IRQ nums for each overlay and while removing those IRQ nums are removed. 2. Support iommu assign/reassign to running domains. 3. Added "map_nodes" options to support two modes: a. Add the nodes in Xen device tree and map the nodes to given VM b. Just add them in xen device tree without mapping. Change device.c: handle_device() function with input domain_mapping flag. Signed-off-by: Vikram Garhwal Signed-off-by: Michal Orzel Signed-off-by: Henry Wang --- xen/arch/arm/device.c | 8 +- xen/arch/arm/domain_build.c | 2 +- xen/arch/arm/include/asm/setup.h | 3 +- xen/common/dt-overlay.c | 218 ++++++++++++++++++++++++++----- xen/include/public/sysctl.h | 4 +- 5 files changed, 199 insertions(+), 36 deletions(-) diff --git a/xen/arch/arm/device.c b/xen/arch/arm/device.c index 3e02cff008..df5035f9a8 100644 --- a/xen/arch/arm/device.c +++ b/xen/arch/arm/device.c @@ -317,7 +317,8 @@ static int map_device_children(const struct dt_device_node *dev, * - Map the IRQs and iomem regions to DOM0 */ int handle_device(struct domain *d, struct dt_device_node *dev, p2m_type_t p2mt, - struct rangeset *iomem_ranges, struct rangeset *irq_ranges) + struct rangeset *iomem_ranges, struct rangeset *irq_ranges, + bool device_mapping) { unsigned int naddr; unsigned int i; @@ -334,9 +335,10 @@ int handle_device(struct domain *d, struct dt_device_node *dev, p2m_type_t p2mt, struct map_range_data mr_data = { .d = d, .p2mt = p2mt, - .skip_mapping = !own_device || + .skip_mapping = (!own_device || (is_pci_passthrough_enabled() && - (device_get_class(dev) == DEVICE_PCI_HOSTBRIDGE)), + (device_get_class(dev) == DEVICE_PCI_HOSTBRIDGE))) && + !device_mapping, .iomem_ranges = iomem_ranges, .irq_ranges = irq_ranges }; diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 54232ed4cb..a525aed175 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -1699,7 +1699,7 @@ static int __init handle_node(struct domain *d, struct kernel_info *kinfo, "WARNING: Path %s is reserved, skip the node as we may re-use the path.\n", path); - res = handle_device(d, node, p2mt, NULL, NULL); + res = handle_device(d, node, p2mt, NULL, NULL, false); if ( res) return res; diff --git a/xen/arch/arm/include/asm/setup.h b/xen/arch/arm/include/asm/setup.h index d15a88d2e0..d6d8c28d02 100644 --- a/xen/arch/arm/include/asm/setup.h +++ b/xen/arch/arm/include/asm/setup.h @@ -172,7 +172,8 @@ u32 device_tree_get_u32(const void *fdt, int node, const char *prop_name, u32 dflt); int handle_device(struct domain *d, struct dt_device_node *dev, p2m_type_t p2mt, - struct rangeset *iomem_ranges, struct rangeset *irq_ranges); + struct rangeset *iomem_ranges, struct rangeset *irq_ranges, + bool device_mapping); int map_device_irqs_to_domain(struct domain *d, struct dt_device_node *dev, bool need_mapping, struct rangeset *irq_ranges); diff --git a/xen/common/dt-overlay.c b/xen/common/dt-overlay.c index 39e4ba59dd..8840ea756b 100644 --- a/xen/common/dt-overlay.c +++ b/xen/common/dt-overlay.c @@ -356,24 +356,133 @@ static int overlay_get_nodes_info(const void *fdto, char **nodes_full_path) return 0; } +static int remove_all_irqs(struct rangeset *irq_ranges, + struct domain *d, bool domain_mapping) +{ + struct range *x; + int rc = 0; + + read_lock(&irq_ranges->lock); + + for ( x = first_range(irq_ranges); x != NULL; + x = next_range(irq_ranges, x) ) + { + /* + * Handle invalid use cases 1: + * Where user assigned the nodes to dom0 along with their irq + * mappings but now just wants to remove the nodes entry from Xen device + * device tree without unmapping the irq. + */ + if ( !domain_mapping && vgic_get_hw_irq_desc(d, NULL, x->s) ) + { + printk(XENLOG_ERR "Removing node from device tree without releasing it's IRQ/IOMMU is not allowed\n"); + rc = -EINVAL; + goto out; + } + + /* + * IRQ should always have access unless there are duplication of + * of irqs in device tree. There are few cases of xen device tree + * where there are duplicate interrupts for the same node. + */ + if (!irq_access_permitted(d, x->s)) + continue; + /* + * TODO: We don't handle shared IRQs for now. So, it is assumed that + * the IRQs was not shared with another domain. + */ + rc = irq_deny_access(d, x->s); + if ( rc ) + { + printk(XENLOG_ERR "unable to revoke access for irq %ld\n", x->s); + goto out; + } + + if ( domain_mapping ) + { + rc = release_guest_irq(d, x->s); + if ( rc ) + { + printk(XENLOG_ERR "unable to release irq %ld\n", x->s); + goto out; + } + } + } + +out: + read_unlock(&irq_ranges->lock); + return rc; +} + +static int remove_all_iomems(struct rangeset *iomem_ranges, + struct domain *d, + bool domain_mapping) +{ + struct range *x; + int rc = 0; + p2m_type_t t; + mfn_t mfn; + + read_lock(&iomem_ranges->lock); + + for ( x = first_range(iomem_ranges); x != NULL; + x = next_range(iomem_ranges, x) ) + { + mfn = p2m_lookup(d, _gfn(x->s), &t); + if ( mfn_x(mfn) == 0 || mfn_x(mfn) == ~0UL ) + { + rc = -EINVAL; + goto out; + } + + rc = iomem_deny_access(d, x->s, x->e); + if ( rc ) + { + printk(XENLOG_ERR "Unable to remove dom%d access to %#lx - %#lx\n", + d->domain_id, + x->s, x->e); + goto out; + } + + rc = unmap_mmio_regions(d, _gfn(x->s), x->e - x->s, + _mfn(x->s)); + if ( rc ) + goto out; + } + +out: + read_unlock(&iomem_ranges->lock); + return rc; +} + /* Check if node itself can be removed and remove node from IOMMU. */ -static int remove_node_resources(struct dt_device_node *device_node) +static int remove_node_resources(struct dt_device_node *device_node, + struct domain *d, bool domain_mapping) { int rc = 0; unsigned int len; domid_t domid; - domid = dt_device_used_by(device_node); + if ( !d ) + { + domid = dt_device_used_by(device_node); - dt_dprintk("Checking if node %s is used by any domain\n", - device_node->full_name); + /* + * We also check if device is assigned to DOMID_IO as when a domain + * is destroyed device is assigned to DOMID_IO or for the case when + * device was never mapped to a running domain. + */ + if ( domid != hardware_domain->domain_id && domid != DOMID_IO ) + { + printk(XENLOG_ERR "Device %s is being assigned to %u. Device is assigned to %d\n", + device_node->full_name, DOMID_IO, domid); + return -EINVAL; + } - /* Remove the node if only it's assigned to hardware domain or domain io. */ - if ( domid != hardware_domain->domain_id && domid != DOMID_IO ) - { - printk(XENLOG_ERR "Device %s is being used by domain %u. Removing nodes failed\n", - device_node->full_name, domid); - return -EINVAL; + /* + * Device is assigned to hardware domain. + */ + d = hardware_domain; } /* Check if iommu property exists. */ @@ -382,6 +491,16 @@ static int remove_node_resources(struct dt_device_node *device_node) if ( dt_device_is_protected(device_node) ) { write_lock(&dt_host_lock); + if ( domain_mapping && !list_empty(&device_node->domain_list) ) + { + rc = iommu_deassign_dt_device(d, device_node); + if ( rc < 0 ) + { + write_unlock(&dt_host_lock); + return rc; + } + } + rc = iommu_remove_dt_device(device_node); if ( rc < 0 ) { @@ -397,7 +516,8 @@ static int remove_node_resources(struct dt_device_node *device_node) /* Remove all descendants from IOMMU. */ static int -remove_descendant_nodes_resources(const struct dt_device_node *device_node) +remove_descendant_nodes_resources(const struct dt_device_node *device_node, + struct domain *d, bool domain_mapping) { int rc = 0; struct dt_device_node *child_node; @@ -407,12 +527,13 @@ remove_descendant_nodes_resources(const struct dt_device_node *device_node) { if ( child_node->child ) { - rc = remove_descendant_nodes_resources(child_node); + rc = remove_descendant_nodes_resources(child_node, d, + domain_mapping); if ( rc ) return rc; } - rc = remove_node_resources(child_node); + rc = remove_node_resources(child_node, d, domain_mapping); if ( rc ) return rc; } @@ -421,12 +542,13 @@ remove_descendant_nodes_resources(const struct dt_device_node *device_node) } /* Remove nodes from dt_host. */ -static int remove_nodes(const struct overlay_track *tracker) +static int remove_nodes(const struct overlay_track *tracker, + struct domain *d) { int rc = 0; struct dt_device_node *overlay_node; unsigned int j; - struct domain *d = hardware_domain; + bool domain_mapping = (d != NULL); for ( j = 0; j < tracker->num_nodes; j++ ) { @@ -434,11 +556,19 @@ static int remove_nodes(const struct overlay_track *tracker) if ( overlay_node == NULL ) return -EINVAL; - rc = remove_descendant_nodes_resources(overlay_node); + rc = remove_descendant_nodes_resources(overlay_node, d, domain_mapping); + if ( rc ) + return rc; + + rc = remove_node_resources(overlay_node, d, domain_mapping); + if ( rc ) + return rc; + + rc = remove_all_irqs(tracker->irq_ranges, d, domain_mapping); if ( rc ) return rc; - rc = remove_node_resources(overlay_node); + rc = remove_all_iomems(tracker->iomem_ranges, d, domain_mapping); if ( rc ) return rc; @@ -481,7 +611,8 @@ static int remove_nodes(const struct overlay_track *tracker) * while destroying the domain. */ static long handle_remove_overlay_nodes(const void *overlay_fdt, - uint32_t overlay_fdt_size) + uint32_t overlay_fdt_size, + struct domain *d) { int rc; struct overlay_track *entry, *temp, *track; @@ -520,7 +651,7 @@ static long handle_remove_overlay_nodes(const void *overlay_fdt, } - rc = remove_nodes(entry); + rc = remove_nodes(entry, d); if ( rc ) { printk(XENLOG_ERR "Removing node failed\n"); @@ -560,12 +691,21 @@ static void free_nodes_full_path(unsigned int num_nodes, char **nodes_full_path) xfree(nodes_full_path); } -static long add_nodes(struct overlay_track *tr, char **nodes_full_path) +static long add_nodes(struct overlay_track *tr, char **nodes_full_path, + struct domain *d) { int rc; unsigned int j; struct dt_device_node *overlay_node; + bool domain_mapping = (d != NULL); + + /* + * If domain is NULL, then we add the devices into hardware domain and skip + * IRQs/IOMMUs mapping. + */ + if ( d == NULL ) + d = hardware_domain; for ( j = 0; j < tr->num_nodes; j++ ) { @@ -609,8 +749,6 @@ static long add_nodes(struct overlay_track *tr, char **nodes_full_path) return rc; } - write_unlock(&dt_host_lock); - prev_node->allnext = next_node; overlay_node = dt_find_node_by_path(overlay_node->full_name); @@ -618,18 +756,23 @@ static long add_nodes(struct overlay_track *tr, char **nodes_full_path) { /* Sanity check. But code will never come here. */ ASSERT_UNREACHABLE(); + write_unlock(&dt_host_lock); return -EFAULT; } - rc = handle_device(hardware_domain, overlay_node, p2m_mmio_direct_c, + rc = handle_device(d, overlay_node, p2m_mmio_direct_c, tr->iomem_ranges, - tr->irq_ranges); + tr->irq_ranges, + domain_mapping); if ( rc ) { printk(XENLOG_ERR "Adding IRQ and IOMMU failed\n"); + write_unlock(&dt_host_lock); return rc; } + write_unlock(&dt_host_lock); + /* Keep overlay_node address in tracker. */ tr->nodes_address[j] = (unsigned long)overlay_node; } @@ -643,7 +786,8 @@ static long add_nodes(struct overlay_track *tr, char **nodes_full_path) * to hardware domain done by handle_node(). */ static long handle_add_overlay_nodes(void *overlay_fdt, - uint32_t overlay_fdt_size) + uint32_t overlay_fdt_size, + struct domain *d) { int rc; unsigned int j; @@ -788,7 +932,7 @@ static long handle_add_overlay_nodes(void *overlay_fdt, goto err; } - rc = add_nodes(tr, nodes_full_path); + rc = add_nodes(tr, nodes_full_path, d); if ( rc ) { printk(XENLOG_ERR "Adding nodes failed. Removing the partially added nodes.\n"); @@ -810,7 +954,7 @@ static long handle_add_overlay_nodes(void *overlay_fdt, */ remove_node: tr->num_nodes = j; - rc = remove_nodes(tr); + rc = remove_nodes(tr, d); if ( rc ) { @@ -855,6 +999,7 @@ long dt_overlay_sysctl(struct xen_sysctl_dt_overlay *op) { long ret; void *overlay_fdt; + struct domain *d = NULL; if ( op->overlay_op != XEN_SYSCTL_DT_OVERLAY_ADD && op->overlay_op != XEN_SYSCTL_DT_OVERLAY_REMOVE ) @@ -863,7 +1008,7 @@ long dt_overlay_sysctl(struct xen_sysctl_dt_overlay *op) if ( op->overlay_fdt_size == 0 || op->overlay_fdt_size > KB(500) ) return -EINVAL; - if ( op->pad[0] || op->pad[1] || op->pad[2] ) + if ( op->pad[0] || op->pad[1] ) return -EINVAL; overlay_fdt = xmalloc_bytes(op->overlay_fdt_size); @@ -880,13 +1025,26 @@ long dt_overlay_sysctl(struct xen_sysctl_dt_overlay *op) return -EFAULT; } + /* + * If domain_mapping == false, domain_id can be ignored as we don't need to + * map resource to any domain. + * + * If domain_mapping == true, domain_id, get the target domain for the + * mapping. + */ + if ( op->domain_mapping ) + d = rcu_lock_domain_by_id(op->domain_id); + if ( op->overlay_op == XEN_SYSCTL_DT_OVERLAY_REMOVE ) - ret = handle_remove_overlay_nodes(overlay_fdt, op->overlay_fdt_size); + ret = handle_remove_overlay_nodes(overlay_fdt, op->overlay_fdt_size, d); else - ret = handle_add_overlay_nodes(overlay_fdt, op->overlay_fdt_size); + ret = handle_add_overlay_nodes(overlay_fdt, op->overlay_fdt_size, d); xfree(overlay_fdt); + if ( op->domain_mapping ) + rcu_unlock_domain(d); + return ret; } diff --git a/xen/include/public/sysctl.h b/xen/include/public/sysctl.h index 9b19679cae..f5435f8890 100644 --- a/xen/include/public/sysctl.h +++ b/xen/include/public/sysctl.h @@ -1197,7 +1197,9 @@ struct xen_sysctl_dt_overlay { #define XEN_SYSCTL_DT_OVERLAY_ADD 1 #define XEN_SYSCTL_DT_OVERLAY_REMOVE 2 uint8_t overlay_op; /* IN: Add or remove. */ - uint8_t pad[3]; /* IN: Must be zero. */ + bool domain_mapping; /* IN: True of False. */ + uint8_t pad[2]; /* IN: Must be zero. */ + uint32_t domain_id; }; #endif From patchwork Wed Apr 24 03:34:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Henry Wang X-Patchwork-Id: 13641139 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 73DA5C4345F for ; Wed, 24 Apr 2024 03:36:15 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.711030.1110685 (Exim 4.92) (envelope-from ) id 1rzTQW-0005EI-Q8; Wed, 24 Apr 2024 03:36:08 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 711030.1110685; Wed, 24 Apr 2024 03:36:08 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rzTQW-0005E5-Me; Wed, 24 Apr 2024 03:36:08 +0000 Received: by outflank-mailman (input) for mailman id 711030; Wed, 24 Apr 2024 03:36:07 +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 1rzTQV-0003iy-JT for xen-devel@lists.xenproject.org; Wed, 24 Apr 2024 03:36:07 +0000 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on20600.outbound.protection.outlook.com [2a01:111:f403:2405::600]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id c891e3d1-01eb-11ef-909a-e314d9c70b13; Wed, 24 Apr 2024 05:36:06 +0200 (CEST) Received: from MN2PR07CA0017.namprd07.prod.outlook.com (2603:10b6:208:1a0::27) by PH8PR12MB7328.namprd12.prod.outlook.com (2603:10b6:510:214::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.45; Wed, 24 Apr 2024 03:36:03 +0000 Received: from BL6PEPF0001AB78.namprd02.prod.outlook.com (2603:10b6:208:1a0:cafe::53) by MN2PR07CA0017.outlook.office365.com (2603:10b6:208:1a0::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7495.34 via Frontend Transport; Wed, 24 Apr 2024 03:36:03 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by BL6PEPF0001AB78.mail.protection.outlook.com (10.167.242.171) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7519.19 via Frontend Transport; Wed, 24 Apr 2024 03:36:02 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Tue, 23 Apr 2024 22:36:02 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Tue, 23 Apr 2024 22:35:53 -0500 Received: from henry-MS-7D54.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Tue, 23 Apr 2024 22:35: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: c891e3d1-01eb-11ef-909a-e314d9c70b13 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=K5tL9Sxp/rggJ7CEyZxPZaL9JEYkIgKLt4n0T3mGFod7CMraQugk8RXIBtDPGZQVtbH80MO6P9p7WsjHDK4mhaY7T///UNLjX5kj0zRRoknTAtB+TuLD3V8oCg+xZo81Ao51XDzPu4JmSi2b3P4NT7abCjcRabgEWKYSS8C4H1sf/YaQYwkU4RV6fWkM7T7N46KrYGd5ccclfZQDYGotHIhEjNCHe9DNA3YfkpX/iA1ErYmeNHsAx/0dRE5Olmi4vWFykFB+FTbY4XkL+up6BeY0v9kHOWDhRBQXh+XwsGG/k3HxQOhvsfg5jtAFzuWU8q8IMxBAbMQsNwr72hR/iw== 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=vaZNaxhv7T814w8ZlBVgWmsi3wP0wrBR0DPOix+QGsc=; b=UGcpmUVDxUy//9VBsiq7i/BBFrobrxbpXjA19cRqSQwbt+hirO3oe90mN81R8hUc9TVjGZz6Dy77AOU5kzOIFB8SCsQ3OIMM6sBywXoduz52Dr3pKBRz+AbHUPFsakgoB7gXdDFiZK5hQ/yUPyAPPEaTCGBycqNMZzAmNCvMDOrnMHRLsnQN1FKnSpFchGCSHa24Lrj3DW6LPHOqvGHuU2GDrZLUK9XOhFcRi7sw611BM+orJZD0NH2cjB8sMMqBDApKIln4nbkCcpWqTJELLqhFtBvKGtJ7g7beLmLGlEd9x2UBXi6/6z+imZ3hSWL2cFgeDGy3pk9VhMEV2MaKdQ== 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=vaZNaxhv7T814w8ZlBVgWmsi3wP0wrBR0DPOix+QGsc=; b=mgTFLUZb+1Q9JYLf/7Op6LsIOlgaXtxja2iEsXJkNN3ylYTUtSpTeLldzOlhAqiXvWFFOaLHlupMNwZpvYDJs9xb8wS9oXCMYnyzgY5Me33u4wQCvCoJlIu0BsoUYT9jaIY83/UmtqtjGV+uGuyYqeocZiJFcSu0KQ6uKB0vUFs= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C From: Henry Wang To: CC: Vikram Garhwal , Anthony PERARD , Juergen Gross , "Stefano Stabellini" , Henry Wang Subject: [PATCH 08/15] tools: Add domain_id and expert mode for overlay operations Date: Wed, 24 Apr 2024 11:34:42 +0800 Message-ID: <20240424033449.168398-9-xin.wang2@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240424033449.168398-1-xin.wang2@amd.com> References: <20240424033449.168398-1-xin.wang2@amd.com> MIME-Version: 1.0 Received-SPF: None (SATLEXMB05.amd.com: xin.wang2@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB78:EE_|PH8PR12MB7328:EE_ X-MS-Office365-Filtering-Correlation-Id: 2d715a70-9c56-4aa0-7bdf-08dc640faa9b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TBRwepVruIHZhfMopOZ1AYNL0yToTQwhSEgMm/BofFL7JAoLdUtq8DDPkU/aG6YhtGbEkdlzYMu9vZrVKXetODPWrEyVRST4oxCODrscSbIQGH5ca+gfXgPEuGubEsPdiBAfkjM8r2XmVQ+LEN9W7C+NrvPSBpFcCGkxEb+cc7mkxeHMjbh5OMnUZrfr3Bb2Gsix9aTawVH0DaK9oXpP7gV/7FWNm8BTe0Oef7llJl448FGnw/WEHKEUOL5xLTY8cyOzBlLmiNOpJvlcdSsXQ+ido7FdkU5aTJ5u+RN8ZMa2Cdv9ihBr0zF331etgeYx7i4APA9KbqrrQ5d47kIeYfpFr3LrZuU5vJ9p4yCbp12f+zXBovMLa+AGPY1JdNUgWDsbAl3HpNG9zyeR2xERNqv6MRqh2c18gR9qLnivsZ4BFq4h9qbqnCBh7+qHQv0mAkaKYA/FMjXbGd2hc/31xuafC9VsB7sHgpzMSXVO8GOECvGn+KDzAkfrvkTanEW+gvidL7Gk2RiP7GIYU9Lcc3RACHe7VDO1IqOd5kKamqmalThMTmLhLjFgnNknZpUonc4zYPbv9Cgyb7v4BH1gj/r5zve7PmK4WeTdiRQg3sfF35mK6q5WA3WbV2DbTINDh6fdWO7pvNSkJ1ktk+q0dMOYZaHyMt4t5kFoXW2o0p4xCSjy/cnJCZ1zJLsvLNdM99bqeqrSRdX6ReHoW1jdwvgmpff9gk7XZC0SIBLCsrI3LUmr9a2tYmYR/BKz4orTCB+8YgkUr/zxCYgj1ZhWWjNKkZwmZZgsqPrn6ribTE90ux8SjS5o1P052bKkR1J2lc6/LkuYt9vfYZb7sSRfi0A34IWlZig6uM/LpzqSHPS4wgOeMOwZpPzO+ZFj66imv3eA+NAAMzIdU4/ohoO0FND7bGkUMSq5C4Fm6abRCUn7qHuIzDvp7zqVjkToU0Q8UY1b03hGkYiUqujXmj5VPCZjRxZQKqfZDM8Mn6BS/7Idn7X6ve1Byezr9KKOX+qJfzcBE9+79TD+yMqses3R/p7lB1b1vqbnUEroH/8Hv8ZESYtFeq9Z5BEiAzkr6+ebzYFnUqgTz6SZioygSKNbrsavHnopfwR09IcguRTX7t9tptbvJU8IwXTRopTydA+RjN2s3jVqJEFpYc7o8/9AbHpVdWfITbF7y8MrGRRupvlb/mBYXtbiq3p914W4kcVtp8of0PD9vTyDlDB+SZR0y2q3IdHqwFAVo1IftzotukENNjvGFeALZcOkIdTPq3PVK5VsG5Z0RQTHIMQbEkPNqH1VjftpK0YvRJYR2KWieh+6F0T8qgItwqbkTNmPpuykY5sTJTqw19Nb8Xiz7dY+s1YQlrpvipmevD54KoUirtqCftkWglk1/wGiZhUBtsZl X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(1800799015)(376005)(82310400014)(36860700004);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2024 03:36:02.8902 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2d715a70-9c56-4aa0-7bdf-08dc640faa9b X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB78.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB7328 From: Vikram Garhwal Add domain_id and expert mode for overlay assignment. This enables dynamic programming of nodes during runtime. Take the opportunity to fix the name mismatch in the xl command, the command name should be "dt-overlay" instead of "dt_overlay". Signed-off-by: Vikram Garhwal Signed-off-by: Stefano Stabellini Signed-off-by: Henry Wang --- tools/include/libxl.h | 8 +++++-- tools/include/xenctrl.h | 5 +++-- tools/libs/ctrl/xc_dt_overlay.c | 7 ++++-- tools/libs/light/libxl_dt_overlay.c | 17 +++++++++++---- tools/xl/xl_vmcontrol.c | 34 ++++++++++++++++++++++++++--- 5 files changed, 58 insertions(+), 13 deletions(-) diff --git a/tools/include/libxl.h b/tools/include/libxl.h index 62cb07dea6..59a3e1b37c 100644 --- a/tools/include/libxl.h +++ b/tools/include/libxl.h @@ -2549,8 +2549,12 @@ 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__) -int libxl_dt_overlay(libxl_ctx *ctx, void *overlay, - uint32_t overlay_size, uint8_t overlay_op); +#define LIBXL_DT_OVERLAY_ADD 1 +#define LIBXL_DT_OVERLAY_REMOVE 2 + +int libxl_dt_overlay(libxl_ctx *ctx, uint32_t domain_id, void *overlay, + uint32_t overlay_size, uint8_t overlay_op, bool auto_mode, + bool domain_mapping); #endif /* diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h index 2ef8b4e054..3861d0a23f 100644 --- a/tools/include/xenctrl.h +++ b/tools/include/xenctrl.h @@ -2654,8 +2654,9 @@ int xc_domain_cacheflush(xc_interface *xch, uint32_t domid, xen_pfn_t start_pfn, xen_pfn_t nr_pfns); #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(xc_interface *xch, uint32_t domain_id, void *overlay_fdt, + uint32_t overlay_fdt_size, uint8_t overlay_op, + bool domain_mapping); #endif /* Compat shims */ diff --git a/tools/libs/ctrl/xc_dt_overlay.c b/tools/libs/ctrl/xc_dt_overlay.c index c2224c4d15..a1dc549915 100644 --- a/tools/libs/ctrl/xc_dt_overlay.c +++ b/tools/libs/ctrl/xc_dt_overlay.c @@ -20,15 +20,18 @@ #include "xc_private.h" -int xc_dt_overlay(xc_interface *xch, void *overlay_fdt, - uint32_t overlay_fdt_size, uint8_t overlay_op) +int xc_dt_overlay(xc_interface *xch, uint32_t domid, void *overlay_fdt, + uint32_t overlay_fdt_size, uint8_t overlay_op, + bool domain_mapping) { int err; struct xen_sysctl sysctl = { .cmd = XEN_SYSCTL_dt_overlay, .u.dt_overlay = { + .domain_id = domid, .overlay_op = overlay_op, .overlay_fdt_size = overlay_fdt_size, + .domain_mapping = domain_mapping, } }; diff --git a/tools/libs/light/libxl_dt_overlay.c b/tools/libs/light/libxl_dt_overlay.c index a6c709a6dc..cdb62b28cf 100644 --- a/tools/libs/light/libxl_dt_overlay.c +++ b/tools/libs/light/libxl_dt_overlay.c @@ -41,8 +41,9 @@ static int check_overlay_fdt(libxl__gc *gc, void *fdt, size_t size) return 0; } -int libxl_dt_overlay(libxl_ctx *ctx, void *overlay_dt, uint32_t overlay_dt_size, - uint8_t overlay_op) +int libxl_dt_overlay(libxl_ctx *ctx, uint32_t domid, void *overlay_dt, + uint32_t overlay_dt_size, uint8_t overlay_op, + bool auto_mode, bool domain_mapping) { int rc; int r; @@ -57,10 +58,18 @@ int libxl_dt_overlay(libxl_ctx *ctx, void *overlay_dt, uint32_t overlay_dt_size, rc = 0; } - r = xc_dt_overlay(ctx->xch, overlay_dt, overlay_dt_size, overlay_op); + /* Check if user entered a valid domain id. */ + rc = libxl_domain_info(CTX, NULL, domid); + if (rc == ERROR_DOMAIN_NOTFOUND) { + LOGD(ERROR, domid, "Non-existant domain."); + return ERROR_FAIL; + } + + r = xc_dt_overlay(ctx->xch, domid, overlay_dt, overlay_dt_size, overlay_op, + domain_mapping); if (r) { - LOG(ERROR, "%s: Adding/Removing overlay dtb failed.", __func__); + LOG(ERROR, "domain%d: Adding/Removing overlay dtb failed.", domid); rc = ERROR_FAIL; } diff --git a/tools/xl/xl_vmcontrol.c b/tools/xl/xl_vmcontrol.c index 98f6bd2e76..9674383ec3 100644 --- a/tools/xl/xl_vmcontrol.c +++ b/tools/xl/xl_vmcontrol.c @@ -1270,21 +1270,48 @@ int main_dt_overlay(int argc, char **argv) { const char *overlay_ops = NULL; const char *overlay_config_file = NULL; + uint32_t domain_id = 0; void *overlay_dtb = NULL; int rc; + bool auto_mode = true; + bool domain_mapping = false; uint8_t op; int overlay_dtb_size = 0; const int overlay_add_op = 1; const int overlay_remove_op = 2; - if (argc < 2) { - help("dt_overlay"); + if (argc < 3) { + help("dt-overlay"); return EXIT_FAILURE; } + if (argc > 5) { + fprintf(stderr, "Too many arguments\n"); + return ERROR_FAIL; + } + overlay_ops = argv[1]; overlay_config_file = argv[2]; + if (!strcmp(argv[argc - 1], "-e")) + auto_mode = false; + + if (argc == 4 || !auto_mode) { + domain_id = find_domain(argv[argc-1]); + domain_mapping = true; + } + + if (argc == 5 || !auto_mode) { + domain_id = find_domain(argv[argc-2]); + domain_mapping = true; + } + + /* User didn't prove any overlay operation. */ + if (overlay_ops == NULL) { + fprintf(stderr, "No overlay operation mode provided\n"); + return ERROR_FAIL; + } + if (strcmp(overlay_ops, "add") == 0) op = overlay_add_op; else if (strcmp(overlay_ops, "remove") == 0) @@ -1309,7 +1336,8 @@ int main_dt_overlay(int argc, char **argv) return ERROR_FAIL; } - rc = libxl_dt_overlay(ctx, overlay_dtb, overlay_dtb_size, op); + rc = libxl_dt_overlay(ctx, domain_id, overlay_dtb, overlay_dtb_size, op, + auto_mode, domain_mapping); free(overlay_dtb); From patchwork Wed Apr 24 03:34:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Henry Wang X-Patchwork-Id: 13641140 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 31D76C04FFE for ; Wed, 24 Apr 2024 03:36:18 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.711031.1110695 (Exim 4.92) (envelope-from ) id 1rzTQY-0005We-5k; Wed, 24 Apr 2024 03:36:10 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 711031.1110695; Wed, 24 Apr 2024 03:36:10 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rzTQY-0005WS-2w; Wed, 24 Apr 2024 03:36:10 +0000 Received: by outflank-mailman (input) for mailman id 711031; Wed, 24 Apr 2024 03:36:09 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rzTQW-0002In-Tn for xen-devel@lists.xenproject.org; Wed, 24 Apr 2024 03:36:08 +0000 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on20601.outbound.protection.outlook.com [2a01:111:f403:2415::601]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id c872f204-01eb-11ef-b4bb-af5377834399; Wed, 24 Apr 2024 05:36:07 +0200 (CEST) Received: from MN2PR10CA0023.namprd10.prod.outlook.com (2603:10b6:208:120::36) by SJ0PR12MB6926.namprd12.prod.outlook.com (2603:10b6:a03:485::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.44; Wed, 24 Apr 2024 03:36:04 +0000 Received: from MN1PEPF0000ECD4.namprd02.prod.outlook.com (2603:10b6:208:120:cafe::c2) by MN2PR10CA0023.outlook.office365.com (2603:10b6:208:120::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7495.35 via Frontend Transport; Wed, 24 Apr 2024 03:36:03 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by MN1PEPF0000ECD4.mail.protection.outlook.com (10.167.242.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7519.19 via Frontend Transport; Wed, 24 Apr 2024 03:36:03 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Tue, 23 Apr 2024 22:36:02 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Tue, 23 Apr 2024 22:35:55 -0500 Received: from henry-MS-7D54.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Tue, 23 Apr 2024 22:35: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: c872f204-01eb-11ef-b4bb-af5377834399 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nh66hdh8V+MTG1oTqu1QsqHiowAaWj3wP8Dx9Dw18soF0k9bhVbMZbFiNil8E7DqFRpCqtjI2hJTTg+LFnBiqhtRDgQ/I9D7pvR8YcivsfBHizkYcfBBhx67zdQ0ayfRbS6EgoMOqZcAcF3losD2yqPRww4hmUOYxIbhZll1nlOwm00rEde0FEd5Q7kQvi1KH7wFrNwk78S35BEAJs+Dx9+1zHSBvF58MytFQM+tv4xucrHsthzaliHUAdYGAfEo8DQebVjBBxnpQQA2EwG9EzBXCti6ka75gqL6561gTIxM/q/6NF2KT7eBkFzSCeveIvR3JtWcVxdiCuOrxDf7nQ== 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=xhPYSAm6thH0Vdom9S+qaKObR5KAXalj4mONsm4a1iY=; b=Tx97yR0Nwaci2mQu7SHE4ZbiZ3Q2CCNz8VF1eSUZltBTIeqQf720JZuEHLRiQjVQYXUZE0l9bbkkUnzGjqrQIv8IWac7yd2ur2A2jDUMy7EUpK3ObDyO0DyXMUpdXjxc/edfn1HYlkcsvRtS3LTfQihe5wVAc9eLwgblsJo+yFyHFwKPcfGv8uKlEhwUzCFgSb//RsPCyCztMAx7rkGBsnh3k0q0LVeSQta/+qFzM9mc6spRspScLLV8VoxVYLY7IIykNHZ8qUXKCS+q8EESMUkeAtkdiZ/clNEdpp4Jk3SzYki7HwtdqML5qoMkCnhvH68ijyLzuiaSD7M0ry9/ng== 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=xhPYSAm6thH0Vdom9S+qaKObR5KAXalj4mONsm4a1iY=; b=JiXge333vWlS6NWGQC6pRjlZppIhuiR6f/SjIuknUm7kUB9MG8W0PpJsdY+kIRfQMHfxzAu55itqNRZ8dkdCot+JLSyWt6Ir5ACYMMwgzoEOSa1xBa0tzT0lzG2gfRtdcB8+YMuFV6djfUGGgDKnUtTB7jsBPB8aF+GoQ3fMHGo= 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: Henry Wang To: CC: Vikram Garhwal , Anthony PERARD , Juergen Gross , "Stefano Stabellini" , Henry Wang Subject: [PATCH 09/15] tools/libs/light: Modify dtbo to domU linux dtbo format Date: Wed, 24 Apr 2024 11:34:43 +0800 Message-ID: <20240424033449.168398-10-xin.wang2@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240424033449.168398-1-xin.wang2@amd.com> References: <20240424033449.168398-1-xin.wang2@amd.com> MIME-Version: 1.0 Received-SPF: None (SATLEXMB05.amd.com: xin.wang2@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000ECD4:EE_|SJ0PR12MB6926:EE_ X-MS-Office365-Filtering-Correlation-Id: 28364718-01ee-4f1e-42f2-08dc640fab39 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: J7IsustZMSCek2kjzRpaPM5uJuakFp5k2JeJfuBN51ZXIqwNZjyKA0q2CEVO+Lg+n+yCTIM9DAZ86HAg6068z4NDI/dVr2ImL3sTJ3dCnf/++J5fQQAX50atO3CKyaEr9shmW8fH8pY6hl9svpVgQxDPnIRWBe1TA9LvjcPxa94KE36TwWMiPsDvJ8tqpKBtpwWmpqyQKWLzKKQz03W4UZsNlIEFZs5w+FRsvhFyca4EW9kLz3rXvUOAlVTm7KIm8QUXGJojjRfM0Pr8fbtLKC/se0CVyd92d2Lk91j39WJBB18/U5E58jfrxCYxzL6q6bFHP3Yt3t2A7R5RuyD0NFrF/7AK77TcKufKMa6Ai2rp6yi7QorUu0K5+TZYIC0TViC4/QNTFgnUhmIAILB6NVABdldDvytwTLnPLFSt7JNswii15tqUDIQ79vXLuFIlSP40tjxmFktKclrFcjIHY+MghD8horxwkkbvNVMlQK09LEQ06wLdEYcB0U0POi63nHqRS/4hFJ7HmMsySCKOqNMxJRUlEoQZnaLEiIpmJy+OXZNdNA269UxiPzf21RqQ1zPjeu44AIpBZBy5F4neA3zyBRnNqqbER4SQK4csinmbPhOluOWQBmucIN7AzLcnEIeHLpULv23HcZKPwNkEg6PDlDWdJg6ShdZn/MbqJoa9CxX9ua/6LMHz0EqlQSjjd4Dhg3ColUvjvu8K5k0VXAd39zLHNjdTHtHwh4WruzFBpQThkfu3oMc5u02K+/I9H2EyO9dqnlTc6kTUakvMXByRCZfwoGoSAq7ssxnzlgUCiIh0hZzIyfXK5QpdfkvUmYYkSHr58br7/lyfFGcNuxf1ognT2QRZxkq69xWzgdTBm3AceczW7NdSD/PAX7JIWXrcZNeUC9qiU9GqoY5EWHWxu1/zhxfDLoUUow7rd2kyHM6bF8nPzgD0bx3mMXhaAmyFtp2HCg8LjH3KUnJzBLqLd2dc2rNlYT1LCsXDrCysMm62smcwmhyEPGkWUxUfUOA2lTMcMYClk7v2x4Wjc0VB4YUC/zlTD1KtMWwiceBUWxdUSRzan9X0F2/zKOkYbDKg7c4mJw1qewk89PeZN8fE41uad2Eoi+kLWqgcb8RMy/mosGzsh20QjA/tlC9WuMxLu1HgANjFi67tntUF/ZkphmvEdtAc4Cyk3lct3kPJ8ooPUlcRB2z2SjiZPFp77J42PxLh7cKHl7ZnDRm48+MeqnmhE6+lePHFn7tYWhnHrxxO9nmuze3IcV1SnSQV7WL0ZyeZK/dJt+a9KI1zoQ/whS9uxI0CWV1sfqvg3XOzuW7p1qd8ymnEByuHcZctdTZor7je6d47CLf4j9kMVplzMrzQaGghFJzUIHEkb1ASl2D1k0u4ECWZY371Mc6t 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)(82310400014)(1800799015)(36860700004);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2024 03:36:03.4867 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 28364718-01ee-4f1e-42f2-08dc640fab39 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: MN1PEPF0000ECD4.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB6926 From: Vikram Garhwal Add support for modifying dtbo to make it suitable for DomU Linux. This is done for '-e expert' mode. Signed-off-by: Vikram Garhwal Signed-off-by: Stefano Stabellini Signed-off-by: Henry Wang --- tools/libs/light/libxl_dt_overlay.c | 73 +++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/tools/libs/light/libxl_dt_overlay.c b/tools/libs/light/libxl_dt_overlay.c index cdb62b28cf..eaf11a0f9c 100644 --- a/tools/libs/light/libxl_dt_overlay.c +++ b/tools/libs/light/libxl_dt_overlay.c @@ -17,6 +17,7 @@ #include "libxl_internal.h" #include #include +#include static int check_overlay_fdt(libxl__gc *gc, void *fdt, size_t size) { @@ -41,6 +42,69 @@ static int check_overlay_fdt(libxl__gc *gc, void *fdt, size_t size) return 0; } +static int modify_overlay_for_domU(libxl__gc *gc, void *overlay_dt_domU, + size_t size) +{ + int rc = 0; + int virtual_interrupt_parent = GUEST_PHANDLE_GIC; + const struct fdt_property *fdt_prop_node = NULL; + int overlay; + int prop_len = 0; + int subnode = 0; + int fragment; + const char *prop_name; + const char *target_path = "/"; + + fdt_for_each_subnode(fragment, overlay_dt_domU, 0) { + prop_name = fdt_getprop(overlay_dt_domU, fragment, "target-path", + &prop_len); + if (prop_name == NULL) { + LOG(ERROR, "target-path property not found\n"); + rc = ERROR_FAIL; + goto err; + } + + /* Change target path for domU dtb. */ + rc = fdt_setprop_string(overlay_dt_domU, fragment, "target-path", + target_path); + if (rc) { + LOG(ERROR, "Setting interrupt parent property failed for %s\n", + prop_name); + goto err; + } + + overlay = fdt_subnode_offset(overlay_dt_domU, fragment, "__overlay__"); + + fdt_for_each_subnode(subnode, overlay_dt_domU, overlay) + { + const char *node_name = fdt_get_name(overlay_dt_domU, subnode, + NULL); + + fdt_prop_node = fdt_getprop(overlay_dt_domU, subnode, + "interrupt-parent", &prop_len); + if (fdt_prop_node == NULL) { + LOG(DETAIL, "%s property not found for %s. Skip to next node\n", + "interrupt-parent", node_name); + continue; + } + + rc = fdt_setprop_inplace_u32(overlay_dt_domU, subnode, + "interrupt-parent", + virtual_interrupt_parent); + if (rc) { + LOG(ERROR, "Setting interrupt parent property failed for %s\n", + "interrupt-parent"); + goto err; + } + } + } + +return 0; + +err: + return rc; +} + int libxl_dt_overlay(libxl_ctx *ctx, uint32_t domid, void *overlay_dt, uint32_t overlay_dt_size, uint8_t overlay_op, bool auto_mode, bool domain_mapping) @@ -73,6 +137,15 @@ int libxl_dt_overlay(libxl_ctx *ctx, uint32_t domid, void *overlay_dt, rc = ERROR_FAIL; } + /* + * auto_mode doesn't apply to dom0 as dom0 can get the physical + * description of the hardware. + */ + if (domid && auto_mode) { + if (overlay_op == LIBXL_DT_OVERLAY_ADD) + rc = modify_overlay_for_domU(gc, overlay_dt, overlay_dt_size); + } + out: GC_FREE; return rc; From patchwork Wed Apr 24 03:34:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Henry Wang X-Patchwork-Id: 13641142 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 9EC39C10F1A for ; Wed, 24 Apr 2024 03:36:25 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.711032.1110705 (Exim 4.92) (envelope-from ) id 1rzTQc-0005tR-Dm; Wed, 24 Apr 2024 03:36:14 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 711032.1110705; Wed, 24 Apr 2024 03:36:14 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rzTQc-0005tI-AI; Wed, 24 Apr 2024 03:36:14 +0000 Received: by outflank-mailman (input) for mailman id 711032; Wed, 24 Apr 2024 03:36:12 +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 1rzTQa-0002In-K5 for xen-devel@lists.xenproject.org; Wed, 24 Apr 2024 03:36:12 +0000 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on20600.outbound.protection.outlook.com [2a01:111:f403:2415::600]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id cb071d83-01eb-11ef-b4bb-af5377834399; Wed, 24 Apr 2024 05:36:10 +0200 (CEST) Received: from MN2PR12CA0008.namprd12.prod.outlook.com (2603:10b6:208:a8::21) by MN0PR12MB6054.namprd12.prod.outlook.com (2603:10b6:208:3ce::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.44; Wed, 24 Apr 2024 03:36:05 +0000 Received: from MN1PEPF0000ECD9.namprd02.prod.outlook.com (2603:10b6:208:a8:cafe::5a) by MN2PR12CA0008.outlook.office365.com (2603:10b6:208:a8::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7495.33 via Frontend Transport; Wed, 24 Apr 2024 03:36:05 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by MN1PEPF0000ECD9.mail.protection.outlook.com (10.167.242.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7519.19 via Frontend Transport; Wed, 24 Apr 2024 03:36:05 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) 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; Tue, 23 Apr 2024 22:36:04 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Tue, 23 Apr 2024 20:36:04 -0700 Received: from henry-MS-7D54.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Tue, 23 Apr 2024 22:36:02 -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: cb071d83-01eb-11ef-b4bb-af5377834399 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j8nhVp3kknyf4echTk6sdYRC0gg6JdtjV5ydZsD+Pop2qIUQeXpBUH2baBogEOBVA3Dfbl5leTceRmzP+7k0Cfng6vA7hRPJqSS+0JWzXlrWjGd6dHH9JaxXLfMqQINM3XwcA4JZ8BqYhonvDj1lFXqamG8I5jmQyvnh4iywSIhsG+L0m5VTcbiOEjWPfIffROvQfa7FRsTB2NYGWZqJEXWMJh8jxztGVRqzU26iDtCDskJN34gpUVLdaiPDtz0OMkq6vNrqQANa7U0qQj/Y1f21JmAUq55R5XwZcaoRZMcoGL0qgWbY1st3lsyayZUHyfIWOvynA/Y2twGK7lkEaw== 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=zlEz8Qbz/UMaWUU/jaiTmBDD/wiyD0++iaf2udSkHFg=; b=WOnZvSv3PaiiQpwUiupW94vZJKTvUqD/eDO5UjBddeWMCo/zv2x+ACpNqXg0+0qxP6Q4bWtlKeBzWqhORvfiY1D4q36CvqLQ9Q6OyVWkPHx9mXBeGsjVDJtQt7l+1ijAcUy8n5i3KUKn3FSuMTcNJ16qACctIpdARoHzCCFy+A2YbQbcDnNdJG381EkOdWUkQG/UPm37y4HG2qhfFqGdbzaba6aztn/dkf/y66b1yorn1Yp7PEAnDZKT5Sv/UQbNxLq1aAwtHwigRvG4w0kUKqTjtN1Dipn39wPLuA9A4qj7nMjiBpAtjru9kbTza/0uNPt+UeVIr2Gt5Glfp2ACog== 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=zlEz8Qbz/UMaWUU/jaiTmBDD/wiyD0++iaf2udSkHFg=; b=IbHyBjeH1aG91WhymMQQHPWlhiAzsbyNeAfoA94TaRzXFSdUnzErh8nw6hb29YzHivz7QdWw5jzSvpAzKwP4jcIBZW2V8FrNSAMvb17CDTbkNtjF83n6rh2bHupfOLCGWKIM/YWdIjWZOv8Me5RqIgN50o9d0B351Y/v/OTEedE= 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: Henry Wang To: CC: Vikram Garhwal , Anthony PERARD , Stewart Hildebrand , Stefano Stabellini , Henry Wang Subject: [PATCH 10/15] tools/xl: Share overlay with domU Date: Wed, 24 Apr 2024 11:34:44 +0800 Message-ID: <20240424033449.168398-11-xin.wang2@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240424033449.168398-1-xin.wang2@amd.com> References: <20240424033449.168398-1-xin.wang2@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000ECD9:EE_|MN0PR12MB6054:EE_ X-MS-Office365-Filtering-Correlation-Id: 651dd3f1-484e-409f-7b9d-08dc640fac09 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TGA3dNGoVRuoqr2bB74CDMTC3H/FjOKwXAdM0KjLpp3TYK2bBucumLoW4/rfcoAQkIjx33fA540XV0REnp8zF3kyxHq8qU5doepJtONQM8KMy780enBwZt13Wi+iDpB7iim1m3Vky1IuLbnewzWzP4bwcTlPM3bE6ortjH2ddoRXPu3WUIIthoKdo6GPFypcaYOkYLnOOcTX72V0CiSrE9u6v31U34W1clqSHOFpYd4RD7Xi899Td5TNKNra0nGgblbr1S7ymY4gzuar+zaFtgZuxOGKU3UVompkOObADegcq+yAA8G1mWwr9lvZAIt9hHpBuXT5VfwInpG5TnllEhGIG9E0fG29QQdPi8LdazdGLP7s5ONnqJqm81c3fTAWVQhc8mbNAjXfU9ML7WMSaPn8YUawihltw3DaUayPEpoFaCgMYvMA26aOl0I+Sd8Ha/8APUc+ZqK8JdWknFCj6uvraAXow0gMbS2nyHbVEAKQOvk2lY7HDJHZUj15GJjCPpZow7U7uLLMV/vkzrGPs9JuW9ADflx4iJ3+yR95+5JOUbs52nORPIq0fwvrXoJbNLJ1r64EVN5IoM+MU6hL+14aVP7aLSYCjvjFKGBblkS2X4SOjcPV4bZstzlDuF+iRjV154AucXTgoyheeXHMroTFMmFLztUAeAZWtV8yQAuHq5uemL0ZJHIlXMlNvq+xmnBmpJUzO9XU1skv4Cg7rofTjssxy78eowUmMkCHqBhg+5syrutgGtG3IJShiMnzgyszgp4kmWXme9EU/Q2dNxwVeTB3gbGGnsd9ndhO8FO2vwf2NVM37uxnwCSgSuFkGZ87RybHUjFXjuqqc963H7gob6lRYmdpxKRAC5akcYwkAV3li1FbpsZs8Bw9OyfQNft1jx+o/FTEdAXNpVnLcoRoWrPw0OT8caPVtLu6m7rbgLXkJU3tWSGRKSQECoHLQjA7t+wHtzTxfga7yq9qbaAugbvaCR49XQWzgmuMPJ+ktpy5DEls3x6dJyh9y4xbCFnJr5XDHobweE6DL51yM0mABjpblshQ/q/CRP31DOlEo49kvv6rSsgWpqsdWZjhPS4Yv+9Ux0GXc2uUUQ4/uHWtFb0BdoP2Ikpnqa3SlHI158X3BRrJx7200IaNY9P5b5CXhOvJj56BateJobmnKT+IxF6Nw5xVW5MRlr+RaO5ziz1monDlXM/rqWDu7Ixm1gwVsUjAhGEBd5Z7tKJ3eVZhFm6gGRkPV6c3YVT69oq7GLXJ5RTLCm0KKDsBhwpIFMlz12KHHbgsIAKBhNQu+F5+Yacw0jYKxnQ4yp0tNjMkVAcS6s8+rge63mYFN+iSUcsfKLwTFSLQgZB5I1uptKMzIc5aXC8/IcGbDYl3wZdrCGFCqWQTio7vb5qOoQ+T 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)(82310400014)(36860700004)(1800799015)(376005);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2024 03:36:05.2888 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 651dd3f1-484e-409f-7b9d-08dc640fac09 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: MN1PEPF0000ECD9.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB6054 From: Vikram Garhwal Add domid to enable assigning the node to a running VMs. Add expert mode option to share the overlay dtbo with domU. In this mode dom0 communicates with domid domain to share the overlay dtbo. This is done via xenstore. Signed-off-by: Vikram Garhwal Signed-off-by: Stewart Hildebrand Signed-off-by: Stefano Stabellini Signed-off-by: Henry Wang --- tools/xl/Makefile | 2 +- tools/xl/xl_cmdtable.c | 2 +- tools/xl/xl_vmcontrol.c | 343 +++++++++++++++++++++++++++++++++++++++- 3 files changed, 342 insertions(+), 5 deletions(-) diff --git a/tools/xl/Makefile b/tools/xl/Makefile index d742e96a5b..122dfb9346 100644 --- a/tools/xl/Makefile +++ b/tools/xl/Makefile @@ -32,7 +32,7 @@ $(XL_OBJS): CFLAGS += -include $(XEN_ROOT)/tools/config.h # libxl_json.h needs i all: xl xl: $(XL_OBJS) - $(CC) $(LDFLAGS) -o $@ $(XL_OBJS) $(LDLIBS_libxenutil) $(LDLIBS_libxenlight) $(LDLIBS_libxentoollog) -lyajl $(APPEND_LDFLAGS) + $(CC) $(LDFLAGS) -o $@ $(XL_OBJS) $(LDLIBS_libxenutil) $(LDLIBS_libxenlight) $(LDLIBS_libxentoollog) $(LDLIBS_libxenstore) $(LDLIBS_libxengnttab) -lyajl $(APPEND_LDFLAGS) .PHONY: install install: all diff --git a/tools/xl/xl_cmdtable.c b/tools/xl/xl_cmdtable.c index 62bdb2aeaa..2531e8517b 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> domain_id -e[expert_mode]", "-h print this help\n" }, #endif diff --git a/tools/xl/xl_vmcontrol.c b/tools/xl/xl_vmcontrol.c index 9674383ec3..2bf76dd389 100644 --- a/tools/xl/xl_vmcontrol.c +++ b/tools/xl/xl_vmcontrol.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -29,6 +30,8 @@ #include "xl.h" #include "xl_utils.h" #include "xl_parse.h" +#include +#include static int fd_lock = -1; @@ -1266,6 +1269,335 @@ int main_create(int argc, char **argv) } #ifdef LIBXL_HAVE_DT_OVERLAY +static int copy_overlay_to_domU(uint32_t domain_id, void *overlay_dt_domU, + uint32_t overlay_dt_size, uint32_t *grant_ref, + uint32_t num_pages) +{ + void *buffer = NULL; + xengnttab_handle *gnttab = xengnttab_open(NULL, 0); + + if (!gnttab) { + fprintf(stderr,"opening gnttab failed for domain %d\n", domain_id); + return -1; + } + + buffer = xengnttab_map_domain_grant_refs(gnttab, num_pages, domain_id, + grant_ref, PROT_READ|PROT_WRITE); + + if (buffer == NULL) { + fprintf(stderr, "Getting the buffer failed for grant_refs\n"); + + return -1; + } + + /* buffer is contiguous allocated. */ + memcpy(buffer, overlay_dt_domU, overlay_dt_size); + + xengnttab_unmap(gnttab, buffer, num_pages); + + return 0; +} + +static bool wait_for_status(struct xs_handle *xs, int fd, char *status_path, + const char *status) +{ + unsigned int num_strings; + char *buf = NULL; + char **vec = NULL; + bool ret = false; + unsigned int len; + int rc = 0; + fd_set set; + + while (1) + { + FD_ZERO(&set); + FD_SET(fd, &set); + + rc = select(fd + 1, &set, NULL, NULL, NULL); + /* Poll for data: Blocking. */ + if (rc <= 0) + break; + + if (FD_ISSET(fd, &set)) { + /* + * num_strings will be set to the number of elements in vec + * (2 - the watched path and the overlay_watch) + */ + vec = xs_read_watch(xs, &num_strings); + if (!vec) { + break; + } + + /* do a read. */ + buf = xs_read(xs, XBT_NULL, status_path, &len); + if (buf) { + if (!strcmp(buf, status)) { + ret = true; + break; + } + } + } + } + + free(vec); + free(buf); + + return ret; +} + +static bool write_overlay_size(struct xs_handle *xs, uint32_t overlay_size, + char *path) +{ + xs_transaction_t xs_trans = XBT_NULL; + char buf[128]; + char ref[16]; + +retry_transaction: + xs_trans = xs_transaction_start(xs); + if (!xs_trans) + return false; + + snprintf(ref, sizeof(ref), "%u", overlay_size); + snprintf(buf, sizeof(buf), "%s/overlay-size", path); + + if (!xs_write(xs, xs_trans, buf, ref, strlen(ref))) + return false; + + if (!xs_transaction_end(xs, xs_trans, 0)) { + if (errno == EAGAIN) + goto retry_transaction; + else + return false; + } + + return true; +} + +static bool write_status(struct xs_handle *xs, char *status, char *status_path) +{ + xs_transaction_t xs_trans = XBT_NULL; + +retry_transaction: + xs_trans = xs_transaction_start(xs); + if (!xs_trans) + return false; + + if (!xs_write(xs, xs_trans, status_path, status, strlen(status))) + return false; + + if (!xs_transaction_end(xs, xs_trans, 0)) { + if (errno == EAGAIN) + goto retry_transaction; + else + return false; + } + + return true; +} + +static uint32_t *get_page_ref(struct xs_handle *xs, const char *xs_path, + uint32_t num_pages) +{ + char buf[128]; + uint32_t *ref = NULL; + char *data; + char temp[16] = { }; + unsigned int len; + int i = 0; + int j = 0; + int start_ind = 0; + + snprintf(buf, sizeof(buf), "%s/page-ref", xs_path); + + /* do a read. */ + data = xs_read(xs, XBT_NULL, buf, &len); + + if (data) { + /* Caller will free this. */ + ref = (uint32_t *)calloc(num_pages, sizeof(uint32_t)); + + for (i = 0; data[i] != '\0'; i++) { + if (data[i] == ',') { + /* Next page_ref data. */ + memset(temp, '\0', sizeof(temp)); + + /* Copy the data between previous ',' to current. */ + memcpy(temp, &data[start_ind], i - start_ind); + + /* Convert to int. */ + ref[j] = atoi(temp); + start_ind = i + 1; + j++; + } + + if (j == num_pages) + break; + } + } + + if (j != num_pages) { + fprintf(stderr, "Number of page_refs are not equal to num_pages\n"); + free(ref); + ref = NULL; + } + + free(data); + return ref; +} + +static uint32_t get_num_pages(struct xs_handle *xs, const char *xs_path) +{ + char buf[128]; + char *ref; + unsigned int len; + uint32_t num_pages = 0; + + snprintf(buf, sizeof(buf), "%s/num-pages", xs_path); + + /* do a read. */ + ref = xs_read(xs, XBT_NULL, buf, &len); + + if (ref) + num_pages = atoi(ref); + + free(ref); + + return num_pages; +} + +static int share_overlay_with_domu(void *overlay_dt_domU, int overlay_dt_size, + int domain_id) +{ + struct xs_handle *xs = NULL; + char *path = NULL; + char receiver_status_path[64] = { }; + char sender_status_path[64] = { }; + int fd = 0; + int err; + uint32_t num_pages= 1; + uint32_t *page_ref = NULL; + + /* XS_watch part. */ + /* Open a connection to the xenstore. */ + xs = xs_open(0); + if (xs == NULL) { + fprintf(stderr, "Deamon open for domain%d failed\n", domain_id); + err = ERROR_FAIL; + goto out; + } + + /* Get the local domain path */ + path = xs_get_domain_path(xs, domain_id); + if (path == NULL) { + fprintf(stderr, "Getting domain%d path failed\n", domain_id); + err = ERROR_FAIL; + goto out; + } + + /* Make space for our node on the path */ + path = realloc(path, strlen(path) + strlen("/data/overlay") + 1); + if (path == NULL) { + fprintf(stderr, "Path allocation failed\n"); + err = ERROR_NOMEM; + goto out; + } + + strcat(path, "/data/overlay"); + strcpy(receiver_status_path, path); + strcat(receiver_status_path, "/receiver-status"); + + /* + * Watch a node for changes (poll on fd to detect). + * When the node (or any child) changes, fd will become readable. + */ + err = xs_watch(xs, receiver_status_path, "overlay_watch"); + if (!err) { + fprintf(stderr, "Creating watch failed\n"); + err = ERROR_FAIL; + goto out; + } + + /* + * We are notified of read availability on the watch via the + * file descriptor. + */ + fd = xs_fileno(xs); + + /* Wait for "waiting" status from other domain. */ + if (!wait_for_status(xs, fd, receiver_status_path, "waiting")) { + err = ERROR_NOT_READY; + goto out; + } + + /* Share the dtb size with domain. */ + if (!write_overlay_size(xs, overlay_dt_size, path)) { + err = ERROR_FAIL; + fprintf(stderr,"Writing page ref failed\n"); + goto out; + } + + strcpy(sender_status_path, path); + strcat(sender_status_path, "/sender-status"); + + /* Write the status "ready". */ + if (!write_status(xs, "ready", sender_status_path)) { + err = ERROR_FAIL; + fprintf(stderr,"Writing status ready failed\n"); + goto out; + } + + /* Wait for "page_ref" status from other domain. */ + if (!wait_for_status(xs, fd, receiver_status_path, "page_ref")) { + err = ERROR_NOT_READY; + goto out; + } + + num_pages = get_num_pages(xs, path); + if (num_pages == 0) { + fprintf(stderr, "no pages allocated\n"); + err = ERROR_FAIL; + goto out; + } + + page_ref = get_page_ref(xs, path, num_pages); + if (page_ref == NULL) { + fprintf(stderr,"page ref is null.\n"); + err = ERROR_FAIL; + goto out; + } + + if (copy_overlay_to_domU(domain_id, overlay_dt_domU, overlay_dt_size, + page_ref, num_pages)) { + fprintf(stderr,"Copy overlay failed\n"); + err = ERROR_FAIL; + goto out; + } + + /* Write the status "done". */ + if (!write_status(xs, "done", sender_status_path)) { + fprintf(stderr,"Writing status DONE failed\n"); + err = ERROR_FAIL; + goto out; + } + +/* Cleanup */ +out: + if (xs) { + close(fd); + xs_unwatch(xs, path, "overlay_watch"); + xs_close(xs); + } + + if (path) + free(path); + + if (page_ref) + free(page_ref); + + return err; +} + int main_dt_overlay(int argc, char **argv) { const char *overlay_ops = NULL; @@ -1339,11 +1671,16 @@ int main_dt_overlay(int argc, char **argv) rc = libxl_dt_overlay(ctx, domain_id, overlay_dtb, overlay_dtb_size, op, auto_mode, domain_mapping); - free(overlay_dtb); - - if (rc) + if (rc) { + free(overlay_dtb); return EXIT_FAILURE; + } + + if (domain_id && auto_mode && (op == LIBXL_DT_OVERLAY_ADD)) + rc = share_overlay_with_domu(overlay_dtb, overlay_dtb_size, + domain_id); + free(overlay_dtb); return rc; } #endif From patchwork Wed Apr 24 03:34:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Henry Wang X-Patchwork-Id: 13641152 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 E32DBC04FFE for ; Wed, 24 Apr 2024 03:44:08 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.711059.1110755 (Exim 4.92) (envelope-from ) id 1rzTY8-0001r9-Ju; Wed, 24 Apr 2024 03:44:00 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 711059.1110755; Wed, 24 Apr 2024 03:44:00 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rzTY8-0001qw-GN; Wed, 24 Apr 2024 03:44:00 +0000 Received: by outflank-mailman (input) for mailman id 711059; Wed, 24 Apr 2024 03:43:59 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rzTQe-0003iy-1c for xen-devel@lists.xenproject.org; Wed, 24 Apr 2024 03:36:16 +0000 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on20601.outbound.protection.outlook.com [2a01:111:f403:2009::601]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id cce739cd-01eb-11ef-909a-e314d9c70b13; Wed, 24 Apr 2024 05:36:15 +0200 (CEST) Received: from MN2PR07CA0004.namprd07.prod.outlook.com (2603:10b6:208:1a0::14) by PH7PR12MB6492.namprd12.prod.outlook.com (2603:10b6:510:1f3::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.22; Wed, 24 Apr 2024 03:36:10 +0000 Received: from BL6PEPF0001AB78.namprd02.prod.outlook.com (2603:10b6:208:1a0:cafe::33) by MN2PR07CA0004.outlook.office365.com (2603:10b6:208:1a0::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7495.34 via Frontend Transport; Wed, 24 Apr 2024 03:36:09 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by BL6PEPF0001AB78.mail.protection.outlook.com (10.167.242.171) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7519.19 via Frontend Transport; Wed, 24 Apr 2024 03:36:09 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Tue, 23 Apr 2024 22:36:06 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Tue, 23 Apr 2024 20:36:06 -0700 Received: from henry-MS-7D54.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Tue, 23 Apr 2024 22:36:05 -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: cce739cd-01eb-11ef-909a-e314d9c70b13 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=m4Y8Do8PJ0gFHTwaKOnk631MUVzOH5f7+coDhnlY/oqNY0Ei/9dEVuyVi3unJ72yXGtB1cO/9VfbIOo1YP/EZAD99LN8VCZz9buxPtDCbjLM4QorILWbpTeb9uA8giZxf/PmgZL9n7vMLFGqFCuc2eNU8ApkKc79vgmtctoPMEyzNoDg1gVY5hyk065gI7AgeBPgW7v96llRQkK9aXnBJGi6SqxYheZZrzrqq1tX2kdnJQMB2Yu5wTrEn8hfOIKYtByHea96ifrpmSrf3rXHHsr4gJECLTPbSPOPdV7Zf/TimiwJZqmPnFxxAofXCllYdHdHY+/UDI5pC6cLJTbAiA== 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=fGHzXleFvzlwnXmUM43m2CIMguyeDmKkEqOTHA8C5K0=; b=Z8x+RI/6hyZDgv1zoU/Jkbcm+3BctGJNn5fsfbpfp0RAczxS6omKECunZR6jfvEXExFEdoYkDv/JV5Fb8zB+022yVvlK4KSWWVhagbAhjI4LbApIXVyE4zo+zuLpE9iwDkrs4+Qkxl5ACojFikbFeyyUI3tWH3Ed9oXdQ3M/Ip0exf5enLDpEACmlgfeHvh0E0CZZEmppVOi6knFyogGgpe+m8MNnyqIQ2qgcjnAxPZOwYaY5TEDWbiUyIeFIEy5H4mHltrbJN01P9o8ryZL9tm+3LwkozAY4K8hsjAiYJemYt46fMKMhQ6asvnqA9qyKVFchtv2/dJ24jR40zqIVA== 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=fGHzXleFvzlwnXmUM43m2CIMguyeDmKkEqOTHA8C5K0=; b=27/mfB22zp2YcUf41E90IeUhIAyNZ2Rap5RnuvZIdVyWA5OY+VCTtgBdA+oVvydZjwWXBp9MAmm11ChgD5wLtCOLzD1/XNhX03zGkpyyh6y2ZJRW2atn5gOn74X7HGfOGV1t87T4F2He8IqWScIGK5SqZ41gKf5ECOEyUACC4E8= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C From: Henry Wang To: CC: Vikram Garhwal , Anthony PERARD , Stefano Stabellini , Henry Wang Subject: [PATCH 11/15] tools/helpers: Add get_overlay Date: Wed, 24 Apr 2024 11:34:45 +0800 Message-ID: <20240424033449.168398-12-xin.wang2@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240424033449.168398-1-xin.wang2@amd.com> References: <20240424033449.168398-1-xin.wang2@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB78:EE_|PH7PR12MB6492:EE_ X-MS-Office365-Filtering-Correlation-Id: fbce0043-a436-4641-53cf-08dc640fae9a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|36860700004|376005|82310400014|1800799015; X-Microsoft-Antispam-Message-Info: W/h1q+75M1kl1T8hCqlGvm+4UyBWUPEj3XbKLJWRKrFVcBujWIAWwvAsi/xY0SeqQYDNNLLCMy406lk2QGhVRfPPe2LGm9teeE2hNaYoOnZlYA0lBcw7YfIL04BIO31VkIwGNttD23qvcmABd9IlrMzrMknGvQ+lLsel1744PnbRT7CVhmTE4exLbjHtXnmx/nl/jAmktl6k5qIvONL4R0PLp08cO+KsB++XYj2Ea7MeI7lyKKaHYpOUwYpUa+hitPATDsoHP44ipj3UxveOroFvtGOkOonvtuNJ/tN2gJi8xeT/AvEBc113Nuj5A8f1HXnL+uz4htJEU7uKuXbXV5AxOiDK4h/0rJ5yCJgOmLMNFXzWtkqDT9GM7XVoeIRfJTXdT99eJQnTog5dq15OGN92g5xd9z4qzvnZcsYk8+04bHMHmIlAZIqFHzRDNJSJ3mMwh4HHRxdwml28Y+vHunC7YW1M9gIoEXDcUaeYBLmQ7Syd6Jkjz+2+uOjQOYciLsG7YVdhB01tobbl6Xjxwee6TJVuaXeGtg6anH0d+GwTMK2uKkjyZfDfsy4+P1OQcDjAUupyJY6m+jyrdkt36Y0GJlw1UYaeuJZIcKcK3AstB4XebOBm8Tvgt1cdLdiUNRne9+loFzycDhtH6MzZXTG+JOVXXd+nlZv3aoXQt3bUVR6HXz5abUx4phirIaIHDklpEyIPqxw/IvMhNqxXfVBPy3cQ4QJKWW5onlbN0N+BNcDCDCkRMDViYtC5y1sTnoqrFIIS8l+EnG1oWRnVrPdNKgQGQ5ERSA/X4BenYWdlJ58yQNldAoe44xYp2gyDp7O0MYUgZPxZMF7W+oHmijF/mIEd2AyhV0BznPjZaYkcpHuxvB+NKc2YvDbZEe3O+oWxBFS/QNWswFD5x9wDfcxNalQ6JJaGUZpBLmleZgkHVMnNv7phM0xL+MThJLlaI25Kd3An77odv4eRh4uu3G1ITHXTG7KqFiLzq7MxZRPKL6P4UJ72S/VyZ5kGnDNH+DWpghTEhu1GdWgGIpj49Idu2EMU7HpU7u01ZD4Hhtzjnhb5ZvjvCB1+b85OWBEFipqHu4810mv1x72N/6C4oYGrDPqHAlvYaQFPvdu6CHW8pF5ExyUObTueSve+gliJ5XdDEMY6W4s4v8mWilqIuPkt2yowFCeo/6Dx5OaKzj4u7BrVG0a6jd62ZQG61yIueOiux7xesu/hoHQRnkBO1xgJOdZazKnTrUHEFg1ttwQObq0APEv8UBfsouzPaLAAtOxVaaNJY7uszZesQZWH8Zfn2iaaWx75ZxiuOAULABupNZWifq9nvFxgL0lvJoSw9YNJS64LazxW3T9fpZdjkbYtoTrBeWp3HTWlBpUIdPw= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(36860700004)(376005)(82310400014)(1800799015);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2024 03:36:09.5935 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fbce0043-a436-4641-53cf-08dc640fae9a X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB78.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6492 From: Vikram Garhwal This user level application copies the overlay dtbo shared by dom0 while doing overlay node assignment operation. It uses xenstore to communicate with dom0. More information on the protocol is writtien in docs/misc/overlay.txt file. Signed-off-by: Vikram Garhwal Signed-off-by: Stefano Stabellini Signed-off-by: Henry Wang --- tools/helpers/Makefile | 8 + tools/helpers/get_overlay.c | 393 ++++++++++++++++++++++++++++++++++++ 2 files changed, 401 insertions(+) create mode 100644 tools/helpers/get_overlay.c diff --git a/tools/helpers/Makefile b/tools/helpers/Makefile index 09590eb5b6..dfe17ef269 100644 --- a/tools/helpers/Makefile +++ b/tools/helpers/Makefile @@ -12,6 +12,7 @@ TARGETS += init-xenstore-domain endif ifeq ($(CONFIG_ARM),y) TARGETS += init-dom0less +TARGETS += get_overlay endif endif @@ -39,6 +40,9 @@ $(INIT_DOM0LESS_OBJS): CFLAGS += $(CFLAGS_libxenctrl) $(INIT_DOM0LESS_OBJS): CFLAGS += $(CFLAGS_libxenevtchn) init-dom0less: LDLIBS += $(call xenlibs-ldlibs,ctrl evtchn toollog store light guest foreignmemory) +SHARE_OVERLAY_OBJS = get_overlay.o +$(SHARE_OVERLAY_OBJS): CFLAGS += $(CFLAGS_libxengnttab) $(CFLAGS_libxenstore) $(CFLAGS_libxenctrl) + .PHONY: all all: $(TARGETS) @@ -51,6 +55,10 @@ init-xenstore-domain: $(INIT_XENSTORE_DOMAIN_OBJS) init-dom0less: $(INIT_DOM0LESS_OBJS) $(CC) $(LDFLAGS) -o $@ $(INIT_DOM0LESS_OBJS) $(LDLIBS) $(APPEND_LDFLAGS) +get_overlay: $(SHARE_OVERLAY_OBJS) + $(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenvchan) $(LDLIBS_libxenstore) $(LDLIBS_libxenctrl) $(LDLIBS_libxengnttab) $(APPEND_LDFLAGS) + + .PHONY: install install: all $(INSTALL_DIR) $(DESTDIR)$(LIBEXEC_BIN) diff --git a/tools/helpers/get_overlay.c b/tools/helpers/get_overlay.c new file mode 100644 index 0000000000..ca3007570e --- /dev/null +++ b/tools/helpers/get_overlay.c @@ -0,0 +1,393 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define PAGE_SIZE 4096 + +static int xs_create_overlay_node(int domain, const char *xs_base, + struct xs_handle *xs) +{ + int ret = -1; + struct xs_permissions perms[2]; + char buf[64]; + char ref[16]; + char *domid_str = NULL; + int overlay_size = 0; + + xs_transaction_t xs_trans = XBT_NULL; + + domid_str = xs_read(xs, XBT_NULL, "domid", NULL); + + if (!domid_str) + return ret; + + /* owner domain is us */ + perms[0].id = atoi(domid_str); + /* permissions for domains not listed = none. */ + perms[0].perms = XS_PERM_NONE; + /* other domains i.e. domain provided by user gets r/w permissions. */ + perms[1].id = domain; + perms[1].perms = XS_PERM_READ | XS_PERM_WRITE; + +retry_transaction: + + xs_trans = xs_transaction_start(xs); + if (!xs_trans) + goto fail_xs_transaction; + + /* Create overlay-size node. */ + snprintf(ref, sizeof(ref), "%d", overlay_size); + snprintf(buf, sizeof(buf), "%s/overlay-size", xs_base); + + if (!xs_write(xs, xs_trans, buf, ref, strlen(ref))) + goto fail_xs_transaction; + if (!xs_set_permissions(xs, xs_trans, buf, perms, 2)) + goto fail_xs_transaction; + + /* Create domU status node. */ + snprintf(ref, sizeof(ref), "%s", "waiting"); + snprintf(buf, sizeof(buf), "%s/receiver-status", xs_base); + + if (!xs_write(xs, xs_trans, buf, ref, strlen(ref))) + goto fail_xs_transaction; + if (!xs_set_permissions(xs, xs_trans, buf, perms, 2)) + goto fail_xs_transaction; + + /* Create dom0 status node. */ + snprintf(ref, sizeof(ref), "%s", "not_ready"); + snprintf(buf, sizeof(buf), "%s/sender-status", xs_base); + + if (!xs_write(xs, xs_trans, buf, ref, strlen(ref))) + goto fail_xs_transaction; + if (!xs_set_permissions(xs, xs_trans, buf, perms, 2)) + goto fail_xs_transaction; + + if (!xs_transaction_end(xs, xs_trans, 0)) { + if (errno == EAGAIN) + goto retry_transaction; + else + goto fail_xs_transaction; + } else + ret = 0; + +fail_xs_transaction: + free(domid_str); + + return ret; +} + +static int get_overlay_size(struct xs_handle *xs, int domain, + const char *xs_path) +{ + char buf[128]; + char *ref; + unsigned int len; + int dt_size = 0; + + snprintf(buf, sizeof(buf), "%s/overlay-size", xs_path); + + ref = xs_read(xs, XBT_NULL, buf, &len); + + if (!ref) + return dt_size; + + dt_size = atoi(ref); + + free(ref); + + return dt_size; +} + +static uint32_t get_num_pages(int dtbo_size) +{ + int num_pages = 1; + + while (dtbo_size > PAGE_SIZE) { + dtbo_size = dtbo_size - PAGE_SIZE; + num_pages++; + } + + return num_pages; +} + +static void *create_shared_buffer(int domain, uint32_t *refs, uint32_t pages, + xengntshr_handle *gntshr) +{ + return xengntshr_share_pages(gntshr, domain, pages, refs, 1); +} + +static bool wait_for_status(struct xs_handle *xs, int fd, char *status_path, + const char *status) +{ + unsigned int num_strings; + char *buf = NULL; + char **vec = NULL; + bool ret = false; + unsigned int len; + int rc = 0; + fd_set set; + + while (1) + { + FD_ZERO(&set); + FD_SET(fd, &set); + + rc = select(fd + 1, &set, NULL, NULL, NULL); + /* Poll for data: Blocking. */ + if (rc <= 0) + break; + + if (FD_ISSET(fd, &set)) { + /* + * num_strings will be set to the number of elements in vec + * (2 - the watched path and the overlay_watch) + */ + vec = xs_read_watch(xs, &num_strings); + if (!vec) { + break; + } + + /* do a read. */ + buf = xs_read(xs, XBT_NULL, status_path, &len); + if (buf) { + if (!strcmp(buf, status)) { + ret = true; + break; + } + } + } + } + + free(vec); + free(buf); + + return ret; +} + +static bool write_page_ref(struct xs_handle *xs, uint32_t *page_ref, + uint32_t num_pages, char *path) +{ + xs_transaction_t xs_trans = XBT_NULL; + char buf[128]; + char *ref = NULL; + char tmp[16]; + int i = 0; + bool rc = false; + + /* Caller will free this. */ + ref = (char *)calloc(num_pages * 16, sizeof(char)); /* For each number. */ + if (ref == NULL) { + fprintf(stderr, "Memory calloc for ref failed\n"); + return rc; + } + +retry_transaction: + xs_trans = xs_transaction_start(xs); + if (!xs_trans) + goto out; + + for (i = 0; i < num_pages; i++) { + snprintf(tmp, sizeof(tmp), "%d,", page_ref[i]); + strcat(ref, tmp); + } + + snprintf(buf, sizeof(buf), "%s/page-ref", path); + + if (!xs_write(xs, xs_trans, buf, ref, strlen(ref))) + goto out; + + snprintf(buf, sizeof(buf), "%s/num-pages", path); + snprintf(tmp, sizeof(tmp), "%u", num_pages); + if (!xs_write(xs, xs_trans, buf, tmp, strlen(tmp))) + goto out; + + if (!xs_transaction_end(xs, xs_trans, 0)) { + if (errno == EAGAIN) + goto retry_transaction; + else + goto out; + } + + rc = true; + +out: + if (ref) + free(ref); + + return rc; +} + +static bool write_status(struct xs_handle *xs, const char *status, + const char *status_path) +{ + xs_transaction_t xs_trans = XBT_NULL; + +retry_transaction: + xs_trans = xs_transaction_start(xs); + if (!xs_trans) + return false; + + if (!xs_write(xs, xs_trans, status_path, status, strlen(status))) + return false; + + if (!xs_transaction_end(xs, xs_trans, 0)) { + if (errno == EAGAIN) + goto retry_transaction; + else + return false; + } + + return true; +} + +int main(int argc, char **argv) +{ + void *buffer = NULL; + int domain ; + uint32_t *page_refs = NULL; + FILE *fptr; + int dtbo_size = 0; + const char *path = "data/overlay"; + char receiver_status_path[64] = { }; + char sender_status_path[64] = { }; + struct xs_handle *xs = NULL; + int rc = 0; + int fd = 0; + uint32_t num_pages = 0; + xengntshr_handle *gntshr; + + if (argc < 2) { + fprintf(stderr,"Please enter domain_id.\n"); + return 0; + } + + domain = atoi(argv[1]); + + xs = xs_open(0); + if (xs == NULL) { + fprintf(stderr, "Xenstore open for domain%d failed\n", domain); + goto out; + } + + rc = xs_create_overlay_node(domain, path, xs); + if (rc) { + fprintf(stderr,"Creating overlay nodes failed\n"); + goto out; + } + + strcpy(receiver_status_path, path); + strcat(receiver_status_path, "/receiver-status"); + + strcpy(sender_status_path, path); + strcat(sender_status_path, "/sender-status"); + + /* + * Watch a node for changes (poll on fd to detect). + * When the node changes, fd will become readable. + */ + rc = xs_watch(xs, sender_status_path, "overlay_watch"); + if (rc == 0) { + fprintf(stderr, "Creating watch failed\n"); + goto out; + } + + /* We are notified of read availability on the watch via the + * file descriptor. + */ + fd = xs_fileno(xs); + + /* Wait for ready. */ + if (!wait_for_status(xs, fd, sender_status_path, "ready")) { + fprintf(stderr, "dom0 not ready.\n"); + goto out; + } + + dtbo_size = get_overlay_size(xs, domain, path); + if (dtbo_size == 0) { + fprintf(stderr,"Overlay data size is zero. Exiting the application\n"); + goto out; + } + + gntshr = xengntshr_open(NULL, 0); + if (!gntshr) { + fprintf(stderr,"Error in opening gntshr\n"); + goto out; + } + + num_pages = get_num_pages(dtbo_size); + + page_refs =(uint32_t *)malloc(num_pages * sizeof(int)); + if (page_refs == NULL) { + fprintf(stderr, "Allocating page_ref array failed\n"); + goto out; + } + + /* Allocate memory for data size and share with domain. */ + buffer = create_shared_buffer(domain, page_refs, num_pages, + gntshr); + if (buffer == NULL) { + fprintf(stderr,"Buffer allocation failed\n"); + goto out; + } + + /* Created the buffer and got page_ref. Share the page_ref with domain. */ + if (!write_page_ref(xs, page_refs, num_pages, path)) { + fprintf(stderr,"Writing page ref failed\n"); + goto out; + } + + /* Write the status "page_ref". */ + if (!write_status(xs, "page_ref", receiver_status_path)) { + fprintf(stderr,"Writing status DONE failed\n"); + goto out; + } + + /* Wait for done. This means other domain done copying the dtb to buffer. */ + if (!wait_for_status(xs, fd, sender_status_path, "done")) { + fprintf(stderr, "dom0 status not done\n"); + goto out; + } + + if ((fptr = fopen("overlay.dtbo","wb")) == NULL) { + fprintf(stderr,"Error! opening file"); + goto out; + } + + printf("Writing to file overlay.dtbo.\n"); + + fwrite(buffer, dtbo_size, 1, fptr); + + printf("Done writing to file overlay.dtbo \n"); + +out: + if (fptr) + fclose(fptr); + + if (page_refs) + free(page_refs); + + if (xs) { + close(fd); + + xs_unwatch(xs, path, "overlay_watch"); + + xs_close(xs); + } + + if (buffer) + xengntshr_unshare(gntshr, buffer, num_pages); + + if (gntshr) + xengntshr_close(gntshr); + + return 0; +} From patchwork Wed Apr 24 03:34:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Henry Wang X-Patchwork-Id: 13641154 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 37DB3C4345F for ; Wed, 24 Apr 2024 03:44:17 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.711065.1110775 (Exim 4.92) (envelope-from ) id 1rzTYG-0002p0-E9; Wed, 24 Apr 2024 03:44:08 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 711065.1110775; Wed, 24 Apr 2024 03:44:08 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rzTYG-0002oj-9u; Wed, 24 Apr 2024 03:44:08 +0000 Received: by outflank-mailman (input) for mailman id 711065; Wed, 24 Apr 2024 03:44:07 +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 1rzTQc-0002In-Hm for xen-devel@lists.xenproject.org; Wed, 24 Apr 2024 03:36:14 +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 cc3f77cc-01eb-11ef-b4bb-af5377834399; Wed, 24 Apr 2024 05:36:12 +0200 (CEST) Received: from BLAPR03CA0001.namprd03.prod.outlook.com (2603:10b6:208:32b::6) by SN7PR12MB7418.namprd12.prod.outlook.com (2603:10b6:806:2a5::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.44; Wed, 24 Apr 2024 03:36:09 +0000 Received: from MN1PEPF0000ECDA.namprd02.prod.outlook.com (2603:10b6:208:32b:cafe::df) by BLAPR03CA0001.outlook.office365.com (2603:10b6:208:32b::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7495.33 via Frontend Transport; Wed, 24 Apr 2024 03:36:09 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by MN1PEPF0000ECDA.mail.protection.outlook.com (10.167.242.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7519.19 via Frontend Transport; Wed, 24 Apr 2024 03:36:09 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) 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; Tue, 23 Apr 2024 22:36:09 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Tue, 23 Apr 2024 20:36:08 -0700 Received: from henry-MS-7D54.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Tue, 23 Apr 2024 22:36:07 -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: cc3f77cc-01eb-11ef-b4bb-af5377834399 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AzAsCVGOIBM4aLWQepgcbkJp/V71xl8o/GOqVHdDvyYOGZG7fadR17re5j6yAaY25X9Dnls0k/woSxdzYb95y7zLYfZuDKhXayCDlOp0YSob7K8mxfGbkqA53F4CKJxgzBc/y5EyxTX/T9TzduATO8v676RgoK2t9ZX9NKb9b2hpZw1ywWOM4dokXJPH0PC5mjaaNoxqXmJyYsB0Zii6PS8HHWGQkngsqgdKnJuxedbxYlTHRIHUIFFe0+kIK+6utFCBvglfO0GntH6IQr1JAXc3u7jAQJwYxpmT7O+kOGsqlzID9F5XJSV8ssKWU8d4444AJpGxkKuyx81wIJcFog== 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=RHMeGH0iZW93mGnvrfaGMm5ps1VEfR09KqSQj+crtvI=; b=I5GPS+tJSgbLnvAHhb1kJU2+4WaxEytlHuhkl4eWmsN9uw2dAOVCwmuQa3unVG6MhiYqVM7gMcjt2H6A2GwhZHZ9kh9bqOMm+ep7IQPZdyvrtJf3MkbX6YlDZqAU7b1hN6/v9R7YEt5LM3/vZCTQ+nf+d10wwFq/KImXAaP7zYq+U6VoI5ImPebk/VyELkQyOb9sQcjPn/MjZzXiAa0p5pwmqTev31AJWXAggl6UxszkMidal5bG39lQbVq9JqqWcVcKUeO68AZiGgrDuUnrcaInS2BtTYhEwkv/IaczKv0e/UeJKkXTlMSqL8tnzIn5SX3SaEjcfZaIPc9aNF0ksA== 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=RHMeGH0iZW93mGnvrfaGMm5ps1VEfR09KqSQj+crtvI=; b=xYv38md6GsKSJEs4ASCuVJDkMcunQ/jigiCVYp9CaPbVbMdGUcHP4u3ObnVQDTChVU2NiZLDUG+WQXGuuzyJM73M6d9pZ8tPkeZ6gfSQSjfHdgjnyYPDsknzFZIDsMC5pVc0DTt88eb53QUL7wfsAtz9rgUk3DPZU3hPBY/PgTA= 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: Henry Wang To: CC: Vikram Garhwal , Anthony PERARD , Stewart Hildebrand , Stefano Stabellini , Henry Wang Subject: [PATCH 12/15] get_overlay: remove domU overlay Date: Wed, 24 Apr 2024 11:34:46 +0800 Message-ID: <20240424033449.168398-13-xin.wang2@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240424033449.168398-1-xin.wang2@amd.com> References: <20240424033449.168398-1-xin.wang2@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000ECDA:EE_|SN7PR12MB7418:EE_ X-MS-Office365-Filtering-Correlation-Id: 3f6bd8ae-55d2-45c2-2d01-08dc640fae7f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Smpqz978Gt8Y4jwYCowjh4u88gFcgSMPBYg2xfE1oZXVTOHkXfrmDhRjxqBrQgyZwnCQ2ytVopj33BzY2ozwczeOtOxkD0iJxut9cGiujaT7DIVETZgIUy1ZtRWdBeucLa6F8+R/V/xGJF3fajioMu8RBdgWcpN35XAA9FN0HqIURCjdrygKfuh+IRnLX+UW+5FUHlvh7BzKfeCHPCeMuvxaoEVcOw2yDOVZTeoG1ElyoocF0leHcZnyKZnsneTzIkWHA+bhirtXRnHn2KdbeR7RiWkVz33LFAPhEhCP3gIIFJIspEWW+ba9buzx7Y6lIgyrekQz007TK/l/b04ZPNfNmOfYEklIQFS1yToJxxG9m/JLL26w2CgJVqbc8ftPd0jdHIzLt+Vk9VY4GR96NLHPi9WbO0Imdw6teQutXZlgu4CXWUf9KQYdu2v4AK6hoMpXGd5FkbR7sGGLfn4HqjX/erBWDJiMMVi+PO5N9WSkqErcPtgIDl/rBBp5KmXa1ULxe+9j5yrWg71B9Z92gYZFc0tQxlpKo+DtS4xBjr2Em7AVwrfijy4bI+T1kqSEuIUtFasxvoeUH/J6OsFbZn2UkmxkuD+PTSJLa8EXx+O8fJgQwQ0oPn2DW/tsZJhlnNfMxkxDtfzf3K+sTUAPFF1YRtjuPnSnoUgDmEOI4cQAn8IytKjvGywAa6t61GY0AOcM5FZP+0RKZjrlqeOyyCN7eP39mgXJqw81rqKYAV4ll8caqLJI4u8/DzgBc00GkrtnyOt3Xqet6N4Gw3OCdlqTFI1A82ZjlfpnZrtUenVhY8k+xVvZMnOiXPjksyzO/HBlvGK8oPxgs0VoVS/VCsL6gRigzajHp1w0EwrEg6vtqGWQmbHZ5Ro5f8VY/+KWQV7B7zFdW2LRFuIFVVL6LN3QTGb5djSDvG6bPgccmKrou5mE2BMaMb5SL8PA63iBOkx8j4jhuc1B4qWp2SNcOpKQio/PEUAtTCwhJDgi6yrqf589pmdm9qLXTT/xW1d7O1Tu7S8cc4rJQkYbJ5kJ40+Tbucx782pZCTD/OquZNgoJx+GwV7KKy4YitCXkQrk3+5i7NpqQIETggqV8Pl5Y+uw6QLQScN6WnY1ircg25PMY/EWUOvafZOiMlM9YqhoVo2yhRJqp+tBNqpYXDBedHIbiZntj6TKI/NLKSVooQ6k/TWu75rwbcP0Cy9NUmxruGnv0NdOxOLvywPXie6Gi7lLBLmlIt3IuAImM3vAdFVSpY9ulG1c8iM8fEueoMHeGLVDVDGu1jTxcgUJUkDApasPkuPgpzNis9XsTSTVzkDbIqIbpWX3+QWrvBWpVN+d4045R6vGK8V8tetUvFeHJ1QzTizQnGnq+GmG4D4gIzs2jWazB8PB9qwcIZguTgTG 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)(82310400014)(1800799015)(376005)(36860700004);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2024 03:36:09.4156 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3f6bd8ae-55d2-45c2-2d01-08dc640fae7f 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: MN1PEPF0000ECDA.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7418 From: Vikram Garhwal Retrieve 4 new parameters from xenstore: overlay name, type, whether it is a partial overlay and operation. Operation can be "add" or "remove". Add correspond to existing mode of operation. Remove introduces support for removing an overlay from a domU. Signed-off-by: Vikram Garhwal Signed-off-by: Stewart Hildebrand Signed-off-by: Stefano Stabellini Signed-off-by: Henry Wang --- tools/helpers/get_overlay.c | 132 +++++++++++++++++++++++++++++++++--- 1 file changed, 123 insertions(+), 9 deletions(-) diff --git a/tools/helpers/get_overlay.c b/tools/helpers/get_overlay.c index ca3007570e..daa697ca04 100644 --- a/tools/helpers/get_overlay.c +++ b/tools/helpers/get_overlay.c @@ -66,6 +66,33 @@ retry_transaction: snprintf(ref, sizeof(ref), "%s", "not_ready"); snprintf(buf, sizeof(buf), "%s/sender-status", xs_base); + if (!xs_write(xs, xs_trans, buf, ref, strlen(ref))) + goto fail_xs_transaction; + if (!xs_set_permissions(xs, xs_trans, buf, perms, 2)) + goto fail_xs_transaction; + + /* Create overlay-name node. */ + snprintf(ref, sizeof(ref), "%s", "overlay_node"); + snprintf(buf, sizeof(buf), "%s/overlay-name", xs_base); + + if (!xs_write(xs, xs_trans, buf, ref, strlen(ref))) + goto fail_xs_transaction; + if (!xs_set_permissions(xs, xs_trans, buf, perms, 2)) + goto fail_xs_transaction; + + /* Create overlay-type node. */ + snprintf(ref, sizeof(ref), "%s", "type"); + snprintf(buf, sizeof(buf), "%s/overlay-type", xs_base); + + if (!xs_write(xs, xs_trans, buf, ref, strlen(ref))) + goto fail_xs_transaction; + if (!xs_set_permissions(xs, xs_trans, buf, perms, 2)) + goto fail_xs_transaction; + + /* Create overlay-partial node. */ + snprintf(ref, sizeof(ref), "%d", 0); + snprintf(buf, sizeof(buf), "%s/overlay-partial", xs_base); + if (!xs_write(xs, xs_trans, buf, ref, strlen(ref))) goto fail_xs_transaction; if (!xs_set_permissions(xs, xs_trans, buf, perms, 2)) @@ -174,7 +201,7 @@ static bool wait_for_status(struct xs_handle *xs, int fd, char *status_path, } static bool write_page_ref(struct xs_handle *xs, uint32_t *page_ref, - uint32_t num_pages, char *path) + uint32_t num_pages, const char *path) { xs_transaction_t xs_trans = XBT_NULL; char buf[128]; @@ -249,12 +276,69 @@ retry_transaction: return true; } +static char *get_overlay_ops(struct xs_handle *xs, const char *xs_path) +{ + char buf[128]; + char *ref = NULL; + unsigned int len; + + snprintf(buf, sizeof(buf), "%s/overlay-operation", xs_path); + + ref = xs_read(xs, XBT_NULL, buf, &len); + + return ref; +} +static char *get_overlay_name(struct xs_handle *xs, const char *xs_path) +{ + char buf[128]; + char *ref = NULL; + unsigned int len; + + snprintf(buf, sizeof(buf), "%s/overlay-name", xs_path); + + ref = xs_read(xs, XBT_NULL, buf, &len); + + return ref; +} + +static char *get_overlay_type(struct xs_handle *xs, const char *xs_path) +{ + char buf[128]; + char *ref = NULL; + unsigned int len; + + snprintf(buf, sizeof(buf), "%s/overlay-type", xs_path); + + ref = xs_read(xs, XBT_NULL, buf, &len); + + return ref; +} + +static bool get_overlay_partial(struct xs_handle *xs, const char *xs_path) +{ + char buf[128]; + char *ref = NULL; + unsigned int len; + + snprintf(buf, sizeof(buf), "%s/overlay-partial", xs_path); + + ref = xs_read(xs, XBT_NULL, buf, &len); + + if (ref) { + bool is_partial = atoi(ref); + free(ref); + return is_partial; + } + + return false; +} + int main(int argc, char **argv) { void *buffer = NULL; int domain ; uint32_t *page_refs = NULL; - FILE *fptr; + FILE *fptr = NULL; int dtbo_size = 0; const char *path = "data/overlay"; char receiver_status_path[64] = { }; @@ -263,7 +347,11 @@ int main(int argc, char **argv) int rc = 0; int fd = 0; uint32_t num_pages = 0; - xengntshr_handle *gntshr; + xengntshr_handle *gntshr = NULL; + char *overlay_ops = NULL; + char *name = NULL; + char *type = NULL; + bool is_partial = false; if (argc < 2) { fprintf(stderr,"Please enter domain_id.\n"); @@ -357,16 +445,33 @@ int main(int argc, char **argv) goto out; } - if ((fptr = fopen("overlay.dtbo","wb")) == NULL) { - fprintf(stderr,"Error! opening file"); + overlay_ops = get_overlay_ops(xs, path); + name = get_overlay_name(xs, path); + type = get_overlay_type(xs, path); + is_partial = get_overlay_partial(xs, path); + + if (overlay_ops == NULL || name == NULL || type == NULL) goto out; - } - printf("Writing to file overlay.dtbo.\n"); + printf("%s %s %s", overlay_ops, name, type); + if (is_partial) + printf(" %d", is_partial); + + printf("\n"); - fwrite(buffer, dtbo_size, 1, fptr); + if (!strcmp(overlay_ops, "add")) { - printf("Done writing to file overlay.dtbo \n"); + if ((fptr = fopen("overlay.dtbo","wb")) == NULL) { + fprintf(stderr,"Error! opening file"); + goto out; + } + + printf("Writing to file overlay.dtbo.\n"); + + fwrite(buffer, dtbo_size, 1, fptr); + + printf("Done writing to file overlay.dtbo \n"); + } out: if (fptr) @@ -375,6 +480,15 @@ out: if (page_refs) free(page_refs); + if (overlay_ops) + free(overlay_ops); + + if (name) + free(name); + + if (type) + free(type); + if (xs) { close(fd); From patchwork Wed Apr 24 03:34:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Henry Wang X-Patchwork-Id: 13641150 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 26DD1C4345F for ; Wed, 24 Apr 2024 03:44:01 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.711057.1110735 (Exim 4.92) (envelope-from ) id 1rzTY1-00013D-1M; Wed, 24 Apr 2024 03:43:53 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 711057.1110735; Wed, 24 Apr 2024 03:43:52 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rzTY0-000136-Sj; Wed, 24 Apr 2024 03:43:52 +0000 Received: by outflank-mailman (input) for mailman id 711057; Wed, 24 Apr 2024 03:43:51 +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 1rzTQg-0003iy-A8 for xen-devel@lists.xenproject.org; Wed, 24 Apr 2024 03:36:18 +0000 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on20600.outbound.protection.outlook.com [2a01:111:f403:200a::600]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id ce1f1d0c-01eb-11ef-909a-e314d9c70b13; Wed, 24 Apr 2024 05:36:17 +0200 (CEST) Received: from BL0PR0102CA0061.prod.exchangelabs.com (2603:10b6:208:25::38) by PH8PR12MB7206.namprd12.prod.outlook.com (2603:10b6:510:226::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.22; Wed, 24 Apr 2024 03:36:12 +0000 Received: from BL6PEPF0001AB73.namprd02.prod.outlook.com (2603:10b6:208:25:cafe::1) by BL0PR0102CA0061.outlook.office365.com (2603:10b6:208:25::38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7495.34 via Frontend Transport; Wed, 24 Apr 2024 03:36:11 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by BL6PEPF0001AB73.mail.protection.outlook.com (10.167.242.166) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7519.19 via Frontend Transport; Wed, 24 Apr 2024 03:36:11 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Tue, 23 Apr 2024 22:36:11 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Tue, 23 Apr 2024 20:36:10 -0700 Received: from henry-MS-7D54.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Tue, 23 Apr 2024 22:36:09 -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: ce1f1d0c-01eb-11ef-909a-e314d9c70b13 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ghRDvkE9FCgwOryUffkQ9/MwMaiV/3XgkUUbsRiyZV1Ju4JDEoOE3d4quczvM9RU7t801t4SWP4jZUvyJC8LNHE3XjA6EWqNofTeXngVmMIKXBfO3QkqYH7/j0rkmtWNvW5H3nzSxGpEBqrgZqPqqUbdzyDYoU91RCcot+qwc8x7cNKoB9x2vD6LSQLDM5nn1DJRVapKLpnBQxQJZRk6zaFECljOYc1rn+LhrFe7uRD4/ZPaUeksycAUVPwfUtsFp9a4RPexFbcufFjVFBk7DyXDav1aJB36xf9JFmN6ah7PqL5S63oKsqRxzbZc1CC3nMJjy2Z+HThri4PqG7ZaNQ== 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=AQUYI8nFNauA8Eqc+dTwkfBb4u7bvFl+DOSdQh9a2O8=; b=Hg6AyUF//gVHUUAvePooLAjWKg3lzfTBVFQLY6PPF/xxFCSWjQ+TK16Czg9ySV4aMUFCYYaGQi8aboE2dXunUVGvJpRcMHVL9w/SLbiBH+V0rZZ92mzDioo+8GIvXokuqXL3pVEaqvSV39iFs5n7B0caaSOhIpH/UkWirBvOvgIbA7z2MrPyPB42ZQvbpixxAtzNeQ7i+mpblIj4X1Ub7YFHVgBQ9D5Sbl5fNnl8jFj2CV7Xrlw9f/T8DV0JoQODNk5JcLSDpKXntEDo4bs58m6DWag0cnACnlDoFh/xh2b/Ei+B/5i7vAr8MPqhr2jBRnktrXwQuyQPewhT7eX/lQ== 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=AQUYI8nFNauA8Eqc+dTwkfBb4u7bvFl+DOSdQh9a2O8=; b=NB4Jbd0TLDTXBfahb8afVzymAvLYtFwrQWa+qWp2ymRyc6DC4Vs0Mbg2aESyxRy3j2dMZG41qgbf6+e2725bNGYK20CLCC+Iw97kBjh4YxVwmlERzQFPkBE0E1mxxiB7kOWfBDfTRkNzvAV6tli3vabUSuEv0F9gQyN82zz1JBE= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C From: Henry Wang To: CC: Vikram Garhwal , Anthony PERARD , Stefano Stabellini , Henry Wang Subject: [PATCH 13/15] xl/overlay: add remove operation to xenstore Date: Wed, 24 Apr 2024 11:34:47 +0800 Message-ID: <20240424033449.168398-14-xin.wang2@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240424033449.168398-1-xin.wang2@amd.com> References: <20240424033449.168398-1-xin.wang2@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB73:EE_|PH8PR12MB7206:EE_ X-MS-Office365-Filtering-Correlation-Id: 3df460e3-5aae-437d-590a-08dc640fafa2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|82310400014|376005|36860700004; X-Microsoft-Antispam-Message-Info: TdSarGKTVe51lz0a5kBmLLtN4JH9E1C/limauW/385+6HgkrE0eLPd7S4OUztr2+yOqQW6YtjGty/LjAuVxVFqFFf7goUCzFmJdvslNm4AY6lPm4POtW042aZ4wqyYUiwKYK8tMt74ZV1sgNQNRR45CKZGgJ4Saze56BFdeYf84UhmLM8FPi6xrKF09ueQAr+ccZ7RgF/pTv0DEE9W0eRhHj2nmNbHCeMdlG8K1M3pPsJwt8CWDwovIUm3c3+8bX813nbCI7XGz8/r3i6Z1CAsgakI2m/KPV2UA996gvVxnPwZLSEzluNRZRhMHRa0EQ2FgrhaqhgV7K6y9l4q8P9xboPHzULrKGUF03XUCReFpGTBj6EwFM8cfo/21C8sfwsaZnZNmJyR8lD5wjfLyUNKJLu37RPJGOqKoi3swZzAJwMSq+egrEmq7AJhAY/f1oqbEmpYtBvw69JJnupDXn/xKr4yprInt+cU1F7yA5Y3E2jaxsk6uNEJi4De1yuo5n3yU59YsGMAoYNcvti3JkkUZ9Ph/+SZlEzXBZ9ST5i/SYtNk3oFnnxmmelY0lPgvovnlMOBPf8WoCex89AVFX7mqzXMXuEuewBAekC0OW5Pl681djcBJ77DneVOaK488Y7Db6yzS9q0lxeO1pUoaFN+lL7R+KtzItyau3rt0qXWzRS6LUZooovv5Q0ruSqTav1Sbrty6JItgdDo+IBUp1fXDvWAsz75D1C2l/1LIxtZL10fYXATi54w63VeY5olLnu2QOTJ49a6tvUh0F3gTzII+fD/9ds7YsVyQpr6jqocrPphLj/NTSmmPmkr/R2HKFWaoC6RaZ5nP+Ik7e8njzpwfPP90eRhKAvgbI/oZsLalsVRMUMi/nb46LFd3mjexBA1D8MKz3jIgeBmuk8KHHKpF1opR+WMpEVkca7PY7MyVHIBrzMBgmHtAqLQrGQ9bhA0QL3NPJ9DjkDQnUOvKdJ4CxjStGBM1HGK/8a1kNBeVHw/YjOT/nL1uXuT+Ud69mOLMOXh73V/rcMt8/dB3C7WgSqkso0X/QmpjTyXXh1eLZJan2fYsgyTSXajRdKce8GM3lyERucDqAKr0akogONq2LmNVm6/qphCG8pak1O3NPGIdWfN8SG0W+vwrRQUm157twupH4QzCenPJe5OAjlbl0zIPuw72QwGphN/xKx/VL7BGmWiuDtXE1s2EJNne9CXKw7vPw70h1Onu7A2805l/Mg/+FSBa/SDV7gRmYi44l+/SJl7oiKYOR8ZTlYaKbypN4lAnwx2wB0vr4kL5XMKuRa2jROMlgFRDbc8+ThtdxTWZI7OaapO+oigcGabM+Cx1GBC9epj2MhUSSujgHVmZy9fYL5EsagACboCyHnhc= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(1800799015)(82310400014)(376005)(36860700004);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2024 03:36:11.3238 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3df460e3-5aae-437d-590a-08dc640fafa2 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB73.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB7206 From: Vikram Garhwal Add 3 new command line parameters to the xl overlay command: overlay name, type and partial. Pass these paramters to the domU via xenstore. Also introduce support for "operation" in xenstore: it can be "add" or "remove". In case of "remove", the overlay is to be removed from the domU device tree. Signed-off-by: Vikram Garhwal Signed-off-by: Stefano Stabellini Signed-off-by: Henry Wang --- tools/xl/xl_vmcontrol.c | 184 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 173 insertions(+), 11 deletions(-) diff --git a/tools/xl/xl_vmcontrol.c b/tools/xl/xl_vmcontrol.c index 2bf76dd389..ddd6e9e370 100644 --- a/tools/xl/xl_vmcontrol.c +++ b/tools/xl/xl_vmcontrol.c @@ -1466,8 +1466,123 @@ static uint32_t get_num_pages(struct xs_handle *xs, const char *xs_path) return num_pages; } +static bool write_overlay_operation(struct xs_handle *xs, char *operation, + char *path) +{ + xs_transaction_t xs_trans = XBT_NULL; + char buf[128]; + char ref[64]; + +retry_transaction: + xs_trans = xs_transaction_start(xs); + if (!xs_trans) + return false; + + snprintf(ref, sizeof(ref), "%s", operation); + snprintf(buf, sizeof(buf), "%s/overlay-operation", path); + + if (!xs_write(xs, xs_trans, buf, ref, strlen(ref))) + return false; + + if (!xs_transaction_end(xs, xs_trans, 0)) { + if (errno == EAGAIN) + goto retry_transaction; + else + return false; + } + + return true; +} + +static bool write_overlay_name(struct xs_handle *xs, char *name, + char *path) +{ + xs_transaction_t xs_trans = XBT_NULL; + char buf[128]; + char ref[64]; + +retry_transaction: + xs_trans = xs_transaction_start(xs); + if (!xs_trans) + return false; + + snprintf(ref, sizeof(ref), "%s", name); + snprintf(buf, sizeof(buf), "%s/overlay-name", path); + + if (!xs_write(xs, xs_trans, buf, ref, strlen(ref))) + return false; + + if (!xs_transaction_end(xs, xs_trans, 0)) { + if (errno == EAGAIN) + goto retry_transaction; + else + return false; + } + + return true; +} + +static bool write_overlay_type(struct xs_handle *xs, char *type, + char *path) +{ + xs_transaction_t xs_trans = XBT_NULL; + char buf[128]; + char ref[64]; + +retry_transaction: + xs_trans = xs_transaction_start(xs); + if (!xs_trans) + return false; + + snprintf(ref, sizeof(ref), "%s", type); + snprintf(buf, sizeof(buf), "%s/overlay-type", path); + + if (!xs_write(xs, xs_trans, buf, ref, strlen(ref))) + return false; + + if (!xs_transaction_end(xs, xs_trans, 0)) { + if (errno == EAGAIN) + goto retry_transaction; + else + return false; + } + + return true; +} + +static bool write_overlay_partial(struct xs_handle *xs, bool is_partial, + char *path) +{ + xs_transaction_t xs_trans = XBT_NULL; + char buf[128]; + char ref[4]; + +retry_transaction: + xs_trans = xs_transaction_start(xs); + if (!xs_trans) + return false; + + snprintf(ref, sizeof(ref), "%d", is_partial); + snprintf(buf, sizeof(buf), "%s/overlay-partial", path); + + if (!xs_write(xs, xs_trans, buf, ref, strlen(ref))) + return false; + + if (!xs_transaction_end(xs, xs_trans, 0)) { + if (errno == EAGAIN) + goto retry_transaction; + else + return false; + } + + return true; +} + + static int share_overlay_with_domu(void *overlay_dt_domU, int overlay_dt_size, - int domain_id) + int domain_id, char *overlay_ops, + char *overlay_name, + char *overlay_type, bool is_overlay_partial) { struct xs_handle *xs = NULL; char *path = NULL; @@ -1574,6 +1689,34 @@ static int share_overlay_with_domu(void *overlay_dt_domU, int overlay_dt_size, goto out; } + /* write overlay ops */ + if (!write_overlay_operation(xs, overlay_ops, path)) { + err = ERROR_FAIL; + fprintf(stderr,"Writing overlay_ops ready failed\n"); + goto out; + } + + /* Write the overlay-name. */ + if (!write_overlay_name(xs, overlay_name, path)) { + err = ERROR_FAIL; + fprintf(stderr,"Writing overlay_name ready failed\n"); + goto out; + } + + /* Write the overlay-type. */ + if (!write_overlay_type(xs, overlay_type, path)) { + err = ERROR_FAIL; + fprintf(stderr,"Writing overlay_type ready failed\n"); + goto out; + } + + /* Write the overlay-partial. */ + if (!write_overlay_partial(xs, is_overlay_partial, path)) { + err = ERROR_FAIL; + fprintf(stderr,"Writing overlay_partial ready failed\n"); + goto out; + } + /* Write the status "done". */ if (!write_status(xs, "done", sender_status_path)) { fprintf(stderr,"Writing status DONE failed\n"); @@ -1611,13 +1754,16 @@ int main_dt_overlay(int argc, char **argv) int overlay_dtb_size = 0; const int overlay_add_op = 1; const int overlay_remove_op = 2; + char *overlay_name = "overlay"; + char *overlay_type = "normal"; + bool is_overlay_partial = false; if (argc < 3) { help("dt-overlay"); return EXIT_FAILURE; } - if (argc > 5) { + if (argc > 7) { fprintf(stderr, "Too many arguments\n"); return ERROR_FAIL; } @@ -1625,17 +1771,22 @@ int main_dt_overlay(int argc, char **argv) overlay_ops = argv[1]; overlay_config_file = argv[2]; - if (!strcmp(argv[argc - 1], "-e")) - auto_mode = false; - - if (argc == 4 || !auto_mode) { + if (argc == 4 ) { domain_id = find_domain(argv[argc-1]); domain_mapping = true; - } - - if (argc == 5 || !auto_mode) { - domain_id = find_domain(argv[argc-2]); + } else if (argc == 5 && !strcmp(argv[4], "-e")) { + domain_id = find_domain(argv[3]); + auto_mode = false; domain_mapping = true; + } else if (argc == 7) { + domain_id = find_domain(argv[3]); + domain_mapping = true; + overlay_name = argv[4]; + overlay_type = argv[5]; + is_overlay_partial = atoi(argv[6]); + } else { + fprintf(stderr, "Invalid arguments\n"); + return ERROR_FAIL; } /* User didn't prove any overlay operation. */ @@ -1678,7 +1829,18 @@ int main_dt_overlay(int argc, char **argv) if (domain_id && auto_mode && (op == LIBXL_DT_OVERLAY_ADD)) rc = share_overlay_with_domu(overlay_dtb, overlay_dtb_size, - domain_id); + domain_id, "add", overlay_name, + overlay_type, is_overlay_partial); + + if (rc) { + free(overlay_dtb); + return rc; + } + + if (domain_id && auto_mode && (op == LIBXL_DT_OVERLAY_REMOVE)) + rc = share_overlay_with_domu(overlay_dtb, overlay_dtb_size, + domain_id, "remove", overlay_name, + overlay_type, is_overlay_partial); free(overlay_dtb); return rc; From patchwork Wed Apr 24 03:34:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Henry Wang X-Patchwork-Id: 13641153 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 78E9FC4345F for ; Wed, 24 Apr 2024 03:44:13 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.711062.1110765 (Exim 4.92) (envelope-from ) id 1rzTYD-0002Lk-4D; Wed, 24 Apr 2024 03:44:05 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 711062.1110765; Wed, 24 Apr 2024 03:44: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 1rzTYC-0002Lb-WA; Wed, 24 Apr 2024 03:44:04 +0000 Received: by outflank-mailman (input) for mailman id 711062; Wed, 24 Apr 2024 03:44:03 +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 1rzTQh-0003iy-Bl for xen-devel@lists.xenproject.org; Wed, 24 Apr 2024 03:36:19 +0000 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on20600.outbound.protection.outlook.com [2a01:111:f403:2412::600]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id cecdd210-01eb-11ef-909a-e314d9c70b13; Wed, 24 Apr 2024 05:36:18 +0200 (CEST) Received: from BL0PR0102CA0024.prod.exchangelabs.com (2603:10b6:207:18::37) by DM4PR12MB7600.namprd12.prod.outlook.com (2603:10b6:8:108::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.22; Wed, 24 Apr 2024 03:36:13 +0000 Received: from BL6PEPF0001AB77.namprd02.prod.outlook.com (2603:10b6:207:18:cafe::cb) by BL0PR0102CA0024.outlook.office365.com (2603:10b6:207:18::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.22 via Frontend Transport; Wed, 24 Apr 2024 03:36:13 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by BL6PEPF0001AB77.mail.protection.outlook.com (10.167.242.170) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7519.19 via Frontend Transport; Wed, 24 Apr 2024 03:36:13 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Tue, 23 Apr 2024 22:36:12 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Tue, 23 Apr 2024 20:36:12 -0700 Received: from henry-MS-7D54.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Tue, 23 Apr 2024 22:36:11 -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: cecdd210-01eb-11ef-909a-e314d9c70b13 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aDSJRmQIiiiLCz9avQGyQktVTogrll7840XOI1Gxap3xP8Ys3sZXilkNbRoV4ddzWH5Ye7fr9tDHF2sKrDrVcdax5PhW9N44JLAAuKSseRwV09/fURn4de0qwHGX20uueNYyP1HiEaYDSMoQGeu/tZBna2euOkvGCXZEFegR1camIYUhuPWev/pkRu2CfF+fckM+E2snbiL3jsVbZKBpXavCVbRKDt11+3l9//G3UF6FXeC/1NwUA6o5aGXT0SHpd8zMFiSkm1kLc3no7tLXQRO/cQWyTnFlnv3fFA6IIzLXc7Fpimdeex/SC/OKKK+oqwGAyKdlUQoyZgN9Wj0Tyg== 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=P4gTMnujfvEGKwn+wIQsB0+jlCBFdxbEKPbGnjsFUW0=; b=a5ztsyrWPlNBC/3ifDww/JtjBO6P3V67Sr+h+CgNQrMSYJksQ/Jx3FxGdgjuXohd3HI0PeipVUG+q/eJIcQ3zpp9i6JLJqhpIBwgv1nbft7dYJS6N+A6b3ka7OWlpyl3Vyb5MZ8mAd88eiqDS0KY7lLn/LDHYS4j2xJuZMYy8LrUJW2WZNvmOiA+9oYe1KOQc6U6BvS50fYGMTG+/0Q36HLdzqukSYdEvNHfz9c7YR7W/sx33TtKU9YqeCQnUX4YrZucudCp5p5ZPHG1Oi2L8noBLBpUz4zDgk8KqHwvKnhTyPU0LR3dBmWJ8MbwIfdwh/TtEowIjvkRNiLmc750+Q== 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=P4gTMnujfvEGKwn+wIQsB0+jlCBFdxbEKPbGnjsFUW0=; b=CTVk0cEiYEly3J39WHNTBaY8/pf1w88nbmJpO0mer+cPTCxHwCKG6Ld2OhcKuGANTjriMGIMj0HfYMNWAk5rW+98kCP67ZqQm/FLa94/YQQuW5EGCvjOQpdPUrULGlaHCMyzaUuJRd/UJz7PCnRFL2Vd/e4otNBryKUhJb1dlR0= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C From: Henry Wang To: CC: Vikram Garhwal , Anthony PERARD , Stefano Stabellini , Henry Wang Subject: [PATCH 14/15] add a domU script to fetch overlays and applying them to linux Date: Wed, 24 Apr 2024 11:34:48 +0800 Message-ID: <20240424033449.168398-15-xin.wang2@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240424033449.168398-1-xin.wang2@amd.com> References: <20240424033449.168398-1-xin.wang2@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB77:EE_|DM4PR12MB7600:EE_ X-MS-Office365-Filtering-Correlation-Id: 31330504-1bb6-42a6-e2c3-08dc640fb0c7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|82310400014|376005|1800799015|36860700004; X-Microsoft-Antispam-Message-Info: ve/mPMYnVY/gFR6TZTIM/qRVge/0fldx8ql4xIXUmxzfZGfeABm3MCsS2ujj8XU41+lT0ofl/JtQsAWiOGSb2vrTvAQYNcg3bPj9b+2zToRVSpK/pNM0Oj2pxyMfKHUlJDQRwQv4j0tW83ESr0R2BbiCP4wsqFVfbwg5RF5A1IL6sNuDZbGv9oKe4uJwvfJIVeQGKA7L5DTtSu2xFRk2jBmaSQAM3izBBmJlXmxy732Cd2PXyaJiFxGhRB8RBgFhPyUvpkbARAuyRRCHHOeav47Dv7e03tVUE1Cr1fbLxwpObYmLsBX+bRsmFQD/gecneBZiCKP09ZbnS4OgU4eshg11Imm/Cdw7WI0pmFKYsT4EZsDslaeN592CrXg5EgD96mgF0cFqo2Irn9St5zYmpiawK5i3xSz+FkGswUQRpixtU2x6n4e3mcZ5Zio5l1vE+kJc7Y1qEHLGbu8kEKl2u9crjMn/pmdPoP4F/jSxfsxp+6oa7aRsmrW5GYLs8j5s+cR4y99NTetyyfpUmvt8El3pKrJ7bqCOoEkPUoBbz4fAmKyz1Ph6JwQSvvaf5oq5xq776IS6n9NFl3u/oUW/y8GHmr0x25TCqhBce3WGJdZzjaU64yAFWy5KlFhLYjv9YgWgV6rYz92GDZWCIsghJnspG4fsBAPkKxPXa4gdiDJeqlnnQkcmTbnQTd4M6zYmmsDV2jTwbygZS+F6nMP6fV51dc6De7hY9Atm9yDyCbdxpUQQbWf025K0YCYfkSozQTSA0sdKM/TPCaNelZxtaYd3qCE5J+p5odiLWBGNgR2bJ0p1bBc1Z7zHjqqffXtfY/jlohsQc7Fw6PXufotBtlHGSUDMLHzA0iviE+QWp5hu8u8QXAEVW7a5fzGoS8q3omw6NRJrHjHXFbmIO8JkJFeA3oXGuxmDsljQBvBbV74EQYqtAOd8S5Lsm0CGT8l/tBOt8YaOmnNuRr02YBnFx6DbiMnqyaQnZfHcoDdcemDSRriKMeit8b+u3UVuqM9yoRanogVluyTSeXBHIoGLzWSGMUPgpaS+EBLkzwi52KJdECToqTsMjX4ENpdoBhfKWhJf3Y27YdHkfVhUsPl4GfCpIbd8y4Xcs/C33hhROIblU8eXwqHkPUAa9rjEkA6W8DkGpRswviqdkpb5SDgpJCvyiG8xT5G0gyTBhEBzOJG0m4Q8yH+3ChnbzNAn/5RSPxQ07IoWD9uqyvC67T+X3LvlY48PT5ZcuGloNKOoK7reYI/Ekcea1rztNigTG2bqdPtzjfrJ45zB/Om1fLXLg4cG4ZD0wqcDiqOMKYN4n6AlIXVbaDqRw1Mv5mrZUC6njMPTqendrN25oAEHXosrDEQp9ryDlh8j5X9cE6BerOc= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(82310400014)(376005)(1800799015)(36860700004);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2024 03:36:13.2475 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 31330504-1bb6-42a6-e2c3-08dc640fb0c7 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB77.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB7600 From: Vikram Garhwal Introduce a shell script that runs in the background and calls get_overlay to retrive overlays and add them (or remove them) to Linux device tree (running as a domU). Signed-off-by: Vikram Garhwal Signed-off-by: Stefano Stabellini Signed-off-by: Henry Wang --- tools/helpers/Makefile | 2 +- tools/helpers/get_overlay.sh | 81 ++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+), 1 deletion(-) create mode 100755 tools/helpers/get_overlay.sh diff --git a/tools/helpers/Makefile b/tools/helpers/Makefile index dfe17ef269..2d0558aeb8 100644 --- a/tools/helpers/Makefile +++ b/tools/helpers/Makefile @@ -58,7 +58,6 @@ init-dom0less: $(INIT_DOM0LESS_OBJS) get_overlay: $(SHARE_OVERLAY_OBJS) $(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenvchan) $(LDLIBS_libxenstore) $(LDLIBS_libxenctrl) $(LDLIBS_libxengnttab) $(APPEND_LDFLAGS) - .PHONY: install install: all $(INSTALL_DIR) $(DESTDIR)$(LIBEXEC_BIN) @@ -67,6 +66,7 @@ install: all .PHONY: uninstall uninstall: for i in $(TARGETS); do rm -f $(DESTDIR)$(LIBEXEC_BIN)/$$i; done + $(RM) $(DESTDIR)$(LIBEXEC_BIN)/get_overlay.sh .PHONY: clean clean: diff --git a/tools/helpers/get_overlay.sh b/tools/helpers/get_overlay.sh new file mode 100755 index 0000000000..2e8c6ecefd --- /dev/null +++ b/tools/helpers/get_overlay.sh @@ -0,0 +1,81 @@ +#!/bin/sh + +modprobe xen_gntalloc +modprobe xen_gntdev + +while : +do + overlay_node_name="" + type_overlay="normal" + is_partial_dtb="" + + output=`/usr/lib/xen/bin/get_overlay 0` + + if test $? -ne 0 + then + echo error + exit 1 + fi + + if test -z "$output" + then + echo "" + exit 1 + fi + + # output: add overlay-name normal partial + operation=`echo $output | cut -d " " -f 1` + overlay_node_name=`echo $output | cut -d " " -f 2` + type_overlay=`echo $output | cut -d " " -f 3` + is_partial_dtb=`echo $output | cut -d " " -f 4` + + if test -z "$operation" || test -z "$overlay_node_name" + then + echo "invalid ops" + exit 1 + fi + + if test $operation = "add" + then + echo "Overlay received" + + if test "$type_overlay" = "normal" + then + final_path="/sys/kernel/config/device-tree/overlays/$overlay_node_name" + mkdir -p $final_path + cat overlay.dtbo > $final_path/dtbo + else + # fpga overlay + cp overlay.dtbo lib/firmware/ + mkdir /configfs + mount -t configfs configfs /configfs + cd /configfs/device-tree/overlays/ + + if test "$is_partial_dtb" + then + mkdir partial + echo 1 > /sys/class/fpga_manager/fpga0/flags + echo -n "overlay.dtbo" > /configfs/device-tree/overlays/partial + else + mkdir full + echo -n "overlay.dtbo" > /configfs/device-tree/overlays/full + fi + fi + elif test $operation = "remove" + then + if test "$type_overlay" = "normal" + then + # implement remove + path=/sys/kernel/config/device-tree/overlays/$overlay_node_name/dtbo + if ! test -f $path + then + echo "error: path doesn't exist" + exit 1 + fi + rm $path + fi + else + echo "operation unsupported" + exit 1 + fi +done From patchwork Wed Apr 24 03:34:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Henry Wang X-Patchwork-Id: 13641149 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 A2E16C4345F for ; Wed, 24 Apr 2024 03:43:56 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.711053.1110725 (Exim 4.92) (envelope-from ) id 1rzTXs-0000cn-P8; Wed, 24 Apr 2024 03:43:44 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 711053.1110725; Wed, 24 Apr 2024 03:43:44 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rzTXs-0000cN-Lb; Wed, 24 Apr 2024 03:43:44 +0000 Received: by outflank-mailman (input) for mailman id 711053; Wed, 24 Apr 2024 03:43:43 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rzTQk-0003iy-7f for xen-devel@lists.xenproject.org; Wed, 24 Apr 2024 03:36:22 +0000 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on20600.outbound.protection.outlook.com [2a01:111:f403:2414::600]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id d10f4b04-01eb-11ef-909a-e314d9c70b13; Wed, 24 Apr 2024 05:36:21 +0200 (CEST) Received: from BLAPR03CA0133.namprd03.prod.outlook.com (2603:10b6:208:32e::18) by CH2PR12MB4246.namprd12.prod.outlook.com (2603:10b6:610:a9::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.44; Wed, 24 Apr 2024 03:36:16 +0000 Received: from BL6PEPF0001AB75.namprd02.prod.outlook.com (2603:10b6:208:32e:cafe::c9) by BLAPR03CA0133.outlook.office365.com (2603:10b6:208:32e::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7495.34 via Frontend Transport; Wed, 24 Apr 2024 03:36:16 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by BL6PEPF0001AB75.mail.protection.outlook.com (10.167.242.168) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7519.19 via Frontend Transport; Wed, 24 Apr 2024 03:36:15 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Tue, 23 Apr 2024 22:36:15 -0500 Received: from henry-MS-7D54.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Tue, 23 Apr 2024 22:36:13 -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: d10f4b04-01eb-11ef-909a-e314d9c70b13 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PGCbezdktqld2vbBB95zhs1DELJyKC2mW/o9ZQKBEqJXWqGlJ2PbyfnyX+xqbiKHgXEfsPej918SG/oOmKJZPOJhjlHIhtPFGiNdx2MGdhjTQrBXTSXtNCgDaE0HAK4V8redAX422glkagWeg7zZo4dZFpkhNkZVjx3HojLjuJsGxqzWcLykDtIsQn8kJQwpGPPL+fCGbx+MifftvlycEndEMjAE/tpWJQSTDFhZ3R7wS839k1DS3dASn/+X2Lo0Ojw3JR9RKy4DQ+6wgDl273yeGWKitQuQFbdFlfdt6oEoryuGHIbZQWZ3Zdl13NH6l82EPQQ7ZKjaAo7ZDoQESw== 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=YTNLBtjiYYmlxApKNXyZCt+SLybH8i5qLWCARszzQRM=; b=gEHr/K4qysy9Yk+pLTqnSiYCjEA3L0iAQ3gDFdG30ftOVikzJ5zyDgHtSJB6yTHILUJ2ffbq6qsWnTKls6H4RRjZ7Wu99dsjpw5ylAkznw9p63vmLulwROmkiqPyDl3YgwIZwgNN5qThwUwmR7Vo08u1kdJAiFcblYvGU6nReNaeHP3L6iHCBrgvHii0sqz6Rqe/SbytYLvEIThbMhY4Vf/clhsTPEsG4LJbZ4SLjDeL415QwWtO0GG2tLWqui7oMjwnIqwbtm/Ng5d/lbsBaUyun01pTFDeGvS5pCtZ6I9NKcLEsqhm0jvjX9PG0ciyFPyeo0uofYdwGWMkatXOrw== 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=YTNLBtjiYYmlxApKNXyZCt+SLybH8i5qLWCARszzQRM=; b=TyhUEB8xgPQSpvDftFo5LvIY70qHo/Eo+KTUqPjOuH+sDEqCbZWE3DAoEfwPMLGZtZ4VOJ7EM4DLrvsh/yhgLrM1ooEXppfitRTxR1xphnMSDBzOYWI/t52xR/p6y7EItVAbPnOINCrJrnd+tSHe6lWcZW1096PKYeklj5Dz3ag= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C From: Henry Wang To: CC: Vikram Garhwal , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , "Volodymyr Babchuk" , Stefano Stabellini , Henry Wang Subject: [PATCH 15/15] docs: add device tree overlay documentation Date: Wed, 24 Apr 2024 11:34:49 +0800 Message-ID: <20240424033449.168398-16-xin.wang2@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240424033449.168398-1-xin.wang2@amd.com> References: <20240424033449.168398-1-xin.wang2@amd.com> MIME-Version: 1.0 Received-SPF: None (SATLEXMB03.amd.com: xin.wang2@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB75:EE_|CH2PR12MB4246:EE_ X-MS-Office365-Filtering-Correlation-Id: 6846187a-e152-4a97-c74c-08dc640fb25a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PGGIThaCJFQX0jXmTSnPba5ZGxXovPsG4o001npZbHll1SNu6Nd5xRq+2PnoKYbv9ZmjTf1Mrl7v4DCRo3AN6ZDx1KMIeTL8h91GBsycf4ZQYgpIuDkd+u/BKa/NyKU29s1ZaXJsex7ZovFfoJJkth57+ixi0KR5lHZ2NCvJNiICe68z+AGaM5NdcpKUyU1U/up/AG3pcxNhX3M1LTAO6bMQH/Bu4/9PCYqQnjT1FSTFghEOxX5MEvkRPXvXRz094DE9WhZC/ucvUlRDhz4hRIU3puOrztB4QdIJPkAvibI9xuMigunKYi4YgkSdAS3ThgaiI2V8d+x/un2pR0aLNTfjSXrsPfopW8Cjp6OaH4ABp59aJ+wCW7MrArKzUBYRBiWal2JDPAkrsN5St1L3+wBAz43e/srs+gskxgNXpeMUaKwP1S6t3IbQtp/DOSRHFgxy5ykTH5KDawqjrH8pyiVayM8qqhfaZLLldCltPxp8RvlAP0Qv1FZILXBc9pnJsoUnCpxaj49B4E0FD/ipTT4bv4FGsgciItgH8jvC8JvJtxCuIGHG08L1s4mOKjdv/fr/BAhSb8Trz87KSA+HYRb8xuyodhwUo5F1ep1T4qVsc4hEwsXT6hFWZiW7KvMr8Fa3i/AFsH6cQjX8nvivN+wOODMBmisXc80M9X9IJhrcpxYyw5NyMQImi142twSZlAnbBOm2XjAXY/WUBbzgJH0gkdp0L2NXt3fyOv8FiNKFzOsz77i9emAyrlA435u+DOs5ntZHMDESxA3qnTjBH2PEUbuwHh/p+gHyZ6ovrl0o1niy787QMmXSqL7Nv4tPyHbcTU5xQ4WVIeRfTMds5ja/Gq3nR6Fdzmvx/QucEF7GyxoJQ4XvSVV5U6hMnqB68ja7VL/kAKpzA+lG+12BEMLaGMJQMgqYLk3W+kbKl/DRuaDby2FkSwvdvYxPG0oMH1JryQTeDVvVPPN7yespSbSac+9IKRzJ3g2IG0+TegBJjhuE2jnnfocVWz51K+8cVeEY/Y8l8IRqsnJsNrsrnkxq77/mp7F3QsfV1bq46JfR5hFw6cP79Mw2wXc4mJPKGhquNhM25KBe6tyK/Lf3ZkXmsTwP8NpjM31X///cGYHAMoLh16OmAc7HnzHiB/7c3KTRS11Y1lsGtepKwo281uV+BX6yZSSxwOfKQbCBNm0VZy24PvGR7wChR/BUTH0npnBTNyuMgQYrRtKPZoWDJiRGl//rPS3wWDqhd8ppQH+yWgjwCOkpIi/X0vxgzlhtbbOgc2vkkXrWeIV7CMsA30I7VpVz0yFNIOxi1pyli03kw0Pj3BDQkYh0BIjSSNQbAwNo5gmZvoiO49u9fN8S6d4Jpkm60nGojeTqJ7kB5k8= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(1800799015)(82310400014)(376005)(36860700004);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2024 03:36:15.8879 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6846187a-e152-4a97-c74c-08dc640fb25a X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB75.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4246 From: Vikram Garhwal Signed-off-by: Vikram Garhwal Signed-off-by: Stefano Stabellini Signed-off-by: Henry Wang --- docs/misc/arm/overlay.txt | 172 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 172 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..0351f82a19 --- /dev/null +++ b/docs/misc/arm/overlay.txt @@ -0,0 +1,172 @@ +# Device Tree Overlays support in Xen + +Xen now supports dynamic device assignment to running domains i.e. +adding/removing nodes (using .dtbo) in Xen device tree, and assigning +them to a running domain with given $domid. + +Xen supports two modes of operation: normal mode and expert mode for +assigning nodes to domU. More on this below. + +Dynamic node assignment works in following ways: + +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 the dtbo to Xen device tree and assign the + dbto's node resources to the user-provided $domid. +4. For normal mode, Xen tools share the modified dtbo with domU. domU needs + to run get_overlay.sh to get the dtbo from dom0 and apply the + overlay. get_overlay.sh uses get_overlay application for data transfer + between dom0 and domU. + + +# Overlay Sharing protocol based on Xenstore + +The overlay sharing protocol with domU works in the following ways: + +1. get_overlay creates Xenstore path data/overlay and creates the + following nodes under data/overlay path: + a. receiver-status + b. sender-status + c. overlay-size + d. overlay-name + e. overlay-type + f. overlay-partial + and write "waiting" on receiver-status and "not_ready" to sender_status. + +2. libxl waits for "waiting" status on receiver-status, then writes + "overlay-size" with dtbo size and "ready" on "sender-status". + +3. get_overlay waits for "sender-status" to "ready", then allocates the + pages, next it shares the pages with dom0 (the page-ref num) by creating + page-ref node under /data/overlay and finally writes "page-refs" to + "receiver_status". + +4. libxl waits for "receiver-status" to become "page-refs" and copies + the data to buffer allocated with page_refs. libxl also writes the + "overlay-name", "overlay-type", and "overlay-partial" nodes with + user-provided information. Lastly, libxl writes "done" to + "sender-status". + +6. get_overlay waits for "sender-status" to be "done". + +7. get_overlay copies the data and writes it to file. + +8. Finally, get_overlay unshares the pages with dom0. + +Note: get_overlay application needs two drivers xen_gntdev and xen_gntalloc in +Linux. These can be loaded using modprobe xen_gntalloc and modprobe xen_gntdev. + + +# Examples + +Here are a few examples on how to use it. + +## Dom0 device add + +For assigning a device tree overlay to dom0, enter the following: + + (dom0) xl dt-overlay add overlay.dtbo 0 + +This will allocate the devices mentioned in overlay.dtbo to Xen device +tree and will assign these devices to dom0. + +Next, if the user wants to add the same device tree overlay to dom0 +Linux, execute the following: + + (dom0) mkdir -p /sys/kernel/config/device-tree/overlays/new_overlay + (dom0) cat overlay.dtbo > /sys/kernel/config/device-tree/overlays/new_overlay/dtbo + +Finally if needed, the relevant Linux kernel drive can be loaded using: + + (dom0) modprobe module_name.ko + + +## Dom0 device remove + +For removing the device from dom0, do the following: + + (dom0) xl dt-overlay remove overlay.dtbo + +NOTE: The user is expected to unload any Linux kernel modules which +might be accessing the devices in overlay.dtbo. Removing devices without +unloading the modules might result in a crash. + +The following is an incorrect sequence: + + (dom0) xl dt-overlay add overlay.dtbo 0 + (dom0) xl dt-overlay remove overlay.dtbo + +The last command only removed the nodes from the Xen dtb but it did not +deassigning irq/iommus from dom0. This will result in unhandled +behavior. The correct sequence is to deassign the nodes from dom0: + + (dom0) xl dt-overlay remove overlay.dtbo 0 + + +## DomU device add/remove + +There are two modes supported for domU use cases: expert mode and normal +mode. + + +### Expert mode + +All the nodes in dtbo will be assigned to a domain; the user will need +to prepare the dtb for the domU. User will also need to modprobe the +relevant drivers. + +Example for domU device add: + + (dom0) xl dt-overlay add overlay.dtbo $domid + (dom0) xl console $domid # to access $domid console + +Next, if the user needs to modify/prepare the overlay.dtbo suitable for +the domU: + + (domU) mkdir -p /sys/kernel/config/device-tree/overlays/new_overlay + (domU) cat overlay_linux.dtbo > /sys/kernel/config/device-tree/overlays/new_overlay/dtbo + +Finally, if needed, the relevant Linux kernel drive can be probed: + + (domU) modprobe module_name.ko + +Example for domU overlay remove: + + (dom0) xl dt-overlay remove overlay.dtbo $domid + + +### Normal mode + +Libxl modifies the dtbo suitable for the domU. Currently, it does basic +modifications like updating "target-path" and "interrupt-parent" to make +them compatible with the domU device tree. Please note that this might +not work for nodes which need more complex adjustments. The user needs +to make any required changes for complex overlays and modprobe the +required Linux modules. + +For normal mode, the user is also required to input below three parameters: + +a. overlay_node: the name +b. overlay_type: whether the nodes are fpga nodes or normal nodes +c. partial or full overlay type: only needed for fpga overlays + +Example for domU overlay add: + + (dom0) xl dt-overlay add overlay.dtbo $domid overlay_node_name overlay_type is_partial + (dom0) xl console $domid # go to $domid console + (domU) ./usr/lib/xen/bin/get_overlay.sh + +Finally if needed, the relevant Linux kernel drive can be loaded: + + (domU) modprobe module_name.ko + +Example for domU overlay remove: + + (dom0) xl dt-overlay remove overlay.dtbo $domid overlay_node_name overlay_type is_partial + +The get_overlay.sh script automates the following: + +a. gets the modified overlay.dtbo from dom0 using Xenstore transactions +b. applies overlay.dtbo to the domU Linux device tree depending on what + type of overlay it is +c. removes the overlay nodes from device tree when the user requests it