Re: [PATCH v4 21/22] Add support for pmd_faults

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

 



On Mon, Dec 23, 2013 at 07:50:31AM -0700, Matthew Wilcox wrote:
> > > +	pgoff = ((address - vma->vm_start) >> PAGE_SHIFT) + vma->vm_pgoff;
> > > +	size = (i_size_read(inode) + PAGE_SIZE - 1) >> PAGE_SHIFT;
> > > +	if (pgoff >= size)
> > > +		return VM_FAULT_SIGBUS;
> > > +	if ((pgoff | PG_PMD_COLOUR) >= size)
> > > +		return VM_FAULT_FALLBACK;
> > 
> > I don't think it's necessary to fallback in this case.
> > Do you care about SIGBUS behaviour or what?
> 
> I'm looking to preserve the same behaviour we see with PTE mappings.  I mean,
> it's supposed to be _transparent_ huge pages, right?

Speaking of which ... we also need to check if the PMD is entirely within
the VMA.  So, this is needed:

@@ -308,6 +308,11 @@ static int do_xip_pmd_fault(struct vm_area_struct *vma, uns
        /* Fall back to PTEs if we're going to COW */
        if ((flags & FAULT_FLAG_WRITE) && !(vma->vm_flags & VM_SHARED))
                return VM_FAULT_FALLBACK;
+       /* Fall back to PTEs if the mapping would extend outside the VMA */
+       if ((address & ~PMD_MASK) < vma->vm_start)
+               return VM_FAULT_FALLBACK;
+       if (ALIGN(address, PMD_SIZE) >= vma->vm_end)
+               return VM_FAULT_FALLBACK;
 
        pgoff = ((address - vma->vm_start) >> PAGE_SHIFT) + vma->vm_pgoff;
        size = (i_size_read(inode) + PAGE_SIZE - 1) >> PAGE_SHIFT;

I'll fold that into the next round of patches.

-- 
Matthew Wilcox				Intel Open Source Technology Centre
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours.  We can't possibly take such
a retrograde step."
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux