From patchwork Wed Aug 31 14:10:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Volodymyr Babchuk X-Patchwork-Id: 12960754 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 D0C76ECAAD1 for ; Wed, 31 Aug 2022 14:11:32 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.395684.635511 (Exim 4.92) (envelope-from ) id 1oTOR2-0003Mm-Ad; Wed, 31 Aug 2022 14:11:16 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 395684.635511; Wed, 31 Aug 2022 14:11:16 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oTOR2-0003Ls-79; Wed, 31 Aug 2022 14:11:16 +0000 Received: by outflank-mailman (input) for mailman id 395684; Wed, 31 Aug 2022 14:11:14 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oTOR0-0002bv-22 for xen-devel@lists.xenproject.org; Wed, 31 Aug 2022 14:11:14 +0000 Received: from mx0a-0039f301.pphosted.com (mx0a-0039f301.pphosted.com [148.163.133.242]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id c45f90ea-2936-11ed-934f-f50d60e1c1bd; Wed, 31 Aug 2022 16:11:12 +0200 (CEST) Received: from pps.filterd (m0174676.ppops.net [127.0.0.1]) by mx0a-0039f301.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 27VBpHD9027047; Wed, 31 Aug 2022 14:11:06 GMT Received: from eur03-ve1-obe.outbound.protection.outlook.com (mail-ve1eur03lp2050.outbound.protection.outlook.com [104.47.9.50]) by mx0a-0039f301.pphosted.com (PPS) with ESMTPS id 3j9huk4eny-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 31 Aug 2022 14:11:06 +0000 Received: from VI1PR03MB3710.eurprd03.prod.outlook.com (2603:10a6:803:31::18) by VI1PR03MB6301.eurprd03.prod.outlook.com (2603:10a6:800:133::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.10; Wed, 31 Aug 2022 14:10:59 +0000 Received: from VI1PR03MB3710.eurprd03.prod.outlook.com ([fe80::9190:c0a7:bd87:f01f]) by VI1PR03MB3710.eurprd03.prod.outlook.com ([fe80::9190:c0a7:bd87:f01f%6]) with mapi id 15.20.5566.019; Wed, 31 Aug 2022 14:10:59 +0000 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: c45f90ea-2936-11ed-934f-f50d60e1c1bd ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bdBMyeS2bf4dH2whMLT+e6ha5bob7QDdy73srMvsV96EzFJY7BPQu3nmJHxRlu/KbyfMn0usSNSG5J0labn/nn1QvZiRLi1ZtaQCQvGE2ra7A0ASI+uoWiH90Fpz3D3lB0TTzxXbQlYBHSH2bq4z4WoEB3YslP9/SANgUB/U2i8xZh18g7PYX9o3VNIRFBbidYUeR2BZHrLcmhsYhvAU2GGahmMNCS+Nkd6QiPS1VhzfuKBYu7Vso+ga1reWlYaX00wJ6B9dXBbGv8nwmULaO6ulEhGYil02K1uCnmD+ISm1+CwUtjlQoHJbY9aTLWGHpLgO34eKr/tShh29m8FLIg== 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=HNHHS4bFB++CGi9rIFiohdrogbiukdzlPrd3LW3sk80=; b=nJaFxHWaZKU7a6IZsKviC84uLMAx8hm5IHwF8IKuoTDBpMYn2+43eqmtJtQ1KzHzqGrNt6DoP7FndkTS3brv4GlvH94Csbj0qH9O7QQ1cfauVuAvJrzMtqGZhnCmkZ2ZvjyXiwTmUD4Txtyudp2snEibnLmO65QupJ1g0avu2mHvHICEsNzVzNvx4SbzC2kx+0WB9eMc2i0u0a3+CEFxCho17qOBWul7eZNFbDVx0j4UX8LaD8eUodr4nxXUEce7wdE2eZv+NdvMcc/5qpswt3tuoh6DnmAuId1KhqvNZ2327woPgG/5b3Trl7TSRTKOUdpTsB6Z0Y3jGamNTlI3Cg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=epam.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HNHHS4bFB++CGi9rIFiohdrogbiukdzlPrd3LW3sk80=; b=l465qaLkIisF9FEXx3dQZMv8eaar7UBwty0sr4KZKF0Ldab0x0/J9l2qGqLRxjPJIu1CUNA3Xum+HmOdfHb7gsPoonZ35vMO9dcKARf0Np74xnfdGShwQSwbMl0XJ0slFhGxDyyQLiIJLge/c9V/BbISUjmReTORMNOa4XgTqZSLP10dTs/oCqFc16xWTnVAm6J8gDGwLJcAEC0uC6HIne9v5/h9Ne3GNS047mrTHLcC6nI2UwrfxCEo9OuK3zoSrNOfAFrUJpJ5KnqXd9+kdD0QsOk8WfjfBo9S+LvTELkvUDU4C9PMpmQiecJs0C69yGSaOOZi6o5Yj7ZHq+wZ0A== From: Volodymyr Babchuk To: "xen-devel@lists.xenproject.org" CC: Oleksandr Andrushchenko , Volodymyr Babchuk , Jan Beulich , Andrew Cooper , Paul Durrant , =?iso-8859-1?q?Roger_Pau_Monn=E9?= , Kevin Tian Subject: [RFC PATCH 03/10] xen: pci: introduce ats_list_lock Thread-Topic: [RFC PATCH 03/10] xen: pci: introduce ats_list_lock Thread-Index: AQHYvUN+A/bxwqt+90CvUR3e9vnmcA== Date: Wed, 31 Aug 2022 14:10:59 +0000 Message-ID: <20220831141040.13231-4-volodymyr_babchuk@epam.com> References: <20220831141040.13231-1-volodymyr_babchuk@epam.com> In-Reply-To: <20220831141040.13231-1-volodymyr_babchuk@epam.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.37.1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 4470ba1a-1e34-4fc9-d11d-08da8b5aa144 x-ms-traffictypediagnostic: VI1PR03MB6301:EE_ x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: QrEARB3ZrAuRvKT4Hde50oCdoWy9MwJlcb2SEbvL/yTmub1XIoSCNkYC0jgibufZQlVgbHqei+cL+VWCOeJEmrsIJFqv21+HCrtWODfMEz8bFZWPmwLb8OHrOeFMLhNDPPq14wZMRiJ2PKGxHdwd10NmTS0kTRn0DZ584Po9hM1XHp+nqOrYmGQNghG5qgAZf+Q2WX6bUR6E+/k14RTwcJxsuH2pdylCadYDMXszVrc79IJAdSlgoGeqdFkormGl0rX30/fyxKulMkjsA2Aam6dgdSHMms4iKynb+mdZJXt/vKcqaerueg+8RvC2GYUKpTFzOv1Cce+YEk+aKp/hYp3JUF2PR1dfuIYUu8bXmfW7+t1/zCRBQs7bBeg+hRDNuYfcvzBimO2IkT8SIPvIP3jPw0s2BKSF4FyVCXmAZqjgry33JKIeGhzPN0dacrlJSvT8fNWCiTAuoUM6PGiEWi7qFXqzRZx/HCEq9ogPTnbGxH0IVdSTpBraQjiE+x5s8oeXY+onBrZsx+4rvhSTFfex9UigqbGvoiEFi8uVuZ9levsESpsnRPn2tBJkwtit0qP4ZOy1OVlEFJmfD58BQzr+Bc/1GEI7dVCHcDoXRAUjJUtc8AQjH0nrvc/E2apL8YVfVhPwbIZYdNZ8UuOF5HaYQnVp55zANexEmrcoF9jMlKtFPfKwPrQ9z972nCXF991txtcZWLDkW/wDo+fl8SWvjpGH+bv0bu+EdUJuTB8oznQggeRKAQ3ZKWAQEwR7Hfxz0phQMcMdGF8fUcOpng== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR03MB3710.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(346002)(39860400002)(366004)(376002)(396003)(136003)(4326008)(66556008)(76116006)(66946007)(38070700005)(66476007)(8676002)(2906002)(66446008)(64756008)(54906003)(1076003)(186003)(83380400001)(2616005)(5660300002)(91956017)(8936002)(316002)(36756003)(6916009)(6486002)(478600001)(71200400001)(86362001)(55236004)(26005)(41300700001)(6512007)(6506007)(122000001)(38100700002);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?0o33FUy0zVvgwCVvxJmkpR6?= =?iso-8859-1?q?rD/i4n0Tc5fXmR3kTQE/H7adxHwzTuifncaKJ8f0YLDTNNEhrc4J7TT6IbHz?= =?iso-8859-1?q?PwCURRoNVqyJfJwhqvp1+RtG6sZGbtM0ju6a+636G2eTiWNtWZOfjVURmp2g?= =?iso-8859-1?q?o/gAjsGfD/b7yg41g4dME6ZvTGEwjSNLPS2mHhPYUvNP6FQhKHyEp9rzMZFs?= =?iso-8859-1?q?Yli6a9VMZM2jjG+GSV62eWpAbbhq0EtV7gtxgde22yBHtjIuXXml2OimGzz3?= =?iso-8859-1?q?Fz59s+5h0+leSlOcx1CJWgt8IiRyMg39Zjz6IFvcyy9lnEiTBQGQcVLMdN3g?= =?iso-8859-1?q?r9xiU0fe7vnl1SC4ol/yj32oGsuN97ThSyMq5FrHV9gZh5MSQnSeHOUAPiXl?= =?iso-8859-1?q?ZQgH/et7BIUi8eikTJLMw8xOkA8E2r3RmDcXLJOSvK/6iiL5eVCXGmOqNJok?= =?iso-8859-1?q?z/iqrtV1GZVHqXhJFtxL9dRSd3ZMcHvaywyOvzUvjV34uG+FBt4jhx4vFWwQ?= =?iso-8859-1?q?hw6NWuptEyPdHpNtHfOVnV+AOcxmd63VAXeF9wQcJvCOg8vp4GPATRDDagbh?= =?iso-8859-1?q?kMNNZVlem8x2btp+mmJEcfxjk050fnnV5woBfjM71czPjkW4mzbmx9P/nJ3I?= =?iso-8859-1?q?Jzj3VagI9/X1lsKzLnM6Yjx7BuCc9rgAw+nuuZh17CVALLfgMMPKV79hLzA3?= =?iso-8859-1?q?we9Ty2OHjjHaPb5oZzTw/wiUEIRcHBkDhgp4UgwAPF6OslVzHbAmcb7yaEwY?= =?iso-8859-1?q?mRvZhmsEXdSMglIOA5ONwrIHj5t6aeDEP/bdrzjt+mk6N5Cdp6DmooRXuoxt?= =?iso-8859-1?q?LQ8fi3Hc3cwNY35MR4fKeAll4M7HnMlNF90aYmEXyxZe4AXgM3WImatspJCz?= =?iso-8859-1?q?Qm4gaZJt6xIUKxY5jcAjmejuvdB0Y85yJrFpnu6/zFFDILGsEBJzNlpbbyKw?= =?iso-8859-1?q?BrhadRdWBfs/dZW/ikQZbZNiYlmZ6O3BYeqBh/FRRCBwWfhSfElRvwU+mRnZ?= =?iso-8859-1?q?2MIe8kjzTMmayi8IR2YSDmPLG7azjHj4/Hnj20mKWumRF70g490Wv36OSoIg?= =?iso-8859-1?q?CEb+Xy9DHiG93X4wgj4RVoePSrcFuEXEyx38hzz+O8vb68Y/v8qG+/W48sg8?= =?iso-8859-1?q?05IR8PruIKHnUkzu4BT7LXhiJfZY7vR7Yx8qXXM+AulLEo+YL8OuHn3c/Cg7?= =?iso-8859-1?q?QbpUONMJ5L5ClJ9SAK3tRoH0o0/e6H659k+XHFbsDkIX53Cz5dilj95TenN2?= =?iso-8859-1?q?kDrVn4YZOmyatq0W4Dstrhp+2Faxqt7EfB/n4dhR7mo7+tWyNu2DyqHfy7mf?= =?iso-8859-1?q?izZQvhaS5e8ZJTKIaNDcgbjKP8rTk0xNe5Dim3DI/cN9EHDOc+fdvoQ5USBy?= =?iso-8859-1?q?T8O/hYuGbeF0UJkrn6vPxcHgG28jEyKPhEuk9RxmmOTgN21oRrgogStYsYwJ?= =?iso-8859-1?q?Aauahy82a4s0Sx+HuoyoBHsD2z4QSThbUL9Sg3erSbot758o8oY0fMu6LFxl?= =?iso-8859-1?q?wGiw/9iMekSlJ2M44vjDP4CKZ94z7F33QGCbWDLsMjFGWbjC1YH0DNi81ab6?= =?iso-8859-1?q?SQOE+HzH61oXQcndqIOsPN7WVDgxM3RgrLw2wjw9GXPBWAYwQQKZ1HS1D2iG?= =?iso-8859-1?q?SfLU3Nax35Fh+5zQlPqm60HbIFMQUPJVnMsUOBg=3D=3D?= MIME-Version: 1.0 X-OriginatorOrg: epam.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: VI1PR03MB3710.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4470ba1a-1e34-4fc9-d11d-08da8b5aa144 X-MS-Exchange-CrossTenant-originalarrivaltime: 31 Aug 2022 14:10:59.4680 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b41b72d0-4e9f-4c26-8a69-f949f367c91d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 8SQbDnJXzFcC+TGh7MPXAff3MbCA/JAYHRg/5PKRriJyNQJFTCo6aaFQH56wvOIWAkCZu+RQUCT/PskOy67qgW9xl/HloThi/qeWGt7Ti8Q= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR03MB6301 X-Proofpoint-GUID: upecQ0VtuA7okT37Z-I5QTk2lr0btmTN X-Proofpoint-ORIG-GUID: upecQ0VtuA7okT37Z-I5QTk2lr0btmTN X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-08-31_08,2022-08-31_03,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 clxscore=1015 impostorscore=0 mlxlogscore=999 priorityscore=1501 lowpriorityscore=0 phishscore=0 suspectscore=0 mlxscore=0 spamscore=0 bulkscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2207270000 definitions=main-2208310070 ATS subsystem has own list of PCI devices. As we are going to remove global pcidevs_lock() in favor to more granular locking, we need to ensure that this list is protected somehow. To do this, we need to add additional lock for each IOMMU, as list to be protected is also part of IOMMU. Signed-off-by: Volodymyr Babchuk --- xen/drivers/passthrough/amd/iommu.h | 1 + xen/drivers/passthrough/amd/iommu_detect.c | 1 + xen/drivers/passthrough/amd/pci_amd_iommu.c | 8 ++++++++ xen/drivers/passthrough/pci.c | 1 + xen/drivers/passthrough/vtd/iommu.c | 11 +++++++++++ xen/drivers/passthrough/vtd/iommu.h | 1 + xen/drivers/passthrough/vtd/qinval.c | 3 +++ xen/drivers/passthrough/vtd/x86/ats.c | 3 +++ 8 files changed, 29 insertions(+) diff --git a/xen/drivers/passthrough/amd/iommu.h b/xen/drivers/passthrough/amd/iommu.h index 8bc3c35b1b..edd6eb52b3 100644 --- a/xen/drivers/passthrough/amd/iommu.h +++ b/xen/drivers/passthrough/amd/iommu.h @@ -106,6 +106,7 @@ struct amd_iommu { int enabled; struct list_head ats_devices; + spinlock_t ats_list_lock; }; struct ivrs_unity_map { diff --git a/xen/drivers/passthrough/amd/iommu_detect.c b/xen/drivers/passthrough/amd/iommu_detect.c index 2317fa6a7d..1d6f4f2168 100644 --- a/xen/drivers/passthrough/amd/iommu_detect.c +++ b/xen/drivers/passthrough/amd/iommu_detect.c @@ -160,6 +160,7 @@ int __init amd_iommu_detect_one_acpi( } spin_lock_init(&iommu->lock); + spin_lock_init(&iommu->ats_list_lock); INIT_LIST_HEAD(&iommu->ats_devices); iommu->seg = ivhd_block->pci_segment_group; diff --git a/xen/drivers/passthrough/amd/pci_amd_iommu.c b/xen/drivers/passthrough/amd/pci_amd_iommu.c index 64c016491d..955f3af57a 100644 --- a/xen/drivers/passthrough/amd/pci_amd_iommu.c +++ b/xen/drivers/passthrough/amd/pci_amd_iommu.c @@ -276,7 +276,11 @@ static int __must_check amd_iommu_setup_domain_device( !pci_ats_enabled(iommu->seg, bus, pdev->devfn) ) { if ( devfn == pdev->devfn ) + { + spin_lock(&iommu->ats_list_lock); enable_ats_device(pdev, &iommu->ats_devices); + spin_unlock(&iommu->ats_list_lock); + } amd_iommu_flush_iotlb(devfn, pdev, INV_IOMMU_ALL_PAGES_ADDRESS, 0); } @@ -416,7 +420,11 @@ static void amd_iommu_disable_domain_device(const struct domain *domain, if ( pci_ats_device(iommu->seg, bus, pdev->devfn) && pci_ats_enabled(iommu->seg, bus, pdev->devfn) ) + { + spin_lock(&iommu->ats_list_lock); disable_ats_device(pdev); + spin_unlock(&iommu->ats_list_lock); + } BUG_ON ( iommu->dev_table.buffer == NULL ); req_id = get_dma_requestor_id(iommu->seg, PCI_BDF(bus, devfn)); diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c index 2dfa1c2875..b5db5498a1 100644 --- a/xen/drivers/passthrough/pci.c +++ b/xen/drivers/passthrough/pci.c @@ -1641,6 +1641,7 @@ void iommu_dev_iotlb_flush_timeout(struct domain *d, struct pci_dev *pdev) { pcidevs_lock(); + /* iommu->ats_list_lock is taken by the caller of this function */ disable_ats_device(pdev); ASSERT(pdev->domain); diff --git a/xen/drivers/passthrough/vtd/iommu.c b/xen/drivers/passthrough/vtd/iommu.c index fff1442265..42661f22f4 100644 --- a/xen/drivers/passthrough/vtd/iommu.c +++ b/xen/drivers/passthrough/vtd/iommu.c @@ -1281,6 +1281,7 @@ int __init iommu_alloc(struct acpi_drhd_unit *drhd) spin_lock_init(&iommu->lock); spin_lock_init(&iommu->register_lock); spin_lock_init(&iommu->intremap.lock); + spin_lock_init(&iommu->ats_list_lock); iommu->drhd = drhd; drhd->iommu = iommu; @@ -1769,7 +1770,11 @@ static int domain_context_mapping(struct domain *domain, u8 devfn, if ( ret > 0 ) ret = 0; if ( !ret && devfn == pdev->devfn && ats_device(pdev, drhd) > 0 ) + { + spin_lock(&drhd->iommu->ats_list_lock); enable_ats_device(pdev, &drhd->iommu->ats_devices); + spin_unlock(&drhd->iommu->ats_list_lock); + } break; @@ -1977,7 +1982,11 @@ static const struct acpi_drhd_unit *domain_context_unmap( domain, &PCI_SBDF(seg, bus, devfn)); ret = domain_context_unmap_one(domain, iommu, bus, devfn); if ( !ret && devfn == pdev->devfn && ats_device(pdev, drhd) > 0 ) + { + spin_lock(&iommu->ats_list_lock); disable_ats_device(pdev); + spin_unlock(&iommu->ats_list_lock); + } break; @@ -2374,7 +2383,9 @@ static int cf_check intel_iommu_enable_device(struct pci_dev *pdev) if ( ret <= 0 ) return ret; + spin_lock(&drhd->iommu->ats_list_lock); ret = enable_ats_device(pdev, &drhd->iommu->ats_devices); + spin_unlock(&drhd->iommu->ats_list_lock); return ret >= 0 ? 0 : ret; } diff --git a/xen/drivers/passthrough/vtd/iommu.h b/xen/drivers/passthrough/vtd/iommu.h index 78aa8a96f5..2a7a4c1b58 100644 --- a/xen/drivers/passthrough/vtd/iommu.h +++ b/xen/drivers/passthrough/vtd/iommu.h @@ -506,6 +506,7 @@ struct vtd_iommu { } flush; struct list_head ats_devices; + spinlock_t ats_list_lock; unsigned long *pseudo_domid_map; /* "pseudo" domain id bitmap */ unsigned long *domid_bitmap; /* domain id bitmap */ domid_t *domid_map; /* domain id mapping array */ diff --git a/xen/drivers/passthrough/vtd/qinval.c b/xen/drivers/passthrough/vtd/qinval.c index 4f9ad136b9..6e876348db 100644 --- a/xen/drivers/passthrough/vtd/qinval.c +++ b/xen/drivers/passthrough/vtd/qinval.c @@ -238,7 +238,10 @@ static int __must_check dev_invalidate_sync(struct vtd_iommu *iommu, if ( d == NULL ) return rc; + spin_lock(&iommu->ats_list_lock); iommu_dev_iotlb_flush_timeout(d, pdev); + spin_unlock(&iommu->ats_list_lock); + rcu_unlock_domain(d); } else if ( rc == -ETIMEDOUT ) diff --git a/xen/drivers/passthrough/vtd/x86/ats.c b/xen/drivers/passthrough/vtd/x86/ats.c index 04d702b1d6..55e991183b 100644 --- a/xen/drivers/passthrough/vtd/x86/ats.c +++ b/xen/drivers/passthrough/vtd/x86/ats.c @@ -117,6 +117,7 @@ int dev_invalidate_iotlb(struct vtd_iommu *iommu, u16 did, if ( !ecap_dev_iotlb(iommu->ecap) ) return ret; + spin_lock(&iommu->ats_list_lock); list_for_each_entry_safe( pdev, temp, &iommu->ats_devices, ats.list ) { bool_t sbit; @@ -155,12 +156,14 @@ int dev_invalidate_iotlb(struct vtd_iommu *iommu, u16 did, break; default: dprintk(XENLOG_WARNING VTDPREFIX, "invalid vt-d flush type\n"); + spin_unlock(&iommu->ats_list_lock); return -EOPNOTSUPP; } if ( !ret ) ret = rc; } + spin_unlock(&iommu->ats_list_lock); return ret; }