From patchwork Thu May 18 10:57:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 13246479 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 11ABFC7EE22 for ; Thu, 18 May 2023 10:58:31 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.536284.834468 (Exim 4.92) (envelope-from ) id 1pzbKg-0008GG-3V; Thu, 18 May 2023 10:58:06 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 536284.834468; Thu, 18 May 2023 10:58:06 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pzbKg-0008G9-09; Thu, 18 May 2023 10:58:06 +0000 Received: by outflank-mailman (input) for mailman id 536284; Thu, 18 May 2023 10:58:05 +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 1pzbKe-0008G3-VE for xen-devel@lists.xenproject.org; Thu, 18 May 2023 10:58:04 +0000 Received: from esa4.hc3370-68.iphmx.com (esa4.hc3370-68.iphmx.com [216.71.155.144]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id dabbb531-f56a-11ed-8611-37d641c3527e; Thu, 18 May 2023 12:58:02 +0200 (CEST) Received: from mail-dm6nam10lp2106.outbound.protection.outlook.com (HELO NAM10-DM6-obe.outbound.protection.outlook.com) ([104.47.58.106]) by ob1.hc3370-68.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 May 2023 06:57:54 -0400 Received: from SJ0PR03MB6423.namprd03.prod.outlook.com (2603:10b6:a03:38d::21) by MN2PR03MB4959.namprd03.prod.outlook.com (2603:10b6:208:1a3::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.33; Thu, 18 May 2023 10:57:51 +0000 Received: from SJ0PR03MB6423.namprd03.prod.outlook.com ([fe80::192:6bdf:b105:64dd]) by SJ0PR03MB6423.namprd03.prod.outlook.com ([fe80::192:6bdf:b105:64dd%3]) with mapi id 15.20.6411.019; Thu, 18 May 2023 10:57:50 +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: dabbb531-f56a-11ed-8611-37d641c3527e DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1684407482; h=from:to:cc:subject:date:message-id: content-transfer-encoding:mime-version; bh=A/uACWFhkkV9jxcmRWs6ZXnElUREbuI1UGoYrXPWvyI=; b=SsXcxyfcbQ1Ju8/QEx6rwjnPPJWvtYeIbh/zwHWgJSabPwiHQPIVgJNJ TIANUAM3ttXaRptuEREGemmI1KD6Ebz6x0Ln4cTOyxO63yJZACc/eyVKp c1ICFHVNdjjQETlY5FVbZjdp2tBOYC46HrCob12cq//8mMzbLL3S0EZtd o=; X-IronPort-RemoteIP: 104.47.58.106 X-IronPort-MID: 111964818 X-IronPort-Reputation: None X-IronPort-Listener: OutboundMail X-IronPort-SenderGroup: RELAY_O365 X-IronPort-MailFlowPolicy: $RELAYED IronPort-Data: A9a23:kT5up6JUbJK1qGgYFE+R8ZQlxSXFcZb7ZxGr2PjKsXjdYENS1jdUx zEZXD3XPPbZNmv0KYx3boXk9ExTvcOGx9VnGwFlqX01Q3x08seUXt7xwmUcnc+xBpaaEB84t ZV2hv3odp1coqr0/0/1WlTZhSAgk/rOHvykU7Ss1hlZHWdMUD0mhQ9oh9k3i4tphcnRKw6Ws Jb5rta31GWNglaYCUpJrfPSwP9TlK6q4mhA4wVuPaojUGL2zBH5MrpOfcldEFOgKmVkNrbSb /rOyri/4lTY838FYj9yuu+mGqGiaue60Tmm0hK6aYD76vRxjnVaPpIAHOgdcS9qZwChxLid/ jnvWauYEm/FNoWU8AgUvoIx/ytWZcWq85efSZSzXFD6I+QrvBIAzt03ZHzaM7H09c5SHTl20 6VCLAlXSSKl2uS98LOmbeJV05FLwMnDZOvzu1lG5BSAVbMKZM6GRK/Ho9hFwD03m8ZCW+7EY NYUYiZuaxKGZABTPlAQC9Q1m+LAanvXKmUE7g7K4/dnpTGLkmSd05C0WDbRUsaNSshP2F6Ru 0rN/njjAwFcP9uaodaA2iv1376RwXOiCOr+EpXg3LlwrXiNmFAwNycREgOC4si20VKhDoc3x 0s8v3BGQbIJ3FymSJzxUgO1pFaAvwUAQJxAHusi8gaPx6HIpQGDCQAsTDRMddgnv88eXiEx2 xmCmNaBLSRmrbm9WX+bsLCOoluP1TM9KGYDYWoISFUD6ty6+IUr1EuXEJBkDbK/icDzFXfo2 TeWoSMihrIVy8kWy6G8+lOBiDWpznTUcjMICszsdjrNxmtEiESNPuRENXCzAS58Ebuk IronPort-HdrOrdr: A9a23:19f0m64C2qo397cRugPXwN/XdLJyesId70hD6qkRc3xom6Oj/f xG8M536faWslcssRMb9uxoUZPoKRjhHPVOj7X5U43PYCDW/EWBaLx45Yz5yzf8Gyv4/us179 YCT5RD X-Talos-CUID: 9a23:eITz6GNZxoIPBu5DfTU/zGhNQMQcKFrv6irWKH+5FEFicejA X-Talos-MUID: 9a23:UeL9twyj97afxORxAOHgO+ApvbCaqPyET1ogtItYh+q7Dys3Yw7evTvsXpByfw== X-IronPort-AV: E=Sophos;i="5.99,285,1677560400"; d="scan'208";a="111964818" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UFeESLyG2xHmsQSif/RAtG5zgpFpmir2qRF+YY5jJhEC+Qw+BXqoYPlRn/110n2uCQY2UswMaDdvI2yz4LzuLmJQF3i/hUkr0jps20giWGShLPvCObOFC+xcuHihUNHh49A6ZsFIbxZY3NlnLN/2Qt4N3VzgzF+u9dnvM/iRKtkjQeMb7EmLufs7vPrIbTkv1OVoDmMK8s2ZdGc/vTIct53j6aPGRUkgjLwkGvS+KCSqL7/tRY5xwVE4GfX+i3yTcyJpev9cW2rgahuMnYeVuJvdNUctJ1OLzn/DAlK+wrT+93412+f4ds0vfuUwEUImnrI8O+MseiHyypXjCYn35A== 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=9Z2b5omfJztJFPLzPsbCzsdAso5yPlwMiZXcEZ1CNcM=; b=NLp3DzxW6+BM+rQRLdqMeVwCvlIk6BKMwA6sZopC8SpLW/m7ECcMJq9gJelqs/EYnfe9eQYmbwezfV6v7TncEKGqvTyWGn1GYbEPOuOpMPm+2em9fgV+4Cg8F0hA5L20mfc5v5LGXYwWvJOwACXPZoXAl77YT2/3rpnIaqRElVYc3Xj2gWziwkm+iURK2yYqIzuuSzoCBCWm/obcwUz91VgI26N66ZycM6Go/9C3os/nyWN9/CgCoy/Vp+5sLGb8yp5mABo3fWG6iSQptPpaoWS20Fo2MjQN2MeqqrVO0w4zxaz0miFIazsNKNZalK4fpQBuOFlod5cgzaR8+YpS1Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.onmicrosoft.com; s=selector2-citrix-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9Z2b5omfJztJFPLzPsbCzsdAso5yPlwMiZXcEZ1CNcM=; b=Ve3bvosAmrdsU1/KEyY+P4K2X6n4qytysE+e+io4AiHgjGdluFp4uiZB7vxKLZPu9GZJq3WCuwA7ohm5qDKOJrDuWXvMuK5WKbS+lwU0vbKgVjFhNmxlH40XAcasgdpCCUcwEn+OYsXQEcuvuMHBryXa8suXTboZNMHhbcoNkeA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com; From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Roger Pau Monne , Jan Beulich , Paul Durrant Subject: [PATCH] pci: fix pci_get_pdev() to always account for the segment Date: Thu, 18 May 2023 12:57:38 +0200 Message-Id: <20230518105738.16695-1-roger.pau@citrix.com> X-Mailer: git-send-email 2.40.0 X-ClientProxiedBy: LO2P265CA0085.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:8::25) To SJ0PR03MB6423.namprd03.prod.outlook.com (2603:10b6:a03:38d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR03MB6423:EE_|MN2PR03MB4959:EE_ X-MS-Office365-Filtering-Correlation-Id: 460b8e72-1681-4ab1-f415-08db578eb91f X-LD-Processed: 335836de-42ef-43a2-b145-348c2ee9ca5b,ExtAddr,ExtFwd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DsTWOTGezYHSO72n1D9voV463VBMohyNRxGRgXs4phIe2VzSjluopIuefZxrOMmi612xnistC2nZQPW8W7X+C0NbhCP7YaFVc3M2Wwh/bcYisVcXv71/MjPELQOQkVXKsLvTuTlFxKxQ5gwggATzfX3UAwKYFCEDbnz+I8cIcRG6V4A8LA1l3kjmzI/awW7YSUFXdGw4RSKBjvenruUzVJ9MYYIv1kwX4mlerk523qBZq5bILyc6oRU3aYNhgXmTg3ICJu1tQPPU7ivtpjfzIBVf+MTV8joEo2Hc2/zKMQ+5H2PiXF8LZf885gCe+fmdBNZnKhASyDFyw+75nXS5sYG/4MpB+wWwH5rVxUbWSC8yvI/hnfRFZMzcCbioFAWLSuaCY4sBeAUHd7SUaZM6ym9EqQatyu2aVu37tsmIZV90qJ5K3bRdp7Quf2iduQp3IB2lDwV8c6JHp4jpPXJ/fjlBsgTswSPFYAUceHJ0Tb5c7qFF51WvPo5y12275JxFZrA/oQ2CUTbw+6s+2uuSYt+DYPPPZhdRchE/Krt5iwYnBQQU0jQj1oUA7ffMlRHa X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ0PR03MB6423.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(346002)(376002)(136003)(366004)(39860400002)(396003)(451199021)(2906002)(5660300002)(82960400001)(6486002)(15650500001)(54906003)(86362001)(41300700001)(6916009)(316002)(66476007)(4326008)(66556008)(66946007)(8676002)(38100700002)(36756003)(8936002)(6666004)(478600001)(83380400001)(186003)(2616005)(6506007)(1076003)(26005)(6512007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?3y9UlNoAK1dVjngkdqCecATOUptH?= =?utf-8?q?PYVyrLGLFJJE/RmMRROmbJrMpJMYLiDbuwxlw77rVxJLjz+PVDUgyZ8Ht+jpz8lZx?= =?utf-8?q?3MVJmm8qyj/+5I2JeHGTYdrV/qQeeR+Ljg9k6SKdOJ6XN9j/EjnD9keQMPK8M3pvU?= =?utf-8?q?8j9qRp45X+9xCt5qA+lq1Qr+B1dXo7B4j9sjBz3ckDklyJTpHVNGiu16KyUpq5uD1?= =?utf-8?q?nlT/UfZ/bXm9gLu9OYgF9o3Ui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m1E9sxQ+tDpuuxSBdpp7C/1Am0TCgub?= =?utf-8?q?F2QcLJq2f+soZ8SSqo9XfwMn//DBean1puans4eKwpEggCsLLE/V3YfZ0PY1/Z5KK?= =?utf-8?q?ZJImZFyl1p/AcbrgaQwV+J5p7bNB0B5/+tD/1kI+3j4tgES7Wwrm7vCvKv6pRdese?= =?utf-8?q?4MFpjDETlO41kcv2i5xr+p5IZ882hAgieUjUnT058Csdo91J7k447z6iWsw+o7tKx?= =?utf-8?q?ZxqKvyRAIF8KZbidwKkm3WLwmxhzXwKqLErwRyvinaEUE6V3xCQXwhdIgFA3wl7y6?= =?utf-8?q?Rx5LW2/bOdYxBG4RilIrZo+NkcWF+oZ+DwB8xYeJaUpmSVfQwfBnwA4rrdViyXaWl?= =?utf-8?q?HjC9zBmHIzutsT6PW8KLK1nk0KibilzS/mKPbKUmhqMwKkD/CbqFK889IWe1ehBi6?= =?utf-8?q?6CT43QSMB//hziX5lSNVI9Q3zLVX16hqWg=3D=3D?= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: XfzXPg2QoQuBWsGBiKJ9WQJk7wTKOFWhGbW9dexZOMxwy9akVc9eJepG5zNyGQA+YkBR5+ZB+GqPqWMveYGhiUS45hychxYAVRvjduPvKDeRQ8E/Y9X5jOtg5O7AVDV6sBNJ96CskS0O7xIpy8AParTbg3oVdzpfxJ/uqw2A5zTSvZ2gTeIIU8or7ibfBfK57CUJETk5WvfTCencE444QzL66bk1PgUIE3+jlK1Jgp/vP+/o5+UtuMzCpBDPpt/hUikdKvx+PcslAJzngggU/xP9HQI27oNTgmrOkAV6/emZzux0K2qzmnWqZpOzL9ufExnkAQMpXV6V24LKXZd7R01WPZGy8HhV/PTlzCZ8DQorIWV18zsbbl0Q0iQVpZN++Ly2KYS6b5k2tnRcaz1ZI54ngu7rUXy6+i8SFOTWI0fOqb2k/Fpi4P9c8b1l2cFSZm4RmOF4jabTEyAA4pmB2E0Arpaae7HdcmAZyvVQoaTw0l2beBED6FGR59DJ0frV+VPDlCqrZ4OluQsRyEmMuAHtEWggYLEdWhZ7/ph4Xs1MlSN+8x5qeIHcdmn7qkzZ15/pP85m+VynPK8VUoT1uijgEn8qbFbTkF6cISZQvXz7o8WcoMbUK8AuFXbpTj4pazbBE+xhK3JRp+eerxxkQnPxj1IolNmpI9QxD1P//SmFcR3OvffKVP4P26m+R0qnBhGz/4wIWSMvqmKidb4cwh4aTWJ2LPYmiN8plI1tl+Q/N+e91EYRDr5dVRzEeHVuP+tvFCIXi0LQ77omMokn+ijEKcQyvm6aahqmz9KUwJQntlpJicsB1ILYFjswv0wWY3qQ266cr8OOxon/Kurl3Q== X-OriginatorOrg: citrix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 460b8e72-1681-4ab1-f415-08db578eb91f X-MS-Exchange-CrossTenant-AuthSource: SJ0PR03MB6423.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 May 2023 10:57:50.7338 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335836de-42ef-43a2-b145-348c2ee9ca5b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: sYT8p4i95o4rVXretaqylsSG6RX65/g00YRflWnHz439cud4oxdnE9zDOP+T5dgbEJi8C5SjZlEqeAOELGZLwg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR03MB4959 When a domain parameter is provided to pci_get_pdev() the search function would match against the bdf, without taking the segment into account. Fix this and also account for the passed segment. Fixes: 8cf6e0738906 ('PCI: simplify (and thus correct) pci_get_pdev{,_by_domain}()') Signed-off-by: Roger Pau Monné Reviewed-by: Rahul Singh Reviewed-by: Andrew Cooper Reviewed-by: Jan Beulich --- There's no mention in 8cf6e0738906 that avoiding the segment check is fine, and hence I assume it's an oversight, as it should be possible to have devices from multiple segments assigned to the same domain. --- xen/drivers/passthrough/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c index b42acb8d7c09..07d1986d330a 100644 --- a/xen/drivers/passthrough/pci.c +++ b/xen/drivers/passthrough/pci.c @@ -552,7 +552,7 @@ struct pci_dev *pci_get_pdev(const struct domain *d, pci_sbdf_t sbdf) } else list_for_each_entry ( pdev, &d->pdev_list, domain_list ) - if ( pdev->sbdf.bdf == sbdf.bdf ) + if ( pdev->sbdf.sbdf == sbdf.sbdf ) return pdev; return NULL;