From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from fout-a1-smtp.messagingengine.com (fout-a1-smtp.messagingengine.com [103.168.172.144]) (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 6C6C93DEAC1; Wed, 29 Jul 2026 21:50:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.144 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785361834; cv=none; b=JQJxJu5Fw5awgq4Pus2EX9mBb9QU4Haa+L4+IRUDYD1YIFtmLGhQtpe4K3k59o+xWvu8TgQpLfRbLRxIQIzu+ssIPaP/We0guu/KN+eD4xxLDfVI5dTzT62pPNbnhv1RgfaI//T2tpwHiW2VG0GR4wKClDJpfrbnQQr9XcPJ/FA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785361834; c=relaxed/simple; bh=FztkdQ/dtyZfDkZCpEWl1/Wb9XGMy69s9lywCcQKXEE=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=eHqcpI+s3hHbVW+61Puh2vfOzFxYpyeEE82u/zA/151v6LEbJE8I7/diJAsRtTFWPwxs7pUXK/udenUps24pDPRtUr0lAJMDrVtTxe0H65QYXRHyeUr3epq0FSpNyG+iRXveVecROHXNgpKcvRb1XG9WF/ADzZZNcD18ZGBVGBc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=shazbot.org; spf=pass smtp.mailfrom=shazbot.org; dkim=pass (2048-bit key) header.d=shazbot.org header.i=@shazbot.org header.b=jzf8yYap; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=e25RWTak; arc=none smtp.client-ip=103.168.172.144 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=shazbot.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=shazbot.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=shazbot.org header.i=@shazbot.org header.b="jzf8yYap"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="e25RWTak" Received: from phl-compute-11.internal (phl-compute-11.internal [10.202.2.51]) by mailfout.phl.internal (Postfix) with ESMTP id 97FF0EC05EF; Wed, 29 Jul 2026 17:50:24 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-11.internal (MEProxy); Wed, 29 Jul 2026 17:50:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shazbot.org; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm2; t=1785361824; x=1785448224; bh=AmXe2mWigapj/LtemwBsm8npUZDPmncTefVXCJhauO0=; b= jzf8yYapzZgckZ3P+4z7UFSHPKZUO/8v+u0lPPxibb6u2h52cIAomNQd2fXse0xL SLuLggw3bOy5ryKKSp2WkQoDNfQcDHixv8WVN1X4vleSu4eYPEqkqfyDGpelanRO tWfuHGkNlwuBUBjfxlyyFGaCTK0aDypcX1amZPTd/LllKn2T8JeiH002vLkVcPQy qt/hRdc+Pw7YqSQwgazSEFCA//98Rt0ykNJlU5O4zQulYY8jk1ivtY+xDd8gcuzf J48b1j2JCGSbosTgxKkS1q63elVn5IG8wfVnOF9vtEtqTUoi5unvTLqXf5mqZiqL kvX0snenPAj7Ac6CEPIjBQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1785361824; x= 1785448224; bh=AmXe2mWigap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5nSOxJwFXREO4Vj+MzcY+RUw X-ME-Proxy: Feedback-ID: i03f14258:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 29 Jul 2026 17:50:23 -0400 (EDT) Date: Wed, 29 Jul 2026 15:50:21 -0600 From: Alex Williamson To: Farhan Ali Cc: Matthew Rosato , linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org, kvm@vger.kernel.org, borntraeger@linux.ibm.com, mattev@meta.com, schnelle@linux.ibm.com, alex@shazbot.org Subject: Re: [PATCH v1] vfio/pci: Avoid mapping BARs for devices with non-mappable BARs Message-ID: <20260729155021.64f7e1ba@shazbot.org> In-Reply-To: <42a3b06d-ecaa-4339-9472-7c592694f877@linux.ibm.com> References: <20260729181116.1373-1-alifm@linux.ibm.com> <46fede14-a740-4d66-98b3-c840e03e8634@linux.ibm.com> <20260729143603.175f60a7@shazbot.org> <42a3b06d-ecaa-4339-9472-7c592694f877@linux.ibm.com> X-Mailer: Claws Mail 4.4.0 (GTK 3.24.52; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Wed, 29 Jul 2026 14:32:45 -0700 Farhan Ali wrote: > On 7/29/2026 1:36 PM, Alex Williamson wrote: > > On Wed, 29 Jul 2026 13:28:46 -0700 > > Farhan Ali wrote: > > > >> On 7/29/2026 12:41 PM, Matthew Rosato wrote: > >>> On 7/29/26 2:11 PM, Farhan Ali wrote: > >>>> vfio_pci_core_map_bars() calls pci_iomap() to set up BAR resources, but not > >>>> all devices support having their BARs mapped by the CPU. The > >>>> non_mappable_bars flag indicates that a PCI device's BARs cannot be > >>>> accessed by the CPU. The ISM device on s390 is one such device. The BAR > >>>> size for an ISM device is 256 TiB, and attempting to map the BAR will lead > >>>> to warnings: > >>>> > >>>> vmalloc_node_range for size 281474976714752 failed: Address range > >>>> restricted to 0x2110bab00000 - 0x21903ab00000 > >>>> > >>>> Use pdev->non_mappable_bars to skip pci_iomap() for such devices. This flag > >>>> is set by the PCI core at enumeration time and already serves the same > >>>> purpose in vfio_pci_probe_mmaps(). > >>>> > >>>> Fixes: 05f2a68b407a ("vfio/pci: Set up BAR resources and maps in vfio_pci_core_enable()") > >>>> Reported-by: Christian Borntraeger > >>>> Signed-off-by: Farhan Ali > >>>> --- > >>>> drivers/vfio/pci/vfio_pci_core.c | 3 +++ > >>>> 1 file changed, 3 insertions(+) > >>>> > >>>> diff --git a/drivers/vfio/pci/vfio_pci_core.c b/drivers/vfio/pci/vfio_pci_core.c > >>>> index 3f11a9624b9c..6a184588ff23 100644 > >>>> --- a/drivers/vfio/pci/vfio_pci_core.c > >>>> +++ b/drivers/vfio/pci/vfio_pci_core.c > >>>> @@ -554,6 +554,9 @@ static void vfio_pci_core_map_bars(struct vfio_pci_core_device *vdev) > >>>> > >>>> vdev->barmap[bar] = IOMEM_ERR_PTR(-ENODEV); > >>>> > >>>> + if (pdev->non_mappable_bars) > >>>> + continue; > >>>> + > >>> This would work for the ISM case at least, but I wonder: should we check > >>> vdev->bar_mmap_supported[bar] instead? > >>> > >>> My question boils down to: do we still want messages for some of the > >>> cases where we set vdev->bar_mmap_supported[bar] = false in > >>> vfio_pci_probe_mmaps()? > >> AFAIU vfio_pci_probe_mmaps() is only called in > >> vfio_pci_core_finish_enable(). Since vfio_pci_core_map_bars() is called > >> in vfio_pci_core_enable(), and before vfio_pci_core_finish_enable(), > >> bar_mmap_supported would be false here for all devices. So I don't think > >> it would work here, unless I missed something? > > Also IO Port and sub-page MMIO BARs are things that do exist. Thanks, > > Just to clarify, are you suggesting we expand this check to also avoid > mapping IO port and sub-page MMIO BARs? Sorry, no, I'm not. I think we're conflating that the barmap is related to mmap access. The barmap itself is holding the iomap of the BAR, used for read/write. The only real relation to the mmap is that we request the resource via this path as well. Therefore not only is the ordering of setting up bar_mmap_supported wrong, it's flagging entirely the wrong thing here and keying on it would entirely break IO port and sub-page MMIO BAR access. Thanks, Alex