From nobody Fri Nov 29 16:36:01 2024 Delivered-To: importer@patchew.org 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; 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=suse.com); dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=2; a=rsa-sha256; t=1631697155; cv=pass; d=zohomail.com; s=zohoarc; b=llm9BPZ2nqOUDmxWGjSyRcBaFHtEq5Lj3cDLLUYUcM9HwOIJeTbguY2yZ+vF1iCDmPzKJLINVo4Y+3D9dTj7gcPtnXMuyyCACErllbUfGXwnZG39BnI+ZZ9tYWLbanzrqQXD6eMLlgdkN0Wr1uN8suuYpbNSOQJ+9PODRFVT6Pg= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631697155; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=V/tbiUwwg7Omg2atvKwkwb61QSkxuOMN4oMJkXQ5UrY=; b=i4ub/bjXa9n1bPG4lLHLsYBRswopb5FsINYAC6QRPndoicss2MDCeQz8QsMduG1qUn3CepLulIO21ehog/Z/H+eoajTWxGt07UIby8xgv7P0gpfuJO/fhh9FOGocgxSNO40JsvOrtFawOMejZO7Ql0Fl3Z/TbGYO6qsbnlbi4tU= 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=suse.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 1631697155907734.6889348813895; Wed, 15 Sep 2021 02:12:35 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.187373.336209 (Exim 4.92) (envelope-from ) id 1mQQxp-000852-Pd; Wed, 15 Sep 2021 09:12:21 +0000 Received: by outflank-mailman (output) from mailman id 187373.336209; Wed, 15 Sep 2021 09:12:21 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mQQxp-00084v-Mh; Wed, 15 Sep 2021 09:12:21 +0000 Received: by outflank-mailman (input) for mailman id 187373; Wed, 15 Sep 2021 09:12:20 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mQQxo-00084l-4H for xen-devel@lists.xenproject.org; Wed, 15 Sep 2021 09:12:20 +0000 Received: from de-smtp-delivery-102.mimecast.com (unknown [194.104.109.102]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 88ed0497-ce9b-4681-86e7-8b084330d285; Wed, 15 Sep 2021 09:12:19 +0000 (UTC) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2174.outbound.protection.outlook.com [104.47.17.174]) (Using TLS) by relay.mimecast.com with ESMTP id de-mta-31-PV71D0OkNracoxx4ys6C6w-1; Wed, 15 Sep 2021 11:12:17 +0200 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) by VI1PR04MB6862.eurprd04.prod.outlook.com (2603:10a6:803:130::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14; Wed, 15 Sep 2021 09:12:16 +0000 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::4d37:ec64:4e90:b16b]) by VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::4d37:ec64:4e90:b16b%7]) with mapi id 15.20.4523.014; Wed, 15 Sep 2021 09:12:16 +0000 Received: from [10.156.60.236] (37.24.206.209) by AM4PR05CA0035.eurprd05.prod.outlook.com (2603:10a6:205::48) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14 via Frontend Transport; Wed, 15 Sep 2021 09:12:16 +0000 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: 88ed0497-ce9b-4681-86e7-8b084330d285 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1631697138; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=V/tbiUwwg7Omg2atvKwkwb61QSkxuOMN4oMJkXQ5UrY=; b=AgkEgSA3u0KOLRp/wV82xAP5lKnDRHEMflkNJ/pQLF2g4IvNq6Ws+LbC2PBJSdaV+z0QQq Wj4uR7I+lOD54Pbzh4TJU1dZ2H93pwqPTOqlxgu9iZlF5+jKgeWjwTJFUH/MC/z2hnpZLm RIkZmh1WG5+tVL3SIJGT7mgcbopKX54= X-MC-Unique: PV71D0OkNracoxx4ys6C6w-1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DoxJu4O3kBhUwA1+Al1FtezdmH+x/dkBK+PxRhrJbBcEite+YB5phhidKBdz+bfTtApAZnjMnIZMuFOVuKbKXr0b18Aa/DH5sNVzvIkRm7W2njqs77OobJeGnXi3756dsrIdbdObbEjWoMxLEdn8ypSEl0KKmJfz2uPSo/aNFvMyLN2cRUB9XPFI6rcxfNKktQUVTDnscqFneO8/6XhPOtXpq7IflxYFFIXPpTEA1+InsaCbXr1WCVYZnM7L1qFarVWvEJEX60FbZ+6Xdt7h2VRN0ulcicOxAiq3rm2vmUdKvGKX/b6LhbHr/2xXFGsXEitpUFsgBRE+OeSizLVTpg== 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; bh=V/tbiUwwg7Omg2atvKwkwb61QSkxuOMN4oMJkXQ5UrY=; b=J2mI4pjQqc7dMjKuSy1Zx4GijafkfEK4O5znFMStR3qZPS8KZQJK4TzTfbKPn062R9phTgSarJngcD5YULpa9KDeGvAFmLSmgwgC9qVwJvoxgPx+0eeXm/aS87HZc6HUpeKy2i9FTizKHaww0gXcDqArdwR2xl8NQopBCyPPVr71XnPptjlZkfmOfi/sDEaFMPe+Ph3kRyEvLHNnVZ5CdE8rAiZ6MBWtUe5WqykLoS0wc8fNtBMYAzKpia3+pfj1OlNWWXrP0h/ZLIS+7ulXsBIkIrqA0kTcyz6w5JFKzqT5kath97El/O8rgFCvMLufXvviVItD7Bu4pELZ5NLG4A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none Authentication-Results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=suse.com; Subject: [PATCH 1/4] VT-d: defer "no DRHD" check when (un)mapping devices From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Paul Durrant , Kevin Tian References: <6b7fa64a-bd6b-353c-30cb-ec25b850cbed@suse.com> Message-ID: Date: Wed, 15 Sep 2021 11:12:14 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 In-Reply-To: <6b7fa64a-bd6b-353c-30cb-ec25b850cbed@suse.com> Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM4PR05CA0035.eurprd05.prod.outlook.com (2603:10a6:205::48) To VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fb7040f1-58e0-4f76-6c61-08d97828e998 X-MS-TrafficTypeDiagnostic: VI1PR04MB6862: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8wa41EkcSi/iLP6H9l0G/u6Uz5E5snSIurSnGN2FoqWNkbcI/WtQRBH2i0iWqCgSGL4QFChsNGvuHDRVx5qWrVY3gUWdJfdKkP/VwDj7yG2amRgN6IXnL4LlJtnf+Xms2yB2IjwL0uUrkQgZkcv9ZL45gvpwTa91sb2AZqauOgrBhbKy9z3bf+4yxhzHZuiRwI4LGXVCyrNJdcESpmqyPyw8gpgEM3meviYPisvWtTTDSpeISHe0os/qMgqBN+TN7tzyrCEFP6D2SVS8n8yBuPuuujMeaWfOVXIZjGNVc0M7nf6PhLG5Kb4TEav5yQzv/Gq7tRHVjyp5rOPP6+RQIpiQSSttshLPPgjz8ebmq6J0eqGIa+lD407bWRovLTSlLzRDPLM0y3vypWGCCh1SDmEvhM7+8E9GAGRQ8+l9PrJ4bqNnqa/+X0Op/fGFXvCabl30C0Ma4jYmqnmYynR5JIfQrzeBsT5mWZB3/0oKcMVEx/rJEGe128I58luJOWheJC65q4T1l7x4xyPrin7hl9/dEscZqOpZeo50an/mI6+MjxaQrEVoadgSdNH2xjfg8alKftGhWDvhsk+kh72/aAv2Wm0GLircDIsThj7HcJ2aDTTCfBqVXD2fCksNQ1JImkyVOSUmeJ178mRq7HlBcfvopfjzSVMX6mcFd6qaepEgIcLyVoX/PJnnXsWQXvvzNUOuDunfhFklB0gWCLfG70ZLbVa0JCzPRhUN7Hzx/cq6YljfchdalKJKU5OIyOhp X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5600.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(39860400002)(396003)(136003)(376002)(346002)(36756003)(956004)(2616005)(86362001)(83380400001)(8936002)(31696002)(2906002)(31686004)(66946007)(66476007)(4326008)(66556008)(26005)(5660300002)(186003)(8676002)(478600001)(6486002)(38100700002)(54906003)(16576012)(316002)(6916009)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?dFZ2N0xNVWpoMWVlcWFZeUhlWW5Xem93QjR2UzllWDcxZTQ2dUthUXYrNWNh?= =?utf-8?B?VXRicGRLVERRZUd1YUx4VWh4S3Nlb0pUckg1UEtSM3AxajFYbERYazZzWHJK?= =?utf-8?B?UElLTHQ3WGVGbWJoUHN0YXk4K3hiSmxkRHd2MjdnWmtmQThNRkw5cXcreHoz?= =?utf-8?B?MUlJdEVHeUhHM0JMakVGQ1EzSnkvVnZBQkdRQ1ZHUVN5UG4wR1o0TXBEcS9m?= =?utf-8?B?akYwN3ZBWXo0RjBUek04N09ORXkzNVcxWjJYK09qa1VnLzRyZC9MclJNVzY2?= =?utf-8?B?WXRubUxQdUQ3K1l4TUQ1eFRaUWk3TVNpcVpKTDl2Q0l0aW1uNE8zUjFCTFA3?= =?utf-8?B?OGdITVNib25leEloeS8xTjdNbWtMZ0l6Skw5Z2ltS1dTbS9DcDNYYmt4bFN2?= =?utf-8?B?UnJ3bFRzUTE5RW5HbTdndnF4U1Nmd1pWSzZ6TlpBcHJlQXJRSHRaZ1lTU2FJ?= =?utf-8?B?djR5SDByNTNpTFg5c3dLbmxkQTM1KzNzS05GNUFWSThV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VU5MlVmd2VjRi84N2RlTE45S01Qb25tdklwTmhOVmErc2VT?= =?utf-8?B?MTZ1aCtFdWVhYjB5WjFZd3V2aWR5ankvdG5LL2pNQ01zOHNCTUxwSzY0R0FF?= =?utf-8?B?bUZMU3ZyN3dPZSsyR1VneTVBSHRjbTB2SmRESWxUOC9yZUhINFdqZWljNmFC?= =?utf-8?B?SDVnWFljb0F5b0N0R2J2Ujc0cGxhMmtLY0FZVy9ERllxaWJrQmh5L0l5cmRG?= =?utf-8?B?Tld4QlZ6SzkrNGpLL3VkbGVQU1d4Y2k5RGJaMGN0Q05GQWlTY0FnaFJMU0ww?= =?utf-8?B?SXVpU3RCUm9jd2Y0QlRwTWlFWXZvTjZmd2xKdnVwOWE3N1ZNZlJyM3ZWVWZE?= =?utf-8?Q?jEYy68EGI7J04EVJU8XUJdKuq0Tmv2CbY+NmA1X?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: fb7040f1-58e0-4f76-6c61-08d97828e998 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5600.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Sep 2021 09:12:16.3550 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 2C3DQbQQUSfj381+o7dsR+d52WpPrWN89NZu0BYtO2gTmTEArHDPG9peT10NAlivFqKlTE4cQsdZwJ6/XcXw4w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB6862 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1631697185741100001 Content-Type: text/plain; charset="utf-8" If devices are to be skipped anyway (which is the case in particular for host bridges), there's no point complaining about a missing DRHD (and hence a missing association with an IOMMU). While there convert assignments to initializers and constify "drhd" local variables. Signed-off-by: Jan Beulich Reviewed-by: Kevin Tian --- a/xen/drivers/passthrough/vtd/iommu.c +++ b/xen/drivers/passthrough/vtd/iommu.c @@ -1460,14 +1460,10 @@ static int domain_context_unmap(struct d static int domain_context_mapping(struct domain *domain, u8 devfn, struct pci_dev *pdev) { - struct acpi_drhd_unit *drhd; + const struct acpi_drhd_unit *drhd =3D acpi_find_matched_drhd_unit(pdev= ); int ret =3D 0; u8 seg =3D pdev->seg, bus =3D pdev->bus, secbus; =20 - drhd =3D acpi_find_matched_drhd_unit(pdev); - if ( !drhd ) - return -ENODEV; - /* * Generally we assume only devices from one node to get assigned to a * given guest. But even if not, by replacing the prior value here we @@ -1476,7 +1472,7 @@ static int domain_context_mapping(struct * this or other devices may be penalized then, but some would also be * if we left other than NUMA_NO_NODE untouched here. */ - if ( drhd->iommu->node !=3D NUMA_NO_NODE ) + if ( drhd && drhd->iommu->node !=3D NUMA_NO_NODE ) dom_iommu(domain)->node =3D drhd->iommu->node; =20 ASSERT(pcidevs_locked()); @@ -1497,6 +1493,9 @@ static int domain_context_mapping(struct break; =20 case DEV_TYPE_PCIe_ENDPOINT: + if ( !drhd ) + return -ENODEV; + if ( iommu_debug ) printk(VTDPREFIX "%pd:PCIe: map %pp\n", domain, &PCI_SBDF3(seg, bus, devfn)); @@ -1508,6 +1507,9 @@ static int domain_context_mapping(struct break; =20 case DEV_TYPE_PCI: + if ( !drhd ) + return -ENODEV; + if ( iommu_debug ) printk(VTDPREFIX "%pd:PCI: map %pp\n", domain, &PCI_SBDF3(seg, bus, devfn)); @@ -1651,17 +1653,12 @@ int domain_context_unmap_one( static int domain_context_unmap(struct domain *domain, u8 devfn, struct pci_dev *pdev) { - struct acpi_drhd_unit *drhd; - struct vtd_iommu *iommu; + const struct acpi_drhd_unit *drhd =3D acpi_find_matched_drhd_unit(pdev= ); + struct vtd_iommu *iommu =3D drhd ? drhd->iommu : NULL; int ret; u8 seg =3D pdev->seg, bus =3D pdev->bus, tmp_bus, tmp_devfn, secbus; int found =3D 0; =20 - drhd =3D acpi_find_matched_drhd_unit(pdev); - if ( !drhd ) - return -ENODEV; - iommu =3D drhd->iommu; - switch ( pdev->type ) { case DEV_TYPE_PCI_HOST_BRIDGE: @@ -1676,6 +1673,9 @@ static int domain_context_unmap(struct d return 0; =20 case DEV_TYPE_PCIe_ENDPOINT: + if ( !iommu ) + return -ENODEV; + if ( iommu_debug ) printk(VTDPREFIX "%pd:PCIe: unmap %pp\n", domain, &PCI_SBDF3(seg, bus, devfn)); @@ -1686,6 +1686,9 @@ static int domain_context_unmap(struct d break; =20 case DEV_TYPE_PCI: + if ( !iommu ) + return -ENODEV; + if ( iommu_debug ) printk(VTDPREFIX "%pd:PCI: unmap %pp\n", domain, &PCI_SBDF3(seg, bus, devfn)); From nobody Fri Nov 29 16:36:01 2024 Delivered-To: importer@patchew.org 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; 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=suse.com); dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=2; a=rsa-sha256; t=1631697195; cv=pass; d=zohomail.com; s=zohoarc; b=Xjwy18ZZ4Byka+5R2bvMk2W9dzsSwYMwpbx9Qf0FL1bkcYfghmjm9GmI3MQlpAkMtQeT28lLuFPBOSrNJ5lQl22jBXOkqFy389+Fc1KR2D1a0ACdbLyIQwiAiP8fMP7XoKZQKCNKEjKLLvKq8DP9jFCMC2b9dI2KIQDGlgeo6gs= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631697195; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/83ivPXoMWZK0DfJ0iAElyITmi87CEwTYL/CkVUUj8s=; b=DWX3k/2O9nXZj2kV73EMsskLOlGmmgcktXOLY0NE6Kv0phjECBZne4F/1NF/ZPeI2nHil5c2xm4LSdlHg3E4ftQJT0JxgSDfMcy6RasjwwRHAyHkvv9N3BHwfQZ/2mMA9QhL3GNWjYI9AhIm1DaDTc/kMzQrZUA6qSzCVRfkaO8= 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=suse.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 16316971951061017.0269691391719; Wed, 15 Sep 2021 02:13:15 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.187381.336219 (Exim 4.92) (envelope-from ) id 1mQQyU-0000Eh-3T; Wed, 15 Sep 2021 09:13:02 +0000 Received: by outflank-mailman (output) from mailman id 187381.336219; Wed, 15 Sep 2021 09:13:02 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mQQyU-0000Ea-0N; Wed, 15 Sep 2021 09:13:02 +0000 Received: by outflank-mailman (input) for mailman id 187381; Wed, 15 Sep 2021 09:13:00 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mQQyS-0000EM-Lk for xen-devel@lists.xenproject.org; Wed, 15 Sep 2021 09:13:00 +0000 Received: from de-smtp-delivery-102.mimecast.com (unknown [194.104.111.102]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 1ed06cdc-1605-11ec-b4ec-12813bfff9fa; Wed, 15 Sep 2021 09:12:59 +0000 (UTC) Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04lp2059.outbound.protection.outlook.com [104.47.14.59]) (Using TLS) by relay.mimecast.com with ESMTP id de-mta-16-KL9Vz8YcNlqdHYbQZdp6-w-1; Wed, 15 Sep 2021 11:12:57 +0200 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) by VI1PR04MB4605.eurprd04.prod.outlook.com (2603:10a6:803:65::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.18; Wed, 15 Sep 2021 09:12:56 +0000 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::4d37:ec64:4e90:b16b]) by VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::4d37:ec64:4e90:b16b%7]) with mapi id 15.20.4523.014; Wed, 15 Sep 2021 09:12:56 +0000 Received: from [10.156.60.236] (37.24.206.209) by AM4PR05CA0009.eurprd05.prod.outlook.com (2603:10a6:205::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14 via Frontend Transport; Wed, 15 Sep 2021 09:12:55 +0000 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: 1ed06cdc-1605-11ec-b4ec-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1631697178; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/83ivPXoMWZK0DfJ0iAElyITmi87CEwTYL/CkVUUj8s=; b=Cc0S76Pgw7Xx9WhPjKbIeA/msdNf8NxNQGHTO7a11i9L8RwXMObvDT/0ztRm7/ozxrtDOb qbxUBAqCifmDTyJnDjwzzL9KCKwZzAwmVQ7Hp7QQYtsYoY+g+38XWjiBFQYMx7QcA64k9W NXMCoO2Jendr9ON3Plgn1rEqvn6VvdM= X-MC-Unique: KL9Vz8YcNlqdHYbQZdp6-w-1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fmo4aJFhHb5z7pPEqc2GAtj+S1xtd9BW2LEyOEttEoofkxpSIIKuXUmDTYdjKM6DlCt+ewJjitwqyxIBX0AZQ+kaQHWXPA3Y+bsQzg4Rk5sFfUrIESGwG8pWM1ZLgGSJy8jgsr9ho00oaApM49u1YVHVCGNMc1X8jvZPBjT0KMnUwdiU5jO60nkM/wTBqyBFGlrrvlLje4m2N5h/jUxhOYOiJ+GF54jqY9bdzn5+4uXkFVOI292bFvXazUnBGQlm6VOHkYOLzi6cBLee/Yxs9GKXIV4pa1ulVQH+HFzkE3L7pj8noWUQX6pk8GgsbxHCTfEOFISA0W6CLXxqhuyc3g== 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; bh=/83ivPXoMWZK0DfJ0iAElyITmi87CEwTYL/CkVUUj8s=; b=BcSHQKEWuqj/X9b6xvanuDEmFQkUsmYBodHk4Hh8yr3AFlFD13Cg71CGZetPVibgIPtRXCGiROsa8m7TAVG2unwu+18c/NFEc2rm3BeDwxAjMWALtfnNfyTjNKstHk/ko9kwaVLCSycyPQGGbxtR9lCNYZs+sH1r/Uo26wvgh4wsGAEinfZcrJQoKa9uBxP+GLN3gYCi1xzxDFdcE51G3JQjXwb/lhEr/UjGKu8WERPI82EFz0p4KzDdTrSiHtREZa5Da7KgrK4r7BfzzohZFGWJA7HvDHFQUVE9GO9BRWwEX3hg8sjObs4c+yV6dZyVA0xrbQ4Os9/Lzr6imWu1Vw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none Authentication-Results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=suse.com; Subject: [PATCH 2/4] VT-d: consider hidden devices when unmapping From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Paul Durrant , Kevin Tian References: <6b7fa64a-bd6b-353c-30cb-ec25b850cbed@suse.com> Message-ID: <5cf392cf-09a2-b23c-2a25-610c64f20707@suse.com> Date: Wed, 15 Sep 2021 11:12:54 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 In-Reply-To: <6b7fa64a-bd6b-353c-30cb-ec25b850cbed@suse.com> Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM4PR05CA0009.eurprd05.prod.outlook.com (2603:10a6:205::22) To VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 642123a2-c9b4-46ae-6e17-08d978290152 X-MS-TrafficTypeDiagnostic: VI1PR04MB4605: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8PCAqCp7QC3Nmn0avbgNteqcuwg/I5Oi3mqHVHYZIh24OwBgi67u0vS8fe1AFKYsG9Cm/qRAqUWGx8bkHuSmluHZRvpKJtv6iZ0n3htwamiJjKPbNUf2F29WWzqxJKHMVdkMYtPi4V90FUCuLX0LtR9KXP3LJy3ktVN3NxJkHSFIitntcWXUog2MR35cDqpmP5x9vjeO7OGjj2MMMON+Wd7qhhITuhRVjlDGR4GQccDmgnxgcQXZbBAAQpO2cP8R/EFX+gDPL6HNECJnlf360DcTr6rL+1TBx8yVw9yNsnGK/63O5tPBM1f0XZq4zpEYJrkQHwXMRpviKEsXmOL3LWMeaUfqXGGA+a89RCi/ONiPilD8SGTt7pCRCx0ycERy4mTodkGPoqovxKHSEJIaPtf7E2nWuZbh7snSkyxgo9cm2n2fMTwpNEfPbWJp4zW1JdOILUAa+qp3bLTcKi9yuyMnHuXL+nfZV5ubt8zpcWms1jmxNdgczlcKhsMb/D1XhfuAeaKmPZg8VX5VvzRyennMd3rb4u/J7ZIvzGsV5sfNh39ghStO8YhHBBfhFqdrhHXUFwDeDHWKh5vaI5Qd6rUwsxKBReHq1c+2Lkhz0l3rSbmnf2V/j//Ami4PskCFoUGSLvXxE2BUtvlua8nmOkP6QvfPBk3id3gnrFqKR3SSQLNjSPbTgucC5O4dGtBBkew9bqNYTwPOvBw0ZOPPc1D4yWguv3v1fZqie0I8N6Q= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5600.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(376002)(346002)(136003)(39860400002)(396003)(2616005)(38100700002)(5660300002)(956004)(86362001)(6486002)(478600001)(66946007)(4326008)(316002)(16576012)(6916009)(54906003)(66476007)(66556008)(31696002)(186003)(26005)(8676002)(2906002)(8936002)(36756003)(31686004)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?L29zdmU1bnpXRkkwZE00ZWoxNS9UN2FWYnJpL3VmTVhxRjBmVklqRmU0OFhF?= =?utf-8?B?Z2IvZ3JtZ2VjenZPQkNJNnJKTG4xNW9SQVVObWFFVHdnODR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9PRmtvNllSc1I0N1ptUkszcVFjVUJtSE9PZkZ2WnQvRVIzaERo?= =?utf-8?B?cFREOFV0TC9WSm1sSTNjUWxEWEV3QzhhVWdaREh3Y0I1RVM1YmprQlJ1dWlE?= =?utf-8?B?ZWtmRXpHakhmV1lyWkQrODIwRE4vOGVxYWhCejJSM1owRFlYbFVONUtVL28w?= =?utf-8?B?Tlc4ZEJtSVNpLzRpVXBpUXAzSlNnYk1UYkExa0JmQW5aSjE0dlh2SWlZYmdG?= =?utf-8?B?SFdZV3dTWjBZd05qS09LMHEvRkdPQ2VnU1hGei9NWlpDbnNQWk54T3liQWlk?= =?utf-8?B?ajVWWXZZK1grTE1lWXFCMThqeURicThMS1VYWUg4VzV5VmVObG1VSG95RnFq?= =?utf-8?B?b2d3MFYvMjNxd0lNT0tvMjFwVUFrZFlCWXFwV0ZSdlZwRlY4aXR3WDhqUTVo?= =?utf-8?B?WnJJbmtmc1hWamduUlNROTZENTV2TzE4ZU5kZVlEYVNyWVdMa3RCaVZoSHBZ?= =?utf-8?B?N1FUSnUvK2hsNE44NmI2cDU4LzBFOVgvMTQwUU8zTmFkbTI2a0Z1UmxMME8x?= =?utf-8?B?dkxqUnVuMFZXbFpSSzVzU2xsUkpUT0wrbklYV3lwZVdIUjZBZTl2cnkzYzE5?= =?utf-8?B?dXViL2prejVwdGw0T05TQytBSDV1S1lBUzlPV2RuZC9nVmRia3E3WDNFVm1I?= =?utf-8?B?UXV6bkhHMVV0dEFQYzRYS2Zka1QzUFRuaURPa29sZFZxNU4zWE83YTVheURU?= =?utf-8?B?cFk0dGYwSGMyYVZqTFJ4dHlRMjU3SUh6YmVqQU1DbHgyMEhUb2R1elZTZG1y?= =?utf-8?Q?xhsmtLPiCL3N1nmIB6wjIPadBfuAJL8ogfBrFj9?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 642123a2-c9b4-46ae-6e17-08d978290152 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5600.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Sep 2021 09:12:56.1517 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: eZ6/Of8FrrXKMK2D3Sd0BBq9yCilaEf2KewdtyO7iSh17n6kJ1v2pJFvEjPJWEAAm9TBOm1i3gRktrbHfERjyQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4605 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1631697206334100001 Content-Type: text/plain; charset="utf-8" Whether to clear an IOMMU's bit in the domain's bitmap should depend on all devices the domain can control. For the hardware domain this includes hidden devices, which are associated with DomXEN. While touching related logic, convert "found" to "bool". Signed-off-by: Jan Beulich --- a/xen/drivers/passthrough/vtd/iommu.c +++ b/xen/drivers/passthrough/vtd/iommu.c @@ -1657,7 +1657,7 @@ static int domain_context_unmap(struct d struct vtd_iommu *iommu =3D drhd ? drhd->iommu : NULL; int ret; u8 seg =3D pdev->seg, bus =3D pdev->bus, tmp_bus, tmp_devfn, secbus; - int found =3D 0; + bool found; =20 switch ( pdev->type ) { @@ -1737,23 +1737,33 @@ static int domain_context_unmap(struct d return ret; =20 /* - * if no other devices under the same iommu owned by this domain, - * clear iommu in iommu_bitmap and clear domain_id in domid_bitmp + * If no other devices under the same iommu owned by this domain, + * clear iommu in iommu_bitmap and clear domain_id in domid_bitmap. */ - for_each_pdev ( domain, pdev ) + for ( found =3D false; ; domain =3D dom_xen ) { - if ( pdev->seg =3D=3D seg && pdev->bus =3D=3D bus && pdev->devfn = =3D=3D devfn ) - continue; - - drhd =3D acpi_find_matched_drhd_unit(pdev); - if ( drhd && drhd->iommu =3D=3D iommu ) + for_each_pdev ( domain, pdev ) { - found =3D 1; - break; + if ( pdev->seg =3D=3D seg && pdev->bus =3D=3D bus && pdev->dev= fn =3D=3D devfn ) + continue; + + drhd =3D acpi_find_matched_drhd_unit(pdev); + if ( drhd && drhd->iommu =3D=3D iommu ) + { + found =3D true; + break; + } } + + /* + * Hidden devices are associated with DomXEN but usable by the + * hardware domain. Hence they need considering here as well. + */ + if ( found || !is_hardware_domain(domain) ) + break; } =20 - if ( found =3D=3D 0 ) + if ( !found ) { clear_bit(iommu->index, &dom_iommu(domain)->arch.vtd.iommu_bitmap); cleanup_domid_map(domain, iommu); From nobody Fri Nov 29 16:36:01 2024 Delivered-To: importer@patchew.org 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; 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=suse.com); dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=2; a=rsa-sha256; t=1631697222; cv=pass; d=zohomail.com; s=zohoarc; b=XLkKHM383LxdzhL3m8enKwGkkEs03Jp2mb1oYoAnSpY7OWhqUbrdJTP5xp5qGwbPMwtLD8qFZvtUnM38Yp8VAc/0SeO5/Pg1yedBGKF0qZ+T5d+aLwngWdiJrkdV1hpUYoy6M6nMpiYeigI48yvMarWdCQdz1SqRqod0/ocYU3E= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631697222; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=32ebYhQya8W1RrUzbbQIk60a77c15WTRh4/23DDxt8s=; b=P1d1QJRVO9O2bF7DhAMSSQ4/axAMNoV5ujhCkiKG/2E1XvmYaNUwFNWD9VWndRarRvJy+kzC/6aId/tTbZNuHKnu9qzpDKJj62DNClCL6h3kfYxF8bIrQNgkS7+CHiDtkgIFWU2OFpx3bu9OoelYDwSb7YK1RYD6xM0JGKtFjjw= 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=suse.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 1631697222312272.2434762169846; Wed, 15 Sep 2021 02:13:42 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.187389.336231 (Exim 4.92) (envelope-from ) id 1mQQyu-0000t6-FU; Wed, 15 Sep 2021 09:13:28 +0000 Received: by outflank-mailman (output) from mailman id 187389.336231; Wed, 15 Sep 2021 09:13:28 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mQQyu-0000sz-CR; Wed, 15 Sep 2021 09:13:28 +0000 Received: by outflank-mailman (input) for mailman id 187389; Wed, 15 Sep 2021 09:13:27 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mQQyt-0000is-5r for xen-devel@lists.xenproject.org; Wed, 15 Sep 2021 09:13:27 +0000 Received: from de-smtp-delivery-102.mimecast.com (unknown [194.104.111.102]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 2b7fb60e-1605-11ec-b4ec-12813bfff9fa; Wed, 15 Sep 2021 09:13:21 +0000 (UTC) Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04lp2055.outbound.protection.outlook.com [104.47.14.55]) (Using TLS) by relay.mimecast.com with ESMTP id de-mta-32-v3woC4z0MwWLON-TAE0nyA-1; Wed, 15 Sep 2021 11:13:19 +0200 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) by VI1PR04MB4605.eurprd04.prod.outlook.com (2603:10a6:803:65::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.18; Wed, 15 Sep 2021 09:13:18 +0000 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::4d37:ec64:4e90:b16b]) by VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::4d37:ec64:4e90:b16b%7]) with mapi id 15.20.4523.014; Wed, 15 Sep 2021 09:13:18 +0000 Received: from [10.156.60.236] (37.24.206.209) by AM3PR05CA0147.eurprd05.prod.outlook.com (2603:10a6:207:3::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14 via Frontend Transport; Wed, 15 Sep 2021 09:13:17 +0000 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: 2b7fb60e-1605-11ec-b4ec-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1631697200; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=32ebYhQya8W1RrUzbbQIk60a77c15WTRh4/23DDxt8s=; b=GEfoYrpzH6+wUCKjZaLEnGB/YHaK4jHBzfiovhP4TfWQbysmSfZficSntMm4aQEM4XJKKO aHd+mcOJ41EdGVoGkFYKnSaQbQ5BFOdcsFnAWy/Y3wYNQ726309+Wpa1Yb3mc3V38965J6 gnK6hO+uqJ/kUIfG6lxz/6fqq+CELpY= X-MC-Unique: v3woC4z0MwWLON-TAE0nyA-1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GwRwISbZXLP3toO46IJntMnZTALYvIh2Nj/kLOpH1vKwiqSmrh3NQJonKMwv4QTmJEucidi7aaKQqFlKC7n2adKKQVWLpsW0Y8a4/AhQEtXmBEcMk656rcRKvnvj48F/LBqWI6XLJpk/GVQS5Eyqj2rgizBhyE1o/v9ezqqqKzdIgpu6H4HjCodNdChcWrkyo9oAKylKRo5x6CHEyItfcFKOF7RLR0ZrjjYxzlAsYIxEHkSndiqlsb84FzbASCp9ABL2NeQOTTdHWnQUk7+F1Y6qFdS/noupRXjaHGR8PLZejkZIto1lASP4sfJKGP2cIchQuiWuPZBBSTJ737YVag== 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; bh=32ebYhQya8W1RrUzbbQIk60a77c15WTRh4/23DDxt8s=; b=TJORSQ5y9HVkQeOC/H0aqi91f4KSXzWYzac5VRxRMDr/8J53fJwg+nJp8qwinmlt5m0W241SyYpo5F4qFn1HMpY6bxzq8ULOtNRiHJJSQqbYY9Ba662zYaa+dK0ZbEy+38s/H+Z/LWdkfdICjMjldSPH21t8ebrtiEcIS2zPHRP1SN6di7gcUeOK1r40AQOKuNgs7n3qezb9210s7OO94cN34qCxdF4t7TV3VUkotCO8pTCY3saO7eXqZRmShKNtm4/Hcnyq0vxguUIb4OXZSTJ5348ndN2EoixrFzOTGDx6YC9bxBdcul3+CyFDk3Tz8CeRIOXlEfP6Hw2eS5lF4g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none Authentication-Results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=suse.com; Subject: [PATCH 3/4] VT-d: skip IOMMU bitmap cleanup for phantom devices From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Paul Durrant , Kevin Tian References: <6b7fa64a-bd6b-353c-30cb-ec25b850cbed@suse.com> Message-ID: <57c75e32-df31-c886-b2b2-86d0f82a57d0@suse.com> Date: Wed, 15 Sep 2021 11:13:16 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 In-Reply-To: <6b7fa64a-bd6b-353c-30cb-ec25b850cbed@suse.com> Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM3PR05CA0147.eurprd05.prod.outlook.com (2603:10a6:207:3::25) To VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a1cf6ae7-7974-45dd-ea38-08d978290e66 X-MS-TrafficTypeDiagnostic: VI1PR04MB4605: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UcUyzyXHSPmodqNl3UsUYxFvt4tIaT11ttbfrzxQS4tdgIIFaK8HCsy60MX/UAEFCrwz4C7PEqJQQjD2BQ3XfwEOIFw8rleTLtZjfABusPXvcSmnzM1xfQKAzDU14/wllmhkYqU2rtONV9D1/fR8bmKDK59aX3eyQ8RPZTXP0z/ZXsfJavh6HLpx+IvM9tIq54djPbREzlKCAMqagv6B4VXlOGddrQ44cstZUy4Xrwakp7kadVN2vxz1DG2cbaS60ucOSMRrRmVoTYSbvBTfxfLK0ChkMJBVA4AkRMhlcBuesC/RiiEK8qy78Fg60yjfU6Y9NUdcR84dB8sgO/4jZOQ1MajonIt6uPwDgoSI5AKkU/4WchOCv7SBlAPt0J967rIZ4LIyL4mIzu4PthyqAhOsBwASa2zLBcw8E9sfgCFzl0oVAzhyNXzxXeiYqIbF+FySm8LXo42xmT/GIpDB8SSFXU2sbfu6qd5sZTt2vHXgIjsgIid3tRhpr9GjrfQZKHYYkKa4xKUM0O3H9n3xNVaYwPtawDWVPa8eo/uB11ggz+nFKEN+balQCzr3gChMBFNWfwhdFz0PXgWGUKchJMfQ++zvLwBx5m7J4QOI+FQXzSi+YnIf2maKXfd35Sv4vJQUWC74VLTQRTF90E0wxnnxF96CJa8KzAJIxNTtGF6y29i3PYv4LepMvIMUqHCErHrwdQIDDg+NWpU5EyMnnFNz0tfH60h3TaGI3BYH52M= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5600.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(376002)(346002)(136003)(39860400002)(396003)(2616005)(38100700002)(5660300002)(956004)(86362001)(6486002)(478600001)(66946007)(4326008)(316002)(16576012)(6916009)(54906003)(66476007)(66556008)(31696002)(186003)(26005)(8676002)(4744005)(2906002)(8936002)(36756003)(31686004)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?UU4wc2hpT1pyT29STnp2bndUTm9iT0g0SFJGZmoxTGFNWDF3ZzdyZFN6OVNV?= =?utf-8?B?dFA4MCt1bGh5alBxY3dMY1IxNjVXYXFFUFRFUmhPakhxRURuTkRsalp0TE5B?= =?utf-8?B?Mjl2bXZxcGRrR2N5aHNpSmYxeWE5SDFaWmVQR1ovVDgxbmFyMWFvZkxKR052?= =?utf-8?B?MmpoMXlZM2pjR3FKTTNISi9vbUdzRDR1Y0F3elZLNWxtbUpkd24rODAzZHZl?= =?utf-8?B?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0U3lZNllZL1BDV0trMWVjeENi?= =?utf-8?B?c1pLZ1FUUWxLRGN3VUFJUGlSeWplT0VHWTVoaVdVcGwzZXUwdUhOL09pczVV?= =?utf-8?B?QzQrajREOEtGR2piUkpTRmc4Um5DdXM5ek5kVFR4L1dQNC9zNlB4WVhNckxm?= =?utf-8?B?Ui9zMzZjVUE4VFFkUDBQYU03alRjcVZnZTVwdGx1RHJDTUhLclFGU0lVRWl3?= =?utf-8?B?b3RUdFZiQmZYUk51S2YyTHVSZWhzNllHR1NYZGJac1ZpaTZaazUwZm1tS3dV?= =?utf-8?B?UHBKSkZDQ1FkMmpTM2l6c2NwK0dBKyt1Y3JqczRUNURhU08rSDRMMHFrTlIv?= =?utf-8?B?Qko0TWRzZHNaLzVid2JMNG9EVlRJNDc5ZENOSG5RQmlkM2ZMWjNITlppY2dn?= =?utf-8?B?ZFNXazR5TzNvYmloRVFmc2tZT1BSZW55NkpzSGNpMUxXMGhubjZXaVJqZGFW?= =?utf-8?B?V1IwWHRvTzJacUd6Mkt6L0dHazZyejZvQjlzL0dkcUwwdURBKzIrZlZmUDJ1?= =?utf-8?B?UzJNdG9pcEl0VGpIZVVQQXE3UG4weU5UTVpOQ0xncDNIZEh2b0lhaWlVdzBT?= =?utf-8?B?cGRXTnNud2M0VHZubHhZYWcxSyt3TUJxTkVHZlR2K0R6SVMyVDE4QlBOMjRY?= =?utf-8?Q?qeCV2/ADKOEVhDXR/GrKYkasJ1NdKzZjYlceDb9?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: a1cf6ae7-7974-45dd-ea38-08d978290e66 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5600.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Sep 2021 09:13:18.0783 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: UKtU3fci0huM32s8PK1/Er8KbcFWG+KyjxkpT3Qo5rSorEgdBFwf4v1xfamLYCyllnDTSNCLx9GaNhZCv2nMmQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4605 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1631697224064100001 Content-Type: text/plain; charset="utf-8" Doing the cleanup also for phantom devices is at best redundant with doing it for the corresponding real device. I couldn't force myself into checking all the code paths whether it really is: It seems better to explicitly skip this step in such cases. Signed-off-by: Jan Beulich Reviewed-by: Kevin Tian --- a/xen/drivers/passthrough/vtd/iommu.c +++ b/xen/drivers/passthrough/vtd/iommu.c @@ -1733,7 +1733,7 @@ static int domain_context_unmap(struct d return -EINVAL; } =20 - if ( ret || QUARANTINE_SKIP(domain) ) + if ( ret || QUARANTINE_SKIP(domain) || pdev->devfn !=3D devfn ) return ret; =20 /* From nobody Fri Nov 29 16:36:01 2024 Delivered-To: importer@patchew.org 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; 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=suse.com); dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=2; a=rsa-sha256; t=1631697251; cv=pass; d=zohomail.com; s=zohoarc; b=UT1VuvIfl41jjkTkXLtnFqXzpCEFfaY8Gtlj+dANCl7TDPOaekZanSZb1Z981JOy5yDK9ypnu0rmq/dZiwkg24zNGFwPOTvhEkoEaYnwQ5+yFybYoexJHeKp5dabZRXdaY2hyAltkdNqFqRy0yWswqfZOjiQM+z3m7w7g8jB9LQ= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631697251; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=TPv3uK8bqSIgwLCsg7oLnpJv0fedDK5iubeaeJBmDWs=; b=oFjcHVwMfNi0Yz2qSCC4GOnl8sWpCIzOtOBtsXb/vOiSHDOtXYSfpXl7pcQpLwDTWKFUp7k7jXwHfCBxxpzzkbjHPGk8mpPShNXbaZTaBHfnKHCYh6Ek3F3UGEkchU+27guOYXnXH6QmokirvUKAEsiTFBjBEn8L9PnC/2oMhPc= 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=suse.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 1631697251773641.5966127893396; Wed, 15 Sep 2021 02:14:11 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.187397.336242 (Exim 4.92) (envelope-from ) id 1mQQzM-0001U2-Of; Wed, 15 Sep 2021 09:13:56 +0000 Received: by outflank-mailman (output) from mailman id 187397.336242; Wed, 15 Sep 2021 09:13:56 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mQQzM-0001Tv-La; Wed, 15 Sep 2021 09:13:56 +0000 Received: by outflank-mailman (input) for mailman id 187397; Wed, 15 Sep 2021 09:13:55 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mQQzL-0001Tf-AZ for xen-devel@lists.xenproject.org; Wed, 15 Sep 2021 09:13:55 +0000 Received: from de-smtp-delivery-102.mimecast.com (unknown [194.104.111.102]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 7117321c-b748-403b-98c6-112c689792df; Wed, 15 Sep 2021 09:13:54 +0000 (UTC) Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-db5eur03lp2057.outbound.protection.outlook.com [104.47.10.57]) (Using TLS) by relay.mimecast.com with ESMTP id de-mta-26-bNj072P4M025VJlUB7dzEw-1; Wed, 15 Sep 2021 11:13:52 +0200 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) by VE1PR04MB7375.eurprd04.prod.outlook.com (2603:10a6:800:1a8::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.16; Wed, 15 Sep 2021 09:13:50 +0000 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::4d37:ec64:4e90:b16b]) by VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::4d37:ec64:4e90:b16b%7]) with mapi id 15.20.4523.014; Wed, 15 Sep 2021 09:13:50 +0000 Received: from [10.156.60.236] (37.24.206.209) by AM4PR0202CA0008.eurprd02.prod.outlook.com (2603:10a6:200:89::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14 via Frontend Transport; Wed, 15 Sep 2021 09:13:50 +0000 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: 7117321c-b748-403b-98c6-112c689792df DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1631697233; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TPv3uK8bqSIgwLCsg7oLnpJv0fedDK5iubeaeJBmDWs=; b=apgQ/xiIRJ0zyjt+w3QK2sdsw5TXBCosQ/8YFdcvXDK85xuvpsEBCgAyj5pkU+3B4tEWb9 B+/ncF/fpl+t4gPBTAcH9yRYO3SFhlaD+JuUoZ3goeIl85SCfdjazXBiLmW8oGGPc0yPoX Qvr17P+ZHAQiKvG1lgpWcKnGfhYC2kQ= X-MC-Unique: bNj072P4M025VJlUB7dzEw-1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bCG3KgvFWoKRGLk0vzMIsx6uAGdCo0wHOGocck3QvFHmCkhNtZ7zCYwaXl2K6J8Jw06UrtvJF0tYoAEmv7vsvy5JgUERf/2+h7hKRbXX7b05fXqSnMV+vopRi6YTADfBbKZ7haX1YMPywPLNOgXOPeJKcrr5qgHmc1ZhCqjZATXQwh2J7GNuaX8+V39w+qVNRynAA0XWePZXpZLB10lX4z79wcwlLjKQmlYoOS/founwdUk39HG4rYqbPLIfaoXV/bPtKRcZrrhas53iFtx3ZWYlKQ6yI1ZdMYdUUxMLWpmZ8FyQbP4o5AyejB0m9uc7dIIAkMJ+h3CyRXHcUlUPOg== 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; bh=TPv3uK8bqSIgwLCsg7oLnpJv0fedDK5iubeaeJBmDWs=; b=O3qt+/t6uVIQEydyIxxfTrz6Cc3rbvFgfDVJTbiFGxL1eKfkgsqy5bX+smjlsq4fUunGKtSoFG5M24yqZOoRPtYknB8ZJ4C6VyHza2tUcq1hVQcrrEsmT21G3ukj2VafqDIpSMVF/G3yOCPBgLDt8MNW+OnSF4QeMTgGLQZmGct8f57kyC/RW5hRdMUgx84TGnE2KNaqOjp+iIOsGGM3h3Clen0MMuHRjGL77+qFInmuScXEfKpiXqPvePA0G8DupMzqK38GASZSDUelItBwOihUZ22lZ1j70xUHrbfQ1gPSpupI7fCG3Gsvycv2DX1k8AZlE6uZ+MZoKEY+PRfdhA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none Authentication-Results: citrix.com; dkim=none (message not signed) header.d=none;citrix.com; dmarc=none action=none header.from=suse.com; Subject: [PATCH 4/4] AMD/IOMMU: consider hidden devices when flushing device I/O TLBs From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Paul Durrant , Andrew Cooper References: <6b7fa64a-bd6b-353c-30cb-ec25b850cbed@suse.com> Message-ID: Date: Wed, 15 Sep 2021 11:13:49 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 In-Reply-To: <6b7fa64a-bd6b-353c-30cb-ec25b850cbed@suse.com> Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM4PR0202CA0008.eurprd02.prod.outlook.com (2603:10a6:200:89::18) To VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 32bb6961-04e3-4b0e-7339-08d9782921a9 X-MS-TrafficTypeDiagnostic: VE1PR04MB7375: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DhtTAYESLKi3B+4UjjZ38SYd9YqjPIDhybF4lJHfWEq3bZmkcvioP22GQYzIZYkBgrolpfYOqtohmh8JYEv7ogwsQXdM0NdBBeijGDRBJnT6xq/pbbqzQIeDkELZf8u08XY0wTt2I1P76AXambUHr4EFuIno3haQrcQcou8hPrk0d/uox38zSt+/29TWCLw9Y4XlCXTgLT/X1w2KCeL/PyfmnySMc0y+O3GOS4+U7luLxudHZi3slhJ1oNDRxaOFhjmxhIGr6tyUAAhzeD9dtUk78gVFgfHVn3tFm/sKkUPLk/pcYtdJI6Bv/P3LvrisJGVgtlLqLcJ5GNoR1GhJ7cK1hsurKNirqkUBdv0w+h9O3bvm0Xs5CF/Ws+dgFSaTBlok/6C0efspCR5IGGET7qAJjvprWM60lVHDHhyIyT9kuUM8codxs6UZh2xBMa9BDE0o+FKsbXbhbmGoGwpgZT/NNLS4M0fu1Ri91Hg9gfXKDUhWXFaAV+/fMDbMMxgT2aYzt5UA/8n0eaeIf4xt36jt812Y9RmMdcERGi/R8mTyFeAs3bACXbYpqNVAegrDOmjVq0HBwEGtDbY4a19pUPe9Eb61pSCPnTYwsnCI/mIQDfOf7ofheFp2nVc6F+7XaGdM92L+uOrspEp/fZn2Lk82GZlNvZfuHJBsCufR5elWr05fLLCtMCLOhoN4DXMNSn0mn20ZnRE276u9uFLNtwgyWrFte3J7r0sHZAdoEJY= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5600.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(39860400002)(396003)(366004)(136003)(376002)(346002)(38100700002)(2616005)(26005)(54906003)(83380400001)(5660300002)(4326008)(8936002)(316002)(6916009)(31686004)(16576012)(8676002)(66946007)(6486002)(86362001)(31696002)(66476007)(66556008)(2906002)(956004)(186003)(36756003)(478600001)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?RUtBRXJzeWhFZUptZGQrQktScHZ1VjYvMlYrdTZyY2FISDBCZHZwRzlqaHNW?= =?utf-8?B?VUhka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9782921a9 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5600.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Sep 2021 09:13:50.3950 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: b1SoOOnzcswpQT+qOlCAapvNcGZ6v6sDofaCXqgnEZaa745w7ejKn69l0zmZPF6axcy1bqMS7/9e/4zgVJdaPg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB7375 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1631697252706100001 Content-Type: text/plain; charset="utf-8" Hidden devices are associated with DomXEN but usable by the hardware domain. Hence they need flushing as well when all devices are to have flushes invoked. While there drop a redundant ATS-enabled check and constify the first parameter of the involved function. Signed-off-by: Jan Beulich --- a/xen/drivers/passthrough/amd/iommu_cmd.c +++ b/xen/drivers/passthrough/amd/iommu_cmd.c @@ -308,14 +308,11 @@ void amd_iommu_flush_iotlb(u8 devfn, con flush_command_buffer(iommu, iommu_dev_iotlb_timeout); } =20 -static void amd_iommu_flush_all_iotlbs(struct domain *d, daddr_t daddr, +static void amd_iommu_flush_all_iotlbs(const struct domain *d, daddr_t dad= dr, unsigned int order) { struct pci_dev *pdev; =20 - if ( !ats_enabled ) - return; - for_each_pdev( d, pdev ) { u8 devfn =3D pdev->devfn; @@ -343,7 +340,16 @@ static void _amd_iommu_flush_pages(struc } =20 if ( ats_enabled ) + { amd_iommu_flush_all_iotlbs(d, daddr, order); + + /* + * Hidden devices are associated with DomXEN but usable by the + * hardware domain. Hence they need dealing with here as well. + */ + if ( is_hardware_domain(d) ) + amd_iommu_flush_all_iotlbs(dom_xen, daddr, order); + } } =20 void amd_iommu_flush_all_pages(struct domain *d)