From nobody Mon Nov 25 16:36:51 2024 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D230321440C; Fri, 25 Oct 2024 21:51:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=198.175.65.16 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729893086; cv=fail; b=sYdrJlHxuaEtWZZoxtVA6ZV6CvLhaE2jnSiwT3gHQStsGsA6Lc0cdtDarMRUpqhYwEN7cNREOHZBy+Kl5woOTMyjrhTcOv3rjx1m9u1qjwilYTrSNEk5G3ssqb3seCfy6FkFLwvJd7ft1cARhftaOrnPMomQSfjLAygp//vr7kQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729893086; c=relaxed/simple; bh=+6kX+PN8G7ONn69IurZXEHL7OKrxjzVRleyDPT0EP3I=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=bI6TCJnugbCoqcfBYD5ghCRKKNf4hTPbmRM6e0P90CONRcjtLj7gdDz3+tbUXGoB112BAJRcOwSE2r2sVT+IQUJXaQLpp+yLhH+MOYHltqy/hIqGva8BESVwFymjs9yxxIA4rtu9dWWfuZZ6ByPz+NkX87sRPoXBHUSIQtyZEpU= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Kh7GiJBt; arc=fail smtp.client-ip=198.175.65.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Kh7GiJBt" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1729893085; x=1761429085; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=+6kX+PN8G7ONn69IurZXEHL7OKrxjzVRleyDPT0EP3I=; b=Kh7GiJBtgsuD9yFaaWJDUF67Wfw5pLut5WyAYuUl6hse8OP7hh15J98i xF336LPCLv3jxK8oaPtqbzQQmvE29Ic5LBNOk4538atBLEgNVydHjIXG+ Omxiz+QarHeocDdYWmh10BhVr8gpTcBllNWo6BbFe6bNXyMyDutAS5ELI MXyZipkKJmr8iiNdOir/m8oAzR2x3hpkv4D27Ci/IFgdPKWIoAWFPEb2m 4TW1bcuaoq6Tbe82YYti3Jq3rgyMhzjE2suL1bK07oiY2XWBzcsqEgHuS 8Tfb8OGFTKv9V7e/mTfn0syTp04thsCUTnRawmAlg7PjdHgrEMonmePJg Q==; X-CSE-ConnectionGUID: dQcZW287SW24Uj3ow2cQLg== X-CSE-MsgGUID: q4Vf/aPsRIa+VPFOjUUOxg== X-IronPort-AV: E=McAfee;i="6700,10204,11222"; a="29704512" X-IronPort-AV: E=Sophos;i="6.11,199,1725346800"; d="scan'208";a="29704512" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Oct 2024 14:51:25 -0700 X-CSE-ConnectionGUID: fVOU1lOORGShgQld12K5tw== X-CSE-MsgGUID: KjNzKySLTx+EEDqUT3X9cg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,233,1725346800"; d="scan'208";a="111854145" Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by fmviesa001.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 25 Oct 2024 14:51:23 -0700 Received: from orsmsx603.amr.corp.intel.com (10.22.229.16) by ORSMSX602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 25 Oct 2024 14:51:23 -0700 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39 via Frontend Transport; Fri, 25 Oct 2024 14:51:23 -0700 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (104.47.56.177) by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Fri, 25 Oct 2024 14:51:23 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=t61H16/QvbYc7XiVxmQ2qeypXB3lixCgRenTVrw5kMtrQNfIhfVToy7lY+e8oT4QsUskzTRWPUeZBhqPCUuS1frnTBez33SXPWC2sRABs3/8z0HAB4VlQ4U2hl0Ys+mcjvDR6LlpOICtNx4D4KLroeyhT3tKoMRCE+3NcEnWMykgBCQ3YSR26EviT8gQi0zxHJWUArKdNZKFU4KMkKTmMEK6GZbKMSFr9Y7cFdWFiD2JXsPcb+GsUWuHRK8i1iKjhfej7XIJE9y8nsCTN1/PKfV3TQz9kuptYvz9BVIzYlX/EgCUnrD8cVAo8CQ+4Qtfqvd91XR/gxdFkbv3rGcg3g== 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=+QmHvi2kGNZ/R3MXys/d+yl7CPR0MJOK4uWFtGOMqxM=; b=c9D9WMMnAdSSbZivka/R6iIInAF2+Xlujo9d9xolefwgiCTjM5nfIushDoInXn+oNUIF3qgiplIWWlh9IwJqnOVCwGrJNmxJ66DHdgwhqVPm7QFTCM6EDoCIDho/DScN4sgrCOoodu0soDq1E7UmJlw9k375jd5uSsVTn2/Bkpvv1kGhQI4RF8aOQQVGZT764q4K7rtTQx28cAAZsu/lAetexg4fUDl6amNrUA8YzEAiG4Aa5tYysDFPPenmTuHDCMVY8lZFYEAxVsKAstLeSDuC4IDH3+7WKoxJ/jS+W+UJcm+FuJeif6GGTch2LX5+C7uhJ76H4Zqy3lGNF8kVVw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from DM4PR11MB5373.namprd11.prod.outlook.com (2603:10b6:5:394::7) by CY8PR11MB7745.namprd11.prod.outlook.com (2603:10b6:930:90::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.16; Fri, 25 Oct 2024 21:51:21 +0000 Received: from DM4PR11MB5373.namprd11.prod.outlook.com ([fe80::927a:9c08:26f7:5b39]) by DM4PR11MB5373.namprd11.prod.outlook.com ([fe80::927a:9c08:26f7:5b39%5]) with mapi id 15.20.8093.018; Fri, 25 Oct 2024 21:51:21 +0000 From: =?UTF-8?q?Micha=C5=82=20Winiarski?= To: , , , , "Bjorn Helgaas" , =?UTF-8?q?Christian=20K=C3=B6nig?= , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= CC: Rodrigo Vivi , Michal Wajdeczko , Lucas De Marchi , =?UTF-8?q?Thomas=20Hellstr=C3=B6m?= , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Matt Roper , =?UTF-8?q?Micha=C5=82=20Winiarski?= Subject: [PATCH v4 5/7] PCI/IOV: Check that VF BAR fits within the reservation Date: Fri, 25 Oct 2024 23:50:36 +0200 Message-ID: <20241025215038.3125626-6-michal.winiarski@intel.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241025215038.3125626-1-michal.winiarski@intel.com> References: <20241025215038.3125626-1-michal.winiarski@intel.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: WA2P291CA0018.POLP291.PROD.OUTLOOK.COM (2603:10a6:1d0:1e::13) To DM4PR11MB5373.namprd11.prod.outlook.com (2603:10b6:5:394::7) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5373:EE_|CY8PR11MB7745:EE_ X-MS-Office365-Filtering-Correlation-Id: ca155235-7f3f-41fa-1ddb-08dcf53f29c4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|366016|1800799024|376014; X-Microsoft-Antispam-Message-Info: =?utf-8?B?V0ZENXRSUmE5NWViZnc5Q3pMUTRaZENXc3ZJVEthbkdwZjM5K01DSlh6N0RY?= =?utf-8?B?Nzl1OGZoWTFVTUhjWGIvNXdqQlhIYnR4MTByZUxjNUJsSEY3SDdtY3lYNElS?= =?utf-8?B?dVJhKzFpL2tlelJWaGhpMWdxaHdiT3krekVmajdCanV6M0NsMitUaS9xSTVn?= =?utf-8?B?bmFFTVBicC91UFlQblY5QU9rVG5JT2hRMnE5YkFLOE1QWkNBL1ZtVStWcjZO?= =?utf-8?B?c1owWmF1RWVSVTZ5UE1kUi9mT1grQkQyZmcyMFd3YzE3T2U3UCtOaWQ4ZTZh?= =?utf-8?B?QkROaWRBM0VjdTBwUVZGM2R2d2xvd25rQ21ySTREV1dHTW83YW5yNStTMmNk?= =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JUbit6NitG?= =?utf-8?B?N1UwMnliNGkvYXlTNEMzaHNJMlFBUEpUNEJodmpvT1VGMGJDUjBoQWpHU1l5?= =?utf-8?B?MU1xNUR1TmFraUV2L2JGSENYMUxpRkpSZkMxUnJDcFVVTFZpeXpyZHVLQmc3?= =?utf-8?B?QlcxZko1MDBpZnNQcGNtRjgxbVFXdzdHTm9nSk1kU0RWeHgwTWlyQlB0UzdQ?= =?utf-8?B?d2RDYWFnWEhEV2ZyVnNUSzdycFg0aXZ4Mkh5M3Ntc2c3bFRGdm9Nd21PVmhO?= =?utf-8?B?aE40UDRYdkFIWkJuRCt4WEgya0dva2JvOVpRYXVES3RLQ09sV3BNUlJNM0da?= =?utf-8?B?RVBFSFQ1VWkxdFVzaHAxUEhLRnhtaUVxK2pmdlNyNUV6TnJUQ25WSmtrNjZ1?= =?utf-8?B?dDYvUEdFdHBzeThOMXU0b243djlIaXNSKzZJY0lBcE9lMVA1NXN1UW1PYVNQ?= =?utf-8?B?eElYVGczYWlpald3a1ppNW92bG1uM1ZrcWV0MGRWREl0VTJvVjhiNmRtcTFl?= =?utf-8?Q?ioaVvkMZrV9D78LVbnLmIXcEUaW8MCTX7epDxLx?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM4PR11MB5373.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(7416014)(366016)(1800799024)(376014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?eGRkWmRJUmdGRUpzaDJtYjBrMmpsNmh6VjJ6S2dia0VoWkFkdzluQ2UyelpL?= =?utf-8?B?MjlMdGlHS05vRDRoYUpGK2tiaTRMZWxEeDdsZFFVV2lJMmRVWG9va3UwYStD?= =?utf-8?B?MVpYL3d2dHIzeGdidFJocFNpaERtUEVFV245eEV1cHJGRnN5K3dQUUYrYnJS?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S3JoOW9GQmZGaTI3a3ZrYjNmNlNVV0ZvanJ5?= =?utf-8?B?UDVIZTh3YTQzR1VXU0FJd1BxSnJsaXJtZjQzR1R5K1ZaUzhzTnhidGFJeU10?= =?utf-8?B?NmJDbVZ6QWxNVnNmSEhCSm5LcWQ2bGJ0bzhSQXRrNDNPbi9xR0J3blY4K2Nz?= =?utf-8?B?R1FwNEsyRHJjeUdPdjlYQWxNTmxkbDE5VVR0dHlQUGZMTXBDallXczJQUm9M?= =?utf-8?B?c3c9PQ==?= X-MS-Exchange-CrossTenant-Network-Message-Id: ca155235-7f3f-41fa-1ddb-08dcf53f29c4 X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5373.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Oct 2024 21:51:21.3542 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 9XgPgUJNOFCIDFEH3Fo/lHsn9Q+NGbgHujLlu+gf3xOdD2MhI4McvcoU5hX4vsWGTbRdzrXCeAW1E9ev9JtOfaRta/VOjhB4TWROpvXHyr4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR11MB7745 X-OriginatorOrg: intel.com VF MMIO resource reservation, either created by system firmware and inherited by Linux PCI subsystem or created by the subsystem itself, should contain enough space to fit the BAR of all SR-IOV Virtual Functions that can potentially be created (total VFs supported by the device). However, that assumption only holds in an environment where VF BAR size can't be modified. Add an additional check that verifies that VF BAR for all enabled VFs fits within the underlying reservation resource. Signed-off-by: Micha=C5=82 Winiarski --- drivers/pci/iov.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c index 79143c1bc7bb4..5de828e5a26ea 100644 --- a/drivers/pci/iov.c +++ b/drivers/pci/iov.c @@ -645,10 +645,14 @@ static int sriov_enable(struct pci_dev *dev, int nr_v= irtfn) =20 nres =3D 0; for (i =3D 0; i < PCI_SRIOV_NUM_BARS; i++) { + int vf_bar_sz =3D pci_iov_resource_size(dev, + pci_resource_to_iov(i)); bars |=3D (1 << pci_resource_to_iov(i)); res =3D &dev->resource[pci_resource_to_iov(i)]; - if (res->parent) - nres++; + if (!res->parent || vf_bar_sz * nr_virtfn > resource_size(res)) + continue; + + nres++; } if (nres !=3D iov->nres) { pci_err(dev, "not enough MMIO resources for SR-IOV\n"); --=20 2.47.0