From nobody Fri Nov 22 03:20:32 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1723806558; cv=pass; d=zohomail.com; s=zohoarc; b=Pqdf8b41H3WJLfnW8BN6kPa5ChtFHkOAEGistcNxURppz2E0v5F8oktpR3ZnnEzikdJ5baw98sc17Ag6yvfOWpPqnC0GYpRtN2KQqYxyQHpkZBXScc9dkiWlafR/ItG9yto+leboq/P9N9kc3wkXEYvVPjuvJNPvT4MID7Ye81U= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1723806558; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=QEmijQKrvaaonY0ryNFeoICShxLiMC7FhSWe8KUC0mg=; b=H0cSs3ZFFDOQUcvQ6bddgqh3OwoG3oBJ8OX0B0kdZktn2maW8o5dGIJ0Sg+hPiJAD0FqaUpZpimqUy/f7wHjPCJyWyqOwJyzRWmJFwam1SxAeZckZEz6HEn9ooYBdyXiEMNhi0H3S1Xpcm/+1PWtneAFnHL5paxzKRuUlIj0cAY= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1723806558531861.4525175893148; Fri, 16 Aug 2024 04:09:18 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.778490.1188552 (Exim 4.92) (envelope-from ) id 1seupG-0002WG-CJ; Fri, 16 Aug 2024 11:08:58 +0000 Received: by outflank-mailman (output) from mailman id 778490.1188552; Fri, 16 Aug 2024 11:08:58 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1seupG-0002W3-97; Fri, 16 Aug 2024 11:08:58 +0000 Received: by outflank-mailman (input) for mailman id 778490; Fri, 16 Aug 2024 11:08:57 +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 1seupF-0001Oc-92 for xen-devel@lists.xenproject.org; Fri, 16 Aug 2024 11:08:57 +0000 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on20610.outbound.protection.outlook.com [2a01:111:f403:200a::610]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id ec9afd98-5bbf-11ef-8776-851b0ebba9a2; Fri, 16 Aug 2024 13:08:55 +0200 (CEST) Received: from BN9P221CA0005.NAMP221.PROD.OUTLOOK.COM (2603:10b6:408:10a::28) by CYYPR12MB8750.namprd12.prod.outlook.com (2603:10b6:930:be::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.20; Fri, 16 Aug 2024 11:08:49 +0000 Received: from BN3PEPF0000B069.namprd21.prod.outlook.com (2603:10b6:408:10a:cafe::4a) by BN9P221CA0005.outlook.office365.com (2603:10b6:408:10a::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.23 via Frontend Transport; Fri, 16 Aug 2024 11:08:49 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by BN3PEPF0000B069.mail.protection.outlook.com (10.167.243.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7897.4 via Frontend Transport; Fri, 16 Aug 2024 11:08:48 +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; Fri, 16 Aug 2024 06:08:44 -0500 X-Outflank-Mailman: Message body and most headers restored to incoming version 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: ec9afd98-5bbf-11ef-8776-851b0ebba9a2 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Fp/dq7IrhwiDsx/qUTdgRxH4Nqmdm8q/w5WTnN+n3sJgQw95LC9Y25ZkDZ6gH3TgGTUtCXmgVZkqw82lCA6EaGrYMJCnQzELO0njQxFVmP1hK+nM4ydLmvR6Vi/ay1kh596EcfLZOSUiCz7u0riQZq5O34SDdiR4rOA41HvWE4PZDRKUoXNS2HpOxsEnb8muf8aIZR3fk+oFrPX0IRplUTDIXDesDteY4i6+2C6mGuGMxf5M7olfTq8j6t+2tjLomNyyvEwfoJS/UfQ2wkFVTAeAIARKnhZFQ3dPd0qKfvHXCz2hLrEEIOEAcauGe0dsXOo9FjNC8jajCwMt0mJGcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=QEmijQKrvaaonY0ryNFeoICShxLiMC7FhSWe8KUC0mg=; b=VPcTrTBgQ2G+7E0KiDIhL2kIfTx+0L7KW4snaC5FYsLhMsEF8ioJ5NahXjktUkefZlo0Mej1wgg96FUjIPoo9gGqp3ZHsXPcomGxfzj9PfFnIiM9XwMHNixvAfQSaJfQl9Y8X/hi11GU87NXUS/uv4RPjFt3xW2vAGxcxpL7vonLTKRZQaEubBHr8ljHztsuicsGCv7vrdd0/i+AfNUj+/MaMdo+u0PXeFFaGdkvufOtYf3OZzxPQM7QtMhO2MBEtNScd5J9OXZ6LX1NTajQbi9ljXM6LIf/QHbTYRF8//4bzFHj56+MzlvlBvAaT1D76nNcACWfPrKLr3i+iLRv5w== 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=QEmijQKrvaaonY0ryNFeoICShxLiMC7FhSWe8KUC0mg=; b=zeNgXRolwhjky5XuvT27UfM8gPkhwPgxHlJDW1CT0K8DKO43/zCcl26/lcHq1xehdhc5avKkEWPQkgX3Kg2wRHcnivwCW+dpduEb8C6SsEOvp7z8fYvtTK+fLspfpIrGlhDG4OoDhsJakBojUfY8x5NGgcPbKNX51xVebesDVk4= 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 (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; 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=20Pau=20Monn=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 v13 3/6] x86/pvh: Add PHYSDEVOP_setup_gsi for PVH dom0 Date: Fri, 16 Aug 2024 19:08:17 +0800 Message-ID: <20240816110820.75672-4-Jiqian.Chen@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240816110820.75672-1-Jiqian.Chen@amd.com> References: <20240816110820.75672-1-Jiqian.Chen@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: BN3PEPF0000B069:EE_|CYYPR12MB8750:EE_ X-MS-Office365-Filtering-Correlation-Id: 91041b6b-1b0e-4d14-68d8-08dcbde3cd64 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|1800799024|7416014|376014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?wL+0lLg6AKsqXM1d+3yJcRlTxYamDeEiureb6JxOJTEtELTaMrOudw5NOunJ?= =?us-ascii?Q?5gcs5iimbCrovCEGXjm7+6RKLpBcgA2HLUDDNnATASs3ADN80zEykhVimZXy?= =?us-ascii?Q?xNTZZ1jAqZ+KIekExBaDF+WeHXVfXQ2BE/DDahmaNaFkI3bFCBNyEsGQbrRZ?= =?us-ascii?Q?/Ki2BRY2Lcu0pi2KrcYUlE/yU4cy6c3bbbyY0EpFAMP+mzZg5qcW8FXFXqH0?= =?us-ascii?Q?zYx0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5ZX606?= =?us-ascii?Q?FmZZf8UHzVEjk+LER1p/5Emug5RE4KoYOD4hAbSrpg0eb9AennGPulN/5XPr?= =?us-ascii?Q?cQK0w2M3v259jKBjH4dyfM3SZPb6KRlVZIgN2ttpk2CYa3W5b1YTj+Qv3WLs?= =?us-ascii?Q?FINxustum0pmApA5gQs10OKsCgAQYhxPeapZwGxrpnwhFCFX7pkJtq0sF8a+?= =?us-ascii?Q?JSsLIe06SrJ7yy3yyT2BnondfMhXw/9T63yNDyrK/uFDCeAeslLO4HjwLFFC?= =?us-ascii?Q?P0psOzY50FgD7C6bPr3Nfw8eT5whPIa4tM22054BXg3Gqc64NQ=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(36860700013)(1800799024)(7416014)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Aug 2024 11:08:48.0122 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 91041b6b-1b0e-4d14-68d8-08dcbde3cd64 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: BN3PEPF0000B069.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYYPR12MB8750 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1723806559517116600 Content-Type: text/plain; charset="utf-8" The gsi of a passthrough device must be configured for it to be able to be mapped into a hvm domU. But When dom0 is PVH, the gsis may not get registered(see below clarification), it causes the info of apic, pin and irq not be added into irq_2_pin list, and the handler of irq_desc is not set, then when passthrough a device, setting ioapic affinity and vector will fail. To fix above problem, on Linux kernel side, a new code will need to call PHYSDEVOP_setup_gsi for passthrough devices to register gsi when dom0 is PVH. So, add PHYSDEVOP_setup_gsi into hvm_physdev_op for above purpose. Clarify two questions: First, why the gsi of devices belong to PVH dom0 can work? Because when probe a driver to a normal device, it uses the normal probe function of pci device, in its callstack, it requests irq and unmask corresponding ioapic of gsi, then trap into xen and register gsi finally. Callstack is(on linux kernel side) pci_device_probe-> request_threaded_irq-> irq_startup-> __unmask_ioapic-> io_apic_write, then trap into xen hvmemul_do_io-> hvm_io_intercept-> hvm_process_io_intercept-> vioapic_write_indirect-> vioapic_hwdom_map_gsi-> mp_register_gsi. So that the gsi can be registered. Second, why the gsi of passthrough device can't work when dom0 is PVH? Because when assign a device to passthrough, it uses the specific probe function of pciback, in its callstack, it doesn't install a fake irq handler due to the ISR is not running. So that mp_register_gsi on Xen side is never called, then the gsi is not registered. Callstack is(on linux kernel side) pcistub_probe->pcistub_seize-> pcistub_init_device-> xen_pcibk_reset_device-> xen_pcibk_control_isr->isr_on=3D=3D0. Signed-off-by: Jiqian Chen Signed-off-by: Huang Rui Signed-off-by: Jiqian Chen Acked-by: Jan Beulich --- xen/arch/x86/hvm/hypercall.c | 1 + 1 file changed, 1 insertion(+) diff --git a/xen/arch/x86/hvm/hypercall.c b/xen/arch/x86/hvm/hypercall.c index 0b7fc060b4e2..81883c8d4f60 100644 --- a/xen/arch/x86/hvm/hypercall.c +++ b/xen/arch/x86/hvm/hypercall.c @@ -82,6 +82,7 @@ long hvm_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void)= arg) return -ENOSYS; break; =20 + case PHYSDEVOP_setup_gsi: case PHYSDEVOP_pci_mmcfg_reserved: case PHYSDEVOP_pci_device_add: case PHYSDEVOP_pci_device_remove: --=20 2.34.1