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/BofFL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SKNbrsavHnopfwR09IcguRTX7t9tptbvJU8IwXTRopTydA+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);