From patchwork Wed Aug 31 14:11:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Volodymyr Babchuk X-Patchwork-Id: 12960757 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 30B28C65C0D for ; Wed, 31 Aug 2022 14:11:34 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.395681.635478 (Exim 4.92) (envelope-from ) id 1oTOR0-0002cN-DK; Wed, 31 Aug 2022 14:11:14 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 395681.635478; Wed, 31 Aug 2022 14:11:14 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oTOR0-0002cG-AP; Wed, 31 Aug 2022 14:11:14 +0000 Received: by outflank-mailman (input) for mailman id 395681; Wed, 31 Aug 2022 14:11:13 +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 1oTOQy-0002bv-S9 for xen-devel@lists.xenproject.org; Wed, 31 Aug 2022 14:11:13 +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 c2df0da8-2936-11ed-934f-f50d60e1c1bd; Wed, 31 Aug 2022 16:11:10 +0200 (CEST) Received: from pps.filterd (m0174677.ppops.net [127.0.0.1]) by mx0a-0039f301.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 27VBo4GE032537; Wed, 31 Aug 2022 14:11:07 GMT Received: from eur04-vi1-obe.outbound.protection.outlook.com (mail-vi1eur04lp2055.outbound.protection.outlook.com [104.47.14.55]) by mx0a-0039f301.pphosted.com (PPS) with ESMTPS id 3ja427h4rd-7 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 31 Aug 2022 14:11:07 +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:11:02 +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:11:01 +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: c2df0da8-2936-11ed-934f-f50d60e1c1bd ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KvArwocYUmWcgj1cBM8dAwNTv+HzTn8sMGFViPImWj5Q3F9llb6oaaTnAutlo5noBmcc2zKT8IJxaSOZUH7d1S7F772NoVqMbdqcYe64AndKM5cI0Z2Z2fMjIDMXWdIEXEw9mHivEY0hB72qpgZAwpqyf33C/aQy/Cf0OYNeYNOgd3X4NopGuzI6zP4Kn9oB8/WNZzFOUg73SIXqke0doOkDWtn1VXAY7iri2kxnSNb4AjYV6oY+KjySFIHhQwl01mQNCT+3yAVx7bLIO9cuw5SXREBsKXJfvaHtdbLB9ZFZGYY9F1Eu1R8vZdWiLOwkvJdiEJqYFpLkKisFTEBAmw== 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=pKNemWZV2+FfurTu7vJyid03vkZnEYejDqPafwLthYA=; b=cPyGpxRKr5BUYR1PXasS2s/HiSxFSR9e9dM1UMDTP1o4OgZ75E0fXwPc68OIxhViChvYjK3MlcZuMgraR+x/sik/L5nuY4rCjUGL/IrFaY5UifPzrk0y38oVUeMlOyrnEcWA2LTWgHK6ITBj/hrrSLGUL+MA/uN2oniAAMStU3xhBOrreQ1SW6/ZjPDhkzj6ZEcrpSpngkP3/Y/AfsllRmSO9TG5Gy9GbBiF4xwVEa6ZAqQsGlDmN1VGt9gOnEfCBcAojPH1gbLuIceFw1eyNtxAD2Ho6IFTPZFlU0mewN+PJg924XA6miKPOuz0yHWx6plrOx3tMAh66z3IgaIcog== 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=pKNemWZV2+FfurTu7vJyid03vkZnEYejDqPafwLthYA=; b=DSjUsgDxzTZHhvTRrd+IuueionF9zq4+bW+5mEv/U1mYDZ6zCO/hYNLCyn2CmOsXRGkQhIaqW72keWvWlfMpes74FY2jMQySY7GlKS6o6rm41h75GBUosWwXJ2NqRtAdKAMEkMF1hL87Rcw7Px5AYL/Qli1ltFNnA8eHOrd3vsonxEHCYPq2eEDfv9tF3h1zq98sUu6CevTUs+45ryGM/H1IbGdkWAJektUZ8q6b/108Osl0ExaGn66hUcImtoZfCQQfHeT8IY2xX7YdtlQp6DrUJW9kreEi6FdmXPnZ1m/VRHLUtDwQS9rEE9ecuUqVdt3NngsuHT6zMI1FrU8vfg== From: Volodymyr Babchuk To: "xen-devel@lists.xenproject.org" CC: Oleksandr Andrushchenko , Volodymyr Babchuk , Kevin Tian , Jan Beulich , Paul Durrant , =?iso-8859-1?q?Roger_Pau_Monn=E9?= Subject: [RFC PATCH 09/10] [RFC only] xen: iommu: remove last pcidevs_lock() calls in iommu Thread-Topic: [RFC PATCH 09/10] [RFC only] xen: iommu: remove last pcidevs_lock() calls in iommu Thread-Index: AQHYvUOAlPa0wkGiakOWSGDBM2amAQ== Date: Wed, 31 Aug 2022 14:11:01 +0000 Message-ID: <20220831141040.13231-10-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: 9c2ed1f2-79cc-492b-ce23-08da8b5aa2ac 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: QThC1htusAtQAt2B2v9A+fgyL3/E9jsD1gfKXVTHPKPnETix/ezkg2zyQKyCwyFzyhO7zRg1HkQClmhC6APAaxz+68k0DRE6YqhG7HlNnB9EYZOQKgGNoQHAE4jXnsJd9xV4wB8WfQ2w0M2dZrvzg+RCe6rkY1QpLHdo+be0s1CF1e5gSjLvyuArl3abxc5Io+4gLGXVY97OzaOzYNTza/CIn+4XVxNn/qrhlDPwthJaVIm4JGyr7+kl9eOJcGUsNLty0VWbE49nCLqXG4c6ek+x1lg8zKSOm0BuXCRDCWMIz4A8ikUWfYSJt8SoU+mzvvIJ3YXWXtjzGCnyz1B7roapQIOv9jDBRP983/lVOW99SkjOv5pAmK7qdjK1nxojrf7/zDOAWfTC99/hxrjxzGgGCbVvzw9p1fvMsgxgDOUmafz69rsZsriGBhiThKsIvyxs/6Ows6FwMJsd/86H2vFfA5L9nqiJXvpkjFAcRtTbCsk4SN3N6VcDy3wzDsduog/wkdLmXh4BSI+6T/4lbHfktO8t9uaL4m6drBSP5ubTR/tJ4TRxIbjURisNa9UhANcqEzSGQrlyOhFbxBjb9G4gzNn1h7qde0aSXzpG8RUnH46wZNGVXUZDEGcNShDjB0DQhDCvFRlX1B5SufD8MgtpWv5+cehnvsXuiK2WrKNK8WIOD79nsieNbSVs00ExTpuH4gEjXvamddHWsZfUMPUfeD67CcIJqWQguYFVPOCwjGPpsTnRXJTq2zlD6bG01nOSYCnX3PZo7Z+AYe/AsA== 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?AnJnovz+0KakAiFLK/BUDZ1?= =?iso-8859-1?q?9KFy3tu4nx8ikSrUggWBAkttwdoDYcEUKwfmRR9aMB9dgu834OlA/Op4mQ6D?= =?iso-8859-1?q?plVpEytw+SoBYj71MMiwktj0wJbMBhDdTBwmOOpPWCzEXAI8bTqWXjz1ADlN?= =?iso-8859-1?q?W166jzeyI1hky7AGafynp6XOTLercFfeBI3fKRkx82ZevpIHSFFbUuTGeyZO?= =?iso-8859-1?q?LpXIsmmOYVF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jvP/DMrCxF0HhuQWqak2+nVIRVw4v5Y?= =?iso-8859-1?q?+R1PKoNdYwvkzrjw0EQEEuGXzbhpOy1SadIzPCd5UqsITRjeobRhjG4UX1Qn?= =?iso-8859-1?q?dwn0EmnXnxKMMCxa7BUilNhnFL/C6pb6UhI1NmEFQ72H1fWqxSTW3w79H9Wa?= =?iso-8859-1?q?zTVB2gNc+rHYkT88g4P3ML1L2MD38su72dB+AdvtH2HMm3DRr4rRRctPrbHF?= =?iso-8859-1?q?nBtlWwmH0eBi9/DifxQHX1pgStR8SpXljNK27fkBOamiD8BVQKg97r7wma/h?= =?iso-8859-1?q?PHQs7QH2P741jt2NCXRkc7UOozk5l3jSj3mxW2khVWR6/IJPVkAVPeDjAFRk?= =?iso-8859-1?q?uEszT5wzDzRZFkqrQC3o0z2Z2iEoqso52y4kC6/Z3plvDTeb37vM251IiPTU?= =?iso-8859-1?q?QTTDiyujGKWuREV+mNCvXcwzsd3t/ziV7w+m08XvCeBwRv5KCZp+hsC8DK8S?= =?iso-8859-1?q?jS+qhdgRcH6jSxGnPtyC3wGXyygbyw8dXGbkkWRCFCwdNKfS/+kp7i6sygxY?= =?iso-8859-1?q?YWB0Rtbo9+CQh13ky0eVR3pR8yoa2zZozghICsw=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: 9c2ed1f2-79cc-492b-ce23-08da8b5aa2ac X-MS-Exchange-CrossTenant-originalarrivaltime: 31 Aug 2022 14:11:01.8272 (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: LhNZ1/FbZV+oN13CFD2tj1ETKjJHk48362a7nk3NfOr1ZSmW8GpCCJLaw81vLHhmlEsfJMilNiSIRv2CxAsYgSoR39STmeejK8hbtByA/Qo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR03MB6301 X-Proofpoint-GUID: d0beUWY9CpniSbmboyjYlg4wxNcL61o4 X-Proofpoint-ORIG-GUID: d0beUWY9CpniSbmboyjYlg4wxNcL61o4 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 impostorscore=0 adultscore=0 clxscore=1015 mlxscore=0 malwarescore=0 lowpriorityscore=0 phishscore=0 suspectscore=0 priorityscore=1501 bulkscore=0 mlxlogscore=999 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2207270000 definitions=main-2208310070 There are number of cases where pcidevs_lock() is used to protect something that is not related to PCI devices per se. Probably pcidev_lock in these places should be replaced with some other lock. This patch is not intended to be merged and is present only to discuss this use of pcidevs_lock() Signed-off-by: Volodymyr Babchuk --- xen/drivers/passthrough/vtd/intremap.c | 2 -- xen/drivers/passthrough/vtd/iommu.c | 5 ----- xen/drivers/passthrough/x86/iommu.c | 5 ----- 3 files changed, 12 deletions(-) diff --git a/xen/drivers/passthrough/vtd/intremap.c b/xen/drivers/passthrough/vtd/intremap.c index 1512e4866b..44e3b72f91 100644 --- a/xen/drivers/passthrough/vtd/intremap.c +++ b/xen/drivers/passthrough/vtd/intremap.c @@ -893,8 +893,6 @@ int pi_update_irte(const struct pi_desc *pi_desc, const struct pirq *pirq, spin_unlock_irq(&desc->lock); - ASSERT(pcidevs_locked()); - return msi_msg_write_remap_rte(msi_desc, &msi_desc->msg); unlock_out: diff --git a/xen/drivers/passthrough/vtd/iommu.c b/xen/drivers/passthrough/vtd/iommu.c index 87868188b7..9d258d154d 100644 --- a/xen/drivers/passthrough/vtd/iommu.c +++ b/xen/drivers/passthrough/vtd/iommu.c @@ -127,8 +127,6 @@ static int context_set_domain_id(struct context_entry *context, { unsigned int i; - ASSERT(pcidevs_locked()); - if ( domid_mapping(iommu) ) { unsigned int nr_dom = cap_ndoms(iommu->cap); @@ -1882,7 +1880,6 @@ int domain_context_unmap_one( int iommu_domid, rc, ret; bool_t flush_dev_iotlb; - ASSERT(pcidevs_locked()); spin_lock(&iommu->lock); maddr = bus_to_context_maddr(iommu, bus); @@ -2601,7 +2598,6 @@ static void __hwdom_init setup_hwdom_rmrr(struct domain *d) u16 bdf; int ret, i; - pcidevs_lock(); for_each_rmrr_device ( rmrr, bdf, i ) { /* @@ -2616,7 +2612,6 @@ static void __hwdom_init setup_hwdom_rmrr(struct domain *d) dprintk(XENLOG_ERR VTDPREFIX, "IOMMU: mapping reserved region failed\n"); } - pcidevs_unlock(); } static struct iommu_state { diff --git a/xen/drivers/passthrough/x86/iommu.c b/xen/drivers/passthrough/x86/iommu.c index f671b0f2bb..4e94ad15df 100644 --- a/xen/drivers/passthrough/x86/iommu.c +++ b/xen/drivers/passthrough/x86/iommu.c @@ -207,7 +207,6 @@ int iommu_identity_mapping(struct domain *d, p2m_access_t p2ma, struct identity_map *map; struct domain_iommu *hd = dom_iommu(d); - ASSERT(pcidevs_locked()); ASSERT(base < end); /* @@ -479,8 +478,6 @@ domid_t iommu_alloc_domid(unsigned long *map) static unsigned int start; unsigned int idx = find_next_zero_bit(map, UINT16_MAX - DOMID_MASK, start); - ASSERT(pcidevs_locked()); - if ( idx >= UINT16_MAX - DOMID_MASK ) idx = find_first_zero_bit(map, UINT16_MAX - DOMID_MASK); if ( idx >= UINT16_MAX - DOMID_MASK ) @@ -495,8 +492,6 @@ domid_t iommu_alloc_domid(unsigned long *map) void iommu_free_domid(domid_t domid, unsigned long *map) { - ASSERT(pcidevs_locked()); - if ( domid == DOMID_INVALID ) return;