On Tue, Feb 18, 2025 at 10:10:08PM +1100, Alexey Kardashevskiy wrote: > Add another resource#d_enc to allow mapping MMIO as > an encrypted/private region. I guess this means a sysfs file. Document alongside the others. > Unlike resourceN_wc, the node is added always as ability to > map MMIO as private depends on negotiation with the TSM which > happens quite late. Match capitalization (subject) and wrap to fill 75 columns. > +++ b/include/linux/pci.h > @@ -2129,7 +2129,7 @@ pci_alloc_irq_vectors(struct pci_dev *dev, unsigned int min_vecs, > */ > int pci_mmap_resource_range(struct pci_dev *dev, int bar, > struct vm_area_struct *vma, > - enum pci_mmap_state mmap_state, int write_combine); > + enum pci_mmap_state mmap_state, int write_combine, int enc); Wrap to fit in 80 columns. > > #ifndef arch_can_pci_mmap_wc > #define arch_can_pci_mmap_wc() 0 > diff --git a/drivers/pci/mmap.c b/drivers/pci/mmap.c > index 8da3347a95c4..4fd522aeb767 100644 > --- a/drivers/pci/mmap.c > +++ b/drivers/pci/mmap.c > @@ -23,7 +23,7 @@ static const struct vm_operations_struct pci_phys_vm_ops = { > > int pci_mmap_resource_range(struct pci_dev *pdev, int bar, > struct vm_area_struct *vma, > - enum pci_mmap_state mmap_state, int write_combine) > + enum pci_mmap_state mmap_state, int write_combine, int enc) Ditto. > { > unsigned long size; > int ret; > @@ -46,6 +46,15 @@ int pci_mmap_resource_range(struct pci_dev *pdev, int bar, > > vma->vm_ops = &pci_phys_vm_ops; > > + /* > + * Calling remap_pfn_range() directly as io_remap_pfn_range() > + * enforces shared mapping. s/Calling/Call/ > + */ > + if (enc) > + return remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff, > + vma->vm_end - vma->vm_start, > + vma->vm_page_prot); > + > return io_remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff, > vma->vm_end - vma->vm_start, > vma->vm_page_prot);