kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] vfio-pci: Use io_remap_pfn_range() for PCI IO memory
@ 2020-11-05 16:34 Jason Gunthorpe
  2020-11-05 23:39 ` Peter Xu
  0 siblings, 1 reply; 16+ messages in thread
From: Jason Gunthorpe @ 2020-11-05 16:34 UTC (permalink / raw)
  To: Cornelia Huck, kvm, Tom Lendacky; +Cc: Alex Williamson, Peter Xu

commit f8f6ae5d077a ("mm: always have io_remap_pfn_range() set
pgprot_decrypted()") allows drivers using mmap to put PCI memory mapped
BAR space into userspace to work correctly on AMD SME systems that default
to all memory encrypted.

Since vfio_pci_mmap_fault() is working with PCI memory mapped BAR space it
should be calling io_remap_pfn_range() otherwise it will not work on SME
systems.

Fixes: 11c4cd07ba11 ("vfio-pci: Fault mmaps to enable vma tracking")
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
---
 drivers/vfio/pci/vfio_pci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

The io_remap_pfn_range() commit is in Linus's tree and will be in rc3, but
there is no cross dependency here.

Tom says VFIO device assignment works OK with KVM, so I expect only things
like DPDK to be broken.

Don't have SME hardware, can't test.

diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
index fbd2b3404184ba..1853cc2548c966 100644
--- a/drivers/vfio/pci/vfio_pci.c
+++ b/drivers/vfio/pci/vfio_pci.c
@@ -1635,8 +1635,8 @@ static vm_fault_t vfio_pci_mmap_fault(struct vm_fault *vmf)
 
 	mutex_unlock(&vdev->vma_lock);
 
-	if (remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff,
-			    vma->vm_end - vma->vm_start, vma->vm_page_prot))
+	if (io_remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff,
+			       vma->vm_end - vma->vm_start, vma->vm_page_prot))
 		ret = VM_FAULT_SIGBUS;
 
 up_out:
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2020-11-30 15:36 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-05 16:34 [PATCH] vfio-pci: Use io_remap_pfn_range() for PCI IO memory Jason Gunthorpe
2020-11-05 23:39 ` Peter Xu
2020-11-16 15:53   ` Jason Gunthorpe
2020-11-16 21:43     ` Tom Lendacky
2020-11-16 23:20       ` Jason Gunthorpe
2020-11-17 15:33         ` Tom Lendacky
2020-11-17 15:54           ` Alex Williamson
2020-11-17 16:37             ` Tom Lendacky
2020-11-17 17:07               ` Jason Gunthorpe
2020-11-17 17:10                 ` Tom Lendacky
2020-11-17 15:57           ` Peter Xu
2020-11-17 16:34             ` Tom Lendacky
2020-11-17 18:17               ` Peter Xu
2020-11-26 20:13                 ` Jason Gunthorpe
2020-11-30 14:34                   ` Tom Lendacky
2020-11-30 15:34                     ` Alex Williamson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).