From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=103.168.172.159 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796253587; b=eclJJ/DmTHVAj4HWbME3O9voZ9KKC287j1zyYIyncrzeM6xLjOOGIEF6KY5j9W24TlGz W7aaFWabvC/6xjf7kHaETecXi+v5uj1OYd0rEXARgaae0VvJDqVsN9hafwE4EAT2PxobE Ejt1MjuRlA1t9V9ZBBTx9aSBDWLrysbAbTBHW6YchCLmhruQ0bRBBVWmUah3tdu7m4mwu fGv+TNebgSotlE1RwdYMjB1dm0wn/SWLu7jfUlj8VZtI+phVPohpSLRY/WbzXsX0AQQdn P5ZsWIXCE6NbOHJQAlXU7pjth1dhX+mJ3AGIKHyp5h2mZGik9UFW3qlJctnTSI8XW9Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796253587; h=DMARC-Filter:Received:Received:DKIM-Signature:DKIM-Signature: X-DKIM2-Info:DKIM2-Signature:X-DKIM2-Info:Message-Instance: X-ME-Sender:X-ME-Received:X-ME-Proxy-Cause:X-ME-Proxy:Feedback-ID: Received:Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: X-Mailer:MIME-Version:Content-Type:Content-Transfer-Encoding; bh=abDu2bx5g7+RgxQM4+GHvjf+WhQIoFTEsax6R3eIkcM=; b=vZ/6qi4wLZWnrEWcc2f+B2aPus8dvdirb8FVfTrxVz/p4edoG9x3qKxDfErqc5o6ucsU k/5uOpiAptCNJz+cj3c03mwUxSYFoJoKBaaZxRcb04/xPHBGLBLeQVBJtFi0ziBWVAVoA 46bltaVx+9/J5QI/aILlrbwuWJV6qVXCPfgEN1VAfics4dKngqJIem06xP9oAhGDweoik xaGUW9ipx7cbb1GULdS+hmrjVuI3Z7w/YqmB0E7UrldOdSpT9fBGcsMIHOxSFKbzjxd2h pGnRQJVOF8txfjRZ3rza02WAG6joxjoURs9atenLATxgZafj/EFDH5pXgaMLjkfAB3A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=shazbot.org; spf=pass smtp.mailfrom=shazbot.org; dkim=pass header.d=shazbot.org header.i=@shazbot.org header.a=rsa-sha256 header.s=fm3 header.b=OFtnjpQ1; dkim=pass header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=NRES69dk; arc=none smtp.remote-ip=103.168.172.159 Received: from fhigh-a8-smtp.messagingengine.com (fhigh-a8-smtp.messagingengine.com [103.168.172.159]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E26E5606A68D for ; Wed, 2 Dec 2026 23:19:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E26E5606A68D 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, unprotected) header.d=shazbot.org header.i=@shazbot.org header.a=rsa-sha256 header.s=fm3 header.b=OFtnjpQ1; dkim=pass (2048-bit key, unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=NRES69dk Received: from phl-compute-01.internal (phl-compute-01.internal [10.202.2.41]) by mailfhigh.phl.internal (Postfix) with ESMTP id 2C9721400153 for ; Wed, 2 Dec 2026 18:19:46 -0500 (EST) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-01.internal (MEProxy); Wed, 02 Dec 2026 18:19:46 -0500 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=fm3; t=1796253586; x=1796339986; bh=abDu2bx5g7+RgxQM4+GHvjf+WhQIoFTEsax6R3eIkcM=; b= OFtnjpQ1F5eiIP0G2MuiL2+mPsKKJYpTrVcIeJL4IjepCyz3tHcBG7Fv8uTOQ+6c euSEZFtvbQX4l7sZ9VC/Ac7VV2Mk8I0tYT2PIhiT4JN8k87wcg50MxeGIqpOFNN+ Zrcxr0LuH0Dwabs5/1K47qAHXmRMTWD9ksJmE455L3qpM46ix85IEd1gRUBuZXGq mAXnC3Eg2C1v1j6QsBKR+Xbnm+TCSZogqI6xth0vYcw2g9b4EmSDVGn9ouYYF6dV /Gk8hox019M2vQrpnbnTF4xZ88pSEILZquTaqDqAszw6w0/BPONpBN9ptdYqFRP1 eUhXkw4QCbV6FT9YxH/zbw== 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=fm3; t=1796253586; x= 1796339986; bh=abDu2bx5g7+RgxQM4+GHvjf+WhQIoFTEsax6R3eIkcM=; b=N RES69dk8YV21OlzOVMuX1owrujclVuHqUGLNBylw/KIQGJfaWHsj0ZliHt59fKl2 mJv182pyNzn1PALCdHNt05cCrhko4jNZFHEXYvPnzYVgwxym7qgfhxl+DgTvhKDZ LyUhA3TAMxhYsli90GFb60X/YNPJX1w36AI7l1PqnJeMcBxwBQOyWhtJlceqQr1A mGWYDrje11jWc4ricfH4Rg9EtI5SdSBHLofSf1rs9f7sxr0tCJ0AcScVsTIYJfsK hpVWOCs1UK464KpNXUXu7jdYePvRlPczI6ZQjuo6xrI6KxPSiXvTXj/oSFk2odut 6M24u3D2Mb8E0C2o/vH3w== X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-09; repo=github.com/dkim2wg/interop; date=2026-11-03; sw=lmtpprox; action=sign d=shazbot.org a=rsa-sha256; DKIM2-Signature: i=1; m=1; t=1796253586; d=shazbot.org; mf=PGFsZXhAc2hhemJvdC5vcmc+; rt=PHZpcnR1YWxpemF0aW9uQGxpc3RzLmxpbnV4LmRldj4=; s=fm3:rsa-sha256:CjjC+HUeAzUYwz3H0bBijqh29DlAvgwg/i0UazTG+kP5aEx HdgyRtlGdVO9FGOQMk6TG2NqHSHM5B14Cl3e7Ztz66eYfatm40cTSjWKH8C8oRhO YSasd/d8es1X0n0Ftc62AkXxVYElCXj2Y1eF5ch5urcrWDEWYaw2LHEhkaDsNthu 6ZDUVIBgWuNdOFQHgbZ38+INazMtZSTNLSpx/9CCqUsKgBrkz/JubNa9NWDNHVhD VIOYkigVkUUmk0pi/CCMKZjK9sAwUbpZorVCXxUY96f2DTBxKNRr8Tgqi3N9rxQf 2EsWsSFIoeJW3IxrI7K9kTHzH1eT/kOSXURAKSg==; X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-09; repo=github.com/dkim2wg/interop; date=2026-11-03; sw=lmtpprox; action=mi-m=1; hc=12; hn=cc,content-transfer-encoding,content-type,date,feedback-id, from,in-reply-to,message-id,mime-version,references,subject,to; Message-Instance: m=1; h=sha256:VdkMEKqB0nVjxnz1KcToRkW46TD5ah+FrQFTkcpBgek=:9LV8F3kla2dw2hU8kWocUiPEFlOVWj98XnPQKI92muQ=; X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTEXyJb/eDIsSuK7ylBpLNPCpyBiPHtP5oCEDymQX6axQbKaf//wvBpF5DodnHZQmQ CPcje2n4s4+jBJlsN5S4zJn5/+3MY94vy8XAJ5zfIVL9vALh9DKVxdzS4+p+FXyDMg3Qq5 gCv7O1RNVQoPOK2cUfwQx8KrqlLE4ZKVuVahi8OTwdk1v0o4xuAJX32kPNM9Xxlm4sugYa hQIMy30wwn1jJAIi93mvI3Mj2yo8Ks3GSQbaVyIrn2V/fXGk345CghTD8xQ3I8y68y1+bp bwCW9rFjOYYdIvmp2b3gUCcXkFG16jep2G4r/+dNf77mkLDHUv/rGMo3vDMdWkfP5DoASr qBWcxEBWT8iu0wAYjyr2Sv+5OijNkiLn40bfucCdSFgRZPa5XOKin7cN4uvXOX+e+mTkQo FI3z2udHA+DWglBW9gjaZpgClFnoLEbDaWaoVTE08X3Oq4K1E5qQR+z0OTAOKqaYoFebr6 s3A1IHrT5oVX/HTZHDeiTZpouxKKSHhYR8j/Z5yPLWe1ilDaTw5W0lOp6WnjQ17mHNUQY8 jr7T0dJ3DE8LESAGXqTQ2sYXZJi0pBVhOZBRkBohR/dfrIqJ89k0Pej7E5VZPu0mzfTaDo uyUoQ2yvdh9xEOy+ro8a3CrHGSFuxc3WpChXw2bciHdvs4Sk+85kNS/CxBnA X-ME-Proxy: Feedback-ID: i03f14258:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 2 Dec 2026 18:19:44 -0500 (EST) Date: Wed, 2 Dec 2026 16:19:29 -0700 From: Alex Williamson To: Cc: , , , , , , , , , alex@shazbot.org Subject: Re: [PATCH 1/5] vfio/pci: Move the excluded windows out of vfio_pci_core_do_io_rw() Message-ID: <20261202161929.77d44151@shazbot.org> In-Reply-To: <20261202093250.1683744-2-mhonap@nvidia.com> References: <20261202093250.1683744-1-mhonap@nvidia.com> <20261202093250.1683744-2-mhonap@nvidia.com> X-Mailer: Claws Mail 4.4.0 (GTK 3.24.52; x86_64-pc-linux-gnu) X-Mailing-List: virtualization@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Wed, 2 Dec 2026 15:02:46 +0530 wrote: > From: Manish Honap > > vfio_pci_core_do_io_rw() fills reads with 0xff and drops writes in one > excluded window given by its caller. vfio_pci_bar_rw() sets it to the > MSI-X table or to the part of a ROM BAR past the ROM image. > vfio_pci_vga_rw() and nvgrace-gpu pass an empty window. > > The next patch for vfio-cxl series puts the MSI-X table on > a per-BAR list of excluded ranges, and a BAR can then have more than one > such range (CXL component register region range) The "next patch" reference should be avoided in commit logs, series are an ephemeral thing that exist on the mailing list, and especially here, it's not even referring to the next patch in this series. > Add a helper in vfio_pci_bar_rw() that sends the bytes before a range to > the device in a call of their own, so no device access runs into the > range, and fills or drops the bytes of the range. Use it for the MSI-X > table and for the ROM BAR past the ROM image. Remove the window > arguments from vfio_pci_core_do_io_rw() and its callers. > > No functional change. > > Signed-off-by: Manish Honap > --- > drivers/vfio/pci/nvgrace-gpu/main.c | 4 +- > drivers/vfio/pci/vfio_pci_rdwr.c | 115 ++++++++++++++++++---------- > include/linux/vfio_pci_core.h | 3 +- > 3 files changed, 76 insertions(+), 46 deletions(-) > > diff --git a/drivers/vfio/pci/nvgrace-gpu/main.c b/drivers/vfio/pci/nvgrace-gpu/main.c > index 5ddec340b73b..432f6b9c2842 100644 > --- a/drivers/vfio/pci/nvgrace-gpu/main.c > +++ b/drivers/vfio/pci/nvgrace-gpu/main.c > @@ -787,7 +787,7 @@ nvgrace_gpu_map_and_read(struct nvgrace_gpu_pci_core_device *nvdev, > ret = vfio_pci_core_do_io_rw(&nvdev->core_device, false, > nvdev->resmem.ioaddr, > buf, offset, mem_count, > - 0, 0, false, VFIO_PCI_IO_WIDTH_8); > + false, VFIO_PCI_IO_WIDTH_8); > } > > return ret; > @@ -925,7 +925,7 @@ nvgrace_gpu_map_and_write(struct nvgrace_gpu_pci_core_device *nvdev, > ret = vfio_pci_core_do_io_rw(&nvdev->core_device, false, > nvdev->resmem.ioaddr, > (char __user *)buf, pos, mem_count, > - 0, 0, true, VFIO_PCI_IO_WIDTH_8); > + true, VFIO_PCI_IO_WIDTH_8); > } > > return ret; > diff --git a/drivers/vfio/pci/vfio_pci_rdwr.c b/drivers/vfio/pci/vfio_pci_rdwr.c > index df8848087681..68008f28bcbe 100644 > --- a/drivers/vfio/pci/vfio_pci_rdwr.c > +++ b/drivers/vfio/pci/vfio_pci_rdwr.c > @@ -12,6 +12,7 @@ > > #include > #include > +#include > #include > #include > #include > @@ -126,66 +127,41 @@ VFIO_IORDWR(16) > VFIO_IORDWR(32) > VFIO_IORDWR(64) > > -/* > - * Read or write from an __iomem region (MMIO or I/O port) with an excluded > - * range which is inaccessible. The excluded range drops writes and fills > - * reads with -1. This is intended for handling MSI-X vector tables and > - * leftover space for ROM BARs. > - */ > +/* Read or write from an __iomem region (MMIO or I/O port) */ > ssize_t vfio_pci_core_do_io_rw(struct vfio_pci_core_device *vdev, bool test_mem, > void __iomem *io, char __user *buf, > - loff_t off, size_t count, size_t x_start, > - size_t x_end, bool iswrite, > + loff_t off, size_t count, bool iswrite, > enum vfio_pci_io_width max_width) I think there's a better shape to this series, and I think we should keep vfio_pci_core_do_io_rw() as the variant driver facing API. I'd propose the following sequence replacing 1 and 3, interleave the virtio patch as necessary: 1. Simple conversion from x_start, x_end to a range. Pass NULL for an empty range rather than {0, 0}. 2. Split static __vfio_pci_do_io_rw() from vfio_pci_core_do_io_rw() as the helper that reads contiguous chunks, called by the original function that retains the range information. 3. Convert from a range to a list_head. Callers allocate the list on the stack and vfio_pci_core_do_io_rw() learns to iterate a list of excluded ranges. 4. Introduce the per BAR excluded range list, populating MSI-X. ROM remains a stack allocated list based on pci_map_rom(). Common vfio_pci_core_do_io_rw() call sites now use the list_head on the BAR, while ROM, VGA, and variant driver decide whether to use a list_head or NULL. For example the nvgrace use case could pass the list_head from the BAR index or NULL. Thanks, Alex