Re: [PATCH] Enable mprotect on huge pages

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

 



On Fri, Feb 24, 2006 at 02:28:44PM -0800, Andrew Morton wrote:
> "Zhang, Yanmin" <[email protected]> wrote:
> >
> > From: Zhang, Yanmin <[email protected]>
> > 
> > 2.6.16-rc3 uses hugetlb on-demand paging, but it doesn_t support hugetlb
> > mprotect. My patch against 2.6.16-rc3 enables this capability.
> > 
> 
> Well I suppose that makes sense.  It does assume that the normal pte
> protection-changing APIs do the right thing on all architectures which
> implement huge pages.  That's quite possibly the case, but we should
> confirm that.

Well, it will need to be huge_ptep_get_and_clear() below, not the
normal version.  But pte_modify should be ok.  I'm not sure
pte_present() is safe, either, !pte_none() is what we use elsewhere in
hugetlb.c.

And.. looks like lazy_mmu_prot_update() is unsafe, too.  The only arch
which has something here (ia64) has a function which does icache
flushes on PAGE_SIZE only.

> > +
> > +void hugetlb_change_protection(struct vm_area_struct *vma,
> > +		unsigned long address, unsigned long end, pgprot_t newprot)
> > +{
> > +	struct mm_struct *mm = vma->vm_mm;
> > +	unsigned long start = address;
> > +	pte_t *ptep;
> > +	pte_t pte;
> > +
> > +	BUG_ON(address >= end);
> > +	flush_cache_range(vma, address, end);
> > +
> > +	spin_lock(&mm->page_table_lock);
> > +	for (; address < end; address += HPAGE_SIZE) {
> > +		ptep = huge_pte_offset(mm, address);
> > +		if (!ptep)
> > +			continue;
> > +		if (pte_present(*ptep)) {
> > +			pte = ptep_get_and_clear(mm, address, ptep);
> > +			pte = pte_modify(pte, newprot);
> > +			set_huge_pte_at(mm, addr, ptep, pte);
> > +			lazy_mmu_prot_update(pte);
> > +		}
> > +	}
> > +	spin_unlock(&mm->page_table_lock);
> > +
> > +	flush_tlb_range(vma, start, end);
> > +}
> 

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux