From patchwork Mon Jul 8 11:41:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Chen, Jiqian" X-Patchwork-Id: 13726457 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 E964FC3DA47 for ; Mon, 8 Jul 2024 11:42:17 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.755306.1163660 (Exim 4.92) (envelope-from ) id 1sQmkz-0005Qk-3f; Mon, 08 Jul 2024 11:42:09 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 755306.1163660; Mon, 08 Jul 2024 11:42: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 1sQmkz-0005Qb-0J; Mon, 08 Jul 2024 11:42:09 +0000 Received: by outflank-mailman (input) for mailman id 755306; Mon, 08 Jul 2024 11:42: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 1sQmkx-00042n-R1 for xen-devel@lists.xenproject.org; Mon, 08 Jul 2024 11:42:07 +0000 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2060f.outbound.protection.outlook.com [2a01:111:f403:2009::60f]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 199b86e5-3d1f-11ef-8776-851b0ebba9a2; Mon, 08 Jul 2024 13:42:06 +0200 (CEST) Received: from BN0PR04CA0012.namprd04.prod.outlook.com (2603:10b6:408:ee::17) by IA1PR12MB6625.namprd12.prod.outlook.com (2603:10b6:208:3a3::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.35; Mon, 8 Jul 2024 11:42:01 +0000 Received: from BN1PEPF00006002.namprd05.prod.outlook.com (2603:10b6:408:ee:cafe::24) by BN0PR04CA0012.outlook.office365.com (2603:10b6:408:ee::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.36 via Frontend Transport; Mon, 8 Jul 2024 11:42:01 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by BN1PEPF00006002.mail.protection.outlook.com (10.167.243.234) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7762.17 via Frontend Transport; Mon, 8 Jul 2024 11:42:01 +0000 Received: from cjq-desktop.amd.com (10.180.168.240) 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.39; Mon, 8 Jul 2024 06:41:57 -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: 199b86e5-3d1f-11ef-8776-851b0ebba9a2 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=c4B1XBl+lTO8+doz6ICL12nryJCgEppYPLFLiMCdUcYg+i6rcH4gPLjs0bJZp83GcIywOz4QhaPS6kEtVEQ4QkNJ89Tr//6JfcaOv4ixJZekD+5YUfZo8g8qJERDgJxXQt1yTIr3wr6Jy0ipXH/WqTOkF476WBN6Rs2WGN7SAsp6k94QBWg+KQ286CXZOJCmocodO+2dbc9mv4lZ2aGvkUvtUMEN3UVv4cbuzroYo05Ga1PjWc2EzcE9VXkOkO/KOslEwDmxtq/9nVGJwgT/NSjZbPhMN29XkistEsoGnj3zxOQfSQKztwMb9JqlCzG+m37T+Z83PTF0yxcoVdsg+Q== 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=iSUMECa+KJwIDIvEDAv8tiYigyciwYLZAvCuoQwKiN4=; b=e3eWwaYEPAGOwwSvTXPPDca7MrMSEmAC9Qh7nsxHGH8Rgdq2EoBNRTeSGdn944OBrI5wwC6NIpmoO5OfI9VqFTTQGtDzzJaWHKYfHSqr7pCGSY7SmWAx9FjwM4LGZ8JlH5/n29XTA/C8k5JcZMryonTJtyI5XYKEBTAVYzJBWRU1pAjvYacLtdQl79KuZ+U7BPF6eB3XffkU+mzvQQvtsepMWSO4+omIRB81aFCrFy+TRxQS/NrbKlOzC1v/c1zsdqfxQQ/YwGxTi4uy23GJhkdLYkDm/r3Fo9+eyoVxpoYsImKba9j/cG30JNuJTZe0ndNM6MOgxNbqsjW6AthNvw== 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=iSUMECa+KJwIDIvEDAv8tiYigyciwYLZAvCuoQwKiN4=; b=3jAkEQvqG3tkxsEC210/MedWfZMJCadvdalzPK8zjNk5CdJFZJNWbU+24ajIfOnSso3fCQmVOE1sUBiKBqdUnq8rrl2rplYeMr9BresgH1LSATpdUn/mo5EzQFmpqfJyNarfzddEB+ZQcWcPud4ZzRMXgQ2WV5efmQkWiXCAHUk= 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: Jiqian Chen To: CC: Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Wei Liu , George Dunlap , Julien Grall , Stefano Stabellini , Anthony PERARD , "Juergen Gross" , "Daniel P . Smith" , Stewart Hildebrand , Jiqian Chen , Huang Rui Subject: [XEN PATCH v12 5/7] tools/libxc: Allow gsi be mapped into a free pirq Date: Mon, 8 Jul 2024 19:41:22 +0800 Message-ID: <20240708114124.407797-6-Jiqian.Chen@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240708114124.407797-1-Jiqian.Chen@amd.com> References: <20240708114124.407797-1-Jiqian.Chen@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN1PEPF00006002:EE_|IA1PR12MB6625:EE_ X-MS-Office365-Filtering-Correlation-Id: 6f27321d-6750-4afe-4137-08dc9f42fb8d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|82310400026|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: NTuSCTQpmqvM2TR0b9BM1YozPKeQPGIBcJfs1iaTVytLksCTo35odu5b1Q2/tM2Nn1hRjhWy9mUJdyr5VVAzfjmDEyAwYPeL4dcHDsdRszVN5d3CJyilOOaWLMrTMtps9yNl4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iGNPxYLCvNUEWrx4kr6RgDmC5Y+lccMRb3xipN8tFgysQJAlImD0ZoPNEnL8g/2e0pziL7Grc8XD13LF/RzokgjTYwMydAbPamAbOliKpeqAZB8UXOrUcZHQJI+lZqhWYcPpNpvj6UBWYUNn1nnLAEUxe4qnO7DiZ1vs2g6gN1YQoT76Q3/twBcZgMD5Ikz13SihDBu/0SI+hJXTqkGD3N4qpAsYwTPBK4nnyUcvpAH+XaUfv4atB7r3uAu0rzjwcaLYqqF94RSxo5bcV 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:(13230040)(376014)(7416014)(82310400026)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jul 2024 11:42:01.6139 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6f27321d-6750-4afe-4137-08dc9f42fb8d 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: BN1PEPF00006002.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6625 Hypercall PHYSDEVOP_map_pirq support to map a gsi into a specific pirq or a free pirq, it depends on the parameter pirq(>0 or <0). But in current xc_physdev_map_pirq, it set *pirq=index when parameter pirq is <0, it causes to force all cases to be mapped to a specific pirq. That has some problems, one is caller can't get a free pirq value, another is that once the pecific pirq was already mapped to other gsi, then it will fail. So, change xc_physdev_map_pirq to allow to pass negative parameter in and then get a free pirq. There are four caller of xc_physdev_map_pirq in original codes, so clarify the affect below(just need to clarify the pirq<0 case): First, pci_add_dm_done->xc_physdev_map_pirq, it pass irq to pirq parameter, if pirq<0 means irq<0, then it will fail at check "index < 0" in allocate_and_map_gsi_pirq and get EINVAL, logic is the same as original code. Second, domcreate_launch_dm->libxl__arch_domain_map_irq-> xc_physdev_map_pirq, the passed pirq is always >=0, so no affect. Third, pyxc_physdev_map_pirq->xc_physdev_map_pirq, not sure, so add the check logic into pyxc_physdev_map_pirq to keep the same behavior. Fourth, xen_pt_realize->xc_physdev_map_pirq, it wants to allocate a pirq for gsi, but it isn't necessary to get pirq whose value is equal with the value of gsi. After this patch, it will get a free pirq, and it also can work. Signed-off-by: Jiqian Chen Signed-off-by: Huang Rui Signed-off-by: Jiqian Chen --- tools/libs/ctrl/xc_physdev.c | 2 +- tools/python/xen/lowlevel/xc/xc.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/libs/ctrl/xc_physdev.c b/tools/libs/ctrl/xc_physdev.c index 460a8e779ce8..e9fcd755fa62 100644 --- a/tools/libs/ctrl/xc_physdev.c +++ b/tools/libs/ctrl/xc_physdev.c @@ -50,7 +50,7 @@ int xc_physdev_map_pirq(xc_interface *xch, map.domid = domid; map.type = MAP_PIRQ_TYPE_GSI; map.index = index; - map.pirq = *pirq < 0 ? index : *pirq; + map.pirq = *pirq; rc = do_physdev_op(xch, PHYSDEVOP_map_pirq, &map, sizeof(map)); diff --git a/tools/python/xen/lowlevel/xc/xc.c b/tools/python/xen/lowlevel/xc/xc.c index 9feb12ae2b16..f8c9db7115ee 100644 --- a/tools/python/xen/lowlevel/xc/xc.c +++ b/tools/python/xen/lowlevel/xc/xc.c @@ -774,6 +774,8 @@ static PyObject *pyxc_physdev_map_pirq(PyObject *self, if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iii", kwd_list, &dom, &index, &pirq) ) return NULL; + if ( pirq < 0 ) + pirq = index; ret = xc_physdev_map_pirq(xc->xc_handle, dom, index, &pirq); if ( ret != 0 ) return pyxc_error_to_exception(xc->xc_handle);