Re: [PATCH 7/7] vfio/pci: Remove map-on-fault behavior

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 10 Aug 2021 11:11:49 +0200
Christoph Hellwig <hch@xxxxxxxxxxxxx> wrote:

> On Thu, Aug 05, 2021 at 11:08:21AM -0600, Alex Williamson wrote:
> > +void vfio_pci_test_and_up_write_memory_lock(struct vfio_pci_device *vdev)
> > +{
> > +	if (vdev->zapped_bars && __vfio_pci_memory_enabled(vdev)) {
> > +		WARN_ON(vfio_device_io_remap_mapping_range(&vdev->vdev,
> > +			VFIO_PCI_INDEX_TO_OFFSET(VFIO_PCI_BAR0_REGION_INDEX),
> > +			VFIO_PCI_INDEX_TO_OFFSET(VFIO_PCI_ROM_REGION_INDEX) -
> > +			VFIO_PCI_INDEX_TO_OFFSET(VFIO_PCI_BAR0_REGION_INDEX)));
> > +		vdev->zapped_bars = false;  
> 
> Doing actual work inside a WARN_ON is pretty nasty.  Also the non-ONCE
> version here will lead to massive log splatter if it actually hits.
> 
> I'd prefer something like:
> 
> 	loff_t start = VFIO_PCI_INDEX_TO_OFFSET(VFIO_PCI_BAR0_REGION_INDEX);
> 	loff_t end = VFIO_PCI_INDEX_TO_OFFSET(VFIO_PCI_ROM_REGION_INDEX);
> 
> 	if (vdev->zapped_bars && __vfio_pci_memory_enabled(vdev)) {
> 		if (!vfio_device_io_remap_mapping_range(&vdev->vdev, start,
> 				end - start))
> 			vdev->zapped_bars = false;
> 		WARN_ON_ONCE(vdev->zapped_bars);
> 
> >  	vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
> > -	vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot);  
> 
> What is the story with this appearing earlier and disappearing here
> again?

We switched from io_remap_pfn_range() which includes this flag
implicitly, to vmf_insert_pfn() which does not, and back to
io_remap_pfn_range() when the fault handler is removed.

> > +extern void vfio_pci_test_and_up_write_memory_lock(struct vfio_pci_device
> > +						   *vdev);  
> 
> No need for the extern.

Thanks much for the reviews!

Alex




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux