From nobody Sun Dec 14 12:35:38 2025 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=1765512467; cv=pass; d=zohomail.com; s=zohoarc; b=Q6GniFy41DM1AqK1kjRxvnGzJ4T9E8GpcLmCmd5VC9iGG0rIlnnHq+XSZ4u2lnziVxnlVmVU6gd91cGh8+qhRbJfO/zIIZVY+ckpNglVEWaV5BrKLka6/MGUkRSrB9uf2YLSx0ZaN2KsIlGt2PVCg6t8EaZk4QcRGZTF/kK52PQ= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1765512467; 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=xmIanaYhA7lDAz9D81o3iTrsQ8uyDXNxse6wMqaVzko=; b=RsowClr9QCmhC/JEWjsnSRJBkmwcQxWT0xDyteYkvNzT5zW02OzA4MFkaM/Ok6r/oEPEeXTvuQh+0MqYu6KPfChzb5CRjHfYfatnby0EzJll8soL5LxtEvUnR3EvzHqHUfQINgMii70RershLbgSB20WsVuMGjH8p7jiYonhLwI= 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 1765512467563607.1081661468921; Thu, 11 Dec 2025 20:07:47 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1184955.1507322 (Exim 4.92) (envelope-from ) id 1vTuRC-0005Ai-9i; Fri, 12 Dec 2025 04:07:26 +0000 Received: by outflank-mailman (output) from mailman id 1184955.1507322; Fri, 12 Dec 2025 04:07:26 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vTuRC-00059Q-36; Fri, 12 Dec 2025 04:07:26 +0000 Received: by outflank-mailman (input) for mailman id 1184955; Fri, 12 Dec 2025 04:07:24 +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 1vTuR1-0007SS-S2 for xen-devel@lists.xenproject.org; Fri, 12 Dec 2025 04:07:15 +0000 Received: from CH1PR05CU001.outbound.protection.outlook.com (mail-northcentralusazlp170100001.outbound.protection.outlook.com [2a01:111:f403:c105::1]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 09083059-d710-11f0-9cce-f158ae23cfc8; Fri, 12 Dec 2025 05:07:12 +0100 (CET) Received: from BL6PEPF00013DF6.NAMP222.PROD.OUTLOOK.COM (2603:10b6:22e:400:0:1001:0:a) by SN7PR12MB8817.namprd12.prod.outlook.com (2603:10b6:806:347::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9412.8; Fri, 12 Dec 2025 04:07:05 +0000 Received: from BL02EPF0002992D.namprd02.prod.outlook.com (2a01:111:f403:f901::7) by BL6PEPF00013DF6.outlook.office365.com (2603:1036:903:4::4) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9412.9 via Frontend Transport; Fri, 12 Dec 2025 04:07:05 +0000 Received: from satlexmb07.amd.com (165.204.84.17) by BL02EPF0002992D.mail.protection.outlook.com (10.167.249.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9412.4 via Frontend Transport; Fri, 12 Dec 2025 04:07:05 +0000 Received: from penny-System-Product-Name.amd.com (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.17; Thu, 11 Dec 2025 22:07:02 -0600 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: 09083059-d710-11f0-9cce-f158ae23cfc8 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=cSwyoK6vazECKfMyXZQGuDC8+bn0B4xzcPRjoXZfQw9L3nOZToKxM7KXmpuLC9bCHE6QqWDk1+NKScTXoAKPiWqgQdm8P1pnsaPoiFjcQIoK7c1f5do0AXKa3VQfqrPHGMeS2AxSOXTbEwKBFrHrzWI5Il4khX+VAXE5dGgfZJ8xyB3BgCmpoVOhzD98mmBTnE/DvzgDZKejs35i7hQHDFeKVzB/EnfU1vDg6iQBcbfpRBeClSjNWy1KIddBvx340ycqWnqGltj3Byuiql0DMgjIIjSE+yM4LxPINcHIk127wm2m5unOksbX2IfhSaomYEuGgvW+cSxfo0Bh7EsHSw== 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=xmIanaYhA7lDAz9D81o3iTrsQ8uyDXNxse6wMqaVzko=; b=o+bWDfhxjXEqIHWbMahNQ7M9b6CLibDZZ5zI0gO3k80JsKmHzQ+kVxyJM1Bua7VVjn74apTBzUUsC+KDC9G11FsGMqTAMWeDNrwvypd/PZyszJk56POBu4mW24D6SXhPZwDL4VRFUvk01VixBfndse6SsQl78Ijzh5MYWFXmXv78uFHTnMNCyb2/aVvwR6UIykg+fqSbPbrAkQZTooMOMuzpM9q/baym8pTpxDiA5Pza464RW6pl7GwxD9+TubuvlaXUhWQD9KP/WXk6Q9EJNB8hlmHn51xUWIK9kNi/C2AtAwpq8uoPzbBP+e5xo5UJqouUpIOCFd6RX9rErvOlrQ== 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=xmIanaYhA7lDAz9D81o3iTrsQ8uyDXNxse6wMqaVzko=; b=Dvv5OaP55+WM7ZMnpMz6QgFeXM5xnVnh9Vg6BgM5CUps8KNdj5NTwqUSC2cQgwbV6Pb8ZcmFvN+08B6iq3K400B5DnkHXBci6r+oJqqxmFSf9kdcb8133faWdiEDJqMvVysGRBdyyf7cmLryF3ykzxWXUwkghZbjB6KWqa4EIW0= 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=satlexmb07.amd.com; pr=C From: Penny Zheng To: CC: , , Penny Zheng , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Jason Andryuk , "Daniel P. Smith" Subject: [PATCH v5 15/24] xen/domctl: wrap pci-subset iommu-related domctl op with CONFIG_MGMT_HYPERCALLS Date: Fri, 12 Dec 2025 12:02:00 +0800 Message-ID: <20251212040209.1970553-16-Penny.Zheng@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251212040209.1970553-1-Penny.Zheng@amd.com> References: <20251212040209.1970553-1-Penny.Zheng@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0002992D:EE_|SN7PR12MB8817:EE_ X-MS-Office365-Filtering-Correlation-Id: e734c53d-e29d-4e7a-cd37-08de3933e947 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|376014|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?/uQVslx0txzvGNuWuq0JWftz3WmeCtox+1jBeK384hLA+smeI4SABYyAc9PE?= =?us-ascii?Q?YHLnv1MkDYfxGz+WF81ADQD1qTEO5Zmj4dhT9K04H91PalkM2KXX/u9DHCMC?= =?us-ascii?Q?LgIBZ8q9OWEIDjuGUqghoElbYJv20MmfBP+ZADaWCbd9zcdvkKfYnJgaZixM?= =?us-ascii?Q?J6N2QaY4KlO+xnorkRzQ4uutUIHPn0fA0pYTSrRR1ORjViqFqH/r7Uunv4H2?= =?us-ascii?Q?eY9nsywhmxFOa4aOcXKP/d1QlQNCzIAlN/h5yO8qMJm8iKo/ngTOeotfiZX0?= =?us-ascii?Q?TVnaKKwsQ5p8IHUGlPlVueL92iBgOE1oF3eu38METRuTKOZ/6AJAN5VbNBBf?= =?us-ascii?Q?TXWMzoCZBflcye0WWsKf+Gdkrp5iopCXyF4u5Bde79fkBQ92hJZHh0oSZVIe?= =?us-ascii?Q?3ogQbC5zxmqUWGQbvF5oGUTzQWUg5NAZXQ9xVW+OfCt38zRjBkBWwYNhEgU8?= =?us-ascii?Q?tLMbRWVW9ILHvk91UlhBR4JV+kgfF9SEaOciPMKe5zGV/ZQhKvykYXl6GPSh?= =?us-ascii?Q?6PxgG0FfXUGMOiL/Qfu0Jwh+vJpTKQ5NWLE01klO1kOmM6XQNrs7p1R+ZTqf?= =?us-ascii?Q?hU2Ja+BMcEgaYe3tALxXF/i9ze8+TnqmqOraMhR0vJKJToGNCzVIMIj4j1hf?= =?us-ascii?Q?AfmkDdI0eGzsYZIKkwdjzQnpliI7kom56qETgZP6D6ctdakWgiuarsHEy1wf?= =?us-ascii?Q?EcYz4ts2wu2t0tvcvCeTLIGKLvXEF/zrAEDfud5HzkOwoSlYJEn4xoHGgXjO?= =?us-ascii?Q?EGrmJ0XEAffAlGH2c18SWtHLkLsAJczUvj0bxwShV1udqpSBv3wL42loMau7?= =?us-ascii?Q?y9+W71o5Exa5yhY4AHGyhCeFB5+ahQVmbUcRUy71n3myte2VqR4eQ8KIlgnj?= =?us-ascii?Q?iztcbQAK1fMLwoZSx/q0PP1iPZyCkCwfqGLk0WW8BZO0wOo9hPpPkW/k0fE/?= =?us-ascii?Q?khh/NcJ7n0SiWZnsi5K/M5REVX9FmCCcNIbCkv51043PKfnpvVlg4WYgescY?= =?us-ascii?Q?P4pBj8m2P2shNxqANdZ4SbT0g4EGp/1OGVZsggf+/yQ5amX/FEkRI7TM7Vx0?= =?us-ascii?Q?953VWwwBvWsSXLORLL8CYXlUmErfO9TnS/gXqCPfS7WeJvKUXeCsNaIXTAwm?= =?us-ascii?Q?8BUpQWof0Y7h/na3sxzbeJxEaJIXtWW7WwRkJA0cKA1cgO/n4z6rDxaUFtir?= =?us-ascii?Q?lrF3Nkm3WW20gIWGTcxontNQxHw77IAHntTsKKj7HWRVMLXEPa+IaSNyHF6+?= =?us-ascii?Q?tCYRWtdtNliwdMOleNmz4qA74TAF8TfUgPkWf3wv4mHLxYl64z66wlMzamhp?= =?us-ascii?Q?oiOT0lB87WrwtRFd0AY0+UQc1wR7oRm93atAw7i4IIrCD0F71POt9IM+8LTu?= =?us-ascii?Q?zZWv9P5Qj8g/ygBXQASwkcHk4G8AvN7R/nmat/mIijRrw0hZB2E4Tvz/xudg?= =?us-ascii?Q?WM1DXKOQq/K4+v2V9N6qUvldf/SVmGeyuJpnfZbazmcLTn10cjBGB2B8S6TT?= =?us-ascii?Q?2Qn4/IvwuAWCi3bBn/bKt8iwquJfyh66xM4/LXBwYsBGEVwSfeyP5zfqrlit?= =?us-ascii?Q?yK2WpBaVvS5cEzrfVrM=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(82310400026)(376014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Dec 2025 04:07:05.2674 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e734c53d-e29d-4e7a-cd37-08de3933e947 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=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL02EPF0002992D.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB8817 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1765512468300158500 Content-Type: text/plain; charset="utf-8" Function iommu_do_pci_domctl() is the main entry for pci-subset iommu-related domctl-op, and shall be wrapped with CONFIG_MGMT_HYPERCALLS. Tracking its calling chain, the following functions shall all be wrapped with CONFIG_MGMT_HYPERCALLS: - iommu_do_pci_domctl - iommu_get_device_group - xsm_get_device_group - iommu_ops.get_device_group_id - amd_iommu_group_id/intel_iommu_group_id - device_assigned - xsm_assign_device - assign_device - iommu_ops.assign_device - intel_iommu_assign_device/amd_iommu_assign_device - xsm_deassign_device - deassign_device - iommu_ops.reassign_device - reassign_device_ownership/reassign_device Otherwise all the functions will become unreachable when MGMT_HYPERCALLS=3D= n, and hence violating Misra rule 2.1 The PCI-part in ARM, (regarding codes under HAS_PCI), will be taken care of later when guarding PCI_PASSTHROUGH with MGMT_HYPERCALLS, as the Kconfig select chain in ARM is as follows: HAS_VPCI_GUEST_SUPPORT if PCI_PASSTHROUGH -> HAS_VPCI -> HAS_PCI So making PCI_PASSTHROUGH depend on MGMT_HYPERCALLS will recursively leading HAS_PCI depend on MGMT_HYPERCALLS too in ARM. Signed-off-by: Penny Zheng --- v1 -> v2: - adapt to changes of "unify DOMCTL to MGMT_HYPERCALLS" - wrap XEN_DOMCTL_assign_device{test_assign_device,deassign_device, get_device_group}-case transiently --- v2 -> v3: - make PCI_PASSTHROUGH(, then HAS_VPCI_GUEST_SUPPORT) depend on MGMT_HYPERC= ALLS - add wrapping for iommu_remove_dt_device/iommu_dt_device_is_assigned_locke= d/ arm_smmu_detach_dev/arm_smmu_domain_remove_master - fold commit "xen/xsm: wrap xsm-iommu-related functions with CONFIG_MGMT_HYPERCALLS" in - fix overly long #ifdef - add missing wrapping in xsm/dummy.h - address "violating Misra rule 2.1" in commit message - remove transient wrapping of XEN_DOMCTL_assign_device{test_assign_device,deassign_device,get_device_grou= p}-case --- v3 -> v4: - move codes to wrap with a single #ifdef - split into PCI related subset and DT subset --- v4 -> v5: - Hook .get_device_group_id should be properly dealt with in xen/iommu.h right away - Add description for how PCI-part will be dealt in ARM --- xen/drivers/passthrough/amd/pci_amd_iommu.c | 20 ++++---- xen/drivers/passthrough/pci.c | 52 +++++++++++---------- xen/drivers/passthrough/vtd/iommu.c | 6 ++- xen/include/xen/iommu.h | 2 + xen/include/xsm/dummy.h | 6 ++- xen/include/xsm/xsm.h | 12 +++-- xen/xsm/dummy.c | 6 ++- xen/xsm/flask/hooks.c | 12 +++-- 8 files changed, 70 insertions(+), 46 deletions(-) diff --git a/xen/drivers/passthrough/amd/pci_amd_iommu.c b/xen/drivers/pass= through/amd/pci_amd_iommu.c index 3a14770855..576b36af92 100644 --- a/xen/drivers/passthrough/amd/pci_amd_iommu.c +++ b/xen/drivers/passthrough/amd/pci_amd_iommu.c @@ -461,6 +461,7 @@ static void amd_iommu_disable_domain_device(const struc= t domain *domain, spin_unlock_irqrestore(&iommu->lock, flags); } =20 +#ifdef CONFIG_MGMT_HYPERCALLS static int cf_check reassign_device( struct domain *source, struct domain *target, u8 devfn, struct pci_dev *pdev) @@ -551,6 +552,14 @@ static int cf_check amd_iommu_assign_device( return rc; } =20 +static int cf_check amd_iommu_group_id(u16 seg, u8 bus, u8 devfn) +{ + unsigned int bdf =3D PCI_BDF(bus, devfn); + + return (bdf < ivrs_bdf_entries) ? get_dma_requestor_id(seg, bdf) : bdf; +} +#endif /* CONFIG_MGMT_HYPERCALLS */ + static void cf_check amd_iommu_clear_root_pgtable(struct domain *d) { struct domain_iommu *hd =3D dom_iommu(d); @@ -698,13 +707,6 @@ static int cf_check amd_iommu_remove_device(u8 devfn, = struct pci_dev *pdev) return 0; } =20 -static int cf_check amd_iommu_group_id(u16 seg, u8 bus, u8 devfn) -{ - unsigned int bdf =3D PCI_BDF(bus, devfn); - - return (bdf < ivrs_bdf_entries) ? get_dma_requestor_id(seg, bdf) : bdf; -} - #include =20 static void amd_dump_page_table_level(struct page_info *pg, int level, @@ -772,14 +774,16 @@ static const struct iommu_ops __initconst_cf_clobber = _iommu_ops =3D { .quarantine_init =3D amd_iommu_quarantine_init, .add_device =3D amd_iommu_add_device, .remove_device =3D amd_iommu_remove_device, - .assign_device =3D amd_iommu_assign_device, .teardown =3D amd_iommu_domain_destroy, .clear_root_pgtable =3D amd_iommu_clear_root_pgtable, .map_page =3D amd_iommu_map_page, .unmap_page =3D amd_iommu_unmap_page, .iotlb_flush =3D amd_iommu_flush_iotlb_pages, +#ifdef CONFIG_MGMT_HYPERCALLS + .assign_device =3D amd_iommu_assign_device, .reassign_device =3D reassign_device, .get_device_group_id =3D amd_iommu_group_id, +#endif .enable_x2apic =3D iov_enable_xt, .update_ire_from_apic =3D amd_iommu_ioapic_update_ire, .update_ire_from_msi =3D amd_iommu_msi_msg_update_ire, diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c index 422e45f5a6..8ab229bfe7 100644 --- a/xen/drivers/passthrough/pci.c +++ b/xen/drivers/passthrough/pci.c @@ -878,6 +878,7 @@ int pci_remove_device(u16 seg, u8 bus, u8 devfn) return ret; } =20 +#ifdef CONFIG_MGMT_HYPERCALLS /* Caller should hold the pcidevs_lock */ static int deassign_device(struct domain *d, uint16_t seg, uint8_t bus, uint8_t devfn) @@ -946,7 +947,6 @@ static int deassign_device(struct domain *d, uint16_t s= eg, uint8_t bus, return ret; } =20 -#ifdef CONFIG_MGMT_HYPERCALLS int pci_release_devices(struct domain *d) { int combined_ret; @@ -1484,6 +1484,7 @@ static int iommu_remove_device(struct pci_dev *pdev) return iommu_call(hd->platform_ops, remove_device, devfn, pci_to_dev(p= dev)); } =20 +#ifdef CONFIG_MGMT_HYPERCALLS static int device_assigned(u16 seg, u8 bus, u8 devfn) { struct pci_dev *pdev; @@ -1648,30 +1649,6 @@ static int iommu_get_device_group( return i; } =20 -void iommu_dev_iotlb_flush_timeout(struct domain *d, struct pci_dev *pdev) -{ - pcidevs_lock(); - - disable_ats_device(pdev); - - ASSERT(pdev->domain); - if ( d !=3D pdev->domain ) - { - pcidevs_unlock(); - return; - } - - pdev->broken =3D true; - - if ( !d->is_shutting_down && printk_ratelimit() ) - printk(XENLOG_ERR "dom%d: ATS device %pp flush failed\n", - d->domain_id, &pdev->sbdf); - if ( !is_hardware_domain(d) ) - domain_crash(d); - - pcidevs_unlock(); -} - int iommu_do_pci_domctl( struct xen_domctl *domctl, struct domain *d, XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl) @@ -1805,6 +1782,31 @@ int iommu_do_pci_domctl( =20 return ret; } +#endif /* CONFIG_MGMT_HYPERCALLS */ + +void iommu_dev_iotlb_flush_timeout(struct domain *d, struct pci_dev *pdev) +{ + pcidevs_lock(); + + disable_ats_device(pdev); + + ASSERT(pdev->domain); + if ( d !=3D pdev->domain ) + { + pcidevs_unlock(); + return; + } + + pdev->broken =3D true; + + if ( !d->is_shutting_down && printk_ratelimit() ) + printk(XENLOG_ERR "dom%d: ATS device %pp flush failed\n", + d->domain_id, &pdev->sbdf); + if ( !is_hardware_domain(d) ) + domain_crash(d); + + pcidevs_unlock(); +} =20 struct segment_iter { int (*handler)(struct pci_dev *pdev, void *arg); diff --git a/xen/drivers/passthrough/vtd/iommu.c b/xen/drivers/passthrough/= vtd/iommu.c index 90f36ac22b..ad2e657bca 100644 --- a/xen/drivers/passthrough/vtd/iommu.c +++ b/xen/drivers/passthrough/vtd/iommu.c @@ -2742,6 +2742,7 @@ static int __init cf_check vtd_setup(void) return ret; } =20 +#ifdef CONFIG_MGMT_HYPERCALLS static int cf_check reassign_device_ownership( struct domain *source, struct domain *target, @@ -2937,6 +2938,7 @@ static int cf_check intel_iommu_group_id(u16 seg, u8 = bus, u8 devfn) =20 return PCI_BDF(bus, devfn); } +#endif /* CONFIG_MGMT_HYPERCALLS */ =20 static int __must_check cf_check vtd_suspend(void) { @@ -3245,14 +3247,16 @@ static const struct iommu_ops __initconst_cf_clobbe= r vtd_ops =3D { .add_device =3D intel_iommu_add_device, .enable_device =3D intel_iommu_enable_device, .remove_device =3D intel_iommu_remove_device, - .assign_device =3D intel_iommu_assign_device, .teardown =3D iommu_domain_teardown, .clear_root_pgtable =3D iommu_clear_root_pgtable, .map_page =3D intel_iommu_map_page, .unmap_page =3D intel_iommu_unmap_page, .lookup_page =3D intel_iommu_lookup_page, +#ifdef CONFIG_MGMT_HYPERCALLS + .assign_device =3D intel_iommu_assign_device, .reassign_device =3D reassign_device_ownership, .get_device_group_id =3D intel_iommu_group_id, +#endif .enable_x2apic =3D intel_iommu_enable_eim, .disable_x2apic =3D intel_iommu_disable_eim, .update_ire_from_apic =3D io_apic_write_remap_rte, diff --git a/xen/include/xen/iommu.h b/xen/include/xen/iommu.h index 37c4a1dc82..6ca4190eb9 100644 --- a/xen/include/xen/iommu.h +++ b/xen/include/xen/iommu.h @@ -333,9 +333,11 @@ struct iommu_ops { uint32_t flag); int (*reassign_device)(struct domain *s, struct domain *t, uint8_t devfn, device_t *dev); +#ifdef CONFIG_MGMT_HYPERCALLS #ifdef CONFIG_HAS_PCI int (*get_device_group_id)(uint16_t seg, uint8_t bus, uint8_t devfn); #endif /* HAS_PCI */ +#endif /* MGMT_HYPERCALLS */ =20 void (*teardown)(struct domain *d); =20 diff --git a/xen/include/xsm/dummy.h b/xen/include/xsm/dummy.h index 92291ac9e5..07d69e3725 100644 --- a/xen/include/xsm/dummy.h +++ b/xen/include/xsm/dummy.h @@ -407,7 +407,8 @@ static XSM_INLINE int cf_check xsm_get_vnumainfo( return xsm_default_action(action, current->domain, d); } =20 -#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_PCI) +#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_MGMT_HYPERCALLS) +#ifdef CONFIG_HAS_PCI static XSM_INLINE int cf_check xsm_get_device_group( XSM_DEFAULT_ARG uint32_t machine_bdf) { @@ -429,7 +430,8 @@ static XSM_INLINE int cf_check xsm_deassign_device( return xsm_default_action(action, current->domain, d); } =20 -#endif /* HAS_PASSTHROUGH && HAS_PCI */ +#endif /* CONFIG_HAS_PCI */ +#endif /* HAS_PASSTHROUGH && MGMT_HYPERCALLS */ =20 #if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_DEVICE_TREE_DISC= OVERY) static XSM_INLINE int cf_check xsm_assign_dtdevice( diff --git a/xen/include/xsm/xsm.h b/xen/include/xsm/xsm.h index b76eb22429..b331e81f9d 100644 --- a/xen/include/xsm/xsm.h +++ b/xen/include/xsm/xsm.h @@ -125,11 +125,13 @@ struct xsm_ops { int (*pci_config_permission)(struct domain *d, uint32_t machine_bdf, uint16_t start, uint16_t end, uint8_t acc= ess); =20 -#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_PCI) +#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_MGMT_HYPERCALLS) +#ifdef CONFIG_HAS_PCI int (*get_device_group)(uint32_t machine_bdf); int (*assign_device)(struct domain *d, uint32_t machine_bdf); int (*deassign_device)(struct domain *d, uint32_t machine_bdf); -#endif +#endif /* CONFIG_HAS_PCI */ +#endif /* HAS_PASSTHROUGH && MGMT_HYPERCALLS */ =20 #if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_DEVICE_TREE_DISC= OVERY) int (*assign_dtdevice)(struct domain *d, const char *dtpath); @@ -532,7 +534,8 @@ static inline int xsm_pci_config_permission( return alternative_call(xsm_ops.pci_config_permission, d, machine_bdf,= start, end, access); } =20 -#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_PCI) +#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_MGMT_HYPERCALLS) +#ifdef CONFIG_HAS_PCI static inline int xsm_get_device_group(xsm_default_t def, uint32_t machine= _bdf) { return alternative_call(xsm_ops.get_device_group, machine_bdf); @@ -549,7 +552,8 @@ static inline int xsm_deassign_device( { return alternative_call(xsm_ops.deassign_device, d, machine_bdf); } -#endif /* HAS_PASSTHROUGH && HAS_PCI) */ +#endif /* CONFIG_HAS_PCI */ +#endif /* HAS_PASSTHROUGH && MGMT_HYPERCALLS */ =20 #if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_DEVICE_TREE_DISC= OVERY) static inline int xsm_assign_dtdevice( diff --git a/xen/xsm/dummy.c b/xen/xsm/dummy.c index f6986dd2bb..c693e77a7d 100644 --- a/xen/xsm/dummy.c +++ b/xen/xsm/dummy.c @@ -81,11 +81,13 @@ static const struct xsm_ops __initconst_cf_clobber dumm= y_ops =3D { .pci_config_permission =3D xsm_pci_config_permission, .get_vnumainfo =3D xsm_get_vnumainfo, =20 -#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_PCI) +#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_MGMT_HYPERCALLS) +#ifdef CONFIG_HAS_PCI .get_device_group =3D xsm_get_device_group, .assign_device =3D xsm_assign_device, .deassign_device =3D xsm_deassign_device, -#endif +#endif /* CONFIG_HAS_PCI */ +#endif /* HAS_PASSTHROUGH && MGMT_HYPERCALLS */ =20 #if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_DEVICE_TREE_DISC= OVERY) .assign_dtdevice =3D xsm_assign_dtdevice, diff --git a/xen/xsm/flask/hooks.c b/xen/xsm/flask/hooks.c index 9c1298697c..c772f79e16 100644 --- a/xen/xsm/flask/hooks.c +++ b/xen/xsm/flask/hooks.c @@ -1388,7 +1388,8 @@ static int cf_check flask_mem_sharing(struct domain *= d) } #endif =20 -#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_PCI) +#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_MGMT_HYPERCALLS) +#ifdef CONFIG_HAS_PCI static int cf_check flask_get_device_group(uint32_t machine_bdf) { uint32_t rsid; @@ -1459,7 +1460,8 @@ static int cf_check flask_deassign_device( =20 return avc_current_has_perm(rsid, SECCLASS_RESOURCE, RESOURCE__REMOVE_= DEVICE, NULL); } -#endif /* HAS_PASSTHROUGH && HAS_PCI */ +#endif /* CONFIG_HAS_PCI */ +#endif /* HAS_PASSTHROUGH && MGMT_HYPERCALLS */ =20 #if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_DEVICE_TREE_DISC= OVERY) static int flask_test_assign_dtdevice(const char *dtpath) @@ -1988,11 +1990,13 @@ static const struct xsm_ops __initconst_cf_clobber = flask_ops =3D { .remove_from_physmap =3D flask_remove_from_physmap, .map_gmfn_foreign =3D flask_map_gmfn_foreign, =20 -#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_PCI) +#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_MGMT_HYPERCALLS) +#ifdef CONFIG_HAS_PCI .get_device_group =3D flask_get_device_group, .assign_device =3D flask_assign_device, .deassign_device =3D flask_deassign_device, -#endif +#endif /* CONFIG_HAS_PCI */ +#endif /* HAS_PASSTHROUGH && MGMT_HYPERCALLS */ =20 #if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_DEVICE_TREE_DISC= OVERY) .assign_dtdevice =3D flask_assign_dtdevice, --=20 2.34.1